--- deliantra/server/common/item.C 2006/09/21 00:05:24 1.7 +++ deliantra/server/common/item.C 2007/02/05 01:39:05 1.21 @@ -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 @@ -101,7 +102,6 @@ {POISON, "poison", "poisons", SK_ALCHEMY, 0}, {BOOK, "book", "books", SK_LITERACY, 0}, {CLOCK, "clock", "clocks", 0, 0}, - {LIGHTNING, "lightning", "lightning", 0, 0}, {ARROW, "arrow", "arrows", SK_BOWYER, 0}, {BOW, "bow", "bows", SK_BOWYER, 0}, {WEAPON, "weapon", "weapons", SK_SMITHERY, 0}, @@ -131,7 +131,6 @@ {TELEPORTER, "teleporter", "teleporters", 0, 0}, {CREATOR, "creator", "creators", 0, 0}, {SKILL, "skill", "skills", 0, 0}, - {EXPERIENCE, "experience", "experience", 0, 0}, {EARTHWALL, "earthwall", "earthwalls", 0, 0}, {GOLEM, "golem", "golems", 0, 0}, {THROWN_OBJ, "projectile", "projectiles", 0, 0}, @@ -161,17 +160,11 @@ {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0}, {SKILL_TOOL, "skill tool", "skill tools", 0, 0}, {LIGHTER, "lighter", "lighters", 0, 0}, - {TRAP_PART, "trap part", "trap parts", 0, 0}, - {WALL, "wall", "walls", 0, 0}, - {LIGHT_SOURCE, "light source", "light sources", 0, 0}, + {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0}, {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, - {MONSTER, "monster", "monsters", 0, 0}, - {SPAWN_GENERATOR, "monster generator", "monster generators", 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}, @@ -188,8 +181,6 @@ {BRACERS, "bracers", "bracers", SK_SMITHERY, 0}, {POISONING, "poisoning", "poisonings", 0, 0}, {SAVEBED, "savebed", "savebeds", 0, 0}, - {POISONCLOUD, "poison cloud", "poison clouds", 0, 0}, - {FIREHOLES, "fireholes", "fireholes", 0, 0}, {WAND, "wand", "wands", SK_THAUMATURGY, 0}, {SCROLL, "scroll", "scrolls", SK_LITERACY, 0}, {DIRECTOR, "director", "directors", 0, 0}, @@ -670,7 +661,7 @@ use_buf %= 5; #ifdef NEW_MATERIAL_CODE - if ((IS_ARMOR (op) || IS_WEAPON (op)) && op->materialname) + if ((op->is_armor () || op->is_weapon ()) && op->materialname) { mt = name_to_material (op->materialname); if (mt) @@ -777,11 +768,11 @@ if (!op->nrof && !op->weight && !op->title && !is_magical (op)) return op->name; /* To speed things up (or make things slower?) */ - if ((IS_ARMOR (op) || IS_WEAPON (op)) && op->materialname) + if ((op->is_armor () || op->is_weapon ()) && op->materialname) mt = name_to_material (op->materialname); #ifdef NEW_MATERIAL_CODE - if ((IS_ARMOR (op) || IS_WEAPON (op)) && op->materialname && mt && + if ((op->is_armor () || op->is_weapon ()) && op->materialname && mt && op->arch->clone.materialname != mt->name && !(op->material & M_SPECIAL)) { strcpy (buf, mt->description); @@ -796,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 } @@ -812,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; } @@ -865,7 +858,6 @@ * be called with monster & player objects. Returns a description * in a static buffer. */ - static char * describe_monster (const object *op) { @@ -879,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)) { @@ -945,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) { @@ -1001,18 +993,13 @@ 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"); @@ -1504,11 +1491,9 @@ return 0; } - /* * Supposed to fix face-values as well here, but later. */ - void identify (object *op) { @@ -1540,7 +1525,7 @@ update_object (op, UP_OBJ_FACE); else { - pl = is_player_inv (op->env); + pl = op->in_player (); if (pl) /* A lot of the values can change from an update - might as well send * it all. @@ -1548,3 +1533,4 @@ esrv_send_item (pl, op); } } +