… | |
… | |
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 | */ |
… | |
… | |
1042 | else |
1053 | else |
1043 | darkness = new_level; |
1054 | darkness = new_level; |
1044 | |
1055 | |
1045 | /* All clients need to get re-updated for the change */ |
1056 | /* All clients need to get re-updated for the change */ |
1046 | update_all_map_los (this); |
1057 | update_all_map_los (this); |
|
|
1058 | |
1047 | return 1; |
1059 | return 1; |
1048 | } |
1060 | } |
1049 | |
1061 | |
1050 | /* |
1062 | /* |
1051 | * This function updates various attributes about a specific space |
1063 | * This function updates various attributes about a specific space |
… | |
… | |
1054 | * through, etc) |
1066 | * through, etc) |
1055 | */ |
1067 | */ |
1056 | void |
1068 | void |
1057 | mapspace::update_ () |
1069 | mapspace::update_ () |
1058 | { |
1070 | { |
1059 | object *tmp, *last = 0; |
1071 | object *last = 0; |
1060 | uint8 flags = P_UPTODATE, light = 0, anywhere = 0; |
1072 | uint8 flags = P_UPTODATE, light = 0, anywhere = 0; |
1061 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1073 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1062 | |
1074 | |
1063 | //object *middle = 0; |
1075 | //object *middle = 0; |
1064 | //object *top = 0; |
1076 | //object *top = 0; |
… | |
… | |
1066 | // this seems to generate better code than using locals, above |
1078 | // this seems to generate better code than using locals, above |
1067 | object *&top = faces_obj[0] = 0; |
1079 | object *&top = faces_obj[0] = 0; |
1068 | object *&middle = faces_obj[1] = 0; |
1080 | object *&middle = faces_obj[1] = 0; |
1069 | object *&floor = faces_obj[2] = 0; |
1081 | object *&floor = faces_obj[2] = 0; |
1070 | |
1082 | |
1071 | for (tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1083 | for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) |
1072 | { |
1084 | { |
1073 | /* This could be made additive I guess (two lights better than |
1085 | /* This could be made additive I guess (two lights better than |
1074 | * one). But if so, it shouldn't be a simple additive - 2 |
1086 | * one). But if so, it shouldn't be a simple additive - 2 |
1075 | * light bulbs do not illuminate twice as far as once since |
1087 | * light bulbs do not illuminate twice as far as once since |
1076 | * it is a dissapation factor that is cubed. |
1088 | * it is a dissapation factor that is cubed. |
… | |
… | |
1102 | else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) |
1114 | else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE)) |
1103 | { |
1115 | { |
1104 | middle = tmp; |
1116 | middle = tmp; |
1105 | anywhere = 1; |
1117 | anywhere = 1; |
1106 | } |
1118 | } |
|
|
1119 | |
1107 | /* Find the highest visible face around. If equal |
1120 | /* Find the highest visible face around. If equal |
1108 | * visibilities, we still want the one nearer to the |
1121 | * visibilities, we still want the one nearer to the |
1109 | * top |
1122 | * top |
1110 | */ |
1123 | */ |
1111 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) |
1124 | else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) |
… | |
… | |
1124 | move_off |= tmp->move_off; |
1137 | move_off |= tmp->move_off; |
1125 | move_allow |= tmp->move_allow; |
1138 | move_allow |= tmp->move_allow; |
1126 | |
1139 | |
1127 | if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; |
1140 | if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; |
1128 | if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; |
1141 | if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; |
1129 | if (tmp->type == PLAYER) flags |= P_PLAYER; |
|
|
1130 | if (tmp->type == SAFE_GROUND) flags |= P_SAFE; |
1142 | if (tmp->type == SAFE_GROUND) flags |= P_SAFE; |
1131 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; |
1143 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; |
1132 | if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; |
1144 | if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; |
1133 | } |
1145 | } |
1134 | |
1146 | |
… | |
… | |
1160 | * 1) top face is set, need middle to be set. |
1172 | * 1) top face is set, need middle to be set. |
1161 | * 2) middle is set, need to set top. |
1173 | * 2) middle is set, need to set top. |
1162 | * 3) neither middle or top is set - need to set both. |
1174 | * 3) neither middle or top is set - need to set both. |
1163 | */ |
1175 | */ |
1164 | |
1176 | |
1165 | for (tmp = last; tmp; tmp = tmp->below) |
1177 | for (object *tmp = last; tmp; tmp = tmp->below) |
1166 | { |
1178 | { |
1167 | /* Once we get to a floor, stop, since we already have a floor object */ |
1179 | /* Once we get to a floor, stop, since we already have a floor object */ |
1168 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1180 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1169 | break; |
1181 | break; |
1170 | |
1182 | |
… | |
… | |
1573 | } |
1585 | } |
1574 | |
1586 | |
1575 | object * |
1587 | object * |
1576 | maptile::insert (object *op, int x, int y, object *originator, int flags) |
1588 | maptile::insert (object *op, int x, int y, object *originator, int flags) |
1577 | { |
1589 | { |
1578 | if (!op->flag [FLAG_REMOVED]) |
|
|
1579 | op->remove (); |
|
|
1580 | |
|
|
1581 | return insert_ob_in_map_at (op, this, originator, flags, x, y); |
1590 | return insert_ob_in_map_at (op, this, originator, flags, x, y); |
1582 | } |
1591 | } |
1583 | |
1592 | |
1584 | region * |
1593 | region * |
1585 | maptile::region (int x, int y) const |
1594 | maptile::region (int x, int y) const |