- Some cleaning of the pc_authok, clif_WantToConnection functions. Also some cleaning of the logout messages and some other cleanups in clif_parse

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9312 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-11-24 15:55:25 +00:00
parent 9db096c861
commit 75ebff35c4

View File

@ -1824,7 +1824,7 @@ void clif_quitsave(int fd,struct map_session_data *sd)
else if (sd->fd) else if (sd->fd)
{ //Disassociate session from player (session is deleted after this function was called) { //Disassociate session from player (session is deleted after this function was called)
//And set a timer to make him quit later. //And set a timer to make him quit later.
session[fd]->session_data = NULL; session[sd->fd]->session_data = NULL;
sd->fd = 0; sd->fd = 0;
add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0); add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
} }
@ -8210,8 +8210,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
packet_ver = clif_guess_PacketVer(fd, 1); packet_ver = clif_guess_PacketVer(fd, 1);
cmd = RFIFOW(fd,0); cmd = RFIFOW(fd,0);
if (packet_ver > 0) if (packet_ver <= 0)
{ return;
account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]); account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]); char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]); login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
@ -8229,9 +8230,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
else else
map_quit(old_sd); map_quit(old_sd);
clif_authfail_fd(fd, 8); // still recognizes last connection clif_authfail_fd(fd, 8); // still recognizes last connection
} else { return;
}
sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
sd->fd = fd; sd->fd = fd;
sd->packet_ver = packet_ver; sd->packet_ver = packet_ver;
session[fd]->session_data = sd; session[fd]->session_data = sd;
@ -8240,10 +8241,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
WFIFOHEAD(fd,4); WFIFOHEAD(fd,4);
WFIFOL(fd,0) = sd->bl.id; WFIFOL(fd,0) = sd->bl.id;
WFIFOSET(fd,4); WFIFOSET(fd,4);
chrif_authreq(sd); chrif_authreq(sd);
}
}
return; return;
} }
@ -11757,32 +11755,34 @@ int clif_parse(int fd) {
} }
sd = (struct map_session_data*)session[fd]->session_data; sd = (struct map_session_data*)session[fd]->session_data;
/* This behaviour has been deprecated due to actually causing trouble instead
* of helping against exploits ~.~ [Skotlex] if (sd && sd->fd != fd)
if (!chrif_isconnect()) { //FIXME: Temporal debug until a certain mysterious crash is fixed.
{ ShowError("Player's connection value is incorrect! %d != %d\n", sd->fd, fd);
ShowInfo("Closing session #%d (Not connected to Char server)\n", fd); sd->fd = fd;
if (sd && sd->state.auth) }
clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
do_close(fd);
return 0;
} else
*/
if (session[fd]->eof) { if (session[fd]->eof) {
if (sd && sd->state.autotrade) { if (sd) {
if (sd->state.autotrade) {
//Disassociate character from the socket connection. //Disassociate character from the socket connection.
session[fd]->session_data = NULL; session[fd]->session_data = NULL;
sd->fd = 0; sd->fd = 0;
ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n",
} else if (sd && sd->state.auth) { (pc_isGM(sd))?"GM ":"",sd->status.name);
} else
if (sd->state.auth) {
clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor] clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
if (sd->status.name != NULL) // Player logout display [Valaris]
ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n",
else (pc_isGM(sd))?"GM ":"",sd->status.name);
ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor] } else {
ShowInfo("Player AID:%d/CID:%d (not authenticated) logged off.\n",
sd->bl.id, sd->char_id);
}
} else { } else {
unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr; unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
ShowInfo("Player not identified with IP '"CL_WHITE"%d.%d.%d.%d"CL_RESET"' logged off.\n", ip[0],ip[1],ip[2],ip[3]); ShowInfo("Closed connection from '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip[0],ip[1],ip[2],ip[3]);
} }
do_close(fd); do_close(fd);
return 0; return 0;
@ -11913,8 +11913,8 @@ int clif_parse(int fd) {
} }
#endif #endif
if (sd && sd->state.auth == 1 && sd->state.waitingdisconnect == 1) { // 切断待ちの場合パケットを処理しない if (sd && sd->state.waitingdisconnect == 1) {
// 切断待ちの場合パケットを処理しない
} else if (packet_db[packet_ver][cmd].func) { } else if (packet_db[packet_ver][cmd].func) {
if (sd && sd->bl.prev == NULL && if (sd && sd->bl.prev == NULL &&
packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck) packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck)
@ -11925,10 +11925,9 @@ int clif_parse(int fd) {
|| packet_db[packet_ver][cmd].func == clif_parse_debug || packet_db[packet_ver][cmd].func == clif_parse_debug
) //Only execute the function when there's an sd (except for debug/wanttoconnect packets) ) //Only execute the function when there's an sd (except for debug/wanttoconnect packets)
packet_db[packet_ver][cmd].func(fd, sd); packet_db[packet_ver][cmd].func(fd, sd);
} else { }
// 不明なパケット #ifdef DUMP_UNKNOWN_PACKET
if (battle_config.error_log) { else if (battle_config.error_log)
#if DUMP_UNKNOWN_PACKET
{ {
int i; int i;
FILE *fp; FILE *fp;
@ -11942,11 +11941,8 @@ int clif_parse(int fd) {
} else { } else {
time(&now); time(&now);
if (sd && sd->state.auth) { if (sd && sd->state.auth) {
if (sd->status.name != NULL)
fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n", fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name); asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
else
fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
} else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified) } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id); fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
@ -11961,8 +11957,6 @@ int clif_parse(int fd) {
} }
} }
#endif #endif
}
}
if (dump) { if (dump) {
int i; int i;