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.30 by root, Mon Sep 11 20:28:37 2006 UTC vs.
Revision 1.34 by root, Tue Sep 12 01:09:53 2006 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 <skills.h>
35#include <loader.h> 34#include <loader.h>
36 35
37int nrofallocobjects = 0; 36int nrofallocobjects = 0;
38 37
39object *objects; /* Pointer to the list of used objects */ 38object *objects; /* Pointer to the list of used objects */
623/* 622/*
624 * Updates the speed of an object. If the speed changes from 0 to another 623 * Updates the speed of an object. If the speed changes from 0 to another
625 * value, or vice versa, then add/remove the object from the active list. 624 * value, or vice versa, then add/remove the object from the active list.
626 * This function needs to be called whenever the speed of an object changes. 625 * This function needs to be called whenever the speed of an object changes.
627 */ 626 */
628
629void 627void
630update_ob_speed (object *op) 628update_ob_speed (object *op)
631{ 629{
632 extern int arch_init; 630 extern int arch_init;
633 631
642 abort (); 640 abort ();
643#else 641#else
644 op->speed = 0; 642 op->speed = 0;
645#endif 643#endif
646 } 644 }
645
647 if (arch_init) 646 if (arch_init)
648 {
649 return; 647 return;
650 } 648
651 if (FABS (op->speed) > MIN_ACTIVE_SPEED) 649 if (FABS (op->speed) > MIN_ACTIVE_SPEED)
652 { 650 {
653 /* If already on active list, don't do anything */ 651 /* If already on active list, don't do anything */
654 if (op->active_next || op->active_prev || op == active_objects) 652 if (op->active_next || op->active_prev || op == active_objects)
655 return; 653 return;
656 654
657 /* process_events() expects us to insert the object at the beginning 655 /* process_events() expects us to insert the object at the beginning
658 * of the list. */ 656 * of the list. */
659 op->active_next = active_objects; 657 op->active_next = active_objects;
658
660 if (op->active_next != NULL) 659 if (op->active_next != NULL)
661 op->active_next->active_prev = op; 660 op->active_next->active_prev = op;
661
662 active_objects = op; 662 active_objects = op;
663 } 663 }
664 else 664 else
665 { 665 {
666 /* If not on the active list, nothing needs to be done */ 666 /* If not on the active list, nothing needs to be done */
668 return; 668 return;
669 669
670 if (op->active_prev == NULL) 670 if (op->active_prev == NULL)
671 { 671 {
672 active_objects = op->active_next; 672 active_objects = op->active_next;
673
673 if (op->active_next != NULL) 674 if (op->active_next != NULL)
674 op->active_next->active_prev = NULL; 675 op->active_next->active_prev = NULL;
675 } 676 }
676 else 677 else
677 { 678 {
678 op->active_prev->active_next = op->active_next; 679 op->active_prev->active_next = op->active_next;
680
679 if (op->active_next) 681 if (op->active_next)
680 op->active_next->active_prev = op->active_prev; 682 op->active_next->active_prev = op->active_prev;
681 } 683 }
684
682 op->active_next = NULL; 685 op->active_next = NULL;
683 op->active_prev = NULL; 686 op->active_prev = NULL;
684 } 687 }
685} 688}
686 689
901 objects = next; 904 objects = next;
902} 905}
903 906
904object *object::create () 907object *object::create ()
905{ 908{
906 object * 909 object *op;
907 op;
908 910
909 if (freed.empty ()) 911 if (freed.empty ())
910 op = new object; 912 op = new object;
911 else 913 else
912 { 914 {
934void object::free (bool free_inventory) 936void object::free (bool free_inventory)
935{ 937{
936 if (QUERY_FLAG (this, FLAG_FREED)) 938 if (QUERY_FLAG (this, FLAG_FREED))
937 return; 939 return;
938 940
941 if (QUERY_FLAG (this, FLAG_FRIENDLY))
942 remove_friendly_object (this);
943
939 if (!QUERY_FLAG (this, FLAG_REMOVED)) 944 if (!QUERY_FLAG (this, FLAG_REMOVED))
940 remove_ob (this); 945 remove_ob (this);
941
942 if (QUERY_FLAG (this, FLAG_FRIENDLY))
943 remove_friendly_object (this);
944 946
945 SET_FLAG (this, FLAG_FREED); 947 SET_FLAG (this, FLAG_FREED);
946 948
947 if (more) 949 if (more)
948 { 950 {
954 { 956 {
955 /* Only if the space blocks everything do we not process - 957 /* Only if the space blocks everything do we not process -
956 * if some form of movement is allowed, let objects 958 * if some form of movement is allowed, let objects
957 * drop on that space. 959 * drop on that space.
958 */ 960 */
959 if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || (GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)) 961 if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)
960 { 962 {
961 object *op = inv; 963 object *op = inv;
962 964
963 while (op) 965 while (op)
964 { 966 {
2840{ 2842{
2841 shstr key_ (key); 2843 shstr key_ (key);
2842 2844
2843 return set_ob_key_value_s (op, key_, value, add_key); 2845 return set_ob_key_value_s (op, key_, value, add_key);
2844} 2846}
2847
2848object::depth_iterator::depth_iterator (object *container)
2849: iterator_base (container)
2850{
2851 while (item->inv)
2852 item = item->inv;
2853}
2854
2855void
2856object::depth_iterator::next ()
2857{
2858 if (item->below)
2859 {
2860 item = item->below;
2861
2862 while (item->inv)
2863 item = item->inv;
2864 }
2865 else
2866 item = item->env;
2867}
2868

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines