Remove some duplicate code
This commit is contained in:
parent
d1eeda3466
commit
d92a8df4c2
@ -367,9 +367,9 @@ void chclif_char_delete2_cancel_ack(int fd, uint32 char_id, uint32 result) {
|
||||
|
||||
// CH: <0827>.W <char id>.L
|
||||
int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
|
||||
FIFOSD_CHECK(6)
|
||||
{
|
||||
uint32 char_id, i;
|
||||
FIFOSD_CHECK(6)
|
||||
{
|
||||
uint32 char_id, i;
|
||||
char* data;
|
||||
time_t delete_date;
|
||||
|
||||
@ -557,15 +557,9 @@ int chclif_parse_maplogin(int fd){
|
||||
strcmp(l_user, charserv_config.userid) != 0 ||
|
||||
strcmp(l_pass, charserv_config.passwd) != 0 )
|
||||
{
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x2af9;
|
||||
WFIFOB(fd,2) = 3;
|
||||
WFIFOSET(fd,3);
|
||||
chmapif_connectack(fd, 3); //fail
|
||||
} else {
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x2af9;
|
||||
WFIFOB(fd,2) = 0;
|
||||
WFIFOSET(fd,3);
|
||||
chmapif_connectack(fd, 0); //success
|
||||
|
||||
map_server[i].fd = fd;
|
||||
map_server[i].ip = ntohl(RFIFOL(fd,54));
|
||||
@ -619,25 +613,21 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
|
||||
WFIFOL(fd,0) = account_id;
|
||||
WFIFOSET(fd,4);
|
||||
|
||||
if( runflag != CHARSERVER_ST_RUNNING )
|
||||
{
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0;// rejected from server
|
||||
WFIFOSET(fd,3);
|
||||
if( runflag != CHARSERVER_ST_RUNNING ) {
|
||||
chclif_reject(fd, 0); // rejected from server
|
||||
return 1;
|
||||
}
|
||||
|
||||
// search authentification
|
||||
node = (struct auth_node*)idb_get(auth_db, account_id);
|
||||
if( node != NULL &&
|
||||
node->account_id == account_id &&
|
||||
node->account_id == account_id &&
|
||||
node->login_id1 == login_id1 &&
|
||||
node->login_id2 == login_id2 /*&&
|
||||
node->ip == ipl*/ )
|
||||
{// authentication found (coming from map server)
|
||||
sd->version = node->version;
|
||||
idb_remove(auth_db, account_id);
|
||||
sd->version = node->version;
|
||||
idb_remove(auth_db, account_id);
|
||||
char_auth_ok(fd, sd);
|
||||
}
|
||||
else
|
||||
@ -653,10 +643,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
|
||||
WFIFOL(login_fd,19) = fd;
|
||||
WFIFOSET(login_fd,23);
|
||||
} else { // if no login-server, we must refuse connection
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0;
|
||||
WFIFOSET(fd,3);
|
||||
chclif_reject(fd, 0); // rejected from server
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -694,10 +681,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
|
||||
{ //Not found?? May be forged packet.
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_FreeResult(sql_handle);
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0; // rejected from server
|
||||
WFIFOSET(fd,3);
|
||||
chclif_reject(fd, 0); // rejected from server
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -706,19 +690,13 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
|
||||
|
||||
// Prevent select a char while retrieving guild bound items
|
||||
if (sd->flag&1) {
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0; // rejected from server
|
||||
WFIFOSET(fd,3);
|
||||
chclif_reject(fd, 0); // rejected from server
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* client doesn't let it get to this point if you're banned, so its a forged packet */
|
||||
if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0; // rejected from server
|
||||
WFIFOSET(fd,3);
|
||||
chclif_reject(fd, 0); // rejected from server
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -727,11 +705,8 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
|
||||
if( !char_mmo_char_fromsql(char_id, &char_dat, true) ) { /* failed? set it back offline */
|
||||
char_set_char_offline(char_id, sd->account_id);
|
||||
/* failed to load something. REJECT! */
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = 0;
|
||||
WFIFOSET(fd,3);
|
||||
return 1;/* jump off this boat */
|
||||
chclif_reject(fd, 0); /* jump off this boat */
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Have to switch over to the DB instance otherwise data won't propagate [Kevin]
|
||||
@ -880,6 +855,20 @@ int chclif_parse_createnewchar(int fd, struct char_session_data* sd,int cmd){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform client that his deletion request was refused
|
||||
* 0x70 <ErrorCode>B HC_REFUSE_DELETECHAR
|
||||
* @param fd
|
||||
* @param ErrorCode
|
||||
* 00 = Incorrect Email address
|
||||
*/
|
||||
void chclif_refuse_delchar(int fd, uint8 errCode){
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x70;
|
||||
WFIFOB(fd,2) = errCode;
|
||||
WFIFOSET(fd,3);
|
||||
}
|
||||
|
||||
int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
|
||||
if (cmd == 0x68) FIFOSD_CHECK(46)
|
||||
else if (cmd == 0x1fb) FIFOSD_CHECK(56)
|
||||
@ -899,10 +888,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
|
||||
strcmp("a@a.com", sd->email) || //it is not default email, or
|
||||
(strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default
|
||||
)) { //Fail
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x70;
|
||||
WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
|
||||
WFIFOSET(fd,3);
|
||||
chclif_refuse_delchar(fd,0); // 00 = Incorrect Email address
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -910,10 +896,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
|
||||
ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid );
|
||||
if( i == MAX_CHARS )
|
||||
{ // Such a character does not exist in the account
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x70;
|
||||
WFIFOB(fd,2) = 0;
|
||||
WFIFOSET(fd,3);
|
||||
chclif_refuse_delchar(fd,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -927,10 +910,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
|
||||
//can't delete the char
|
||||
//either SQL error or can't delete by some CONFIG conditions
|
||||
//del fail
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd, 0) = 0x70;
|
||||
WFIFOB(fd, 2) = 0;
|
||||
WFIFOSET(fd, 3);
|
||||
chclif_refuse_delchar(fd,0);
|
||||
return 1;
|
||||
}
|
||||
/* Char successfully deleted.*/
|
||||
@ -1089,6 +1069,14 @@ int chclif_ack_captcha(int fd){
|
||||
return 1;
|
||||
}
|
||||
|
||||
// R 06C <ErrorCode>B HEADER_HC_REFUSE_ENTER
|
||||
void chclif_reject(int fd, uint8 errCode){
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x6c;
|
||||
WFIFOB(fd,2) = errCode;// rejected from server
|
||||
WFIFOSET(fd,3);
|
||||
}
|
||||
|
||||
// R 07e5 <?>.w <aid>.l
|
||||
int chclif_parse_reqcaptcha(int fd){
|
||||
//FIFOSD_CHECK(8)
|
||||
|
@ -22,6 +22,8 @@ int chclif_parse_pincode_check( int fd, struct char_session_data* sd );
|
||||
int chclif_parse_pincode_change( int fd, struct char_session_data* sd );
|
||||
int chclif_parse_pincode_setnew( int fd, struct char_session_data* sd );
|
||||
|
||||
void chclif_reject(int fd, uint8 errCode);
|
||||
void chclif_refuse_delchar(int fd, uint8 errCode);
|
||||
void chclif_charlist_notify( int fd, struct char_session_data* sd );
|
||||
void chclif_block_character( int fd, struct char_session_data* sd );
|
||||
int chclif_mmo_send006b(int fd, struct char_session_data* sd);
|
||||
|
@ -281,10 +281,7 @@ int chlogif_parse_ackaccreq(int fd, struct char_session_data* sd){
|
||||
char_auth_ok(client_fd, sd);
|
||||
break;
|
||||
case 1:// auth failed
|
||||
WFIFOHEAD(client_fd,3);
|
||||
WFIFOW(client_fd,0) = 0x6c;
|
||||
WFIFOB(client_fd,2) = 0;// rejected from server
|
||||
WFIFOSET(client_fd,3);
|
||||
chclif_reject(client_fd,0); // rejected from server
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -324,10 +321,7 @@ int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd){
|
||||
(charserv_config.max_connect_user == 0 && sd->group_id != charserv_config.gm_allow_group) ||
|
||||
( charserv_config.max_connect_user > 0 && char_count_users() >= charserv_config.max_connect_user && sd->group_id != charserv_config.gm_allow_group ) ) {
|
||||
// refuse connection (over populated)
|
||||
WFIFOHEAD(u_fd,3);
|
||||
WFIFOW(u_fd,0) = 0x6c;
|
||||
WFIFOW(u_fd,2) = 0;
|
||||
WFIFOSET(u_fd,3);
|
||||
chclif_reject(u_fd,0);
|
||||
} else {
|
||||
// send characters to player
|
||||
chclif_mmo_char_send(u_fd, sd);
|
||||
|
@ -425,6 +425,20 @@ int chmapif_parse_reqsavechar(int fd, int id){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform mapserv of a new character selection request
|
||||
* @param fd : FD link tomapserv
|
||||
* @param aid : Player account id
|
||||
* @param res : result, 0=not ok, 1=ok
|
||||
*/
|
||||
void chmapif_charselres(int fd, uint32 aid, uint8 res){
|
||||
WFIFOHEAD(fd,7);
|
||||
WFIFOW(fd,0) = 0x2b03;
|
||||
WFIFOL(fd,2) = aid;
|
||||
WFIFOB(fd,6) = res;
|
||||
WFIFOSET(fd,7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Player Requesting char-select from map_serv
|
||||
* @param fd: wich fd to parse from
|
||||
@ -442,11 +456,7 @@ int chmapif_parse_authok(int fd){
|
||||
RFIFOSKIP(fd,19);
|
||||
|
||||
if( runflag != CHARSERVER_ST_RUNNING ){
|
||||
WFIFOHEAD(fd,7);
|
||||
WFIFOW(fd,0) = 0x2b03;
|
||||
WFIFOL(fd,2) = account_id;
|
||||
WFIFOB(fd,6) = 0;// not ok
|
||||
WFIFOSET(fd,7);
|
||||
chmapif_charselres(fd,account_id,0);
|
||||
}else{
|
||||
struct auth_node* node;
|
||||
DBMap* auth_db = char_get_authdb();
|
||||
@ -473,12 +483,7 @@ int chmapif_parse_authok(int fd){
|
||||
character->pincode_success = true;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOHEAD(fd,7);
|
||||
WFIFOW(fd,0) = 0x2b03;
|
||||
WFIFOL(fd,2) = account_id;
|
||||
WFIFOB(fd,6) = 1;// ok
|
||||
WFIFOSET(fd,7);
|
||||
chmapif_charselres(fd,account_id,1);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -565,6 +570,20 @@ int chmapif_parse_req_skillcooldown(int fd){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the mapserv, of a change mapserv request
|
||||
* @param fd :Link to mapserv
|
||||
* @param nok : 0=accepted or no=1
|
||||
*/
|
||||
void chmapif_changemapserv_ack(int fd, bool nok){
|
||||
WFIFOHEAD(fd,30);
|
||||
WFIFOW(fd,0) = 0x2b06;
|
||||
memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
|
||||
if(nok)
|
||||
WFIFOL(fd,6) = 0; //Set login1 to 0.(not ok)
|
||||
WFIFOSET(fd,30);
|
||||
}
|
||||
|
||||
/**
|
||||
* Player requesting to change map-serv
|
||||
* @param fd: wich fd to parse from
|
||||
@ -624,16 +643,9 @@ int chmapif_parse_reqchangemapserv(int fd){
|
||||
data->server = map_id; //Update server where char is.
|
||||
|
||||
//Reply with an ack.
|
||||
WFIFOHEAD(fd,30);
|
||||
WFIFOW(fd,0) = 0x2b06;
|
||||
memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
|
||||
WFIFOSET(fd,30);
|
||||
chmapif_changemapserv_ack(fd,0);
|
||||
} else { //Reply with nak
|
||||
WFIFOHEAD(fd,30);
|
||||
WFIFOW(fd,0) = 0x2b06;
|
||||
memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
|
||||
WFIFOL(fd,6) = 0; //Set login1 to 0.
|
||||
WFIFOSET(fd,30);
|
||||
chmapif_changemapserv_ack(fd,1);
|
||||
}
|
||||
RFIFOSKIP(fd,39);
|
||||
}
|
||||
@ -1397,6 +1409,18 @@ int chmapif_bonus_script_save(int fd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the mapserv wheater his login attemp to us was a success or not
|
||||
* @param fd : file descriptor to parse, (link to mapserv)
|
||||
* @param errCode 0:success, 3:fail
|
||||
*/
|
||||
void chmapif_connectack(int fd, uint8 errCode){
|
||||
WFIFOHEAD(fd,3);
|
||||
WFIFOW(fd,0) = 0x2af9;
|
||||
WFIFOB(fd,2) = errCode;
|
||||
WFIFOSET(fd,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point from map-server to char-server.
|
||||
* Function that checks incoming command, then splits it to the correct handler.
|
||||
|
@ -54,6 +54,10 @@ int chmapif_parse_reqcharunban(int fd);
|
||||
int chmapif_bonus_script_get(int fd);
|
||||
int chmapif_bonus_script_save(int fd);
|
||||
|
||||
void chmapif_connectack(int fd, uint8 errCode);
|
||||
void chmapif_charselres(int fd, uint32 aid, uint8 res);
|
||||
void chmapif_changemapserv_ack(int fd, bool nok);
|
||||
|
||||
int chmapif_parse(int fd);
|
||||
int chmapif_init(int fd);
|
||||
void chmapif_server_init(int id);
|
||||
|
@ -454,7 +454,7 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// map-server change request acknowledgement (positive or negative)
|
||||
/// map-server change (mapserv) request acknowledgement (positive or negative)
|
||||
/// R 2b06 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.W
|
||||
int chrif_changemapserverack(uint32 account_id, int login_id1, int login_id2, uint32 char_id, short map_index, short x, short y, uint32 ip, uint16 port) {
|
||||
struct auth_node *node;
|
||||
@ -474,9 +474,14 @@ int chrif_changemapserverack(uint32 account_id, int login_id1, int login_id2, ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
*
|
||||
*------------------------------------------*/
|
||||
/**
|
||||
* Does the char_serv have validate our connection to him ?
|
||||
* If yes then
|
||||
* - Send all our mapname to charserv
|
||||
* - Retrieve guild castle
|
||||
* - Do OnInterIfInit and OnInterIfInitOnce on all npc
|
||||
* 0x2af9 <errCode>B
|
||||
*/
|
||||
int chrif_connectack(int fd) {
|
||||
static bool char_init_done = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user