… | |
… | |
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 | /** |
… | |
… | |
711 | * commands for now. |
705 | * commands for now. |
712 | */ |
706 | */ |
713 | void |
707 | void |
714 | esrv_update_stats (player *pl) |
708 | esrv_update_stats (player *pl) |
715 | { |
709 | { |
716 | char buf[MAX_BUF]; |
|
|
717 | uint16 flags; |
|
|
718 | |
|
|
719 | client *ns = pl->ns; |
710 | client *ns = pl->ns; |
720 | if (!ns) |
711 | if (!ns) |
721 | return; |
712 | return; |
722 | |
713 | |
723 | object *ob = pl->observe; |
714 | object *ob = pl->observe; |
… | |
… | |
764 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
755 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
765 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
756 | 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); |
757 | 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); |
758 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
768 | |
759 | |
769 | flags = (opl->fire_on ? SF_FIREON : 0) |
760 | int flags = (opl->fire_on ? SF_FIREON : 0) |
770 | | (opl->run_on ? SF_RUNON : 0); |
761 | | (opl->run_on ? SF_RUNON : 0); |
771 | |
762 | |
772 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
763 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
773 | |
764 | |
774 | for (int i = 0; i < NROFATTACKS; i++) |
765 | for (int i = 0; i < NROFATTACKS; i++) |
775 | /* Skip ones we won't send */ |
766 | /* Skip ones we won't send */ |
… | |
… | |
781 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
772 | 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); |
773 | 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); |
774 | AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); |
784 | } |
775 | } |
785 | |
776 | |
|
|
777 | char buf[MAX_BUF]; |
786 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
778 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
787 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
779 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
788 | set_title (ob, buf); |
780 | set_title (ob, buf); |
789 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
781 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
790 | |
782 | |
… | |
… | |
886 | return 0; |
878 | return 0; |
887 | } |
879 | } |
888 | |
880 | |
889 | //-GPL |
881 | //-GPL |
890 | |
882 | |
891 | // prefetch (and touch) all maps within a specific distancd |
883 | // prefetch maps in an area of PREFETCH x PREFETCH around the player |
892 | static void |
884 | #define PREFETCH 40 |
893 | prefetch_surrounding_maps (maptile *map, int distance) |
|
|
894 | { |
|
|
895 | map->touch (); |
|
|
896 | |
|
|
897 | if (--distance) |
|
|
898 | for (int dir = 4; dir--; ) |
|
|
899 | if (const shstr &path = map->tile_path [dir]) |
|
|
900 | if (maptile *&neigh = map->tile_map [dir]) |
|
|
901 | prefetch_surrounding_maps (neigh, distance); |
|
|
902 | else |
|
|
903 | neigh = maptile::find_async (path, map); |
|
|
904 | } |
|
|
905 | |
885 | |
906 | // prefetch a generous area around the player |
886 | // prefetch a generous area around the player |
907 | static void |
887 | static void |
908 | prefetch_surrounding_maps (object *op) |
888 | prefetch_surrounding_maps (object *op) |
909 | { |
889 | { |
910 | prefetch_surrounding_maps (op->map, 3); |
890 | for (maprect *rect = op->map->split_to_tiles (mapwalk_buf, |
|
|
891 | op->x - PREFETCH , op->y - PREFETCH , |
|
|
892 | op->x + PREFETCH + 1, op->y + PREFETCH + 1); |
|
|
893 | rect->m; |
|
|
894 | ++rect) |
|
|
895 | rect->m->touch (); |
911 | } |
896 | } |
912 | |
897 | |
913 | //+GPL |
898 | //+GPL |
914 | |
899 | |
915 | /** |
900 | /** |
… | |
… | |
1358 | } |
1343 | } |
1359 | else |
1344 | else |
1360 | append_spell (pl, sl, spell); |
1345 | append_spell (pl, sl, spell); |
1361 | |
1346 | |
1362 | if (sl.length () > MAXSOCKBUF) |
1347 | if (sl.length () > MAXSOCKBUF) |
1363 | { |
|
|
1364 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
1348 | cleanup ("buffer overflow in esrv_add_spells!"); |
1365 | fatal (0); |
|
|
1366 | } |
|
|
1367 | |
1349 | |
1368 | /* finally, we can send the packet */ |
1350 | /* finally, we can send the packet */ |
1369 | pl->ns->flush_fx (); |
1351 | pl->ns->flush_fx (); |
1370 | pl->ns->send_packet (sl); |
1352 | pl->ns->send_packet (sl); |
1371 | } |
1353 | } |