… | |
… | |
383 | if (!spaces) |
383 | if (!spaces) |
384 | return false; |
384 | return false; |
385 | |
385 | |
386 | for (int i = 0; i < size (); ++i) |
386 | for (int i = 0; i < size (); ++i) |
387 | { |
387 | { |
388 | int unique = 0; |
388 | bool unique = 0; |
|
|
389 | |
389 | for (object *op = spaces [i].bot; op; op = op->above) |
390 | for (object *op = spaces [i].bot; op; op = op->above) |
390 | { |
391 | { |
391 | if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) |
392 | unique |= op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]; |
392 | unique = 1; |
|
|
393 | |
393 | |
394 | if (!op->can_map_save ()) |
394 | if (expect_false (!op->can_map_save ())) |
395 | continue; |
395 | continue; |
396 | |
396 | |
397 | if (unique || op->flag [FLAG_UNIQUE]) |
397 | if (expect_false (unique || op->flag [FLAG_UNIQUE])) |
398 | { |
398 | { |
399 | if (flags & IO_UNIQUES) |
399 | if (flags & IO_UNIQUES) |
400 | op->write (f); |
400 | op->write (f); |
401 | } |
401 | } |
402 | else if (flags & IO_OBJECTS) |
402 | else if (expect_true (flags & IO_OBJECTS)) |
403 | op->write (f); |
403 | op->write (f); |
404 | } |
404 | } |
405 | } |
405 | } |
406 | |
406 | |
407 | coroapi::cede_to_tick (); |
407 | coroapi::cede_to_tick (); |
… | |
… | |
677 | case KW_tile_path_2: thawer.get (tile_path [1]); break; |
677 | case KW_tile_path_2: thawer.get (tile_path [1]); break; |
678 | case KW_tile_path_3: thawer.get (tile_path [2]); break; |
678 | case KW_tile_path_3: thawer.get (tile_path [2]); break; |
679 | case KW_tile_path_4: thawer.get (tile_path [3]); break; |
679 | case KW_tile_path_4: thawer.get (tile_path [3]); break; |
680 | |
680 | |
681 | case KW_ERROR: |
681 | case KW_ERROR: |
682 | set_key (thawer.kw_str, thawer.value); |
682 | set_key_text (thawer.kw_str, thawer.value); |
683 | break; |
683 | break; |
684 | |
684 | |
685 | case KW_end: |
685 | case KW_end: |
686 | return true; |
686 | return true; |
687 | |
687 | |
… | |
… | |
889 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
889 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
890 | break; |
890 | break; |
891 | |
891 | |
892 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
892 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
893 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
893 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
894 | || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) |
|
|
895 | || QUERY_FLAG (op, FLAG_UNIQUE) |
894 | || QUERY_FLAG (op, FLAG_UNIQUE) |
896 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
895 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
897 | || QUERY_FLAG (op, FLAG_UNPAID) |
896 | || QUERY_FLAG (op, FLAG_UNPAID) |
898 | || op->is_alive ()) |
897 | || op->is_alive ()) |
899 | ; // do not decay |
898 | ; // do not decay |
… | |
… | |
1259 | if (!m) |
1258 | if (!m) |
1260 | return 0; |
1259 | return 0; |
1261 | |
1260 | |
1262 | if (x < 0) |
1261 | if (x < 0) |
1263 | { |
1262 | { |
1264 | if (!m->tile_available (3, 0)) |
1263 | if (!m->tile_available (3)) |
1265 | return 1; |
1264 | return 1; |
1266 | |
1265 | |
1267 | return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); |
1266 | return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); |
1268 | } |
1267 | } |
1269 | |
1268 | |
1270 | if (x >= m->width) |
1269 | if (x >= m->width) |
1271 | { |
1270 | { |
1272 | if (!m->tile_available (1, 0)) |
1271 | if (!m->tile_available (1)) |
1273 | return 1; |
1272 | return 1; |
1274 | |
1273 | |
1275 | return out_of_map (m->tile_map[1], x - m->width, y); |
1274 | return out_of_map (m->tile_map[1], x - m->width, y); |
1276 | } |
1275 | } |
1277 | |
1276 | |
1278 | if (y < 0) |
1277 | if (y < 0) |
1279 | { |
1278 | { |
1280 | if (!m->tile_available (0, 0)) |
1279 | if (!m->tile_available (0)) |
1281 | return 1; |
1280 | return 1; |
1282 | |
1281 | |
1283 | return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); |
1282 | return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); |
1284 | } |
1283 | } |
1285 | |
1284 | |
1286 | if (y >= m->height) |
1285 | if (y >= m->height) |
1287 | { |
1286 | { |
1288 | if (!m->tile_available (2, 0)) |
1287 | if (!m->tile_available (2)) |
1289 | return 1; |
1288 | return 1; |
1290 | |
1289 | |
1291 | return out_of_map (m->tile_map[2], x, y - m->height); |
1290 | return out_of_map (m->tile_map[2], x, y - m->height); |
1292 | } |
1291 | } |
1293 | |
1292 | |
… | |
… | |
1308 | maptile * |
1307 | maptile * |
1309 | maptile::xy_find (sint16 &x, sint16 &y) |
1308 | maptile::xy_find (sint16 &x, sint16 &y) |
1310 | { |
1309 | { |
1311 | if (x < 0) |
1310 | if (x < 0) |
1312 | { |
1311 | { |
1313 | if (!tile_available (3, 1)) |
1312 | if (!tile_available (3)) |
1314 | return 0; |
1313 | return 0; |
1315 | |
1314 | |
1316 | x += tile_map[3]->width; |
1315 | x += tile_map[3]->width; |
1317 | return tile_map[3]->xy_find (x, y); |
1316 | return tile_map[3]->xy_find (x, y); |
1318 | } |
1317 | } |
1319 | |
1318 | |
1320 | if (x >= width) |
1319 | if (x >= width) |
1321 | { |
1320 | { |
1322 | if (!tile_available (1, 1)) |
1321 | if (!tile_available (1)) |
1323 | return 0; |
1322 | return 0; |
1324 | |
1323 | |
1325 | x -= width; |
1324 | x -= width; |
1326 | return tile_map[1]->xy_find (x, y); |
1325 | return tile_map[1]->xy_find (x, y); |
1327 | } |
1326 | } |
1328 | |
1327 | |
1329 | if (y < 0) |
1328 | if (y < 0) |
1330 | { |
1329 | { |
1331 | if (!tile_available (0, 1)) |
1330 | if (!tile_available (0)) |
1332 | return 0; |
1331 | return 0; |
1333 | |
1332 | |
1334 | y += tile_map[0]->height; |
1333 | y += tile_map[0]->height; |
1335 | return tile_map[0]->xy_find (x, y); |
1334 | return tile_map[0]->xy_find (x, y); |
1336 | } |
1335 | } |
1337 | |
1336 | |
1338 | if (y >= height) |
1337 | if (y >= height) |
1339 | { |
1338 | { |
1340 | if (!tile_available (2, 1)) |
1339 | if (!tile_available (2)) |
1341 | return 0; |
1340 | return 0; |
1342 | |
1341 | |
1343 | y -= height; |
1342 | y -= height; |
1344 | return tile_map[2]->xy_find (x, y); |
1343 | return tile_map[2]->xy_find (x, y); |
1345 | } |
1344 | } |
… | |
… | |
1358 | adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) |
1357 | adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) |
1359 | { |
1358 | { |
1360 | if (!map1 || !map2) |
1359 | if (!map1 || !map2) |
1361 | return 0; |
1360 | return 0; |
1362 | |
1361 | |
1363 | //TODO: this doesn't actually check corretcly when intermediate maps are not loaded |
1362 | //TODO: this doesn't actually check correctly when intermediate maps are not loaded |
1364 | //fix: compare paths instead (this is likely faster, too!) |
1363 | //fix: compare paths instead (this is likely faster, too!) |
1365 | if (map1 == map2) |
1364 | if (map1 == map2) |
1366 | { |
1365 | { |
1367 | *dx = 0; |
1366 | *dx = 0; |
1368 | *dy = 0; |
1367 | *dy = 0; |