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.142 by root, Mon Apr 30 04:25:29 2007 UTC vs.
Revision 1.148 by root, Mon May 14 19:08:25 2007 UTC

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;
449 owner = owner->owner; 450 owner = owner->owner;
450 451
451 this->owner = owner; 452 this->owner = owner;
452} 453}
453 454
455int
456object::slottype () const
457{
458 if (type == SKILL)
459 {
460 if (IS_COMBAT_SKILL (subtype)) return slot_combat;
461 if (IS_RANGED_SKILL (subtype)) return slot_ranged;
462 }
463 else
464 {
465 if (slot [body_combat].info) return slot_combat;
466 if (slot [body_range ].info) return slot_ranged;
467 }
468
469 return slot_none;
470}
471
472bool
473object::change_weapon (object *ob)
474{
475 if (current_weapon == ob)
476 return true;
477
478 if (chosen_skill)
479 chosen_skill->flag [FLAG_APPLIED] = false;
480
481 current_weapon = ob;
482 chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill);
483
484 if (chosen_skill)
485 chosen_skill->flag [FLAG_APPLIED] = true;
486
487 update_stats ();
488
489 if (ob)
490 {
491 // now check wether any body locations became invalid, in which case
492 // we cannot apply the weapon at the moment.
493 for (int i = 0; i < NUM_BODY_LOCATIONS; ++i)
494 if (slot[i].used < 0)
495 {
496 current_weapon = chosen_skill = 0;
497 update_stats ();
498
499 new_draw_info_format (NDI_UNIQUE, 0, this,
500 "You try to balance your applied items all at once, but the %s is too much. "
501 "You need to unapply some items first.", &ob->name);
502 return false;
503 }
504
505 //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
506 }
507 else
508 ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons.");
509
510 return true;
511}
512
454/* Zero the key_values on op, decrementing the shared-string 513/* Zero the key_values on op, decrementing the shared-string
455 * refcounts and freeing the links. 514 * refcounts and freeing the links.
456 */ 515 */
457static void 516static void
458free_key_values (object *op) 517free_key_values (object *op)
538 * need for monsters, but doesn't hurt to do it for everything. 597 * need for monsters, but doesn't hurt to do it for everything.
539 * by doing so, when a monster is created, it has good starting 598 * by doing so, when a monster is created, it has good starting
540 * values for the body_used info, so when items are created 599 * values for the body_used info, so when items are created
541 * for it, they can be properly equipped. 600 * for it, they can be properly equipped.
542 */ 601 */
543 memcpy (body_used, body_info, sizeof (body_used)); 602 for (int i = NUM_BODY_LOCATIONS; i--; )
603 slot[i].used = slot[i].info;
544 604
545 attachable::instantiate (); 605 attachable::instantiate ();
546} 606}
547 607
548object * 608object *
2584} 2644}
2585 2645
2586const char * 2646const char *
2587object::debug_desc () const 2647object::debug_desc () const
2588{ 2648{
2589 static char info[256 * 4]; 2649 static char info[3][256 * 4];
2650 static int info_idx;
2651
2590 return debug_desc (info); 2652 return debug_desc (info [++info_idx % 3]);
2591}
2592
2593const char *
2594object::debug_desc2 () const
2595{
2596 static char info[256 * 4];
2597 return debug_desc (info);
2598} 2653}
2599 2654
2600struct region * 2655struct region *
2601object::region () const 2656object::region () const
2602{ 2657{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines