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.146 by root, Fri May 11 21:07:13 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 *
29#include <stdio.h> 29#include <stdio.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/uio.h> 31#include <sys/uio.h>
32#include <object.h> 32#include <object.h>
33#include <funcpoint.h> 33#include <funcpoint.h>
34#include <sproto.h>
34#include <loader.h> 35#include <loader.h>
35 36
36#include <bitset> 37#include <bitset>
37 38
38int nrofallocobjects = 0; 39int nrofallocobjects = 0;
324sum_weight (object *op) 325sum_weight (object *op)
325{ 326{
326 long sum; 327 long sum;
327 object *inv; 328 object *inv;
328 329
329 for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) 330 for (sum = 0, inv = op->inv; inv; inv = inv->below)
330 { 331 {
331 if (inv->inv) 332 if (inv->inv)
332 sum_weight (inv); 333 sum_weight (inv);
334
333 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); 335 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1);
334 } 336 }
335 337
336 if (op->type == CONTAINER && op->stats.Str) 338 if (op->type == CONTAINER && op->stats.Str)
337 sum = (sum * (100 - op->stats.Str)) / 100; 339 sum = (sum * (100 - op->stats.Str)) / 100;
446 */ 448 */
447 while (owner->owner) 449 while (owner->owner)
448 owner = owner->owner; 450 owner = owner->owner;
449 451
450 this->owner = owner; 452 this->owner = owner;
453}
454
455void
456object::set_weapon (object *ob)
457{
458 if (current_weapon == ob)
459 return;
460
461 new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
462
463 if (chosen_skill)
464 chosen_skill->flag [FLAG_APPLIED] = false;
465
466 current_weapon = ob;
467 chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill);
468
469 if (chosen_skill)
470 chosen_skill->flag [FLAG_APPLIED] = true;
471
472 update_stats ();
451} 473}
452 474
453/* Zero the key_values on op, decrementing the shared-string 475/* Zero the key_values on op, decrementing the shared-string
454 * refcounts and freeing the links. 476 * refcounts and freeing the links.
455 */ 477 */
537 * need for monsters, but doesn't hurt to do it for everything. 559 * 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 560 * by doing so, when a monster is created, it has good starting
539 * values for the body_used info, so when items are created 561 * values for the body_used info, so when items are created
540 * for it, they can be properly equipped. 562 * for it, they can be properly equipped.
541 */ 563 */
542 memcpy (body_used, body_info, sizeof (body_used)); 564 for (int i = NUM_BODY_LOCATIONS; i--; )
565 slot[i].used = slot[i].info;
543 566
544 attachable::instantiate (); 567 attachable::instantiate ();
545} 568}
546 569
547object * 570object *
835 858
836 if (flag [FLAG_IS_LINKED]) 859 if (flag [FLAG_IS_LINKED])
837 remove_button_link (this); 860 remove_button_link (this);
838 861
839 if (flag [FLAG_FRIENDLY]) 862 if (flag [FLAG_FRIENDLY])
840 {
841 remove_friendly_object (this); 863 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 864
850 if (!flag [FLAG_REMOVED]) 865 if (!flag [FLAG_REMOVED])
851 remove (); 866 remove ();
852 867
853 destroy_inv (true); 868 destroy_inv (true);
1180 1195
1181 object *tmp, *top, *floor = NULL; 1196 object *tmp, *top, *floor = NULL;
1182 1197
1183 op->remove (); 1198 op->remove ();
1184 1199
1200#if 0
1185 if (!m->active != !op->active) 1201 if (!m->active != !op->active)
1186 if (m->active) 1202 if (m->active)
1187 op->activate_recursive (); 1203 op->activate_recursive ();
1188 else 1204 else
1189 op->deactivate_recursive (); 1205 op->deactivate_recursive ();
1206#endif
1190 1207
1191 if (out_of_map (m, op->x, op->y)) 1208 if (out_of_map (m, op->x, op->y))
1192 { 1209 {
1193 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ()); 1210 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ());
1194#ifdef MANY_CORES 1211#ifdef MANY_CORES
2589} 2606}
2590 2607
2591const char * 2608const char *
2592object::debug_desc () const 2609object::debug_desc () const
2593{ 2610{
2594 static char info[256 * 4]; 2611 static char info[3][256 * 4];
2612 static int info_idx;
2613
2595 return debug_desc (info); 2614 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} 2615}
2604 2616
2605struct region * 2617struct region *
2606object::region () const 2618object::region () const
2607{ 2619{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines