… | |
… | |
138 | } |
138 | } |
139 | |
139 | |
140 | static void |
140 | static void |
141 | clear_map (player *pl) |
141 | clear_map (player *pl) |
142 | { |
142 | { |
143 | client &socket = *pl->socket; |
|
|
144 | |
|
|
145 | memset (&socket.lastmap, 0, sizeof (socket.lastmap)); |
143 | memset (&pl->socket->lastmap, 0, sizeof (pl->socket->lastmap)); |
146 | |
144 | |
147 | if (socket.newmapcmd == 1) |
145 | if (pl->socket->newmapcmd == 1) |
148 | socket.send_packet ("newmap"); |
146 | pl->socket->send_packet ("newmap"); |
149 | |
147 | |
150 | socket.update_look = 1; |
148 | pl->socket->floorbox_reset (); |
151 | socket.look_position = 0; |
|
|
152 | } |
149 | } |
153 | |
150 | |
154 | /** check for map change and send new map data */ |
151 | /** check for map change and send new map data */ |
155 | static void |
152 | static void |
156 | check_map_change (player *pl) |
153 | check_map_change (player *pl) |
… | |
… | |
197 | if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8)) |
194 | if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8)) |
198 | clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows |
195 | clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows |
199 | else |
196 | else |
200 | { |
197 | { |
201 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
198 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
202 | socket.update_look = 1; |
199 | socket.floorbox_reset (); |
203 | socket.look_position = 0; |
|
|
204 | } |
200 | } |
205 | } |
201 | } |
206 | |
202 | |
207 | socket.current_x = ob->x; |
203 | socket.current_x = ob->x; |
208 | socket.current_y = ob->y; |
204 | socket.current_y = ob->y; |
… | |
… | |
254 | |
250 | |
255 | void |
251 | void |
256 | ExtCmd (char *buf, int len, player *pl) |
252 | ExtCmd (char *buf, int len, player *pl) |
257 | { |
253 | { |
258 | INVOKE_PLAYER (EXTCMD, pl, ARG_DATA (buf, len)); |
254 | INVOKE_PLAYER (EXTCMD, pl, ARG_DATA (buf, len)); |
|
|
255 | } |
|
|
256 | |
|
|
257 | void |
|
|
258 | ExtiCmd (char *buf, int len, client *ns) |
|
|
259 | { |
|
|
260 | INVOKE_CLIENT (EXTICMD, ns, ARG_DATA (buf, len)); |
259 | } |
261 | } |
260 | |
262 | |
261 | void |
263 | void |
262 | MapInfoCmd (char *buf, int len, player *pl) |
264 | MapInfoCmd (char *buf, int len, player *pl) |
263 | { |
265 | { |
… | |
… | |
717 | if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) |
719 | if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) |
718 | esrv_send_face (ns, smoothface, 0); |
720 | esrv_send_face (ns, smoothface, 0); |
719 | |
721 | |
720 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
722 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
721 | |
723 | |
722 | packet sl; |
724 | packet sl ("smooth"); |
723 | |
725 | |
724 | sl << "smooth " |
|
|
725 | << uint16 (face) |
726 | sl << uint16 (face) |
726 | << uint16 (smoothface); |
727 | << uint16 (smoothface); |
727 | |
728 | |
728 | ns->send_packet (sl); |
729 | ns->send_packet (sl); |
729 | } |
730 | } |
730 | |
731 | |
… | |
… | |
807 | int time = FABS (pl->ob->speed) < 0.001 |
808 | int time = FABS (pl->ob->speed) < 0.001 |
808 | ? time = MAX_TIME * 100 |
809 | ? time = MAX_TIME * 100 |
809 | : time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
810 | : time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
810 | |
811 | |
811 | /* Send confirmation of command execution now */ |
812 | /* Send confirmation of command execution now */ |
812 | packet sl; |
813 | packet sl ("comc"); |
813 | sl << "comc " << uint16 (cmdid) << uint32 (time); |
814 | sl << uint16 (cmdid) << uint32 (time); |
814 | pl->socket->send_packet (sl); |
815 | pl->socket->send_packet (sl); |
815 | } |
816 | } |
816 | |
817 | |
817 | |
818 | |
818 | /** This is a reply to a previous query. */ |
819 | /** This is a reply to a previous query. */ |
… | |
… | |
1031 | esrv_update_stats (player *pl) |
1032 | esrv_update_stats (player *pl) |
1032 | { |
1033 | { |
1033 | char buf[MAX_BUF]; |
1034 | char buf[MAX_BUF]; |
1034 | uint16 flags; |
1035 | uint16 flags; |
1035 | |
1036 | |
1036 | packet sl; |
1037 | packet sl ("stats"); |
1037 | sl << "stats "; |
|
|
1038 | |
1038 | |
1039 | if (pl->ob) |
1039 | if (pl->ob) |
1040 | { |
1040 | { |
1041 | AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP); |
1041 | AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP); |
1042 | AddIfShort (pl->last_stats.maxhp, pl->ob->stats.maxhp, CS_STAT_MAXHP); |
1042 | AddIfShort (pl->last_stats.maxhp, pl->ob->stats.maxhp, CS_STAT_MAXHP); |
… | |
… | |
1125 | void |
1125 | void |
1126 | esrv_new_player (player *pl, uint32 weight) |
1126 | esrv_new_player (player *pl, uint32 weight) |
1127 | { |
1127 | { |
1128 | pl->last_weight = weight; |
1128 | pl->last_weight = weight; |
1129 | |
1129 | |
1130 | packet sl; |
1130 | packet sl ("player"); |
1131 | sl << "player "; |
|
|
1132 | |
1131 | |
1133 | sl << uint32 (pl->ob->count) |
1132 | sl << uint32 (pl->ob->count) |
1134 | << uint32 (weight) |
1133 | << uint32 (weight) |
1135 | << uint32 (pl->ob->face->number) |
1134 | << uint32 (pl->ob->face->number) |
1136 | << data8 (pl->ob->name); |
1135 | << data8 (pl->ob->name); |
… | |
… | |
1157 | { |
1156 | { |
1158 | LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); |
1157 | LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); |
1159 | return; |
1158 | return; |
1160 | } |
1159 | } |
1161 | |
1160 | |
1162 | packet sl; |
1161 | packet sl ("anim"); |
1163 | |
1162 | |
1164 | sl << "anim " |
|
|
1165 | << uint16 (anim_num) |
1163 | sl << uint16 (anim_num) |
1166 | << uint16 (0); /* flags - not used right now */ |
1164 | << uint16 (0); /* flags - not used right now */ |
1167 | |
1165 | |
1168 | /* Build up the list of faces. Also, send any information (ie, the |
1166 | /* Build up the list of faces. Also, send any information (ie, the |
1169 | * the face itself) down to the client. |
1167 | * the face itself) down to the client. |
1170 | */ |
1168 | */ |
… | |
… | |
1616 | |
1614 | |
1617 | client &socket = *pl->contr->socket; |
1615 | client &socket = *pl->contr->socket; |
1618 | |
1616 | |
1619 | check_map_change (pl->contr); |
1617 | check_map_change (pl->contr); |
1620 | |
1618 | |
1621 | packet sl; |
1619 | packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a"); |
1622 | packet esl; |
1620 | packet esl; |
1623 | |
1621 | |
1624 | sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a "); |
|
|
1625 | startlen = sl.length (); |
1622 | startlen = sl.length (); |
1626 | |
1623 | |
1627 | /*Extendedmapinfo structure initialisation */ |
1624 | /*Extendedmapinfo structure initialisation */ |
1628 | if (socket.ext_mapinfos) |
1625 | if (socket.ext_mapinfos) |
1629 | { |
1626 | { |
… | |
… | |
1673 | for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) |
1670 | for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) |
1674 | { |
1671 | { |
1675 | ax = 0; |
1672 | ax = 0; |
1676 | for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) |
1673 | for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) |
1677 | { |
1674 | { |
1678 | |
|
|
1679 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1675 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1680 | |
1676 | |
1681 | /* If this space is out of the normal viewable area, we only check |
1677 | /* If this space is out of the normal viewable area, we only check |
1682 | * the heads value ax or ay will only be greater than what |
1678 | * the heads value ax or ay will only be greater than what |
1683 | * the client wants if using the map1a command - this is because |
1679 | * the client wants if using the map1a command - this is because |
… | |
… | |
2014 | return; |
2010 | return; |
2015 | |
2011 | |
2016 | memset (&newmap, 0, sizeof (struct Map)); |
2012 | memset (&newmap, 0, sizeof (struct Map)); |
2017 | |
2013 | |
2018 | for (j = (pl->y - pl->contr->socket->mapy / 2); j < (pl->y + (pl->contr->socket->mapy + 1) / 2); j++) |
2014 | for (j = (pl->y - pl->contr->socket->mapy / 2); j < (pl->y + (pl->contr->socket->mapy + 1) / 2); j++) |
2019 | { |
|
|
2020 | for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++) |
2015 | for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++) |
2021 | { |
2016 | { |
2022 | ax = i; |
2017 | ax = i; |
2023 | ay = j; |
2018 | ay = j; |
2024 | m = pm; |
2019 | m = pm; |
2025 | mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); |
2020 | mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); |
2026 | |
2021 | |
2027 | if (mflags & P_OUT_OF_MAP) |
2022 | if (mflags & P_OUT_OF_MAP) |
2028 | continue; |
2023 | continue; |
2029 | |
2024 | |
2030 | if (mflags & P_NEED_UPDATE) |
|
|
2031 | update_position (m, ax, ay); |
|
|
2032 | |
|
|
2033 | /* If a map is visible to the player, we don't want to swap it out |
2025 | /* If a map is visible to the player, we don't want to swap it out |
2034 | * just to reload it. This should really call something like |
2026 | * just to reload it. This should really call something like |
2035 | * swap_map, but this is much more efficient and 'good enough' |
2027 | * swap_map, but this is much more efficient and 'good enough' |
2036 | */ |
2028 | */ |
2037 | if (mflags & P_NEW_MAP) |
2029 | if (mflags & P_NEW_MAP) |
2038 | m->timeout = 50; |
2030 | m->timeout = 50; |
2039 | } |
2031 | } |
2040 | } |
2032 | |
2041 | /* do LOS after calls to update_position */ |
2033 | /* do LOS after calls to update_position */ |
2042 | if (pl->contr->do_los) |
2034 | if (pl->contr->do_los) |
2043 | { |
2035 | { |
2044 | update_los (pl); |
2036 | update_los (pl); |
2045 | pl->contr->do_los = 0; |
2037 | pl->contr->do_los = 0; |
… | |
… | |
2173 | { |
2165 | { |
2174 | LOG (llevError, "Invalid call to esrv_remove_spell"); |
2166 | LOG (llevError, "Invalid call to esrv_remove_spell"); |
2175 | return; |
2167 | return; |
2176 | } |
2168 | } |
2177 | |
2169 | |
2178 | packet sl; |
2170 | packet sl ("delspell"); |
2179 | |
2171 | |
2180 | sl << "delspell " |
|
|
2181 | << uint32 (spell->count); |
2172 | sl << uint32 (spell->count); |
2182 | |
2173 | |
2183 | pl->socket->send_packet (sl); |
2174 | pl->socket->send_packet (sl); |
2184 | } |
2175 | } |
2185 | |
2176 | |
2186 | /* appends the spell *spell to the Socklist we will send the data to. */ |
2177 | /* appends the spell *spell to the Socklist we will send the data to. */ |
… | |
… | |
2239 | } |
2230 | } |
2240 | |
2231 | |
2241 | if (!pl->socket->monitor_spells) |
2232 | if (!pl->socket->monitor_spells) |
2242 | return; |
2233 | return; |
2243 | |
2234 | |
2244 | packet sl; |
2235 | packet sl ("addspell"); |
2245 | sl << "addspell "; |
|
|
2246 | |
2236 | |
2247 | if (!spell) |
2237 | if (!spell) |
2248 | { |
2238 | { |
2249 | for (spell = pl->ob->inv; spell != NULL; spell = spell->below) |
2239 | for (spell = pl->ob->inv; spell != NULL; spell = spell->below) |
2250 | { |
2240 | { |