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.256 by root, Sun Aug 31 05:47:14 2008 UTC vs.
Revision 1.261 by root, Wed Oct 1 16:04:16 2008 UTC

830{ 830{
831 /* If already on active list, don't do anything */ 831 /* If already on active list, don't do anything */
832 if (active) 832 if (active)
833 return; 833 return;
834 834
835 if (has_active_speed () && flag [FLAG_FREED ]) LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D 835 if (has_active_speed () && flag [FLAG_FREED]) LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D
836 if (has_active_speed () && flag [FLAG_DEBUG]) LOG (llevError | logBacktrace, "BUG: tried to activate DEBUG object %s\n", debug_desc ());//D temp
836 837
837 if (has_active_speed ()) 838 if (has_active_speed ())
838 actives.insert (this); 839 actives.insert (this);
839} 840}
840 841
908 || map->in_memory != MAP_ACTIVE 909 || map->in_memory != MAP_ACTIVE
909 || map->no_drop 910 || map->no_drop
910 || ms ().move_block == MOVE_ALL) 911 || ms ().move_block == MOVE_ALL)
911 { 912 {
912 while (inv) 913 while (inv)
913 inv->destroy (true); 914 inv->destroy ();
914 } 915 }
915 else 916 else
916 { /* Put objects in inventory onto this space */ 917 { /* Put objects in inventory onto this space */
917 while (inv) 918 while (inv)
918 { 919 {
922 || op->flag [FLAG_NO_DROP] 923 || op->flag [FLAG_NO_DROP]
923 || op->type == RUNE 924 || op->type == RUNE
924 || op->type == TRAP 925 || op->type == TRAP
925 || op->flag [FLAG_IS_A_TEMPLATE] 926 || op->flag [FLAG_IS_A_TEMPLATE]
926 || op->flag [FLAG_DESTROY_ON_DEATH]) 927 || op->flag [FLAG_DESTROY_ON_DEATH])
927 op->destroy (true); 928 op->destroy ();
928 else 929 else
929 map->insert (op, x, y); 930 map->insert (op, x, y);
930 } 931 }
931 } 932 }
932} 933}
996 attacked_by = 0; 997 attacked_by = 0;
997 current_weapon = 0; 998 current_weapon = 0;
998} 999}
999 1000
1000void 1001void
1001object::destroy (bool destroy_inventory) 1002object::destroy ()
1002{ 1003{
1003 if (destroyed ()) 1004 if (destroyed ())
1004 return; 1005 return;
1005 1006
1006 if (!is_head () && !head->destroyed ()) 1007 if (!is_head () && !head->destroyed ())
1007 { 1008 {
1008 LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); 1009 LOG (llevError | logBacktrace, "tried to destroy the tail of an object");
1009 head->destroy (destroy_inventory); 1010 head->destroy ();
1010 return; 1011 return;
1011 } 1012 }
1012 1013
1013 destroy_inv (!destroy_inventory); 1014 destroy_inv (false);
1014 1015
1015 if (is_head ()) 1016 if (is_head ())
1016 if (sound_destroy) 1017 if (sound_destroy)
1017 play_sound (sound_destroy); 1018 play_sound (sound_destroy);
1018 else if (flag [FLAG_MONSTER]) 1019 else if (flag [FLAG_MONSTER])
1190 esrv_update_item (UPD_NROF, pl, top); 1191 esrv_update_item (UPD_NROF, pl, top);
1191 1192
1192 op->weight = 0; // cancel the addition above 1193 op->weight = 0; // cancel the addition above
1193 op->carrying = 0; // must be 0 already 1194 op->carrying = 0; // must be 0 already
1194 1195
1195 op->destroy (1); 1196 op->destroy ();
1196 1197
1197 return top; 1198 return top;
1198 } 1199 }
1199 1200
1200 return 0; 1201 return 0;
1262 * just 'op' otherwise 1263 * just 'op' otherwise
1263 */ 1264 */
1264object * 1265object *
1265insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1266insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1266{ 1267{
1267 if (op->is_on_map ())
1268 {
1269 LOG (llevError, "insert_ob_in_map called for object already on map");
1270 abort ();
1271 }
1272
1273 if (op->env)
1274 {
1275 LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)");
1276 op->remove (); 1268 op->remove ();
1277 }
1278 1269
1279 if (op->face && !face_info (op->face))//D TODO: remove soon 1270 if (m == &freed_map)//D TODO: remove soon
1280 {//D 1271 {//D
1281 LOG (llevError | logBacktrace, "op->face out of bounds: %s", op->debug_desc ());//D 1272 LOG (llevError | logBacktrace, "tries to insret object on freed objects map: %s", op->debug_desc ());//D
1282 op->face = 1;//D
1283 }//D 1273 }//D
1284 1274
1285 /* Ideally, the caller figures this out. However, it complicates a lot 1275 /* Ideally, the caller figures this out. However, it complicates a lot
1286 * of areas of callers (eg, anything that uses find_free_spot would now 1276 * of areas of callers (eg, anything that uses find_free_spot would now
1287 * need extra work 1277 * need extra work
1288 */ 1278 */
1289 if (!xy_normalise (m, op->x, op->y)) 1279 if (!xy_normalise (m, op->x, op->y))
1290 { 1280 {
1291 op->head_ ()->destroy (1);// remove head_ once all tail object destroyers found 1281 op->head_ ()->destroy ();// remove head_ once all tail object destroyers found
1292 return 0; 1282 return 0;
1293 } 1283 }
1294 1284
1295 if (object *more = op->more) 1285 if (object *more = op->more)
1296 if (!insert_ob_in_map (more, m, originator, flag)) 1286 if (!insert_ob_in_map (more, m, originator, flag))
1309 { 1299 {
1310 // TODO: we actually want to update tmp, not op, 1300 // TODO: we actually want to update tmp, not op,
1311 // but some caller surely breaks when we return tmp 1301 // but some caller surely breaks when we return tmp
1312 // from here :/ 1302 // from here :/
1313 op->nrof += tmp->nrof; 1303 op->nrof += tmp->nrof;
1314 tmp->destroy (1); 1304 tmp->destroy ();
1315 } 1305 }
1316 1306
1317 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1307 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1318 CLEAR_FLAG (op, FLAG_INV_LOCKED); 1308 CLEAR_FLAG (op, FLAG_INV_LOCKED);
1319 1309
1494{ 1484{
1495 /* first search for itself and remove any old instances */ 1485 /* first search for itself and remove any old instances */
1496 1486
1497 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above) 1487 for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above)
1498 if (!strcmp (tmp->arch->archname, arch_string)) /* same archetype */ 1488 if (!strcmp (tmp->arch->archname, arch_string)) /* same archetype */
1499 tmp->destroy (1); 1489 tmp->destroy ();
1500 1490
1501 object *tmp = arch_to_object (archetype::find (arch_string)); 1491 object *tmp = arch_to_object (archetype::find (arch_string));
1502 1492
1503 tmp->x = op->x; 1493 tmp->x = op->x;
1504 tmp->y = op->y; 1494 tmp->y = op->y;
1627 if (object *pl = tmp->visible_to ()) 1617 if (object *pl = tmp->visible_to ())
1628 esrv_update_item (UPD_NROF, pl, tmp); 1618 esrv_update_item (UPD_NROF, pl, tmp);
1629 1619
1630 adjust_weight (this, op->total_weight ()); 1620 adjust_weight (this, op->total_weight ());
1631 1621
1632 op->destroy (1); 1622 op->destroy ();
1633 op = tmp; 1623 op = tmp;
1634 goto inserted; 1624 goto inserted;
1635 } 1625 }
1636 1626
1637 op->owner = 0; // it's his/hers now. period. 1627 op->owner = 0; // it's his/hers now. period.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines