--- deliantra/server/common/item.C 2008/04/20 22:03:21 1.46 +++ deliantra/server/common/item.C 2009/01/12 00:17:22 1.54 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * 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 * @@ -22,7 +22,6 @@ */ #include -#include #include #include @@ -255,10 +254,7 @@ int get_power_from_ench (int ench) { - if (ench < 0) ench = 0; - if (ench > 20) ench = 20; - - return enc_to_item_power[ench]; + return enc_to_item_power [clamp (ench, 0, 20)]; } /* This takes an object 'op' and figures out what its item_power @@ -302,9 +298,11 @@ for (i = 1; i < NROFATTACKS; i++) if (op->attacktype & (1 << i)) enc++; + if (op->slaying) enc += 2; /* What it slays is probably more relevent */ } + /* Items the player can equip */ if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || (op->type == SHIELD) || (op->type == RING) || @@ -317,6 +315,7 @@ enc += op->stats.grace; /* grace regen */ enc += op->stats.exp; /* speed bonus */ } + enc += op->stats.luck; /* Do spell paths now */ @@ -358,6 +357,7 @@ for (i = 0; i < item_types_size; i++) if (item_types[i].number == itemtype) return &item_types[i]; + return NULL; } @@ -372,13 +372,15 @@ for (i = 0; i < item_types_size; i++) if (!strcmp (item_types[i].name, name)) return &item_types[i]; + for (i = 0; i < item_types_size; i++) if (!strcmp (item_types[i].name_pl, name)) { LOG (llevInfo, - "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", name, item_types[i].name); + "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name); return &item_types[i]; } + return NULL; } @@ -540,7 +542,7 @@ const char * query_short_name (const object *op) { - if (op->name == 0) + if (!op->name) return "(null)"; if (!op->nrof @@ -573,30 +575,30 @@ } break; - case ALTAR: - case TRIGGER_ALTAR: - case IDENTIFY_ALTAR: - case CONVERTER: - if (op->slaying == shstr_money) - { - bool wrap = !!buf.size (); + case ALTAR: + case TRIGGER_ALTAR: + case IDENTIFY_ALTAR: + case CONVERTER: + if (op->slaying == shstr_money) + { + bool wrap = !!buf.size (); - if (wrap) buf << " ["; + if (wrap) buf << " ["; - archetype *coin = 0; + archetype *coin = 0; - for (char const *const *c = coins; *coins; ++c) - if ((coin = archetype::find (*c))) - if (op->stats.food % coin->value == 0) - break; + for (char const *const *c = coins; *coins; ++c) + if ((coin = archetype::find (*c))) + if (op->stats.food % coin->value == 0) + break; - sint32 coins = op->stats.food / coin->value; + sint32 coins = op->stats.food / coin->value; - buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); + buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); - if (wrap) buf << ']'; - } - break; + if (wrap) buf << ']'; + } + break; case SKILL: case AMULET: @@ -717,6 +719,25 @@ } } + switch (op->type) + { + case LAMP: + if (op->glow_radius) + buf << " (on)"; + else if (op->stats.food <= 0) + buf << " (empty)"; + else + buf << " (off)"; + break; + + case TORCH: + if (op->glow_radius) + buf << " (burning)"; + else if (op->stats.food <= 0) + buf << " (burned out)"; + break; + } + if (QUERY_FLAG (op, FLAG_UNPAID)) buf << " (unpaid)"; @@ -810,7 +831,7 @@ switch ((int) ((FABS (op->speed)) * 15)) { case 0: - buf << "(very slow movement"; + buf << "(very slow movement)"; break; case 1: buf << "(slow movement)"; @@ -1009,6 +1030,28 @@ buf << "almost full."; break; + case LAMP: + { + int percent = ((double) 100 / op->arch->stats.food) * op->stats.food; + buf << "(fuel: "; + if (percent == 0) + buf << "empty"; + else if (percent < 10) + buf << "very low"; + else if (percent < 25) + buf << "low"; + else if (percent < 50) + buf << "half empty"; + else if (percent < 75) + buf << "half full"; + else if (percent < 95) + buf << "well filled"; + else if (percent <= 100) + buf << "full"; + buf << ")"; + } + break; + case FOOD: case FLESH: case DRINK: @@ -1212,12 +1255,12 @@ for (object *tmp = inv; tmp; tmp = tmp->below) if (who && QUERY_FLAG (who, FLAG_WIZ)) - buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, query_name (tmp), tmp->count, query_weight (tmp)); + buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) - buf.printf ("%s- %-36.36s %-8s\n", indent, query_name (tmp), query_weight (tmp)); + buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); if (buf.size ()) - buf.printf ("%s(total weight: %s)\n", indent, query_weight (this)); + buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); else buf.printf ("%s(empty)\n", indent); @@ -1359,8 +1402,6 @@ void identify (object *op) { - object *pl; - SET_FLAG (op, FLAG_IDENTIFIED); CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT); @@ -1377,7 +1418,7 @@ op->title = op->inv->name; else if (op->arch) { - op->name = op->arch->object::name; + op->name = op->arch->object::name; op->name_pl = op->arch->object::name_pl; } } @@ -1385,14 +1426,11 @@ /* If the object is on a map, make sure we update its face */ if (op->map) update_object (op, UP_OBJ_CHANGE); - else - { - pl = op->in_player (); - if (pl) - /* A lot of the values can change from an update - might as well send - * it all. - */ - esrv_send_item (pl, op); - } + + if (object *pl = op->visible_to ()) + /* A lot of the values can change from an update - might as well send + * it all. + */ + esrv_send_item (pl, op); }