--- deliantra/server/common/object.C 2007/04/24 12:32:14 1.140 +++ deliantra/server/common/object.C 2007/05/11 21:07:13 1.146 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -326,10 +327,11 @@ long sum; object *inv; - for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) + for (sum = 0, inv = op->inv; inv; inv = inv->below) { if (inv->inv) sum_weight (inv); + sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); } @@ -450,6 +452,26 @@ this->owner = owner; } +void +object::set_weapon (object *ob) +{ + if (current_weapon == ob) + return; + + new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); + + if (chosen_skill) + chosen_skill->flag [FLAG_APPLIED] = false; + + current_weapon = ob; + chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); + + if (chosen_skill) + chosen_skill->flag [FLAG_APPLIED] = true; + + update_stats (); +} + /* Zero the key_values on op, decrementing the shared-string * refcounts and freeing the links. */ @@ -539,7 +561,8 @@ * values for the body_used info, so when items are created * for it, they can be properly equipped. */ - memcpy (body_used, body_info, sizeof (body_used)); + for (int i = NUM_BODY_LOCATIONS; i--; ) + slot[i].used = slot[i].info; attachable::instantiate (); } @@ -2585,15 +2608,10 @@ const char * object::debug_desc () const { - static char info[256 * 4]; - return debug_desc (info); -} + static char info[3][256 * 4]; + static int info_idx; -const char * -object::debug_desc2 () const -{ - static char info[256 * 4]; - return debug_desc (info); + return debug_desc (info [++info_idx % 3]); } struct region *