summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/HPMchar.c10
-rw-r--r--src/char/char.c201
-rw-r--r--src/char/char.h106
-rw-r--r--src/char/geoip.c1
-rw-r--r--src/char/geoip.h6
-rw-r--r--src/char/int_auction.c1
-rw-r--r--src/char/int_auction.h11
-rw-r--r--src/char/int_elemental.c1
-rw-r--r--src/char/int_elemental.h12
-rw-r--r--src/char/int_guild.c1
-rw-r--r--src/char/int_guild.h10
-rw-r--r--src/char/int_homun.c1
-rw-r--r--src/char/int_homun.h14
-rw-r--r--src/char/int_mail.c1
-rw-r--r--src/char/int_mail.h12
-rw-r--r--src/char/int_mercenary.c1
-rw-r--r--src/char/int_mercenary.h12
-rw-r--r--src/char/int_party.c1
-rw-r--r--src/char/int_party.h11
-rw-r--r--src/char/int_pet.c1
-rw-r--r--src/char/int_pet.h12
-rw-r--r--src/char/int_quest.c1
-rw-r--r--src/char/int_quest.h10
-rw-r--r--src/char/int_storage.c1
-rw-r--r--src/char/int_storage.h12
-rw-r--r--src/char/inter.c9
-rw-r--r--src/char/inter.h18
-rw-r--r--src/char/loginif.c12
-rw-r--r--src/char/loginif.h6
-rw-r--r--src/char/mapif.c1
-rw-r--r--src/char/mapif.h6
-rw-r--r--src/char/pincode.c1
-rw-r--r--src/char/pincode.h6
33 files changed, 250 insertions, 259 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c
index 2d4c570d7..a67f017c1 100644
--- a/src/char/HPMchar.c
+++ b/src/char/HPMchar.c
@@ -8,7 +8,6 @@
#include "common/HPM.h"
#include "common/cbasetypes.h"
-#if 0 // TODO (HPMDataCheck is disabled for the time being)
#include "char/char.h"
#include "char/geoip.h"
#include "char/inter.h"
@@ -47,7 +46,6 @@
// HPMDataCheck comes after all the other includes
#include "common/HPMDataCheck.h"
-#endif
bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
/* record address */
@@ -59,18 +57,14 @@ bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTyp
}
void HPM_char_plugin_load_sub(struct hplugin *plugin) {
+ plugin->hpi->sql_handle = inter->sql_handle;
}
void HPM_char_do_init(void) {
-#if 0 // TODO (HPMDataCheck is disabled for the time being)
HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
-#else
- HPM->DataCheck = NULL;
-#endif
+ HPM_shared_symbols(SERVER_TYPE_CHAR);
}
void HPM_char_do_final(void) {
-#if 0 // TODO (HPMDataCheck is disabled for the time being)
HPM->datacheck_final();
-#endif
}
diff --git a/src/char/char.c b/src/char/char.c
index e70a4b762..576eb9630 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -87,6 +87,7 @@ char char_reg_str_db[32] = "char_reg_str_db";
char char_reg_num_db[32] = "char_reg_num_db";
struct char_interface char_s;
+struct char_interface *chr;
// show loading/saving messages
int save_log = 1;
@@ -206,7 +207,7 @@ void char_set_char_charselect(int account_id)
character->waiting_disconnect = INVALID_TIMER;
}
- if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof)
+ if (chr->login_fd > 0 && !sockt->session[chr->login_fd]->flag.eof)
chr->set_account_online(account_id);
}
@@ -246,7 +247,7 @@ void char_set_char_online(int map_id, int char_id, int account_id)
inter_guild->CharOnline(char_id, cp?cp->guild_id:-1);
//Notify login server
- if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof)
+ if (chr->login_fd > 0 && !sockt->session[chr->login_fd]->flag.eof)
chr->set_account_online(account_id);
}
@@ -292,7 +293,7 @@ void char_set_char_offline(int char_id, int account_id)
}
//Remove char if 1- Set all offline, or 2- character is no longer connected to char-server.
- if (chr->login_fd > 0 && !session[chr->login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
+ if (chr->login_fd > 0 && !sockt->session[chr->login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
chr->set_account_offline(account_id);
}
@@ -355,7 +356,7 @@ void char_set_all_offline(int id)
ShowNotice("Sending users of map-server %d offline.\n",id);
chr->online_char_db->foreach(chr->online_char_db,chr->db_kickoffline,id);
- if (id >= 0 || chr->login_fd <= 0 || session[chr->login_fd]->flag.eof)
+ if (id >= 0 || chr->login_fd <= 0 || sockt->session[chr->login_fd]->flag.eof)
return;
chr->set_login_all_offline();
}
@@ -2206,9 +2207,9 @@ void char_disconnect_player(int account_id)
struct char_session_data* sd;
// disconnect player if online on char-server
- ARR_FIND( 0, sockt->fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == account_id );
+ ARR_FIND( 0, sockt->fd_max, i, sockt->session[i] && (sd = (struct char_session_data*)sockt->session[i]->session_data) && sd->account_id == account_id );
if( i < sockt->fd_max )
- set_eof(i);
+ sockt->eof(i);
}
void char_authfail_fd(int fd, int type)
@@ -2280,7 +2281,7 @@ int char_parse_fromlogin_connection_state(int fd)
ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
ShowError("The communication passwords are set in /conf/map-server.conf and /conf/char-server.conf\n");
- set_eof(fd);
+ sockt->eof(fd);
return 1;
} else {
ShowStatus("Connected to login-server (connection #%d).\n", fd);
@@ -2315,7 +2316,7 @@ void char_parse_fromlogin_auth_state(int fd)
unsigned int expiration_time = RFIFOL(fd, 29);
RFIFOSKIP(fd,33);
- if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
+ if (sockt->session_is_active(request_id) && (sd=(struct char_session_data*)sockt->session[request_id]->session_data) &&
!sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
{
int client_fd = request_id;
@@ -2344,10 +2345,10 @@ void char_parse_fromlogin_auth_state(int fd)
void char_parse_fromlogin_account_data(int fd)
{
- struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data;
+ struct char_session_data* sd = (struct char_session_data*)sockt->session[fd]->session_data;
int i;
// find the authenticated session with this account id
- ARR_FIND( 0, sockt->fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
+ ARR_FIND( 0, sockt->fd_max, i, sockt->session[i] && (sd = (struct char_session_data*)sockt->session[i]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
if( i < sockt->fd_max ) {
memcpy(sd->email, RFIFOP(fd,6), 40);
sd->expiration_time = (time_t)RFIFOL(fd,46);
@@ -2388,8 +2389,8 @@ void char_parse_fromlogin_account_data(int fd)
void char_parse_fromlogin_login_pong(int fd)
{
RFIFOSKIP(fd,2);
- if (session[fd])
- session[fd]->flag.ping = 0;
+ if (sockt->session[fd])
+ sockt->session[fd]->flag.ping = 0;
}
void char_changesex(int account_id, int sex)
@@ -2532,11 +2533,11 @@ void char_parse_fromlogin_kick(int fd)
{// Manual kick from char server.
struct char_session_data *tsd;
int i;
- ARR_FIND( 0, sockt->fd_max, i, session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid );
+ ARR_FIND( 0, sockt->fd_max, i, sockt->session[i] && (tsd = (struct char_session_data*)sockt->session[i]->session_data) && tsd->account_id == aid );
if( i < sockt->fd_max )
{
chr->authfail_fd(i, 2);
- set_eof(i);
+ sockt->eof(i);
}
else // still moving to the map-server
chr->set_char_offline(-1, aid);
@@ -2561,11 +2562,11 @@ void char_parse_fromlogin_update_ip(int fd)
WBUFW(buf,0) = 0x2b1e;
mapif->sendall(buf, 2);
- new_ip = host2ip(login_ip_str);
+ new_ip = sockt->host2ip(login_ip_str);
if (new_ip && new_ip != login_ip)
login_ip = new_ip; //Update login ip, too.
- new_ip = host2ip(char_ip_str);
+ new_ip = sockt->host2ip(char_ip_str);
if (new_ip && new_ip != chr->ip) {
//Update ip.
chr->ip = new_ip;
@@ -2596,22 +2597,22 @@ int char_parse_fromlogin(int fd) {
// only process data from the login-server
if( fd != chr->login_fd ) {
ShowDebug("chr->parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
- do_close(fd);
+ sockt->close(fd);
return 0;
}
- if( session[fd]->flag.eof ) {
- do_close(fd);
+ if( sockt->session[fd]->flag.eof ) {
+ sockt->close(fd);
chr->login_fd = -1;
loginif->on_disconnect();
return 0;
- } else if ( session[fd]->flag.ping ) {/* we've reached stall time */
- if( DIFF_TICK(sockt->last_tick, session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */
- set_eof(fd);
+ } else if ( sockt->session[fd]->flag.ping ) {/* we've reached stall time */
+ if( DIFF_TICK(sockt->last_tick, sockt->session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */
+ sockt->eof(fd);
return 0;
- } else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
+ } else if( sockt->session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
chr->ping_login_server(fd);
- session[fd]->flag.ping = 2;
+ sockt->session[fd]->flag.ping = 2;
}
}
@@ -2713,7 +2714,7 @@ int char_parse_fromlogin(int fd) {
default:
ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
}
@@ -2940,7 +2941,7 @@ void mapif_server_destroy(int id)
{
if( chr->server[id].fd == -1 )
{
- do_close(chr->server[id].fd);
+ sockt->close(chr->server[id].fd);
chr->server[id].fd = -1;
}
}
@@ -3241,7 +3242,7 @@ void char_parse_frommap_char_select_req(int fd)
int32 group_id = RFIFOL(fd, 18);
RFIFOSKIP(fd,22);
- if( runflag != CHARSERVER_ST_RUNNING )
+ if( core->runflag != CHARSERVER_ST_RUNNING )
{
chr->select_ack(fd, account_id, 0);
}
@@ -3296,7 +3297,7 @@ void char_parse_frommap_change_map_server(int fd)
char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14));
}
- if (runflag == CHARSERVER_ST_RUNNING && session_isActive(map_fd) && char_data) {
+ if (core->runflag == CHARSERVER_ST_RUNNING && sockt->session_is_active(map_fd) && char_data) {
//Send the map server the auth of this player.
struct online_char_data* data;
struct char_auth_node* node;
@@ -3777,7 +3778,7 @@ void char_parse_frommap_auth_request(int fd, int id)
cd = (struct mmo_charstatus*)uidb_get(chr->char_db_,char_id);
}
- if( runflag == CHARSERVER_ST_RUNNING && cd && standalone ) {
+ if( core->runflag == CHARSERVER_ST_RUNNING && cd && standalone ) {
cd->sex = sex;
chr->map_auth_ok(fd, account_id, NULL, cd);
@@ -3785,7 +3786,7 @@ void char_parse_frommap_auth_request(int fd, int id)
return;
}
- if( runflag == CHARSERVER_ST_RUNNING &&
+ if( core->runflag == CHARSERVER_ST_RUNNING &&
cd != NULL &&
node != NULL &&
node->account_id == account_id &&
@@ -3824,14 +3825,14 @@ void char_parse_frommap_request_stats_report(int fd)
opt.silent = 1;
opt.setTimeo = 1;
- if( (sfd = make_connection(host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1 ) {
+ if ((sfd = sockt->make_connection(sockt->host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1) {
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
return;/* connection not possible, we drop the report */
}
- session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
- realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
+ sockt->realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
WFIFOHEAD(sfd, RFIFOW(fd,2) );
@@ -3840,15 +3841,15 @@ void char_parse_frommap_request_stats_report(int fd)
WFIFOSET(sfd, RFIFOW(fd,2) );
do {
- flush_fifo(sfd);
+ sockt->flush(sfd);
#ifdef WIN32
Sleep(1);
#else
sleep(1);
#endif
- } while( !session[sfd]->flag.eof && session[sfd]->wdata_size );
+ } while( !sockt->session[sfd]->flag.eof && sockt->session[sfd]->wdata_size );
- do_close(sfd);
+ sockt->close(sfd);
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
@@ -3894,11 +3895,11 @@ int char_parse_frommap(int fd)
ARR_FIND( 0, ARRAYLENGTH(chr->server), id, chr->server[id].fd == fd );
if( id == ARRAYLENGTH(chr->server) ) {// not a map server
ShowDebug("chr->parse_frommap: Disconnecting invalid session #%d (is not a map-server)\n", fd);
- do_close(fd);
+ sockt->close(fd);
return 0;
}
- if( session[fd]->flag.eof ) {
- do_close(fd);
+ if( sockt->session[fd]->flag.eof ) {
+ sockt->close(fd);
chr->server[id].fd = -1;
mapif->on_disconnect(id);
return 0;
@@ -4113,7 +4114,7 @@ int char_parse_frommap(int fd)
// no inter server packet. no char server packet -> disconnect
ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0));
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
} // switch
@@ -4226,7 +4227,7 @@ void char_delete2_accept_ack(int fd, int char_id, uint32 result)
{// HC: <082a>.W <char id>.L <Msg:0-5>.L
#if PACKETVER >= 20130000 /* not sure the exact date -- must refresh or client gets stuck */
if( result == 1 ) {
- struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data;
+ struct char_session_data* sd = (struct char_session_data*)sockt->session[fd]->session_data;
chr->mmo_char_send099d(fd, sd);
}
#endif
@@ -4442,8 +4443,8 @@ void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl)
return;
}
- CREATE(session[fd]->session_data, struct char_session_data, 1);
- sd = (struct char_session_data*)session[fd]->session_data;
+ CREATE(sockt->session[fd]->session_data, struct char_session_data, 1);
+ sd = (struct char_session_data*)sockt->session[fd]->session_data;
sd->account_id = account_id;
sd->login_id1 = login_id1;
sd->login_id2 = login_id2;
@@ -4453,7 +4454,7 @@ void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl)
// send back account_id
chr->send_account_id(fd, account_id);
- if( runflag != CHARSERVER_ST_RUNNING ) {
+ if( core->runflag != CHARSERVER_ST_RUNNING ) {
chr->auth_error(fd, 0);
return;
}
@@ -4497,7 +4498,7 @@ void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstat
WFIFOL(fd,2) = cd->char_id;
mapindex->getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6));
WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : chr->server[i].ip);
- WFIFOW(fd,26) = ntows(htons(chr->server[i].port)); // [!] LE byte order here [!]
+ WFIFOW(fd,26) = sockt->ntows(htons(chr->server[i].port)); // [!] LE byte order here [!]
WFIFOSET(fd,28);
}
@@ -4647,7 +4648,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
//Send NEW auth packet [Kevin]
//FIXME: is this case even possible? [ultramage]
- if ((map_fd = chr->server[i].fd) < 1 || session[map_fd] == NULL)
+ if ((map_fd = chr->server[i].fd) < 1 || sockt->session[map_fd] == NULL)
{
ShowError("chr->parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
chr->server[i].fd = -1;
@@ -4961,7 +4962,7 @@ void char_parse_char_login_map_server(int fd, uint32 ipl)
l_pass[23] = '\0';
ARR_FIND( 0, ARRAYLENGTH(chr->server), i, chr->server[i].fd <= 0 );
- if (runflag != CHARSERVER_ST_RUNNING ||
+ if (core->runflag != CHARSERVER_ST_RUNNING ||
i == ARRAYLENGTH(chr->server) ||
strcmp(l_user, chr->userid) != 0 ||
strcmp(l_pass, chr->passwd) != 0 ||
@@ -4975,9 +4976,9 @@ void char_parse_char_login_map_server(int fd, uint32 ipl)
chr->server[i].ip = ntohl(RFIFOL(fd,54));
chr->server[i].port = ntohs(RFIFOW(fd,58));
chr->server[i].users = 0;
- session[fd]->func_parse = chr->parse_frommap;
- session[fd]->flag.server = 1;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->session[fd]->func_parse = chr->parse_frommap;
+ sockt->session[fd]->flag.server = 1;
+ sockt->realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chr->mapif_init(fd);
}
sockt->datasync(fd, true);
@@ -5052,8 +5053,8 @@ void char_parse_char_move_character(int fd, struct char_session_data* sd)
int char_parse_char_unknown_packet(int fd, uint32 ipl)
{
- ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
- set_eof(fd);
+ ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), sockt->ip2str(ipl, NULL));
+ sockt->eof(fd);
return 1;
}
@@ -5061,15 +5062,15 @@ int char_parse_char(int fd)
{
unsigned short cmd;
struct char_session_data* sd;
- uint32 ipl = session[fd]->client_addr;
+ uint32 ipl = sockt->session[fd]->client_addr;
- sd = (struct char_session_data*)session[fd]->session_data;
+ sd = (struct char_session_data*)sockt->session[fd]->session_data;
// disconnect any player if no login-server.
if(chr->login_fd < 0)
- set_eof(fd);
+ sockt->eof(fd);
- if(session[fd]->flag.eof)
+ if(sockt->session[fd]->flag.eof)
{
if( sd != NULL && sd->auth ) {
// already authed client
@@ -5079,7 +5080,7 @@ int char_parse_char(int fd)
if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
chr->set_char_offline(-1,sd->account_id);
}
- do_close(fd);
+ sockt->close(fd);
return 0;
}
@@ -5340,7 +5341,7 @@ int char_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) {
return 0;
prev_users = users;
- if( chr->login_fd > 0 && session[chr->login_fd] )
+ if( chr->login_fd > 0 && sockt->session[chr->login_fd] )
{
// send number of user to login server
loginif->send_users_count(users);
@@ -5371,7 +5372,7 @@ static int char_send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap)
}
int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) {
- if (chr->login_fd > 0 && session[chr->login_fd])
+ if (chr->login_fd > 0 && sockt->session[chr->login_fd])
{
// send account list to login server
int users = chr->online_char_db->size(chr->online_char_db);
@@ -5388,19 +5389,19 @@ int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) {
}
int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) {
- if (chr->login_fd > 0 && session[chr->login_fd] != NULL)
+ if (chr->login_fd > 0 && sockt->session[chr->login_fd] != NULL)
return 0;
ShowInfo("Attempt to connect to login-server...\n");
- if ( (chr->login_fd = make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
+ if ((chr->login_fd = sockt->make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
chr->login_fd = 0;
return 0;
}
- session[chr->login_fd]->func_parse = chr->parse_fromlogin;
- session[chr->login_fd]->flag.server = 1;
- realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->session[chr->login_fd]->func_parse = chr->parse_fromlogin;
+ sockt->session[chr->login_fd]->flag.server = 1;
+ sockt->realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
loginif->connect_to_server();
@@ -5575,13 +5576,13 @@ int char_config_read(const char* cfgName)
remove_control_chars(w1);
remove_control_chars(w2);
if(strcmpi(w1,"timestamp_format") == 0) {
- safestrncpy(timestamp_format, w2, sizeof(timestamp_format));
+ safestrncpy(showmsg->timestamp_format, w2, sizeof(showmsg->timestamp_format));
} else if(strcmpi(w1,"console_silent")==0){
- msg_silent = atoi(w2);
- if( msg_silent ) /* only bother if its actually enabled */
+ showmsg->silent = atoi(w2);
+ if (showmsg->silent) /* only bother if its actually enabled */
ShowInfo("Console Silent Setting: %d\n", atoi(w2));
} else if(strcmpi(w1,"stdout_with_ansisequence")==0){
- stdout_with_ansisequence = config_switch(w2);
+ showmsg->stdout_with_ansisequence = config_switch(w2) ? true : false;
} else if (strcmpi(w1, "userid") == 0) {
safestrncpy(chr->userid, w2, sizeof(chr->userid));
} else if (strcmpi(w1, "passwd") == 0) {
@@ -5593,27 +5594,27 @@ int char_config_read(const char* cfgName)
safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name));
}
} else if (strcmpi(w1, "login_ip") == 0) {
- login_ip = host2ip(w2);
+ login_ip = sockt->host2ip(w2);
if (login_ip) {
char ip_str[16];
safestrncpy(login_ip_str, w2, sizeof(login_ip_str));
- ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
+ ShowStatus("Login server IP address : %s -> %s\n", w2, sockt->ip2str(login_ip, ip_str));
}
} else if (strcmpi(w1, "login_port") == 0) {
login_port = atoi(w2);
} else if (strcmpi(w1, "char_ip") == 0) {
- chr->ip = host2ip(w2);
+ chr->ip = sockt->host2ip(w2);
if (chr->ip) {
char ip_str[16];
safestrncpy(char_ip_str, w2, sizeof(char_ip_str));
- ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(chr->ip, ip_str));
+ ShowStatus("Character server IP address : %s -> %s\n", w2, sockt->ip2str(chr->ip, ip_str));
}
} else if (strcmpi(w1, "bind_ip") == 0) {
- bind_ip = host2ip(w2);
+ bind_ip = sockt->host2ip(w2);
if (bind_ip) {
char ip_str[16];
safestrncpy(bind_ip_str, w2, sizeof(bind_ip_str));
- ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
+ ShowStatus("Character server binding IP address : %s -> %s\n", w2, sockt->ip2str(bind_ip, ip_str));
}
} else if (strcmpi(w1, "char_port") == 0) {
chr->port = atoi(w2);
@@ -5739,7 +5740,7 @@ int do_final(void) {
inter->final();
- flush_fifos();
+ sockt->flush_fifos();
do_final_mapif();
loginif->final();
@@ -5752,7 +5753,7 @@ int do_final(void) {
auth_db->destroy(auth_db, NULL);
if( chr->char_fd != -1 ) {
- do_close(chr->char_fd);
+ sockt->close(chr->char_fd);
chr->char_fd = -1;
}
@@ -5791,39 +5792,18 @@ void set_server_type(void) {
/// Called when a terminate signal is received.
void do_shutdown(void)
{
- if( runflag != CHARSERVER_ST_SHUTDOWN )
+ if( core->runflag != CHARSERVER_ST_SHUTDOWN )
{
int id;
- runflag = CHARSERVER_ST_SHUTDOWN;
+ core->runflag = CHARSERVER_ST_SHUTDOWN;
ShowStatus("Shutting down...\n");
// TODO proper shutdown procedure; wait for acks?, kick all characters, ... [FlavoJS]
for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
mapif->server_reset(id);
loginif->check_shutdown();
- flush_fifos();
- runflag = CORE_ST_STOP;
- }
-}
-
-void char_hp_symbols(void) {
- HPM->share(mapindex,"mapindex");
- HPM->share(chr, "chr");
- HPM->share(geoip, "geoip");
- HPM->share(inter_auction, "inter_auction");
- HPM->share(inter_elemental, "inter_elemental");
- HPM->share(inter_guild, "inter_guild");
- HPM->share(inter_homunculus, "inter_homunculus");
- HPM->share(inter_mail, "inter_mail");
- HPM->share(inter_mercenary, "inter_mercenary");
- HPM->share(inter_party, "inter_party");
- HPM->share(inter_pet, "inter_pet");
- HPM->share(inter_quest, "inter_quest");
- HPM->share(inter_storage, "inter_storage");
- HPM->share(inter, "inter");
- HPM->share(loginif, "loginif");
- HPM->share(mapif, "mapif");
- HPM->share(pincode, "pincode");
- HPM->share(inter->sql_handle, "sql_handle");
+ sockt->flush_fifos();
+ core->runflag = CORE_ST_STOP;
+ }
}
/**
@@ -5887,7 +5867,6 @@ int do_init(int argc, char **argv) {
chr->server[i].map = NULL;
HPM_char_do_init();
- HPM->symbol_defaults_sub = char_hp_symbols;
cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT);
HPM->config_read();
HPM->event(HPET_PRE_INIT);
@@ -5919,7 +5898,7 @@ int do_init(int argc, char **argv) {
if ((sockt->naddr_ != 0) && (!login_ip || !chr->ip)) {
char ip_str[16];
- ip2str(sockt->addr_[0], ip_str);
+ sockt->ip2str(sockt->addr_[0], ip_str);
if (sockt->naddr_ > 1)
ShowStatus("Multiple interfaces detected.. using %s as our IP address\n", ip_str);
@@ -5927,11 +5906,11 @@ int do_init(int argc, char **argv) {
ShowStatus("Defaulting to %s as our IP address\n", ip_str);
if (!login_ip) {
safestrncpy(login_ip_str, ip_str, sizeof(login_ip_str));
- login_ip = str2ip(login_ip_str);
+ login_ip = sockt->str2ip(login_ip_str);
}
if (!chr->ip) {
safestrncpy(char_ip_str, ip_str, sizeof(char_ip_str));
- chr->ip = str2ip(char_ip_str);
+ chr->ip = sockt->str2ip(char_ip_str);
}
}
@@ -5962,9 +5941,9 @@ int do_init(int argc, char **argv) {
if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
Sql_ShowDebug(inter->sql_handle);
- set_defaultparse(chr->parse_char);
+ sockt->set_defaultparse(chr->parse_char);
- if( (chr->char_fd = make_listen_bind(bind_ip,chr->port)) == -1 ) {
+ if ((chr->char_fd = sockt->make_listen_bind(bind_ip,chr->port)) == -1) {
ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",chr->port);
exit(EXIT_FAILURE);
}
@@ -5975,10 +5954,10 @@ int do_init(int argc, char **argv) {
#endif
ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", chr->port);
- if( runflag != CORE_ST_STOP )
+ if( core->runflag != CORE_ST_STOP )
{
- shutdown_callback = do_shutdown;
- runflag = CHARSERVER_ST_RUNNING;
+ core->shutdown_callback = do_shutdown;
+ core->runflag = CHARSERVER_ST_RUNNING;
}
HPM->event(HPET_READY);
diff --git a/src/char/char.h b/src/char/char.h
index 1f5df2750..e79cc1898 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -5,7 +5,7 @@
#ifndef CHAR_CHAR_H
#define CHAR_CHAR_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/core.h" // CORE_ST_LAST
#include "common/db.h"
#include "common/mmo.h"
@@ -64,57 +64,6 @@ enum {
TABLE_GUILD_STORAGE,
};
-#ifdef HERCULES_CORE
-extern int char_name_option;
-extern char char_name_letters[];
-extern bool char_gm_read;
-extern int autosave_interval;
-extern int save_log;
-extern char db_path[];
-extern char char_db[256];
-extern char scdata_db[256];
-extern char cart_db[256];
-extern char inventory_db[256];
-extern char charlog_db[256];
-extern char storage_db[256];
-extern char interlog_db[256];
-extern char skill_db[256];
-extern char memo_db[256];
-extern char guild_db[256];
-extern char guild_alliance_db[256];
-extern char guild_castle_db[256];
-extern char guild_expulsion_db[256];
-extern char guild_member_db[256];
-extern char guild_position_db[256];
-extern char guild_skill_db[256];
-extern char guild_storage_db[256];
-extern char party_db[256];
-extern char pet_db[256];
-extern char mail_db[256];
-extern char auction_db[256];
-extern char quest_db[256];
-extern char homunculus_db[256];
-extern char skill_homunculus_db[256];
-extern char mercenary_db[256];
-extern char mercenary_owner_db[256];
-extern char ragsrvinfo_db[256];
-extern char elemental_db[256];
-extern char acc_reg_num_db[32];
-extern char acc_reg_str_db[32];
-extern char char_reg_str_db[32];
-extern char char_reg_num_db[32];
-
-extern int db_use_sql_item_db;
-extern int db_use_sql_mob_db;
-extern int db_use_sql_mob_skill_db;
-
-extern int guild_exp_rate;
-extern int log_inter;
-
-void char_load_defaults();
-void char_defaults();
-#endif // HERCULES_CORE
-
struct char_auth_node {
int account_id;
int char_id;
@@ -310,6 +259,57 @@ struct char_interface {
int (*config_read) (const char* cfgName);
};
-struct char_interface *chr;
+#ifdef HERCULES_CORE
+extern int char_name_option;
+extern char char_name_letters[];
+extern bool char_gm_read;
+extern int autosave_interval;
+extern int save_log;
+extern char db_path[];
+extern char char_db[256];
+extern char scdata_db[256];
+extern char cart_db[256];
+extern char inventory_db[256];
+extern char charlog_db[256];
+extern char storage_db[256];
+extern char interlog_db[256];
+extern char skill_db[256];
+extern char memo_db[256];
+extern char guild_db[256];
+extern char guild_alliance_db[256];
+extern char guild_castle_db[256];
+extern char guild_expulsion_db[256];
+extern char guild_member_db[256];
+extern char guild_position_db[256];
+extern char guild_skill_db[256];
+extern char guild_storage_db[256];
+extern char party_db[256];
+extern char pet_db[256];
+extern char mail_db[256];
+extern char auction_db[256];
+extern char quest_db[256];
+extern char homunculus_db[256];
+extern char skill_homunculus_db[256];
+extern char mercenary_db[256];
+extern char mercenary_owner_db[256];
+extern char ragsrvinfo_db[256];
+extern char elemental_db[256];
+extern char acc_reg_num_db[32];
+extern char acc_reg_str_db[32];
+extern char char_reg_str_db[32];
+extern char char_reg_num_db[32];
+
+extern int db_use_sql_item_db;
+extern int db_use_sql_mob_db;
+extern int db_use_sql_mob_skill_db;
+
+extern int guild_exp_rate;
+extern int log_inter;
+
+void char_load_defaults();
+void char_defaults();
+#endif // HERCULES_CORE
+
+HPShared struct char_interface *chr;
#endif /* CHAR_CHAR_H */
diff --git a/src/char/geoip.c b/src/char/geoip.c
index 8c415b6bf..65bb2bdd4 100644
--- a/src/char/geoip.c
+++ b/src/char/geoip.c
@@ -17,6 +17,7 @@
struct s_geoip geoip_data;
struct geoip_interface geoip_s;
+struct geoip_interface *geoip;
/* [Dekamaster/Nightroad] */
#define GEOIP_MAX_COUNTRIES 255
diff --git a/src/char/geoip.h b/src/char/geoip.h
index 4d39011aa..5a6abf68a 100644
--- a/src/char/geoip.h
+++ b/src/char/geoip.h
@@ -5,7 +5,7 @@
#ifndef CHAR_GEOIP_H
#define CHAR_GEOIP_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
/**
* GeoIP information
@@ -26,10 +26,10 @@ struct geoip_interface {
void (*init) (void);
};
-struct geoip_interface *geoip;
-
#ifdef HERCULES_CORE
void geoip_defaults(void);
#endif // HERCULES_CORE
+HPShared struct geoip_interface *geoip;
+
#endif /* CHAR_GEOIP_H */
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 8d51777fb..67c83ca22 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
struct inter_auction_interface inter_auction_s;
+struct inter_auction_interface *inter_auction;
static int inter_auction_count(int char_id, bool buy)
{
diff --git a/src/char/int_auction.h b/src/char/int_auction.h
index 610042b9a..37fd48264 100644
--- a/src/char/int_auction.h
+++ b/src/char/int_auction.h
@@ -4,13 +4,10 @@
#ifndef CHAR_INT_AUCTION_H
#define CHAR_INT_AUCTION_H
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h"
-#ifdef HERCULES_CORE
-void inter_auction_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_auction_interface interface
**/
@@ -27,6 +24,10 @@ struct inter_auction_interface {
void (*sql_final) (void);
};
-struct inter_auction_interface *inter_auction;
+#ifdef HERCULES_CORE
+void inter_auction_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_auction_interface *inter_auction;
#endif /* CHAR_INT_AUCTION_H */
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index eff84c57d..e7708179a 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
struct inter_elemental_interface inter_elemental_s;
+struct inter_elemental_interface *inter_elemental;
bool mapif_elemental_save(struct s_elemental* ele) {
bool flag = true;
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
index 7385fc496..0fae74cd0 100644
--- a/src/char/int_elemental.h
+++ b/src/char/int_elemental.h
@@ -4,11 +4,7 @@
#ifndef CHAR_INT_ELEMENTAL_H
#define CHAR_INT_ELEMENTAL_H
-#include "common/cbasetypes.h"
-
-#ifdef HERCULES_CORE
-void inter_elemental_defaults(void);
-#endif // HERCULES_CORE
+#include "common/hercules.h"
/**
* inter_elemental_interface interface
@@ -19,6 +15,10 @@ struct inter_elemental_interface {
int (*parse_frommap) (int fd);
};
-struct inter_elemental_interface *inter_elemental;
+#ifdef HERCULES_CORE
+void inter_elemental_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_elemental_interface *inter_elemental;
#endif /* CHAR_INT_ELEMENTAL_H */
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 24561fe21..54355161d 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -35,6 +35,7 @@
#define GUILD_ALLIANCE_REMOVE 0x08
struct inter_guild_interface inter_guild_s;
+struct inter_guild_interface *inter_guild;
static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index eb4c930fc..7a5ed3aae 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -23,10 +23,6 @@ enum {
GS_REMOVE = 0x8000,
};
-#ifdef HERCULES_CORE
-void inter_guild_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_guild interface
**/
@@ -59,6 +55,10 @@ struct inter_guild_interface {
int (*broken) (int guild_id);
};
-struct inter_guild_interface *inter_guild;
+#ifdef HERCULES_CORE
+void inter_guild_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_guild_interface *inter_guild;
#endif /* CHAR_INT_GUILD_H */
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index eda2afe69..be72ecd58 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
struct inter_homunculus_interface inter_homunculus_s;
+struct inter_homunculus_interface *inter_homunculus;
int inter_homunculus_sql_init(void)
{
diff --git a/src/char/int_homun.h b/src/char/int_homun.h
index 113c6d340..d5a35283f 100644
--- a/src/char/int_homun.h
+++ b/src/char/int_homun.h
@@ -4,13 +4,7 @@
#ifndef CHAR_INT_HOMUN_H
#define CHAR_INT_HOMUN_H
-#include "common/cbasetypes.h"
-
-struct s_homunculus;
-
-#ifdef HERCULES_CORE
-void inter_homunculus_defaults(void);
-#endif // HERCULES_CORE
+#include "common/hercules.h"
/**
* inter_homunculus interface
@@ -21,6 +15,10 @@ struct inter_homunculus_interface {
int (*parse_frommap) (int fd);
};
-struct inter_homunculus_interface *inter_homunculus;
+#ifdef HERCULES_CORE
+void inter_homunculus_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_homunculus_interface *inter_homunculus;
#endif /* CHAR_INT_HOMUN_H */
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index d4bfe14e4..854fe31b1 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
struct inter_mail_interface inter_mail_s;
+struct inter_mail_interface *inter_mail;
static int inter_mail_fromsql(int char_id, struct mail_data* md)
{
diff --git a/src/char/int_mail.h b/src/char/int_mail.h
index 8e6acf846..d15b264b5 100644
--- a/src/char/int_mail.h
+++ b/src/char/int_mail.h
@@ -4,16 +4,12 @@
#ifndef CHAR_INT_MAIL_H
#define CHAR_INT_MAIL_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct item;
struct mail_data;
struct mail_message;
-#ifdef HERCULES_CORE
-void inter_mail_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_mail interface
**/
@@ -28,6 +24,10 @@ struct inter_mail_interface {
void (*sendmail) (int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item);
};
-struct inter_mail_interface *inter_mail;
+#ifdef HERCULES_CORE
+void inter_mail_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_mail_interface *inter_mail;
#endif /* CHAR_INT_MAIL_H */
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index 02082aa13..dd40a0224 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
struct inter_mercenary_interface inter_mercenary_s;
+struct inter_mercenary_interface *inter_mercenary;
bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
{
diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h
index 632a9ab37..0d52b02e1 100644
--- a/src/char/int_mercenary.h
+++ b/src/char/int_mercenary.h
@@ -4,14 +4,10 @@
#ifndef CHAR_INT_MERCENARY_H
#define CHAR_INT_MERCENARY_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct mmo_charstatus;
-#ifdef HERCULES_CORE
-void inter_mercenary_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_mercenary interface
**/
@@ -24,6 +20,10 @@ struct inter_mercenary_interface {
int (*parse_frommap) (int fd);
};
-struct inter_mercenary_interface *inter_mercenary;
+#ifdef HERCULES_CORE
+void inter_mercenary_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_mercenary_interface *inter_mercenary;
#endif /* CHAR_INT_MERCENARY_H */
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 3b857318c..aedcb8535 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
struct inter_party_interface inter_party_s;
+struct inter_party_interface *inter_party;
//Updates party's level range and unsets even share if broken.
static int inter_party_check_lv(struct party_data *p) {
diff --git a/src/char/int_party.h b/src/char/int_party.h
index 99ee5b13e..af3877549 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -4,6 +4,7 @@
#ifndef CHAR_INT_PARTY_H
#define CHAR_INT_PARTY_H
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h"
@@ -24,10 +25,6 @@ struct party_data {
unsigned char size; //Total size of party.
};
-#ifdef HERCULES_CORE
-void inter_party_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_party interface
**/
@@ -49,6 +46,10 @@ struct inter_party_interface {
int (*CharOffline) (int char_id, int party_id);
};
-struct inter_party_interface *inter_party;
+#ifdef HERCULES_CORE
+void inter_party_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_party_interface *inter_party;
#endif /* CHAR_INT_PARTY_H */
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 22fe2dcc2..97b2fb6a4 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
struct inter_pet_interface inter_pet_s;
+struct inter_pet_interface *inter_pet;
//---------------------------------------------------------
int inter_pet_tosql(int pet_id, struct s_pet* p)
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
index 69e440781..213c377ee 100644
--- a/src/char/int_pet.h
+++ b/src/char/int_pet.h
@@ -4,11 +4,9 @@
#ifndef CHAR_INT_PET_H
#define CHAR_INT_PET_H
-struct s_pet;
+#include "common/hercules.h"
-#ifdef HERCULES_CORE
-void inter_pet_defaults(void);
-#endif // HERCULES_CORE
+struct s_pet;
/**
* inter_pet interface
@@ -23,6 +21,10 @@ struct inter_pet_interface {
int (*parse_frommap) (int fd);
};
-struct inter_pet_interface *inter_pet;
+#ifdef HERCULES_CORE
+void inter_pet_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_pet_interface *inter_pet;
#endif /* CHAR_INT_PET_H */
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index cf9b9c172..fcd56230b 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
struct inter_quest_interface inter_quest_s;
+struct inter_quest_interface *inter_quest;
/**
* Loads the entire questlog for a character.
diff --git a/src/char/int_quest.h b/src/char/int_quest.h
index ee04388fc..c2393d103 100644
--- a/src/char/int_quest.h
+++ b/src/char/int_quest.h
@@ -4,9 +4,7 @@
#ifndef CHAR_INT_QUEST_H
#define CHAR_INT_QUEST_H
-#ifdef HERCULES_CORE
-void inter_quest_defaults(void);
-#endif // HERCULES_CORE
+#include "common/hercules.h"
/**
* inter_quest interface
@@ -15,7 +13,11 @@ struct inter_quest_interface {
int (*parse_frommap) (int fd);
};
-struct inter_quest_interface *inter_quest;
+#ifdef HERCULES_CORE
+void inter_quest_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_quest_interface *inter_quest;
#endif /* CHAR_INT_QUEST_H */
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index a12d9fe17..3a8a6a169 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -24,6 +24,7 @@
#define STORAGE_MEMINC 16
struct inter_storage_interface inter_storage_s;
+struct inter_storage_interface *inter_storage;
/// Save storage data to sql
int inter_storage_tosql(int account_id, struct storage_data* p)
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index 11a16de83..f02decf49 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -4,13 +4,11 @@
#ifndef CHAR_INT_STORAGE_H
#define CHAR_INT_STORAGE_H
+#include "common/hercules.h"
+
struct storage_data;
struct guild_storage;
-#ifdef HERCULES_CORE
-void inter_storage_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter_storage interface
**/
@@ -26,6 +24,10 @@ struct inter_storage_interface {
int (*parse_frommap) (int fd);
};
-struct inter_storage_interface *inter_storage;
+#ifdef HERCULES_CORE
+void inter_storage_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_storage_interface *inter_storage;
#endif /* CHAR_INT_STORAGE_H */
diff --git a/src/char/inter.c b/src/char/inter.c
index dbb782093..548b24ee8 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -36,6 +36,7 @@
#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis
struct inter_interface inter_s;
+struct inter_interface *inter;
int char_server_port = 3306;
char char_server_ip[32] = "127.0.0.1";
@@ -492,7 +493,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
nullpo_retv(last_ip);
nullpo_retv(lastlogin);
nullpo_retv(birthdate);
- if (map_fd <= 0 || !session_isActive(map_fd))
+ if (map_fd <= 0 || !sockt->session_is_active(map_fd))
return; // check if we have a valid fd
if (!success) {
@@ -511,7 +512,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
}
inter->msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
- inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(str2ip(last_ip)));
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(sockt->str2ip(last_ip)));
inter->msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
@@ -557,7 +558,7 @@ void inter_savereg(int account_id, int char_id, const char *key, unsigned int in
nullpo_retv(key);
/* to login server we go! */
if( key[0] == '#' && key[1] == '#' ) {/* global account reg */
- if( session_isValid(chr->login_fd) )
+ if (sockt->session_is_valid(chr->login_fd))
chr->global_accreg_to_login_add(key,index,val,is_string);
else {
ShowError("Login server unavailable, cant perform update on '%s' variable for AID:%d CID:%d\n",key,account_id,char_id);
@@ -1170,7 +1171,7 @@ int mapif_parse_Registry(int fd)
if( count ) {
int cursor = 14, i;
char key[32], sval[254];
- bool isLoginActive = session_isActive(chr->login_fd);
+ bool isLoginActive = sockt->session_is_active(chr->login_fd);
if( isLoginActive )
chr->global_accreg_to_login_start(account_id,char_id);
diff --git a/src/char/inter.h b/src/char/inter.h
index 2e89a685b..743f7e2f1 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -5,20 +5,12 @@
#ifndef CHAR_INTER_H
#define CHAR_INTER_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/sql.h"
#include <stdarg.h>
-struct accreg;
-
-#ifdef HERCULES_CORE
-extern unsigned int party_share_level;
-
-void inter_defaults(void);
-#endif // HERCULES_CORE
-
/**
* inter interface
**/
@@ -44,6 +36,12 @@ struct inter_interface {
void (*final) (void);
};
-struct inter_interface *inter;
+#ifdef HERCULES_CORE
+extern unsigned int party_share_level;
+
+void inter_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct inter_interface *inter;
#endif /* CHAR_INTER_H */
diff --git a/src/char/loginif.c b/src/char/loginif.c
index 881c8f2ac..422c7c589 100644
--- a/src/char/loginif.c
+++ b/src/char/loginif.c
@@ -20,6 +20,7 @@
#include <string.h>
struct loginif_interface loginif_s;
+struct loginif_interface *loginif;
/// Resets all the data.
void loginif_reset(void)
@@ -28,7 +29,7 @@ void loginif_reset(void)
// TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS]
for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
mapif->server_reset(id);
- flush_fifos();
+ sockt->flush_fifos();
exit(EXIT_FAILURE);
}
@@ -38,9 +39,9 @@ void loginif_reset(void)
/// If all the conditions are met, it stops the core loop.
void loginif_check_shutdown(void)
{
- if( runflag != CHARSERVER_ST_SHUTDOWN )
+ if( core->runflag != CHARSERVER_ST_SHUTDOWN )
return;
- runflag = CORE_ST_STOP;
+ core->runflag = CORE_ST_STOP;
}
@@ -80,9 +81,8 @@ void do_init_loginif(void)
void do_final_loginif(void)
{
- if( chr->login_fd != -1 )
- {
- do_close(chr->login_fd);
+ if (chr->login_fd != -1) {
+ sockt->close(chr->login_fd);
chr->login_fd = -1;
}
}
diff --git a/src/char/loginif.h b/src/char/loginif.h
index 548eaff02..44cf1ebf6 100644
--- a/src/char/loginif.h
+++ b/src/char/loginif.h
@@ -5,7 +5,7 @@
#ifndef CHAR_LOGINIF_H
#define CHAR_LOGINIF_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct char_session_data;
@@ -28,10 +28,10 @@ struct loginif_interface {
void (*connect_to_server) (void);
};
-struct loginif_interface *loginif;
-
#ifdef HERCULES_CORE
void loginif_defaults(void);
#endif // HERCULES_CORE
+HPShared struct loginif_interface *loginif;
+
#endif /* CHAR_LOGINIF_H */
diff --git a/src/char/mapif.c b/src/char/mapif.c
index 92506cd49..eb5a6690a 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -189,6 +189,7 @@ void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int fla
int mapif_parse_NameChangeRequest(int fd);
struct mapif_interface mapif_s;
+struct mapif_interface *mapif;
void mapif_defaults(void) {
mapif = &mapif_s;
diff --git a/src/char/mapif.h b/src/char/mapif.h
index 6b015d155..a986cd46f 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -5,7 +5,7 @@
#ifndef CHAR_MAPIF_H
#define CHAR_MAPIF_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h"
struct WisData;
@@ -184,10 +184,10 @@ struct mapif_interface {
int (*parse_NameChangeRequest) (int fd);
};
-struct mapif_interface *mapif;
-
#ifdef HERCULES_CORE
void mapif_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mapif_interface *mapif;
+
#endif /* CHAR_MAPIF_H */
diff --git a/src/char/pincode.c b/src/char/pincode.c
index 5085349cc..f5992de83 100644
--- a/src/char/pincode.c
+++ b/src/char/pincode.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
struct pincode_interface pincode_s;
+struct pincode_interface *pincode;
void pincode_handle (int fd, struct char_session_data* sd) {
struct online_char_data* character;
diff --git a/src/char/pincode.h b/src/char/pincode.h
index 01f6c7bf9..3cda11768 100644
--- a/src/char/pincode.h
+++ b/src/char/pincode.h
@@ -5,7 +5,7 @@
#ifndef CHAR_PINCODE_H
#define CHAR_PINCODE_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct char_session_data;
@@ -42,10 +42,10 @@ struct pincode_interface {
bool (*config_read) (char *w1, char *w2);
};
-struct pincode_interface *pincode;
-
#ifdef HERCULES_CORE
void pincode_defaults(void);
#endif // HERCULES_CORE
+HPShared struct pincode_interface *pincode;
+
#endif /* CHAR_PINCODE_H */