… | |
… | |
959 | object *op = new object; |
959 | object *op = new object; |
960 | op->link (); |
960 | op->link (); |
961 | return op; |
961 | return op; |
962 | } |
962 | } |
963 | |
963 | |
|
|
964 | static struct freed_map : maptile |
|
|
965 | { |
|
|
966 | freed_map () |
|
|
967 | { |
|
|
968 | path = "<freed objects map>"; |
|
|
969 | name = "/internal/freed_objects_map"; |
|
|
970 | width = 3; |
|
|
971 | height = 3; |
|
|
972 | nodrop = 1; |
|
|
973 | |
|
|
974 | alloc (); |
|
|
975 | in_memory = MAP_ACTIVE; |
|
|
976 | } |
|
|
977 | } freed_map; // freed objects are moved here to avoid crashes |
|
|
978 | |
964 | void |
979 | void |
965 | object::do_destroy () |
980 | object::do_destroy () |
966 | { |
981 | { |
967 | if (flag [FLAG_IS_LINKED]) |
982 | if (flag [FLAG_IS_LINKED]) |
968 | remove_button_link (this); |
983 | remove_button_link (this); |
… | |
… | |
978 | unlink (); |
993 | unlink (); |
979 | |
994 | |
980 | flag [FLAG_FREED] = 1; |
995 | flag [FLAG_FREED] = 1; |
981 | |
996 | |
982 | // hack to ensure that freed objects still have a valid map |
997 | // hack to ensure that freed objects still have a valid map |
983 | { |
|
|
984 | static maptile *freed_map; // freed objects are moved here to avoid crashes |
|
|
985 | |
|
|
986 | if (!freed_map) |
|
|
987 | { |
|
|
988 | freed_map = new maptile; |
|
|
989 | |
|
|
990 | freed_map->path = "<freed objects map>"; |
|
|
991 | freed_map->name = "/internal/freed_objects_map"; |
|
|
992 | freed_map->width = 3; |
|
|
993 | freed_map->height = 3; |
|
|
994 | freed_map->nodrop = 1; |
|
|
995 | |
|
|
996 | freed_map->alloc (); |
|
|
997 | freed_map->in_memory = MAP_ACTIVE; |
|
|
998 | } |
|
|
999 | |
|
|
1000 | map = freed_map; |
998 | map = &freed_map; |
1001 | x = 1; |
999 | x = 1; |
1002 | y = 1; |
1000 | y = 1; |
1003 | } |
|
|
1004 | |
1001 | |
1005 | if (more) |
1002 | if (more) |
1006 | { |
1003 | { |
1007 | more->destroy (); |
1004 | more->destroy (); |
1008 | more = 0; |
1005 | more = 0; |
… | |
… | |
1025 | |
1022 | |
1026 | if (!is_head () && !head->destroyed ()) |
1023 | if (!is_head () && !head->destroyed ()) |
1027 | { |
1024 | { |
1028 | LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); |
1025 | LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); |
1029 | head->destroy (destroy_inventory); |
1026 | head->destroy (destroy_inventory); |
|
|
1027 | return; |
1030 | } |
1028 | } |
1031 | |
1029 | |
1032 | destroy_inv (!destroy_inventory); |
1030 | destroy_inv (!destroy_inventory); |
1033 | |
1031 | |
1034 | if (is_head ()) |
1032 | if (is_head ()) |