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.137 by root, Mon Apr 16 06:23:40 2007 UTC vs.
Revision 1.140 by root, Tue Apr 24 12:32:14 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
835 835
836 if (flag [FLAG_IS_LINKED]) 836 if (flag [FLAG_IS_LINKED])
837 remove_button_link (this); 837 remove_button_link (this);
838 838
839 if (flag [FLAG_FRIENDLY]) 839 if (flag [FLAG_FRIENDLY])
840 {
841 remove_friendly_object (this); 840 remove_friendly_object (this);
842
843 if (type == GOLEM
844 && owner
845 && owner->type == PLAYER
846 && owner->contr->ranges[range_golem] == this)
847 owner->contr->ranges[range_golem] = 0;
848 }
849 841
850 if (!flag [FLAG_REMOVED]) 842 if (!flag [FLAG_REMOVED])
851 remove (); 843 remove ();
852 844
853 destroy_inv (true); 845 destroy_inv (true);
1110 return top; 1102 return top;
1111 } 1103 }
1112 } 1104 }
1113 1105
1114 return 0; 1106 return 0;
1107}
1108
1109void
1110object::expand_tail ()
1111{
1112 if (more)
1113 return;
1114
1115 object *prev = this;
1116
1117 for (archetype *at = arch->more; at; at = at->more)
1118 {
1119 object *op = arch_to_object (at);
1120
1121 op->name = name;
1122 op->name_pl = name_pl;
1123 op->title = title;
1124
1125 op->head = this;
1126 prev->more = op;
1127
1128 prev = op;
1129 }
1115} 1130}
1116 1131
1117/* 1132/*
1118 * same as insert_ob_in_map except it handles separate coordinates and does a clean 1133 * same as insert_ob_in_map except it handles separate coordinates and does a clean
1119 * job preparing multi-part monsters. 1134 * job preparing multi-part monsters.
1151 * just 'op' otherwise 1166 * just 'op' otherwise
1152 */ 1167 */
1153object * 1168object *
1154insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1169insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1155{ 1170{
1171 assert (!op->flag [FLAG_FREED]);
1172
1156 object *tmp, *top, *floor = NULL; 1173 object *tmp, *top, *floor = NULL;
1157 1174
1158 if (QUERY_FLAG (op, FLAG_FREED))
1159 {
1160 LOG (llevError, "Trying to insert freed object!\n");
1161 return NULL;
1162 }
1163
1164 if (!QUERY_FLAG (op, FLAG_REMOVED))
1165 LOG (llevError, "Trying to insert already inserted object %s\n", op->debug_desc ());
1166
1167 op->remove (); 1175 op->remove ();
1168 1176
1169 if (!m) 1177#if 0
1170 { 1178 if (!m->active != !op->active)
1171 char *dump = dump_object (op); 1179 if (m->active)
1172 LOG (llevError, "Trying to insert in null-map!\n%s\n", dump); 1180 op->activate_recursive ();
1173 free (dump); 1181 else
1174 return op; 1182 op->deactivate_recursive ();
1175 } 1183#endif
1176 1184
1177 if (out_of_map (m, op->x, op->y)) 1185 if (out_of_map (m, op->x, op->y))
1178 { 1186 {
1179 char *dump = dump_object (op);
1180 LOG (llevError, "Trying to insert object outside the map.\n%s\n", dump); 1187 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ());
1181#ifdef MANY_CORES 1188#ifdef MANY_CORES
1182 /* Better to catch this here, as otherwise the next use of this object 1189 /* Better to catch this here, as otherwise the next use of this object
1183 * is likely to cause a crash. Better to find out where it is getting 1190 * is likely to cause a crash. Better to find out where it is getting
1184 * improperly inserted. 1191 * improperly inserted.
1185 */ 1192 */
1186 abort (); 1193 abort ();
1187#endif 1194#endif
1188 free (dump);
1189 return op; 1195 return op;
1190 } 1196 }
1191 1197
1192 if (object *more = op->more) 1198 if (object *more = op->more)
1193 { 1199 {
1430 tmp1->x = op->x; 1436 tmp1->x = op->x;
1431 tmp1->y = op->y; 1437 tmp1->y = op->y;
1432 insert_ob_in_map (tmp1, op->map, op, 0); 1438 insert_ob_in_map (tmp1, op->map, op, 0);
1433} 1439}
1434 1440
1435// XXX: function not returning object*
1436object * 1441object *
1437object::insert_at (object *where, object *originator, int flags) 1442object::insert_at (object *where, object *originator, int flags)
1438{ 1443{
1439 where->map->insert (this, where->x, where->y, originator, flags); 1444 return where->map->insert (this, where->x, where->y, originator, flags);
1440} 1445}
1441 1446
1442/* 1447/*
1443 * get_split_ob(ob,nr) splits up ob into two parts. The part which 1448 * get_split_ob(ob,nr) splits up ob into two parts. The part which
1444 * is returned contains nr objects, and the remaining parts contains 1449 * is returned contains nr objects, and the remaining parts contains
1484 * the amount of an object. If the amount reaches 0, the object 1489 * the amount of an object. If the amount reaches 0, the object
1485 * is subsequently removed and freed. 1490 * is subsequently removed and freed.
1486 * 1491 *
1487 * Return value: 'op' if something is left, NULL if the amount reached 0 1492 * Return value: 'op' if something is left, NULL if the amount reached 0
1488 */ 1493 */
1489
1490object * 1494object *
1491decrease_ob_nr (object *op, uint32 i) 1495decrease_ob_nr (object *op, uint32 i)
1492{ 1496{
1493 object *tmp; 1497 object *tmp;
1494 1498
1569 1573
1570/* 1574/*
1571 * add_weight(object, weight) adds the specified weight to an object, 1575 * add_weight(object, weight) adds the specified weight to an object,
1572 * and also updates how much the environment(s) is/are carrying. 1576 * and also updates how much the environment(s) is/are carrying.
1573 */ 1577 */
1574
1575void 1578void
1576add_weight (object *op, signed long weight) 1579add_weight (object *op, signed long weight)
1577{ 1580{
1578 while (op != NULL) 1581 while (op != NULL)
1579 { 1582 {
1611 * inside the object environment. 1614 * inside the object environment.
1612 * 1615 *
1613 * The function returns now pointer to inserted item, and return value can 1616 * The function returns now pointer to inserted item, and return value can
1614 * be != op, if items are merged. -Tero 1617 * be != op, if items are merged. -Tero
1615 */ 1618 */
1616
1617object * 1619object *
1618object::insert (object *op) 1620object::insert (object *op)
1619{ 1621{
1620 object *tmp, *otmp; 1622 object *tmp, *otmp;
1621 1623

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines