… | |
… | |
131 | } |
131 | } |
132 | |
132 | |
133 | return result; |
133 | return result; |
134 | } |
134 | } |
135 | |
135 | |
|
|
136 | /* check_formulae()- since we are doing a squential search on the |
|
|
137 | * formulae lists now, we have to be carefull that we dont have 2 |
|
|
138 | * formula with the exact same index value. Under the new nbatches |
|
|
139 | * code, it is possible to have multiples of ingredients in a cauldron |
|
|
140 | * which could result in an index formula mismatch. We *don't* check for |
|
|
141 | * that possibility here. -b.t. |
|
|
142 | */ |
|
|
143 | void |
|
|
144 | check_formulae (void) |
|
|
145 | { |
|
|
146 | recipelist *fl; |
|
|
147 | recipe *check, *formula; |
|
|
148 | int numb = 1; |
|
|
149 | |
|
|
150 | LOG (llevDebug, "Checking formulae lists...\n"); |
|
|
151 | |
|
|
152 | for (fl = formulalist; fl; fl = fl->next) |
|
|
153 | { |
|
|
154 | for (formula = fl->items; formula; formula = formula->next) |
|
|
155 | for (check = formula->next; check; check = check->next) |
|
|
156 | if (check->index == formula->index) |
|
|
157 | { |
|
|
158 | LOG (llevError, " ERROR: On %d ingred list: ", numb); |
|
|
159 | LOG (llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n", |
|
|
160 | formula->arch_name[0], &formula->title, check->arch_name[0], &check->title, formula->index); |
|
|
161 | } |
|
|
162 | numb++; |
|
|
163 | } |
|
|
164 | |
|
|
165 | LOG (llevDebug, "done.\n"); |
|
|
166 | |
|
|
167 | } |
|
|
168 | |
136 | /* |
169 | /* |
137 | * init_formulae() - Builds up the lists of formula from the file in |
170 | * init_formulae() - Builds up the lists of formula from the file in |
138 | * the libdir. -b.t. |
171 | * the libdir. -b.t. |
139 | */ |
172 | */ |
140 | void |
173 | void |
… | |
… | |
248 | |
281 | |
249 | LOG (llevDebug, "done.\n"); |
282 | LOG (llevDebug, "done.\n"); |
250 | close_and_delete (fp, comp); |
283 | close_and_delete (fp, comp); |
251 | /* Lastly, lets check for problems in formula we got */ |
284 | /* Lastly, lets check for problems in formula we got */ |
252 | check_formulae (); |
285 | check_formulae (); |
253 | } |
|
|
254 | |
|
|
255 | /* check_formulae()- since we are doing a squential search on the |
|
|
256 | * formulae lists now, we have to be carefull that we dont have 2 |
|
|
257 | * formula with the exact same index value. Under the new nbatches |
|
|
258 | * code, it is possible to have multiples of ingredients in a cauldron |
|
|
259 | * which could result in an index formula mismatch. We *don't* check for |
|
|
260 | * that possibility here. -b.t. |
|
|
261 | */ |
|
|
262 | void |
|
|
263 | check_formulae (void) |
|
|
264 | { |
|
|
265 | recipelist *fl; |
|
|
266 | recipe *check, *formula; |
|
|
267 | int numb = 1; |
|
|
268 | |
|
|
269 | LOG (llevDebug, "Checking formulae lists...\n"); |
|
|
270 | |
|
|
271 | for (fl = formulalist; fl; fl = fl->next) |
|
|
272 | { |
|
|
273 | for (formula = fl->items; formula; formula = formula->next) |
|
|
274 | for (check = formula->next; check; check = check->next) |
|
|
275 | if (check->index == formula->index) |
|
|
276 | { |
|
|
277 | LOG (llevError, " ERROR: On %d ingred list: ", numb); |
|
|
278 | LOG (llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n", |
|
|
279 | formula->arch_name[0], &formula->title, check->arch_name[0], &check->title, formula->index); |
|
|
280 | } |
|
|
281 | numb++; |
|
|
282 | } |
|
|
283 | |
|
|
284 | LOG (llevDebug, "done.\n"); |
|
|
285 | |
|
|
286 | } |
286 | } |
287 | |
287 | |
288 | /* Find a treasure with a matching name. The 'depth' parameter is |
288 | /* Find a treasure with a matching name. The 'depth' parameter is |
289 | * only there to prevent infinite loops in treasure lists (a list |
289 | * only there to prevent infinite loops in treasure lists (a list |
290 | * referencing another list pointing back to the first one). */ |
290 | * referencing another list pointing back to the first one). */ |
… | |
… | |
425 | cp = strchr (cp, ' ') + 1; |
425 | cp = strchr (cp, ' ') + 1; |
426 | |
426 | |
427 | return cp; |
427 | return cp; |
428 | } |
428 | } |
429 | |
429 | |
|
|
430 | int |
|
|
431 | numb_ingred (const char *buf) |
|
|
432 | { |
|
|
433 | int numb; |
|
|
434 | |
|
|
435 | if ((numb = atoi (buf))) |
|
|
436 | return numb; |
|
|
437 | else |
|
|
438 | return 1; |
|
|
439 | } |
|
|
440 | |
430 | /* strtoint() - we use this to convert buf into an integer |
441 | /* strtoint() - we use this to convert buf into an integer |
431 | * equal to the coadded sum of the (lowercase) character |
442 | * equal to the coadded sum of the (lowercase) character |
432 | * ASCII values in buf (times prepended integers). |
443 | * ASCII values in buf (times prepended integers). |
|
|
444 | * Some kind of hashing. |
433 | */ |
445 | */ |
434 | |
|
|
435 | int |
446 | int |
436 | strtoint (const char *buf) |
447 | strtoint (const char *buf) |
437 | { |
448 | { |
438 | const char *cp = ingred_name (buf); |
449 | const char *cp = ingred_name (buf); |
439 | int val = 0, len = strlen (cp), mult = numb_ingred (buf); |
450 | int val = 0, len = strlen (cp), mult = numb_ingred (buf); |
… | |
… | |
442 | { |
453 | { |
443 | val += tolower (*cp); |
454 | val += tolower (*cp); |
444 | cp++; |
455 | cp++; |
445 | len--; |
456 | len--; |
446 | } |
457 | } |
|
|
458 | |
447 | return val * mult; |
459 | return val * mult; |
448 | } |
460 | } |
449 | |
461 | |
450 | artifact * |
462 | artifact * |
451 | locate_recipe_artifact (const recipe *rp, size_t idx) |
463 | locate_recipe_artifact (const recipe *rp, size_t idx) |
… | |
… | |
457 | for (artifact *art = al->items; art; art = art->next) |
469 | for (artifact *art = al->items; art; art = art->next) |
458 | if (art->item->name == rp->title) |
470 | if (art->item->name == rp->title) |
459 | return art; |
471 | return art; |
460 | |
472 | |
461 | return 0; |
473 | return 0; |
462 | } |
|
|
463 | |
|
|
464 | int |
|
|
465 | numb_ingred (const char *buf) |
|
|
466 | { |
|
|
467 | int numb; |
|
|
468 | |
|
|
469 | if ((numb = atoi (buf))) |
|
|
470 | return numb; |
|
|
471 | else |
|
|
472 | return 1; |
|
|
473 | } |
474 | } |
474 | |
475 | |
475 | recipelist * |
476 | recipelist * |
476 | get_random_recipelist (void) |
477 | get_random_recipelist (void) |
477 | { |
478 | { |