--- deliantra/server/common/item.C 2008/04/13 20:21:50 1.43 +++ deliantra/server/common/item.C 2009/01/01 11:41:17 1.52 @@ -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 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 @@ -302,9 +301,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 +318,7 @@ enc += op->stats.grace; /* grace regen */ enc += op->stats.exp; /* speed bonus */ } + enc += op->stats.luck; /* Do spell paths now */ @@ -358,6 +360,7 @@ for (i = 0; i < item_types_size; i++) if (item_types[i].number == itemtype) return &item_types[i]; + return NULL; } @@ -372,13 +375,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; } @@ -421,7 +426,7 @@ query_weight (const object *op) { static char buf[10]; - sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; + sint32 i = op->total_weight (); if (op->weight < 0) return " "; @@ -540,7 +545,7 @@ const char * query_short_name (const object *op) { - if (op->name == 0) + if (!op->name) return "(null)"; if (!op->nrof @@ -592,7 +597,7 @@ sint32 coins = op->stats.food / coin->value; - buf.printf ("drop %d %s", 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 << ']'; } @@ -810,7 +815,7 @@ switch ((int) ((FABS (op->speed)) * 15)) { case 0: - buf << "(very slow movement"; + buf << "(very slow movement)"; break; case 1: buf << "(slow movement)"; @@ -1196,9 +1201,8 @@ void examine (object *op, object *tmp) { - std::string s = tmp->describe (op); - - new_draw_info (NDI_UNIQUE, 0, op, s.c_str ()); + std::string info = tmp->describe (op); + op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); } /* @@ -1360,8 +1364,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); @@ -1378,7 +1380,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; } } @@ -1386,14 +1388,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); }