… | |
… | |
65 | * This table translates the attack numbers as used within the |
65 | * This table translates the attack numbers as used within the |
66 | * program to the value we use when sending STATS command to the |
66 | * program to the value we use when sending STATS command to the |
67 | * client. If a value is -1, then we don't send that to the |
67 | * client. If a value is -1, then we don't send that to the |
68 | * client. |
68 | * client. |
69 | */ |
69 | */ |
70 | static short atnr_cs_stat[NROFATTACKS] = { CS_STAT_RES_PHYS, |
70 | static short atnr_cs_stat[NROFATTACKS] = |
71 | CS_STAT_RES_MAG, CS_STAT_RES_FIRE, CS_STAT_RES_ELEC, |
71 | { |
72 | CS_STAT_RES_COLD, CS_STAT_RES_CONF, CS_STAT_RES_ACID, |
72 | CS_STAT_RES_PHYS, |
73 | CS_STAT_RES_DRAIN, -1 /* weaponmagic */ , |
73 | CS_STAT_RES_MAG, |
74 | CS_STAT_RES_GHOSTHIT, CS_STAT_RES_POISON, |
74 | CS_STAT_RES_FIRE, |
75 | CS_STAT_RES_SLOW, CS_STAT_RES_PARA, CS_STAT_TURN_UNDEAD, |
75 | CS_STAT_RES_ELEC, |
76 | CS_STAT_RES_FEAR, -1 /* Cancellation */ , |
76 | CS_STAT_RES_COLD, |
77 | CS_STAT_RES_DEPLETE, CS_STAT_RES_DEATH, |
77 | CS_STAT_RES_CONF, |
78 | -1 /* Chaos */ , -1 /* Counterspell */ , |
78 | CS_STAT_RES_ACID, |
79 | -1 /* Godpower */ , CS_STAT_RES_HOLYWORD, |
79 | CS_STAT_RES_DRAIN, |
|
|
80 | -1 /* weaponmagic */, |
|
|
81 | CS_STAT_RES_GHOSTHIT, |
|
|
82 | CS_STAT_RES_POISON, |
|
|
83 | CS_STAT_RES_SLOW, |
|
|
84 | CS_STAT_RES_PARA, |
|
|
85 | CS_STAT_TURN_UNDEAD, |
|
|
86 | CS_STAT_RES_FEAR, |
|
|
87 | -1 /* Cancellation */, |
|
|
88 | CS_STAT_RES_DEPLETE, |
|
|
89 | CS_STAT_RES_DEATH, |
|
|
90 | -1 /* Chaos */, |
|
|
91 | -1 /* Counterspell */, |
|
|
92 | -1 /* Godpower */, |
|
|
93 | CS_STAT_RES_HOLYWORD, |
80 | CS_STAT_RES_BLIND, |
94 | CS_STAT_RES_BLIND, |
81 | -1, /* Internal */ |
95 | -1, /* Internal */ |
82 | -1, /* life stealing */ |
96 | -1, /* life stealing */ |
83 | -1 /* Disease - not fully done yet */ |
97 | -1 /* Disease - not fully done yet */ |
84 | }; |
98 | }; |
… | |
… | |
132 | pl->ns->mapinfo_queue_clear (); |
146 | pl->ns->mapinfo_queue_clear (); |
133 | |
147 | |
134 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
148 | memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); |
135 | |
149 | |
136 | pl->ns->force_newmap = false; |
150 | pl->ns->force_newmap = false; |
137 | |
|
|
138 | if (pl->ns->newmapcmd == 1) |
|
|
139 | pl->ns->send_packet ("newmap"); |
151 | pl->ns->send_packet ("newmap"); |
140 | |
|
|
141 | pl->ns->floorbox_reset (); |
152 | pl->ns->floorbox_reset (); |
142 | } |
153 | } |
143 | |
154 | |
144 | static void |
155 | static void |
145 | send_map_info (player *pl) |
156 | send_map_info (player *pl) |
… | |
… | |
228 | send_skill_info (client *ns, char *params) |
239 | send_skill_info (client *ns, char *params) |
229 | { |
240 | { |
230 | packet sl; |
241 | packet sl; |
231 | sl << "replyinfo skill_info\n"; |
242 | sl << "replyinfo skill_info\n"; |
232 | |
243 | |
233 | for (int i = 1; i < NUM_SKILLS; i++) |
244 | for (int i = 0; i < skillvec.size (); ++i) |
234 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); |
245 | sl.printf ("%d:%s\n", CS_STAT_SKILLINFO + i, &skillvec [i]->name); |
235 | |
246 | |
236 | if (sl.length () > MAXSOCKBUF) |
247 | if (sl.length () > MAXSOCKBUF) |
237 | { |
|
|
238 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
248 | cleanup ("buffer overflow in send_skill_info!"); |
239 | fatal (0); |
|
|
240 | } |
|
|
241 | |
249 | |
242 | ns->send_packet (sl); |
250 | ns->send_packet (sl); |
243 | } |
251 | } |
244 | |
252 | |
245 | /** |
253 | /** |
… | |
… | |
255 | |
263 | |
256 | for (int i = 0; i < NRSPELLPATHS; i++) |
264 | for (int i = 0; i < NRSPELLPATHS; i++) |
257 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
265 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
258 | |
266 | |
259 | if (sl.length () > MAXSOCKBUF) |
267 | if (sl.length () > MAXSOCKBUF) |
260 | { |
|
|
261 | LOG (llevError, "Buffer overflow in send_spell_paths!\n"); |
268 | cleanup ("buffer overflow in send_spell_paths!"); |
262 | fatal (0); |
|
|
263 | } |
|
|
264 | |
269 | |
265 | ns->send_packet (sl); |
270 | ns->send_packet (sl); |
266 | } |
271 | } |
267 | |
272 | |
268 | /** |
273 | /** |
… | |
… | |
697 | * commands for now. |
702 | * commands for now. |
698 | */ |
703 | */ |
699 | void |
704 | void |
700 | esrv_update_stats (player *pl) |
705 | esrv_update_stats (player *pl) |
701 | { |
706 | { |
702 | char buf[MAX_BUF]; |
|
|
703 | uint16 flags; |
|
|
704 | |
|
|
705 | client *ns = pl->ns; |
707 | client *ns = pl->ns; |
706 | if (!ns) |
708 | if (!ns) |
707 | return; |
709 | return; |
708 | |
710 | |
709 | object *ob = pl->observe; |
711 | object *ob = pl->observe; |
… | |
… | |
726 | AddIfShort (ns->last_stats.Int, ob->stats.Int, CS_STAT_INT); |
728 | AddIfShort (ns->last_stats.Int, ob->stats.Int, CS_STAT_INT); |
727 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
729 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
728 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
730 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
729 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
731 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
730 | |
732 | |
731 | for (int s = 0; s < NUM_SKILLS; s++) |
733 | for (int s = 0; s < CS_NUM_SKILLS; s++) |
732 | if (object *skill = opl->last_skill_ob [s]) |
734 | if (object *skill = opl->last_skill_ob [s]) |
733 | if (skill->stats.exp != ns->last_skill_exp [s]) |
735 | if (skill->stats.exp != ns->last_skill_exp [s]) |
734 | { |
736 | { |
735 | ns->last_skill_exp [s] = skill->stats.exp; |
737 | ns->last_skill_exp [s] = skill->stats.exp; |
736 | |
738 | |
737 | /* Always send along the level if exp changes. This is only |
739 | /* Always send along the level if exp changes. This is only |
738 | * 1 extra byte, but keeps processing simpler. |
740 | * 1 extra byte, but keeps processing simpler. |
739 | */ |
741 | */ |
740 | sl << uint8 (s + CS_STAT_SKILLINFO) |
742 | sl << uint8 (CS_STAT_SKILLINFO + s) |
741 | << uint8 (skill->level) |
743 | << uint8 (skill->level) |
742 | << uint64 (skill->stats.exp); |
744 | << uint64 (skill->stats.exp); |
743 | } |
745 | } |
744 | |
746 | |
745 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
747 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
… | |
… | |
750 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
752 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK); |
751 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
753 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
752 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
754 | AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK); |
753 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
755 | AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); |
754 | |
756 | |
755 | flags = 0; |
757 | int flags = (opl->fire_on ? SF_FIREON : 0) |
756 | |
758 | | (opl->run_on ? SF_RUNON : 0); |
757 | if (opl->fire_on) |
|
|
758 | flags |= SF_FIREON; |
|
|
759 | |
|
|
760 | if (opl->run_on) |
|
|
761 | flags |= SF_RUNON; |
|
|
762 | |
759 | |
763 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
760 | AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); |
764 | |
761 | |
765 | for (int i = 0; i < NROFATTACKS; i++) |
762 | for (int i = 0; i < NROFATTACKS; i++) |
766 | { |
|
|
767 | /* Skip ones we won't send */ |
763 | /* Skip ones we won't send */ |
768 | if (atnr_cs_stat[i] == -1) |
764 | if (atnr_cs_stat[i] >= 0) |
769 | continue; |
|
|
770 | |
|
|
771 | AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); |
765 | AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); |
772 | } |
|
|
773 | |
766 | |
774 | if (pl->ns->monitor_spells) |
767 | if (pl->ns->monitor_spells) |
775 | { |
768 | { |
776 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
769 | AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
777 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
770 | AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); |
778 | AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); |
771 | AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); |
779 | } |
772 | } |
780 | |
773 | |
|
|
774 | char buf[MAX_BUF]; |
781 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
775 | rangetostring (opl, buf); /* we want use the new fire & run system in new client */ |
782 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
776 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
783 | set_title (ob, buf); |
777 | set_title (ob, buf); |
784 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
778 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
785 | |
779 | |
… | |
… | |
881 | return 0; |
875 | return 0; |
882 | } |
876 | } |
883 | |
877 | |
884 | //-GPL |
878 | //-GPL |
885 | |
879 | |
886 | // prefetch (and touch) all maps within a specific distancd |
880 | // prefetch maps in an area of PREFETCH x PREFETCH around the player |
887 | static void |
881 | #define PREFETCH 40 |
888 | prefetch_surrounding_maps (maptile *map, int distance) |
|
|
889 | { |
|
|
890 | map->touch (); |
|
|
891 | |
|
|
892 | if (--distance) |
|
|
893 | for (int dir = 4; dir--; ) |
|
|
894 | if (const shstr &path = map->tile_path [dir]) |
|
|
895 | if (maptile *&neigh = map->tile_map [dir]) |
|
|
896 | prefetch_surrounding_maps (neigh, distance); |
|
|
897 | else |
|
|
898 | neigh = maptile::find_async (path, map); |
|
|
899 | } |
|
|
900 | |
882 | |
901 | // prefetch a generous area around the player |
883 | // prefetch a generous area around the player |
902 | static void |
884 | static void |
903 | prefetch_surrounding_maps (object *op) |
885 | prefetch_surrounding_maps (object *op) |
904 | { |
886 | { |
905 | 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 (); |
906 | } |
893 | } |
907 | |
894 | |
908 | //+GPL |
895 | //+GPL |
909 | |
896 | |
910 | /** |
897 | /** |
… | |
… | |
960 | * look like. |
947 | * look like. |
961 | */ |
948 | */ |
962 | |
949 | |
963 | client &socket = *pl->ns; |
950 | client &socket = *pl->ns; |
964 | |
951 | |
965 | packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); |
952 | packet sl ("map1a"); |
966 | |
953 | |
967 | startlen = sl.length (); |
954 | startlen = sl.length (); |
968 | |
955 | |
969 | int hx = socket.mapx / 2; |
956 | int hx = socket.mapx / 2; |
970 | int hy = socket.mapy / 2; |
957 | int hy = socket.mapy / 2; |
… | |
… | |
1269 | spell->cached_eat = casting_level (pl->ob, spell); |
1256 | spell->cached_eat = casting_level (pl->ob, spell); |
1270 | |
1257 | |
1271 | /* figure out which skill it uses, if it uses one */ |
1258 | /* figure out which skill it uses, if it uses one */ |
1272 | if (spell->skill) |
1259 | if (spell->skill) |
1273 | if (object *tmp = pl->find_skill (spell->skill)) |
1260 | if (object *tmp = pl->find_skill (spell->skill)) |
1274 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1261 | skill = CS_STAT_SKILLINFO + SKILL_INDEX (tmp); |
1275 | |
1262 | |
1276 | // spells better have a face |
1263 | // spells better have a face |
1277 | if (!spell->face) |
1264 | if (!spell->face) |
1278 | { |
1265 | { |
1279 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
1266 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
… | |
… | |
1353 | } |
1340 | } |
1354 | else |
1341 | else |
1355 | append_spell (pl, sl, spell); |
1342 | append_spell (pl, sl, spell); |
1356 | |
1343 | |
1357 | if (sl.length () > MAXSOCKBUF) |
1344 | if (sl.length () > MAXSOCKBUF) |
1358 | { |
|
|
1359 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
1345 | cleanup ("buffer overflow in esrv_add_spells!"); |
1360 | fatal (0); |
|
|
1361 | } |
|
|
1362 | |
1346 | |
1363 | /* finally, we can send the packet */ |
1347 | /* finally, we can send the packet */ |
1364 | pl->ns->flush_fx (); |
1348 | pl->ns->flush_fx (); |
1365 | pl->ns->send_packet (sl); |
1349 | pl->ns->send_packet (sl); |
1366 | } |
1350 | } |