… | |
… | |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* Basic stuff for use with the alchemy code. Clearly some of this stuff |
25 | /* Basic stuff for use with the alchemy code. Clearly some of this stuff |
26 | * could go into server/alchemy, but I left it here just in case it proves |
26 | * could go into server/alchemy, but I left it here just in case it proves |
27 | * more generally useful. |
27 | * more generally useful. |
28 | * |
28 | * |
29 | * Nov 1995 - file created by b.t. thomas@astro.psu.edu |
29 | * Nov 1995 - file created by b.t. thomas@astro.psu.edu |
30 | */ |
30 | */ |
31 | |
31 | |
32 | |
32 | |
33 | /* Our definition of 'formula' is any product of an alchemical process. |
33 | /* Our definition of 'formula' is any product of an alchemical process. |
34 | * Ingredients are just comma delimited list of archetype (or object) |
34 | * Ingredients are just comma delimited list of archetype (or object) |
35 | * names. |
35 | * names. |
36 | */ |
36 | */ |
37 | |
37 | |
38 | /* Example 'formula' entry in libdir/formulae: |
38 | /* Example 'formula' entry in libdir/formulae: |
39 | * object transparency |
39 | * object transparency |
40 | * chance 10 |
40 | * chance 10 |
… | |
… | |
102 | } |
102 | } |
103 | |
103 | |
104 | return fl; |
104 | return fl; |
105 | } |
105 | } |
106 | |
106 | |
107 | /* check_recipe() - makes sure we actually have the requested artifact |
107 | /* check_recipe() - makes sure we actually have the requested artifact |
108 | * and archetype. */ |
108 | * and archetype. */ |
109 | static int |
109 | static int |
110 | check_recipe (const recipe *rp) |
110 | check_recipe (const recipe *rp) |
111 | { |
111 | { |
112 | size_t i; |
112 | size_t i; |
… | |
… | |
166 | LOG (llevDebug, "done.\n"); |
166 | LOG (llevDebug, "done.\n"); |
167 | |
167 | |
168 | } |
168 | } |
169 | |
169 | |
170 | /* |
170 | /* |
171 | * init_formulae() - Builds up the lists of formula from the file in |
171 | * init_formulae() - Builds up the lists of formula from the file in |
172 | * the libdir. -b.t. |
172 | * the libdir. -b.t. |
173 | */ |
173 | */ |
174 | void |
174 | void |
175 | init_formulae () |
175 | init_formulae () |
176 | { |
176 | { |
177 | static int has_been_done = 0; |
177 | static int has_been_done = 0; |
… | |
… | |
243 | tmp = new linked_char; |
243 | tmp = new linked_char; |
244 | |
244 | |
245 | tmp->name = cp; |
245 | tmp->name = cp; |
246 | tmp->next = formula->ingred; |
246 | tmp->next = formula->ingred; |
247 | formula->ingred = tmp; |
247 | formula->ingred = tmp; |
248 | /* each ingredient's ASCII value is coadded. Later on this |
248 | /* each ingredient's ASCII value is coadded. Later on this |
249 | * value will be used allow us to search the formula lists |
249 | * value will be used allow us to search the formula lists |
250 | * quickly for the right recipe. |
250 | * quickly for the right recipe. |
251 | */ |
251 | */ |
252 | formula->index += strtoint (cp); |
252 | formula->index += strtoint (cp); |
253 | } |
253 | } |
254 | while ((cp = next)); |
254 | while ((cp = next)); |
255 | |
255 | |
… | |
… | |
345 | else |
345 | else |
346 | return 1; |
346 | return 1; |
347 | } |
347 | } |
348 | |
348 | |
349 | /* strtoint() - we use this to convert buf into an integer |
349 | /* strtoint() - we use this to convert buf into an integer |
350 | * equal to the coadded sum of the (lowercase) character |
350 | * equal to the coadded sum of the (lowercase) character |
351 | * ASCII values in buf (times prepended integers). |
351 | * ASCII values in buf (times prepended integers). |
352 | * Some kind of hashing. |
352 | * Some kind of hashing. |
353 | */ |
353 | */ |
354 | int |
354 | int |
355 | strtoint (const char *buf) |
355 | strtoint (const char *buf) |