… | |
… | |
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) |
… | |
… | |
165 | { |
162 | { |
166 | if (ob->map && ob->map->path[0]) |
163 | if (ob->map && ob->map->path[0]) |
167 | { |
164 | { |
168 | int flags = 0; |
165 | int flags = 0; |
169 | |
166 | |
170 | if (ob->map->tile_path[0]) flags |= 1; |
167 | if (ob->map->tile_path[0]) flags |= 0x01; |
171 | if (ob->map->tile_path[1]) flags |= 2; |
168 | if (ob->map->tile_path[1]) flags |= 0x02; |
172 | if (ob->map->tile_path[2]) flags |= 4; |
169 | if (ob->map->tile_path[2]) flags |= 0x04; |
173 | if (ob->map->tile_path[3]) flags |= 8; |
170 | if (ob->map->tile_path[3]) flags |= 0x08; |
|
|
171 | // these two are debatable |
|
|
172 | if (ob->map->tile_path[4]) flags |= 0x10; |
|
|
173 | if (ob->map->tile_path[5]) flags |= 0x20; |
174 | |
174 | |
175 | socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", |
175 | socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s", |
176 | flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, |
176 | flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, |
177 | ob->map->width, ob->map->height, &ob->map->path); |
177 | ob->map->width, ob->map->height, &ob->map->path); |
178 | } |
178 | } |
… | |
… | |
246 | |
246 | |
247 | for (int i = 0; i < skillvec.size (); ++i) |
247 | for (int i = 0; i < skillvec.size (); ++i) |
248 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
248 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
249 | |
249 | |
250 | if (sl.length () > MAXSOCKBUF) |
250 | if (sl.length () > MAXSOCKBUF) |
251 | { |
|
|
252 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
251 | cleanup ("buffer overflow in send_skill_info!"); |
253 | fatal (0); |
|
|
254 | } |
|
|
255 | |
252 | |
256 | ns->send_packet (sl); |
253 | ns->send_packet (sl); |
257 | } |
254 | } |
258 | |
255 | |
259 | /** |
256 | /** |
… | |
… | |
269 | |
266 | |
270 | for (int i = 0; i < NRSPELLPATHS; i++) |
267 | for (int i = 0; i < NRSPELLPATHS; i++) |
271 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
268 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
272 | |
269 | |
273 | if (sl.length () > MAXSOCKBUF) |
270 | if (sl.length () > MAXSOCKBUF) |
274 | { |
|
|
275 | LOG (llevError, "Buffer overflow in send_spell_paths!\n"); |
271 | cleanup ("buffer overflow in send_spell_paths!"); |
276 | fatal (0); |
|
|
277 | } |
|
|
278 | |
272 | |
279 | ns->send_packet (sl); |
273 | ns->send_packet (sl); |
280 | } |
274 | } |
281 | |
275 | |
282 | /** |
276 | /** |
… | |
… | |
350 | |
344 | |
351 | while (*buf && map && max_distance) |
345 | while (*buf && map && max_distance) |
352 | { |
346 | { |
353 | int dir = *buf++ - '1'; |
347 | int dir = *buf++ - '1'; |
354 | |
348 | |
|
|
349 | // maybe we should only allow the four flat directions |
355 | if (dir >= 0 && dir <= 3) |
350 | if (dir >= 0 && dir < TILE_NUM) |
356 | { |
351 | { |
357 | if (!map->tile_path [dir]) |
352 | if (!map->tile_path [dir]) |
358 | map = 0; |
353 | map = 0; |
359 | else if (map->tile_available (dir, false)) |
354 | else if (map->tile_available (dir, false)) |
360 | { |
355 | { |
… | |
… | |
384 | send_packet_printf ("mapinfo %s nomap", token); |
379 | send_packet_printf ("mapinfo %s nomap", token); |
385 | else |
380 | else |
386 | { |
381 | { |
387 | int flags = 0; |
382 | int flags = 0; |
388 | |
383 | |
389 | if (map->tile_path[0]) flags |= 1; |
384 | if (map->tile_path[0]) flags |= 0x01; |
390 | if (map->tile_path[1]) flags |= 2; |
385 | if (map->tile_path[1]) flags |= 0x02; |
391 | if (map->tile_path[2]) flags |= 4; |
386 | if (map->tile_path[2]) flags |= 0x04; |
392 | if (map->tile_path[3]) flags |= 8; |
387 | if (map->tile_path[3]) flags |= 0x08; |
|
|
388 | // these two are debatable |
|
|
389 | if (map->tile_path[4]) flags |= 0x10; |
|
|
390 | if (map->tile_path[5]) flags |= 0x20; |
393 | |
391 | |
394 | send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); |
392 | send_packet_printf ("mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); |
395 | } |
393 | } |
396 | |
394 | |
397 | return 1; |
395 | return 1; |
… | |
… | |
711 | * commands for now. |
709 | * commands for now. |
712 | */ |
710 | */ |
713 | void |
711 | void |
714 | esrv_update_stats (player *pl) |
712 | esrv_update_stats (player *pl) |
715 | { |
713 | { |
716 | char buf[MAX_BUF]; |
|
|
717 | uint16 flags; |
|
|
718 | |
|
|
719 | client *ns = pl->ns; |
714 | client *ns = pl->ns; |
720 | if (!ns) |
715 | if (!ns) |
721 | return; |
716 | return; |
722 | |
717 | |
723 | object *ob = pl->observe; |
718 | object *ob = pl->observe; |
… | |
… | |
764 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
759 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
765 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
760 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
766 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
761 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
767 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
762 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
768 | |
763 | |
769 | flags = (opl->fire_on ? SF_FIREON : 0) |
764 | int flags = (opl->fire_on ? SF_FIREON : 0) |
770 | | (opl->run_on ? SF_RUNON : 0); |
765 | | (opl->run_on ? SF_RUNON : 0); |
771 | |
766 | |
772 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
767 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
773 | |
768 | |
774 | for (int i = 0; i < NROFATTACKS; i++) |
769 | for (int i = 0; i < NROFATTACKS; i++) |
775 | /* Skip ones we won't send */ |
770 | /* Skip ones we won't send */ |
… | |
… | |
781 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
776 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
782 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
777 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
783 | AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); |
778 | AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); |
784 | } |
779 | } |
785 | |
780 | |
|
|
781 | char buf[MAX_BUF]; |
786 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
782 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
787 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
783 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
788 | set_title (ob, buf); |
784 | set_title (ob, buf); |
789 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
785 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
790 | |
786 | |
… | |
… | |
886 | return 0; |
882 | return 0; |
887 | } |
883 | } |
888 | |
884 | |
889 | //-GPL |
885 | //-GPL |
890 | |
886 | |
891 | // prefetch (and touch) all maps within a specific distancd |
887 | // prefetch some flat area around the player |
892 | static void |
888 | static void |
893 | prefetch_surrounding_maps (maptile *map, int distance) |
889 | prefetch_surrounding_area (object *op, maptile *map, int range) |
894 | { |
890 | { |
895 | map->touch (); |
891 | for (maprect *rect = map->split_to_tiles (mapwalk_buf, |
896 | |
892 | op->x - range , op->y - range , |
897 | if (--distance) |
893 | op->x + range + 1, op->y + range + 1); |
898 | for (int dir = 4; dir--; ) |
894 | rect->m; |
899 | if (const shstr &path = map->tile_path [dir]) |
895 | ++rect) |
900 | if (maptile *&neigh = map->tile_map [dir]) |
896 | rect->m->touch (); |
901 | prefetch_surrounding_maps (neigh, distance); |
|
|
902 | else |
|
|
903 | neigh = maptile::find_async (path, map); |
|
|
904 | } |
897 | } |
905 | |
898 | |
906 | // prefetch a generous area around the player |
899 | // prefetch a generous area around the player, also up and down |
907 | static void |
900 | static void |
908 | prefetch_surrounding_maps (object *op) |
901 | prefetch_surrounding_maps (object *op) |
909 | { |
902 | { |
910 | prefetch_surrounding_maps (op->map, 3); |
903 | prefetch_surrounding_area (op, op->map, 40); |
|
|
904 | |
|
|
905 | if (maptile *m = op->map->tile_available (TILE_DOWN)) |
|
|
906 | prefetch_surrounding_area (op, m, 20); |
|
|
907 | |
|
|
908 | if (maptile *m = op->map->tile_available (TILE_UP)) |
|
|
909 | prefetch_surrounding_area (op, m, 20); |
911 | } |
910 | } |
912 | |
911 | |
913 | //+GPL |
912 | //+GPL |
914 | |
913 | |
915 | /** |
914 | /** |
… | |
… | |
965 | * look like. |
964 | * look like. |
966 | */ |
965 | */ |
967 | |
966 | |
968 | client &socket = *pl->ns; |
967 | client &socket = *pl->ns; |
969 | |
968 | |
970 | packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); |
969 | packet sl ("map1a"); |
971 | |
970 | |
972 | startlen = sl.length (); |
971 | startlen = sl.length (); |
973 | |
972 | |
974 | int hx = socket.mapx / 2; |
973 | int hx = socket.mapx / 2; |
975 | int hy = socket.mapy / 2; |
974 | int hy = socket.mapy / 2; |
… | |
… | |
1358 | } |
1357 | } |
1359 | else |
1358 | else |
1360 | append_spell (pl, sl, spell); |
1359 | append_spell (pl, sl, spell); |
1361 | |
1360 | |
1362 | if (sl.length () > MAXSOCKBUF) |
1361 | if (sl.length () > MAXSOCKBUF) |
1363 | { |
|
|
1364 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
1362 | cleanup ("buffer overflow in esrv_add_spells!"); |
1365 | fatal (0); |
|
|
1366 | } |
|
|
1367 | |
1363 | |
1368 | /* finally, we can send the packet */ |
1364 | /* finally, we can send the packet */ |
1369 | pl->ns->flush_fx (); |
1365 | pl->ns->flush_fx (); |
1370 | pl->ns->send_packet (sl); |
1366 | pl->ns->send_packet (sl); |
1371 | } |
1367 | } |