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