… | |
… | |
671 | case KW_value: case KW_swap_time: thawer.get (timeout); break; |
671 | case KW_value: case KW_swap_time: thawer.get (timeout); break; |
672 | case KW_level: case KW_difficulty: thawer.get (difficulty); difficulty = clamp (difficulty, 1, settings.max_level); break; |
672 | case KW_level: case KW_difficulty: thawer.get (difficulty); difficulty = clamp (difficulty, 1, settings.max_level); break; |
673 | case KW_invisible: case KW_darkness: thawer.get (darkness); break; |
673 | case KW_invisible: case KW_darkness: thawer.get (darkness); break; |
674 | case KW_stand_still: case KW_fixed_resettime: thawer.get (fixed_resettime); break; |
674 | case KW_stand_still: case KW_fixed_resettime: thawer.get (fixed_resettime); break; |
675 | |
675 | |
676 | case KW_tile_path_1: thawer.get (tile_path [0]); break; |
676 | case KW_tile_path_1: thawer.get (tile_path [TILE_NORTH]); break; |
677 | case KW_tile_path_2: thawer.get (tile_path [1]); break; |
677 | case KW_tile_path_2: thawer.get (tile_path [TILE_EAST ]); break; |
678 | case KW_tile_path_3: thawer.get (tile_path [2]); break; |
678 | case KW_tile_path_3: thawer.get (tile_path [TILE_SOUTH]); break; |
679 | case KW_tile_path_4: thawer.get (tile_path [3]); break; |
679 | case KW_tile_path_4: thawer.get (tile_path [TILE_WEST ]); break; |
680 | case KW_tile_path_5: thawer.get (tile_path [4]); break; |
680 | case KW_tile_path_5: thawer.get (tile_path [TILE_UP ]); break; |
681 | case KW_tile_path_6: thawer.get (tile_path [5]); break; |
681 | case KW_tile_path_6: thawer.get (tile_path [TILE_DOWN ]); break; |
682 | |
682 | |
683 | case KW_ERROR: |
683 | case KW_ERROR: |
684 | set_key_text (thawer.kw_str, thawer.value); |
684 | set_key_text (thawer.kw_str, thawer.value); |
685 | break; |
685 | break; |
686 | |
686 | |
… | |
… | |
765 | if (maplore) freezer.put (KW(maplore), KW(endmaplore), maplore); |
765 | if (maplore) freezer.put (KW(maplore), KW(endmaplore), maplore); |
766 | |
766 | |
767 | MAP_OUT (per_player); |
767 | MAP_OUT (per_player); |
768 | MAP_OUT (per_party); |
768 | MAP_OUT (per_party); |
769 | |
769 | |
770 | if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); |
770 | if (tile_path [TILE_NORTH]) MAP_OUT2 (tile_path_1, tile_path [TILE_NORTH]); |
771 | if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); |
771 | if (tile_path [TILE_EAST ]) MAP_OUT2 (tile_path_2, tile_path [TILE_EAST ]); |
772 | if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); |
772 | if (tile_path [TILE_SOUTH]) MAP_OUT2 (tile_path_3, tile_path [TILE_SOUTH]); |
773 | if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); |
773 | if (tile_path [TILE_WEST ]) MAP_OUT2 (tile_path_4, tile_path [TILE_WEST ]); |
774 | if (tile_path [4]) MAP_OUT2 (tile_path_5, tile_path [4]); |
774 | if (tile_path [TILE_UP ]) MAP_OUT2 (tile_path_5, tile_path [TILE_UP ]); |
775 | if (tile_path [5]) MAP_OUT2 (tile_path_6, tile_path [5]); |
775 | if (tile_path [TILE_DOWN ]) MAP_OUT2 (tile_path_6, tile_path [TILE_DOWN ]); |
776 | |
776 | |
777 | freezer.put (this); |
777 | freezer.put (this); |
778 | freezer.put (KW(end)); |
778 | freezer.put (KW(end)); |
779 | |
779 | |
780 | return true; |
780 | return true; |
… | |
… | |
1195 | middle = 0; |
1195 | middle = 0; |
1196 | |
1196 | |
1197 | if (top == middle) |
1197 | if (top == middle) |
1198 | middle = 0; |
1198 | middle = 0; |
1199 | |
1199 | |
1200 | // dire hack to handle "transparent" floors - currently only open_space |
1200 | // set lower map transparent floor flag if applicable |
1201 | // should be based by some floor_blocksview or so |
1201 | if (floor && floor->flag [FLAG_IS_TRANSPARENT_FLOOR] && !middle && !top) |
1202 | if (floor && floor->arch->archname == shstr_quad_open_space) |
|
|
1203 | { |
1202 | { |
1204 | floor->set_anim_frame (0); |
1203 | floor->set_anim_frame (0); |
1205 | |
1204 | |
1206 | if (maptile *m = floor->map->tile_map [TILE_DOWN]) |
1205 | if (maptile *m = floor->map->tile_map [TILE_DOWN]) |
1207 | { |
1206 | { |
1208 | // mirror the floor - very unreliable because usually outdated, |
|
|
1209 | // but somewhta works because floors do not change often :/ |
|
|
1210 | mapspace &ms = m->at (floor->x, floor->y); |
1207 | mapspace &ms = m->at (floor->x, floor->y); |
1211 | ms.update (); |
1208 | ms.update (); |
1212 | |
1209 | |
1213 | if (object *floor2 = ms.faces_obj [2]) |
1210 | if (object *floor2 = ms.faces_obj [2]) |
1214 | if (floor2->arch->archname != shstr_quad_open_space && !middle) |
1211 | if (!floor2->flag [FLAG_IS_TRANSPARENT_FLOOR]) |
1215 | { |
1212 | { |
1216 | floor->set_anim_frame (1); |
1213 | floor->set_anim_frame (1); |
1217 | middle = floor; |
1214 | top = floor; |
|
|
1215 | middle = ms.faces_obj [0]; |
1218 | floor = floor2; |
1216 | floor = floor2; |
1219 | } |
1217 | } |
|
|
1218 | |
|
|
1219 | ms.pflags |= PF_VIS_UP; |
1220 | } |
1220 | } |
1221 | } |
1221 | } |
1222 | |
1222 | |
1223 | #if 0 |
1223 | #if 0 |
1224 | faces_obj [0] = top; |
1224 | faces_obj [0] = top; |
1225 | faces_obj [1] = middle; |
1225 | faces_obj [1] = middle; |
1226 | faces_obj [2] = floor; |
1226 | faces_obj [2] = floor; |
1227 | #endif |
1227 | #endif |
1228 | } |
1228 | } |
1229 | |
1229 | |
|
|
1230 | void |
|
|
1231 | mapspace::update_up () |
|
|
1232 | { |
|
|
1233 | // invalidate up |
|
|
1234 | if (!(pflags & PF_VIS_UP)) |
|
|
1235 | return; |
|
|
1236 | |
|
|
1237 | pflags &= ~PF_VIS_UP; |
|
|
1238 | |
|
|
1239 | if (bot) |
|
|
1240 | if (maptile *m = bot->map->tile_map [TILE_UP]) |
|
|
1241 | m->at (bot->x, bot->y).invalidate (); |
|
|
1242 | } |
|
|
1243 | |
1230 | maptile * |
1244 | maptile * |
1231 | maptile::tile_available (int dir, bool load) |
1245 | maptile::tile_available (int dir, bool load) |
1232 | { |
1246 | { |
1233 | if (tile_path[dir]) |
|
|
1234 | { |
|
|
1235 | // map is there and we don't need to load it OR it's loaded => return what we have |
1247 | // map is there and we don't need to load it OR it's loaded => return what we have |
1236 | if (tile_map[dir] && (!load || tile_map[dir]->linkable ())) |
1248 | if (tile_map [dir] && (!load || tile_map [dir]->linkable ())) |
1237 | return tile_map[dir]; |
1249 | return tile_map [dir]; |
1238 | |
1250 | |
|
|
1251 | if (tile_path [dir]) |
|
|
1252 | { |
1239 | // well, try to locate it then, if possible - maybe it's there already |
1253 | // well, try to locate it then, if possible - maybe it's there already |
1240 | if ((tile_map[dir] = find_async (tile_path[dir], this, load))) |
1254 | if (maptile *m = find_async (tile_path [dir], this, load)) |
|
|
1255 | { |
|
|
1256 | bool match = true; |
|
|
1257 | |
|
|
1258 | if (dir == TILE_NORTH || dir == TILE_SOUTH || dir == TILE_UP || dir == TILE_DOWN) |
|
|
1259 | if (width != m->width) |
|
|
1260 | match = false; |
|
|
1261 | |
|
|
1262 | if (dir == TILE_EAST || dir == TILE_WEST || dir == TILE_UP || dir == TILE_DOWN) |
|
|
1263 | if (height != m->height) |
|
|
1264 | match = false; |
|
|
1265 | |
|
|
1266 | if (!match) |
|
|
1267 | { |
|
|
1268 | LOG (llevError, "tile dimension mismatch for direction %d from %s to %s\n", |
|
|
1269 | dir, &path, &m->path); |
|
|
1270 | m = 0; |
|
|
1271 | } |
|
|
1272 | |
|
|
1273 | // this could be optimised endlessly |
|
|
1274 | //m->activate_physics (); |
|
|
1275 | |
1241 | return tile_map[dir]; |
1276 | return tile_map [dir] = m; |
|
|
1277 | } |
1242 | } |
1278 | } |
1243 | |
1279 | |
1244 | return 0; |
1280 | return 0; |
1245 | } |
1281 | } |
1246 | |
1282 | |
… | |
… | |
1262 | if (!m) |
1298 | if (!m) |
1263 | return 0; |
1299 | return 0; |
1264 | |
1300 | |
1265 | if (x < 0) |
1301 | if (x < 0) |
1266 | { |
1302 | { |
1267 | if (!m->tile_available (3)) |
1303 | if (!m->tile_available (TILE_WEST)) |
1268 | return 1; |
1304 | return 1; |
1269 | |
1305 | |
1270 | return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); |
1306 | return out_of_map (m->tile_map [TILE_WEST], x + m->tile_map [TILE_WEST]->width, y); |
1271 | } |
1307 | } |
1272 | |
1308 | |
1273 | if (x >= m->width) |
1309 | if (x >= m->width) |
1274 | { |
1310 | { |
1275 | if (!m->tile_available (1)) |
1311 | if (!m->tile_available (TILE_EAST)) |
1276 | return 1; |
1312 | return 1; |
1277 | |
1313 | |
1278 | return out_of_map (m->tile_map[1], x - m->width, y); |
1314 | return out_of_map (m->tile_map [TILE_EAST], x - m->width, y); |
1279 | } |
1315 | } |
1280 | |
1316 | |
1281 | if (y < 0) |
1317 | if (y < 0) |
1282 | { |
1318 | { |
1283 | if (!m->tile_available (0)) |
1319 | if (!m->tile_available (TILE_NORTH)) |
1284 | return 1; |
1320 | return 1; |
1285 | |
1321 | |
1286 | return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); |
1322 | return out_of_map (m->tile_map [TILE_NORTH], x, y + m->tile_map [TILE_NORTH]->height); |
1287 | } |
1323 | } |
1288 | |
1324 | |
1289 | if (y >= m->height) |
1325 | if (y >= m->height) |
1290 | { |
1326 | { |
1291 | if (!m->tile_available (2)) |
1327 | if (!m->tile_available (TILE_SOUTH)) |
1292 | return 1; |
1328 | return 1; |
1293 | |
1329 | |
1294 | return out_of_map (m->tile_map[2], x, y - m->height); |
1330 | return out_of_map (m->tile_map [TILE_SOUTH], x, y - m->height); |
1295 | } |
1331 | } |
1296 | |
1332 | |
1297 | /* Simple case - coordinates are within this local |
1333 | /* Simple case - coordinates are within this local |
1298 | * map. |
1334 | * map. |
1299 | */ |
1335 | */ |
… | |
… | |
1311 | maptile * |
1347 | maptile * |
1312 | maptile::xy_find (sint16 &x, sint16 &y) |
1348 | maptile::xy_find (sint16 &x, sint16 &y) |
1313 | { |
1349 | { |
1314 | if (x < 0) |
1350 | if (x < 0) |
1315 | { |
1351 | { |
1316 | if (!tile_available (3)) |
1352 | if (!tile_available (TILE_WEST)) |
1317 | return 0; |
1353 | return 0; |
1318 | |
1354 | |
1319 | x += tile_map[3]->width; |
1355 | x += tile_map [TILE_WEST]->width; |
1320 | return tile_map[3]->xy_find (x, y); |
1356 | return tile_map [TILE_WEST]->xy_find (x, y); |
1321 | } |
1357 | } |
1322 | |
1358 | |
1323 | if (x >= width) |
1359 | if (x >= width) |
1324 | { |
1360 | { |
1325 | if (!tile_available (1)) |
1361 | if (!tile_available (TILE_EAST)) |
1326 | return 0; |
1362 | return 0; |
1327 | |
1363 | |
1328 | x -= width; |
1364 | x -= width; |
1329 | return tile_map[1]->xy_find (x, y); |
1365 | return tile_map [TILE_EAST]->xy_find (x, y); |
1330 | } |
1366 | } |
1331 | |
1367 | |
1332 | if (y < 0) |
1368 | if (y < 0) |
1333 | { |
1369 | { |
1334 | if (!tile_available (0)) |
1370 | if (!tile_available (TILE_NORTH)) |
1335 | return 0; |
1371 | return 0; |
1336 | |
1372 | |
1337 | y += tile_map[0]->height; |
1373 | y += tile_map [TILE_NORTH]->height; |
1338 | return tile_map[0]->xy_find (x, y); |
1374 | return tile_map [TILE_NORTH]->xy_find (x, y); |
1339 | } |
1375 | } |
1340 | |
1376 | |
1341 | if (y >= height) |
1377 | if (y >= height) |
1342 | { |
1378 | { |
1343 | if (!tile_available (2)) |
1379 | if (!tile_available (TILE_SOUTH)) |
1344 | return 0; |
1380 | return 0; |
1345 | |
1381 | |
1346 | y -= height; |
1382 | y -= height; |
1347 | return tile_map[2]->xy_find (x, y); |
1383 | return tile_map [TILE_SOUTH]->xy_find (x, y); |
1348 | } |
1384 | } |
1349 | |
1385 | |
1350 | /* Simple case - coordinates are within this local |
1386 | /* Simple case - coordinates are within this local |
1351 | * map. |
1387 | * map. |
1352 | */ |
1388 | */ |