… | |
… | |
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 |
… | |
… | |
1249 | return tile_map [dir]; |
1249 | return tile_map [dir]; |
1250 | |
1250 | |
1251 | if (tile_path [dir]) |
1251 | if (tile_path [dir]) |
1252 | { |
1252 | { |
1253 | // 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. |
1254 | if (maptile *m = find_async (tile_path [dir], this, load)) |
1256 | if (maptile *m = find_async (tile_path [dir], this, load)) |
1255 | { |
1257 | { |
1256 | bool match = true; |
1258 | bool mismatch = false; |
1257 | |
1259 | |
1258 | if (dir == TILE_NORTH || dir == TILE_SOUTH || dir == TILE_UP || dir == TILE_DOWN) |
1260 | if (dir == TILE_NORTH || dir == TILE_SOUTH || dir == TILE_UP || dir == TILE_DOWN) |
1259 | if (width != m->width) |
1261 | if (width != m->width) |
1260 | match = false; |
1262 | mismatch = true; |
1261 | |
1263 | |
1262 | if (dir == TILE_EAST || dir == TILE_WEST || dir == TILE_UP || dir == TILE_DOWN) |
1264 | if (dir == TILE_EAST || dir == TILE_WEST || dir == TILE_UP || dir == TILE_DOWN) |
1263 | if (height != m->height) |
1265 | if (height != m->height) |
1264 | match = false; |
1266 | mismatch = true; |
1265 | |
1267 | |
1266 | if (!match) |
1268 | if (mismatch) |
1267 | { |
1269 | { |
1268 | LOG (llevError, "tile dimension mismatch for direction %d from %s to %s\n", |
1270 | LOG (llevError, "tile dimension mismatch for direction %d from %s to %s\n", |
1269 | dir, &path, &m->path); |
1271 | dir, &path, &m->path); |
1270 | m = 0; |
1272 | m = 0; |
1271 | } |
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); |
1272 | |
1279 | |
1273 | // this could be optimised endlessly |
1280 | if (m->tile_path [dir2] == path) |
1274 | //m->activate_physics (); |
1281 | m->tile_map [dir2] = this; |
|
|
1282 | } |
|
|
1283 | |
1275 | |
1284 | |
1276 | return tile_map [dir] = m; |
1285 | return tile_map [dir] = m; |
1277 | } |
1286 | } |
1278 | } |
1287 | } |
1279 | |
1288 | |
… | |
… | |
1719 | if (x1 > m->width) |
1728 | if (x1 > m->width) |
1720 | { |
1729 | { |
1721 | if (maptile *tile = m->tile_available (TILE_EAST, 1)) |
1730 | if (maptile *tile = m->tile_available (TILE_EAST, 1)) |
1722 | 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); |
1723 | |
1732 | |
1724 | if (x0 > m->width) // entirely to the right |
1733 | if (x0 >= m->width) // entirely to the right |
1725 | return; |
1734 | return; |
1726 | |
1735 | |
1727 | x1 = m->width; |
1736 | x1 = m->width; |
1728 | } |
1737 | } |
1729 | |
1738 | |
1730 | // clip to map above |
1739 | // clip to map to the north |
1731 | if (y0 < 0) |
1740 | if (y0 < 0) |
1732 | { |
1741 | { |
1733 | if (maptile *tile = m->tile_available (TILE_NORTH, 1)) |
1742 | if (maptile *tile = m->tile_available (TILE_NORTH, 1)) |
1734 | 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); |
1735 | |
1744 | |
1736 | if (y1 < 0) // entirely above |
1745 | if (y1 < 0) // entirely to the north |
1737 | return; |
1746 | return; |
1738 | |
1747 | |
1739 | y0 = 0; |
1748 | y0 = 0; |
1740 | } |
1749 | } |
1741 | |
1750 | |
1742 | // clip to map below |
1751 | // clip to map to the south |
1743 | if (y1 > m->height) |
1752 | if (y1 > m->height) |
1744 | { |
1753 | { |
1745 | if (maptile *tile = m->tile_available (TILE_SOUTH, 1)) |
1754 | if (maptile *tile = m->tile_available (TILE_SOUTH, 1)) |
1746 | 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); |
1747 | |
1756 | |
1748 | if (y0 > m->height) // entirely below |
1757 | if (y0 >= m->height) // entirely to the south |
1749 | return; |
1758 | return; |
1750 | |
1759 | |
1751 | y1 = m->height; |
1760 | y1 = m->height; |
1752 | } |
1761 | } |
1753 | |
1762 | |