--- deliantra/server/common/object.C 2007/04/21 16:56:29 1.138 +++ deliantra/server/common/object.C 2007/05/11 21:07:13 1.146 @@ -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) 2001 Mark Wedel & Crossfire Development Team @@ -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 (); } @@ -837,15 +860,7 @@ remove_button_link (this); if (flag [FLAG_FRIENDLY]) - { - remove_friendly_object (this); - - if (type == GOLEM - && owner - && owner->type == PLAYER - && owner->contr->ranges[range_golem] == this) - owner->contr->ranges[range_golem] = 0; - } + remove_friendly_object (this); if (!flag [FLAG_REMOVED]) remove (); @@ -1182,11 +1197,13 @@ op->remove (); +#if 0 if (!m->active != !op->active) if (m->active) op->activate_recursive (); else op->deactivate_recursive (); +#endif if (out_of_map (m, op->x, op->y)) { @@ -2591,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 *