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.43 by root, Thu Sep 14 17:10:24 2006 UTC vs.
Revision 1.46 by root, Thu Sep 14 21:16:11 2006 UTC

35 35
36int nrofallocobjects = 0; 36int nrofallocobjects = 0;
37static UUID uuid; 37static UUID uuid;
38const uint64 UUID_SKIP = 1<<19; 38const uint64 UUID_SKIP = 1<<19;
39 39
40object *objects; /* Pointer to the list of used objects */
41object *active_objects; /* List of active objects that need to be processed */ 40object *active_objects; /* List of active objects that need to be processed */
42 41
43short freearr_x[SIZEOFFREE] = { 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, 42short freearr_x[SIZEOFFREE] = { 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,
44 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1 43 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1
45}; 44};
447void 446void
448dump_all_objects (void) 447dump_all_objects (void)
449{ 448{
450 object *op; 449 object *op;
451 450
452 for (op = objects; op != NULL; op = op->next) 451 for (op = object::first; op != NULL; op = op->next)
453 { 452 {
454 dump_object (op); 453 dump_object (op);
455 fprintf (logfile, "Object %d\n:%s\n", op->count, errmsg); 454 fprintf (logfile, "Object %d\n:%s\n", op->count, errmsg);
456 } 455 }
457} 456}
483object * 482object *
484find_object (tag_t i) 483find_object (tag_t i)
485{ 484{
486 object *op; 485 object *op;
487 486
488 for (op = objects; op != NULL; op = op->next) 487 for (op = object::first; op != NULL; op = op->next)
489 if (op->count == i) 488 if (op->count == i)
490 break; 489 break;
491 return op; 490 return op;
492} 491}
493 492
501find_object_name (const char *str) 500find_object_name (const char *str)
502{ 501{
503 shstr_cmp str_ (str); 502 shstr_cmp str_ (str);
504 object *op; 503 object *op;
505 504
506 for (op = objects; op != NULL; op = op->next) 505 for (op = object::first; op != NULL; op = op->next)
507 if (op->name == str_) 506 if (op->name == str_)
508 break; 507 break;
509 508
510 return op; 509 return op;
511} 510}
895 894
896 if (op->more != NULL) 895 if (op->more != NULL)
897 update_object (op->more, action); 896 update_object (op->more, action);
898} 897}
899 898
900static unordered_vector<object *> mortals; 899object::vector object::mortals;
900object::vector object::objects; // not yet used
901object *object::first;
901 902
902void object::free_mortals () 903void object::free_mortals ()
903{ 904{
904 for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) 905 for (AUTODECL (i, mortals.begin ()); i != mortals.end ();)
905 if ((*i)->refcnt) 906 if ((*i)->refcnt)
906 ++i; // further delay freeing 907 ++i; // further delay freeing
907 else 908 else
908 { 909 {
909 delete *i; 910 delete *i;
936{ 937{
937 count = ++ob_count; 938 count = ++ob_count;
938 uuid = gen_uuid (); 939 uuid = gen_uuid ();
939 940
940 prev = 0; 941 prev = 0;
941 next = objects; 942 next = object::first;
942 943
943 if (objects) 944 if (object::first)
944 objects->prev = this; 945 object::first->prev = this;
945 946
946 objects = this; 947 object::first = this;
947} 948}
948 949
949void object::unlink () 950void object::unlink ()
950{ 951{
951 //count = 0;//D 952 //count = 0;//D
952 if (!prev && !next) return;//D 953 if (!prev && !next) return;//D
953 954
954 if (this == objects) 955 if (this == object::first)
955 objects = next; 956 object::first = next;
956 957
957 /* Remove this object from the list of used objects */ 958 /* Remove this object from the list of used objects */
958 if (prev) prev->next = next; 959 if (prev) prev->next = next;
959 if (next) next->prev = prev; 960 if (next) next->prev = prev;
960 961
1038 op = tmp; 1039 op = tmp;
1039 } 1040 }
1040 } 1041 }
1041 } 1042 }
1042 1043
1044 // clear those pointers that likely might have circular references to us
1043 owner = 0; 1045 owner = 0;
1046 enemy = 0;
1047 attacked_by = 0;
1044 1048
1045 /* Remove object from the active list */ 1049 /* Remove object from the active list */
1046 speed = 0; 1050 speed = 0;
1047 update_ob_speed (this); 1051 update_ob_speed (this);
1048 1052
1060sub_weight (object *op, signed long weight) 1064sub_weight (object *op, signed long weight)
1061{ 1065{
1062 while (op != NULL) 1066 while (op != NULL)
1063 { 1067 {
1064 if (op->type == CONTAINER) 1068 if (op->type == CONTAINER)
1065 {
1066 weight = (signed long) (weight * (100 - op->stats.Str) / 100); 1069 weight = (signed long) (weight * (100 - op->stats.Str) / 100);
1067 } 1070
1068 op->carrying -= weight; 1071 op->carrying -= weight;
1069 op = op->env; 1072 op = op->env;
1070 } 1073 }
1071} 1074}
1072 1075
1080 */ 1083 */
1081 1084
1082void 1085void
1083remove_ob (object *op) 1086remove_ob (object *op)
1084{ 1087{
1088 object *tmp, *last = 0;
1085 object * 1089 object *otmp;
1086 tmp, *
1087 last = NULL;
1088 object *
1089 otmp;
1090 1090
1091 tag_t 1091 tag_t tag;
1092 tag;
1093 int
1094 check_walk_off; 1092 int check_walk_off;
1095 mapstruct * 1093 mapstruct *m;
1096 m;
1097 1094
1098 sint16 1095 sint16 x, y;
1099 x,
1100 y;
1101 1096
1102 if (QUERY_FLAG (op, FLAG_REMOVED)) 1097 if (QUERY_FLAG (op, FLAG_REMOVED))
1103 return; 1098 return;
1104 1099
1105 SET_FLAG (op, FLAG_REMOVED); 1100 SET_FLAG (op, FLAG_REMOVED);
1293 free_object (op); 1288 free_object (op);
1294 return top; 1289 return top;
1295 } 1290 }
1296 } 1291 }
1297 1292
1298 return NULL; 1293 return 0;
1299} 1294}
1300 1295
1301/* 1296/*
1302 * same as insert_ob_in_map except it handle separate coordinates and do a clean 1297 * same as insert_ob_in_map except it handle separate coordinates and do a clean
1303 * job preparing multi-part monsters 1298 * job preparing multi-part monsters
1630 remove_ob (tmp); 1625 remove_ob (tmp);
1631 free_object (tmp); 1626 free_object (tmp);
1632 } 1627 }
1633 } 1628 }
1634 1629
1635 tmp1 = arch_to_object (find_archetype (arch_string)); 1630 tmp1 = arch_to_object (archetype::find (arch_string));
1636 1631
1637 tmp1->x = op->x; 1632 tmp1->x = op->x;
1638 tmp1->y = op->y; 1633 tmp1->y = op->y;
1639 insert_ob_in_map (tmp1, op->map, op, 0); 1634 insert_ob_in_map (tmp1, op->map, op, 0);
1640} 1635}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines