summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-01-14 00:07:55 -0200
committerpanikon <panikon@zoho.com>2014-01-14 00:07:55 -0200
commit6860ff92acdb9a018e9085676299ef631ecea57c (patch)
tree3e255d196921bf8557e519d8a1dd1020d8a053b9 /src/map/chrif.c
parent9832e82b0e8dbda38bf4feb18e48cf5335e213ee (diff)
downloadhercules-6860ff92acdb9a018e9085676299ef631ecea57c.tar.gz
hercules-6860ff92acdb9a018e9085676299ef631ecea57c.tar.bz2
hercules-6860ff92acdb9a018e9085676299ef631ecea57c.tar.xz
hercules-6860ff92acdb9a018e9085676299ef631ecea57c.zip
Updated return values of some atcommands.
Altered many function types from int to bool(C99) and added meaningful return values. Altered many function types from int to void as they didn't have any meaningful return value. Replaced chrif_char_offline with a macro as this function did exactly the same as chrif_char_offline_nsd.
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c252
1 files changed, 109 insertions, 143 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index aaef0d6ef..964354e24 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -208,20 +208,19 @@ void chrif_checkdefaultlogin(void) {
}
// sets char-server's ip address
-int chrif_setip(const char* ip) {
+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 0;
+ 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 1;
+ return true;
}
// sets char-server's port number
@@ -239,8 +238,8 @@ int chrif_isconnected(void) {
* Flag = 1: Character is quitting
* Flag = 2: Character is changing map-servers
*------------------------------------------*/
-int chrif_save(struct map_session_data *sd, int flag) {
- nullpo_retr(-1, sd);
+bool chrif_save(struct map_session_data *sd, int flag) {
+ nullpo_ret(sd);
pc->makesavestatus(sd);
@@ -285,11 +284,11 @@ int chrif_save(struct map_session_data *sd, int flag) {
if( sd->save_quest )
intif->quest_save(sd);
- return 0;
+ return true;
}
// connects to char-server (plaintext)
-int chrif_connect(int fd) {
+void chrif_connect(int fd) {
ShowStatus("Logging in to char server...\n", chrif->fd);
WFIFOHEAD(fd,60);
WFIFOW(fd,0) = 0x2af8;
@@ -299,12 +298,10 @@ int chrif_connect(int fd) {
WFIFOL(fd,54) = htonl(clif->map_ip);
WFIFOW(fd,58) = htons(clif->map_port);
WFIFOSET(fd,60);
-
- return 0;
}
// sends maps to char-server
-int chrif_sendmap(int fd) {
+void chrif_sendmap(int fd) {
int i;
ShowStatus("Sending maps to char server...\n");
@@ -316,12 +313,10 @@ int chrif_sendmap(int fd) {
WFIFOW(fd,4+i*4) = map_id2index(i);
WFIFOW(fd,2) = 4 + i * 4;
WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
}
// receive maps from some other map-server (relayed via char-server)
-int chrif_recvmap(int fd) {
+void chrif_recvmap(int fd) {
int i, j;
uint32 ip = ntohl(RFIFOL(fd,4));
uint16 port = ntohs(RFIFOW(fd,8));
@@ -334,12 +329,10 @@ int chrif_recvmap(int fd) {
ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
chrif->other_mapserver_count++;
-
- return 0;
}
// remove specified maps (used when some other map-server disconnects)
-int chrif_removemap(int fd) {
+void chrif_removemap(int fd) {
int i, j;
uint32 ip = RFIFOL(fd,4);
uint16 port = RFIFOW(fd,8);
@@ -351,8 +344,6 @@ int chrif_removemap(int fd) {
if(battle_config.etc_log)
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
-
- return 0;
}
// received after a character has been "final saved" on the char-server
@@ -362,12 +353,12 @@ void chrif_save_ack(int fd) {
}
// request to move a character between mapservers
-int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
- nullpo_retr(-1, sd);
+bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
+ nullpo_ret(sd);
if (chrif->other_mapserver_count < 1) {//No other map servers are online!
clif->authfail_fd(sd->fd, 0);
- return -1;
+ return false;
}
chrif_check(-1);
@@ -388,19 +379,19 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
WFIFOL(chrif->fd,35) = sd->group_id;
WFIFOSET(chrif->fd,39);
- return 0;
+ return true;
}
/// map-server change 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(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) {
+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 -1;
+ return false;
if ( !login_id1 ) {
- ShowError("map server change failed.\n");
+ ShowError("chrif_changemapserverack: map server change failed.\n");
clif->authfail_fd(node->fd, 0);
} else
clif->changemapserver(node->sd, map_index, x, y, ntohl(ip), ntohs(port));
@@ -408,13 +399,13 @@ int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int c
//Player has been saved already, remove him from memory. [Skotlex]
chrif->auth_delete(account_id, char_id, ST_MAPCHANGE);
- return 0;
+ return (!login_id1)?false:true; // Is this the best approach here?
}
/*==========================================
*
*------------------------------------------*/
-int chrif_connectack(int fd) {
+void chrif_connectack(int fd) {
static bool char_init_done = false;
if (RFIFOB(fd,2)) {
@@ -437,8 +428,6 @@ int chrif_connectack(int fd) {
socket_datasync(fd, true);
chrif->skillid2idx(fd);
-
- return 0;
}
/**
@@ -451,7 +440,7 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
case ST_LOGIN:
if ( node->sd ) {//Since there is no way to request the char auth, make it fail.
pc->authfail(node->sd);
- chrif->char_offline(node->sd);
+ chrif_char_offline(node->sd);
chrif->auth_delete(node->account_id, node->char_id, ST_LOGIN);
}
break;
@@ -510,7 +499,7 @@ void chrif_on_ready(void) {
/*==========================================
*
*------------------------------------------*/
-int 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));
@@ -520,17 +509,15 @@ int chrif_sendmapack(int fd) {
memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
chrif->on_ready();
-
- return 0;
}
/*==========================================
* Request sc_data from charserver [Skotlex]
*------------------------------------------*/
-int 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(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2afc;
@@ -539,7 +526,7 @@ int chrif_scdata_request(int account_id, int char_id) {
WFIFOSET(chrif->fd,10);
#endif
- return 0;
+ return true;
}
/*==========================================
@@ -625,7 +612,7 @@ void chrif_authok(int fd) {
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);
}
@@ -690,15 +677,15 @@ int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data) {
}
/*==========================================
- *
+ * Request char selection
*------------------------------------------*/
-int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
- nullpo_retr(-1, sd);
+bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
+ nullpo_ret(sd);
- if( !sd || !sd->bl.id || !sd->login_id1 )
- return -1;
+ if( !sd->bl.id || !sd->login_id1 )
+ return false;
- chrif_check(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,18);
WFIFOW(chrif->fd, 0) = 0x2b02;
@@ -708,36 +695,36 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
WFIFOL(chrif->fd,14) = htonl(s_ip);
WFIFOSET(chrif->fd,18);
- return 0;
+ return true;
}
/*==========================================
* Search Char trough id on char serv
*------------------------------------------*/
-int chrif_searchcharid(int char_id) {
+bool chrif_searchcharid(int char_id) {
if( !char_id )
- return -1;
+ return false;
- chrif_check(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,6);
WFIFOW(chrif->fd,0) = 0x2b08;
WFIFOL(chrif->fd,2) = char_id;
WFIFOSET(chrif->fd,6);
- return 0;
+ return true;
}
/*==========================================
* Change Email
*------------------------------------------*/
-int chrif_changeemail(int id, const char *actual_email, const char *new_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);
- chrif_check(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,86);
WFIFOW(chrif->fd,0) = 0x2b0c;
@@ -746,7 +733,7 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) {
memcpy(WFIFOP(chrif->fd,46), new_email, 40);
WFIFOSET(chrif->fd,86);
- return 0;
+ return true;
}
/*==========================================
@@ -755,9 +742,9 @@ int 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
*------------------------------------------*/
-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) {
+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(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,44);
WFIFOW(chrif->fd,0) = 0x2b0e;
@@ -775,11 +762,11 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper
}
WFIFOSET(chrif->fd,44);
- return 0;
+ return true;
}
-int chrif_changesex(struct map_session_data *sd) {
- chrif_check(-1);
+bool chrif_changesex(struct map_session_data *sd) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,44);
WFIFOW(chrif->fd,0) = 0x2b0e;
@@ -794,7 +781,7 @@ int chrif_changesex(struct map_session_data *sd) {
clif->authfail_fd(sd->fd, 15);
else
map->quit(sd);
- return 0;
+ return true;
}
/*==========================================
@@ -808,7 +795,7 @@ int chrif_changesex(struct map_session_data *sd) {
* 2: gm level too low
* 3: login-server offline
*------------------------------------------*/
-void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) {
+bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) {
struct map_session_data* sd;
char action[25];
char output[256];
@@ -818,7 +805,7 @@ void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
if( acc < 0 || sd == NULL ) {
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
- return;
+ return false;
}
/* re-use previous msg_txt */
@@ -839,12 +826,13 @@ void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
}
clif->message(sd->fd, output);
+ return true;
}
/*==========================================
* Request char server to change sex of char (modified by Yor)
*------------------------------------------*/
-int chrif_changedsex(int fd) {
+void chrif_changedsex(int fd) {
int acc, sex;
struct map_session_data *sd;
@@ -857,7 +845,7 @@ int chrif_changedsex(int fd) {
sd = map->id2sd(acc);
if ( sd ) { //Normally there should not be a char logged on right now!
if ( sd->status.sex == sex )
- return 0; //Do nothing? Likely safe.
+ return; //Do nothing? Likely safe.
sd->status.sex = !sd->status.sex;
// reset skill of some job
@@ -896,13 +884,12 @@ int chrif_changedsex(int fd) {
set_eof(sd->fd); // forced to disconnect for the change
map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
}
- return 0;
}
/*==========================================
* Request Char Server to Divorce Players
*------------------------------------------*/
-int chrif_divorce(int partner_id1, int partner_id2) {
- chrif_check(-1);
+bool chrif_divorce(int partner_id1, int partner_id2) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2b11;
@@ -910,19 +897,19 @@ int chrif_divorce(int partner_id1, int partner_id2) {
WFIFOL(chrif->fd,6) = partner_id2;
WFIFOSET(chrif->fd,10);
- return 0;
+ return true;
}
/*==========================================
* Divorce players
* only used if 'partner_id' is offline
*------------------------------------------*/
-int chrif_divorceack(int char_id, int partner_id) {
+bool chrif_divorceack(int char_id, int partner_id) {
struct map_session_data* sd;
int i;
if( !char_id || !partner_id )
- return 0;
+ return false;
if( ( sd = map->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
sd->status.partner_id = 0;
@@ -938,12 +925,12 @@ int chrif_divorceack(int char_id, int partner_id) {
pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
- return 0;
+ return true;
}
/*==========================================
* Removes Baby from parents
*------------------------------------------*/
-int chrif_deadopt(int father_id, int mother_id, int child_id) {
+void chrif_deadopt(int father_id, int mother_id, int child_id) {
struct map_session_data* sd;
int idx = skill->get_index(WE_CALLBABY);
@@ -963,13 +950,12 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
clif->deleteskill(sd,WE_CALLBABY);
}
- return 0;
}
/*==========================================
* Disconnection of a player (account or char has been banned of has a status, from login or char server) by [Yor]
*------------------------------------------*/
-int chrif_idbanned(int fd) {
+void chrif_idbanned(int fd) {
int id;
struct map_session_data *sd;
@@ -982,7 +968,7 @@ int chrif_idbanned(int fd) {
if ( id < 0 || sd == NULL ) {
/* player not online or unknown id, either way no error is necessary (since if you try to ban a offline char it still works) */
- return 0;
+ return;
}
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
@@ -1012,7 +998,6 @@ int chrif_idbanned(int fd) {
set_eof(sd->fd); // forced to disconnect for the change
map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
- return 0;
}
//Disconnect the player out of the game, simple packet
@@ -1075,17 +1060,17 @@ int chrif_updatefamelist(struct map_session_data* sd) {
return 0;
}
-int chrif_buildfamelist(void) {
- chrif_check(-1);
+bool chrif_buildfamelist(void) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,2);
WFIFOW(chrif->fd,0) = 0x2b1a;
WFIFOSET(chrif->fd,2);
- return 0;
+ return true;
}
-int chrif_recvfamelist(int fd) {
+void chrif_recvfamelist(int fd) {
int num, size;
int total = 0, len = 8;
@@ -1121,8 +1106,6 @@ int chrif_recvfamelist(int fd) {
total += num;
ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);
-
- return 0;
}
/// fame ranking update confirmation
@@ -1148,7 +1131,7 @@ int chrif_updatefamelist_ack(int fd) {
return 1;
}
-int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the player and sends it to the char-server for saving. [Skotlex]
+bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the player and sends it to the char-server for saving. [Skotlex]
#ifdef ENABLE_SC_SAVING
int i, count=0;
@@ -1157,7 +1140,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
struct status_change *sc = &sd->sc;
const struct TimerData *td;
- chrif_check(-1);
+ chrif_check(false);
tick = timer->gettick();
WFIFOHEAD(chrif->fd, 14 + SC_MAX*sizeof(struct status_change_data));
@@ -1186,18 +1169,18 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
}
if (count == 0)
- return 0; //Nothing to save.
+ 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 0;
+ return true;
}
//Retrieve and load sc_data for a player. [Skotlex]
-int chrif_load_scdata(int fd) {
+bool chrif_load_scdata(int fd) {
#ifdef ENABLE_SC_SAVING
struct map_session_data *sd;
@@ -1211,12 +1194,12 @@ int chrif_load_scdata(int fd) {
if ( !sd ) {
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
- return -1;
+ 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 -1;
+ return false;
}
count = RFIFOW(fd,12); //sc_count
@@ -1229,15 +1212,15 @@ int chrif_load_scdata(int fd) {
pc->scdata_received(sd);
#endif
- return 0;
+ return true;
}
/*==========================================
* Send rates to char server [Wizputer]
* S 2b16 <base rate>.L <job rate>.L <drop rate>.L
*------------------------------------------*/
-int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
- chrif_check(-1);
+bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,14);
WFIFOW(chrif->fd,0) = 0x2b16;
@@ -1246,26 +1229,15 @@ int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
WFIFOL(chrif->fd,10) = drop_rate;
WFIFOSET(chrif->fd,14);
- return 0;
+ return true;
}
/*=========================================
* Tell char-server charcter disconnected [Wizputer]
*-----------------------------------------*/
-int chrif_char_offline(struct map_session_data *sd) {
- chrif_check(-1);
-
- WFIFOHEAD(chrif->fd,10);
- WFIFOW(chrif->fd,0) = 0x2b17;
- WFIFOL(chrif->fd,2) = sd->status.char_id;
- WFIFOL(chrif->fd,6) = sd->status.account_id;
- WFIFOSET(chrif->fd,10);
-
- return 0;
-}
-int chrif_char_offline_nsd(int account_id, int char_id) {
- chrif_check(-1);
+bool chrif_char_offline_nsd(int account_id, int char_id) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2b17;
@@ -1273,41 +1245,40 @@ int chrif_char_offline_nsd(int account_id, int char_id) {
WFIFOL(chrif->fd,6) = account_id;
WFIFOSET(chrif->fd,10);
- return 0;
+ return true;
}
/*=========================================
* Tell char-server to reset all chars offline [Wizputer]
*-----------------------------------------*/
-int chrif_flush_fifo(void) {
- chrif_check(-1);
+bool chrif_flush_fifo(void) {
+ chrif_check(false);
set_nonblocking(chrif->fd, 0);
flush_fifos();
set_nonblocking(chrif->fd, 1);
- return 0;
+ return true;
}
/*=========================================
* Tell char-server to reset all chars offline [Wizputer]
*-----------------------------------------*/
-int chrif_char_reset_offline(void) {
- chrif_check(-1);
+bool chrif_char_reset_offline(void) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,2);
WFIFOW(chrif->fd,0) = 0x2b18;
WFIFOSET(chrif->fd,2);
- return 0;
+ return true;
}
/*=========================================
* Tell char-server charcter is online [Wizputer]
*-----------------------------------------*/
-
-int chrif_char_online(struct map_session_data *sd) {
- chrif_check(-1);
+bool chrif_char_online(struct map_session_data *sd) {
+ chrif_check(false);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2b19;
@@ -1315,10 +1286,9 @@ int chrif_char_online(struct map_session_data *sd) {
WFIFOL(chrif->fd,6) = sd->status.account_id;
WFIFOSET(chrif->fd,10);
- return 0;
+ return true;
}
-
/// Called when the connection to Char Server is disconnected.
void chrif_on_disconnect(void) {
if( chrif->connected != 1 )
@@ -1390,18 +1360,18 @@ int chrif_parse(int fd) {
if ( fd != chrif->fd ) {
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd);
do_close(fd);
- return 0;
+ return false;
}
if ( session[fd]->flag.eof ) {
do_close(fd);
chrif->fd = -1;
chrif->on_disconnect();
- return 0;
+ return false;
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
if( DIFF_TICK(last_tick, session[fd]->rdata_tick) > (stall_time * 2) ) {/* we can't wait any longer */
set_eof(fd);
- return 0;
+ return false;
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
chrif->keepalive(fd);
session[fd]->flag.ping = 2;
@@ -1413,7 +1383,7 @@ int chrif_parse(int fd) {
if( HPM->packetsc[hpChrif_Parse] ) {
if( (r = HPM->parse_packets(fd,hpChrif_Parse)) ) {
if( r == 1 ) continue;
- if( r == 2 ) return 0;
+ if( r == 2 ) return false;
}
}
@@ -1422,22 +1392,22 @@ int chrif_parse(int fd) {
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 false; // 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);
- return 0;
+ return false;
}
if ( ( packet_len = chrif->packet_len_table[cmd-0x2af8] ) == -1) { // dynamic-length packet, second WORD holds the length
if (RFIFOREST(fd) < 4)
- return 0;
+ return false;
packet_len = RFIFOW(fd,2);
}
if ((int)RFIFOREST(fd) < packet_len)
- return 0;
+ return false;
//ShowDebug("Received packet 0x%4x (%d bytes) from char-server (connection %d)\n", RFIFOW(fd,0), packet_len, fd);
@@ -1468,13 +1438,13 @@ int chrif_parse(int fd) {
default:
ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd);
set_eof(fd);
- return 0;
+ return false;
}
if ( fd == chrif->fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex]
RFIFOSKIP(fd, packet_len);
}
- return 0;
+ return true;
}
int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) {
@@ -1491,12 +1461,12 @@ int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) {
* timerFunction
* Send to char the number of client connected to map
*------------------------------------------*/
-int send_users_tochar(void) {
+bool send_users_tochar(void) {
int users = 0, i = 0;
struct map_session_data* sd;
struct s_mapiterator* iter;
- chrif_check(-1);
+ chrif_check(false);
users = map->usercount();
@@ -1517,12 +1487,12 @@ int send_users_tochar(void) {
WFIFOW(chrif->fd,4) = users;
WFIFOSET(chrif->fd, 6+8*users);
- return 0;
+ return true;
}
/*==========================================
* timerFunction
- * Chk 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;
@@ -1558,9 +1528,9 @@ 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
*------------------------------------------*/
-int chrif_removefriend(int char_id, int friend_id) {
+bool chrif_removefriend(int char_id, int friend_id) {
- chrif_check(-1);
+ chrif_check(false);
WFIFOHEAD(chrif->fd,10);
WFIFOW(chrif->fd,0) = 0x2b07;
@@ -1568,7 +1538,7 @@ int chrif_removefriend(int char_id, int friend_id) {
WFIFOL(chrif->fd,6) = friend_id;
WFIFOSET(chrif->fd,10);
- return 0;
+ return true;
}
void chrif_send_report(char* buf, int len) {
@@ -1597,14 +1567,14 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
aFree(node->sd);
ers_free(chrif->auth_db_ers, node);
-
+
return 0;
}
/*==========================================
* Destructor
*------------------------------------------*/
-int do_final_chrif(void) {
+void do_final_chrif(void) {
if( chrif->fd != -1 ) {
do_close(chrif->fd);
@@ -1614,16 +1584,14 @@ int do_final_chrif(void) {
chrif->auth_db->destroy(chrif->auth_db, chrif->auth_db_final);
ers_destroy(chrif->auth_db_ers);
-
- return 0;
}
/*==========================================
*
*------------------------------------------*/
-int do_init_chrif(bool minimal) {
+void do_init_chrif(bool minimal) {
if (minimal)
- return 0;
+ return;
chrif->auth_db = idb_alloc(DB_OPT_BASE);
chrif->auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE);
@@ -1640,8 +1608,6 @@ int do_init_chrif(bool minimal) {
// send the user count every 10 seconds, to hide the charserver's online counting problem
timer->add_interval(timer->gettick() + 1000, chrif->send_usercount_tochar, 0, 0, UPDATE_INTERVAL);
-
- return 0;
}
@@ -1712,7 +1678,7 @@ void chrif_defaults(void) {
chrif->buildfamelist = chrif_buildfamelist;
chrif->save_scdata = chrif_save_scdata;
chrif->ragsrvinfo = chrif_ragsrvinfo;
- chrif->char_offline = chrif_char_offline;
+ //chrif->char_offline = chrif_char_offline;
chrif->char_offline_nsd = chrif_char_offline_nsd;
chrif->char_reset_offline = chrif_char_reset_offline;
chrif->send_users_tochar = send_users_tochar;