--- deliantra/server/common/item.C 2006/12/20 14:11:42 1.14 +++ deliantra/server/common/item.C 2007/02/16 19:43:40 1.23 @@ -1,25 +1,26 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program 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 2 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 GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail at -*/ + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program 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 2 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 GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The authors can be reached via e-mail at + */ #include #include @@ -163,9 +164,7 @@ {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, {LAMP, "lamp", "lamps", 0, 0}, {DUPLICATOR, "duplicator", "duplicators", 0, 0}, - {TOOL, "tool", "tools", 0, 0}, {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0}, - {BUILDFAC, "building facility", "building facilities", 0, 0}, {CLOAK, "cloak", "cloaks", SK_SMITHERY, 0}, {SPINNER, "spinner", "spinners", 0, 0}, {GATE, "gate", "gates", 0, 0}, @@ -459,14 +458,12 @@ return buf; } - /* * get_number(integer) returns the text-representation of the given number * in a static buffer. The buffer might be overwritten at the next * call to get_number(). * It is currently only used by the query_name() function. */ - char * get_number (int i) { @@ -650,7 +647,7 @@ char * query_name (const object *op) { - static char buf[5][HUGE_BUF]; + static char buf[5][HUGE_BUF]; // OMFG static int use_buf = 0; int len = 0; @@ -687,6 +684,7 @@ else if (QUERY_FLAG (op, FLAG_CURSED)) safe_strcat (buf[use_buf], " (cursed)", &len, HUGE_BUF); } + /* Basically, if the object is known magical (detect magic spell on it), * and it isn't identified, print out the fact that * it is magical. Assume that the detect magical spell will only set @@ -712,39 +710,40 @@ { switch (op->type) { - case BOW: - case WAND: - case ROD: - case HORN: - safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); - break; - case WEAPON: - safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); - break; - case ARMOUR: - case HELMET: - case SHIELD: - case RING: - case BOOTS: - case GLOVES: - case AMULET: - case GIRDLE: - case BRACERS: - case CLOAK: - safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF); - break; - case CONTAINER: - safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF); - break; - case SKILL: - default: - safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF); + case BOW: + case WAND: + case ROD: + case HORN: + safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); + break; + case WEAPON: + safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); + break; + case ARMOUR: + case HELMET: + case SHIELD: + case RING: + case BOOTS: + case GLOVES: + case AMULET: + case GIRDLE: + case BRACERS: + case CLOAK: + safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF); + break; + case CONTAINER: + safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF); + break; + case SKILL: + default: + safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF); } } + if (QUERY_FLAG (op, FLAG_UNPAID)) safe_strcat (buf[use_buf], " (unpaid)", &len, HUGE_BUF); - return buf[use_buf]; + return buf [use_buf]; } /* @@ -788,9 +787,10 @@ { #endif if (!plural) - strcpy (buf, op->name); + assign (buf, op->name); else - strcpy (buf, op->name_pl); + assign (buf, op->name_pl); + len = strlen (buf); #ifdef NEW_MATERIAL_CODE } @@ -804,50 +804,51 @@ switch (op->type) { - case SPELLBOOK: - case SCROLL: - case WAND: - case ROD: - if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) - { - if (!op->title) - { - safe_strcat (buf, " of ", &len, MAX_BUF); - if (op->inv) - safe_strcat (buf, op->inv->name, &len, MAX_BUF); - else - LOG (llevError, "Spellbook %s lacks inventory\n", &op->name); - } - if (op->type != SPELLBOOK) - { - sprintf (buf2, " (lvl %d)", op->level); - safe_strcat (buf, buf2, &len, MAX_BUF); - } - } - break; + case SPELLBOOK: + case SCROLL: + case WAND: + case ROD: + if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) + { + if (!op->title) + { + safe_strcat (buf, " of ", &len, MAX_BUF); + if (op->inv) + safe_strcat (buf, op->inv->name, &len, MAX_BUF); + else + LOG (llevError, "Spellbook %s lacks inventory\n", &op->name); + } + if (op->type != SPELLBOOK) + { + sprintf (buf2, " (lvl %d)", op->level); + safe_strcat (buf, buf2, &len, MAX_BUF); + } + } + break; - case SKILL: - case AMULET: - case RING: - if (!op->title) - { - /* If ring has a title, full description isn't so useful */ - char *s = ring_desc (op); + case SKILL: + case AMULET: + case RING: + if (!op->title) + { + /* If ring has a title, full description isn't so useful */ + char *s = ring_desc (op); - if (s[0]) - { - safe_strcat (buf, " ", &len, MAX_BUF); - safe_strcat (buf, s, &len, MAX_BUF); - } - } - break; - default: - if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) - { - sprintf (buf + strlen (buf), " %+d", op->magic); - } + if (s[0]) + { + safe_strcat (buf, " ", &len, MAX_BUF); + safe_strcat (buf, s, &len, MAX_BUF); + } + } + break; + default: + if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) + { + sprintf (buf + strlen (buf), " %+d", op->magic); + } } + return buf; } @@ -857,7 +858,6 @@ * be called with monster & player objects. Returns a description * in a static buffer. */ - static char * describe_monster (const object *op) { @@ -871,7 +871,7 @@ * very good. Any player with a speed greater than .67 will * fall into the 'lightning fast movement' category. */ - if (FABS (op->speed) > MIN_ACTIVE_SPEED) + if (op->has_active_speed ()) { switch ((int) ((FABS (op->speed)) * 15)) { @@ -937,7 +937,7 @@ int first = 1; for (t = op->randomitems->items; t != NULL; t = t->next) - if (t->item && (t->item->clone.type == SPELL)) + if (t->item && t->item->clone.type == SPELL) { if (first) { @@ -993,29 +993,24 @@ break; if (tmp && tmp->attacktype != 0) - { - DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws"); - } + { DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws") } else - { - DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); - } + { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") } } else - { - DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); - } + { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") } + DESCRIBE_PATH (retbuf, op->path_attuned, "Attuned"); DESCRIBE_PATH (retbuf, op->path_repelled, "Repelled"); DESCRIBE_PATH (retbuf, op->path_denied, "Denied"); + for (i = 0; i < NROFATTACKS; i++) - { - if (op->resist[i]) - { - sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]); - strcat (retbuf, buf); - } - } + if (op->resist[i]) + { + sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]); + strcat (retbuf, buf); + } + return retbuf; }