|
@@ -139,28 +139,28 @@ struct auth_node* chrif_search(int account_id) {
|
|
|
|
|
|
struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) {
|
|
struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) {
|
|
struct auth_node *node = chrif_search(account_id);
|
|
struct auth_node *node = chrif_search(account_id);
|
|
-
|
|
|
|
|
|
+
|
|
return ( node && node->char_id == char_id && node->state == state ) ? node : NULL;
|
|
return ( node && node->char_id == char_id && node->state == state ) ? node : NULL;
|
|
}
|
|
}
|
|
|
|
|
|
bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
|
|
bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
|
|
struct auth_node *node;
|
|
struct auth_node *node;
|
|
-
|
|
|
|
|
|
+
|
|
if ( (node = chrif_auth_check(account_id, char_id, state) ) ) {
|
|
if ( (node = chrif_auth_check(account_id, char_id, state) ) ) {
|
|
int fd = node->sd ? node->sd->fd : node->fd;
|
|
int fd = node->sd ? node->sd->fd : node->fd;
|
|
-
|
|
|
|
|
|
+
|
|
if ( session[fd] && session[fd]->session_data == node->sd )
|
|
if ( session[fd] && session[fd]->session_data == node->sd )
|
|
session[fd]->session_data = NULL;
|
|
session[fd]->session_data = NULL;
|
|
-
|
|
|
|
|
|
+
|
|
if ( node->char_dat )
|
|
if ( node->char_dat )
|
|
aFree(node->char_dat);
|
|
aFree(node->char_dat);
|
|
-
|
|
|
|
|
|
+
|
|
if ( node->sd )
|
|
if ( node->sd )
|
|
aFree(node->sd);
|
|
aFree(node->sd);
|
|
-
|
|
|
|
|
|
+
|
|
ers_free(auth_db_ers, node);
|
|
ers_free(auth_db_ers, node);
|
|
idb_remove(auth_db,account_id);
|
|
idb_remove(auth_db,account_id);
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
@@ -169,14 +169,14 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
|
|
//Moves the sd character to the auth_db structure.
|
|
//Moves the sd character to the auth_db structure.
|
|
static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
|
|
static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
|
|
struct auth_node *node;
|
|
struct auth_node *node;
|
|
-
|
|
|
|
|
|
+
|
|
if ( chrif_search(sd->status.account_id) )
|
|
if ( chrif_search(sd->status.account_id) )
|
|
return false; //Already exists?
|
|
return false; //Already exists?
|
|
|
|
|
|
node = ers_alloc(auth_db_ers, struct auth_node);
|
|
node = ers_alloc(auth_db_ers, struct auth_node);
|
|
-
|
|
|
|
|
|
+
|
|
memset(node, 0, sizeof(struct auth_node));
|
|
memset(node, 0, sizeof(struct auth_node));
|
|
-
|
|
|
|
|
|
+
|
|
node->account_id = sd->status.account_id;
|
|
node->account_id = sd->status.account_id;
|
|
node->char_id = sd->status.char_id;
|
|
node->char_id = sd->status.char_id;
|
|
node->login_id1 = sd->login_id1;
|
|
node->login_id1 = sd->login_id1;
|
|
@@ -188,33 +188,33 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
|
|
node->state = state;
|
|
node->state = state;
|
|
|
|
|
|
sd->state.active = 0;
|
|
sd->state.active = 0;
|
|
-
|
|
|
|
|
|
+
|
|
idb_put(auth_db, node->account_id, node);
|
|
idb_put(auth_db, node->account_id, node);
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
static bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) {
|
|
static bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) {
|
|
-
|
|
|
|
|
|
+
|
|
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
|
|
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
|
|
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
|
|
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
|
|
if ( session[sd->fd] )
|
|
if ( session[sd->fd] )
|
|
session[sd->fd]->session_data = NULL;
|
|
session[sd->fd]->session_data = NULL;
|
|
sd->fd = 0;
|
|
sd->fd = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return chrif_sd_to_auth(sd, state);
|
|
return chrif_sd_to_auth(sd, state);
|
|
}
|
|
}
|
|
|
|
|
|
bool chrif_auth_finished(TBL_PC* sd) {
|
|
bool chrif_auth_finished(TBL_PC* sd) {
|
|
struct auth_node *node= chrif_search(sd->status.account_id);
|
|
struct auth_node *node= chrif_search(sd->status.account_id);
|
|
-
|
|
|
|
|
|
+
|
|
if ( node && node->sd == sd && node->state == ST_LOGIN ) {
|
|
if ( node && node->sd == sd && node->state == ST_LOGIN ) {
|
|
node->sd = NULL;
|
|
node->sd = NULL;
|
|
-
|
|
|
|
|
|
+
|
|
return chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
|
|
return chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
// sets char-server's user id
|
|
// sets char-server's user id
|
|
@@ -239,17 +239,17 @@ void chrif_checkdefaultlogin(void) {
|
|
// sets char-server's ip address
|
|
// sets char-server's ip address
|
|
int chrif_setip(const char* ip) {
|
|
int chrif_setip(const char* ip) {
|
|
char ip_str[16];
|
|
char ip_str[16];
|
|
-
|
|
|
|
|
|
+
|
|
if ( !( char_ip = host2ip(ip) ) ) {
|
|
if ( !( char_ip = host2ip(ip) ) ) {
|
|
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
|
|
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
safestrncpy(char_ip_str, ip, sizeof(char_ip_str));
|
|
safestrncpy(char_ip_str, ip, sizeof(char_ip_str));
|
|
-
|
|
|
|
|
|
+
|
|
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(char_ip, ip_str));
|
|
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(char_ip, ip_str));
|
|
-
|
|
|
|
|
|
+
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -290,7 +290,7 @@ int chrif_save(struct map_session_data *sd, int flag) {
|
|
if (flag)
|
|
if (flag)
|
|
sd->state.storage_flag = 0; //Force close it.
|
|
sd->state.storage_flag = 0; //Force close it.
|
|
|
|
|
|
- //Saving of registry values.
|
|
|
|
|
|
+ //Saving of registry values.
|
|
if (sd->state.reg_dirty&4)
|
|
if (sd->state.reg_dirty&4)
|
|
intif_saveregistry(sd, 3); //Save char regs
|
|
intif_saveregistry(sd, 3); //Save char regs
|
|
if (sd->state.reg_dirty&2)
|
|
if (sd->state.reg_dirty&2)
|
|
@@ -314,7 +314,7 @@ int chrif_save(struct map_session_data *sd, int flag) {
|
|
if( sd->md && mercenary_get_lifetime(sd->md) > 0 )
|
|
if( sd->md && mercenary_get_lifetime(sd->md) > 0 )
|
|
mercenary_save(sd->md);
|
|
mercenary_save(sd->md);
|
|
if( sd->ed && elemental_get_lifetime(sd->ed) > 0 )
|
|
if( sd->ed && elemental_get_lifetime(sd->ed) > 0 )
|
|
- elemental_save(sd->ed);
|
|
|
|
|
|
+ elemental_save(sd->ed);
|
|
if( sd->save_quest )
|
|
if( sd->save_quest )
|
|
intif_quest_save(sd);
|
|
intif_quest_save(sd);
|
|
|
|
|
|
@@ -339,9 +339,9 @@ int chrif_connect(int fd) {
|
|
// sends maps to char-server
|
|
// sends maps to char-server
|
|
int chrif_sendmap(int fd) {
|
|
int chrif_sendmap(int fd) {
|
|
int i;
|
|
int i;
|
|
-
|
|
|
|
|
|
+
|
|
ShowStatus("Sending maps to char server...\n");
|
|
ShowStatus("Sending maps to char server...\n");
|
|
-
|
|
|
|
|
|
+
|
|
// Sending normal maps, not instances
|
|
// Sending normal maps, not instances
|
|
WFIFOHEAD(fd, 4 + instance_start * 4);
|
|
WFIFOHEAD(fd, 4 + instance_start * 4);
|
|
WFIFOW(fd,0) = 0x2afa;
|
|
WFIFOW(fd,0) = 0x2afa;
|
|
@@ -362,12 +362,12 @@ int chrif_recvmap(int fd) {
|
|
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
|
|
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
|
|
map_setipport(RFIFOW(fd,i), ip, port);
|
|
map_setipport(RFIFOW(fd,i), ip, port);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (battle_config.etc_log)
|
|
if (battle_config.etc_log)
|
|
ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
|
|
ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
|
|
|
|
|
|
other_mapserver_count++;
|
|
other_mapserver_count++;
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -381,10 +381,10 @@ int chrif_removemap(int fd) {
|
|
map_eraseipport(RFIFOW(fd, i), ip, port);
|
|
map_eraseipport(RFIFOW(fd, i), ip, port);
|
|
|
|
|
|
other_mapserver_count--;
|
|
other_mapserver_count--;
|
|
-
|
|
|
|
|
|
+
|
|
if(battle_config.etc_log)
|
|
if(battle_config.etc_log)
|
|
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
|
|
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -420,7 +420,7 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
|
|
WFIFOL(char_fd,31) = htonl(session[sd->fd]->client_addr);
|
|
WFIFOL(char_fd,31) = htonl(session[sd->fd]->client_addr);
|
|
WFIFOL(char_fd,35) = sd->group_id;
|
|
WFIFOL(char_fd,35) = sd->group_id;
|
|
WFIFOSET(char_fd,39);
|
|
WFIFOSET(char_fd,39);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -428,7 +428,7 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
|
|
/// 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
|
|
/// 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(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) {
|
|
int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) {
|
|
struct auth_node *node;
|
|
struct auth_node *node;
|
|
-
|
|
|
|
|
|
+
|
|
if ( !( node = chrif_auth_check(account_id, char_id, ST_MAPCHANGE) ) )
|
|
if ( !( node = chrif_auth_check(account_id, char_id, ST_MAPCHANGE) ) )
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
@@ -476,7 +476,7 @@ int chrif_connectack(int fd) {
|
|
*/
|
|
*/
|
|
static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
|
|
static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
|
|
struct auth_node *node = db_data2ptr(data);
|
|
struct auth_node *node = db_data2ptr(data);
|
|
-
|
|
|
|
|
|
+
|
|
switch (node->state) {
|
|
switch (node->state) {
|
|
case ST_LOGIN:
|
|
case ST_LOGIN:
|
|
if ( node->sd && node->char_dat == NULL ) {//Since there is no way to request the char auth, make it fail.
|
|
if ( node->sd && node->char_dat == NULL ) {//Since there is no way to request the char auth, make it fail.
|
|
@@ -493,16 +493,16 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
|
|
struct map_session_data *sd = node->sd;
|
|
struct map_session_data *sd = node->sd;
|
|
uint32 ip;
|
|
uint32 ip;
|
|
uint16 port;
|
|
uint16 port;
|
|
-
|
|
|
|
|
|
+
|
|
if( map_mapname2ipport(sd->mapindex,&ip,&port) == 0 )
|
|
if( map_mapname2ipport(sd->mapindex,&ip,&port) == 0 )
|
|
chrif_changemapserver(sd, ip, port);
|
|
chrif_changemapserver(sd, ip, port);
|
|
else //too much lag/timeout is the closest explanation for this error.
|
|
else //too much lag/timeout is the closest explanation for this error.
|
|
clif_authfail_fd(sd->fd, 3);
|
|
clif_authfail_fd(sd->fd, 3);
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -510,9 +510,9 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
|
|
/// Called when all the connection steps are completed.
|
|
/// Called when all the connection steps are completed.
|
|
void chrif_on_ready(void) {
|
|
void chrif_on_ready(void) {
|
|
ShowStatus("Map Server is now online.\n");
|
|
ShowStatus("Map Server is now online.\n");
|
|
-
|
|
|
|
|
|
+
|
|
chrif_state = 2;
|
|
chrif_state = 2;
|
|
-
|
|
|
|
|
|
+
|
|
chrif_check_shutdown();
|
|
chrif_check_shutdown();
|
|
|
|
|
|
//If there are players online, send them to the char-server. [Skotlex]
|
|
//If there are players online, send them to the char-server. [Skotlex]
|
|
@@ -533,16 +533,16 @@ void chrif_on_ready(void) {
|
|
*
|
|
*
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_sendmapack(int fd) {
|
|
int chrif_sendmapack(int fd) {
|
|
-
|
|
|
|
|
|
+
|
|
if (RFIFOB(fd,2)) {
|
|
if (RFIFOB(fd,2)) {
|
|
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
|
|
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
|
|
exit(EXIT_FAILURE);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
|
|
memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
|
|
memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
|
|
-
|
|
|
|
|
|
+
|
|
chrif_on_ready();
|
|
chrif_on_ready();
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -550,7 +550,7 @@ int chrif_sendmapack(int fd) {
|
|
* Request sc_data from charserver [Skotlex]
|
|
* Request sc_data from charserver [Skotlex]
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_scdata_request(int account_id, int char_id) {
|
|
int chrif_scdata_request(int account_id, int char_id) {
|
|
-
|
|
|
|
|
|
+
|
|
#ifdef ENABLE_SC_SAVING
|
|
#ifdef ENABLE_SC_SAVING
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
@@ -560,7 +560,7 @@ int chrif_scdata_request(int account_id, int char_id) {
|
|
WFIFOL(char_fd,6) = char_id;
|
|
WFIFOL(char_fd,6) = char_id;
|
|
WFIFOSET(char_fd,10);
|
|
WFIFOSET(char_fd,10);
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -617,7 +617,7 @@ void chrif_authok(int fd) {
|
|
//Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth.
|
|
//Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth.
|
|
if ( ( sd = map_id2sd(account_id) ) != NULL )
|
|
if ( ( sd = map_id2sd(account_id) ) != NULL )
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
if ( ( node = chrif_search(account_id) ) == NULL )
|
|
if ( ( node = chrif_search(account_id) ) == NULL )
|
|
return; // should not happen
|
|
return; // should not happen
|
|
|
|
|
|
@@ -646,7 +646,7 @@ void chrif_authok(int fd) {
|
|
} else { //Auth Failed
|
|
} else { //Auth Failed
|
|
pc_authfail(sd);
|
|
pc_authfail(sd);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already.
|
|
chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already.
|
|
chrif_auth_delete(account_id, char_id, ST_LOGIN);
|
|
chrif_auth_delete(account_id, char_id, ST_LOGIN);
|
|
}
|
|
}
|
|
@@ -664,7 +664,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
|
|
sex = RFIFOB(fd,14);
|
|
sex = RFIFOB(fd,14);
|
|
|
|
|
|
node = chrif_search(account_id);
|
|
node = chrif_search(account_id);
|
|
-
|
|
|
|
|
|
+
|
|
if( node != NULL &&
|
|
if( node != NULL &&
|
|
node->account_id == account_id &&
|
|
node->account_id == account_id &&
|
|
node->char_id == char_id &&
|
|
node->char_id == char_id &&
|
|
@@ -685,7 +685,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
|
|
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
|
|
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
|
|
struct auth_node *node = db_data2ptr(data);
|
|
struct auth_node *node = db_data2ptr(data);
|
|
const char* states[] = { "Login", "Logout", "Map change" };
|
|
const char* states[] = { "Login", "Logout", "Map change" };
|
|
-
|
|
|
|
|
|
+
|
|
if(DIFF_TICK(gettick(),node->node_created)>60000) {
|
|
if(DIFF_TICK(gettick(),node->node_created)>60000) {
|
|
switch (node->state) {
|
|
switch (node->state) {
|
|
case ST_LOGOUT:
|
|
case ST_LOGOUT:
|
|
@@ -719,7 +719,7 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
|
|
|
|
|
|
if( !sd || !sd->bl.id || !sd->login_id1 )
|
|
if( !sd || !sd->bl.id || !sd->login_id1 )
|
|
return -1;
|
|
return -1;
|
|
-
|
|
|
|
|
|
+
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
WFIFOHEAD(char_fd,18);
|
|
WFIFOHEAD(char_fd,18);
|
|
@@ -737,10 +737,10 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
|
|
* Search Char trough id on char serv
|
|
* Search Char trough id on char serv
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_searchcharid(int char_id) {
|
|
int chrif_searchcharid(int char_id) {
|
|
-
|
|
|
|
|
|
+
|
|
if( !char_id )
|
|
if( !char_id )
|
|
return -1;
|
|
return -1;
|
|
-
|
|
|
|
|
|
+
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
WFIFOHEAD(char_fd,6);
|
|
WFIFOHEAD(char_fd,6);
|
|
@@ -755,7 +755,7 @@ int chrif_searchcharid(int char_id) {
|
|
* Change Email
|
|
* Change Email
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_changeemail(int id, const char *actual_email, const char *new_email) {
|
|
int chrif_changeemail(int id, const char *actual_email, const char *new_email) {
|
|
-
|
|
|
|
|
|
+
|
|
if (battle_config.etc_log)
|
|
if (battle_config.etc_log)
|
|
ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
|
|
ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
|
|
|
|
|
|
@@ -778,7 +778,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) {
|
|
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5)
|
|
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5)
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) {
|
|
int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) {
|
|
-
|
|
|
|
|
|
+
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
WFIFOHEAD(char_fd,44);
|
|
WFIFOHEAD(char_fd,44);
|
|
@@ -786,7 +786,7 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper
|
|
WFIFOL(char_fd,2) = acc;
|
|
WFIFOL(char_fd,2) = acc;
|
|
safestrncpy((char*)WFIFOP(char_fd,6), character_name, NAME_LENGTH);
|
|
safestrncpy((char*)WFIFOP(char_fd,6), character_name, NAME_LENGTH);
|
|
WFIFOW(char_fd,30) = operation_type;
|
|
WFIFOW(char_fd,30) = operation_type;
|
|
-
|
|
|
|
|
|
+
|
|
if ( operation_type == 2 ) {
|
|
if ( operation_type == 2 ) {
|
|
WFIFOW(char_fd,32) = year;
|
|
WFIFOW(char_fd,32) = year;
|
|
WFIFOW(char_fd,34) = month;
|
|
WFIFOW(char_fd,34) = month;
|
|
@@ -795,14 +795,14 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper
|
|
WFIFOW(char_fd,40) = minute;
|
|
WFIFOW(char_fd,40) = minute;
|
|
WFIFOW(char_fd,42) = second;
|
|
WFIFOW(char_fd,42) = second;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOSET(char_fd,44);
|
|
WFIFOSET(char_fd,44);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
int chrif_changesex(struct map_session_data *sd) {
|
|
int chrif_changesex(struct map_session_data *sd) {
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOHEAD(char_fd,44);
|
|
WFIFOHEAD(char_fd,44);
|
|
WFIFOW(char_fd,0) = 0x2b0e;
|
|
WFIFOW(char_fd,0) = 0x2b0e;
|
|
WFIFOL(char_fd,2) = sd->status.account_id;
|
|
WFIFOL(char_fd,2) = sd->status.account_id;
|
|
@@ -834,9 +834,9 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
|
|
struct map_session_data* sd;
|
|
struct map_session_data* sd;
|
|
char action[25];
|
|
char action[25];
|
|
char output[256];
|
|
char output[256];
|
|
-
|
|
|
|
|
|
+
|
|
sd = map_id2sd(acc);
|
|
sd = map_id2sd(acc);
|
|
-
|
|
|
|
|
|
+
|
|
if( acc < 0 || sd == NULL ) {
|
|
if( acc < 0 || sd == NULL ) {
|
|
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
|
|
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
|
|
return;
|
|
return;
|
|
@@ -854,7 +854,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
|
|
case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break;
|
|
case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break;
|
|
default: output[0] = '\0'; break;
|
|
default: output[0] = '\0'; break;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
clif_displaymessage(sd->fd, output);
|
|
clif_displaymessage(sd->fd, output);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -867,13 +867,13 @@ int chrif_changedsex(int fd) {
|
|
|
|
|
|
acc = RFIFOL(fd,2);
|
|
acc = RFIFOL(fd,2);
|
|
sex = RFIFOL(fd,6);
|
|
sex = RFIFOL(fd,6);
|
|
-
|
|
|
|
|
|
+
|
|
if ( battle_config.etc_log )
|
|
if ( battle_config.etc_log )
|
|
ShowNotice("chrif_changedsex %d.\n", acc);
|
|
ShowNotice("chrif_changedsex %d.\n", acc);
|
|
-
|
|
|
|
|
|
+
|
|
sd = map_id2sd(acc);
|
|
sd = map_id2sd(acc);
|
|
if ( sd ) { //Normally there should not be a char logged on right now!
|
|
if ( sd ) { //Normally there should not be a char logged on right now!
|
|
- if ( sd->status.sex == sex )
|
|
|
|
|
|
+ if ( sd->status.sex == sex )
|
|
return 0; //Do nothing? Likely safe.
|
|
return 0; //Do nothing? Likely safe.
|
|
sd->status.sex = !sd->status.sex;
|
|
sd->status.sex = !sd->status.sex;
|
|
|
|
|
|
@@ -952,7 +952,7 @@ int chrif_divorceack(int char_id, int partner_id) {
|
|
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
|
|
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
|
|
pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
|
|
pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
/*==========================================
|
|
/*==========================================
|
|
@@ -965,7 +965,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
|
|
sd->status.child = 0;
|
|
sd->status.child = 0;
|
|
sd->status.skill[WE_CALLBABY].id = 0;
|
|
sd->status.skill[WE_CALLBABY].id = 0;
|
|
sd->status.skill[WE_CALLBABY].lv = 0;
|
|
sd->status.skill[WE_CALLBABY].lv = 0;
|
|
- sd->status.skill[WE_CALLBABY].flag = 0;
|
|
|
|
|
|
+ sd->status.skill[WE_CALLBABY].flag = SKILL_FLAG_PERMANENT;
|
|
clif_deleteskill(sd,WE_CALLBABY);
|
|
clif_deleteskill(sd,WE_CALLBABY);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -973,7 +973,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
|
|
sd->status.child = 0;
|
|
sd->status.child = 0;
|
|
sd->status.skill[WE_CALLBABY].id = 0;
|
|
sd->status.skill[WE_CALLBABY].id = 0;
|
|
sd->status.skill[WE_CALLBABY].lv = 0;
|
|
sd->status.skill[WE_CALLBABY].lv = 0;
|
|
- sd->status.skill[WE_CALLBABY].flag = 0;
|
|
|
|
|
|
+ sd->status.skill[WE_CALLBABY].flag = SKILL_FLAG_PERMANENT;
|
|
clif_deleteskill(sd,WE_CALLBABY);
|
|
clif_deleteskill(sd,WE_CALLBABY);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -988,10 +988,10 @@ int chrif_accountban(int fd) {
|
|
struct map_session_data *sd;
|
|
struct map_session_data *sd;
|
|
|
|
|
|
acc = RFIFOL(fd,2);
|
|
acc = RFIFOL(fd,2);
|
|
-
|
|
|
|
|
|
+
|
|
if ( battle_config.etc_log )
|
|
if ( battle_config.etc_log )
|
|
ShowNotice("chrif_accountban %d.\n", acc);
|
|
ShowNotice("chrif_accountban %d.\n", acc);
|
|
-
|
|
|
|
|
|
+
|
|
sd = map_id2sd(acc);
|
|
sd = map_id2sd(acc);
|
|
|
|
|
|
if ( acc < 0 || sd == NULL ) {
|
|
if ( acc < 0 || sd == NULL ) {
|
|
@@ -1006,8 +1006,8 @@ int chrif_accountban(int fd) {
|
|
clif_displaymessage(sd->fd, msg_txt(411+ret_status));
|
|
clif_displaymessage(sd->fd, msg_txt(411+ret_status));
|
|
else if(ret_status==100)
|
|
else if(ret_status==100)
|
|
clif_displaymessage(sd->fd, msg_txt(421));
|
|
clif_displaymessage(sd->fd, msg_txt(421));
|
|
- else
|
|
|
|
- clif_displaymessage(sd->fd, msg_txt(420)); //"Your account has not more authorised."
|
|
|
|
|
|
+ else
|
|
|
|
+ clif_displaymessage(sd->fd, msg_txt(420)); //"Your account has not more authorised."
|
|
} else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban
|
|
} else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban
|
|
time_t timestamp;
|
|
time_t timestamp;
|
|
char tmpstr[2048];
|
|
char tmpstr[2048];
|
|
@@ -1031,10 +1031,10 @@ int chrif_disconnectplayer(int fd) {
|
|
sd = map_id2sd(account_id);
|
|
sd = map_id2sd(account_id);
|
|
if( sd == NULL ) {
|
|
if( sd == NULL ) {
|
|
struct auth_node* auth = chrif_search(account_id);
|
|
struct auth_node* auth = chrif_search(account_id);
|
|
-
|
|
|
|
|
|
+
|
|
if( auth != NULL && chrif_auth_delete(account_id, auth->char_id, ST_LOGIN) )
|
|
if( auth != NULL && chrif_auth_delete(account_id, auth->char_id, ST_LOGIN) )
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
|
|
+
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1061,7 +1061,7 @@ int chrif_disconnectplayer(int fd) {
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int chrif_updatefamelist(struct map_session_data* sd) {
|
|
int chrif_updatefamelist(struct map_session_data* sd) {
|
|
char type;
|
|
char type;
|
|
-
|
|
|
|
|
|
+
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
switch(sd->class_ & MAPID_UPPERMASK) {
|
|
switch(sd->class_ & MAPID_UPPERMASK) {
|
|
@@ -1101,30 +1101,30 @@ int chrif_recvfamelist(int fd) {
|
|
memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
|
|
memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
|
|
|
|
|
|
size = RFIFOW(fd, 6); //Blacksmith block size
|
|
size = RFIFOW(fd, 6); //Blacksmith block size
|
|
-
|
|
|
|
|
|
+
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
memcpy(&smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
memcpy(&smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
len += sizeof(struct fame_list);
|
|
len += sizeof(struct fame_list);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
total += num;
|
|
total += num;
|
|
|
|
|
|
size = RFIFOW(fd, 4); //Alchemist block size
|
|
size = RFIFOW(fd, 4); //Alchemist block size
|
|
-
|
|
|
|
|
|
+
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
memcpy(&chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
memcpy(&chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
len += sizeof(struct fame_list);
|
|
len += sizeof(struct fame_list);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
total += num;
|
|
total += num;
|
|
|
|
|
|
size = RFIFOW(fd, 2); //Total packet length
|
|
size = RFIFOW(fd, 2); //Total packet length
|
|
-
|
|
|
|
|
|
+
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
|
|
memcpy(&taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
memcpy(&taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
|
|
len += sizeof(struct fame_list);
|
|
len += sizeof(struct fame_list);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
total += num;
|
|
total += num;
|
|
|
|
|
|
ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);
|
|
ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);
|
|
@@ -1137,21 +1137,21 @@ int chrif_recvfamelist(int fd) {
|
|
int chrif_updatefamelist_ack(int fd) {
|
|
int chrif_updatefamelist_ack(int fd) {
|
|
struct fame_list* list;
|
|
struct fame_list* list;
|
|
uint8 index;
|
|
uint8 index;
|
|
-
|
|
|
|
|
|
+
|
|
switch (RFIFOB(fd,2)) {
|
|
switch (RFIFOB(fd,2)) {
|
|
case 1: list = smith_fame_list; break;
|
|
case 1: list = smith_fame_list; break;
|
|
case 2: list = chemist_fame_list; break;
|
|
case 2: list = chemist_fame_list; break;
|
|
case 3: list = taekwon_fame_list; break;
|
|
case 3: list = taekwon_fame_list; break;
|
|
default: return 0;
|
|
default: return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
index = RFIFOB(fd, 3);
|
|
index = RFIFOB(fd, 3);
|
|
-
|
|
|
|
|
|
+
|
|
if (index >= MAX_FAME_LIST)
|
|
if (index >= MAX_FAME_LIST)
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
|
|
+
|
|
list[index].fame = RFIFOL(fd,4);
|
|
list[index].fame = RFIFOL(fd,4);
|
|
-
|
|
|
|
|
|
+
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1166,12 +1166,12 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
|
|
|
|
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
tick = gettick();
|
|
tick = gettick();
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
|
|
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
|
|
WFIFOW(char_fd,0) = 0x2b1c;
|
|
WFIFOW(char_fd,0) = 0x2b1c;
|
|
WFIFOL(char_fd,4) = sd->status.account_id;
|
|
WFIFOL(char_fd,4) = sd->status.account_id;
|
|
WFIFOL(char_fd,8) = sd->status.char_id;
|
|
WFIFOL(char_fd,8) = sd->status.char_id;
|
|
-
|
|
|
|
|
|
+
|
|
for (i = 0; i < SC_MAX; i++) {
|
|
for (i = 0; i < SC_MAX; i++) {
|
|
if (!sc->data[i])
|
|
if (!sc->data[i])
|
|
continue;
|
|
continue;
|
|
@@ -1191,15 +1191,15 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
|
|
&data, sizeof(struct status_change_data));
|
|
&data, sizeof(struct status_change_data));
|
|
count++;
|
|
count++;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (count == 0)
|
|
if (count == 0)
|
|
return 0; //Nothing to save.
|
|
return 0; //Nothing to save.
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOW(char_fd,12) = count;
|
|
WFIFOW(char_fd,12) = count;
|
|
WFIFOW(char_fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
|
|
WFIFOW(char_fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
|
|
WFIFOSET(char_fd,WFIFOW(char_fd,2));
|
|
WFIFOSET(char_fd,WFIFOW(char_fd,2));
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1213,27 +1213,27 @@ int chrif_load_scdata(int fd) {
|
|
|
|
|
|
aid = RFIFOL(fd,4); //Player Account ID
|
|
aid = RFIFOL(fd,4); //Player Account ID
|
|
cid = RFIFOL(fd,8); //Player Char ID
|
|
cid = RFIFOL(fd,8); //Player Char ID
|
|
-
|
|
|
|
|
|
+
|
|
sd = map_id2sd(aid);
|
|
sd = map_id2sd(aid);
|
|
-
|
|
|
|
|
|
+
|
|
if ( !sd ) {
|
|
if ( !sd ) {
|
|
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
|
|
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if ( sd->status.char_id != cid ) {
|
|
if ( sd->status.char_id != cid ) {
|
|
ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid);
|
|
ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
count = RFIFOW(fd,12); //sc_count
|
|
count = RFIFOW(fd,12); //sc_count
|
|
-
|
|
|
|
|
|
+
|
|
for (i = 0; i < count; i++) {
|
|
for (i = 0; i < count; i++) {
|
|
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
|
|
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
|
|
status_change_start(NULL,&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
|
|
status_change_start(NULL,&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1250,7 +1250,7 @@ int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
|
|
WFIFOL(char_fd,6) = job_rate;
|
|
WFIFOL(char_fd,6) = job_rate;
|
|
WFIFOL(char_fd,10) = drop_rate;
|
|
WFIFOL(char_fd,10) = drop_rate;
|
|
WFIFOSET(char_fd,14);
|
|
WFIFOSET(char_fd,14);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1329,7 +1329,7 @@ void chrif_on_disconnect(void) {
|
|
if( chrif_connected != 1 )
|
|
if( chrif_connected != 1 )
|
|
ShowWarning("Connection to Char Server lost.\n\n");
|
|
ShowWarning("Connection to Char Server lost.\n\n");
|
|
chrif_connected = 0;
|
|
chrif_connected = 0;
|
|
-
|
|
|
|
|
|
+
|
|
other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
|
|
other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
|
|
map_eraseallipport();
|
|
map_eraseallipport();
|
|
|
|
|
|
@@ -1340,19 +1340,19 @@ void chrif_on_disconnect(void) {
|
|
|
|
|
|
void chrif_update_ip(int fd) {
|
|
void chrif_update_ip(int fd) {
|
|
uint32 new_ip;
|
|
uint32 new_ip;
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOHEAD(fd,6);
|
|
WFIFOHEAD(fd,6);
|
|
-
|
|
|
|
|
|
+
|
|
new_ip = host2ip(char_ip_str);
|
|
new_ip = host2ip(char_ip_str);
|
|
-
|
|
|
|
|
|
+
|
|
if (new_ip && new_ip != char_ip)
|
|
if (new_ip && new_ip != char_ip)
|
|
char_ip = new_ip; //Update char_ip
|
|
char_ip = new_ip; //Update char_ip
|
|
|
|
|
|
new_ip = clif_refresh_ip();
|
|
new_ip = clif_refresh_ip();
|
|
-
|
|
|
|
|
|
+
|
|
if (!new_ip)
|
|
if (!new_ip)
|
|
return; //No change
|
|
return; //No change
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOW(fd,0) = 0x2736;
|
|
WFIFOW(fd,0) = 0x2736;
|
|
WFIFOL(fd,2) = htonl(new_ip);
|
|
WFIFOL(fd,2) = htonl(new_ip);
|
|
WFIFOSET(fd,6);
|
|
WFIFOSET(fd,6);
|
|
@@ -1400,7 +1400,7 @@ int chrif_parse(int fd) {
|
|
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0) {
|
|
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0) {
|
|
int r = intif_parse(fd); // Passed on to the intif
|
|
int r = intif_parse(fd); // Passed on to the intif
|
|
|
|
|
|
- if (r == 1) continue; // Treated in intif
|
|
|
|
|
|
+ if (r == 1) continue; // Treated in intif
|
|
if (r == 2) return 0; // Didn't have enough data (len==-1)
|
|
if (r == 2) return 0; // Didn't have enough data (len==-1)
|
|
|
|
|
|
ShowWarning("chrif_parse: session #%d, intif_parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
|
|
ShowWarning("chrif_parse: session #%d, intif_parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
|
|
@@ -1477,20 +1477,20 @@ int send_users_tochar(void) {
|
|
chrif_check(-1);
|
|
chrif_check(-1);
|
|
|
|
|
|
users = map_usercount();
|
|
users = map_usercount();
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOHEAD(char_fd, 6+8*users);
|
|
WFIFOHEAD(char_fd, 6+8*users);
|
|
WFIFOW(char_fd,0) = 0x2aff;
|
|
WFIFOW(char_fd,0) = 0x2aff;
|
|
-
|
|
|
|
|
|
+
|
|
iter = mapit_getallusers();
|
|
iter = mapit_getallusers();
|
|
-
|
|
|
|
|
|
+
|
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) {
|
|
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) {
|
|
WFIFOL(char_fd,6+8*i) = sd->status.account_id;
|
|
WFIFOL(char_fd,6+8*i) = sd->status.account_id;
|
|
WFIFOL(char_fd,6+8*i+4) = sd->status.char_id;
|
|
WFIFOL(char_fd,6+8*i+4) = sd->status.char_id;
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
mapit_free(iter);
|
|
mapit_free(iter);
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOW(char_fd,2) = 6 + 8*users;
|
|
WFIFOW(char_fd,2) = 6 + 8*users;
|
|
WFIFOW(char_fd,4) = users;
|
|
WFIFOW(char_fd,4) = users;
|
|
WFIFOSET(char_fd, 6+8*users);
|
|
WFIFOSET(char_fd, 6+8*users);
|
|
@@ -1512,7 +1512,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
|
|
|
|
|
|
chrif_state = 0;
|
|
chrif_state = 0;
|
|
char_fd = make_connection(char_ip, char_port,false);
|
|
char_fd = make_connection(char_ip, char_port,false);
|
|
-
|
|
|
|
|
|
+
|
|
if (char_fd == -1)//Attempt to connect later. [Skotlex]
|
|
if (char_fd == -1)//Attempt to connect later. [Skotlex]
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
@@ -1546,7 +1546,7 @@ int chrif_removefriend(int char_id, int friend_id) {
|
|
WFIFOL(char_fd,2) = char_id;
|
|
WFIFOL(char_fd,2) = char_id;
|
|
WFIFOL(char_fd,6) = friend_id;
|
|
WFIFOL(char_fd,6) = friend_id;
|
|
WFIFOSET(char_fd,10);
|
|
WFIFOSET(char_fd,10);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1554,13 +1554,13 @@ void chrif_send_report(char* buf, int len) {
|
|
|
|
|
|
#ifndef STATS_OPT_OUT
|
|
#ifndef STATS_OPT_OUT
|
|
WFIFOHEAD(char_fd,len + 2);
|
|
WFIFOHEAD(char_fd,len + 2);
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOW(char_fd,0) = 0x3008;
|
|
WFIFOW(char_fd,0) = 0x3008;
|
|
-
|
|
|
|
|
|
+
|
|
memcpy(WFIFOP(char_fd,2), buf, len);
|
|
memcpy(WFIFOP(char_fd,2), buf, len);
|
|
-
|
|
|
|
|
|
+
|
|
WFIFOSET(char_fd,len + 2);
|
|
WFIFOSET(char_fd,len + 2);
|
|
-
|
|
|
|
|
|
+
|
|
flush_fifo(char_fd); /* ensure it's sent now. */
|
|
flush_fifo(char_fd); /* ensure it's sent now. */
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -1571,15 +1571,15 @@ void chrif_send_report(char* buf, int len) {
|
|
*/
|
|
*/
|
|
int auth_db_final(DBKey key, DBData *data, va_list ap) {
|
|
int auth_db_final(DBKey key, DBData *data, va_list ap) {
|
|
struct auth_node *node = db_data2ptr(data);
|
|
struct auth_node *node = db_data2ptr(data);
|
|
-
|
|
|
|
|
|
+
|
|
if (node->char_dat)
|
|
if (node->char_dat)
|
|
aFree(node->char_dat);
|
|
aFree(node->char_dat);
|
|
-
|
|
|
|
|
|
+
|
|
if (node->sd)
|
|
if (node->sd)
|
|
aFree(node->sd);
|
|
aFree(node->sd);
|
|
-
|
|
|
|
|
|
+
|
|
ers_free(auth_db_ers, node);
|
|
ers_free(auth_db_ers, node);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1587,16 +1587,16 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
|
|
* Destructor
|
|
* Destructor
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int do_final_chrif(void) {
|
|
int do_final_chrif(void) {
|
|
-
|
|
|
|
|
|
+
|
|
if( char_fd != -1 ) {
|
|
if( char_fd != -1 ) {
|
|
do_close(char_fd);
|
|
do_close(char_fd);
|
|
char_fd = -1;
|
|
char_fd = -1;
|
|
}
|
|
}
|
|
|
|
|
|
auth_db->destroy(auth_db, auth_db_final);
|
|
auth_db->destroy(auth_db, auth_db_final);
|
|
-
|
|
|
|
|
|
+
|
|
ers_destroy(auth_db_ers);
|
|
ers_destroy(auth_db_ers);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1604,7 +1604,7 @@ int do_final_chrif(void) {
|
|
*
|
|
*
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|
|
int do_init_chrif(void) {
|
|
int do_init_chrif(void) {
|
|
-
|
|
|
|
|
|
+
|
|
auth_db = idb_alloc(DB_OPT_BASE);
|
|
auth_db = idb_alloc(DB_OPT_BASE);
|
|
auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE);
|
|
auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE);
|
|
|
|
|