- Moved refusal of a known packet versions to clif_parse_WantToConnection and made it check for non-player object with that id.

Changed in reaction to: http://www.eathena.ws/board/index.php?showtopic=130808

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9610 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
FlavioJS 2007-01-03 07:57:05 +00:00
parent 00c558490a
commit ed74a4c9c7
2 changed files with 60 additions and 81 deletions

View File

@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/01/03 2007/01/03
* Moved refusal of a known packet versions to clif_parse_WantToConnection
and made it check for non-player object with that id.
* JK_JOINTBEAT as described in: * JK_JOINTBEAT as described in:
http://www.ragnainfo.net/wiki/index.php/Vital_Strike http://www.ragnainfo.net/wiki/index.php/Vital_Strike
Although not clear, it's being assumed that the 2x damage is only for the Although not clear, it's being assumed that the 2x damage is only for the

View File

@ -8164,9 +8164,8 @@ static int clif_guess_PacketVer(int fd, int get_previous, int *error)
* *
*------------------------------------------ *------------------------------------------
*/ */
void clif_parse_WantToConnection(int fd, struct map_session_data *sd) void clif_parse_WantToConnection(int fd, TBL_PC* sd)
{ {
struct map_session_data *old_sd;
int cmd, account_id, char_id, login_id1, sex; int cmd, account_id, char_id, login_id1, sex;
unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex] unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
@ -8178,20 +8177,42 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
return; return;
} }
// Only valid packet version get here
packet_ver = clif_guess_PacketVer(fd, 1, NULL); packet_ver = clif_guess_PacketVer(fd, 1, NULL);
cmd = RFIFOW(fd,0); cmd = RFIFOW(fd,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]);
client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]); client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]); sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
if ((old_sd = map_id2sd(account_id)) != NULL) if( packet_ver < 5 || // reject really old client versions
{ // if same account already connected, we disconnect the 2 sessions (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
(packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0)) // version not allowed
{// packet version rejected
WFIFOHEAD(fd,packet_len(0x6a));
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 5; // Your Game's EXE file is not the latest version
WFIFOSET(fd,packet_len(0x6a));
clif_setwaitclose(fd);
return;
} else
{// packet version accepted
TBL_PC* old_sd;
if( map_id2bl(account_id) != NULL )
{// non-player object already has that id
ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id);
WFIFOHEAD(fd,packet_len(0x6a));
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // Rejected by server
WFIFOSET(fd,packet_len(0x6a));
clif_setwaitclose(fd);
return;
} else if( (old_sd=map_id2sd(account_id)) != NULL ){
// if same account already connected, we disconnect the 2 sessions
//Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex] //Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
if (old_sd->state.finalsave || !old_sd->state.auth) if (old_sd->state.finalsave || !old_sd->state.auth)
; //Previous player is not done loading. ; //Previous player is not done loading.
@ -8203,7 +8224,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
clif_authfail_fd(fd, 8); // still recognizes last connection clif_authfail_fd(fd, 8); // still recognizes last connection
return; return;
} }
sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data)); }
CREATE(sd, TBL_PC, 1);
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;
@ -11812,40 +11835,6 @@ int clif_parse(int fd) {
cmd = RFIFOW(fd,0); cmd = RFIFOW(fd,0);
/*
// These are remants of ladmin packet processing, only in the login server now. [FlavioJS]
// @see int parse_admin(int)
// 管理用パケット処理
if (cmd >= 30000) {
switch(cmd) {
case 0x7530: { //Why are we letting people know which version we are running?
WFIFOHEAD(fd, 10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
WFIFOB(fd,4) = ATHENA_REVISION;
WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
WFIFOB(fd,7) = ATHENA_SERVER_MAP;
WFIFOW(fd,8) = ATHENA_MOD_VERSION;
WFIFOSET(fd,10);
RFIFOSKIP(fd,2);
break;
}
case 0x7532: // 接続の切断
ShowWarning("clif_parse: session #%d disconnected for sending packet 0x04%x\n", fd, cmd);
session[fd]->eof=1;
break;
default:
ShowWarning("Unknown incoming packet (command: 0x%04x, session: %d), disconnecting.\n", cmd, fd);
session[fd]->eof=1;
break;
}
return 0;
}
*/
// get packet version before to parse // get packet version before to parse
packet_ver = 0; packet_ver = 0;
if (sd) { if (sd) {
@ -11858,14 +11847,8 @@ int clif_parse(int fd) {
} else { } else {
// check authentification packet to know packet version // check authentification packet to know packet version
packet_ver = clif_guess_PacketVer(fd, 0, &err); packet_ver = clif_guess_PacketVer(fd, 0, &err);
if (err || // unknown packet version
packet_ver < 5 || // reject really old client versions
(packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
(packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0) ||
packet_ver > MAX_PACKET_VER) // no packet version support yet
{
if( err ) if( err )
{// failed to identify {// failed to identify packet version
ShowInfo("clif_parse: Disconnecting session #%d with unknown packet version%s.\n", fd, ( ShowInfo("clif_parse: Disconnecting session #%d with unknown packet version%s.\n", fd, (
err == 1 ? "" : err == 1 ? "" :
err == 2 ? ", possibly for having an invalid account_id" : err == 2 ? ", possibly for having an invalid account_id" :
@ -11876,23 +11859,17 @@ int clif_parse(int fd) {
*/ */
err == 6 ? ", possibly for having an invalid sex." : err == 6 ? ", possibly for having an invalid sex." :
". ERROR invalid error code")); ". ERROR invalid error code"));
err = 3; // 3 = Rejected from Server
}
else
{// version not accepted
ShowInfo("clif_parse: Disconnecting session #%d for not having latest client version (has version %d).\n", fd, packet_ver);
err = 5; // 05 = Game's EXE is not the latest version
}
WFIFOHEAD(fd,packet_len(0x6a)); WFIFOHEAD(fd,packet_len(0x6a));
WFIFOW(fd,0) = 0x6a; WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = err; WFIFOB(fd,2) = 3; // Rejected from Server
WFIFOSET(fd,packet_len(0x6a)); WFIFOSET(fd,packet_len(0x6a));
packet_len = RFIFOREST(fd); RFIFOSKIP(fd, RFIFOREST(fd));
RFIFOSKIP(fd, packet_len);
clif_setwaitclose(fd); clif_setwaitclose(fd);
/*
//## TODO check if it still doesn't send and why. [FlavioJS] //## TODO check if it still doesn't send and why. [FlavioJS]
if (session[fd]->func_send) //socket.c doesn't wants to send the data when left on it's own... [Skotlex] if (session[fd]->func_send) //socket.c doesn't wants to send the data when left on it's own... [Skotlex]
session[fd]->func_send(fd); session[fd]->func_send(fd);
*/
return 0; return 0;
} }
} }