The max_account_id packetver detection mechanism will never cause any connection problems ever again. (bugreport:388)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12563 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-04-11 09:31:32 +00:00
parent f45a8f2c82
commit 00a5bccbd3
10 changed files with 5 additions and 84 deletions

View File

@ -147,9 +147,6 @@ int online_display_option = 1; // display options: to know which columns must be
int online_refresh_html = 20; // refresh time (in sec) of the html file in the explorer int online_refresh_html = 20; // refresh time (in sec) of the html file in the explorer
int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it
//These are used to aid the map server in identifying valid clients. [Skotlex]
static int max_account_id = DEFAULT_MAX_ACCOUNT_ID, max_char_id = DEFAULT_MAX_CHAR_ID;
int console = 0; int console = 0;
//----------------------------------------------------- //-----------------------------------------------------
@ -200,17 +197,6 @@ void set_char_online(int map_id, int char_id, int account_id)
{ {
struct online_char_data* character; struct online_char_data* character;
if ( char_id != 99 ) {
if (max_account_id < account_id || max_char_id < char_id)
{ //Notify map-server of the new max IDs [Skotlex]
if (account_id > max_account_id)
max_account_id = account_id;
if (char_id > max_char_id)
max_char_id = char_id;
mapif_send_maxid(max_account_id, max_char_id);
}
}
character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id && map_id != -3) if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id && map_id != -3)
{ {
@ -2668,9 +2654,6 @@ int parse_frommap(int fd)
char_log("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d. Map-server %d loading complete.\n", char_log("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d. Map-server %d loading complete.\n",
id, j, CONVIP(server[id].ip), server[id].port, id); id, j, CONVIP(server[id].ip), server[id].port, id);
if (max_account_id != DEFAULT_MAX_ACCOUNT_ID || max_char_id != DEFAULT_MAX_CHAR_ID)
mapif_send_maxid(max_account_id, max_char_id); //Send the current max ids to the server to keep in sync [Skotlex]
// send name for wisp to player // send name for wisp to player
WFIFOHEAD(fd, 3 + NAME_LENGTH); WFIFOHEAD(fd, 3 + NAME_LENGTH);
WFIFOW(fd,0) = 0x2afb; WFIFOW(fd,0) = 0x2afb;
@ -3436,8 +3419,6 @@ int parse_char(int fd)
node->expiration_time = sd->expiration_time; node->expiration_time = sd->expiration_time;
node->ip = ipl; node->ip = ipl;
idb_put(auth_db, sd->account_id, node); idb_put(auth_db, sd->account_id, node);
set_char_online(i, cd->char_id, cd->account_id);
} }
break; break;

View File

@ -294,17 +294,6 @@ int inter_mapif_init(int fd) {
//-------------------------------------------------------- //--------------------------------------------------------
// sended packets to map-server // sended packets to map-server
//Sends the current max account/char id to map server [Skotlex]
void mapif_send_maxid(int account_id, int char_id)
{
unsigned char buf[12];
WBUFW(buf,0) = 0x2b07;
WBUFL(buf,2) = account_id;
WBUFL(buf,6) = char_id;
mapif_sendall(buf, 10);
}
// GMメッセージ送信 // GMメッセージ送信
int mapif_GMmessage(unsigned char *mes, int len, unsigned long color, int sfd) { int mapif_GMmessage(unsigned char *mes, int len, unsigned long color, int sfd) {
unsigned char buf[2048]; unsigned char buf[2048];

View File

@ -11,7 +11,6 @@ void inter_final(void);
int inter_save(void); int inter_save(void);
int inter_parse_frommap(int fd); int inter_parse_frommap(int fd);
int inter_mapif_init(int fd); int inter_mapif_init(int fd);
void mapif_send_maxid(int, int);
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
int inter_check_length(int fd,int length); int inter_check_length(int fd,int length);

View File

@ -117,8 +117,6 @@ int save_log = 0; //Have the logs be off by default when converting
int save_log = 1; int save_log = 1;
#endif #endif
//These are used to aid the map server in identifying valid clients. [Skotlex]
static int max_account_id = DEFAULT_MAX_ACCOUNT_ID, max_char_id = DEFAULT_MAX_CHAR_ID;
static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex] static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex]
// Advanced subnet check [LuzZza] // Advanced subnet check [LuzZza]
@ -221,15 +219,6 @@ void set_char_online(int map_id, int char_id, int account_id)
if ( char_id != 99 ) { if ( char_id != 99 ) {
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) ) if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) )
Sql_ShowDebug(sql_handle); Sql_ShowDebug(sql_handle);
if (max_account_id < account_id || max_char_id < char_id)
{ //Notify map-server of the new max IDs [Skotlex]
if (account_id > max_account_id)
max_account_id = account_id;
if (char_id > max_char_id)
max_char_id = char_id;
mapif_send_maxid(max_account_id, max_char_id);
}
} }
character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
@ -2318,9 +2307,6 @@ int parse_frommap(int fd)
id, j, CONVIP(server[id].ip), server[id].port); id, j, CONVIP(server[id].ip), server[id].port);
ShowStatus("Map-server %d loading complete.\n", id); ShowStatus("Map-server %d loading complete.\n", id);
if (max_account_id != DEFAULT_MAX_ACCOUNT_ID || max_char_id != DEFAULT_MAX_CHAR_ID)
mapif_send_maxid(max_account_id, max_char_id); //Send the current max ids to the server to keep in sync [Skotlex]
// send name for wisp to player // send name for wisp to player
WFIFOHEAD(fd, 3 + NAME_LENGTH); WFIFOHEAD(fd, 3 + NAME_LENGTH);
WFIFOW(fd,0) = 0x2afb; WFIFOW(fd,0) = 0x2afb;

View File

@ -552,17 +552,6 @@ int mapif_send_gmaccounts()
return 0; return 0;
} }
//Sends the current max account/char id to map server [Skotlex]
void mapif_send_maxid(int account_id, int char_id)
{
unsigned char buf[12];
WBUFW(buf,0) = 0x2b07;
WBUFL(buf,2) = account_id;
WBUFL(buf,6) = char_id;
mapif_sendall(buf, 10);
}
//Request to kick char from a certain map server. [Skotlex] //Request to kick char from a certain map server. [Skotlex]
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
{ {

View File

@ -12,7 +12,6 @@ void inter_final(void);
int inter_parse_frommap(int fd); int inter_parse_frommap(int fd);
int inter_mapif_init(int fd); int inter_mapif_init(int fd);
int mapif_send_gmaccounts(void); int mapif_send_gmaccounts(void);
void mapif_send_maxid(int, int);
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
int inter_check_length(int fd,int length); int inter_check_length(int fd,int length);

View File

@ -86,17 +86,11 @@
//Size of the fame list arrays. //Size of the fame list arrays.
#define MAX_FAME_LIST 10 #define MAX_FAME_LIST 10
//These max values can be exceeded and the char/map servers will update them with no problems
//These are just meant to minimize the updating needed between char/map servers as players login.
//Room for initial 10K accounts
#define DEFAULT_MAX_ACCOUNT_ID 2010000
//Limits to avoid ID collision with other game objects
#define START_ACCOUNT_NUM 2000000 #define START_ACCOUNT_NUM 2000000
#define END_ACCOUNT_NUM 100000000 #define END_ACCOUNT_NUM 100000000
//Room for initial 100k characters
#define DEFAULT_MAX_CHAR_ID 250000
//Base Homun skill. //Base Homun skill.
#define HM_SKILLBASE 8001 #define HM_SKILLBASE 8001
#define MAX_HOMUNSKILL 16 #define MAX_HOMUNSKILL 16

View File

@ -33,7 +33,7 @@ static DBMap* auth_db; // int id -> struct auth_node*
static const int packet_len_table[0x3d] = { // U - used, F - free static const int packet_len_table[0x3d] = { // U - used, F - free
60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
6,-1,18, 7,-1,35,30,10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07 6,-1,18, 7,-1,35,30,-1, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, F->2b07
6,30,-1,-1,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f 6,30,-1,-1,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, F->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
11,10,10, 6,11,-1,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17 11,10,10, 6,11,-1,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17
2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
@ -56,7 +56,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
//2b04: Incoming, chrif_recvmap -> 'getting maps from charserver of other mapserver's' //2b04: Incoming, chrif_recvmap -> 'getting maps from charserver of other mapserver's'
//2b05: Outgoing, chrif_changemapserver -> 'Tell the charserver the mapchange / quest for ok...' //2b05: Outgoing, chrif_changemapserver -> 'Tell the charserver the mapchange / quest for ok...'
//2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^' //2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^'
//2b07: Incoming, clif_updatemaxid -> Received when updating the max account/char known //2b07: FREE
//2b08: Outgoing, chrif_searchcharid -> '...' //2b08: Outgoing, chrif_searchcharid -> '...'
//2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db' //2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db'
//2b0a: FREE //2b0a: FREE
@ -1427,7 +1427,6 @@ int chrif_parse(int fd)
case 0x2b03: clif_charselectok(RFIFOL(fd,2)); break; case 0x2b03: clif_charselectok(RFIFOL(fd,2)); break;
case 0x2b04: chrif_recvmap(fd); break; case 0x2b04: chrif_recvmap(fd); break;
case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break; case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break;
case 0x2b07: clif_updatemaxid(RFIFOL(fd,2), RFIFOL(fd,6)); break;
case 0x2b09: map_addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; case 0x2b09: map_addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
case 0x2b0d: chrif_changedsex(fd); break; case 0x2b0d: chrif_changedsex(fd); break;
case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break;

View File

@ -92,11 +92,6 @@ static uint32 bind_ip = INADDR_ANY;
static uint16 map_port = 5121; static uint16 map_port = 5121;
int map_fd; int map_fd;
//These two will be used to verify the incoming player's validity.
//It helps identify their client packet version correctly. [Skotlex]
static int max_account_id = DEFAULT_MAX_ACCOUNT_ID;
static int max_char_id = DEFAULT_MAX_CHAR_ID;
int clif_parse (int fd); int clif_parse (int fd);
/*========================================== /*==========================================
@ -540,15 +535,6 @@ int clif_authfail_fd(int fd, int type)
return 0; return 0;
} }
/*==========================================
* Used to know which is the max valid account/char id [Skotlex]
*------------------------------------------*/
void clif_updatemaxid(int account_id, int char_id)
{
max_account_id = account_id;
max_char_id = char_id;
}
/*========================================== /*==========================================
* *
*------------------------------------------*/ *------------------------------------------*/
@ -7617,9 +7603,9 @@ static int clif_guess_PacketVer(int fd, int get_previous, int *error)
#define CHECK_PACKET_VER() \ #define CHECK_PACKET_VER() \
if( cmd != clif_config.connect_cmd[packet_ver] || packet_len != packet_db[packet_ver][cmd].len )\ if( cmd != clif_config.connect_cmd[packet_ver] || packet_len != packet_db[packet_ver][cmd].len )\
;/* not wanttoconnection or wrong length */\ ;/* not wanttoconnection or wrong length */\
else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < START_ACCOUNT_NUM || value > max_account_id )\ else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < START_ACCOUNT_NUM || value > END_ACCOUNT_NUM )\
{ SET_ERROR(2); }/* invalid account_id */\ { SET_ERROR(2); }/* invalid account_id */\
else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) <= 0 || value > max_char_id )\ else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) <= 0 )\
{ SET_ERROR(3); }/* invalid char_id */\ { SET_ERROR(3); }/* invalid char_id */\
/* RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) - don't care about login_id1 */\ /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) - don't care about login_id1 */\
/* RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]) - don't care about client_tick */\ /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]) - don't care about client_tick */\

View File

@ -96,7 +96,6 @@ uint16 clif_getport(void);
int clif_authok(struct map_session_data *); int clif_authok(struct map_session_data *);
int clif_authfail_fd(int fd,int type); int clif_authfail_fd(int fd,int type);
void clif_updatemaxid(int, int);
int clif_charselectok(int); int clif_charselectok(int);
int clif_dropflooritem(struct flooritem_data *); int clif_dropflooritem(struct flooritem_data *);
int clif_clearflooritem(struct flooritem_data *,int); int clif_clearflooritem(struct flooritem_data *,int);