… | |
… | |
543 | *q = '\0'; |
543 | *q = '\0'; |
544 | |
544 | |
545 | current_type = get_typedata_by_name (p); |
545 | current_type = get_typedata_by_name (p); |
546 | if (current_type) |
546 | if (current_type) |
547 | { |
547 | { |
548 | items[i].name = current_type->name; |
548 | items[i].name = current_type->name; |
549 | items[i].typenum = current_type->number; |
549 | items[i].typenum = current_type->number; |
550 | items[i].name_pl = current_type->name_pl; |
550 | items[i].name_pl = current_type->name_pl; |
551 | } |
551 | } |
552 | else |
552 | else |
553 | { /* oh uh, something's wrong, let's free up this one, and try |
553 | { /* oh uh, something's wrong, let's free up this one, and try |
… | |
… | |
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 | if (floor && floor->arch->archname == shstr_quad_open_space) |
1201 | if (floor && floor->flag [FLAG_IS_TRANSPARENT_FLOOR] && !middle && !top) |
1202 | { |
1202 | { |
1203 | floor->set_anim_frame (0); |
1203 | floor->set_anim_frame (0); |
1204 | |
1204 | |
1205 | if (maptile *m = floor->map->tile_map [TILE_DOWN]) |
1205 | if (maptile *m = floor->map->tile_map [TILE_DOWN]) |
1206 | { |
1206 | { |
1207 | // mirror the floor - very unreliable because usually outdated, |
|
|
1208 | // but somewhta works because floors do not change often :/ |
|
|
1209 | mapspace &ms = m->at (floor->x, floor->y); |
1207 | mapspace &ms = m->at (floor->x, floor->y); |
1210 | ms.update (); |
1208 | ms.update (); |
1211 | |
1209 | |
1212 | if (object *floor2 = ms.faces_obj [2]) |
1210 | if (object *floor2 = ms.faces_obj [2]) |
1213 | if (floor2->arch->archname != shstr_quad_open_space && !middle) |
1211 | if (!floor2->flag [FLAG_IS_TRANSPARENT_FLOOR]) |
1214 | { |
1212 | { |
1215 | floor->set_anim_frame (1); |
1213 | floor->set_anim_frame (1); |
1216 | middle = floor; |
1214 | top = floor; |
|
|
1215 | middle = ms.faces_obj [0]; |
1217 | floor = floor2; |
1216 | floor = floor2; |
1218 | } |
1217 | } |
|
|
1218 | |
|
|
1219 | ms.pflags |= PF_VIS_UP; |
1219 | } |
1220 | } |
1220 | } |
1221 | } |
1221 | |
1222 | |
1222 | #if 0 |
1223 | #if 0 |
1223 | faces_obj [0] = top; |
1224 | faces_obj [0] = top; |
1224 | faces_obj [1] = middle; |
1225 | faces_obj [1] = middle; |
1225 | faces_obj [2] = floor; |
1226 | faces_obj [2] = floor; |
1226 | #endif |
1227 | #endif |
1227 | } |
1228 | } |
1228 | |
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 | |
1229 | maptile * |
1244 | maptile * |
1230 | maptile::tile_available (int dir, bool load) |
1245 | maptile::tile_available (int dir, bool load) |
1231 | { |
1246 | { |
1232 | if (tile_path[dir]) |
|
|
1233 | { |
|
|
1234 | // 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 |
1235 | if (tile_map[dir] && (!load || tile_map[dir]->linkable ())) |
1248 | if (tile_map [dir] && (!load || tile_map [dir]->linkable ())) |
1236 | return tile_map[dir]; |
1249 | return tile_map [dir]; |
1237 | |
1250 | |
|
|
1251 | if (tile_path [dir]) |
|
|
1252 | { |
1238 | // 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 |
|
|
1254 | // this is the ONLY place in the server that links maps with each other, |
|
|
1255 | // so any kind of inter-map stuff has to be initiated here. |
1239 | if ((tile_map[dir] = find_async (tile_path[dir], this, load))) |
1256 | if (maptile *m = find_async (tile_path [dir], this, load)) |
|
|
1257 | { |
|
|
1258 | bool mismatch = false; |
|
|
1259 | |
|
|
1260 | if (dir == TILE_NORTH || dir == TILE_SOUTH || dir == TILE_UP || dir == TILE_DOWN) |
|
|
1261 | if (width != m->width) |
|
|
1262 | mismatch = true; |
|
|
1263 | |
|
|
1264 | if (dir == TILE_EAST || dir == TILE_WEST || dir == TILE_UP || dir == TILE_DOWN) |
|
|
1265 | if (height != m->height) |
|
|
1266 | mismatch = true; |
|
|
1267 | |
|
|
1268 | if (mismatch) |
|
|
1269 | { |
|
|
1270 | LOG (llevError, "tile dimension mismatch for direction %d from %s to %s\n", |
|
|
1271 | dir, &path, &m->path); |
|
|
1272 | m = 0; |
|
|
1273 | } |
|
|
1274 | else if (0)//D |
|
|
1275 | { |
|
|
1276 | // as an optimisation, link us against the other map if the other map |
|
|
1277 | // has us as neighbour, which is very common, but not guaranteed. |
|
|
1278 | int dir2 = REVERSE_TILE_DIR (dir); |
|
|
1279 | |
|
|
1280 | if (m->tile_path [dir2] == path) |
|
|
1281 | m->tile_map [dir2] = this; |
|
|
1282 | } |
|
|
1283 | |
|
|
1284 | |
1240 | return tile_map[dir]; |
1285 | return tile_map [dir] = m; |
|
|
1286 | } |
1241 | } |
1287 | } |
1242 | |
1288 | |
1243 | return 0; |
1289 | return 0; |
1244 | } |
1290 | } |
1245 | |
1291 | |
… | |
… | |
1261 | if (!m) |
1307 | if (!m) |
1262 | return 0; |
1308 | return 0; |
1263 | |
1309 | |
1264 | if (x < 0) |
1310 | if (x < 0) |
1265 | { |
1311 | { |
1266 | if (!m->tile_available (3)) |
1312 | if (!m->tile_available (TILE_WEST)) |
1267 | return 1; |
1313 | return 1; |
1268 | |
1314 | |
1269 | return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); |
1315 | return out_of_map (m->tile_map [TILE_WEST], x + m->tile_map [TILE_WEST]->width, y); |
1270 | } |
1316 | } |
1271 | |
1317 | |
1272 | if (x >= m->width) |
1318 | if (x >= m->width) |
1273 | { |
1319 | { |
1274 | if (!m->tile_available (1)) |
1320 | if (!m->tile_available (TILE_EAST)) |
1275 | return 1; |
1321 | return 1; |
1276 | |
1322 | |
1277 | return out_of_map (m->tile_map[1], x - m->width, y); |
1323 | return out_of_map (m->tile_map [TILE_EAST], x - m->width, y); |
1278 | } |
1324 | } |
1279 | |
1325 | |
1280 | if (y < 0) |
1326 | if (y < 0) |
1281 | { |
1327 | { |
1282 | if (!m->tile_available (0)) |
1328 | if (!m->tile_available (TILE_NORTH)) |
1283 | return 1; |
1329 | return 1; |
1284 | |
1330 | |
1285 | return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); |
1331 | return out_of_map (m->tile_map [TILE_NORTH], x, y + m->tile_map [TILE_NORTH]->height); |
1286 | } |
1332 | } |
1287 | |
1333 | |
1288 | if (y >= m->height) |
1334 | if (y >= m->height) |
1289 | { |
1335 | { |
1290 | if (!m->tile_available (2)) |
1336 | if (!m->tile_available (TILE_SOUTH)) |
1291 | return 1; |
1337 | return 1; |
1292 | |
1338 | |
1293 | return out_of_map (m->tile_map[2], x, y - m->height); |
1339 | return out_of_map (m->tile_map [TILE_SOUTH], x, y - m->height); |
1294 | } |
1340 | } |
1295 | |
1341 | |
1296 | /* Simple case - coordinates are within this local |
1342 | /* Simple case - coordinates are within this local |
1297 | * map. |
1343 | * map. |
1298 | */ |
1344 | */ |
… | |
… | |
1310 | maptile * |
1356 | maptile * |
1311 | maptile::xy_find (sint16 &x, sint16 &y) |
1357 | maptile::xy_find (sint16 &x, sint16 &y) |
1312 | { |
1358 | { |
1313 | if (x < 0) |
1359 | if (x < 0) |
1314 | { |
1360 | { |
1315 | if (!tile_available (3)) |
1361 | if (!tile_available (TILE_WEST)) |
1316 | return 0; |
1362 | return 0; |
1317 | |
1363 | |
1318 | x += tile_map[3]->width; |
1364 | x += tile_map [TILE_WEST]->width; |
1319 | return tile_map[3]->xy_find (x, y); |
1365 | return tile_map [TILE_WEST]->xy_find (x, y); |
1320 | } |
1366 | } |
1321 | |
1367 | |
1322 | if (x >= width) |
1368 | if (x >= width) |
1323 | { |
1369 | { |
1324 | if (!tile_available (1)) |
1370 | if (!tile_available (TILE_EAST)) |
1325 | return 0; |
1371 | return 0; |
1326 | |
1372 | |
1327 | x -= width; |
1373 | x -= width; |
1328 | return tile_map[1]->xy_find (x, y); |
1374 | return tile_map [TILE_EAST]->xy_find (x, y); |
1329 | } |
1375 | } |
1330 | |
1376 | |
1331 | if (y < 0) |
1377 | if (y < 0) |
1332 | { |
1378 | { |
1333 | if (!tile_available (0)) |
1379 | if (!tile_available (TILE_NORTH)) |
1334 | return 0; |
1380 | return 0; |
1335 | |
1381 | |
1336 | y += tile_map[0]->height; |
1382 | y += tile_map [TILE_NORTH]->height; |
1337 | return tile_map[0]->xy_find (x, y); |
1383 | return tile_map [TILE_NORTH]->xy_find (x, y); |
1338 | } |
1384 | } |
1339 | |
1385 | |
1340 | if (y >= height) |
1386 | if (y >= height) |
1341 | { |
1387 | { |
1342 | if (!tile_available (2)) |
1388 | if (!tile_available (TILE_SOUTH)) |
1343 | return 0; |
1389 | return 0; |
1344 | |
1390 | |
1345 | y -= height; |
1391 | y -= height; |
1346 | return tile_map[2]->xy_find (x, y); |
1392 | return tile_map [TILE_SOUTH]->xy_find (x, y); |
1347 | } |
1393 | } |
1348 | |
1394 | |
1349 | /* Simple case - coordinates are within this local |
1395 | /* Simple case - coordinates are within this local |
1350 | * map. |
1396 | * map. |
1351 | */ |
1397 | */ |
… | |
… | |
1682 | if (x1 > m->width) |
1728 | if (x1 > m->width) |
1683 | { |
1729 | { |
1684 | if (maptile *tile = m->tile_available (TILE_EAST, 1)) |
1730 | if (maptile *tile = m->tile_available (TILE_EAST, 1)) |
1685 | split_to_tiles (buf, tile, max (x0 - m->width, 0), y0, x1 - m->width, y1, dx + m->width, dy); |
1731 | split_to_tiles (buf, tile, max (x0 - m->width, 0), y0, x1 - m->width, y1, dx + m->width, dy); |
1686 | |
1732 | |
1687 | if (x0 > m->width) // entirely to the right |
1733 | if (x0 >= m->width) // entirely to the right |
1688 | return; |
1734 | return; |
1689 | |
1735 | |
1690 | x1 = m->width; |
1736 | x1 = m->width; |
1691 | } |
1737 | } |
1692 | |
1738 | |
1693 | // clip to map above |
1739 | // clip to map to the north |
1694 | if (y0 < 0) |
1740 | if (y0 < 0) |
1695 | { |
1741 | { |
1696 | if (maptile *tile = m->tile_available (TILE_NORTH, 1)) |
1742 | if (maptile *tile = m->tile_available (TILE_NORTH, 1)) |
1697 | split_to_tiles (buf, tile, x0, y0 + tile->height, x1, min (y1 + tile->height, tile->height), dx, dy - tile->height); |
1743 | split_to_tiles (buf, tile, x0, y0 + tile->height, x1, min (y1 + tile->height, tile->height), dx, dy - tile->height); |
1698 | |
1744 | |
1699 | if (y1 < 0) // entirely above |
1745 | if (y1 < 0) // entirely to the north |
1700 | return; |
1746 | return; |
1701 | |
1747 | |
1702 | y0 = 0; |
1748 | y0 = 0; |
1703 | } |
1749 | } |
1704 | |
1750 | |
1705 | // clip to map below |
1751 | // clip to map to the south |
1706 | if (y1 > m->height) |
1752 | if (y1 > m->height) |
1707 | { |
1753 | { |
1708 | if (maptile *tile = m->tile_available (TILE_SOUTH, 1)) |
1754 | if (maptile *tile = m->tile_available (TILE_SOUTH, 1)) |
1709 | split_to_tiles (buf, tile, x0, max (y0 - m->height, 0), x1, y1 - m->height, dx, dy + m->height); |
1755 | split_to_tiles (buf, tile, x0, max (y0 - m->height, 0), x1, y1 - m->height, dx, dy + m->height); |
1710 | |
1756 | |
1711 | if (y0 > m->height) // entirely below |
1757 | if (y0 >= m->height) // entirely to the south |
1712 | return; |
1758 | return; |
1713 | |
1759 | |
1714 | y1 = m->height; |
1760 | y1 = m->height; |
1715 | } |
1761 | } |
1716 | |
1762 | |