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.1 by elmex, Sun Aug 13 17:16:00 2006 UTC vs.
Revision 1.4 by root, Sat Aug 26 23:36:30 2006 UTC

1/* 1/*
2 * static char *rcsid_object_c = 2 * static char *rcsid_object_c =
3 * "$Id: object.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; 3 * "$Id: object.C,v 1.4 2006/08/26 23:36:30 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
51#endif 51#endif
52 52
53object *objects; /* Pointer to the list of used objects */ 53object *objects; /* Pointer to the list of used objects */
54object *free_objects; /* Pointer to the list of unused objects */ 54object *free_objects; /* Pointer to the list of unused objects */
55object *active_objects; /* List of active objects that need to be processed */ 55object *active_objects; /* List of active objects that need to be processed */
56
57void (*object_free_callback)(object *ob);
58 56
59short freearr_x[SIZEOFFREE]= 57short freearr_x[SIZEOFFREE]=
60 {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1, 58 {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,
61 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1}; 59 0,1,2,3,3,3,3,3,3,3,2,1,0,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1};
62short freearr_y[SIZEOFFREE]= 60short freearr_y[SIZEOFFREE]=
581 * clear_object() frees everything allocated by an object, and also 579 * clear_object() frees everything allocated by an object, and also
582 * clears all variables and flags to default settings. 580 * clears all variables and flags to default settings.
583 */ 581 */
584 582
585void clear_object(object *op) { 583void clear_object(object *op) {
584 op->clear ();
586 585
587 event *evt; 586 event *evt;
588 event *evt2; 587 event *evt2;
589 588
590 /* redo this to be simpler/more efficient. Was also seeing 589 /* redo this to be simpler/more efficient. Was also seeing
661 660
662void copy_object(object *op2, object *op) { 661void copy_object(object *op2, object *op) {
663 int is_freed=QUERY_FLAG(op,FLAG_FREED),is_removed=QUERY_FLAG(op,FLAG_REMOVED); 662 int is_freed=QUERY_FLAG(op,FLAG_FREED),is_removed=QUERY_FLAG(op,FLAG_REMOVED);
664 event *evt, *evt2, *evt_new; 663 event *evt, *evt2, *evt_new;
665 664
665 op->clear ();
666
666 /* Decrement the refcounts, but don't bother zeroing the fields; 667 /* Decrement the refcounts, but don't bother zeroing the fields;
667 they'll be overwritten by memcpy. */ 668 they'll be overwritten by memcpy. */
668 if(op->name!=NULL) free_string(op->name); 669 if(op->name!=NULL) free_string(op->name);
669 if(op->name_pl!=NULL) free_string(op->name_pl); 670 if(op->name_pl!=NULL) free_string(op->name_pl);
670 if(op->title!=NULL) free_string(op->title); 671 if(op->title!=NULL) free_string(op->title);
689 op->events = NULL; 690 op->events = NULL;
690 691
691 free_key_values(op); 692 free_key_values(op);
692 693
693 *(object_special *)op = *(object_special *)op2; 694 *(object_special *)op = *(object_special *)op2;
695 op2->clone (op);
694 696
695 if(is_freed) SET_FLAG(op,FLAG_FREED); 697 if(is_freed) SET_FLAG(op,FLAG_FREED);
696 if(is_removed) SET_FLAG(op,FLAG_REMOVED); 698 if(is_removed) SET_FLAG(op,FLAG_REMOVED);
697 if(op->name!=NULL) add_refcount(op->name); 699 if(op->name!=NULL) add_refcount(op->name);
698 if(op->name_pl!=NULL) add_refcount(op->name_pl); 700 if(op->name_pl!=NULL) add_refcount(op->name_pl);
754 tail->next = new_link; 756 tail->next = new_link;
755 tail = new_link; 757 tail = new_link;
756 } 758 }
757 } 759 }
758 } 760 }
759 761
760 update_ob_speed(op); 762 update_ob_speed(op);
761} 763}
762 764
763/* 765/*
764 * expand_objects() allocates more objects for the list of unused objects. 766 * expand_objects() allocates more objects for the list of unused objects.
1063 free_object2(ob, 0); 1065 free_object2(ob, 0);
1064} 1066}
1065void free_object2(object *ob, int free_inventory) { 1067void free_object2(object *ob, int free_inventory) {
1066 object *tmp,*op; 1068 object *tmp,*op;
1067 1069
1068 if (object_free_callback) 1070 ob->clear ();
1069 object_free_callback (ob);
1070 1071
1071 if (!QUERY_FLAG(ob,FLAG_REMOVED)) { 1072 if (!QUERY_FLAG(ob,FLAG_REMOVED)) {
1072 LOG(llevDebug,"Free object called with non removed object\n"); 1073 LOG(llevDebug,"Free object called with non removed object\n");
1073 dump_object(ob); 1074 dump_object(ob);
1074#ifdef MANY_CORES 1075#ifdef MANY_CORES

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines