--- deliantra/server/common/material.C 2009/11/10 04:38:45 1.5 +++ deliantra/server/common/material.C 2010/04/28 19:49:50 1.13 @@ -1,9 +1,9 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team - * Copyright (©) 1992,2007 Frank Tore Johansen + * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2002 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the @@ -61,8 +61,8 @@ for (int i = 0; i < NROFATTACKS; i++) { - save [i] = 10; - mod [i] = 9; + save [i] = 0; + mod [i] = 0; } chance = 0; @@ -91,8 +91,14 @@ materialtype_t *mt = new materialtype_t; mt->name = name; - mt->next = materialt; - materialt = mt; + // make it susceptible to attacks + for (int i = 0; i < NROFATTACKS; i++) + { + mt->save [i] = 10; + mt->mod [i] = 9; + } + + mt->next = materialt; materialt = mt; return mt; } @@ -103,17 +109,18 @@ void transmute_materialname (object *op, const object *change) { - int j; + if (!op->is_armor ()) + return; - if (op->material != change->material) + if (op->material == MATERIAL_NULL) return; - if (!op->is_armor ()) + if (op->material != change->material) return; materialtype_t *mt = op->material; - for (j = 0; j < NROFATTACKS; j++) + for (int j = 0; j < NROFATTACKS; j++) if (op->resist[j] == 0 && change->resist[j] != 0) { op->resist[j] += mt->mod[j]; @@ -127,7 +134,7 @@ void select_material (object *op, int difficulty) { - if (op->material != &material_null || !op->materials) + if (op->material != MATERIAL_NULL || !op->materials) return; materialtype_t *lmt = 0; @@ -185,22 +192,17 @@ //-GPL void -load_materials (void) +load_materials () { - char filename[MAX_BUF]; - - sprintf (filename, "%s/materials", settings.datadir); - LOG (llevDebug, "Reading material type data from %s...\n", filename); - //TODO: somehow free old materials, or update them in-place - material_null.next = 0; - materialt = &material_null; + // currently we effectively leak them. + material_null.next = 0; materialt = &material_null; - object_thawer thawer (filename); + object_thawer thawer (settings.datadir, "materials"); if (!thawer) { - LOG (llevError, "Cannot open %s for reading\n", filename); + LOG (llevError, "Cannot open %s for reading\n", thawer.name); goto done; } @@ -223,8 +225,7 @@ thawer.get (mt->name); mt->description = mt->name; - mt->next = materialt; - materialt = mt; + mt->next = materialt; materialt = mt; break; case KW_description: @@ -294,7 +295,7 @@ goto done; default: - if (!thawer.parse_error ("materials file", "materials")) + if (!thawer.parse_error ("materials file")) goto done; break; } @@ -303,9 +304,6 @@ } done: - if (!materialt) - materialt = new materialtype_t; - LOG (llevDebug, "Done.\n"); }