ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.44 by root, Sat Dec 16 21:40:26 2006 UTC vs.
Revision 1.49 by root, Thu Dec 21 06:12:37 2006 UTC

138} 138}
139 139
140static void 140static void
141clear_map (player *pl) 141clear_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 */
155static void 152static void
156check_map_change (player *pl) 153check_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
255void 251void
256ExtCmd (char *buf, int len, player *pl) 252ExtCmd (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
257void
258ExtiCmd (char *buf, int len, client *ns)
259{
260 INVOKE_CLIENT (EXTICMD, ns, ARG_DATA (buf, len));
259} 261}
260 262
261void 263void
262MapInfoCmd (char *buf, int len, player *pl) 264MapInfoCmd (char *buf, int len, player *pl)
263{ 265{
567 * it either has to be here or init_sockets needs to be exported. 569 * it either has to be here or init_sockets needs to be exported.
568 */ 570 */
569void 571void
570AddMeCmd (char *buf, int len, client * ns) 572AddMeCmd (char *buf, int len, client * ns)
571{ 573{
574 if (INVOKE_CLIENT (ADDME, ns))
575 return;
576
572 if (ns->status != Ns_Add || add_player (ns)) 577 if (ns->pl || add_player (ns))
573 ns->send_packet ("addme_failed"); 578 ns->send_packet ("addme_failed");
574 else 579 else
575 ns->send_packet ("addme_success"); 580 ns->send_packet ("addme_success");
576} 581}
577 582
717 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) 722 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE))
718 esrv_send_face (ns, smoothface, 0); 723 esrv_send_face (ns, smoothface, 0);
719 724
720 ns->faces_sent[face] |= NS_FACESENT_SMOOTH; 725 ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
721 726
722 packet sl; 727 packet sl ("smooth");
723 728
724 sl << "smooth "
725 << uint16 (face) 729 sl << uint16 (face)
726 << uint16 (smoothface); 730 << uint16 (smoothface);
727 731
728 ns->send_packet (sl); 732 ns->send_packet (sl);
729} 733}
730 734
807 int time = FABS (pl->ob->speed) < 0.001 811 int time = FABS (pl->ob->speed) < 0.001
808 ? time = MAX_TIME * 100 812 ? time = MAX_TIME * 100
809 : time = (int) (MAX_TIME / FABS (pl->ob->speed)); 813 : time = (int) (MAX_TIME / FABS (pl->ob->speed));
810 814
811 /* Send confirmation of command execution now */ 815 /* Send confirmation of command execution now */
812 packet sl; 816 packet sl ("comc");
813 sl << "comc " << uint16 (cmdid) << uint32 (time); 817 sl << uint16 (cmdid) << uint32 (time);
814 pl->socket->send_packet (sl); 818 pl->socket->send_packet (sl);
815} 819}
816 820
817
818/** This is a reply to a previous query. */ 821/** This is a reply to a previous query. */
819void 822void
820ReplyCmd (char *buf, int len, player *pl) 823ReplyCmd (char *buf, int len, client *ns)
821{ 824{
825 if (!ns->pl)
826 return; //TODO: depends on the exact reply we are after
827 //TODO: but right now, we always have a ns->pl
828
829 player *pl = ns->pl;
830
822 /* This is to synthesize how the data would be stored if it 831 /* This is to synthesize how the data would be stored if it
823 * was normally entered. A bit of a hack, and should be cleaned up 832 * was normally entered. A bit of a hack, and should be cleaned up
824 * once all the X11 code is removed from the server. 833 * once all the X11 code is removed from the server.
825 * 834 *
826 * We pass 13 to many of the functions because this way they 835 * We pass 13 to many of the functions because this way they
847 case ST_ROLL_STAT: 856 case ST_ROLL_STAT:
848 key_roll_stat (pl->ob, buf[0]); 857 key_roll_stat (pl->ob, buf[0]);
849 break; 858 break;
850 859
851 case ST_CHANGE_CLASS: 860 case ST_CHANGE_CLASS:
852
853 key_change_class (pl->ob, buf[0]); 861 key_change_class (pl->ob, buf[0]);
854 break; 862 break;
855 863
856 case ST_CONFIRM_QUIT: 864 case ST_CONFIRM_QUIT:
857 key_confirm_quit (pl->ob, buf[0]); 865 key_confirm_quit (pl->ob, buf[0]);
1031esrv_update_stats (player *pl) 1039esrv_update_stats (player *pl)
1032{ 1040{
1033 char buf[MAX_BUF]; 1041 char buf[MAX_BUF];
1034 uint16 flags; 1042 uint16 flags;
1035 1043
1036 packet sl; 1044 packet sl ("stats");
1037 sl << "stats ";
1038 1045
1039 if (pl->ob) 1046 if (pl->ob)
1040 { 1047 {
1041 AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP); 1048 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); 1049 AddIfShort (pl->last_stats.maxhp, pl->ob->stats.maxhp, CS_STAT_MAXHP);
1125void 1132void
1126esrv_new_player (player *pl, uint32 weight) 1133esrv_new_player (player *pl, uint32 weight)
1127{ 1134{
1128 pl->last_weight = weight; 1135 pl->last_weight = weight;
1129 1136
1130 packet sl; 1137 packet sl ("player");
1131 sl << "player ";
1132 1138
1133 sl << uint32 (pl->ob->count) 1139 sl << uint32 (pl->ob->count)
1134 << uint32 (weight) 1140 << uint32 (weight)
1135 << uint32 (pl->ob->face->number) 1141 << uint32 (pl->ob->face->number)
1136 << data8 (pl->ob->name); 1142 << data8 (pl->ob->name);
1157 { 1163 {
1158 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); 1164 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
1159 return; 1165 return;
1160 } 1166 }
1161 1167
1162 packet sl; 1168 packet sl ("anim");
1163 1169
1164 sl << "anim "
1165 << uint16 (anim_num) 1170 sl << uint16 (anim_num)
1166 << uint16 (0); /* flags - not used right now */ 1171 << uint16 (0); /* flags - not used right now */
1167 1172
1168 /* Build up the list of faces. Also, send any information (ie, the 1173 /* Build up the list of faces. Also, send any information (ie, the
1169 * the face itself) down to the client. 1174 * the face itself) down to the client.
1170 */ 1175 */
1616 1621
1617 client &socket = *pl->contr->socket; 1622 client &socket = *pl->contr->socket;
1618 1623
1619 check_map_change (pl->contr); 1624 check_map_change (pl->contr);
1620 1625
1621 packet sl; 1626 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a");
1622 packet esl; 1627 packet esl;
1623 1628
1624 sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a ");
1625 startlen = sl.length (); 1629 startlen = sl.length ();
1626 1630
1627 /*Extendedmapinfo structure initialisation */ 1631 /*Extendedmapinfo structure initialisation */
1628 if (socket.ext_mapinfos) 1632 if (socket.ext_mapinfos)
1629 { 1633 {
1673 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++) 1677 for (y = pl->y - socket.mapy / 2; y < max_y; y++, ay++)
1674 { 1678 {
1675 ax = 0; 1679 ax = 0;
1676 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++) 1680 for (x = pl->x - socket.mapx / 2; x < max_x; x++, ax++)
1677 { 1681 {
1678
1679 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1682 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1680 1683
1681 /* If this space is out of the normal viewable area, we only check 1684 /* 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 1685 * the heads value ax or ay will only be greater than what
1683 * the client wants if using the map1a command - this is because 1686 * the client wants if using the map1a command - this is because
2014 return; 2017 return;
2015 2018
2016 memset (&newmap, 0, sizeof (struct Map)); 2019 memset (&newmap, 0, sizeof (struct Map));
2017 2020
2018 for (j = (pl->y - pl->contr->socket->mapy / 2); j < (pl->y + (pl->contr->socket->mapy + 1) / 2); j++) 2021 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++) 2022 for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++)
2021 { 2023 {
2022 ax = i; 2024 ax = i;
2023 ay = j; 2025 ay = j;
2024 m = pm; 2026 m = pm;
2025 mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); 2027 mflags = get_map_flags (m, &m, ax, ay, &ax, &ay);
2026 2028
2027 if (mflags & P_OUT_OF_MAP) 2029 if (mflags & P_OUT_OF_MAP)
2028 continue; 2030 continue;
2029 2031
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 2032 /* 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 2033 * just to reload it. This should really call something like
2035 * swap_map, but this is much more efficient and 'good enough' 2034 * swap_map, but this is much more efficient and 'good enough'
2036 */ 2035 */
2037 if (mflags & P_NEW_MAP) 2036 if (mflags & P_NEW_MAP)
2038 m->timeout = 50; 2037 m->timeout = 50;
2039 } 2038 }
2040 } 2039
2041 /* do LOS after calls to update_position */ 2040 /* do LOS after calls to update_position */
2042 if (pl->contr->do_los) 2041 if (pl->contr->do_los)
2043 { 2042 {
2044 update_los (pl); 2043 update_los (pl);
2045 pl->contr->do_los = 0; 2044 pl->contr->do_los = 0;
2173 { 2172 {
2174 LOG (llevError, "Invalid call to esrv_remove_spell"); 2173 LOG (llevError, "Invalid call to esrv_remove_spell");
2175 return; 2174 return;
2176 } 2175 }
2177 2176
2178 packet sl; 2177 packet sl ("delspell");
2179 2178
2180 sl << "delspell "
2181 << uint32 (spell->count); 2179 sl << uint32 (spell->count);
2182 2180
2183 pl->socket->send_packet (sl); 2181 pl->socket->send_packet (sl);
2184} 2182}
2185 2183
2186/* appends the spell *spell to the Socklist we will send the data to. */ 2184/* appends the spell *spell to the Socklist we will send the data to. */
2239 } 2237 }
2240 2238
2241 if (!pl->socket->monitor_spells) 2239 if (!pl->socket->monitor_spells)
2242 return; 2240 return;
2243 2241
2244 packet sl; 2242 packet sl ("addspell");
2245 sl << "addspell ";
2246 2243
2247 if (!spell) 2244 if (!spell)
2248 { 2245 {
2249 for (spell = pl->ob->inv; spell != NULL; spell = spell->below) 2246 for (spell = pl->ob->inv; spell != NULL; spell = spell->below)
2250 { 2247 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines