--- deliantra/server/common/item.C 2010/10/11 18:40:43 1.90 +++ deliantra/server/common/item.C 2018/11/17 23:40:00 1.100 @@ -1,24 +1,25 @@ /* * 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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 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 * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . - * + * * The authors can be reached via e-mail to */ @@ -76,8 +77,8 @@ /* The following is a large table of item types, the fields are: * item number, item name, item name (plural), and two numbers that are the skills * used to identify them. Anytime a new item type is added or removed, this list - * should be altered to reflect that. The defines for the numerical values are in - * define.h + * should be altered to reflect that. The defines for the numerical values are in + * define.h */ static const typedata item_types[] = { {PLAYER, "player", "players", 0, 0}, @@ -148,6 +149,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}, @@ -281,7 +283,7 @@ /* This protection logic is pretty flawed. 20% fire resistance * is much more valuable than 20% confusion, or 20% slow, or * several others. Start at 1 - ignore physical - all that normal - * armour shouldn't be counted against + * armour shouldn't be counted against */ tmp = 0; for (i = 1; i < NROFATTACKS; i++) @@ -359,7 +361,7 @@ } } get_typedata_; -/* returns the typedata that has a number equal to itemtype, if there +/* returns the typedata that has a number equal to itemtype, if there * isn't one, returns NULL */ const typedata * get_typedata (int itemtype) @@ -367,7 +369,7 @@ return get_typedata_ (itemtype); } -/* returns the typedata that has a name equal to itemtype, if there +/* returns the typedata that has a name equal to itemtype, if there * isn't one, return the plural name that matches, if there still isn't * one return NULL */ const typedata * @@ -477,7 +479,7 @@ ring_desc (const object *op) { static dynbuf_text buf; buf.clear (); - int attr, val, len; + int attr, val; if (op->flag [FLAG_IDENTIFIED]) { @@ -515,7 +517,7 @@ } /* - * query_short_name(object) is similar to query_name, but doesn't + * query_short_name(object) is similar to query_name, but doesn't * contain any information about object status (worn/cursed/etc.) * * It is sometimes used when printing messages, so should fit well into a sentence. @@ -621,7 +623,6 @@ const char * query_name (const object *op) { - int len = 0; static dynbuf_text bufs[5]; static int use_buf = 0; @@ -1011,21 +1012,15 @@ else buf.printf ("(capacity %d; it is ", op->stats.maxsp); - i = (op->stats.sp * 10) / op->stats.maxsp; - if (op->stats.sp == 0) - buf << "empty"; - else if (i == 0) - buf << "almost empty"; - else if (i < 3) - buf << "partially filled"; - else if (i < 6) - buf << "half full"; - else if (i < 9) - buf << "well charged"; - else if (op->stats.sp == op->stats.maxsp) - buf << "fully charged"; - else - buf << "almost full"; + i = op->stats.sp * 10 / max (op->stats.maxsp, 1); + + if (op->stats.sp == 0) buf << "empty"; + else if (i <= 0) buf << "almost empty"; + else if (i <= 2) buf << "partially filled"; + else if (i <= 5) buf << "half full"; + else if (i <= 8) buf << "well charged"; + else if (op->stats.sp < op->stats.maxsp) buf << "almost full"; + else buf << "fully charged"; buf << ')'; break; @@ -1200,7 +1195,7 @@ { if (op->stats.food) buf.printf ("(sustenance%+d)", op->stats.food); if (op->stats.grace) buf.printf ("(grace%+d)", op->stats.grace); - if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); + if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); } @@ -1354,7 +1349,7 @@ && inv->type == SPELL && flag [FLAG_IDENTIFIED] && (type == SPELLBOOK || type == ROD || type == WAND - || type == ROD || type == POTION || type == SCROLL)) + || type == POTION || type == SCROLL)) // for spellbooks and other stuff that contains spells, print the spell message, // unless the object has a custom message handled above. buf << '\r' << inv->msg << '\n'; @@ -1419,7 +1414,7 @@ /* * inventory prints object's inventory. If inv==NULL then print player's - * inventory. + * inventory. * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] */ const char *