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.139 by root, Sat Apr 21 17:34:22 2007 UTC

1112 } 1112 }
1113 1113
1114 return 0; 1114 return 0;
1115} 1115}
1116 1116
1117void
1118object::expand_tail ()
1119{
1120 if (more)
1121 return;
1122
1123 object *prev = this;
1124
1125 for (archetype *at = arch->more; at; at = at->more)
1126 {
1127 object *op = arch_to_object (at);
1128
1129 op->name = name;
1130 op->name_pl = name_pl;
1131 op->title = title;
1132
1133 op->head = this;
1134 prev->more = op;
1135
1136 prev = op;
1137 }
1138}
1139
1117/* 1140/*
1118 * same as insert_ob_in_map except it handles separate coordinates and does a clean 1141 * same as insert_ob_in_map except it handles separate coordinates and does a clean
1119 * job preparing multi-part monsters. 1142 * job preparing multi-part monsters.
1120 */ 1143 */
1121object * 1144object *
1151 * just 'op' otherwise 1174 * just 'op' otherwise
1152 */ 1175 */
1153object * 1176object *
1154insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1177insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1155{ 1178{
1179 assert (!op->flag [FLAG_FREED]);
1180
1156 object *tmp, *top, *floor = NULL; 1181 object *tmp, *top, *floor = NULL;
1157 1182
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 (); 1183 op->remove ();
1168 1184
1169 if (!m) 1185#if 0
1170 { 1186 if (!m->active != !op->active)
1171 char *dump = dump_object (op); 1187 if (m->active)
1172 LOG (llevError, "Trying to insert in null-map!\n%s\n", dump); 1188 op->activate_recursive ();
1173 free (dump); 1189 else
1174 return op; 1190 op->deactivate_recursive ();
1175 } 1191#endif
1176 1192
1177 if (out_of_map (m, op->x, op->y)) 1193 if (out_of_map (m, op->x, op->y))
1178 { 1194 {
1179 char *dump = dump_object (op);
1180 LOG (llevError, "Trying to insert object outside the map.\n%s\n", dump); 1195 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ());
1181#ifdef MANY_CORES 1196#ifdef MANY_CORES
1182 /* Better to catch this here, as otherwise the next use of this object 1197 /* 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 1198 * is likely to cause a crash. Better to find out where it is getting
1184 * improperly inserted. 1199 * improperly inserted.
1185 */ 1200 */
1186 abort (); 1201 abort ();
1187#endif 1202#endif
1188 free (dump);
1189 return op; 1203 return op;
1190 } 1204 }
1191 1205
1192 if (object *more = op->more) 1206 if (object *more = op->more)
1193 { 1207 {
1430 tmp1->x = op->x; 1444 tmp1->x = op->x;
1431 tmp1->y = op->y; 1445 tmp1->y = op->y;
1432 insert_ob_in_map (tmp1, op->map, op, 0); 1446 insert_ob_in_map (tmp1, op->map, op, 0);
1433} 1447}
1434 1448
1435// XXX: function not returning object*
1436object * 1449object *
1437object::insert_at (object *where, object *originator, int flags) 1450object::insert_at (object *where, object *originator, int flags)
1438{ 1451{
1439 where->map->insert (this, where->x, where->y, originator, flags); 1452 return where->map->insert (this, where->x, where->y, originator, flags);
1440} 1453}
1441 1454
1442/* 1455/*
1443 * get_split_ob(ob,nr) splits up ob into two parts. The part which 1456 * 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 1457 * is returned contains nr objects, and the remaining parts contains
1484 * the amount of an object. If the amount reaches 0, the object 1497 * the amount of an object. If the amount reaches 0, the object
1485 * is subsequently removed and freed. 1498 * is subsequently removed and freed.
1486 * 1499 *
1487 * Return value: 'op' if something is left, NULL if the amount reached 0 1500 * Return value: 'op' if something is left, NULL if the amount reached 0
1488 */ 1501 */
1489
1490object * 1502object *
1491decrease_ob_nr (object *op, uint32 i) 1503decrease_ob_nr (object *op, uint32 i)
1492{ 1504{
1493 object *tmp; 1505 object *tmp;
1494 1506
1569 1581
1570/* 1582/*
1571 * add_weight(object, weight) adds the specified weight to an object, 1583 * add_weight(object, weight) adds the specified weight to an object,
1572 * and also updates how much the environment(s) is/are carrying. 1584 * and also updates how much the environment(s) is/are carrying.
1573 */ 1585 */
1574
1575void 1586void
1576add_weight (object *op, signed long weight) 1587add_weight (object *op, signed long weight)
1577{ 1588{
1578 while (op != NULL) 1589 while (op != NULL)
1579 { 1590 {
1611 * inside the object environment. 1622 * inside the object environment.
1612 * 1623 *
1613 * The function returns now pointer to inserted item, and return value can 1624 * The function returns now pointer to inserted item, and return value can
1614 * be != op, if items are merged. -Tero 1625 * be != op, if items are merged. -Tero
1615 */ 1626 */
1616
1617object * 1627object *
1618object::insert (object *op) 1628object::insert (object *op)
1619{ 1629{
1620 object *tmp, *otmp; 1630 object *tmp, *otmp;
1621 1631

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines