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.86 by root, Tue Dec 26 08:17:58 2006 UTC vs.
Revision 1.87 by root, Tue Dec 26 08:54:59 2006 UTC

522 tail = new_link; 522 tail = new_link;
523 } 523 }
524 } 524 }
525 } 525 }
526 526
527 update_ob_speed (dst); 527 dst->set_speed (dst->speed);
528} 528}
529 529
530object * 530object *
531object::clone () 531object::clone ()
532{ 532{
554 * Updates the speed of an object. If the speed changes from 0 to another 554 * Updates the speed of an object. If the speed changes from 0 to another
555 * value, or vice versa, then add/remove the object from the active list. 555 * value, or vice versa, then add/remove the object from the active list.
556 * This function needs to be called whenever the speed of an object changes. 556 * This function needs to be called whenever the speed of an object changes.
557 */ 557 */
558void 558void
559update_ob_speed (object *op) 559object::set_speed (float speed)
560{ 560{
561 extern int arch_init; 561 extern int arch_init;
562 562
563 /* No reason putting the archetypes objects on the speed list, 563 /* No reason putting the archetypes objects on the speed list,
564 * since they never really need to be updated. 564 * since they never really need to be updated.
565 */ 565 */
566 if (QUERY_FLAG (op, FLAG_FREED) && op->speed) 566 if (flag [FLAG_FREED] && speed)
567 { 567 {
568 LOG (llevError, "Object %s is freed but has speed.\n", &op->name); 568 LOG (llevError, "Object %s is freed but has speed.\n", &name);
569 op->speed = 0; 569 speed = 0;
570 } 570 }
571
572 this->speed = speed;
571 573
572 if (arch_init) 574 if (arch_init)
573 return; 575 return;
574 576
575 if (FABS (op->speed) > MIN_ACTIVE_SPEED) 577 if (FABS (speed) > MIN_ACTIVE_SPEED)
576 { 578 {
577 /* If already on active list, don't do anything */ 579 /* If already on active list, don't do anything */
578 if (op->active_next || op->active_prev || op == active_objects) 580 if (active_next || active_prev || this == active_objects)
579 return; 581 return;
580 582
581 /* process_events() expects us to insert the object at the beginning 583 /* process_events() expects us to insert the object at the beginning
582 * of the list. */ 584 * of the list. */
583 op->active_next = active_objects; 585 active_next = active_objects;
584 586
585 if (op->active_next != NULL) 587 if (active_next)
586 op->active_next->active_prev = op; 588 active_next->active_prev = this;
587 589
588 active_objects = op; 590 active_objects = this;
589 } 591 }
590 else 592 else
591 { 593 {
592 /* If not on the active list, nothing needs to be done */ 594 /* If not on the active list, nothing needs to be done */
593 if (!op->active_next && !op->active_prev && op != active_objects) 595 if (!active_next && !active_prev && this != active_objects)
594 return; 596 return;
595 597
596 if (op->active_prev == NULL) 598 if (!active_prev)
597 { 599 {
598 active_objects = op->active_next; 600 active_objects = active_next;
599 601
600 if (op->active_next != NULL) 602 if (active_next)
601 op->active_next->active_prev = NULL; 603 active_next->active_prev = 0;
602 } 604 }
603 else 605 else
604 { 606 {
605 op->active_prev->active_next = op->active_next; 607 active_prev->active_next = active_next;
606 608
607 if (op->active_next) 609 if (active_next)
608 op->active_next->active_prev = op->active_prev; 610 active_next->active_prev = active_prev;
609 } 611 }
610 612
611 op->active_next = NULL; 613 active_next = 0;
612 op->active_prev = NULL; 614 active_prev = 0;
613 } 615 }
614} 616}
615 617
616/* This function removes object 'op' from the list of active 618/* This function removes object 'op' from the list of active
617 * objects. 619 * objects.
783 object *op = new object; 785 object *op = new object;
784 op->link (); 786 op->link ();
785 return op; 787 return op;
786} 788}
787 789
788/*
789 * free_object() frees everything allocated by an object, removes
790 * it from the list of used objects, and puts it on the list of
791 * free objects. The IS_FREED() flag is set in the object.
792 * The object must have been removed by remove_ob() first for
793 * this function to succeed.
794 *
795 * If destroy_inventory is set, free inventory as well. Else drop items in
796 * inventory to the ground.
797 */
798void 790void
799object::do_destroy () 791object::do_destroy ()
800{ 792{
801 attachable::do_destroy (); 793 attachable::do_destroy ();
802 794
845 837
846 // only relevant for players(?), but make sure of it anyways 838 // only relevant for players(?), but make sure of it anyways
847 contr = 0; 839 contr = 0;
848 840
849 /* Remove object from the active list */ 841 /* Remove object from the active list */
850 speed = 0; 842 set_speed (0);
851 update_ob_speed (this);
852 843
853 unlink (); 844 unlink ();
854} 845}
855 846
856/* 847/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines