… | |
… | |
146 | pl->ns->mapinfo_queue_clear (); |
146 | pl->ns->mapinfo_queue_clear (); |
147 | |
147 | |
148 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
148 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
149 | |
149 | |
150 | pl->ns->force_newmap = false; |
150 | pl->ns->force_newmap = false; |
151 | |
|
|
152 | if (pl->ns->newmapcmd == 1) |
|
|
153 | pl->ns->send_packet ("newmap"); |
151 | pl->ns->send_packet ("newmap"); |
154 | |
|
|
155 | pl->ns->floorbox_reset (); |
152 | pl->ns->floorbox_reset (); |
156 | } |
153 | } |
157 | |
154 | |
158 | static void |
155 | static void |
159 | send_map_info (player *pl) |
156 | send_map_info (player *pl) |
… | |
… | |
246 | |
243 | |
247 | for (int i = 0; i < skillvec.size (); ++i) |
244 | for (int i = 0; i < skillvec.size (); ++i) |
248 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
245 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
249 | |
246 | |
250 | if (sl.length () > MAXSOCKBUF) |
247 | if (sl.length () > MAXSOCKBUF) |
251 | { |
|
|
252 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
248 | cleanup ("buffer overflow in send_skill_info!"); |
253 | fatal (0); |
|
|
254 | } |
|
|
255 | |
249 | |
256 | ns->send_packet (sl); |
250 | ns->send_packet (sl); |
257 | } |
251 | } |
258 | |
252 | |
259 | /** |
253 | /** |
… | |
… | |
269 | |
263 | |
270 | for (int i = 0; i < NRSPELLPATHS; i++) |
264 | for (int i = 0; i < NRSPELLPATHS; i++) |
271 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
265 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
272 | |
266 | |
273 | if (sl.length () > MAXSOCKBUF) |
267 | if (sl.length () > MAXSOCKBUF) |
274 | { |
|
|
275 | LOG (llevError, "Buffer overflow in send_spell_paths!\n"); |
268 | cleanup ("buffer overflow in send_spell_paths!"); |
276 | fatal (0); |
|
|
277 | } |
|
|
278 | |
269 | |
279 | ns->send_packet (sl); |
270 | ns->send_packet (sl); |
280 | } |
271 | } |
281 | |
272 | |
282 | /** |
273 | /** |
… | |
… | |
884 | return 0; |
875 | return 0; |
885 | } |
876 | } |
886 | |
877 | |
887 | //-GPL |
878 | //-GPL |
888 | |
879 | |
889 | // prefetch (and touch) all maps within a specific distancd |
880 | // prefetch maps in an area of PREFETCH x PREFETCH around the player |
890 | static void |
881 | #define PREFETCH 40 |
891 | prefetch_surrounding_maps (maptile *map, int distance) |
|
|
892 | { |
|
|
893 | map->touch (); |
|
|
894 | |
|
|
895 | if (--distance) |
|
|
896 | for (int dir = 4; dir--; ) |
|
|
897 | if (const shstr &path = map->tile_path [dir]) |
|
|
898 | if (maptile *&neigh = map->tile_map [dir]) |
|
|
899 | prefetch_surrounding_maps (neigh, distance); |
|
|
900 | else |
|
|
901 | neigh = maptile::find_async (path, map); |
|
|
902 | } |
|
|
903 | |
882 | |
904 | // prefetch a generous area around the player |
883 | // prefetch a generous area around the player |
905 | static void |
884 | static void |
906 | prefetch_surrounding_maps (object *op) |
885 | prefetch_surrounding_maps (object *op) |
907 | { |
886 | { |
908 | prefetch_surrounding_maps (op->map, 3); |
887 | for (maprect *rect = op->map->split_to_tiles (mapwalk_buf, |
|
|
888 | op->x - PREFETCH , op->y - PREFETCH , |
|
|
889 | op->x + PREFETCH + 1, op->y + PREFETCH + 1); |
|
|
890 | rect->m; |
|
|
891 | ++rect) |
|
|
892 | rect->m->touch (); |
909 | } |
893 | } |
910 | |
894 | |
911 | //+GPL |
895 | //+GPL |
912 | |
896 | |
913 | /** |
897 | /** |
… | |
… | |
963 | * look like. |
947 | * look like. |
964 | */ |
948 | */ |
965 | |
949 | |
966 | client &socket = *pl->ns; |
950 | client &socket = *pl->ns; |
967 | |
951 | |
968 | packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); |
952 | packet sl ("map1a"); |
969 | |
953 | |
970 | startlen = sl.length (); |
954 | startlen = sl.length (); |
971 | |
955 | |
972 | int hx = socket.mapx / 2; |
956 | int hx = socket.mapx / 2; |
973 | int hy = socket.mapy / 2; |
957 | int hy = socket.mapy / 2; |
… | |
… | |
1356 | } |
1340 | } |
1357 | else |
1341 | else |
1358 | append_spell (pl, sl, spell); |
1342 | append_spell (pl, sl, spell); |
1359 | |
1343 | |
1360 | if (sl.length () > MAXSOCKBUF) |
1344 | if (sl.length () > MAXSOCKBUF) |
1361 | { |
|
|
1362 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
1345 | cleanup ("buffer overflow in esrv_add_spells!"); |
1363 | fatal (0); |
|
|
1364 | } |
|
|
1365 | |
1346 | |
1366 | /* finally, we can send the packet */ |
1347 | /* finally, we can send the packet */ |
1367 | pl->ns->flush_fx (); |
1348 | pl->ns->flush_fx (); |
1368 | pl->ns->send_packet (sl); |
1349 | pl->ns->send_packet (sl); |
1369 | } |
1350 | } |