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

Comparing deliantra/server/common/recipe.C (file contents):
Revision 1.38 by root, Thu Apr 15 21:49:15 2010 UTC vs.
Revision 1.44 by root, Tue Jan 3 11:25:31 2012 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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
173 */ 173 */
174void 174void
175init_formulae () 175init_formulae ()
176{ 176{
177 static int has_been_done = 0; 177 static int has_been_done = 0;
178 FILE *fp; 178 char *next;
179 char filename[MAX_BUF], buf[MAX_BUF], *cp, *next;
180 recipelist *fl = init_recipelist (); 179 recipelist *fl = init_recipelist ();
181 linked_char *tmp; 180 linked_char *tmp;
182 int value, comp;
183 181
184 if (!formulalist) 182 if (!formulalist)
185 formulalist = fl; 183 formulalist = fl;
186 184
187 if (has_been_done) 185 if (has_been_done)
188 return; 186 return;
189 else 187 else
190 has_been_done = 1; 188 has_been_done = 1;
191 189
192 sprintf (filename, "%s/formulae", settings.datadir); 190 object_thawer thawer (settings.datadir, "formulae");
193 LOG (llevDebug, "Reading alchemical formulae from %s...\n", filename);
194
195 object_thawer thawer (filename);
196 191
197 if (!thawer) 192 if (!thawer)
198 { 193 {
199 LOG (llevError, "Can't open %s.\n", filename); 194 LOG (llevError, "Can't open %s.\n", thawer.name);
200 return; 195 return;
201 } 196 }
202 197
203 while (thawer.kw) 198 while (thawer.kw)
204 { 199 {
276 } 271 }
277 break; 272 break;
278 273
279 default: 274 default:
280 delete formula; 275 delete formula;
276 case KW_EOF:
281 case KW_object: 277 case KW_object:
282 goto next_object; 278 goto next_object;
283 } 279 }
284 } 280 }
285 281
286next_object: ; 282next_object: ;
287 } 283 }
288 284
289 LOG (llevDebug, "done.\n");
290 /* Lastly, lets check for problems in formula we got */ 285 /* Lastly, lets check for problems in formula we got */
291 check_formulae (); 286 check_formulae ();
292} 287}
293 288
294/* Find a treasure with a matching name. The 'depth' parameter is 289/* Find a treasure with a matching name. The 'depth' parameter is
460 char *p; 455 char *p;
461 size_t size; 456 size_t size;
462 size_t i; 457 size_t i;
463 458
464 dup = strdup (str); 459 dup = strdup (str);
465 if (dup == NULL)
466 fatal ("out of memory");
467 460
468 size = 0; 461 size = 0;
469 for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ",")) 462 for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ","))
470 size++; 463 size++;
471 464

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines