--- deliantra/server/common/item.C 2007/02/05 01:42:22 1.22 +++ deliantra/server/common/item.C 2007/05/07 07:47:32 1.31 @@ -1,5 +1,5 @@ /* - * CrossFire, A Multiplayer game for X-windows + * CrossFire, A Multiplayer game * * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team * Copyright (C) 2002 Mark Wedel & Crossfire Development Team @@ -49,18 +49,20 @@ * "This item goes %s\n", with the use/nonuse values filling in the %s */ Body_Locations body_locations[NUM_BODY_LOCATIONS] = { - {"body_range", "in your range slot", "in a human's range slot"}, - {"body_arm", "on your arm", "on a human's arm"}, - {"body_torso", "on your body", "on a human's torso"}, - {"body_head", "on your head", "on a human's head"}, - {"body_neck", "around your neck", "around a humans neck"}, - {"body_skill", "in your skill slot", "in a human's skill slot"}, - {"body_finger", "on your finger", "on a human's finger"} , - {"body_shoulder", "around your shoulders", "around a human's shoulders"}, - {"body_foot", "on your feet", "on a human's feet"}, - {"body_hand", "on your hands", "on a human's hands"}, - {"body_wrist", "around your wrists", "around a human's wrist"}, - {"body_waist", "around your waist", "around a human's waist"}, + {"body_range" , "You can use it as your range weapon" , "It is used as a range weapon"}, + {"body_shield" , "You can wield it as a shield" , "It is used as a shield"}, + {"body_combat" , "You can wield it as your weapon" , "It is used as a combat weapon"}, + {"body_arm" , "You can put it on your arm" , "It goes on a human's arm"}, + {"body_torso" , "You can wear it on your body" , "It goes on a human's torso"}, + {"body_head" , "You can wear it on your head" , "It goes on a human's head"}, + {"body_neck" , "You can wear it around your neck" , "It goes around a human's neck"}, + {"body_skill" , "You can have it in your skill slot" , "It goes in a human's skill slot"}, + {"body_finger" , "You can wear it on your finger" , "It goes on a human's finger"} , + {"body_shoulder", "You can wear it around your shoulders", "It goes around a human's shoulders"}, + {"body_foot" , "You can put your feets into it" , "It goes on a human's feet"}, + {"body_hand" , "You can put it on your hands" , "It goes on a human's hands"}, + {"body_wrist" , "You can wear it around your wrists" , "It goes around a human's wrist"}, + {"body_waist" , "You can wear it around your waist" , "It goes around a human's waist"}, /*{"body_dragon_torso", "your body", "a dragon's body"} */ }; @@ -252,10 +254,9 @@ int get_power_from_ench (int ench) { - if (ench < 0) - ench = 0; - if (ench > 20) - ench = 20; + if (ench < 0) ench = 0; + if (ench > 20) ench = 20; + return enc_to_item_power[ench]; } @@ -344,12 +345,10 @@ enc += 1; return get_power_from_ench (enc); - } /* returns the typedata that has a number equal to itemtype, if there * isn't one, returns NULL */ - const typedata * get_typedata (int itemtype) { @@ -364,7 +363,6 @@ /* 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 * get_typedata_by_name (const char *name) { @@ -389,7 +387,7 @@ * if newline is true, we don't put parens around the description * but do put a newline at the end. Useful when dumping to files */ -char * +const char * describe_resistance (const object *op, int newline) { static char buf[VERY_BIG_BUF]; @@ -418,8 +416,7 @@ * containing the text-representation of the weight of the given object. * The buffer will be overwritten by the next call to query_weight(). */ - -char * +const char * query_weight (const object *op) { static char buf[10]; @@ -427,10 +424,12 @@ if (op->weight < 0) return " "; + if (i % 1000) sprintf (buf, "%6.1f", i / 1000.0); else sprintf (buf, "%4d ", i / 1000); + return buf; } @@ -438,8 +437,7 @@ * Returns the pointer to a static buffer containing * the number requested (of the form first, second, third...) */ - -char * +const char * get_levelnumber (int i) { static char buf[MAX_BUF]; @@ -449,24 +447,24 @@ sprintf (buf, "%d.", i); return buf; } + if (i < 21) return levelnumbers[i]; if (!(i % 10)) return levelnumbers_10[i / 10]; + strcpy (buf, numbers_10[i / 10]); strcat (buf, levelnumbers[i % 10]); 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 * +const char * get_number (int i) { if (i <= 20) @@ -493,7 +491,7 @@ /* Aug 95 modified this slightly so that Skill tools don't have magic bonus * from stats.sp - b.t. */ -char * +const char * ring_desc (const object *op) { static char buf[VERY_BIG_BUF]; @@ -511,6 +509,7 @@ sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); } } + if (op->stats.exp) sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); if (op->stats.wc) @@ -542,6 +541,7 @@ strcat (buf, "(reflect missiles)"); if (QUERY_FLAG (op, FLAG_STEALTH)) strcat (buf, "(stealth)"); + /* Shorten some of the names, so they appear better in the windows */ len = strlen (buf); DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); @@ -616,7 +616,7 @@ if (!op->title) { /* If ring has a title, full description isn't so useful */ - char *s = ring_desc (op); + const char *s = ring_desc (op); if (s[0]) { @@ -646,10 +646,10 @@ * use several names much easier (don't need to store them to temp variables.) * */ -char * +const 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; @@ -686,6 +686,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 @@ -711,39 +712,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], op->env && op->env->current_weapon == op ? " (readied)" : " (applied)", &len, HUGE_BUF); + break; + case WEAPON: + safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (wielded)" : " (applied)", &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]; } /* @@ -833,7 +835,7 @@ if (!op->title) { /* If ring has a title, full description isn't so useful */ - char *s = ring_desc (op); + const char *s = ring_desc (op); if (s[0]) { @@ -842,11 +844,10 @@ } } 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); - } + sprintf (buf + strlen (buf), " %+d", op->magic); } return buf; @@ -1041,8 +1042,7 @@ * owner can be null if no one is being associated with this * item (eg, debug dump or the like) */ - -char * +const char * describe_item (const object *op, object *owner) { char buf[MAX_BUF]; @@ -1362,6 +1362,12 @@ return retbuf; } +std::string +object::describe_item (object *who) +{ + return std::string (::describe_item (this, who)); +} + /* 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. @@ -1522,7 +1528,7 @@ /* If the object is on a map, make sure we update its face */ if (op->map) - update_object (op, UP_OBJ_FACE); + update_object (op, UP_OBJ_CHANGE); else { pl = op->in_player ();