ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.138 by root, Sat Apr 21 16:56:29 2007 UTC vs.
Revision 1.145 by root, Mon May 7 03:05:58 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
324sum_weight (object *op) 324sum_weight (object *op)
325{ 325{
326 long sum; 326 long sum;
327 object *inv; 327 object *inv;
328 328
329 for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) 329 for (sum = 0, inv = op->inv; inv; inv = inv->below)
330 { 330 {
331 if (inv->inv) 331 if (inv->inv)
332 sum_weight (inv); 332 sum_weight (inv);
333
333 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); 334 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1);
334 } 335 }
335 336
336 if (op->type == CONTAINER && op->stats.Str) 337 if (op->type == CONTAINER && op->stats.Str)
337 sum = (sum * (100 - op->stats.Str)) / 100; 338 sum = (sum * (100 - op->stats.Str)) / 100;
446 */ 447 */
447 while (owner->owner) 448 while (owner->owner)
448 owner = owner->owner; 449 owner = owner->owner;
449 450
450 this->owner = owner; 451 this->owner = owner;
452}
453
454void
455object::set_weapon (object *ob)
456{
457 if (current_weapon == ob)
458 return;
459
460 current_weapon = ob;
461 new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
462 update_stats ();
451} 463}
452 464
453/* Zero the key_values on op, decrementing the shared-string 465/* Zero the key_values on op, decrementing the shared-string
454 * refcounts and freeing the links. 466 * refcounts and freeing the links.
455 */ 467 */
537 * need for monsters, but doesn't hurt to do it for everything. 549 * need for monsters, but doesn't hurt to do it for everything.
538 * by doing so, when a monster is created, it has good starting 550 * by doing so, when a monster is created, it has good starting
539 * values for the body_used info, so when items are created 551 * values for the body_used info, so when items are created
540 * for it, they can be properly equipped. 552 * for it, they can be properly equipped.
541 */ 553 */
542 memcpy (body_used, body_info, sizeof (body_used)); 554 for (int i = NUM_BODY_LOCATIONS; i--; )
555 slot[i].used = slot[i].info;
543 556
544 attachable::instantiate (); 557 attachable::instantiate ();
545} 558}
546 559
547object * 560object *
835 848
836 if (flag [FLAG_IS_LINKED]) 849 if (flag [FLAG_IS_LINKED])
837 remove_button_link (this); 850 remove_button_link (this);
838 851
839 if (flag [FLAG_FRIENDLY]) 852 if (flag [FLAG_FRIENDLY])
840 {
841 remove_friendly_object (this); 853 remove_friendly_object (this);
842
843 if (type == GOLEM
844 && owner
845 && owner->type == PLAYER
846 && owner->contr->ranges[range_golem] == this)
847 owner->contr->ranges[range_golem] = 0;
848 }
849 854
850 if (!flag [FLAG_REMOVED]) 855 if (!flag [FLAG_REMOVED])
851 remove (); 856 remove ();
852 857
853 destroy_inv (true); 858 destroy_inv (true);
1180 1185
1181 object *tmp, *top, *floor = NULL; 1186 object *tmp, *top, *floor = NULL;
1182 1187
1183 op->remove (); 1188 op->remove ();
1184 1189
1190#if 0
1185 if (!m->active != !op->active) 1191 if (!m->active != !op->active)
1186 if (m->active) 1192 if (m->active)
1187 op->activate_recursive (); 1193 op->activate_recursive ();
1188 else 1194 else
1189 op->deactivate_recursive (); 1195 op->deactivate_recursive ();
1196#endif
1190 1197
1191 if (out_of_map (m, op->x, op->y)) 1198 if (out_of_map (m, op->x, op->y))
1192 { 1199 {
1193 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ()); 1200 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ());
1194#ifdef MANY_CORES 1201#ifdef MANY_CORES
2589} 2596}
2590 2597
2591const char * 2598const char *
2592object::debug_desc () const 2599object::debug_desc () const
2593{ 2600{
2594 static char info[256 * 4]; 2601 static char info[3][256 * 4];
2602 static int info_idx;
2603
2595 return debug_desc (info); 2604 return debug_desc (info [++info_idx % 3]);
2596}
2597
2598const char *
2599object::debug_desc2 () const
2600{
2601 static char info[256 * 4];
2602 return debug_desc (info);
2603} 2605}
2604 2606
2605struct region * 2607struct region *
2606object::region () const 2608object::region () const
2607{ 2609{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines