--- deliantra/server/socket/request.C 2007/03/14 15:44:47 1.77 +++ deliantra/server/socket/request.C 2007/05/12 19:30:18 1.96 @@ -134,6 +134,8 @@ { memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); + pl->ns->force_newmap = false; + if (pl->ns->newmapcmd == 1) pl->ns->send_packet ("newmap"); @@ -148,11 +150,10 @@ object *ob = pl->ob; char buf[MAX_BUF]; /* eauugggh */ - if (socket.current_map != ob->map) + if (socket.current_map != ob->map || socket.force_newmap) { - socket.current_map = ob->map; - clear_map (pl); + socket.current_map = ob->map; if (socket.mapinfocmd) { @@ -160,14 +161,10 @@ { int flags = 0; - if (ob->map->tile_path[0]) - flags |= 1; - if (ob->map->tile_path[1]) - flags |= 2; - if (ob->map->tile_path[2]) - flags |= 4; - if (ob->map->tile_path[3]) - flags |= 8; + if (ob->map->tile_path[0]) flags |= 1; + if (ob->map->tile_path[1]) flags |= 2; + if (ob->map->tile_path[2]) flags |= 4; + if (ob->map->tile_path[3]) flags |= 8; snprintf (buf, MAX_BUF, "mapinfo - spatial %d %d %d %d %d %s", flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, ob->map->width, ob->map->height, &ob->map->path); @@ -326,14 +323,10 @@ { int flags = 0; - if (map->tile_path[0]) - flags |= 1; - if (map->tile_path[1]) - flags |= 2; - if (map->tile_path[2]) - flags |= 4; - if (map->tile_path[3]) - flags |= 8; + if (map->tile_path[0]) flags |= 1; + if (map->tile_path[1]) flags |= 2; + if (map->tile_path[2]) flags |= 4; + if (map->tile_path[3]) flags |= 8; snprintf (bigbuf, MAX_BUF, "mapinfo %s spatial %d %d %d %d %d %s", token, flags, mapx, mapy, map->width, map->height, &map->path); } @@ -346,215 +339,11 @@ pl->ns->send_packet (bigbuf); } -/** This is the Setup cmd - easy first implementation */ +/** This is the Setup cmd */ void SetUp (char *buf, int len, client * ns) { - int s, slen; - char *cmd, *param, cmdback[HUGE_BUF]; - - /* run through the cmds of setup - * syntax is setup ... - * - * we send the status of the cmd back, or a FALSE is the cmd is the server unknown - * The client then must sort this out - */ - - //LOG (llevInfo, "Get SetupCmd:: %s\n", buf); - - strcpy (cmdback, "setup"); - for (s = 0; s < len; ) - { - cmd = &buf[s]; - - /* find the next space, and put a null there */ - for (; buf[s] && buf[s] != ' '; s++) - ; - - buf[s++] = 0; - - while (buf[s] == ' ') - s++; - - if (s >= len) - break; - - param = &buf[s]; - - for (; buf[s] && buf[s] != ' '; s++) - ; - - buf[s++] = 0; - - while (buf[s] == ' ') - s++; - - slen = strlen (cmdback); - safe_strcat (cmdback, " ", &slen, HUGE_BUF); - safe_strcat (cmdback, cmd, &slen, HUGE_BUF); - safe_strcat (cmdback, " ", &slen, HUGE_BUF); - - if (!strcmp (cmd, "sound")) - { - ns->sound = atoi (param); - safe_strcat (cmdback, param, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "exp64")) - safe_strcat (cmdback, param, &slen, HUGE_BUF); - else if (!strcmp (cmd, "spellmon")) - { - ns->monitor_spells = atoi (param); - safe_strcat (cmdback, param, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "darkness")) - { - ns->darkness = atoi (param); - safe_strcat (cmdback, param, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "map1cmd")) - { - if (atoi (param)) - ns->mapmode = Map1Cmd; - /* if beyond this size, need to use map1cmd no matter what */ - if (ns->mapx > 11 || ns->mapy > 11) - ns->mapmode = Map1Cmd; - safe_strcat (cmdback, ns->mapmode == Map1Cmd ? "1" : "0", &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "map1acmd")) - { - if (atoi (param)) - ns->mapmode = Map1aCmd; - /* if beyond this size, need to use map1acmd no matter what */ - if (ns->mapx > 11 || ns->mapy > 11) - ns->mapmode = Map1aCmd; - safe_strcat (cmdback, ns->mapmode == Map1aCmd ? "1" : "0", &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "newmapcmd")) - { - ns->newmapcmd = atoi (param); - safe_strcat (cmdback, param, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "mapinfocmd")) - { - ns->mapinfocmd = atoi (param); - safe_strcat (cmdback, "1", &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "extcmd")) - { - ns->extcmd = atoi (param); - safe_strcat (cmdback, "1", &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "extmap")) - { - ns->extmap = atoi (param); - safe_strcat (cmdback, "1", &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "facecache")) - { - ns->facecache = atoi (param); - safe_strcat (cmdback, param, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "faceset")) - { - char tmpbuf[20]; - int q = atoi (param); - - if (is_valid_faceset (q)) - ns->faceset = q; - - sprintf (tmpbuf, "%d", ns->faceset); - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - /* if the client is using faceset, it knows about image2 command */ - ns->image2 = 1; - } - else if (!strcmp (cmd, "itemcmd")) - { - /* Version of the item protocol command to use. Currently, - * only supported versions are 1 and 2. Using a numeric - * value will make it very easy to extend this in the future. - */ - char tmpbuf[20]; - int q = atoi (param); - - if (q < 1 || q > 2) - { - strcpy (tmpbuf, "FALSE"); - } - else - { - ns->itemcmd = q; - sprintf (tmpbuf, "%d", ns->itemcmd); - } - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "mapsize")) - { - int x, y = 0; - char tmpbuf[MAX_BUF], *cp; - - x = atoi (param); - for (cp = param; *cp != 0; cp++) - if (*cp == 'x' || *cp == 'X') - { - y = atoi (cp + 1); - break; - } - - if (x < 9 || y < 9 || x > MAP_CLIENT_X || y > MAP_CLIENT_Y) - { - sprintf (tmpbuf, " %dx%d", MAP_CLIENT_X, MAP_CLIENT_Y); - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - } - else - { - ns->mapx = x; - ns->mapy = y; - /* better to send back what we are really using and not the - * param as given to us in case it gets parsed differently. - */ - sprintf (tmpbuf, "%dx%d", x, y); - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - /* If beyond this size and still using orig map command, need to - * go to map1cmd. - */ - if ((x > 11 || y > 11) && ns->mapmode == Map0Cmd) - ns->mapmode = Map1Cmd; - } - } - else if (!strcmp (cmd, "extendedMapInfos")) - { - /* Added by tchize - * prepare to use the mapextended command - */ - char tmpbuf[20]; - - ns->ext_mapinfos = (atoi (param)); - sprintf (tmpbuf, "%d", ns->ext_mapinfos); - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - } - else if (!strcmp (cmd, "extendedTextInfos")) - { - /* Added by tchize - * prepare to use the extended text commands - * Client toggle this to non zero to get exttext - */ - char tmpbuf[20]; - - ns->has_readable_type = (atoi (param)); - sprintf (tmpbuf, "%d", ns->has_readable_type); - safe_strcat (cmdback, tmpbuf, &slen, HUGE_BUF); - } - else - { - /* Didn't get a setup command we understood - - * report a failure to the client. - */ - safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF); - } - } /* for processing all the setup commands */ - - LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback); - ns->send_packet (cmdback); + INVOKE_CLIENT (SETUP, ns, ARG_DATA (buf, len)); } /** @@ -566,26 +355,6 @@ void AddMeCmd (char *buf, int len, client *ns) { - // face caching is mandatory - if (!ns->facecache) - { - ns->send_drawinfo ( - "\n" - "\n" - "***\n" - "*** WARNING:\n" - "*** Your client does not support face/image caching,\n" - "*** or it has been disabled. Face caching is mandatory\n" - "*** so please enable it or use a newer client.\n" - "***\n" - "*** I will proceed as if face caching were enabled.\n" - "\n" - "***\n", - NDI_RED - ); - //ns->facecache = true; - } - INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); } @@ -723,6 +492,7 @@ AskSmooth (char *buf, int len, client *ns) { ns->send_face (atoi (buf)); + ns->flush_fx (); } /** @@ -835,10 +605,6 @@ LOG (llevError, "Got reply message with ST_PLAYING input state\n"); break; - case ST_CHANGE_CLASS: - key_change_class (pl->ob, buf[0]); - break; - case ST_GET_PARTY_PASSWORD: /* Get password for party */ receive_party_password (pl->ob, 13); break; @@ -887,7 +653,7 @@ if (cp) { - assign (ns->version, cp + 1); + ns->version = cp + 1; if (ns->sc_version < 1026) ns->send_packet_printf ("drawinfo %d %s", NDI_RED, @@ -957,11 +723,33 @@ * it needs to send something back (vs just printing out a message) */ void -send_query (client *ns, uint8 flags, char *text) +send_query (client *ns, uint8 flags, const char *text) { ns->send_packet_printf ("query %d %s", flags, text ? text : ""); } +/** + * Get player's current range attack in obuf. + */ +static void +rangetostring (player *pl, char *obuf) +{ + dynbuf_text buf; + + if (pl->ranged_ob) + buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; + + if (pl->combat_ob) + buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name; + + //TODO: maybe golem should become the current_weapon, quite simply? + if (pl->golem) + buf << " Golem*: " << pl->golem->name; + + buf.linearise (obuf); + obuf [buf.size ()] = 0; +} + #define AddIfInt64(Old,New,Type) if (Old != New) {\ Old = New; \ sl << uint8 (Type) << uint64 (New); \ @@ -1076,7 +864,7 @@ AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); } - rangetostring (ob, buf); /* we want use the new fire & run system in new client */ + rangetostring (pl, buf); /* we want use the new fire & run system in new client */ AddIfString (ns->stats.range, buf, CS_STAT_RANGE); set_title (ob, buf); AddIfString (ns->stats.title, buf, CS_STAT_TITLE); @@ -1407,10 +1195,10 @@ if (socket.extmap) { - uint8 stat_hp = 0; + uint8 stat_hp = 0; uint8 stat_width = 0; - uint8 flags = 0; - UUID player = 0; + uint8 flags = 0; + tag_t player = 0; // send hp information, if applicable if (object *op = ms.faces_obj [0]) @@ -1461,7 +1249,7 @@ *last_ext |= 0x80; last_ext = &sl[sl.length ()]; - sl << uint8 (0x47) << uint8 (8) << (uint64)player; + sl << uint8 (0x47) << uint8 (4) << (uint32)player; } if (lastcell.flags != flags) @@ -1545,6 +1333,8 @@ } /* for x loop */ } /* for y loop */ + socket.flush_fx (); + /* Verify that we in fact do need to send this */ if (socket.ext_mapinfos) {