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.c281
1 files changed, 167 insertions, 114 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 52af1137e..b131907e0 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
*/
#define HERCULES_CORE
-#include "config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT
+#include "config/core.h" // AUTOTRADE_PERSISTENCY
#include "chrif.h"
#include "map/battle.h"
@@ -53,7 +53,7 @@
#include <stdlib.h>
#include <sys/types.h>
-struct chrif_interface chrif_s;
+static struct chrif_interface chrif_s;
struct chrif_interface *chrif;
//Used Packets:
@@ -109,18 +109,21 @@ struct chrif_interface *chrif;
//This define should spare writing the check in every function. [Skotlex]
#define chrif_check(a) do { if(!chrif->isconnected()) return a; } while(0)
+#if 0 // Unused
/// Resets all the data.
-void chrif_reset(void) __attribute__ ((noreturn));
-void chrif_reset(void)
+static void chrif_reset(void) __attribute__ ((noreturn));
+static void chrif_reset(void)
{
// TODO kick everyone out and reset everything [FlavioJS]
exit(EXIT_FAILURE);
}
+#endif // 0
/// Checks the conditions for the server to stop.
/// Releases the cookie when all characters are saved.
/// If all the conditions are met, it stops the core loop.
-void chrif_check_shutdown(void) {
+static void chrif_check_shutdown(void)
+{
if( core->runflag != MAPSERVER_ST_SHUTDOWN )
return;
if( db_size(chrif->auth_db) > 0 )
@@ -128,16 +131,19 @@ void chrif_check_shutdown(void) {
core->runflag = CORE_ST_STOP;
}
-struct auth_node* chrif_search(int account_id) {
+static struct auth_node* chrif_search(int account_id)
+{
return (struct auth_node*)idb_get(chrif->auth_db, account_id);
}
-struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) {
+static 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;
}
-bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
+static bool chrif_auth_delete(int account_id, int char_id, enum sd_state state)
+{
struct auth_node *node;
if ( (node = chrif->auth_check(account_id, char_id, state) ) ) {
@@ -165,7 +171,7 @@ 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(struct map_session_data *sd, enum sd_state state)
+static bool chrif_sd_to_auth(struct map_session_data *sd, enum sd_state state)
{
struct auth_node *node;
@@ -194,7 +200,7 @@ bool chrif_sd_to_auth(struct map_session_data *sd, enum sd_state state)
return true;
}
-bool chrif_auth_logout(struct map_session_data *sd, enum sd_state state)
+static bool chrif_auth_logout(struct map_session_data *sd, enum sd_state state)
{
nullpo_retr(false, sd);
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
@@ -207,7 +213,7 @@ bool chrif_auth_logout(struct map_session_data *sd, enum sd_state state)
return chrif->sd_to_auth(sd, state);
}
-bool chrif_auth_finished(struct map_session_data *sd)
+static bool chrif_auth_finished(struct map_session_data *sd)
{
struct auth_node *node;
@@ -223,28 +229,34 @@ bool chrif_auth_finished(struct map_session_data *sd)
}
// sets char-server's user id
-void chrif_setuserid(char *id) {
+static void chrif_setuserid(char *id)
+{
nullpo_retv(id);
memcpy(chrif->userid, id, NAME_LENGTH);
}
// sets char-server's password
-void chrif_setpasswd(char *pwd) {
+static void chrif_setpasswd(char *pwd)
+{
nullpo_retv(pwd);
memcpy(chrif->passwd, pwd, NAME_LENGTH);
}
// security check, prints warning if using default password
-void chrif_checkdefaultlogin(void) {
+static void chrif_checkdefaultlogin(void)
+{
+#ifndef BUILDBOT
if (strcmp(chrif->userid, "s1")==0 && strcmp(chrif->passwd, "p1")==0) {
ShowWarning("Using the default user/password s1/p1 is NOT RECOMMENDED.\n");
ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n");
ShowNotice("and then edit your user/password in conf/map-server.conf (or conf/import/map_conf.txt)\n");
}
+#endif
}
// sets char-server's ip address
-bool chrif_setip(const char* ip) {
+static bool chrif_setip(const char *ip)
+{
char ip_str[16];
nullpo_retr(false, ip);
@@ -261,12 +273,14 @@ bool chrif_setip(const char* ip) {
}
// sets char-server's port number
-void chrif_setport(uint16 port) {
+static void chrif_setport(uint16 port)
+{
chrif->port = port;
}
// says whether the char-server is connected or not
-int chrif_isconnected(void) {
+static int chrif_isconnected(void)
+{
return (chrif->fd > 0 && sockt->session[chrif->fd] != NULL && chrif->state == 2);
}
@@ -276,7 +290,8 @@ int chrif_isconnected(void) {
* Flag = 2: Character is changing map-servers
*------------------------------------------*/
// TODO: Flag enum
-bool chrif_save(struct map_session_data *sd, int flag) {
+static bool chrif_save(struct map_session_data *sd, int flag)
+{
nullpo_ret(sd);
pc->makesavestatus(sd);
@@ -321,12 +336,18 @@ bool chrif_save(struct map_session_data *sd, int flag) {
elemental->save(sd->ed);
if( sd->save_quest )
intif->quest_save(sd);
+ if (VECTOR_LENGTH(sd->achievement) > 0)
+ intif->achievements_save(sd);
+
+ if (sd->storage.received == true && sd->storage.save == true)
+ intif->send_account_storage(sd);
return true;
}
// connects to char-server (plaintext)
-void chrif_connect(int fd) {
+static void chrif_connect(int fd)
+{
ShowStatus("Logging in to char server...\n");
WFIFOHEAD(fd,60);
WFIFOW(fd,0) = 0x2af8;
@@ -339,7 +360,8 @@ void chrif_connect(int fd) {
}
// sends maps to char-server
-void chrif_sendmap(int fd) {
+static void chrif_sendmap(int fd)
+{
int i;
ShowStatus("Sending maps to char server...\n");
@@ -354,7 +376,8 @@ void chrif_sendmap(int fd) {
}
// receive maps from some other map-server (relayed via char-server)
-void chrif_recvmap(int fd) {
+static void chrif_recvmap(int fd)
+{
int i, j;
uint32 ip = ntohl(RFIFOL(fd,4));
uint16 port = ntohs(RFIFOW(fd,8));
@@ -370,7 +393,8 @@ void chrif_recvmap(int fd) {
}
// remove specified maps (used when some other map-server disconnects)
-void chrif_removemap(int fd) {
+static void chrif_removemap(int fd)
+{
int i, j;
uint32 ip = RFIFOL(fd,4);
uint16 port = RFIFOW(fd,8);
@@ -385,13 +409,15 @@ void chrif_removemap(int fd) {
}
// received after a character has been "final saved" on the char-server
-void chrif_save_ack(int fd) {
+static void chrif_save_ack(int fd)
+{
chrif->auth_delete(RFIFOL(fd,2), RFIFOL(fd,6), ST_LOGOUT);
chrif->check_shutdown();
}
// request to move a character between mapservers
-bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) {
+static 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!
@@ -422,7 +448,8 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port)
/// map-server change request acknowledgment (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
-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) {
+static 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) ) )
@@ -432,7 +459,7 @@ bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int
ShowError("chrif_changemapserverack: map server change failed.\n");
clif->authfail_fd(node->fd, 0); // Disconnected from server
} else
- clif->changemapserver(node->sd, map_index, x, y, ntohl(ip), ntohs(port));
+ clif->changemapserver(node->sd, map_index, x, y, ntohl(ip), ntohs(port), NULL);
//Player has been saved already, remove him from memory. [Skotlex]
chrif->auth_delete(account_id, char_id, ST_MAPCHANGE);
@@ -443,7 +470,8 @@ bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int
/*==========================================
*
*------------------------------------------*/
-void chrif_connectack(int fd) {
+static void chrif_connectack(int fd)
+{
static bool char_init_done = false;
if (RFIFOB(fd,2)) {
@@ -471,7 +499,7 @@ void chrif_connectack(int fd) {
/**
* @see DBApply
*/
-int chrif_reconnect(union DBKey key, struct DBData *data, va_list ap)
+static int chrif_reconnect(union DBKey key, struct DBData *data, va_list ap)
{
struct auth_node *node = DB->data2ptr(data);
@@ -504,7 +532,8 @@ int chrif_reconnect(union DBKey key, struct DBData *data, va_list ap)
}
/// Called when all the connection steps are completed.
-void chrif_on_ready(void) {
+static void chrif_on_ready(void)
+{
static bool once = false;
ShowStatus("Map Server is now online.\n");
@@ -535,7 +564,7 @@ void chrif_on_ready(void) {
/*==========================================
*
*------------------------------------------*/
-void chrif_sendmapack(int fd)
+static void chrif_sendmapack(int fd)
{
if (RFIFOB(fd,2)) {
ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2));
@@ -550,7 +579,7 @@ void chrif_sendmapack(int fd)
/*==========================================
* Request sc_data from charserver [Skotlex]
*------------------------------------------*/
-bool chrif_scdata_request(int account_id, int char_id)
+static bool chrif_scdata_request(int account_id, int char_id)
{
#ifdef ENABLE_SC_SAVING
chrif_check(false);
@@ -567,7 +596,8 @@ bool chrif_scdata_request(int account_id, int char_id)
/*==========================================
* Request auth confirmation
*------------------------------------------*/
-void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
+static void chrif_authreq(struct map_session_data *sd, bool hstandalone)
+{
struct auth_node *node= chrif->search(sd->bl.id);
nullpo_retv(sd);
@@ -591,7 +621,8 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
/*==========================================
* Auth confirmation ack
*------------------------------------------*/
-void chrif_authok(int fd) {
+static void chrif_authok(int fd)
+{
int account_id, group_id, char_id;
uint32 login_id1,login_id2;
time_t expiration_time;
@@ -653,7 +684,9 @@ void chrif_authok(int fd) {
}
// client authentication failed
-void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (but is available) */
+static void chrif_authfail(int fd)
+{
+ /* HELLO WORLD. ip in RFIFOL 15 is not being used (but is available) */
int account_id, char_id;
uint32 login_id1;
char sex;
@@ -682,7 +715,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
* This can still happen (client times out while waiting for char to confirm auth data)
* @see DBApply
*/
-int auth_db_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
+static int auth_db_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
{
struct auth_node *node = DB->data2ptr(data);
@@ -707,7 +740,8 @@ int auth_db_cleanup_sub(union DBKey key, struct DBData *data, va_list ap)
return 0;
}
-int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data) {
+static int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data)
+{
chrif_check(0);
chrif->auth_db->foreach(chrif->auth_db, chrif->auth_db_cleanup_sub);
return 0;
@@ -716,7 +750,8 @@ int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data) {
/*==========================================
* Request char selection
*------------------------------------------*/
-bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
+static bool chrif_charselectreq(struct map_session_data *sd, uint32 s_ip)
+{
nullpo_ret(sd);
if( !sd->bl.id || !sd->login_id1 )
@@ -739,7 +774,8 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) {
/*==========================================
* Search Char trough id on char serv
*------------------------------------------*/
-bool chrif_searchcharid(int char_id) {
+static bool chrif_searchcharid(int char_id)
+{
if( !char_id )
return false;
@@ -757,7 +793,8 @@ bool chrif_searchcharid(int char_id) {
/*==========================================
* Change Email
*------------------------------------------*/
-bool chrif_changeemail(int id, const char *actual_email, const char *new_email) {
+static 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);
@@ -790,7 +827,7 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email)
* charunban { n/a }
* changecharsex { <sex>.b } -- use chrif_changesex
*------------------------------------------*/
-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)
+static 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)
{
nullpo_retr(false, character_name);
chrif_check(false);
@@ -821,7 +858,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope
* @param change_account Whether to change the per-account sex.
* @retval true.
*/
-bool chrif_changesex(struct map_session_data *sd, bool change_account)
+static bool chrif_changesex(struct map_session_data *sd, bool change_account)
{
nullpo_retr(false, sd);
chrif_check(false);
@@ -850,7 +887,8 @@ bool chrif_changesex(struct map_session_data *sd, bool change_account)
* type of operation: @see chrif_char_ask_name
* type of answer: @see hz_char_ask_name_answer
*------------------------------------------*/
-bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) {
+static 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];
@@ -888,7 +926,8 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u
/*==========================================
* Request char server to change sex of char (modified by Yor)
*------------------------------------------*/
-void chrif_changedsex(int fd) {
+static void chrif_changedsex(int fd)
+{
int acc = RFIFOL(fd,2);
//int sex = RFIFOL(fd,6); // Dead store. Uncomment if needed again.
@@ -905,10 +944,12 @@ void chrif_changedsex(int fd) {
// of this process, but there's no need to perform map-server specific response
// as everything should been changed through char-server [Panikon]
}
+
/*==========================================
* Request Char Server to Divorce Players
*------------------------------------------*/
-bool chrif_divorce(int partner_id1, int partner_id2) {
+static bool chrif_divorce(int partner_id1, int partner_id2)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,10);
@@ -924,7 +965,8 @@ bool chrif_divorce(int partner_id1, int partner_id2) {
* Divorce players
* only used if 'partner_id' is offline
*------------------------------------------*/
-bool chrif_divorceack(int char_id, int partner_id) {
+static bool chrif_divorceack(int char_id, int partner_id)
+{
struct map_session_data* sd;
int i;
@@ -933,24 +975,26 @@ bool chrif_divorceack(int char_id, int partner_id) {
if( ( sd = map->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
sd->status.partner_id = 0;
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (i = 0; i < sd->status.inventorySize; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
}
if( ( sd = map->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
sd->status.partner_id = 0;
- for(i = 0; i < MAX_INVENTORY; i++)
+ for (i = 0; i < sd->status.inventorySize; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_DIVORCE);
}
return true;
}
+
/*==========================================
* Removes Baby from parents
*------------------------------------------*/
-void chrif_deadopt(int father_id, int mother_id, int child_id) {
+static void chrif_deadopt(int father_id, int mother_id, int child_id)
+{
struct map_session_data* sd;
int idx = skill->get_index(WE_CALLBABY);
@@ -975,7 +1019,8 @@ void chrif_deadopt(int father_id, int mother_id, int child_id) {
/*==========================================
* Disconnection of a player (account or char has been banned of has a status, from login or char server) by [Yor]
*------------------------------------------*/
-void chrif_idbanned(int fd) {
+static void chrif_idbanned(int fd)
+{
int id;
struct map_session_data *sd;
@@ -997,9 +1042,9 @@ void chrif_idbanned(int fd) {
if(0<ret_status && ret_status<=9)
clif->message(sd->fd, msg_sd(sd,411+ret_status)); // Message IDs (for search convenience): 412, 413, 414, 415, 416, 417, 418, 419, 420
else if(ret_status==100)
- clif->message(sd->fd, msg_sd(sd,421));
+ clif->message(sd->fd, msg_sd(sd,421)); // Your account has been totally erased.
else
- clif->message(sd->fd, msg_sd(sd,420)); //"Your account has not more authorized."
+ clif->message(sd->fd, msg_sd(sd,420)); //"Your account is not longer authorized."
} else if (RFIFOB(fd,6) == 1) { // 1: ban
time_t timestamp;
char tmpstr[2048];
@@ -1022,7 +1067,8 @@ void chrif_idbanned(int fd) {
//Disconnect the player out of the game, simple packet
//packet.w AID.L WHY.B 2+4+1 = 7byte
-int chrif_disconnectplayer(int fd) {
+static int chrif_disconnectplayer(int fd)
+{
struct map_session_data* sd;
int account_id = RFIFOL(fd, 2);
@@ -1057,19 +1103,17 @@ int chrif_disconnectplayer(int fd) {
/*==========================================
* Request/Receive top 10 Fame character list
*------------------------------------------*/
-int chrif_updatefamelist(struct map_session_data* sd) {
- char type;
+static int chrif_updatefamelist(struct map_session_data *sd)
+{
+ int type;
nullpo_retr(0, sd);
chrif_check(-1);
- switch(sd->class_ & MAPID_UPPERMASK) {
- case MAPID_BLACKSMITH: type = RANKTYPE_BLACKSMITH; break;
- case MAPID_ALCHEMIST: type = RANKTYPE_ALCHEMIST; break;
- case MAPID_TAEKWON: type = RANKTYPE_TAEKWON; break;
- default:
- return 0;
- }
+ type = pc->famelist_type(sd->job);
+
+ if (type == RANKTYPE_UNKNOWN)
+ return 0;
WFIFOHEAD(chrif->fd, 11);
WFIFOW(chrif->fd,0) = 0x2b10;
@@ -1081,7 +1125,8 @@ int chrif_updatefamelist(struct map_session_data* sd) {
return 0;
}
-bool chrif_buildfamelist(void) {
+static bool chrif_buildfamelist(void)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,2);
@@ -1091,7 +1136,8 @@ bool chrif_buildfamelist(void) {
return true;
}
-void chrif_recvfamelist(int fd) {
+static void chrif_recvfamelist(int fd)
+{
int num, size;
int total = 0, len = 8;
@@ -1125,7 +1171,8 @@ void chrif_recvfamelist(int fd) {
/// fame ranking update confirmation
/// R 2b22 <table>.B <index>.B <value>.L
-int chrif_updatefamelist_ack(int fd) {
+static int chrif_updatefamelist_ack(int fd)
+{
struct fame_list* list;
uint8 index;
@@ -1145,8 +1192,9 @@ int chrif_updatefamelist_ack(int fd) {
return 1;
}
-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]
-
+//parses the sc_data of the player and sends it to the char-server for saving. [Skotlex]
+static bool chrif_save_scdata(struct map_session_data *sd)
+{
#ifdef ENABLE_SC_SAVING
int i, count=0;
int64 tick;
@@ -1178,6 +1226,7 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
} else {
data.tick = INFINITE_DURATION;
}
+ data.total_tick = sc->data[i]->total_tick;
data.type = i;
data.val1 = sc->data[i]->val1;
data.val2 = sc->data[i]->val2;
@@ -1200,8 +1249,8 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th
}
//Retrieve and load sc_data for a player. [Skotlex]
-bool chrif_load_scdata(int fd) {
-
+static bool chrif_load_scdata(int fd)
+{
#ifdef ENABLE_SC_SAVING
struct map_session_data *sd;
int aid, cid, i, count;
@@ -1225,8 +1274,8 @@ bool chrif_load_scdata(int fd) {
for (i = 0; i < count; i++) {
const struct status_change_data *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);
+ status->change_start_sub(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4,
+ data->tick, data->total_tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE);
}
pc->scdata_received(sd);
@@ -1238,7 +1287,8 @@ bool chrif_load_scdata(int fd) {
* Send rates to char server [Wizputer]
* S 2b16 <base rate>.L <job rate>.L <drop rate>.L
*------------------------------------------*/
-bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
+static bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,14);
@@ -1253,7 +1303,8 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
/*=========================================
* Tell char-server character disconnected [Wizputer]
*-----------------------------------------*/
-bool chrif_char_offline_nsd(int account_id, int char_id) {
+static bool chrif_char_offline_nsd(int account_id, int char_id)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,10);
@@ -1268,7 +1319,8 @@ bool chrif_char_offline_nsd(int account_id, int char_id) {
/*=========================================
* Tell char-server to reset all chars offline [Wizputer]
*-----------------------------------------*/
-bool chrif_flush(void) {
+static bool chrif_flush(void)
+{
chrif_check(false);
sockt->set_nonblocking(chrif->fd, 0);
@@ -1281,7 +1333,8 @@ bool chrif_flush(void) {
/*=========================================
* Tell char-server to reset all chars offline [Wizputer]
*-----------------------------------------*/
-bool chrif_char_reset_offline(void) {
+static bool chrif_char_reset_offline(void)
+{
chrif_check(false);
WFIFOHEAD(chrif->fd,2);
@@ -1294,7 +1347,8 @@ bool chrif_char_reset_offline(void) {
/*=========================================
* Tell char-server character is online [Wizputer]. Look like unused.
*-----------------------------------------*/
-bool chrif_char_online(struct map_session_data *sd) {
+static bool chrif_char_online(struct map_session_data *sd)
+{
chrif_check(false);
nullpo_retr(false, sd);
@@ -1308,7 +1362,8 @@ bool chrif_char_online(struct map_session_data *sd) {
}
/// Called when the connection to Char Server is disconnected.
-void chrif_on_disconnect(void) {
+static void chrif_on_disconnect(void)
+{
if( chrif->connected != 1 )
ShowWarning("Connection to Char Server lost.\n\n");
chrif->connected = 0;
@@ -1320,7 +1375,8 @@ void chrif_on_disconnect(void) {
timer->add(timer->gettick() + 1000, chrif->check_connect_char_server, 0, 0);
}
-void chrif_update_ip(int fd) {
+static void chrif_update_ip(int fd)
+{
uint32 new_ip;
WFIFOHEAD(fd,6);
@@ -1341,15 +1397,20 @@ void chrif_update_ip(int fd) {
}
// pings the charserver ( since on-demand flag.ping was introduced, shouldn't this be dropped? only wasting traffic and processing [Ind])
-void chrif_keepalive(int fd) {
+static void chrif_keepalive(int fd)
+{
WFIFOHEAD(fd,2);
WFIFOW(fd,0) = 0x2b23;
WFIFOSET(fd,2);
}
-void chrif_keepalive_ack(int fd) {
+
+static void chrif_keepalive_ack(int fd)
+{
sockt->session[fd]->flag.ping = 0;/* reset ping state, we received a packet */
}
-void chrif_skillid2idx(int fd) {
+
+static void chrif_skillid2idx(int fd)
+{
int i, count = 0;
if( fd == 0 ) fd = chrif->fd;
@@ -1357,11 +1418,11 @@ void chrif_skillid2idx(int fd) {
if (!sockt->session_is_valid(fd))
return;
- WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
+ WFIFOHEAD(fd,4 + (MAX_SKILL_DB * 4));
WFIFOW(fd,0) = 0x2b0b;
- for(i = 0; i < MAX_SKILL; i++) {
- if( skill->dbs->db[i].nameid ) {
- WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid;
+ for (i = 0; i < MAX_SKILL_DB; i++) {
+ if (skill->dbs->db[i].nameid != 0) {
+ WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid; // really skill id
WFIFOW(fd, 6 + (count*4)) = i;
count++;
}
@@ -1370,10 +1431,12 @@ void chrif_skillid2idx(int fd) {
WFIFOSET(fd,4 + (count * 4));
}
+
/*==========================================
*
*------------------------------------------*/
-int chrif_parse(int fd) {
+static int chrif_parse(int fd)
+{
int packet_len, cmd;
// only process data from the char-server
@@ -1467,7 +1530,8 @@ int chrif_parse(int fd) {
return 0;
}
-int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) {
+static int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data)
+{
chrif_check(-1);
WFIFOHEAD(chrif->fd,4);
@@ -1481,7 +1545,8 @@ int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) {
* timerFunction
* Send to char the number of client connected to map
*------------------------------------------*/
-bool send_users_tochar(void) {
+static bool send_users_tochar(void)
+{
int users = 0, i = 0;
const struct map_session_data *sd;
struct s_mapiterator *iter;
@@ -1512,7 +1577,8 @@ bool send_users_tochar(void) {
* timerFunction
* 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 check_connect_char_server(int tid, int64 tick, int id, intptr_t data)
+{
static int displayed = 0;
if ( chrif->fd <= 0 || sockt->session[chrif->fd] == NULL ) {
if ( !displayed ) {
@@ -1527,6 +1593,7 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
sockt->session[chrif->fd]->func_parse = chrif->parse;
sockt->session[chrif->fd]->flag.server = 1;
+ sockt->session[chrif->fd]->flag.validate = 0;
sockt->realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chrif->connect(chrif->fd);
@@ -1546,7 +1613,7 @@ 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)
+static bool chrif_removefriend(int char_id, int friend_id)
{
chrif_check(false);
@@ -1558,26 +1625,10 @@ bool chrif_removefriend(int char_id, int friend_id)
return true;
}
-void chrif_send_report(char* buf, int len) {
-#ifndef STATS_OPT_OUT
- if( chrif->fd > 0 ) {
- nullpo_retv(buf);
- WFIFOHEAD(chrif->fd,len + 2);
-
- WFIFOW(chrif->fd,0) = 0x3008;
- memcpy(WFIFOP(chrif->fd,2), buf, len);
-
- WFIFOSET(chrif->fd,len + 2);
-
- sockt->flush(chrif->fd); /* ensure it's sent now. */
- }
-#endif
-}
-
/**
* 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)
+static void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce)
{
if( !chrif->isconnected() )
return;
@@ -1596,10 +1647,11 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st
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)
+static 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);
@@ -1619,7 +1671,7 @@ void chrif_del_scdata_single(int account_id, int char_id, short type)
/**
* @see DBApply
*/
-int auth_db_final(union DBKey key, struct DBData *data, va_list ap)
+static int auth_db_final(union DBKey key, struct DBData *data, va_list ap)
{
struct auth_node *node = DB->data2ptr(data);
@@ -1641,7 +1693,7 @@ int auth_db_final(union DBKey key, struct DBData *data, va_list ap)
/*==========================================
* Destructor
*------------------------------------------*/
-void do_final_chrif(void)
+static void do_final_chrif(void)
{
if( chrif->fd != -1 ) {
sockt->close(chrif->fd);
@@ -1656,7 +1708,8 @@ void do_final_chrif(void)
/*==========================================
*
*------------------------------------------*/
-void do_init_chrif(bool minimal) {
+static void do_init_chrif(bool minimal)
+{
if (minimal)
return;
@@ -1682,7 +1735,8 @@ void do_init_chrif(bool minimal) {
* Generated by HerculesInterfaceMaker
* created by Susu
*-------------------------------------*/
-void chrif_defaults(void) {
+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
@@ -1753,7 +1807,6 @@ void chrif_defaults(void) {
chrif->divorce = chrif_divorce;
chrif->removefriend = chrif_removefriend;
- chrif->send_report = chrif_send_report;
chrif->flush = chrif_flush;
chrif->skillid2idx = chrif_skillid2idx;