--- deliantra/server/common/item.C 2007/07/10 05:51:37 1.39 +++ deliantra/server/common/item.C 2008/04/09 14:36:47 1.42 @@ -1,11 +1,11 @@ /* - * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * - * Crossfire TRT is free software: you can redistribute it and/or modify + * Deliantra is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * The authors can be reached via e-mail to + * The authors can be reached via e-mail to */ #include @@ -26,6 +26,8 @@ #include #include +const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 }; + /* the ordering of this is actually doesn't make a difference * However, for ease of use, new entries should go at the end * so those people that debug the code that get used to something @@ -538,14 +540,18 @@ const char * query_short_name (const object *op) { - static dynbuf_text buf; buf.clear (); - - if (op->name == NULL) + if (op->name == 0) return "(null)"; - if (!op->nrof && !op->weight && !op->title && !is_magical (op)) + if (!op->nrof + && !op->weight + && !op->title + && !is_magical (op) + && op->slaying != shstr_money) return op->name; /* To speed things up (or make things slower?) */ + static dynbuf_text buf; buf.clear (); + buf << (op->nrof <= 1 ? op->name : op->name_pl); if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) @@ -567,6 +573,30 @@ } break; + case ALTAR: + case TRIGGER_ALTAR: + case IDENTIFY_ALTAR: + if (op->slaying == shstr_money) + { + bool wrap = !!buf.size (); + + if (wrap) buf << " ["; + + archetype *coin = 0; + + 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; + + buf.printf ("drop %d %s", coins, coins == 1 ? &coin->name : &coin->name_pl); + + if (wrap) buf << ']'; + } + break; + case SKILL: case AMULET: case RING: @@ -579,6 +609,7 @@ buf << " " << s; } break; + default: if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) buf.printf (" %+d", op->magic); @@ -1161,6 +1192,38 @@ return std::string (::describe_item (this, who)); } +void +examine (object *op, object *tmp) +{ + std::string s = tmp->describe (op); + + new_draw_info (NDI_UNIQUE, 0, op, s.c_str ()); +} + +/* + * inventory prints object's inventory. If inv==NULL then print player's + * inventory. + * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] + */ +const char * +object::query_inventory (object *who, const char *indent) +{ + static dynbuf_text buf; buf.clear (); + + 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)); + 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)); + + if (buf.size ()) + buf.printf ("%s(total weight: %s)\n", indent, query_weight (this)); + else + buf.printf ("%s(empty)\n", indent); + + return buf; +} + /* Return true if the item is magical. A magical item is one that * increases/decreases any abilities, provides a resistance, * has a generic magical bonus, or is an artifact.