1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <unistd.h> |
25 | #include <unistd.h> |
26 | |
26 | |
… | |
… | |
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 | |
… | |
… | |
1495 | * so you just can not look the the map coordinates and get the |
1504 | * so you just can not look the the map coordinates and get the |
1496 | * righte value. distance_x/y are distance away, which |
1505 | * righte value. distance_x/y are distance away, which |
1497 | * can be negative. direction is the crossfire direction scheme |
1506 | * can be negative. direction is the crossfire direction scheme |
1498 | * that the creature should head. part is the part of the |
1507 | * that the creature should head. part is the part of the |
1499 | * monster that is closest. |
1508 | * monster that is closest. |
1500 | * |
1509 | * |
1501 | * get_rangevector looks at op1 and op2, and fills in the |
1510 | * get_rangevector looks at op1 and op2, and fills in the |
1502 | * structure for op1 to get to op2. |
1511 | * structure for op1 to get to op2. |
1503 | * We already trust that the caller has verified that the |
1512 | * We already trust that the caller has verified that the |
1504 | * two objects are at least on adjacent maps. If not, |
1513 | * two objects are at least on adjacent maps. If not, |
1505 | * results are not likely to be what is desired. |
1514 | * results are not likely to be what is desired. |
… | |
… | |
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 | |