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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel |
5 | * Copyright (©) 2001 Mark Wedel |
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 | //+GPL |
25 | //+GPL |
26 | |
26 | |
… | |
… | |
163 | if (ob->map && ob->map->path) |
163 | if (ob->map && ob->map->path) |
164 | { |
164 | { |
165 | int flags = 0; |
165 | int flags = 0; |
166 | |
166 | |
167 | // due to historical glitches, the bit ordering and map index ordering differs |
167 | // due to historical glitches, the bit ordering and map index ordering differs |
168 | if (ob->map->tile_path[TILE_NORTH]) flags |= 0x01; |
168 | if (ob->map->tile_path [TILE_NORTH]) flags |= 0x01; |
169 | if (ob->map->tile_path[TILE_EAST ]) flags |= 0x02; |
169 | if (ob->map->tile_path [TILE_EAST ]) flags |= 0x02; |
170 | if (ob->map->tile_path[TILE_SOUTH]) flags |= 0x04; |
170 | if (ob->map->tile_path [TILE_SOUTH]) flags |= 0x04; |
171 | if (ob->map->tile_path[TILE_WEST ]) flags |= 0x08; |
171 | if (ob->map->tile_path [TILE_WEST ]) flags |= 0x08; |
172 | // these two are debatable |
172 | // these two are debatable |
173 | if (ob->map->tile_path[TILE_UP ]) flags |= 0x10; |
173 | if (ob->map->tile_path [TILE_UP ]) flags |= 0x10; |
174 | if (ob->map->tile_path[TILE_DOWN ]) flags |= 0x20; |
174 | if (ob->map->tile_path [TILE_DOWN ]) flags |= 0x20; |
175 | |
175 | |
176 | socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", |
176 | socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", |
177 | flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, |
177 | flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, |
178 | ob->map->width, ob->map->height, &ob->map->path); |
178 | ob->map->width, ob->map->height, &ob->map->path); |
179 | } |
179 | } |
… | |
… | |
194 | { |
194 | { |
195 | INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); |
195 | INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); |
196 | socket.current_region = reg; |
196 | socket.current_region = reg; |
197 | } |
197 | } |
198 | |
198 | |
199 | // first try to aovid a full newmap on tiled map scrolls |
199 | // first try to avoid a full newmap on tiled map scrolls |
200 | if (socket.current_map != ob->map && !socket.force_newmap) |
200 | if (socket.current_map != ob->map && !socket.force_newmap) |
201 | { |
201 | { |
202 | rv_vector rv; |
202 | rv_vector rv; |
203 | |
203 | |
204 | get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0); |
204 | get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0); |
… | |
… | |
276 | |
276 | |
277 | /** |
277 | /** |
278 | * RequestInfo is sort of a meta command. There is some specific |
278 | * RequestInfo is sort of a meta command. There is some specific |
279 | * request of information, but we call other functions to provide |
279 | * request of information, but we call other functions to provide |
280 | * that information. |
280 | * that information. |
|
|
281 | * requestinfo is completely deprecated, use resource exti request |
|
|
282 | * and the fxix or http protocols. |
281 | */ |
283 | */ |
282 | void |
284 | void |
283 | RequestInfo (char *buf, int len, client *ns) |
285 | RequestInfo (char *buf, int len, client *ns) |
284 | { |
286 | { |
285 | char *params; |
287 | char *params; |
… | |
… | |
349 | |
351 | |
350 | // due to historical glitches, the mapinfo index and tile index differs |
352 | // due to historical glitches, the mapinfo index and tile index differs |
351 | static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN }; |
353 | static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN }; |
352 | |
354 | |
353 | // maybe we should only allow the four flat directions |
355 | // maybe we should only allow the four flat directions |
354 | if (dir >= 0 && dir < array_length (dirmap)) |
356 | if (IN_RANGE_EXC (dir, 0, array_length (dirmap))) |
355 | { |
357 | { |
356 | dir = dirmap [dir]; |
358 | dir = dirmap [dir]; |
357 | |
359 | |
358 | if (!map->tile_path [dir]) |
360 | if (!map->tile_path [dir]) |
359 | map = 0; |
361 | map = 0; |
… | |
… | |
386 | else |
388 | else |
387 | { |
389 | { |
388 | int flags = 0; |
390 | int flags = 0; |
389 | |
391 | |
390 | // due to historical glitches, the bit ordering and map index ordering differs |
392 | // due to historical glitches, the bit ordering and map index ordering differs |
391 | if (map->tile_path[TILE_NORTH]) flags |= 0x01; |
393 | if (map->tile_path [TILE_NORTH]) flags |= 0x01; |
392 | if (map->tile_path[TILE_EAST ]) flags |= 0x02; |
394 | if (map->tile_path [TILE_EAST ]) flags |= 0x02; |
393 | if (map->tile_path[TILE_SOUTH]) flags |= 0x04; |
395 | if (map->tile_path [TILE_SOUTH]) flags |= 0x04; |
394 | if (map->tile_path[TILE_WEST ]) flags |= 0x08; |
396 | if (map->tile_path [TILE_WEST ]) flags |= 0x08; |
395 | // these two are debatable |
397 | // these two are debatable |
396 | if (map->tile_path[TILE_UP ]) flags |= 0x10; |
398 | if (map->tile_path [TILE_UP ]) flags |= 0x10; |
397 | if (map->tile_path[TILE_DOWN ]) flags |= 0x20; |
399 | if (map->tile_path [TILE_DOWN ]) flags |= 0x20; |
398 | |
400 | |
399 | send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); |
401 | send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); |
400 | } |
402 | } |
401 | |
403 | |
402 | return 1; |
404 | return 1; |
… | |
… | |
886 | } |
888 | } |
887 | |
889 | |
888 | /* Nothing changed */ |
890 | /* Nothing changed */ |
889 | return 0; |
891 | return 0; |
890 | } |
892 | } |
891 | |
|
|
892 | //-GPL |
|
|
893 | |
|
|
894 | // prefetch some flat area around the player |
|
|
895 | static void |
|
|
896 | prefetch_surrounding_area (object *op, maptile *map, int range) |
|
|
897 | { |
|
|
898 | for (maprect *rect = map->split_to_tiles (mapwalk_buf, |
|
|
899 | op->x - range , op->y - range , |
|
|
900 | op->x + range + 1, op->y + range + 1); |
|
|
901 | rect->m; |
|
|
902 | ++rect) |
|
|
903 | { |
|
|
904 | rect->m->touch (); |
|
|
905 | rect->m->activate (); |
|
|
906 | } |
|
|
907 | } |
|
|
908 | |
|
|
909 | // prefetch a generous area around the player, also up and down |
|
|
910 | void |
|
|
911 | object::prefetch_surrounding_maps () |
|
|
912 | { |
|
|
913 | prefetch_surrounding_area (this, map, 40); |
|
|
914 | |
|
|
915 | if (maptile *m = map->tile_available (TILE_DOWN)) |
|
|
916 | prefetch_surrounding_area (this, m, 20); |
|
|
917 | |
|
|
918 | if (maptile *m = map->tile_available (TILE_UP)) |
|
|
919 | prefetch_surrounding_area (this, m, 20); |
|
|
920 | } |
|
|
921 | |
|
|
922 | //+GPL |
|
|
923 | |
893 | |
924 | /** |
894 | /** |
925 | * Draws client map. |
895 | * Draws client map. |
926 | */ |
896 | */ |
927 | void |
897 | void |
… | |
… | |
1267 | |
1237 | |
1268 | /* appends the spell *spell to the Socklist we will send the data to. */ |
1238 | /* appends the spell *spell to the Socklist we will send the data to. */ |
1269 | static void |
1239 | static void |
1270 | append_spell (player *pl, packet &sl, object *spell) |
1240 | append_spell (player *pl, packet &sl, object *spell) |
1271 | { |
1241 | { |
1272 | int i, skill = 0; |
1242 | int skill = 0; |
1273 | |
1243 | |
1274 | if (!(spell->name)) |
1244 | if (!(spell->name)) |
1275 | { |
1245 | { |
1276 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1246 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1277 | return; |
1247 | return; |