… | |
… | |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <unistd.h> |
24 | #include <unistd.h> |
25 | |
25 | |
26 | #include "global.h" |
26 | #include "global.h" |
27 | |
|
|
28 | #include "loader.h" |
27 | #include "loader.h" |
29 | |
|
|
30 | #include "path.h" |
28 | #include "path.h" |
31 | |
29 | |
32 | /* This rolls up wall, blocks_magic, blocks_view, etc, all into |
30 | /* This rolls up wall, blocks_magic, blocks_view, etc, all into |
33 | * one function that just returns a P_.. value (see map.h) |
31 | * one function that just returns a P_.. value (see map.h) |
34 | * it will also do map translation for tiled maps, returning |
32 | * it will also do map translation for tiled maps, returning |
… | |
… | |
260 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
258 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
261 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
259 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
262 | tmp->flag [flag] = value; |
260 | tmp->flag [flag] = value; |
263 | } |
261 | } |
264 | |
262 | |
|
|
263 | void |
|
|
264 | maptile::post_load_original () |
|
|
265 | { |
|
|
266 | if (!spaces) |
|
|
267 | return; |
|
|
268 | |
|
|
269 | set_object_flag (FLAG_OBJ_ORIGINAL); |
|
|
270 | |
|
|
271 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
|
|
272 | for (object *tmp = ms->bot; tmp; tmp = tmp->above) |
|
|
273 | INVOKE_OBJECT (RESET, tmp); |
|
|
274 | } |
|
|
275 | |
265 | /* link_multipart_objects go through all the objects on the map looking |
276 | /* link_multipart_objects go through all the objects on the map looking |
266 | * for objects whose arch says they are multipart yet according to the |
277 | * for objects whose arch says they are multipart yet according to the |
267 | * info we have, they only have the head (as would be expected when |
278 | * info we have, they only have the head (as would be expected when |
268 | * they are saved). |
279 | * they are saved). |
269 | */ |
280 | */ |
… | |
… | |
641 | case KW_sky: thawer.get (sky); break; |
652 | case KW_sky: thawer.get (sky); break; |
642 | |
653 | |
643 | case KW_per_player: thawer.get (per_player); break; |
654 | case KW_per_player: thawer.get (per_player); break; |
644 | case KW_per_party: thawer.get (per_party); break; |
655 | case KW_per_party: thawer.get (per_party); break; |
645 | case KW_no_reset: thawer.get (no_reset); break; |
656 | case KW_no_reset: thawer.get (no_reset); break; |
|
|
657 | case KW_no_drop: thawer.get (no_drop); break; |
646 | |
658 | |
647 | case KW_region: default_region = region::find (thawer.get_str ()); break; |
659 | case KW_region: default_region = region::find (thawer.get_str ()); break; |
648 | case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; |
660 | case KW_shopitems: shopitems = parse_shop_string (thawer.get_str ()); break; |
649 | |
661 | |
650 | // old names new names |
662 | // old names new names |
… | |
… | |
700 | |
712 | |
701 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
713 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
702 | unique = 1; |
714 | unique = 1; |
703 | |
715 | |
704 | if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) |
716 | if (op->head_ () == op && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) |
705 | { |
|
|
706 | op->destroy_inv (false); |
|
|
707 | op->destroy (); |
717 | op->destroy (); |
708 | } |
|
|
709 | |
718 | |
710 | op = above; |
719 | op = above; |
711 | } |
720 | } |
712 | } |
721 | } |
713 | } |
722 | } |
… | |
… | |
724 | MAP_OUT (swap_time); |
733 | MAP_OUT (swap_time); |
725 | MAP_OUT (reset_time); |
734 | MAP_OUT (reset_time); |
726 | MAP_OUT (reset_timeout); |
735 | MAP_OUT (reset_timeout); |
727 | MAP_OUT (fixed_resettime); |
736 | MAP_OUT (fixed_resettime); |
728 | MAP_OUT (no_reset); |
737 | MAP_OUT (no_reset); |
|
|
738 | MAP_OUT (no_drop); |
729 | MAP_OUT (difficulty); |
739 | MAP_OUT (difficulty); |
730 | |
740 | |
731 | if (default_region) MAP_OUT2 (region, default_region->name); |
741 | if (default_region) MAP_OUT2 (region, default_region->name); |
732 | |
742 | |
733 | if (shopitems) |
743 | if (shopitems) |
… | |
… | |
800 | |
810 | |
801 | op->flag [FLAG_REMOVED] = true; |
811 | op->flag [FLAG_REMOVED] = true; |
802 | |
812 | |
803 | object *head = op->head_ (); |
813 | object *head = op->head_ (); |
804 | if (op == head) |
814 | if (op == head) |
805 | { |
|
|
806 | op->destroy_inv (false); |
|
|
807 | op->destroy (); |
815 | op->destroy (); |
808 | } |
|
|
809 | else if (head->map != op->map) |
816 | else if (head->map != op->map) |
810 | { |
817 | { |
811 | LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); |
818 | LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); |
812 | head->destroy (); |
819 | head->destroy (); |
813 | } |
820 | } |
… | |
… | |
1040 | else |
1047 | else |
1041 | darkness = new_level; |
1048 | darkness = new_level; |
1042 | |
1049 | |
1043 | /* All clients need to get re-updated for the change */ |
1050 | /* All clients need to get re-updated for the change */ |
1044 | update_all_map_los (this); |
1051 | update_all_map_los (this); |
|
|
1052 | |
1045 | return 1; |
1053 | return 1; |
1046 | } |
1054 | } |
1047 | |
1055 | |
1048 | /* |
1056 | /* |
1049 | * This function updates various attributes about a specific space |
1057 | * This function updates various attributes about a specific space |
… | |
… | |
1052 | * through, etc) |
1060 | * through, etc) |
1053 | */ |
1061 | */ |
1054 | void |
1062 | void |
1055 | mapspace::update_ () |
1063 | mapspace::update_ () |
1056 | { |
1064 | { |
1057 | object *tmp, *last = 0; |
1065 | object *last = 0; |
1058 | uint8 flags = P_UPTODATE, light = 0, anywhere = 0; |
1066 | uint8 flags = P_UPTODATE, light = 0, anywhere = 0; |
1059 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1067 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1060 | |
1068 | |
1061 | //object *middle = 0; |
1069 | //object *middle = 0; |
1062 | //object *top = 0; |
1070 | //object *top = 0; |
… | |
… | |
1064 | // this seems to generate better code than using locals, above |
1072 | // this seems to generate better code than using locals, above |
1065 | object *&top = faces_obj[0] = 0; |
1073 | object *&top = faces_obj[0] = 0; |
1066 | object *&middle = faces_obj[1] = 0; |
1074 | object *&middle = faces_obj[1] = 0; |
1067 | object *&floor = faces_obj[2] = 0; |
1075 | object *&floor = faces_obj[2] = 0; |
1068 | |
1076 | |
1069 | for (tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1077 | for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1070 | { |
1078 | { |
1071 | /* This could be made additive I guess (two lights better than |
1079 | /* This could be made additive I guess (two lights better than |
1072 | * one). But if so, it shouldn't be a simple additive - 2 |
1080 | * one). But if so, it shouldn't be a simple additive - 2 |
1073 | * light bulbs do not illuminate twice as far as once since |
1081 | * light bulbs do not illuminate twice as far as once since |
1074 | * it is a dissapation factor that is cubed. |
1082 | * it is a dissapation factor that is cubed. |
… | |
… | |
1100 | else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) |
1108 | else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) |
1101 | { |
1109 | { |
1102 | middle = tmp; |
1110 | middle = tmp; |
1103 | anywhere = 1; |
1111 | anywhere = 1; |
1104 | } |
1112 | } |
|
|
1113 | |
1105 | /* Find the highest visible face around. If equal |
1114 | /* Find the highest visible face around. If equal |
1106 | * visibilities, we still want the one nearer to the |
1115 | * visibilities, we still want the one nearer to the |
1107 | * top |
1116 | * top |
1108 | */ |
1117 | */ |
1109 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) |
1118 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) |
… | |
… | |
1158 | * 1) top face is set, need middle to be set. |
1167 | * 1) top face is set, need middle to be set. |
1159 | * 2) middle is set, need to set top. |
1168 | * 2) middle is set, need to set top. |
1160 | * 3) neither middle or top is set - need to set both. |
1169 | * 3) neither middle or top is set - need to set both. |
1161 | */ |
1170 | */ |
1162 | |
1171 | |
1163 | for (tmp = last; tmp; tmp = tmp->below) |
1172 | for (object *tmp = last; tmp; tmp = tmp->below) |
1164 | { |
1173 | { |
1165 | /* Once we get to a floor, stop, since we already have a floor object */ |
1174 | /* Once we get to a floor, stop, since we already have a floor object */ |
1166 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1175 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1167 | break; |
1176 | break; |
1168 | |
1177 | |
… | |
… | |
1571 | } |
1580 | } |
1572 | |
1581 | |
1573 | object * |
1582 | object * |
1574 | maptile::insert (object *op, int x, int y, object *originator, int flags) |
1583 | maptile::insert (object *op, int x, int y, object *originator, int flags) |
1575 | { |
1584 | { |
1576 | if (!op->flag [FLAG_REMOVED]) |
|
|
1577 | op->remove (); |
|
|
1578 | |
|
|
1579 | return insert_ob_in_map_at (op, this, originator, flags, x, y); |
1585 | return insert_ob_in_map_at (op, this, originator, flags, x, y); |
1580 | } |
1586 | } |
1581 | |
1587 | |
1582 | region * |
1588 | region * |
1583 | maptile::region (int x, int y) const |
1589 | maptile::region (int x, int y) const |