--- deliantra/server/common/item.C 2012/01/03 11:25:30 1.93 +++ deliantra/server/common/item.C 2016/11/16 23:41:59 1.98 @@ -1,24 +1,24 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / 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 */ @@ -478,7 +478,7 @@ ring_desc (const object *op) { static dynbuf_text buf; buf.clear (); - int attr, val, len; + int attr, val; if (op->flag [FLAG_IDENTIFIED]) { @@ -622,7 +622,6 @@ const char * query_name (const object *op) { - int len = 0; static dynbuf_text bufs[5]; static int use_buf = 0; @@ -1012,21 +1011,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; @@ -1355,7 +1348,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';