--- deliantra/server/common/item.C 2010/04/15 02:51:39 1.84 +++ deliantra/server/common/item.C 2011/08/13 23:18:20 1.92 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen * @@ -51,21 +51,9 @@ */ // see include/object.h Body_Locations body_locations[NUM_BODY_LOCATIONS] = { - {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, - {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, - {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, - {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, - {KW_body_arm , "You can put it on your arm" , "It goes on a human's arm"}, - {KW_body_torso , "You can wear it on your body" , "It goes on a human's torso"}, - {KW_body_head , "You can wear it on your head" , "It goes on a human's head"}, - {KW_body_neck , "You can wear it around your neck" , "It goes around a human's neck"}, - {KW_body_finger , "You can wear it on your finger" , "It goes on a human's finger"} , - {KW_body_shoulder, "You can wear it around your shoulders", "It goes around a human's shoulders"}, - {KW_body_foot , "You can put it on your foot" , "It goes on a human's foot"}, - {KW_body_hand , "You can put it on your hand" , "It goes on a human's hand"}, - {KW_body_wrist , "You can wear it around your wrist" , "It goes around a human's wrist"}, - {KW_body_waist , "You can wear it around your waist" , "It goes around a human's waist"}, -/*{"body_dragon_torso", "your body", "a dragon's body"} */ +# define def(name, use, nonuse) { # name, KW_body_ ## name, use, nonuse }, +# include "slotinc.h" +# undef def }; static char numbers_10[10][20] = { @@ -160,6 +148,7 @@ {LIGHTER, "lighter", "lighters", 0, 0}, {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0}, {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, + {TORCH, "torch", "torches", 0, 0}, {LAMP, "lamp", "lamps", 0, 0}, {DUPLICATOR, "duplicator", "duplicators", 0, 0}, {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0}, @@ -204,7 +193,7 @@ {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, }; -static const int item_types_size = sizeof (item_types) / sizeof (*item_types); +static const int item_types_size = array_length (item_types); /* This curve may be too steep. But the point is that there should * be tough choices - there is no real point to this if everyone can @@ -216,10 +205,11 @@ * custom objects can use whatever they want. */ static int enc_to_item_power[21] = { - 0, 0, 1, 2, 3, 4, /* 5 */ - 5, 7, 9, 11, 13, /* 10 */ - 15, 18, 21, 24, 27, /* 15 */ - 30, 35, 40, 45, 50 /* 20 */ + 0, + 0, 1, 2, 3, 4, // 5 + 5, 7, 9, 11, 13, // 10 + 15, 18, 21, 24, 27, // 15 + 30, 35, 40, 45, 50 // 20 }; int @@ -354,16 +344,28 @@ return get_power_from_ench (enc); } +static const struct get_typedata +{ + const typedata *data [NUM_TYPES]; + + get_typedata () + { + for (int i = 0; i < item_types_size; i++) + data [item_types[i].number] = &item_types [i]; + } + + const typedata *operator ()(int itemtype) const + { + return data [itemtype]; + } +} get_typedata_; + /* returns the typedata that has a number equal to itemtype, if there * isn't one, returns NULL */ const typedata * get_typedata (int itemtype) { - for (int i = 0; i < item_types_size; i++) - if (item_types[i].number == itemtype) - return &item_types[i]; - - return NULL; + return get_typedata_ (itemtype); } /* returns the typedata that has a name equal to itemtype, if there @@ -484,7 +486,7 @@ if ((val = op->stats.stat (attr))) buf.printf ("(%s%+d)", short_stat_name[attr], val); - if (op->stats.exp) buf.printf ("(speed %+lld)", (long long)op->stats.exp); + if (op->stats.exp) buf.printf ("(speed %+d)", (int)op->stats.exp); if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); @@ -675,12 +677,11 @@ { switch (op->type) { + case RANGED: case BOW: case WAND: case ROD: case HORN: - buf << " (applied)"; - break; case WEAPON: buf << " (applied)"; break; @@ -980,6 +981,7 @@ switch (op->type) { + case RANGED: case BOW: case ARROW: case WAND: @@ -1094,10 +1096,8 @@ */ if (identified || op->flag [FLAG_BEEN_APPLIED]) { - int attr, val; - - for (attr = 0; attr < NUM_STATS; attr++) - if ((val = op->stats.stat (attr))) + for (int attr = 0; attr < NUM_STATS; attr++) + if (int val = op->stats.stat (attr)) buf.printf ("(%s%+d)", short_stat_name[attr], val); if (op->stats.exp) @@ -1105,6 +1105,7 @@ switch (op->type) { + case RANGED: case BOW: case ARROW: case GIRDLE: @@ -1157,6 +1158,7 @@ switch (op->type) { + case RANGED: case ROD: /* These use stats.sp for spell selection and stats.food */ case HORN: /* and stats.hp for spell-point regeneration... */ case BOW: