--- deliantra/server/socket/request.C 2006/12/15 03:53:44 1.39 +++ deliantra/server/socket/request.C 2006/12/16 03:08:26 1.42 @@ -48,8 +48,6 @@ #include #include -#include -#include #include #include @@ -90,17 +88,12 @@ }; static void -socket_map_scroll (client_socket * ns, int dx, int dy) +socket_map_scroll (client * ns, int dx, int dy) { struct Map newmap; int x, y, mx, my; - { - packet sl; - - sl.printf ("map_scroll %d %d", dx, dy); - ns->send_packet (sl); - } + ns->send_packet_printf ("map_scroll %d %d", dx, dy); /* If we are using the Map1aCmd, we may in fact send * head information that is outside the viewable map. @@ -150,7 +143,7 @@ static void clear_map (player *pl) { - client_socket &socket = *pl->socket; + client &socket = *pl->socket; memset (&socket.lastmap, 0, sizeof (socket.lastmap)); @@ -165,7 +158,7 @@ static void check_map_change (player *pl) { - client_socket &socket = *pl->socket; + client &socket = *pl->socket; object *ob = pl->ob; char buf[MAX_BUF]; /* eauugggh */ @@ -218,6 +211,50 @@ socket.current_y = ob->y; } +/** + * RequestInfo is sort of a meta command. There is some specific + * request of information, but we call other functions to provide + * that information. + */ +void +RequestInfo (char *buf, int len, client * ns) +{ + char *params = NULL, *cp; + + /* No match */ + char bigbuf[MAX_BUF]; + int slen; + + /* Set up replyinfo before we modify any of the buffers - this is used + * if we don't find a match. + */ + strcpy (bigbuf, "replyinfo "); + slen = strlen (bigbuf); + safe_strcat (bigbuf, buf, &slen, MAX_BUF); + + /* find the first space, make it null, and update the + * params pointer. + */ + for (cp = buf; *cp != '\0'; cp++) + if (*cp == ' ') + { + *cp = '\0'; + params = cp + 1; + break; + } + + if (!strcmp (buf, "image_info")) + send_image_info (ns, params); + else if (!strcmp (buf, "image_sums")) + send_image_sums (ns, params); + else if (!strcmp (buf, "skill_info")) + send_skill_info (ns, params); + else if (!strcmp (buf, "spell_paths")) + send_spell_paths (ns, params); + else + ns->send_packet (bigbuf, len); +} + void ExtCmd (char *buf, int len, player *pl) { @@ -313,7 +350,7 @@ /** This is the Setup cmd - easy first implementation */ void -SetUp (char *buf, int len, client_socket * ns) +SetUp (char *buf, int len, client * ns) { int s, slen; char *cmd, *param, cmdback[HUGE_BUF]; @@ -533,7 +570,7 @@ * it either has to be here or init_sockets needs to be exported. */ void -AddMeCmd (char *buf, int len, client_socket * ns) +AddMeCmd (char *buf, int len, client * ns) { Settings oldsettings; @@ -548,7 +585,7 @@ /** Reply to ExtendedInfos command */ void -ToggleExtendedInfos (char *buf, int len, client_socket * ns) +ToggleExtendedInfos (char *buf, int len, client * ns) { char cmdback[MAX_BUF]; char command[50]; @@ -609,7 +646,7 @@ /** Reply to ExtendedInfos command */ void -ToggleExtendedText (char *buf, int len, client_socket * ns) +ToggleExtendedText (char *buf, int len, client * ns) { char cmdback[MAX_BUF]; char temp[10]; @@ -670,7 +707,7 @@ * client. */ static void -SendSmooth (client_socket * ns, uint16 face) +SendSmooth (client * ns, uint16 face) { uint16 smoothface; @@ -704,7 +741,7 @@ * to smooth a picture number given as argument. */ void -AskSmooth (char *buf, int len, client_socket * ns) +AskSmooth (char *buf, int len, client * ns) { uint16 facenbr; @@ -895,7 +932,7 @@ * problem. */ void -VersionCmd (char *buf, int len, client_socket * ns) +VersionCmd (char *buf, int len, client * ns) { char *cp; char version_warning[256]; @@ -929,17 +966,8 @@ { LOG (llevDebug, "CS: connection from client of type <%s>, ip %s\n", cp, ns->host); - snprintf (ns->client, sizeof (ns->client), "%s", cp + 1); - - /* This is first implementation - i skip all beta DX clients with it - * Add later stuff here for other clients - */ + assign (ns->version, cp + 1); - /* these are old dxclients */ - /* Version 1024 added support for singular + plural name values - - * requiing this minimal value reduces complexity of that code, and it - * has been around for a long time. - */ if (ns->sc_version < 1026) { sprintf (version_warning, "drawinfo %d %s", NDI_RED, @@ -951,9 +979,8 @@ } /** sound related functions. */ - void -SetSound (char *buf, int len, client_socket * ns) +SetSound (char *buf, int len, client * ns) { ns->sound = atoi (buf); } @@ -1021,7 +1048,7 @@ * it needs to send something back (vs just printing out a message) */ void -send_query (client_socket * ns, uint8 flags, char *text) +send_query (client * ns, uint8 flags, char *text) { char buf[MAX_BUF]; @@ -1190,7 +1217,7 @@ * when the player logs in and picks stuff up. */ void -esrv_send_animation (client_socket * ns, short anim_num) +esrv_send_animation (client * ns, short anim_num) { int i; @@ -1237,7 +1264,7 @@ * the face yet, we will also send it. */ static void -esrv_map_setbelow (client_socket * ns, int x, int y, short face_num, struct Map *newmap) +esrv_map_setbelow (client * ns, int x, int y, short face_num, struct Map *newmap) { if (newmap->cells[x][y].count >= MAP_LAYERS) { @@ -1267,7 +1294,7 @@ /** Checkes if map cells have changed */ static int -mapcellchanged (client_socket * ns, int i, int j, struct Map *newmap) +mapcellchanged (client * ns, int i, int j, struct Map *newmap) { int k; @@ -1290,7 +1317,7 @@ * how many layers of data we should back. */ static uint8 * -compactlayer (client_socket * ns, unsigned char *cur, int numlayers, struct Map *newmap) +compactlayer (client * ns, unsigned char *cur, int numlayers, struct Map *newmap) { int x, y, k; int face; @@ -1408,7 +1435,7 @@ * sent, it returns zero. */ static int -check_head (packet &sl, client_socket &ns, int ax, int ay, int layer) +check_head (packet &sl, client &ns, int ax, int ay, int layer) { short face_num; @@ -1452,7 +1479,7 @@ */ static int -update_space (packet &sl, client_socket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) +update_space (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) { object *ob, *head; uint16 face_num; @@ -1675,7 +1702,7 @@ */ static inline int -update_smooth (packet &sl, client_socket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) +update_smooth (packet &sl, client &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) { object *ob; int smoothlevel; /* old face_num; */ @@ -1719,7 +1746,7 @@ * available. */ int -getExtendedMapInfoSize (client_socket * ns) +getExtendedMapInfoSize (client * ns) { int result = 0; @@ -1765,7 +1792,7 @@ uint8 extendedinfos; maptile *m; - client_socket &socket = *pl->contr->socket; + client &socket = *pl->contr->socket; check_map_change (pl->contr); @@ -2218,7 +2245,7 @@ * the params - we always send the same info no matter what. */ void -send_skill_info (client_socket *ns, char *params) +send_skill_info (client *ns, char *params) { packet sl; sl << "replyinfo skill_info\n"; @@ -2240,7 +2267,7 @@ * the params - we always send the same info no matter what. */ void -send_spell_paths (client_socket * ns, char *params) +send_spell_paths (client * ns, char *params) { packet sl;