summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c293
1 files changed, 136 insertions, 157 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index c78b34309..a5003ab95 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -116,7 +116,6 @@ 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 *node = chrif->search(account_id);
-
return ( node && node->char_id == char_id && node->state == state ) ? node : NULL;
}
@@ -125,24 +124,23 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
if ( (node = chrif->auth_check(account_id, char_id, state) ) ) {
int fd = node->sd ? node->sd->fd : node->fd;
-
+
if ( session[fd] && session[fd]->session_data == node->sd )
session[fd]->session_data = NULL;
-
+
if ( node->sd ) {
-
if( node->sd->regs.vars )
node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy);
-
+
if( node->sd->regs.arrays )
node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db);
-
+
aFree(node->sd);
}
-
+
ers_free(chrif->auth_db_ers, node);
idb_remove(chrif->auth_db,account_id);
-
+
return true;
}
return false;
@@ -151,52 +149,52 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
//Moves the sd character to the auth_db structure.
bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
struct auth_node *node;
-
+
if ( chrif->search(sd->status.account_id) )
return false; //Already exists?
node = ers_alloc(chrif->auth_db_ers, struct auth_node);
-
+
memset(node, 0, sizeof(struct auth_node));
-
+
node->account_id = sd->status.account_id;
node->char_id = sd->status.char_id;
node->login_id1 = sd->login_id1;
node->login_id2 = sd->login_id2;
node->sex = sd->status.sex;
node->fd = sd->fd;
- node->sd = sd; //Data from logged on char.
+ node->sd = sd; //Data from logged on char.
node->node_created = timer->gettick(); //timestamp for node timeouts
node->state = state;
sd->state.active = 0;
-
+
idb_put(chrif->auth_db, node->account_id, node);
-
+
return true;
}
-bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) {
-
+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]
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
if ( session[sd->fd] )
session[sd->fd]->session_data = NULL;
sd->fd = 0;
}
-
+
return chrif->sd_to_auth(sd, state);
}
bool chrif_auth_finished(TBL_PC* sd) {
struct auth_node *node= chrif->search(sd->status.account_id);
-
+
if ( node && node->sd == sd && node->state == ST_LOGIN ) {
node->sd = NULL;
-
+
return chrif->auth_delete(node->account_id, node->char_id, ST_LOGIN);
}
-
+
return false;
}
// sets char-server's user id
@@ -221,16 +219,16 @@ void chrif_checkdefaultlogin(void) {
// sets char-server's ip address
bool chrif_setip(const char* ip) {
char ip_str[16];
-
+
if ( !( chrif->ip = host2ip(ip) ) ) {
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
return false;
}
-
+
safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str));
-
+
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str));
-
+
return true;
}
@@ -314,9 +312,9 @@ void chrif_connect(int fd) {
// sends maps to char-server
void chrif_sendmap(int fd) {
int i;
-
+
ShowStatus("Sending maps to char server...\n");
-
+
// Sending normal maps, not instances
WFIFOHEAD(fd, 4 + instance->start_id * 4);
WFIFOW(fd,0) = 0x2afa;
@@ -335,7 +333,7 @@ void chrif_recvmap(int fd) {
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
map->setipport(RFIFOW(fd,i), ip, port);
}
-
+
if (battle_config.etc_log)
ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
@@ -352,7 +350,7 @@ void chrif_removemap(int fd) {
map->eraseipport(RFIFOW(fd, i), ip, port);
chrif->other_mapserver_count--;
-
+
if(battle_config.etc_log)
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
}
@@ -389,7 +387,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port)
WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr);
WFIFOL(chrif->fd,35) = sd->group_id;
WFIFOSET(chrif->fd,39);
-
+
return true;
}
@@ -397,7 +395,7 @@ bool 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
bool 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;
-
+
if ( !( node = chrif->auth_check(account_id, char_id, ST_MAPCHANGE) ) )
return false;
@@ -436,7 +434,7 @@ void chrif_connectack(int fd) {
ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce"));
guild->castle_map_init();
}
-
+
sockt->datasync(fd, true);
chrif->skillid2idx(fd);
}
@@ -446,7 +444,7 @@ void chrif_connectack(int fd) {
*/
int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
-
+
switch (node->state) {
case ST_LOGIN:
if ( node->sd ) {//Since there is no way to request the char auth, make it fail.
@@ -463,7 +461,7 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
struct map_session_data *sd = node->sd;
uint32 ip;
uint16 port;
-
+
if( map->mapname2ipport(sd->mapindex,&ip,&port) == 0 )
chrif->changemapserver(sd, ip, port);
else //too much lag/timeout is the closest explanation for this error.
@@ -471,7 +469,6 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
break;
}
}
-
return 0;
}
@@ -480,9 +477,9 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
void chrif_on_ready(void) {
static bool once = false;
ShowStatus("Map Server is now online.\n");
-
+
chrif->state = 2;
-
+
chrif->check_shutdown();
//If there are players online, send them to the char-server. [Skotlex]
@@ -496,7 +493,7 @@ void chrif_on_ready(void) {
//Re-save any guild castles that were modified in the disconnection time.
guild->castle_reconnect(-1, 0, 0);
-
+
if( !once ) {
#ifdef AUTOTRADE_PERSISTENCY
pc->autotrade_load();
@@ -509,23 +506,23 @@ void chrif_on_ready(void) {
/*==========================================
*
*------------------------------------------*/
-void chrif_sendmapack(int fd) {
-
+void chrif_sendmapack(int fd)
+{
if (RFIFOB(fd,2)) {
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
exit(EXIT_FAILURE);
}
memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
-
+
chrif->on_ready();
}
/*==========================================
* Request sc_data from charserver [Skotlex]
*------------------------------------------*/
-bool chrif_scdata_request(int account_id, int char_id) {
-
+bool chrif_scdata_request(int account_id, int char_id)
+{
#ifdef ENABLE_SC_SAVING
chrif_check(false);
@@ -535,7 +532,6 @@ bool chrif_scdata_request(int account_id, int char_id) {
WFIFOL(chrif->fd,6) = char_id;
WFIFOSET(chrif->fd,10);
#endif
-
return true;
}
@@ -544,7 +540,7 @@ bool chrif_scdata_request(int account_id, int char_id) {
*------------------------------------------*/
void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
struct auth_node *node= chrif->search(sd->bl.id);
-
+
if( node != NULL || !chrif->isconnected() ) {
set_eof(sd->fd);
return;
@@ -621,7 +617,7 @@ void chrif_authok(int fd) {
} else { //Auth Failed
pc->authfail(sd);
}
-
+
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);
}
@@ -639,7 +635,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
sex = RFIFOB(fd,14);
node = chrif->search(account_id);
-
+
if( node != NULL &&
node->account_id == account_id &&
node->char_id == char_id &&
@@ -660,7 +656,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) {
struct auth_node *node = DB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
-
+
if(DIFF_TICK(timer->gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
@@ -694,7 +690,7 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
if( !sd->bl.id || !sd->login_id1 )
return false;
-
+
chrif_check(false);
WFIFOHEAD(chrif->fd,22);
@@ -713,10 +709,10 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
* Search Char trough id on char serv
*------------------------------------------*/
bool chrif_searchcharid(int char_id) {
-
+
if( !char_id )
return false;
-
+
chrif_check(false);
WFIFOHEAD(chrif->fd,6);
@@ -731,7 +727,7 @@ bool chrif_searchcharid(int char_id) {
* Change Email
*------------------------------------------*/
bool chrif_changeemail(int id, const char *actual_email, const char *new_email) {
-
+
if (battle_config.etc_log)
ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
@@ -753,8 +749,8 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
* type of operation:
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5), 6: charban
*------------------------------------------*/
-bool 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) {
-
+bool 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(false);
WFIFOHEAD(chrif->fd,44);
@@ -762,7 +758,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
WFIFOL(chrif->fd,2) = acc;
safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH);
WFIFOW(chrif->fd,30) = operation_type;
-
+
if ( operation_type == 2 || operation_type == 6 ) {
WFIFOW(chrif->fd,32) = year;
WFIFOW(chrif->fd,34) = month;
@@ -771,14 +767,14 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
WFIFOW(chrif->fd,40) = minute;
WFIFOW(chrif->fd,42) = second;
}
-
+
WFIFOSET(chrif->fd,44);
return true;
}
bool chrif_changesex(struct map_session_data *sd) {
chrif_check(false);
-
+
WFIFOHEAD(chrif->fd,44);
WFIFOW(chrif->fd,0) = 0x2b0e;
WFIFOL(chrif->fd,2) = sd->status.account_id;
@@ -811,9 +807,9 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
char action[25];
char output[256];
bool charsrv = ( type == 6 || type == 7 ) ? true : false;
-
+
sd = map->id2sd(acc);
-
+
if( acc < 0 || sd == NULL ) {
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
return false;
@@ -822,7 +818,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
/* re-use previous msg_txt */
if( type == 6 ) type = 2;
if( type == 7 ) type = 4;
-
+
if( type > 0 && type <= 5 )
snprintf(action,25,"%s",msg_txt(427+type)); //block|ban|unblock|unban|change the sex of
else
@@ -835,7 +831,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break;
default: output[0] = '\0'; break;
}
-
+
clif->message(sd->fd, output);
return true;
}
@@ -846,7 +842,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
void chrif_changedsex(int fd) {
int acc = RFIFOL(fd,2);
//int sex = RFIFOL(fd,6); // Dead store. Uncomment if needed again.
-
+
if ( battle_config.etc_log )
ShowNotice("chrif_changedsex %d.\n", acc);
@@ -896,7 +892,7 @@ bool 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)
pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
-
+
return true;
}
/*==========================================
@@ -932,10 +928,10 @@ void chrif_idbanned(int fd) {
struct map_session_data *sd;
id = RFIFOL(fd,2);
-
+
if ( battle_config.etc_log )
ShowNotice("chrif_idbanned %d.\n", id);
-
+
sd = ( RFIFOB(fd,6) == 2 ) ? map->charid2sd(id) : map->id2sd(id);
if ( id < 0 || sd == NULL ) {
@@ -981,10 +977,10 @@ int chrif_disconnectplayer(int fd) {
sd = map->id2sd(account_id);
if( sd == NULL ) {
struct auth_node* auth = chrif->search(account_id);
-
+
if( auth != NULL && chrif->auth_delete(account_id, auth->char_id, ST_LOGIN) )
return 0;
-
+
return -1;
}
@@ -1011,7 +1007,7 @@ int chrif_disconnectplayer(int fd) {
*------------------------------------------*/
int chrif_updatefamelist(struct map_session_data* sd) {
char type;
-
+
chrif_check(-1);
switch(sd->class_ & MAPID_UPPERMASK) {
@@ -1051,30 +1047,24 @@ void chrif_recvfamelist(int fd) {
memset(pc->taekwon_fame_list, 0, sizeof(pc->taekwon_fame_list));
size = RFIFOW(fd, 6); //Blacksmith block size
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
size = RFIFOW(fd, 4); //Alchemist block size
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
size = RFIFOW(fd, 2); //Total packet length
-
for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
memcpy(&pc->taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
- len += sizeof(struct fame_list);
+ len += sizeof(struct fame_list);
}
-
total += num;
ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);
@@ -1085,21 +1075,20 @@ void chrif_recvfamelist(int fd) {
int chrif_updatefamelist_ack(int fd) {
struct fame_list* list;
uint8 index;
-
+
switch (RFIFOB(fd,2)) {
case RANKTYPE_BLACKSMITH: list = pc->smith_fame_list; break;
case RANKTYPE_ALCHEMIST: list = pc->chemist_fame_list; break;
case RANKTYPE_TAEKWON: list = pc->taekwon_fame_list; break;
default: return 0;
}
-
+
index = RFIFOB(fd, 3);
-
if (index >= MAX_FAME_LIST)
return 0;
-
+
list[index].fame = RFIFOL(fd,4);
-
+
return 1;
}
@@ -1114,12 +1103,12 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
chrif_check(false);
tick = timer->gettick();
-
+
WFIFOHEAD(chrif->fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(chrif->fd,0) = 0x2b1c;
WFIFOL(chrif->fd,4) = sd->status.account_id;
WFIFOL(chrif->fd,8) = sd->status.char_id;
-
+
for (i = 0; i < SC_MAX; i++) {
if (!sc->data[i])
continue;
@@ -1142,15 +1131,15 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
&data, sizeof(struct status_change_data));
count++;
}
-
+
if (count == 0)
return true; //Nothing to save. | Everything was as successful as if there was something to save.
-
+
WFIFOW(chrif->fd,12) = count;
WFIFOW(chrif->fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
WFIFOSET(chrif->fd,WFIFOW(chrif->fd,2));
#endif
-
+
return true;
}
@@ -1164,30 +1153,29 @@ bool chrif_load_scdata(int fd) {
aid = RFIFOL(fd,4); //Player Account ID
cid = RFIFOL(fd,8); //Player Char ID
-
+
sd = map->id2sd(aid);
-
+
if ( !sd ) {
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
return false;
}
-
+
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);
return false;
}
-
+
count = RFIFOW(fd,12); //sc_count
-
+
for (i = 0; i < count; i++) {
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, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE);
}
-
+
pc->scdata_received(sd);
#endif
-
return true;
}
@@ -1204,7 +1192,6 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
WFIFOL(chrif->fd,6) = job_rate;
WFIFOL(chrif->fd,10) = drop_rate;
WFIFOSET(chrif->fd,14);
-
return true;
}
@@ -1270,7 +1257,7 @@ void chrif_on_disconnect(void) {
if( chrif->connected != 1 )
ShowWarning("Connection to Char Server lost.\n\n");
chrif->connected = 0;
-
+
chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
map->eraseallipport();
@@ -1281,19 +1268,19 @@ void chrif_on_disconnect(void) {
void chrif_update_ip(int fd) {
uint32 new_ip;
-
+
WFIFOHEAD(fd,6);
-
+
new_ip = host2ip(chrif->ip_str);
-
+
if (new_ip && new_ip != chrif->ip)
chrif->ip = new_ip; //Update chrif->ip
new_ip = clif->refresh_ip();
-
+
if (!new_ip)
return; //No change
-
+
WFIFOW(fd,0) = 0x2736;
WFIFOL(fd,2) = htonl(new_ip);
WFIFOSET(fd,6);
@@ -1310,12 +1297,12 @@ void chrif_keepalive_ack(int fd) {
}
void chrif_skillid2idx(int fd) {
int i, count = 0;
-
+
if( fd == 0 ) fd = chrif->fd;
-
+
if( !session_isValid(fd) )
return;
-
+
WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
WFIFOW(fd,0) = 0x2b0b;
for(i = 0; i < MAX_SKILL; i++) {
@@ -1367,12 +1354,12 @@ int chrif_parse(int fd) {
}
cmd = RFIFOW(fd,0);
-
+
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) {
r = intif->parse(fd); // Passed on to the intif
- if (r == 1) continue; // Treated in intif
- if (r == 2) return 0; // Didn't have enough data (len==-1)
+ if (r == 1) continue; // Treated in intif
+ 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);
set_eof(fd);
@@ -1448,20 +1435,18 @@ bool send_users_tochar(void) {
chrif_check(false);
users = map->usercount();
-
+
WFIFOHEAD(chrif->fd, 6+8*users);
WFIFOW(chrif->fd,0) = 0x2aff;
-
+
iter = mapit_getallusers();
-
for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) {
WFIFOL(chrif->fd,6+8*i) = sd->status.account_id;
WFIFOL(chrif->fd,6+8*i+4) = sd->status.char_id;
i++;
}
-
mapit->free(iter);
-
+
WFIFOW(chrif->fd,2) = 6 + 8*users;
WFIFOW(chrif->fd,4) = users;
WFIFOSET(chrif->fd, 6+8*users);
@@ -1471,7 +1456,7 @@ bool send_users_tochar(void) {
/*==========================================
* timerFunction
- * Check the connection to char server, (if it down)
+ * Check the connection to char server, (if it down)
*------------------------------------------*/
int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
static int displayed = 0;
@@ -1482,7 +1467,7 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
}
chrif->state = 0;
-
+
if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex]
return 0;
@@ -1507,8 +1492,8 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
/*==========================================
* Asks char server to remove friend_id from the friend list of char_id
*------------------------------------------*/
-bool chrif_removefriend(int char_id, int friend_id) {
-
+bool chrif_removefriend(int char_id, int friend_id)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,10);
@@ -1516,7 +1501,6 @@ bool chrif_removefriend(int char_id, int friend_id) {
WFIFOL(chrif->fd,2) = char_id;
WFIFOL(chrif->fd,6) = friend_id;
WFIFOSET(chrif->fd,10);
-
return true;
}
@@ -1524,13 +1508,12 @@ void chrif_send_report(char* buf, int len) {
#ifndef STATS_OPT_OUT
if( chrif->fd > 0 ) {
WFIFOHEAD(chrif->fd,len + 2);
-
+
WFIFOW(chrif->fd,0) = 0x3008;
-
memcpy(WFIFOP(chrif->fd,2), buf, len);
-
+
WFIFOSET(chrif->fd,len + 2);
-
+
flush_fifo(chrif->fd); /* ensure it's sent now. */
}
#endif
@@ -1539,13 +1522,13 @@ void chrif_send_report(char* buf, int len) {
/**
* Sends a single scdata for saving into char server, meant to ensure integrity of duration-less conditions
**/
-void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce) {
-
+void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce)
+{
if( !chrif->isconnected() )
return;
-
+
WFIFOHEAD(chrif->fd, 28);
-
+
WFIFOW(chrif->fd, 0) = 0x2740;
WFIFOL(chrif->fd, 2) = account_id;
WFIFOL(chrif->fd, 6) = char_id;
@@ -1554,46 +1537,42 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st
WFIFOL(chrif->fd, 16) = sce->val2;
WFIFOL(chrif->fd, 20) = sce->val3;
WFIFOL(chrif->fd, 24) = sce->val4;
-
+
WFIFOSET(chrif->fd, 28);
-
}
/**
* Sends a single scdata deletion request into char server, meant to ensure integrity of duration-less conditions
**/
-void chrif_del_scdata_single(int account_id, int char_id, short type) {
-
+void chrif_del_scdata_single(int account_id, int char_id, short type)
+{
if( !chrif->isconnected() ) {
ShowError("MAYDAY! failed to delete status %d from CID:%d/AID:%d\n",type,char_id,account_id);
return;
}
-
WFIFOHEAD(chrif->fd, 12);
-
+
WFIFOW(chrif->fd, 0) = 0x2741;
WFIFOL(chrif->fd, 2) = account_id;
WFIFOL(chrif->fd, 6) = char_id;
WFIFOW(chrif->fd, 10) = type;
-
- WFIFOSET(chrif->fd, 12);
+ WFIFOSET(chrif->fd, 12);
}
-/** `
+/**
* @see DBApply
*/
int auth_db_final(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
-
+
if (node->sd) {
-
if( node->sd->regs.vars )
node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy);
-
+
if( node->sd->regs.arrays )
node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db);
-
+
aFree(node->sd);
}
ers_free(chrif->auth_db_ers, node);
@@ -1604,15 +1583,15 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
/*==========================================
* Destructor
*------------------------------------------*/
-void do_final_chrif(void) {
-
+void do_final_chrif(void)
+{
if( chrif->fd != -1 ) {
do_close(chrif->fd);
chrif->fd = -1;
}
chrif->auth_db->destroy(chrif->auth_db, chrif->auth_db_final);
-
+
ers_destroy(chrif->auth_db_ers);
}
@@ -1648,12 +1627,12 @@ void do_init_chrif(bool minimal) {
*-------------------------------------*/
void chrif_defaults(void) {
const int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE] = { // 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
- 6,-1,18, 7,-1,39,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
- 6,30, -1, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
- 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->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
- -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27
+ 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, 39, 30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
+ 6, 30, -1, 0, 86, 7, 44, 34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
+ 11, 10, 10, 0, 11, 0,266, 10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->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
+ -1, 10, 8, 2, 2, 14, 19, 19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27
};
chrif = &chrif_s;
@@ -1661,7 +1640,7 @@ void chrif_defaults(void) {
/* vars */
chrif->connected = 0;
chrif->other_mapserver_count = 0;
-
+
memcpy(chrif->packet_len_table,&packet_len_table,sizeof(chrif->packet_len_table));
chrif->fd = -1;
chrif->srvinfo = 0;
@@ -1671,36 +1650,36 @@ void chrif_defaults(void) {
memset(chrif->userid,0,sizeof(chrif->userid));
memset(chrif->passwd,0,sizeof(chrif->passwd));
chrif->state = 0;
-
+
/* */
chrif->auth_db = NULL;
chrif->auth_db_ers = NULL;
/* */
chrif->init = do_init_chrif;
chrif->final = do_final_chrif;
-
+
/* funcs */
chrif->setuserid = chrif_setuserid;
chrif->setpasswd = chrif_setpasswd;
chrif->checkdefaultlogin = chrif_checkdefaultlogin;
chrif->setip = chrif_setip;
chrif->setport = chrif_setport;
-
+
chrif->isconnected = chrif_isconnected;
chrif->check_shutdown = chrif_check_shutdown;
-
+
chrif->search = chrif_search;
chrif->auth_check = chrif_auth_check;
chrif->auth_delete = chrif_auth_delete;
chrif->auth_finished = chrif_auth_finished;
-
+
chrif->authreq = chrif_authreq;
chrif->authok = chrif_authok;
chrif->scdata_request = chrif_scdata_request;
chrif->save = chrif_save;
chrif->charselectreq = chrif_charselectreq;
chrif->changemapserver = chrif_changemapserver;
-
+
chrif->searchcharid = chrif_searchcharid;
chrif->changeemail = chrif_changeemail;
chrif->char_ask_name = chrif_char_ask_name;
@@ -1715,13 +1694,13 @@ void chrif_defaults(void) {
chrif->changesex = chrif_changesex;
//chrif->chardisconnect = chrif_chardisconnect;
chrif->divorce = chrif_divorce;
-
+
chrif->removefriend = chrif_removefriend;
chrif->send_report = chrif_send_report;
-
+
chrif->flush = chrif_flush;
chrif->skillid2idx = chrif_skillid2idx;
-
+
chrif->sd_to_auth = chrif_sd_to_auth;
chrif->check_connect_char_server = check_connect_char_server;
chrif->auth_logout = chrif_auth_logout;
@@ -1732,7 +1711,7 @@ void chrif_defaults(void) {
chrif->auth_db_final = auth_db_final;
chrif->send_usercount_tochar = send_usercount_tochar;
chrif->auth_db_cleanup = auth_db_cleanup;
-
+
chrif->connect = chrif_connect;
chrif->connectack = chrif_connectack;
chrif->sendmap = chrif_sendmap;