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.46 by root, Tue Dec 19 05:12:52 2006 UTC vs.
Revision 1.49 by root, Thu Dec 21 06:12:37 2006 UTC

569 * 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.
570 */ 570 */
571void 571void
572AddMeCmd (char *buf, int len, client * ns) 572AddMeCmd (char *buf, int len, client * ns)
573{ 573{
574 if (INVOKE_CLIENT (ADDME, ns))
575 return;
576
574 if (ns->status != Ns_Add || add_player (ns)) 577 if (ns->pl || add_player (ns))
575 ns->send_packet ("addme_failed"); 578 ns->send_packet ("addme_failed");
576 else 579 else
577 ns->send_packet ("addme_success"); 580 ns->send_packet ("addme_success");
578} 581}
579 582
719 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) 722 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE))
720 esrv_send_face (ns, smoothface, 0); 723 esrv_send_face (ns, smoothface, 0);
721 724
722 ns->faces_sent[face] |= NS_FACESENT_SMOOTH; 725 ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
723 726
724 packet sl; 727 packet sl ("smooth");
725 728
726 sl << "smooth "
727 << uint16 (face) 729 sl << uint16 (face)
728 << uint16 (smoothface); 730 << uint16 (smoothface);
729 731
730 ns->send_packet (sl); 732 ns->send_packet (sl);
731} 733}
732 734
809 int time = FABS (pl->ob->speed) < 0.001 811 int time = FABS (pl->ob->speed) < 0.001
810 ? time = MAX_TIME * 100 812 ? time = MAX_TIME * 100
811 : time = (int) (MAX_TIME / FABS (pl->ob->speed)); 813 : time = (int) (MAX_TIME / FABS (pl->ob->speed));
812 814
813 /* Send confirmation of command execution now */ 815 /* Send confirmation of command execution now */
814 packet sl; 816 packet sl ("comc");
815 sl << "comc " << uint16 (cmdid) << uint32 (time); 817 sl << uint16 (cmdid) << uint32 (time);
816 pl->socket->send_packet (sl); 818 pl->socket->send_packet (sl);
817} 819}
818 820
819
820/** This is a reply to a previous query. */ 821/** This is a reply to a previous query. */
821void 822void
822ReplyCmd (char *buf, int len, player *pl) 823ReplyCmd (char *buf, int len, client *ns)
823{ 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
824 /* 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
825 * 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
826 * once all the X11 code is removed from the server. 833 * once all the X11 code is removed from the server.
827 * 834 *
828 * 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
849 case ST_ROLL_STAT: 856 case ST_ROLL_STAT:
850 key_roll_stat (pl->ob, buf[0]); 857 key_roll_stat (pl->ob, buf[0]);
851 break; 858 break;
852 859
853 case ST_CHANGE_CLASS: 860 case ST_CHANGE_CLASS:
854
855 key_change_class (pl->ob, buf[0]); 861 key_change_class (pl->ob, buf[0]);
856 break; 862 break;
857 863
858 case ST_CONFIRM_QUIT: 864 case ST_CONFIRM_QUIT:
859 key_confirm_quit (pl->ob, buf[0]); 865 key_confirm_quit (pl->ob, buf[0]);
1033esrv_update_stats (player *pl) 1039esrv_update_stats (player *pl)
1034{ 1040{
1035 char buf[MAX_BUF]; 1041 char buf[MAX_BUF];
1036 uint16 flags; 1042 uint16 flags;
1037 1043
1038 packet sl; 1044 packet sl ("stats");
1039 sl << "stats ";
1040 1045
1041 if (pl->ob) 1046 if (pl->ob)
1042 { 1047 {
1043 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);
1044 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);
1127void 1132void
1128esrv_new_player (player *pl, uint32 weight) 1133esrv_new_player (player *pl, uint32 weight)
1129{ 1134{
1130 pl->last_weight = weight; 1135 pl->last_weight = weight;
1131 1136
1132 packet sl; 1137 packet sl ("player");
1133 sl << "player ";
1134 1138
1135 sl << uint32 (pl->ob->count) 1139 sl << uint32 (pl->ob->count)
1136 << uint32 (weight) 1140 << uint32 (weight)
1137 << uint32 (pl->ob->face->number) 1141 << uint32 (pl->ob->face->number)
1138 << data8 (pl->ob->name); 1142 << data8 (pl->ob->name);
1159 { 1163 {
1160 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);
1161 return; 1165 return;
1162 } 1166 }
1163 1167
1164 packet sl; 1168 packet sl ("anim");
1165 1169
1166 sl << "anim "
1167 << uint16 (anim_num) 1170 sl << uint16 (anim_num)
1168 << uint16 (0); /* flags - not used right now */ 1171 << uint16 (0); /* flags - not used right now */
1169 1172
1170 /* 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
1171 * the face itself) down to the client. 1174 * the face itself) down to the client.
1172 */ 1175 */
1618 1621
1619 client &socket = *pl->contr->socket; 1622 client &socket = *pl->contr->socket;
1620 1623
1621 check_map_change (pl->contr); 1624 check_map_change (pl->contr);
1622 1625
1623 packet sl; 1626 packet sl (socket.mapmode == Map1Cmd ? "map1" : "map1a");
1624 packet esl; 1627 packet esl;
1625 1628
1626 sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a ");
1627 startlen = sl.length (); 1629 startlen = sl.length ();
1628 1630
1629 /*Extendedmapinfo structure initialisation */ 1631 /*Extendedmapinfo structure initialisation */
1630 if (socket.ext_mapinfos) 1632 if (socket.ext_mapinfos)
1631 { 1633 {
1675 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++)
1676 { 1678 {
1677 ax = 0; 1679 ax = 0;
1678 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++)
1679 { 1681 {
1680
1681 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1682 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1682 1683
1683 /* 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
1684 * 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
1685 * the client wants if using the map1a command - this is because 1686 * the client wants if using the map1a command - this is because
2016 return; 2017 return;
2017 2018
2018 memset (&newmap, 0, sizeof (struct Map)); 2019 memset (&newmap, 0, sizeof (struct Map));
2019 2020
2020 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++)
2021 {
2022 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++)
2023 { 2023 {
2024 ax = i; 2024 ax = i;
2025 ay = j; 2025 ay = j;
2026 m = pm; 2026 m = pm;
2027 mflags = get_map_flags (m, &m, ax, ay, &ax, &ay); 2027 mflags = get_map_flags (m, &m, ax, ay, &ax, &ay);
2028 2028
2029 if (mflags & P_OUT_OF_MAP) 2029 if (mflags & P_OUT_OF_MAP)
2030 continue; 2030 continue;
2031 2031
2032 if (mflags & P_NEED_UPDATE)
2033 update_position (m, ax, ay);
2034
2035 /* 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
2036 * just to reload it. This should really call something like 2033 * just to reload it. This should really call something like
2037 * swap_map, but this is much more efficient and 'good enough' 2034 * swap_map, but this is much more efficient and 'good enough'
2038 */ 2035 */
2039 if (mflags & P_NEW_MAP) 2036 if (mflags & P_NEW_MAP)
2040 m->timeout = 50; 2037 m->timeout = 50;
2041 } 2038 }
2042 } 2039
2043 /* do LOS after calls to update_position */ 2040 /* do LOS after calls to update_position */
2044 if (pl->contr->do_los) 2041 if (pl->contr->do_los)
2045 { 2042 {
2046 update_los (pl); 2043 update_los (pl);
2047 pl->contr->do_los = 0; 2044 pl->contr->do_los = 0;
2175 { 2172 {
2176 LOG (llevError, "Invalid call to esrv_remove_spell"); 2173 LOG (llevError, "Invalid call to esrv_remove_spell");
2177 return; 2174 return;
2178 } 2175 }
2179 2176
2180 packet sl; 2177 packet sl ("delspell");
2181 2178
2182 sl << "delspell "
2183 << uint32 (spell->count); 2179 sl << uint32 (spell->count);
2184 2180
2185 pl->socket->send_packet (sl); 2181 pl->socket->send_packet (sl);
2186} 2182}
2187 2183
2188/* 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. */
2241 } 2237 }
2242 2238
2243 if (!pl->socket->monitor_spells) 2239 if (!pl->socket->monitor_spells)
2244 return; 2240 return;
2245 2241
2246 packet sl; 2242 packet sl ("addspell");
2247 sl << "addspell ";
2248 2243
2249 if (!spell) 2244 if (!spell)
2250 { 2245 {
2251 for (spell = pl->ob->inv; spell != NULL; spell = spell->below) 2246 for (spell = pl->ob->inv; spell != NULL; spell = spell->below)
2252 { 2247 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines