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.317 by root, Fri Apr 2 03:41:24 2010 UTC vs.
Revision 1.320 by root, Wed Apr 7 19:54:44 2010 UTC

574 } 574 }
575 575
576 this->owner = owner; 576 this->owner = owner;
577} 577}
578 578
579int
580object::slottype () const
581{
582 if (type == SKILL)
583 {
584 if (IS_COMBAT_SKILL (subtype)) return slot_combat;
585 if (IS_RANGED_SKILL (subtype)) return slot_ranged;
586 }
587 else
588 {
589 if (slot [body_combat].info) return slot_combat;
590 if (slot [body_range ].info) return slot_ranged;
591 }
592
593 return slot_none;
594}
595
596bool
597object::change_weapon (object *ob)
598{
599 if (current_weapon == ob)
600 return true;
601
602 if (current_weapon && current_weapon->flag [FLAG_APPLIED])
603 {
604 manual_apply (this, current_weapon, AP_UNAPPLY);
605
606 if (current_weapon && !current_weapon->flag [FLAG_APPLIED])//D
607 LOG (llevError, "FATAL: did not clear current_weapon (%s)\n", current_weapon->debug_desc ());
608
609 if (current_weapon && current_weapon->flag [FLAG_APPLIED])
610 return false;
611 }
612
613 current_weapon = 0;
614
615 if (ob && !ob->flag [FLAG_APPLIED])
616 {
617 manual_apply (this, ob, AP_APPLY);
618
619 if (ob->flag [FLAG_APPLIED])
620 current_weapon = ob;
621 else
622 return false;
623 }
624
625 return true;
626}
627
628/* Zero the key_values on op, decrementing the shared-string 579/* Zero the key_values on op, decrementing the shared-string
629 * refcounts and freeing the links. 580 * refcounts and freeing the links.
630 */ 581 */
631static void 582static void
632free_key_values (object *op) 583free_key_values (object *op)
988 map->insert (op, x, y); 939 map->insert (op, x, y);
989 } 940 }
990 } 941 }
991} 942}
992 943
944/*
945 * Remove and free all objects in the inventory of the given object.
946 * Unlike destroy_inv, this assumes the *this is destroyed as well
947 * well, so we can (and have to!) take shortcuts.
948 */
949void
950object::destroy_inv_fast ()
951{
952 while (object *op = inv)
953 {
954 // remove from object the fast way
955 op->flag [FLAG_REMOVED] = true;
956 op->env = 0;
957 if ((inv = inv->below))
958 inv->above = 0;
959
960 // then destroy
961 op->destroy ();
962 }
963}
964
993object *object::create () 965object *object::create ()
994{ 966{
995 object *op = new object; 967 object *op = new object;
996 op->link (); 968 op->link ();
997 return op; 969 return op;
1067 LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); 1039 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1068 head->destroy (); 1040 head->destroy ();
1069 return; 1041 return;
1070 } 1042 }
1071 1043
1072 destroy_inv (false); 1044 destroy_inv_fast ();
1073 1045
1074 if (is_head ()) 1046 if (is_head ())
1075 if (sound_destroy) 1047 if (sound_destroy)
1076 play_sound (sound_destroy); 1048 play_sound (sound_destroy);
1077 else if (flag [FLAG_MONSTER]) 1049 else if (flag [FLAG_MONSTER])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines