- 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,40 +8210,38 @@ 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]);
char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
if ((old_sd = map_id2sd(account_id)) != NULL) account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
{ // if same account already connected, we disconnect the 2 sessions char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
//Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex] login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
if (old_sd->state.finalsave || !old_sd->state.auth) client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
; //Previous player is not done loading. sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
//Or he has quit, but is not done saving on the charserver.
else if (old_sd->fd)
clif_authfail_fd(old_sd->fd, 2); // same id
else
map_quit(old_sd);
clif_authfail_fd(fd, 8); // still recognizes last connection
} else {
sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
sd->fd = fd; if ((old_sd = map_id2sd(account_id)) != NULL)
sd->packet_ver = packet_ver; { // if same account already connected, we disconnect the 2 sessions
session[fd]->session_data = sd; //Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
if (old_sd->state.finalsave || !old_sd->state.auth)
pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); ; //Previous player is not done loading.
WFIFOHEAD(fd,4); //Or he has quit, but is not done saving on the charserver.
WFIFOL(fd,0) = sd->bl.id; else if (old_sd->fd)
WFIFOSET(fd,4); clif_authfail_fd(old_sd->fd, 2); // same id
else
chrif_authreq(sd); map_quit(old_sd);
} clif_authfail_fd(fd, 8); // still recognizes last connection
return;
} }
sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
sd->fd = fd;
sd->packet_ver = packet_ver;
session[fd]->session_data = sd;
pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
WFIFOHEAD(fd,4);
WFIFOL(fd,0) = sd->bl.id;
WFIFOSET(fd,4);
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) {
//Disassociate character from the socket connection. if (sd->state.autotrade) {
session[fd]->session_data = NULL; //Disassociate character from the socket connection.
sd->fd = 0; session[fd]->session_data = NULL;
ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] sd->fd = 0;
} else if (sd && sd->state.auth) { ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n",
clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor] (pc_isGM(sd))?"GM ":"",sd->status.name);
if (sd->status.name != NULL) } else
ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"",sd->status.name); // Player logout display [Valaris] if (sd->state.auth) {
else clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' logged off.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id); // Player logout display [Yor] // Player logout display [Valaris]
ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n",
(pc_isGM(sd))?"GM ":"",sd->status.name);
} 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,44 +11925,38 @@ 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; char packet_txt[256] = "save/packet.txt";
char packet_txt[256] = "save/packet.txt"; time_t now;
time_t now; dump = 1;
dump = 1;
if ((fp = fopen(packet_txt, "a")) == NULL) { if ((fp = fopen(packet_txt, "a")) == NULL) {
ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt); ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
return 1; return 1;
} 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 if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
else 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);
} 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, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"); fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
for(i = 0; i < packet_len; i++) { for(i = 0; i < packet_len; i++) {
if ((i & 15) == 0) if ((i & 15) == 0)
fprintf(fp, "\n\t%04X ", i); fprintf(fp, "\n\t%04X ", i);
fprintf(fp, "%02X ", RFIFOB(fd,i)); fprintf(fp, "%02X ", RFIFOB(fd,i));
}
fprintf(fp, "\n\n");
fclose(fp);
}
} }
#endif fprintf(fp, "\n\n");
fclose(fp);
} }
} }
#endif
if (dump) { if (dump) {
int i; int i;