… | |
… | |
138 | } else if (!strncmp(cp, "keycode", 7)) { |
138 | } else if (!strncmp(cp, "keycode", 7)) { |
139 | formula->keycode = add_string(strchr(cp,' ') + 1); |
139 | formula->keycode = add_string(strchr(cp,' ') + 1); |
140 | } else if (sscanf(cp, "trans %d", &value)) { |
140 | } else if (sscanf(cp, "trans %d", &value)) { |
141 | formula->transmute = (uint16)value; |
141 | formula->transmute = (uint16)value; |
142 | } else if (sscanf(cp, "yield %d", &value)) { |
142 | } else if (sscanf(cp, "yield %d", &value)) { |
143 | formula->yield = (uint16)value; |
143 | formula->yield = (uint16)value; |
144 | } else if (sscanf(cp, "chance %d", &value)) { |
144 | } else if (sscanf(cp, "chance %d", &value)) { |
145 | formula->chance = (uint16)value; |
145 | formula->chance = (uint16)value; |
146 | } else if (sscanf(cp, "exp %d", &value)) { |
146 | } else if (sscanf(cp, "exp %d", &value)) { |
147 | formula->exp = (uint16)value; |
147 | formula->exp = (uint16)value; |
148 | } else if (sscanf(cp, "diff %d", &value)) { |
148 | } else if (sscanf(cp, "diff %d", &value)) { |
149 | formula->diff = (uint16)value; |
149 | formula->diff = (uint16)value; |
150 | } else if (!strncmp(cp, "ingred",6)) { |
150 | } else if (!strncmp(cp, "ingred",6)) { |
151 | int numb_ingred = 1; |
151 | int numb_ingred = 1; |
152 | cp = strchr(cp,' ') + 1; |
152 | cp = strchr(cp,' ') + 1; |
153 | do { |
153 | do { |
154 | if ((next=strchr(cp,','))!=NULL) |
154 | if ((next=strchr(cp,','))!=NULL) |
155 | {*(next++) = '\0'; numb_ingred++;} |
155 | {*(next++) = '\0'; numb_ingred++;} |
156 | tmp = (linked_char*) malloc(sizeof(linked_char)); |
156 | tmp = (linked_char*) malloc(sizeof(linked_char)); |
157 | tmp->name = add_string(cp); |
157 | tmp->name = add_string(cp); |
158 | tmp->next = formula->ingred; |
158 | tmp->next = formula->ingred; |
159 | formula->ingred = tmp; |
159 | formula->ingred = tmp; |
160 | /* each ingredient's ASCII value is coadded. Later on this |
160 | /* each ingredient's ASCII value is coadded. Later on this |
161 | * value will be used allow us to search the formula lists |
161 | * value will be used allow us to search the formula lists |
162 | * quickly for the right recipe. |
162 | * quickly for the right recipe. |
163 | */ |
163 | */ |
164 | formula->index += strtoint(cp); |
164 | formula->index += strtoint(cp); |
165 | } while ((cp=next)!=NULL); |
165 | } while ((cp=next)!=NULL); |
166 | /* now find the correct (# of ingred ordered) formulalist */ |
166 | /* now find the correct (# of ingred ordered) formulalist */ |
167 | fl=formulalist; |
167 | fl=formulalist; |
168 | while(numb_ingred!=1) { |
168 | while(numb_ingred!=1) { |
169 | if(!fl->next) |
169 | if(!fl->next) |
170 | fl->next = init_recipelist(); |
170 | fl->next = init_recipelist(); |
171 | fl = fl->next; |
171 | fl = fl->next; |
172 | numb_ingred--; |
172 | numb_ingred--; |
173 | } |
173 | } |
174 | fl->total_chance += formula->chance; |
174 | fl->total_chance += formula->chance; |
175 | fl->number++; |
175 | fl->number++; |
176 | formula->next = fl->items; |
176 | formula->next = fl->items; |
177 | fl->items = formula; |
177 | fl->items = formula; |
178 | } else if (!strncmp(cp, "arch",4)) { |
178 | } else if (!strncmp(cp, "arch",4)) { |
179 | build_stringlist(strchr(cp, ' ')+1, &formula->arch_name, &formula->arch_names); |
179 | build_stringlist(strchr(cp, ' ')+1, &formula->arch_name, &formula->arch_names); |
180 | (void) check_recipe(formula); |
180 | (void) check_recipe(formula); |
181 | } else if (!strncmp(cp, "skill", 5)) { |
181 | } else if (!strncmp(cp, "skill", 5)) { |
182 | formula->skill = add_string(strchr(cp, ' ')+1); |
182 | formula->skill = add_string(strchr(cp, ' ')+1); |
183 | } else if (!strncmp(cp, "cauldron", 8)) { |
183 | } else if (!strncmp(cp, "cauldron", 8)) { |
184 | formula->cauldron = add_string(strchr(cp, ' ')+1); |
184 | formula->cauldron = add_string(strchr(cp, ' ')+1); |
185 | } else |
185 | } else |
186 | LOG(llevError,"Unknown input in file %s: %s\n", filename, buf); |
186 | LOG(llevError,"Unknown input in file %s: %s\n", filename, buf); |
187 | } |
187 | } |
188 | LOG(llevDebug,"done.\n"); |
188 | LOG(llevDebug,"done.\n"); |
189 | close_and_delete(fp, comp); |
189 | close_and_delete(fp, comp); |
… | |
… | |
229 | int num_ingred=1; |
229 | int num_ingred=1; |
230 | |
230 | |
231 | fprintf(logfile, "\n"); |
231 | fprintf(logfile, "\n"); |
232 | while(fl) { |
232 | while(fl) { |
233 | fprintf(logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", |
233 | fprintf(logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", |
234 | num_ingred, num_ingred>1?"s.":".",fl->number,fl->total_chance); |
234 | num_ingred, num_ingred>1?"s.":".",fl->number,fl->total_chance); |
235 | for (formula=fl->items; formula!=NULL; formula=formula->next) { |
235 | for (formula=fl->items; formula!=NULL; formula=formula->next) { |
236 | artifact *art=NULL; |
236 | artifact *art=NULL; |
237 | char buf[MAX_BUF]; |
237 | char buf[MAX_BUF]; |
238 | size_t i; |
238 | size_t i; |
239 | |
239 | |
240 | for (i = 0; i < formula->arch_names; i++) { |
240 | for (i = 0; i < formula->arch_names; i++) { |
241 | const char *string = formula->arch_name[i]; |
241 | const char *string = formula->arch_name[i]; |
242 | if(find_archetype(string)!=NULL) { |
242 | if(find_archetype(string)!=NULL) { |
243 | art = locate_recipe_artifact(formula, i); |
243 | art = locate_recipe_artifact(formula, i); |
244 | if (!art && strcmp(formula->title,"NONE")) |
244 | if (!art && strcmp(formula->title,"NONE")) |
245 | LOG(llevError,"Formula %s has no artifact\n",formula->title); |
245 | LOG(llevError,"Formula %s has no artifact\n",formula->title); |
246 | else { |
246 | else { |
247 | if(strcmp(formula->title,"NONE")) |
247 | if(strcmp(formula->title,"NONE")) |
248 | sprintf(buf,"%s of %s",string,formula->title); |
248 | sprintf(buf,"%s of %s",string,formula->title); |
249 | else |
249 | else |
250 | sprintf(buf,"%s",string); |
250 | sprintf(buf,"%s",string); |
251 | fprintf(logfile,"%-30s(%d) bookchance %3d ",buf,formula->index, |
251 | fprintf(logfile,"%-30s(%d) bookchance %3d ",buf,formula->index, |
252 | formula->chance); |
252 | formula->chance); |
253 | fprintf(logfile,"skill %s",formula->skill); |
253 | fprintf(logfile,"skill %s",formula->skill); |
254 | fprintf(logfile,"\n"); |
254 | fprintf(logfile,"\n"); |
255 | if (formula->ingred !=NULL) { |
255 | if (formula->ingred !=NULL) { |
256 | int nval=0,tval=0; |
256 | int nval=0,tval=0; |
257 | fprintf(logfile,"\tIngred: "); |
257 | fprintf(logfile,"\tIngred: "); |
258 | for (next=formula->ingred; next!=NULL; next=next->next) { |
258 | for (next=formula->ingred; next!=NULL; next=next->next) { |
259 | if(nval!=0) fprintf(logfile,","); |
259 | if(nval!=0) fprintf(logfile,","); |
260 | fprintf(logfile,"%s(%d)",next->name,(nval=strtoint(next->name))); |
260 | fprintf(logfile,"%s(%d)",next->name,(nval=strtoint(next->name))); |
261 | tval += nval; |
261 | tval += nval; |
262 | } |
262 | } |
263 | fprintf(logfile,"\n"); |
263 | fprintf(logfile,"\n"); |
264 | if(tval!=formula->index) fprintf(logfile, "WARNING:ingredient list and formula values not equal.\n"); |
264 | if(tval!=formula->index) fprintf(logfile, "WARNING:ingredient list and formula values not equal.\n"); |
265 | } |
265 | } |
266 | if (formula->skill != NULL) |
266 | if (formula->skill != NULL) |
267 | fprintf(logfile, "\tSkill Required: %s", formula->skill); |
267 | fprintf(logfile, "\tSkill Required: %s", formula->skill); |
268 | if (formula->cauldron != NULL) |
268 | if (formula->cauldron != NULL) |
269 | fprintf(logfile, "\tCauldron: %s\n", formula->cauldron); |
269 | fprintf(logfile, "\tCauldron: %s\n", formula->cauldron); |
270 | fprintf(logfile, "\tDifficulty: %d\t Exp: %d\n", formula->diff, |
270 | fprintf(logfile, "\tDifficulty: %d\t Exp: %d\n", formula->diff, |
271 | formula->exp); |
271 | formula->exp); |
272 | } |
272 | } |
273 | } else |
273 | } else |
274 | LOG(llevError,"Can't find archetype:%s for formula %s\n", string, |
274 | LOG(llevError,"Can't find archetype:%s for formula %s\n", string, |
275 | formula->title); |
275 | formula->title); |
276 | } |
276 | } |
277 | } |
277 | } |
278 | fprintf(logfile,"\n"); |
278 | fprintf(logfile,"\n"); |
279 | fl = fl->next; |
279 | fl = fl->next; |
280 | num_ingred++; |
280 | num_ingred++; |
… | |
… | |
292 | if (depth > 10) |
292 | if (depth > 10) |
293 | return NULL; |
293 | return NULL; |
294 | while (t != NULL) |
294 | while (t != NULL) |
295 | { |
295 | { |
296 | if (t->name != NULL) |
296 | if (t->name != NULL) |
297 | { |
297 | { |
298 | tl = find_treasurelist (t->name); |
298 | tl = find_treasurelist (t->name); |
299 | at = find_treasure_by_name (tl->items, name, depth + 1); |
299 | at = find_treasure_by_name (tl->items, name, depth + 1); |
300 | if (at != NULL) |
300 | if (at != NULL) |
301 | return at; |
301 | return at; |
302 | } |
302 | } |
303 | else |
303 | else |
304 | { |
304 | { |
305 | if (! strcasecmp (t->item->clone.name, name)) |
305 | if (! strcasecmp (t->item->clone.name, name)) |
306 | return t->item; |
306 | return t->item; |
307 | } |
307 | } |
308 | if (t->next_yes != NULL) |
308 | if (t->next_yes != NULL) |
309 | { |
309 | { |
310 | at = find_treasure_by_name (t->next_yes, name, depth); |
310 | at = find_treasure_by_name (t->next_yes, name, depth); |
311 | if (at != NULL) |
311 | if (at != NULL) |
312 | return at; |
312 | return at; |
313 | } |
313 | } |
314 | if (t->next_no != NULL) |
314 | if (t->next_no != NULL) |
315 | { |
315 | { |
316 | at = find_treasure_by_name (t->next_no, name, depth); |
316 | at = find_treasure_by_name (t->next_no, name, depth); |
317 | if (at != NULL) |
317 | if (at != NULL) |
318 | return at; |
318 | return at; |
319 | } |
319 | } |
320 | t = t->next; |
320 | t = t->next; |
321 | } |
321 | } |
322 | return NULL; |
322 | return NULL; |
323 | } |
323 | } |
324 | |
324 | |
… | |
… | |
354 | mult = 1; |
354 | mult = 1; |
355 | /* first, try to match the name of an archetype */ |
355 | /* first, try to match the name of an archetype */ |
356 | for (at = first_archetype; at != NULL; at = at->next) |
356 | for (at = first_archetype; at != NULL; at = at->next) |
357 | { |
357 | { |
358 | if (at->clone.title != NULL) |
358 | if (at->clone.title != NULL) |
359 | { |
359 | { |
360 | /* inefficient, but who cares? */ |
360 | /* inefficient, but who cares? */ |
361 | sprintf (part1, "%s %s", at->clone.name, at->clone.title); |
361 | sprintf (part1, "%s %s", at->clone.name, at->clone.title); |
362 | if (! strcasecmp (part1, name)) |
362 | if (! strcasecmp (part1, name)) |
363 | return mult * at->clone.value; |
363 | return mult * at->clone.value; |
364 | } |
364 | } |
365 | if (! strcasecmp (at->clone.name, name)) |
365 | if (! strcasecmp (at->clone.name, name)) |
366 | return mult * at->clone.value; |
366 | return mult * at->clone.value; |
367 | } |
367 | } |
368 | /* second, try to match an artifact ("arch of something") */ |
368 | /* second, try to match an artifact ("arch of something") */ |
369 | cp = strstr (name, " of "); |
369 | cp = strstr (name, " of "); |
370 | if (cp != NULL) |
370 | if (cp != NULL) |
371 | { |
371 | { |
372 | strcpy (part1, name); |
372 | strcpy (part1, name); |
373 | part1[cp - name] = '\0'; |
373 | part1[cp - name] = '\0'; |
374 | strcpy (part2, cp + 4); |
374 | strcpy (part2, cp + 4); |
375 | /* find the first archetype matching the first part of the name */ |
375 | /* find the first archetype matching the first part of the name */ |
376 | for (at = first_archetype; at != NULL; at = at->next) |
376 | for (at = first_archetype; at != NULL; at = at->next) |
377 | if (! strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
377 | if (! strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
378 | break; |
378 | break; |
379 | if (at != NULL) |
379 | if (at != NULL) |
380 | { |
380 | { |
381 | /* find the first artifact derived from that archetype (same type) */ |
381 | /* find the first artifact derived from that archetype (same type) */ |
382 | for (al = first_artifactlist; al != NULL; al = al->next) |
382 | for (al = first_artifactlist; al != NULL; al = al->next) |
383 | if (al->type == at->clone.type) |
383 | if (al->type == at->clone.type) |
384 | { |
384 | { |
385 | for (art = al->items; art != NULL; art = art->next) |
385 | for (art = al->items; art != NULL; art = art->next) |
386 | if (! strcasecmp (art->item->name, part2)) |
386 | if (! strcasecmp (art->item->name, part2)) |
387 | return mult * at->clone.value * art->item->value; |
387 | return mult * at->clone.value * art->item->value; |
|
|
388 | } |
388 | } |
389 | } |
389 | } |
|
|
390 | } |
390 | } |
391 | /* third, try to match a body part ("arch's something") */ |
391 | /* third, try to match a body part ("arch's something") */ |
392 | cp = strstr (name, "'s "); |
392 | cp = strstr (name, "'s "); |
393 | if (cp != NULL) |
393 | if (cp != NULL) |
394 | { |
394 | { |
395 | strcpy (part1, name); |
395 | strcpy (part1, name); |
396 | part1[cp - name] = '\0'; |
396 | part1[cp - name] = '\0'; |
397 | strcpy (part2, cp + 3); |
397 | strcpy (part2, cp + 3); |
398 | /* examine all archetypes matching the first part of the name */ |
398 | /* examine all archetypes matching the first part of the name */ |
399 | for (at = first_archetype; at != NULL; at = at->next) |
399 | for (at = first_archetype; at != NULL; at = at->next) |
400 | if (! strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
400 | if (! strcasecmp (at->clone.name, part1) && at->clone.title == NULL) |
401 | { |
401 | { |
402 | if (at->clone.randomitems != NULL) |
402 | if (at->clone.randomitems != NULL) |
403 | { |
403 | { |
404 | at2 = find_treasure_by_name (at->clone.randomitems->items, |
404 | at2 = find_treasure_by_name (at->clone.randomitems->items, |
405 | part2, 0); |
405 | part2, 0); |
406 | if (at2 != NULL) |
406 | if (at2 != NULL) |
407 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
407 | return mult * at2->clone.value * isqrt (at->clone.level * 2); |
408 | } |
408 | } |
409 | } |
409 | } |
410 | } |
410 | } |
411 | /* failed to find any matching items -- formula should be checked */ |
411 | /* failed to find any matching items -- formula should be checked */ |
412 | return -1; |
412 | return -1; |
413 | } |
413 | } |
414 | |
414 | |
… | |
… | |
424 | long tcost; |
424 | long tcost; |
425 | |
425 | |
426 | fprintf (logfile, "\n"); |
426 | fprintf (logfile, "\n"); |
427 | while (fl) { |
427 | while (fl) { |
428 | fprintf(logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", |
428 | fprintf(logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", |
429 | num_ingred, num_ingred>1?"s.":".",fl->number,fl->total_chance); |
429 | num_ingred, num_ingred>1?"s.":".",fl->number,fl->total_chance); |
430 | for (formula = fl->items; formula != NULL; formula = formula->next) { |
430 | for (formula = fl->items; formula != NULL; formula = formula->next) { |
431 | artifact *art=NULL; |
431 | artifact *art=NULL; |
432 | archetype *at=NULL; |
432 | archetype *at=NULL; |
433 | char buf[MAX_BUF]; |
433 | char buf[MAX_BUF]; |
434 | size_t i; |
434 | size_t i; |
435 | |
435 | |
436 | for (i = 0; i < formula->arch_names; i++) { |
436 | for (i = 0; i < formula->arch_names; i++) { |
437 | const char *string = formula->arch_name[i]; |
437 | const char *string = formula->arch_name[i]; |
438 | if ((at = find_archetype (string)) != NULL) { |
438 | if ((at = find_archetype (string)) != NULL) { |
439 | art = locate_recipe_artifact (formula, i); |
439 | art = locate_recipe_artifact (formula, i); |
440 | if (!art && strcmp (formula->title,"NONE")) |
440 | if (!art && strcmp (formula->title,"NONE")) |
441 | LOG (llevError, "Formula %s has no artifact\n", formula->title); |
441 | LOG (llevError, "Formula %s has no artifact\n", formula->title); |
442 | else |
442 | else |
443 | { |
443 | { |
444 | if (! strcmp (formula->title, "NONE")) |
444 | if (! strcmp (formula->title, "NONE")) |
445 | sprintf (buf, "%s", string); |
445 | sprintf (buf, "%s", string); |
446 | else |
446 | else |
447 | sprintf (buf, "%s of %s", string, formula->title); |
447 | sprintf (buf, "%s of %s", string, formula->title); |
448 | fprintf (logfile, "\n%-40s bookchance %3d skill %s\n", |
448 | fprintf (logfile, "\n%-40s bookchance %3d skill %s\n", |
449 | buf, formula->chance, formula->skill); |
449 | buf, formula->chance, formula->skill); |
450 | if (formula->ingred !=NULL) |
450 | if (formula->ingred !=NULL) |
451 | { |
451 | { |
452 | tcost = 0; |
452 | tcost = 0; |
453 | for (next = formula->ingred; next != NULL; next = next->next) |
453 | for (next = formula->ingred; next != NULL; next = next->next) |
454 | { |
454 | { |
455 | cost = find_ingred_cost (next->name); |
455 | cost = find_ingred_cost (next->name); |
456 | if (cost < 0) |
456 | if (cost < 0) |
457 | num_errors++; |
457 | num_errors++; |
458 | fprintf (logfile,"\t%-33s%5ld\n", next->name, cost); |
458 | fprintf (logfile,"\t%-33s%5ld\n", next->name, cost); |
459 | if (cost < 0 || tcost < 0) |
459 | if (cost < 0 || tcost < 0) |
460 | tcost = -1; |
460 | tcost = -1; |
461 | else |
461 | else |
462 | tcost += cost; |
462 | tcost += cost; |
463 | } |
463 | } |
464 | if (art != NULL && art->item != NULL) |
464 | if (art != NULL && art->item != NULL) |
465 | cost = at->clone.value * art->item->value; |
465 | cost = at->clone.value * art->item->value; |
466 | else |
466 | else |
467 | cost = at->clone.value; |
467 | cost = at->clone.value; |
468 | fprintf (logfile, "\t\tBuying result costs: %5ld", cost); |
468 | fprintf (logfile, "\t\tBuying result costs: %5ld", cost); |
469 | if (formula->yield > 1) |
469 | if (formula->yield > 1) |
470 | { |
470 | { |
471 | fprintf (logfile, " to %ld (max %d items)\n", |
471 | fprintf (logfile, " to %ld (max %d items)\n", |
472 | cost * formula->yield, formula->yield); |
472 | cost * formula->yield, formula->yield); |
473 | cost = cost * (formula->yield + 1L) / 2L; |
473 | cost = cost * (formula->yield + 1L) / 2L; |
474 | } |
474 | } |
475 | else |
475 | else |
476 | fprintf (logfile, "\n"); |
476 | fprintf (logfile, "\n"); |
477 | fprintf (logfile, "\t\tIngredients cost: %5ld\n\t\tComment: ", tcost); |
477 | fprintf (logfile, "\t\tIngredients cost: %5ld\n\t\tComment: ", tcost); |
478 | if (tcost < 0) |
478 | if (tcost < 0) |
479 | fprintf (logfile, "Could not find some ingredients. Check the formula!\n"); |
479 | fprintf (logfile, "Could not find some ingredients. Check the formula!\n"); |
480 | else if (tcost > cost) |
480 | else if (tcost > cost) |
481 | fprintf (logfile, "Ingredients are much too expensive. Useless formula.\n"); |
481 | fprintf (logfile, "Ingredients are much too expensive. Useless formula.\n"); |
482 | else if (tcost * 2L > cost) |
482 | else if (tcost * 2L > cost) |
483 | fprintf (logfile, "Ingredients are too expensive.\n"); |
483 | fprintf (logfile, "Ingredients are too expensive.\n"); |
484 | else if (tcost * 10L < cost) |
484 | else if (tcost * 10L < cost) |
485 | fprintf (logfile, "Ingredients are too cheap.\n"); |
485 | fprintf (logfile, "Ingredients are too cheap.\n"); |
486 | else |
486 | else |
487 | fprintf (logfile, "OK.\n"); |
487 | fprintf (logfile, "OK.\n"); |
488 | } |
488 | } |
489 | } |
489 | } |
490 | } |
490 | } |
491 | else |
491 | else |
492 | LOG(llevError, "Can't find archetype:%s for formula %s\n", string, |
492 | LOG(llevError, "Can't find archetype:%s for formula %s\n", string, |
493 | formula->title); |
493 | formula->title); |
494 | } |
494 | } |
495 | } |
495 | } |
496 | fprintf (logfile,"\n"); |
496 | fprintf (logfile,"\n"); |
497 | fl = fl->next; |
497 | fl = fl->next; |
498 | num_ingred++; |
498 | num_ingred++; |
499 | } |
499 | } |
500 | if (num_errors > 0) |
500 | if (num_errors > 0) |
501 | fprintf (logfile, "WARNING: %d objects required by the formulae do not exist in the game.\n", |
501 | fprintf (logfile, "WARNING: %d objects required by the formulae do not exist in the game.\n", |
502 | num_errors); |
502 | num_errors); |
503 | } |
503 | } |
504 | |
504 | |
505 | const char * ingred_name (const char *name) { |
505 | const char * ingred_name (const char *name) { |
506 | const char *cp=name; |
506 | const char *cp=name; |
507 | |
507 | |
… | |
… | |
595 | recipe *formula=NULL,*next; |
595 | recipe *formula=NULL,*next; |
596 | linked_char *lchar, *charnext; |
596 | linked_char *lchar, *charnext; |
597 | |
597 | |
598 | LOG(llevDebug,"Freeing all the recipes\n"); |
598 | LOG(llevDebug,"Freeing all the recipes\n"); |
599 | for (fl=formulalist; fl!=NULL; fl=flnext) { |
599 | for (fl=formulalist; fl!=NULL; fl=flnext) { |
600 | flnext=fl->next; |
600 | flnext=fl->next; |
601 | |
601 | |
602 | for (formula=fl->items; formula!=NULL; formula=next) { |
602 | for (formula=fl->items; formula!=NULL; formula=next) { |
603 | next=formula->next; |
603 | next=formula->next; |
604 | |
604 | |
605 | free(formula->arch_name[0]); |
605 | free(formula->arch_name[0]); |
606 | free(formula->arch_name); |
606 | free(formula->arch_name); |
607 | if (formula->title) |
607 | if (formula->title) |
608 | free_string(formula->title); |
608 | free_string(formula->title); |
609 | if (formula->skill) |
609 | if (formula->skill) |
610 | free_string(formula->skill); |
610 | free_string(formula->skill); |
611 | if (formula->cauldron) |
611 | if (formula->cauldron) |
612 | free_string(formula->cauldron); |
612 | free_string(formula->cauldron); |
613 | for (lchar=formula->ingred; lchar; lchar=charnext) { |
613 | for (lchar=formula->ingred; lchar; lchar=charnext) { |
614 | charnext=lchar->next; |
614 | charnext=lchar->next; |
615 | free_string(lchar->name); |
615 | free_string(lchar->name); |
616 | free(lchar); |
616 | free(lchar); |
617 | } |
617 | } |
618 | free(formula); |
618 | free(formula); |
619 | } |
619 | } |
620 | free(fl); |
620 | free(fl); |
621 | } |
621 | } |
622 | } |
622 | } |
623 | |
623 | |
624 | /** |
624 | /** |
625 | * Split a comma separated string list into words. |
625 | * Split a comma separated string list into words. |