--- deliantra/server/socket/request.C 2006/12/21 06:12:37 1.49 +++ deliantra/server/socket/request.C 2006/12/21 23:37:06 1.50 @@ -140,19 +140,19 @@ static void clear_map (player *pl) { - memset (&pl->socket->lastmap, 0, sizeof (pl->socket->lastmap)); + memset (&pl->ns->lastmap, 0, sizeof (pl->ns->lastmap)); - if (pl->socket->newmapcmd == 1) - pl->socket->send_packet ("newmap"); + if (pl->ns->newmapcmd == 1) + pl->ns->send_packet ("newmap"); - pl->socket->floorbox_reset (); + pl->ns->floorbox_reset (); } /** check for map change and send new map data */ static void check_map_change (player *pl) { - client &socket = *pl->socket; + client &socket = *pl->ns; object *ob = pl->ob; char buf[MAX_BUF]; /* eauugggh */ @@ -282,8 +282,8 @@ // initial map and its origin maptile *map = pl->ob->map; sint16 dx, dy; - int mapx = pl->socket->mapx / 2 - pl->ob->x; - int mapy = pl->socket->mapy / 2 - pl->ob->y; + int mapx = pl->ns->mapx / 2 - pl->ob->x; + int mapy = pl->ns->mapy / 2 - pl->ob->y; int max_distance = 8; // limit maximum path length to something generous while (*buf && map && max_distance) @@ -344,7 +344,7 @@ else snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token); - pl->socket->send_packet (bigbuf); + pl->ns->send_packet (bigbuf); } /** This is the Setup cmd - easy first implementation */ @@ -815,13 +815,19 @@ /* Send confirmation of command execution now */ packet sl ("comc"); sl << uint16 (cmdid) << uint32 (time); - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); } /** This is a reply to a previous query. */ void ReplyCmd (char *buf, int len, client *ns) { + if (ns->state == ST_CUSTOM) + { + INVOKE_CLIENT (REPLY, ns, ARG_DATA (buf, len)); + return; + } + if (!ns->pl) return; //TODO: depends on the exact reply we are after //TODO: but right now, we always have a ns->pl @@ -840,7 +846,7 @@ /* this avoids any hacking here */ - switch (pl->state) + switch (ns->state) { case ST_PLAYING: LOG (llevError, "Got reply message with ST_PLAYING input state\n"); @@ -867,7 +873,7 @@ case ST_CONFIGURE: LOG (llevError, "In client input handling, but into configure state\n"); - pl->state = ST_PLAYING; + ns->state = ST_PLAYING; break; case ST_GET_NAME: @@ -884,7 +890,7 @@ break; default: - LOG (llevError, "Unknown input state: %d\n", pl->state); + LOG (llevError, "Unknown input state: %d\n", ns->state); } } @@ -1060,7 +1066,7 @@ AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); } - if (pl->socket->exp64) + if (pl->ns->exp64) for (int s = 0; s < NUM_SKILLS; s++) if (pl->last_skill_ob[s] && pl->last_skill_exp[s] != pl->last_skill_ob[s]->stats.exp) { @@ -1074,7 +1080,7 @@ pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp; } - if (pl->socket->exp64) + if (pl->ns->exp64) { AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64) } else { AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP) } @@ -1097,7 +1103,7 @@ AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); - if (pl->socket->sc_version < 1025) + if (pl->ns->sc_version < 1025) { AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) } else for (int i = 0; i < NROFATTACKS; i++) @@ -1109,7 +1115,7 @@ AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); } - if (pl->socket->monitor_spells) + if (pl->ns->monitor_spells) { AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); @@ -1117,13 +1123,13 @@ } rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ - AddIfString (pl->socket->stats.range, buf, CS_STAT_RANGE); + AddIfString (pl->ns->stats.range, buf, CS_STAT_RANGE); set_title (pl->ob, buf); - AddIfString (pl->socket->stats.title, buf, CS_STAT_TITLE); + AddIfString (pl->ns->stats.title, buf, CS_STAT_TITLE); /* Only send it away if we have some actual data */ if (sl.length () > 6) - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); } /** @@ -1141,7 +1147,7 @@ << uint32 (pl->ob->face->number) << data8 (pl->ob->name); - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); SET_FLAG (pl->ob, FLAG_CLIENT_SENT); } @@ -1598,7 +1604,7 @@ * and use the other 4 bits for other informatiion. For full documentation * of what we send, see the doc/Protocol file. * I will describe internally what we do: - * the socket->lastmap shows how the map last looked when sent to the client. + * the ns->lastmap shows how the map last looked when sent to the client. * in the lastmap structure, there is a cells array, which is set to the * maximum viewable size (As set in config.h). * in the cells, there are faces and a count value. @@ -1619,7 +1625,7 @@ uint8 extendedinfos; maptile *m; - client &socket = *pl->contr->socket; + client &socket = *pl->contr->ns; check_map_change (pl->contr); @@ -2018,8 +2024,8 @@ memset (&newmap, 0, sizeof (struct Map)); - for (j = (pl->y - pl->contr->socket->mapy / 2); j < (pl->y + (pl->contr->socket->mapy + 1) / 2); j++) - for (i = (pl->x - pl->contr->socket->mapx / 2); i < (pl->x + (pl->contr->socket->mapx + 1) / 2); i++) + for (j = (pl->y - pl->contr->ns->mapy / 2); j < (pl->y + (pl->contr->ns->mapy + 1) / 2); j++) + for (i = (pl->x - pl->contr->ns->mapx / 2); i < (pl->x + (pl->contr->ns->mapx + 1) / 2); i++) { ax = i; ay = j; @@ -2061,7 +2067,7 @@ void send_plugin_custom_message (object *pl, char *buf) { - pl->contr->socket->send_packet (buf); + pl->contr->ns->send_packet (buf); } /** @@ -2116,7 +2122,7 @@ void esrv_update_spells (player *pl) { - if (!pl->socket->monitor_spells) + if (!pl->ns->monitor_spells) return; for (object *spell = pl->ob->inv; spell; spell = spell->below) @@ -2156,7 +2162,7 @@ if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); } } } @@ -2165,7 +2171,7 @@ void esrv_remove_spell (player *pl, object *spell) { - if (!pl->socket->monitor_spells) + if (!pl->ns->monitor_spells) return; if (!pl || !spell || spell->env != pl->ob) @@ -2178,7 +2184,7 @@ sl << uint32 (spell->count); - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); } /* appends the spell *spell to the Socklist we will send the data to. */ @@ -2236,7 +2242,7 @@ return; } - if (!pl->socket->monitor_spells) + if (!pl->ns->monitor_spells) return; packet sl ("addspell"); @@ -2263,7 +2269,7 @@ if (sl.length () >= (MAXSOCKBUF - (26 + strlen (spell->name) + (spell->msg ? strlen (spell->msg) : 0)))) { - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); sl.reset (); sl << "addspell "; @@ -2287,6 +2293,6 @@ } /* finally, we can send the packet */ - pl->socket->send_packet (sl); + pl->ns->send_packet (sl); }