ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/alchemy.C
(Generate patch)

Comparing deliantra/server/server/alchemy.C (file contents):
Revision 1.31 by root, Mon Sep 29 10:20:48 2008 UTC vs.
Revision 1.42 by sf-marcmagus, Fri Oct 16 16:29:47 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * 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>
22 */ 23 */
23 24
24/* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */ 25/* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */
55 "rattles", 56 "rattles",
56 "makes chugging sounds", 57 "makes chugging sounds",
57 "smokes heavily for a while" 58 "smokes heavily for a while"
58}; 59};
59 60
60
61static int is_defined_recipe (const recipe *rp, const object *cauldron, object *caster); 61static int is_defined_recipe (const recipe *rp, const object *cauldron, object *caster);
62static recipe *find_recipe (recipelist * fl, int formula, object *ingredients); 62static recipe *find_recipe (recipelist * fl, int formula, object *ingredients);
63
64 63
65/** Returns a random selection from cauldron_effect[] */ 64/** Returns a random selection from cauldron_effect[] */
66static const char * 65static const char *
67cauldron_sound (void) 66cauldron_sound (void)
68{ 67{
69 int size = sizeof (cauldron_effect) / sizeof (char *); 68 int size = sizeof (cauldron_effect) / sizeof (char *);
70 69
71 return cauldron_effect[rndm (0, size - 1)]; 70 return cauldron_effect[rndm (0, size - 1)];
72} 71}
73 72
74/** 73/**
75 * Main part of the ALCHEMY code. From this we call fctns 74 * Main part of the ALCHEMY code. From this we call fctns
76 * that take a look at the contents of the 'cauldron' and, using these ingredients, 75 * that take a look at the contents of the 'cauldron' and, using these ingredients,
77 * we construct an integer formula value which is referenced (randomly) against a 76 * we construct an integer formula value which is referenced (randomly) against a
78 * formula list (the formula list chosen is based on the # contents of the cauldron). 77 * formula list (the formula list chosen is based on the # contents of the cauldron).
79 * 78 *
94 * around. :) 93 * around. :)
95 * -b.t. 94 * -b.t.
96 */ 95 */
97 96
98void 97void
99attempt_do_alchemy (object *caster, object *cauldron) 98attempt_do_alchemy (object *caster, object *cauldron, object *skill)
100{ 99{
101 recipelist *fl; 100 recipelist *fl;
102 recipe *rp = NULL; 101 recipe *rp = NULL;
103 float success_chance; 102 float success_chance;
104 int numb, ability = 1; 103 int numb, ability = 1;
127 rp = find_recipe (fl, formula, cauldron->inv); 126 rp = find_recipe (fl, formula, cauldron->inv);
128 if (rp != NULL) 127 if (rp != NULL)
129 { 128 {
130#ifdef ALCHEMY_DEBUG 129#ifdef ALCHEMY_DEBUG
131 if (strcmp (rp->title, "NONE")) 130 if (strcmp (rp->title, "NONE"))
132 LOG (llevDebug, "WIZ got formula: %s of %s\n", rp->arch_name[0], rp->title); 131 LOG (llevDebug, "WIZ got formula: %s of %s\n", rp->arch_name[0], &rp->title);
133 else 132 else
134 LOG (llevDebug, "WIZ got formula: %s (nbatches:%d)\n", rp->arch_name[0], formula / rp->index); 133 LOG (llevDebug, "WIZ got formula: %s (nbatches:%d)\n", rp->arch_name[0], formula / rp->index);
135#endif 134#endif
136 attempt_recipe (caster, cauldron, ability, rp, formula / rp->index); 135 attempt_recipe (caster, cauldron, ability, rp, formula / rp->index);
137 } 136 }
140 return; 139 return;
141 } /* End of WIZ alchemy */ 140 } /* End of WIZ alchemy */
142 141
143 /* find the recipe */ 142 /* find the recipe */
144 rp = find_recipe (fl, formula, cauldron->inv); 143 rp = find_recipe (fl, formula, cauldron->inv);
145 if (rp) 144 if (rp
145 && rp->skill == skill->skill
146 && (!rp->cauldron
147 || rp->cauldron == cauldron->arch->archname))
146 { 148 {
147 uint64 value_ingredients; 149 uint64 value_ingredients;
148 uint64 value_item; 150 uint64 value_item;
149 object *tmp; 151 object *tmp;
150 int attempt_shadow_alchemy; 152 int attempt_shadow_alchemy;
151 153
152 ave_chance = fl->total_chance / (float) fl->number; 154 ave_chance = fl->total_chance / (float) fl->number;
153 /* the caster gets an increase in ability based on thier skill lvl */ 155
154 if (rp->skill)
155 {
156 skop = find_skill_by_name (caster, rp->skill);
157 if (!skop)
158 new_draw_info (NDI_UNIQUE, 0, caster, "You do not have the proper skill for this recipe");
159 else
160 ability += (int) (skop->level * ((4.0 + cauldron->magic) / 4.0)); 156 ability += (int) (skill->level * ((4.0 + cauldron->magic) / 4.0));
161 }
162 else
163 {
164 LOG (llevDebug, "Recipe %s has NULL skill!\n", &rp->title);
165 return;
166 }
167
168 if (!rp->cauldron)
169 {
170 LOG (llevDebug, "Recipe %s has NULL cauldron!\n", &rp->title);
171 return;
172 }
173 157
174 /* determine value of ingredients */ 158 /* determine value of ingredients */
175 value_ingredients = 0; 159 value_ingredients = 0;
176 for (tmp = cauldron->inv; tmp != NULL; tmp = tmp->below) 160 for (tmp = cauldron->inv; tmp != NULL; tmp = tmp->below)
177 value_ingredients += query_cost (tmp, NULL, F_TRUE); 161 value_ingredients += query_cost (tmp, NULL, F_TRUE);
215 199
216 /* if we get here, we failed!! */ 200 /* if we get here, we failed!! */
217 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp)); 201 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp));
218} 202}
219 203
220/** 204/**
221 * Recipe value of the entire contents of a container. 205 * Recipe value of the entire contents of a container.
222 * This appears to just generate a hash value, which I guess for now works 206 * This appears to just generate a hash value, which I guess for now works
223 * ok, but the possibility of duplicate hashes is certainly possible - msw 207 * ok, but the possibility of duplicate hashes is certainly possible - msw
224 */ 208 */
225
226int 209int
227content_recipe_value (object *op) 210content_recipe_value (object *op)
228{ 211{
229 char name[MAX_BUF]; 212 char name[MAX_BUF];
230 object *tmp = op->inv; 213 object *tmp = op->inv;
247 LOG (llevDebug, " Formula value=%d\n", formula); 230 LOG (llevDebug, " Formula value=%d\n", formula);
248#endif 231#endif
249 return formula; 232 return formula;
250} 233}
251 234
252/** 235/**
253 * Returns total number of items in op 236 * Returns total number of items in op
254 */ 237 */
255 238
256int 239int
257numb_ob_inside (object *op) 240numb_ob_inside (object *op)
258{ 241{
267 number++; 250 number++;
268 o_number++; 251 o_number++;
269 tmp = tmp->below; 252 tmp = tmp->below;
270 } 253 }
271#ifdef ALCHEMY_DEBUG 254#ifdef ALCHEMY_DEBUG
272 LOG (llevDebug, "numb_ob_inside(%s): found %d ingredients\n", op->name, o_number); 255 LOG (llevDebug, "numb_ob_inside(%s): found %d ingredients\n", &op->name, o_number);
273#endif 256#endif
274 return o_number; 257 return o_number;
275} 258}
276 259
277/** 260/**
279 * insert_ob_in_ob. If the caster has some alchemy skill, then they might 262 * insert_ob_in_ob. If the caster has some alchemy skill, then they might
280 * gain some exp from (successfull) fabrication of the product. 263 * gain some exp from (successfull) fabrication of the product.
281 * If nbatches==-1, don't give exp for this creation (random generation/ 264 * If nbatches==-1, don't give exp for this creation (random generation/
282 * failed recipe) 265 * failed recipe)
283 */ 266 */
284
285object * 267object *
286attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches) 268attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches)
287{ 269{
288 270
289 object *item = NULL, *skop; 271 object *item = NULL, *skop;
290 272
291 /* this should be passed to this fctn, not effiecent cpu use this way */ 273 /* this should be passed to this fctn, not effiecent cpu use this way */
292 int batches = abs (nbatches); 274 int batches = abs (nbatches);
293 275
294
295 /* is the cauldron the right type? */ 276 /* is the cauldron the right type? */
296 if (rp->cauldron != cauldron->arch->archname) 277 if (rp->cauldron && rp->cauldron != cauldron->arch->archname)
297 {
298 new_draw_info (NDI_UNIQUE, 0, caster, "You are not using the proper" " facilities for this formula.");
299 return 0; 278 return 0;
300 }
301 279
302 skop = find_skill_by_name (caster, rp->skill); 280 skop = find_skill_by_name (caster, rp->skill);
303 /* does the caster have the skill? */ 281 /* does the caster have the skill? */
304 if (!skop) 282 if (!skop)
305 return 0; 283 return 0;
322 } 300 }
323 } 301 }
324 302
325#ifdef EXTREME_ALCHEMY_DEBUG 303#ifdef EXTREME_ALCHEMY_DEBUG
326 LOG (llevDebug, "attempt_recipe(): got %d nbatches\n", nbatches); 304 LOG (llevDebug, "attempt_recipe(): got %d nbatches\n", nbatches);
327 LOG (llevDebug, "attempt_recipe(): using recipe %s\n", rp->title ? rp->title : "unknown"); 305 LOG (llevDebug, "attempt_recipe(): using recipe %s\n", *rp->title ? &rp->title : "unknown");
328#endif 306#endif
329 307
330 if ((item = make_item_from_recipe (cauldron, rp)) != NULL) 308 if ((item = make_item_from_recipe (cauldron, rp)) != NULL)
331 { 309 {
332 remove_contents (cauldron->inv, item); 310 remove_contents (cauldron->inv, item);
346 } 324 }
347 325
348 return item; 326 return item;
349} 327}
350 328
351
352
353/** 329/**
354 * We adjust the nrof, exp and level of the final product, based 330 * We adjust the nrof, exp and level of the final product, based
355 * on the item's default parameters, and the relevant caster skill level. 331 * on the item's default parameters, and the relevant caster skill level.
356 */ 332 */
357void 333void
358adjust_product (object *item, int lvl, int yield) 334adjust_product (object *item, int lvl, int yield)
359{ 335{
360 int nrof = 1; 336 int nrof = 1;
373 nrof = yield; 349 nrof = yield;
374 350
375 item->nrof = nrof; 351 item->nrof = nrof;
376 } 352 }
377} 353}
378
379 354
380/** 355/**
381 * Using a list of items and a recipe to make an artifact. 356 * Using a list of items and a recipe to make an artifact.
382 * 357 *
383 * @param cauldron the cauldron (including the ingredients) used to make the item 358 * @param cauldron the cauldron (including the ingredients) used to make the item
384 * 359 *
385 * @param rp the recipe to make the artifact from 360 * @param rp the recipe to make the artifact from
386 * 361 *
387 * @return the newly created object, NULL if something failed 362 * @return the newly created object, NULL if something failed
388 */ 363 */
389
390object * 364object *
391make_item_from_recipe (object *cauldron, recipe *rp) 365make_item_from_recipe (object *cauldron, recipe *rp)
392{ 366{
393 artifact *art = NULL; 367 artifact *art = NULL;
394 object *item = NULL; 368 object *item = NULL;
403 LOG (llevDebug, "make_alchemy_item(): failed to create alchemical object.\n"); 377 LOG (llevDebug, "make_alchemy_item(): failed to create alchemical object.\n");
404 return (object *) NULL; 378 return (object *) NULL;
405 } 379 }
406 380
407 /* Find the appropriate artifact template... */ 381 /* Find the appropriate artifact template... */
408 if (strcmp (rp->title, "NONE")) 382 if (rp->title != shstr_NONE)
409 { 383 {
410 if ((art = locate_recipe_artifact (rp, rp_arch_index)) == NULL) 384 if ((art = locate_recipe_artifact (rp, rp_arch_index)) == NULL)
411 { 385 {
412 LOG (llevError, "make_alchemy_item(): failed to locate recipe artifact.\n"); 386 LOG (llevError, "make_alchemy_item(): failed to locate recipe artifact.\n");
413 LOG (llevDebug, " --requested recipe: %s of %s.\n", rp->arch_name[0], &rp->title); 387 LOG (llevDebug, " --requested recipe: %s of %s.\n", rp->arch_name[0], &rp->title);
414 return (object *) NULL; 388 return (object *) NULL;
415 } 389 }
390
416 transmute_materialname (item, art->item); 391 transmute_materialname (item, art->item);
417 give_artifact_abilities (item, art->item); 392 give_artifact_abilities (item, art->item);
418 } 393 }
419 394
420 if (QUERY_FLAG (cauldron, FLAG_CURSED)) 395 if (QUERY_FLAG (cauldron, FLAG_CURSED))
423 SET_FLAG (item, FLAG_DAMNED); 398 SET_FLAG (item, FLAG_DAMNED);
424 399
425 return item; 400 return item;
426} 401}
427 402
428
429/** 403/**
430 * Looks through the ingredient list. If we find a 404 * Looks through the ingredient list. If we find a
431 * suitable object in it - we will use that to make the requested artifact. 405 * suitable object in it - we will use that to make the requested artifact.
432 * Otherwise the code returns a 'generic' item if create_item is set. -b.t. 406 * Otherwise the code returns a 'generic' item if create_item is set. -b.t.
433 * 407 *
434 * @param rp_arch_index pointer to return value; set to arch index for recipe; 408 * @param rp_arch_index pointer to return value; set to arch index for recipe;
435 * set to zero if not using a transmution formula 409 * set to zero if not using a transmution formula
436 */ 410 */
437
438object * 411object *
439find_transmution_ob (object *first_ingred, recipe *rp, size_t * rp_arch_index, int create_item) 412find_transmution_ob (object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item)
440{ 413{
441 object *item = NULL; 414 object *prod_item = 0;
442 415 bool found = false;
443 *rp_arch_index = 0; 416 *rp_arch_index = 0;
444 417
445 if (rp->transmute) /* look for matching ingredient/prod archs */ 418 if (rp->transmute) /* look for matching ingredient/prod archs */
446 for (item = first_ingred; item; item = item->below) 419 for (object *item = first_ingred; item; item = item->below)
447 { 420 {
448 size_t i;
449
450 for (i = 0; i < rp->arch_names; i++) 421 for (int i = 0; i < rp->arch_names; i++)
451 { 422 //TODO: should be a shstr comparison
452 if (item->arch->archname == rp->arch_name[i]) 423 if (!strcmp(&item->arch->archname,rp->arch_name[i]))
453 { 424 {
454 *rp_arch_index = i; 425 *rp_arch_index = i;
426 prod_item = item;
455 break; 427 break;
456 } 428 }
457 }
458 429
459 if (i < rp->arch_names) 430 if (prod_item)
460 break; 431 break;
461 } 432 }
462 433
463 /* failed, create a fresh object. Note no nrof>1 because that would 434 /* failed, create a fresh object. Note no nrof>1 because that would
464 * allow players to create massive amounts of artifacts easily */ 435 * allow players to create massive amounts of artifacts easily */
465 if (create_item && (!item || item->nrof > 1)) 436 if (create_item && (!prod_item || prod_item->nrof > 1))
437 {
438#ifdef ALCHEMY_DEBUG
439 LOG (llevDebug, "creating a new item.\n");
440 if (prod_item != NULL)
466 { 441 {
442 LOG (llevDebug, " had item: arch %s(nrof:%d)\n",
443 &prod_item->arch->archname, prod_item->nrof);
444 }
445#endif
446 if (!prod_item)
467 *rp_arch_index = RANDOM () % rp->arch_names; 447 *rp_arch_index = rndm (rp->arch_names);
468 item = get_archetype (rp->arch_name[*rp_arch_index]); 448 prod_item = get_archetype (rp->arch_name[*rp_arch_index]);
469 } 449 }
470 450
471#ifdef ALCHEMY_DEBUG 451#ifdef ALCHEMY_DEBUG
472 LOG (llevDebug, "recipe calls for%stransmution.\n", rp->transmute ? " " : " no "); 452 LOG (llevDebug, "recipe calls for%stransmution.\n", rp->transmute ? " " : " no ");
473 if (item != NULL) 453 if (prod_item != NULL)
474 { 454 {
475 LOG (llevDebug, " find_transmutable_ob(): returns arch %s(sp:%d)\n", item->arch->name, item->stats.sp); 455 LOG (llevDebug, " find_transmutable_ob(): returns arch %s(sp:%d)\n",
456 &prod_item->arch->archname, prod_item->stats.sp);
476 } 457 }
477#endif 458#endif
478 459
479 return item; 460 return prod_item;
480} 461}
481 462
482
483/** 463/**
484 * Ouch. We didnt get the formula we wanted. 464 * Ouch. We didnt get the formula we wanted.
485 * This fctn simulates the backfire effects--worse effects as the level 465 * This fctn simulates the backfire effects--worse effects as the level
486 * increases. If SPELL_FAILURE_EFFECTS is defined some really evil things 466 * increases. If SPELL_FAILURE_EFFECTS is defined some really evil things
487 * can happen to the would be alchemist. This table probably needs some 467 * can happen to the would be alchemist. This table probably needs some
488 * adjustment for playbalance. -b.t. 468 * adjustment for playbalance. -b.t.
489 */ 469 */
490
491void 470void
492alchemy_failure_effect (object *op, object *cauldron, recipe *rp, int danger) 471alchemy_failure_effect (object *op, object *cauldron, recipe *rp, int danger)
493{ 472{
494 int level = 0; 473 int level = 0;
495 474
519 tmp->materialname = "stone"; 498 tmp->materialname = "stone";
520 tmp->name = "slag"; 499 tmp->name = "slag";
521 tmp->name_pl = "slags"; 500 tmp->name_pl = "slags";
522 item = insert_ob_in_ob (tmp, cauldron); 501 item = insert_ob_in_ob (tmp, cauldron);
523 CLEAR_FLAG (tmp, FLAG_CAN_ROLL); 502 CLEAR_FLAG (tmp, FLAG_CAN_ROLL);
524 CLEAR_FLAG (tmp, FLAG_NO_PICK); 503 SET_FLAG (tmp, FLAG_NO_DROP);
525 tmp->move_block = 0; 504 tmp->move_block = 0;
526 } 505 }
527 506
528 remove_contents (cauldron->inv, item); 507 remove_contents (cauldron->inv, item);
529 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); 508 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ());
615 { /* MAJOR FIRE */ 594 { /* MAJOR FIRE */
616 object *fb = get_archetype (SP_MED_FIREBALL); 595 object *fb = get_archetype (SP_MED_FIREBALL);
617 596
618 remove_contents (cauldron->inv, NULL); 597 remove_contents (cauldron->inv, NULL);
619 fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb); 598 fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb);
620 fb->destroy (true); 599 fb->destroy ();
621 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); 600 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name);
622 } 601 }
623 else if (level < 100) 602 else if (level < 100)
624 { /* WHAMMY the CAULDRON */ 603 { /* WHAMMY the CAULDRON */
625 if (!QUERY_FLAG (cauldron, FLAG_CURSED)) 604 if (!QUERY_FLAG (cauldron, FLAG_CURSED))
666 * in this one, we allow *any* valid alchemy artifact 645 * in this one, we allow *any* valid alchemy artifact
667 * to be made (rather than only those on the given 646 * to be made (rather than only those on the given
668 * formulalist) */ 647 * formulalist) */
669 if (!rp) 648 if (!rp)
670 rp = get_random_recipe ((recipelist *) NULL); 649 rp = get_random_recipe ((recipelist *) NULL);
650
671 if (rp && (tmp = get_archetype (rp->arch_name[RANDOM () % rp->arch_names]))) 651 if (rp && (tmp = get_archetype (rp->arch_name [rndm (rp->arch_names)])))
672 { 652 {
673 generate_artifact (tmp, random_roll (1, op->level / 2 + 1, op, PREFER_HIGH) + 1); 653 generate_artifact (tmp, random_roll (1, op->level / 2 + 1, op, PREFER_HIGH) + 1);
674 if ((tmp = insert_ob_in_ob (tmp, cauldron))) 654 if ((tmp = insert_ob_in_ob (tmp, cauldron)))
675 { 655 {
676 remove_contents (cauldron->inv, tmp); 656 remove_contents (cauldron->inv, tmp);
712 } 692 }
713 693
714 if (tmp->inv) 694 if (tmp->inv)
715 remove_contents (tmp->inv, NULL); 695 remove_contents (tmp->inv, NULL);
716 696
717 tmp->destroy (true); 697 tmp->destroy ();
718 tmp = next; 698 tmp = next;
719 } 699 }
720} 700}
721 701
722/** 702/**
837 for (ob = cauldron->inv; ob != NULL; ob = ob->below) 817 for (ob = cauldron->inv; ob != NULL; ob = ob->below)
838 { 818 {
839 char name_ob[MAX_BUF]; 819 char name_ob[MAX_BUF];
840 const char *name2; 820 const char *name2;
841 821
842 if (ob->title == NULL) 822 if (!ob->title)
843 name2 = ob->name; 823 name2 = ob->name;
844 else 824 else
845 { 825 {
846 snprintf (name_ob, sizeof (name_ob), "%s %s", &ob->name, &ob->title); 826 snprintf (name_ob, sizeof (name_ob), "%s %s", &ob->name, &ob->title);
847 name2 = name_ob; 827 name2 = name_ob;
899 { 879 {
900 /* check if recipe matches at all */ 880 /* check if recipe matches at all */
901 if (formula % rp->index != 0) 881 if (formula % rp->index != 0)
902 { 882 {
903#ifdef EXTREME_ALCHEMY_DEBUG 883#ifdef EXTREME_ALCHEMY_DEBUG
904 LOG (llevDebug, " formula %s of %s (%d) does not match\n", rp->arch_name[0], rp->title, rp->index); 884 LOG (llevDebug, " formula %s of %s (%d) does not match\n", rp->arch_name[0], &rp->title, rp->index);
905#endif 885#endif
906 continue; 886 continue;
907 } 887 }
908 888
909 if (rp->transmute && find_transmution_ob (ingredients, rp, &rp_arch_index, 0) != NULL) 889 if (rp->transmute && find_transmution_ob (ingredients, rp, &rp_arch_index, 0) != NULL)
910 { 890 {
911#ifdef EXTREME_ALCHEMY_DEBUG 891#ifdef EXTREME_ALCHEMY_DEBUG
912 LOG (llevDebug, " formula %s of %s (%d) is a matching transmuting formula\n", rp->arch_name[rp_arch_index], rp->title, rp->index); 892 LOG (llevDebug, " formula %s of %s (%d) is a matching transmuting formula\n", rp->arch_name[rp_arch_index], &rp->title, rp->index);
913#endif 893#endif
914 /* transmution recipe with matching base ingredient */ 894 /* transmution recipe with matching base ingredient */
915 if (!transmute_found) 895 if (!transmute_found)
916 { 896 {
917 transmute_found = 1; 897 transmute_found = 1;
919 } 899 }
920 } 900 }
921 else if (transmute_found) 901 else if (transmute_found)
922 { 902 {
923#ifdef EXTREME_ALCHEMY_DEBUG 903#ifdef EXTREME_ALCHEMY_DEBUG
924 LOG (llevDebug, " formula %s of %s (%d) matches but is not a matching transmuting formula\n", rp->arch_name[0], rp->title, 904 LOG (llevDebug, " formula %s of %s (%d) matches but is not a matching transmuting formula\n", rp->arch_name[0], &rp->title,
925 rp->index); 905 rp->index);
926#endif 906#endif
927 /* "normal" recipe found after previous transmution recipe => ignore this recipe */ 907 /* "normal" recipe found after previous transmution recipe => ignore this recipe */
928 continue; 908 continue;
929 } 909 }
930#ifdef EXTREME_ALCHEMY_DEBUG 910#ifdef EXTREME_ALCHEMY_DEBUG
931 else 911 else
932 { 912 {
933 LOG (llevDebug, " formula %s of %s (%d) matches\n", rp->arch_name[0], rp->title, rp->index); 913 LOG (llevDebug, " formula %s of %s (%d) matches\n", rp->arch_name[0], &rp->title, rp->index);
934 } 914 }
935#endif 915#endif
936 916
937 if (rndm (0, recipes_matching) == 0) 917 if (rndm (0, recipes_matching) == 0)
938 result = rp; 918 result = rp;
948 return NULL; 928 return NULL;
949 } 929 }
950 930
951#ifdef ALCHEMY_DEBUG 931#ifdef ALCHEMY_DEBUG
952 if (strcmp (result->title, "NONE") != 0) 932 if (strcmp (result->title, "NONE") != 0)
953 LOG (llevDebug, "got formula: %s of %s (nbatches:%d)\n", result->arch_name[0], result->title, formula / result->index); 933 LOG (llevDebug, "got formula: %s of %s (nbatches:%d)\n", result->arch_name[0], &result->title, formula / result->index);
954 else 934 else
955 LOG (llevDebug, "got formula: %s (nbatches:%d)\n", result->arch_name[0], formula / result->index); 935 LOG (llevDebug, "got formula: %s (nbatches:%d)\n", result->arch_name[0], formula / result->index);
956#endif 936#endif
957 return result; 937 return result;
958} 938}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines