summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/HPMmap.c8
-rw-r--r--src/map/atcommand.c9
-rw-r--r--src/map/atcommand.h6
-rw-r--r--src/map/battle.c1
-rw-r--r--src/map/battle.h12
-rw-r--r--src/map/battleground.c1
-rw-r--r--src/map/battleground.h6
-rw-r--r--src/map/buyingstore.c1
-rw-r--r--src/map/buyingstore.h6
-rw-r--r--src/map/channel.c3
-rw-r--r--src/map/channel.h6
-rw-r--r--src/map/chat.c1
-rw-r--r--src/map/chat.h6
-rw-r--r--src/map/chrif.c75
-rw-r--r--src/map/chrif.h6
-rw-r--r--src/map/clif.c72
-rw-r--r--src/map/clif.h16
-rw-r--r--src/map/duel.c1
-rw-r--r--src/map/duel.h6
-rw-r--r--src/map/elemental.c3
-rw-r--r--src/map/elemental.h6
-rw-r--r--src/map/guild.c1
-rw-r--r--src/map/guild.h6
-rw-r--r--src/map/homunculus.c2
-rw-r--r--src/map/homunculus.h5
-rw-r--r--src/map/instance.c1
-rw-r--r--src/map/instance.h6
-rw-r--r--src/map/intif.c7
-rw-r--r--src/map/intif.h6
-rw-r--r--src/map/irc-bot.c17
-rw-r--r--src/map/irc-bot.h6
-rw-r--r--src/map/itemdb.c1
-rw-r--r--src/map/itemdb.h6
-rw-r--r--src/map/log.c1
-rw-r--r--src/map/log.h6
-rw-r--r--src/map/mail.c1
-rw-r--r--src/map/mail.h6
-rw-r--r--src/map/map.c90
-rw-r--r--src/map/map.h19
-rw-r--r--src/map/mapreg.h6
-rw-r--r--src/map/mapreg_sql.c1
-rw-r--r--src/map/mercenary.c2
-rw-r--r--src/map/mercenary.h6
-rw-r--r--src/map/mob.c1
-rw-r--r--src/map/mob.h10
-rw-r--r--src/map/npc.c1
-rw-r--r--src/map/npc.h13
-rw-r--r--src/map/npc_chat.c2
-rw-r--r--src/map/party.c1
-rw-r--r--src/map/party.h6
-rw-r--r--src/map/path.c1
-rw-r--r--src/map/path.h6
-rw-r--r--src/map/pc.c23
-rw-r--r--src/map/pc.h8
-rw-r--r--src/map/pc_groups.c1
-rw-r--r--src/map/pc_groups.h6
-rw-r--r--src/map/pet.c1
-rw-r--r--src/map/pet.h6
-rw-r--r--src/map/quest.c2
-rw-r--r--src/map/quest.h6
-rw-r--r--src/map/script.c9
-rw-r--r--src/map/script.h6
-rw-r--r--src/map/searchstore.c1
-rw-r--r--src/map/searchstore.h6
-rw-r--r--src/map/skill.c6
-rw-r--r--src/map/skill.h8
-rw-r--r--src/map/status.c4
-rw-r--r--src/map/status.h8
-rw-r--r--src/map/storage.c3
-rw-r--r--src/map/storage.h8
-rw-r--r--src/map/trade.c5
-rw-r--r--src/map/trade.h6
-rw-r--r--src/map/unit.c1
-rw-r--r--src/map/unit.h12
-rw-r--r--src/map/vending.c1
-rw-r--r--src/map/vending.h6
76 files changed, 313 insertions, 324 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 7600d3d0c..a59fbb6ef 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -135,9 +135,10 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType
}
void HPM_map_plugin_load_sub(struct hplugin *plugin) {
- plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx);
- plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx);
- plugin->hpi->addPCGPermission = HPM->import_symbol("addGroupPermission",plugin->idx);
+ plugin->hpi->sql_handle = map->mysql_handle;
+ plugin->hpi->addCommand = atcommand->create;
+ plugin->hpi->addScript = script->addScript;
+ plugin->hpi->addPCGPermission = HPM_map_add_group_permission;
}
bool HPM_map_add_atcommand(char *name, AtCommandFunc func) {
@@ -185,6 +186,7 @@ void HPM_map_do_init(void) {
HPM->load_sub = HPM_map_plugin_load_sub;
HPM->grabHPDataSub = HPM_map_grabHPData;
HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
+ HPM_shared_symbols(SERVER_TYPE_MAP);
}
void HPM_map_do_final(void) {
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index fb0b89381..95db0c2e6 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -58,6 +58,7 @@
#include <string.h>
struct atcommand_interface atcommand_s;
+struct atcommand_interface *atcommand;
static char atcmd_output[CHAT_SIZE_MAX];
static char atcmd_player_name[NAME_LENGTH];
@@ -83,7 +84,7 @@ const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) {
}
const char* atcommand_msgfd(int fd, int msg_number) {
- struct map_session_data *sd = session_isValid(fd) ? session[fd]->session_data : NULL;
+ struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL;
if( !(msg_number >= 0 && msg_number < MAX_MSG) )
return "??";
if( !sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number] )
@@ -3676,7 +3677,7 @@ ACMD(reloadscript) {
}
mapit->free(iter);
- flush_fifos();
+ sockt->flush_fifos();
map->reloadnpc(true); // reload config files seeking for npcs
script->reload();
npc->reload();
@@ -10199,7 +10200,7 @@ bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtComm
bool atcommand_hp_add(char *name, AtCommandFunc func) {
/* if commands are added after group permissions are thrown in, they end up with no permissions */
/* so we restrict commands to be linked in during boot */
- if( runflag == MAPSERVER_ST_RUNNING ) {
+ if( core->runflag == MAPSERVER_ST_RUNNING ) {
ShowDebug("atcommand_hp_add: Commands can't be added after server is ready, skipping '%s'...\n",name);
return false;
}
@@ -10231,7 +10232,7 @@ void atcommand_db_clear(void) {
}
void atcommand_doload(void) {
- if( runflag >= MAPSERVER_ST_RUNNING )
+ if( core->runflag >= MAPSERVER_ST_RUNNING )
atcommand->cmd_db_clear();
if( atcommand->db == NULL )
atcommand->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 88ddde8c2..ccc7d3725 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -6,7 +6,7 @@
#define MAP_ATCOMMAND_H
#include "map/pc_groups.h"
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/conf.h"
#include "common/db.h"
@@ -127,12 +127,12 @@ struct atcommand_interface {
const char* (*msgsd) (struct map_session_data *sd, int msg_number);
};
-struct atcommand_interface *atcommand;
-
#ifdef HERCULES_CORE
void atcommand_defaults(void);
#endif // HERCULES_CORE
+HPShared struct atcommand_interface *atcommand;
+
/* stay here */
#define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info)
diff --git a/src/map/battle.c b/src/map/battle.c
index f64fde55f..671d63200 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -43,6 +43,7 @@
struct Battle_Config battle_config;
struct battle_interface battle_s;
+struct battle_interface *battle;
int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl.
struct unit_data *ud;
diff --git a/src/map/battle.h b/src/map/battle.h
index 6bc2659b9..b211afff5 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -6,7 +6,7 @@
#define MAP_BATTLE_H
#include "map/map.h" //ELE_MAX
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
/**
* Declarations
@@ -509,10 +509,6 @@ struct Battle_Config {
int feature_roulette;
};
-#ifdef HERCULES_CORE
-extern struct Battle_Config battle_config;
-#endif // HERCULES_CORE
-
/* criteria for battle_config.idletime_critera */
enum e_battle_config_idletime {
BCIDLE_WALK = 0x001,
@@ -643,10 +639,12 @@ struct battle_interface {
void (*calc_misc_attack_unknown) (struct block_list *src, struct block_list *target, uint16 *skill_id, uint16 *skill_lv, int *mflag, struct Damage *md);
};
-struct battle_interface *battle;
-
#ifdef HERCULES_CORE
+extern struct Battle_Config battle_config;
+
void battle_defaults(void);
#endif // HERCULES_CORE
+HPShared struct battle_interface *battle;
+
#endif /* MAP_BATTLE_H */
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 0fe42110f..915ccc851 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -32,6 +32,7 @@
#include <string.h>
struct battleground_interface bg_s;
+struct battleground_interface *bg;
/// Search a BG Team using bg_id
struct battleground_data* bg_team_search(int bg_id) {
diff --git a/src/map/battleground.h b/src/map/battleground.h
index a67deb722..094037f43 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -6,7 +6,7 @@
#define MAP_BATTLEGROUND_H
#include "map/map.h" // EVENT_NAME_LENGTH
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h" // struct party
@@ -127,10 +127,10 @@ struct battleground_interface {
void (*config_read) (void);
};
-struct battleground_interface *bg;
-
#ifdef HERCULES_CORE
void battleground_defaults(void);
#endif // HERCULES_CORE
+HPShared struct battleground_interface *bg;
+
#endif /* MAP_BATTLEGROUND_H */
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index d1ce4ba0d..a1b6e9e65 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -19,6 +19,7 @@
#include "common/strlib.h" // safestrncpy
struct buyingstore_interface buyingstore_s;
+struct buyingstore_interface *buyingstore;
/// Returns unique buying store id
unsigned int buyingstore_getuid(void) {
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index f23790459..74f61239f 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -5,7 +5,7 @@
#ifndef MAP_BUYINGSTORE_H
#define MAP_BUYINGSTORE_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // MAX_SLOTS
struct map_session_data;
@@ -71,10 +71,10 @@ struct buyingstore_interface {
unsigned int (*getuid) (void);
};
-struct buyingstore_interface *buyingstore;
-
#ifdef HERCULES_CORE
void buyingstore_defaults (void);
#endif // HERCULES_CORE
+HPShared struct buyingstore_interface *buyingstore;
+
#endif // MAP_BUYINGSTORE_H
diff --git a/src/map/channel.c b/src/map/channel.c
index 69f7ab872..337d05504 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -28,6 +28,7 @@
#include <string.h>
struct channel_interface channel_s;
+struct channel_interface *channel;
static struct Channel_Config channel_config;
@@ -301,7 +302,7 @@ void channel_join_sub(struct channel_data *chan, struct map_session_data *sd, bo
/* someone is cheating, we kindly disconnect the bastard */
if (sd->channel_count > 200) {
- set_eof(sd->fd);
+ sockt->eof(sd->fd);
}
}
diff --git a/src/map/channel.h b/src/map/channel.h
index de1779d96..391045c59 100644
--- a/src/map/channel.h
+++ b/src/map/channel.h
@@ -4,7 +4,7 @@
#ifndef MAP_CHANNEL_H
#define MAP_CHANNEL_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h"
@@ -109,10 +109,10 @@ struct channel_interface {
void (*config_read) (void);
};
-struct channel_interface *channel;
-
#ifdef HERCULES_CORE
void channel_defaults(void);
#endif // HERCULES_CORE
+HPShared struct channel_interface *channel;
+
#endif /* MAP_CHANNEL_H */
diff --git a/src/map/chat.c b/src/map/chat.c
index 08c904290..ed9d9c598 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -24,6 +24,7 @@
#include <string.h>
struct chat_interface chat_s;
+struct chat_interface *chat;
/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
/// Returns a chatroom object on success, or NULL on failure.
diff --git a/src/map/chat.h b/src/map/chat.h
index 31048d5dd..68f9107f3 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -6,7 +6,7 @@
#define MAP_CHAT_H
#include "map/map.h" // struct block_list, CHATROOM_TITLE_SIZE
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct chat_data;
@@ -55,10 +55,10 @@ struct chat_interface {
struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl);
};
-struct chat_interface *chat;
-
#ifdef HERCULES_CORE
void chat_defaults(void);
#endif // HERCULES_CORE
+HPShared struct chat_interface *chat;
+
#endif /* MAP_CHAT_H */
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 5bd1e436f..65c042533 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -38,6 +38,7 @@
#include <sys/types.h>
struct chrif_interface chrif_s;
+struct chrif_interface *chrif;
//Used Packets:
//2af8: Outgoing, chrif_connect -> 'connect to charserver / auth @ charserver'
@@ -102,11 +103,11 @@ void chrif_reset(void) {
/// Releases the cookie when all characters are saved.
/// If all the conditions are met, it stops the core loop.
void chrif_check_shutdown(void) {
- if( runflag != MAPSERVER_ST_SHUTDOWN )
+ if( core->runflag != MAPSERVER_ST_SHUTDOWN )
return;
if( db_size(chrif->auth_db) > 0 )
return;
- runflag = CORE_ST_STOP;
+ core->runflag = CORE_ST_STOP;
}
struct auth_node* chrif_search(int account_id) {
@@ -124,8 +125,8 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
if ( (node = chrif->auth_check(account_id, char_id, state) ) ) {
int fd = node->sd ? node->sd->fd : node->fd;
- if ( session[fd] && session[fd]->session_data == node->sd )
- session[fd]->session_data = NULL;
+ if ( sockt->session[fd] && sockt->session[fd]->session_data == node->sd )
+ sockt->session[fd]->session_data = NULL;
if ( node->sd ) {
if( node->sd->regs.vars )
@@ -177,8 +178,8 @@ bool chrif_auth_logout(TBL_PC* sd, enum sd_state state)
{
if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
- if ( session[sd->fd] )
- session[sd->fd]->session_data = NULL;
+ if ( sockt->session[sd->fd] )
+ sockt->session[sd->fd]->session_data = NULL;
sd->fd = 0;
}
@@ -219,14 +220,14 @@ void chrif_checkdefaultlogin(void) {
bool chrif_setip(const char* ip) {
char ip_str[16];
- if ( !( chrif->ip = host2ip(ip) ) ) {
+ if (!(chrif->ip = sockt->host2ip(ip))) {
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
return false;
}
safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str));
- ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str));
+ ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(chrif->ip, ip_str));
return true;
}
@@ -238,7 +239,7 @@ void chrif_setport(uint16 port) {
// says whether the char-server is connected or not
int chrif_isconnected(void) {
- return (chrif->fd > 0 && session[chrif->fd] != NULL && chrif->state == 2);
+ return (chrif->fd > 0 && sockt->session[chrif->fd] != NULL && chrif->state == 2);
}
/*==========================================
@@ -384,7 +385,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port)
WFIFOL(chrif->fd,24) = htonl(ip);
WFIFOW(chrif->fd,28) = htons(port);
WFIFOB(chrif->fd,30) = sd->status.sex;
- WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr);
+ WFIFOL(chrif->fd,31) = htonl(sockt->session[sd->fd]->client_addr);
WFIFOL(chrif->fd,35) = sd->group_id;
WFIFOSET(chrif->fd,39);
@@ -542,7 +543,7 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
struct auth_node *node= chrif->search(sd->bl.id);
if( node != NULL || !chrif->isconnected() ) {
- set_eof(sd->fd);
+ sockt->eof(sd->fd);
return;
}
@@ -552,7 +553,7 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
WFIFOL(chrif->fd,6) = sd->status.char_id;
WFIFOL(chrif->fd,10) = sd->login_id1;
WFIFOB(chrif->fd,14) = sd->status.sex;
- WFIFOL(chrif->fd,15) = htonl(session[sd->fd]->client_addr);
+ WFIFOL(chrif->fd,15) = htonl(sockt->session[sd->fd]->client_addr);
WFIFOB(chrif->fd,19) = hstandalone ? 1 : 0;
WFIFOSET(chrif->fd,20);
chrif->sd_to_auth(sd, ST_LOGIN);
@@ -607,7 +608,7 @@ void chrif_authok(int fd) {
sd = node->sd;
- if( runflag == MAPSERVER_ST_RUNNING &&
+ if( core->runflag == MAPSERVER_ST_RUNNING &&
node->account_id == account_id &&
node->char_id == char_id &&
node->login_id1 == login_id1 )
@@ -980,7 +981,7 @@ void chrif_idbanned(int fd) {
clif->message(sd->fd, tmpstr);
}
- set_eof(sd->fd); // forced to disconnect for the change
+ sockt->eof(sd->fd); // forced to disconnect for the change
map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
}
@@ -1232,9 +1233,9 @@ bool chrif_char_offline_nsd(int account_id, int char_id) {
bool chrif_flush(void) {
chrif_check(false);
- set_nonblocking(chrif->fd, 0);
- flush_fifos();
- set_nonblocking(chrif->fd, 1);
+ sockt->set_nonblocking(chrif->fd, 0);
+ sockt->flush_fifos();
+ sockt->set_nonblocking(chrif->fd, 1);
return true;
}
@@ -1286,7 +1287,7 @@ void chrif_update_ip(int fd) {
WFIFOHEAD(fd,6);
- new_ip = host2ip(chrif->ip_str);
+ new_ip = sockt->host2ip(chrif->ip_str);
if (new_ip && new_ip != chrif->ip)
chrif->ip = new_ip; //Update chrif->ip
@@ -1308,14 +1309,14 @@ void chrif_keepalive(int fd) {
WFIFOSET(fd,2);
}
void chrif_keepalive_ack(int fd) {
- session[fd]->flag.ping = 0;/* reset ping state, we received a packet */
+ sockt->session[fd]->flag.ping = 0;/* reset ping state, we received a packet */
}
void chrif_skillid2idx(int fd) {
int i, count = 0;
if( fd == 0 ) fd = chrif->fd;
- if( !session_isValid(fd) )
+ if (!sockt->session_is_valid(fd))
return;
WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
@@ -1340,22 +1341,22 @@ int chrif_parse(int fd) {
// only process data from the char-server
if ( fd != chrif->fd ) {
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-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);
chrif->fd = -1;
chrif->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 */
chrif->keepalive(fd);
- session[fd]->flag.ping = 2;
+ sockt->session[fd]->flag.ping = 2;
}
}
@@ -1377,7 +1378,7 @@ int chrif_parse(int fd) {
if (r == 2) return 0; // Didn't have enough data (len==-1)
ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
@@ -1418,7 +1419,7 @@ int chrif_parse(int fd) {
case 0x2b27: chrif->authfail(fd); break;
default:
ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
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]
@@ -1475,7 +1476,7 @@ bool send_users_tochar(void) {
*------------------------------------------*/
int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
static int displayed = 0;
- if ( chrif->fd <= 0 || session[chrif->fd] == NULL ) {
+ if ( chrif->fd <= 0 || sockt->session[chrif->fd] == NULL ) {
if ( !displayed ) {
ShowStatus("Attempting to connect to Char Server. Please wait.\n");
displayed = 1;
@@ -1483,12 +1484,12 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
chrif->state = 0;
- if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex]
+ if ((chrif->fd = sockt->make_connection(chrif->ip, chrif->port,NULL)) == -1) //Attempt to connect later. [Skotlex]
return 0;
- session[chrif->fd]->func_parse = chrif->parse;
- session[chrif->fd]->flag.server = 1;
- realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->session[chrif->fd]->func_parse = chrif->parse;
+ sockt->session[chrif->fd]->flag.server = 1;
+ sockt->realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chrif->connect(chrif->fd);
chrif->connected = (chrif->state == 2);
@@ -1529,7 +1530,7 @@ void chrif_send_report(char* buf, int len) {
WFIFOSET(chrif->fd,len + 2);
- flush_fifo(chrif->fd); /* ensure it's sent now. */
+ sockt->flush(chrif->fd); /* ensure it's sent now. */
}
#endif
}
@@ -1601,7 +1602,7 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
void do_final_chrif(void)
{
if( chrif->fd != -1 ) {
- do_close(chrif->fd);
+ sockt->close(chrif->fd);
chrif->fd = -1;
}
diff --git a/src/map/chrif.h b/src/map/chrif.h
index cac965f74..25f69a309 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -6,7 +6,7 @@
#define MAP_CHRIF_H
#include "map/map.h" //TBL_PC
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct eri;
@@ -150,10 +150,10 @@ struct chrif_interface {
void (*del_scdata_single) (int account_id, int char_id, short type);
};
-struct chrif_interface *chrif;
-
#ifdef HERCULES_CORE
void chrif_defaults(void);
#endif // HERCULES_CORE
+HPShared struct chrif_interface *chrif;
+
#endif /* MAP_CHRIF_H */
diff --git a/src/map/clif.c b/src/map/clif.c
index d00cac0ee..ded028974 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -59,6 +59,9 @@
#include <time.h>
struct clif_interface clif_s;
+struct clif_interface *clif;
+
+struct s_packet_db packet_db[MAX_PACKET_DB + 1];
/* re-usable */
static struct packet_itemlist_normal itemlist_normal;
@@ -193,22 +196,22 @@ static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned i
*------------------------------------------*/
bool clif_setip(const char* ip) {
char ip_str[16];
- clif->map_ip = host2ip(ip);
+ clif->map_ip = sockt->host2ip(ip);
if ( !clif->map_ip ) {
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
return false;
}
safestrncpy(clif->map_ip_str, ip, sizeof(clif->map_ip_str));
- ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->map_ip, ip_str));
+ ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(clif->map_ip, ip_str));
return true;
}
bool clif_setbindip(const char* ip) {
- clif->bind_ip = host2ip(ip);
+ clif->bind_ip = sockt->host2ip(ip);
if ( clif->bind_ip ) {
char ip_str[16];
- ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->bind_ip, ip_str));
+ ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(clif->bind_ip, ip_str));
return true;
}
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
@@ -242,10 +245,9 @@ uint16 clif_getport(void)
/*==========================================
* Updates server ip resolution and returns it
*------------------------------------------*/
-uint32 clif_refresh_ip(void) {
- uint32 new_ip;
-
- new_ip = host2ip(clif->map_ip_str);
+uint32 clif_refresh_ip(void)
+{
+ uint32 new_ip = sockt->host2ip(clif->map_ip_str);
if ( new_ip && new_ip != clif->map_ip ) {
clif->map_ip = new_ip;
ShowInfo("Updating IP resolution of [%s].\n", clif->map_ip_str);
@@ -292,7 +294,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) {
nullpo_ret(sd = (struct map_session_data *)bl);
fd = sd->fd;
- if (!fd || session[fd] == NULL) //Don't send to disconnected clients.
+ if (!fd || sockt->session[fd] == NULL) //Don't send to disconnected clients.
return 0;
buf = va_arg(ap,void*);
@@ -428,7 +430,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
for(i = 0; i < cd->users; i++) {
if (type == CHAT_WOS && cd->usersd[i] == sd)
continue;
- if ((fd=cd->usersd[i]->fd) >0 && session[fd]) { // Added check to see if session exists [PoW]
+ if ((fd=cd->usersd[i]->fd) >0 && sockt->session[fd]) { // Added check to see if session exists [PoW]
WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
@@ -691,14 +693,14 @@ void clif_authrefuse(int fd, uint8 error_code)
// TODO: type enum
void clif_authfail_fd(int fd, int type)
{
- if (!fd || !session[fd] || session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players!
+ if (!fd || !sockt->session[fd] || sockt->session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players!
return;
WFIFOHEAD(fd, packet_len(0x81));
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = type;
WFIFOSET(fd,packet_len(0x81));
- set_eof(fd);
+ sockt->eof(fd);
}
@@ -1711,7 +1713,7 @@ void clif_quitsave(int fd,struct map_session_data *sd) {
else if (sd->fd) {
//Disassociate session from player (session is deleted after this function was called)
//And set a timer to make him quit later.
- session[sd->fd]->session_data = NULL;
+ sockt->session[sd->fd]->session_data = NULL;
sd->fd = 0;
timer->add(timer->gettick() + 10000, clif->delayquit, sd->bl.id, 0);
}
@@ -1746,7 +1748,7 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index,
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOL(fd,22) = htonl(ip);
- WFIFOW(fd,26) = ntows(htons(port)); // [!] LE byte order here [!]
+ WFIFOW(fd,26) = sockt->ntows(htons(port)); // [!] LE byte order here [!]
WFIFOSET(fd,packet_len(0x92));
}
@@ -2238,7 +2240,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
struct packet_additem p;
nullpo_retv(sd);
- if( !session_isActive(sd->fd) ) //Sasuke-
+ if (!sockt->session_is_active(sd->fd)) //Sasuke-
return;
if( fail )
@@ -2697,7 +2699,7 @@ void clif_updatestatus(struct map_session_data *sd,int type)
fd=sd->fd;
- if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin]
+ if (!sockt->session_is_active(fd)) // Invalid pointer fix, by sasuke [Kevin]
return;
WFIFOHEAD(fd, 14);
@@ -3605,7 +3607,7 @@ void clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
nullpo_retv(cd);
fd = sd->fd;
- if (!session_isActive(fd))
+ if (!sockt->session_is_active(fd))
return;
t = (int)(cd->owner->type == BL_NPC);
WFIFOHEAD(fd, 8 + (28*(cd->users+t)));
@@ -5404,7 +5406,7 @@ void clif_displaymessage_sprintf(const int fd, const char *mes, ...) {
if (map->cpsd_active && fd == 0) {
ShowInfo("HCP: ");
va_start(ap,mes);
- vShowMessage_(MSG_NONE,mes,ap);
+ vShowMessage(mes,ap);
va_end(ap);
ShowMessage("\n");
} else if (fd > 0) {
@@ -5683,7 +5685,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len)
/// 2 = ignored by target
/// 3 = everyone ignored by target
void clif_wis_end(int fd, int flag) {
- struct map_session_data *sd = session_isValid(fd) ? session[fd]->session_data : NULL;
+ struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL;
struct packet_wis_end p;
if( !sd )
@@ -7450,7 +7452,7 @@ void clif_guild_notice(struct map_session_data* sd, struct guild* g)
fd = sd->fd;
- if ( !session_isActive(fd) )
+ if (!sockt->session_is_active(fd))
return;
if(g->mes1[0] == '\0' && g->mes2[0] == '\0')
@@ -8806,7 +8808,7 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_,
{
//Hacked message, or infamous "client desynchronize" issue where they pick one char while loading another.
ShowWarning("clif_process_message: Player '%s' sent a message using an incorrect name! Forcing a relog...\n", sd->status.name);
- set_eof(fd); // Just kick them out to correct it.
+ sockt->eof(fd); // Just kick them out to correct it.
return false;
}
@@ -8943,7 +8945,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
client_tick = RFIFOL(fd, packet_db[cmd].pos[3]);
sex = RFIFOB(fd, packet_db[cmd].pos[4]);
- if( runflag != MAPSERVER_ST_RUNNING ) { // not allowed
+ if( core->runflag != MAPSERVER_ST_RUNNING ) { // not allowed
clif->authfail_fd(fd,1);// server closed
return;
}
@@ -8956,7 +8958,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // Rejected by server
WFIFOSET(fd,packet_len(0x6a));
- set_eof(fd);
+ sockt->eof(fd);
return;
}
@@ -8976,7 +8978,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
* clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF;
sd->parse_cmd_func = clif->parse_cmd;
- session[fd]->session_data = sd;
+ sockt->session[fd]->session_data = sd;
pc->setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
@@ -9528,7 +9530,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd)
if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] &&
(!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
{
- set_eof(fd);
+ sockt->eof(fd);
clif->disconnect_ack(sd, 0);
} else {
@@ -9981,7 +9983,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) {
&& (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout)
) {
//Send to char-server for character selection.
- chrif->charselectreq(sd, session[fd]->client_addr);
+ chrif->charselectreq(sd, sockt->session[fd]->client_addr);
} else {
clif->disconnect_ack(sd, 1);
}
@@ -18297,13 +18299,13 @@ int clif_parse(int fd) {
unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd);
// begin main client packet processing loop
- sd = (TBL_PC *)session[fd]->session_data;
+ sd = (TBL_PC *)sockt->session[fd]->session_data;
- if (session[fd]->flag.eof) {
+ if (sockt->session[fd]->flag.eof) {
if (sd) {
if (sd->state.autotrade) {
//Disassociate character from the socket connection.
- session[fd]->session_data = NULL;
+ sockt->session[fd]->session_data = NULL;
sd->fd = 0;
ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", sd->status.name);
} else
@@ -18317,9 +18319,9 @@ int clif_parse(int fd) {
map->quit(sd);
}
} else {
- ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL));
+ ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", sockt->ip2str(sockt->session[fd]->client_addr, NULL));
}
- do_close(fd);
+ sockt->close(fd);
return 0;
}
@@ -18348,7 +18350,7 @@ int clif_parse(int fd) {
#ifdef DUMP_INVALID_PACKET
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
@@ -18364,7 +18366,7 @@ int clif_parse(int fd) {
#ifdef DUMP_INVALID_PACKET
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
@@ -18506,8 +18508,8 @@ int do_init_clif(bool minimal)
packetdb_loaddb();
- set_defaultparse(clif->parse);
- if( make_listen_bind(clif->bind_ip,clif->map_port) == -1 ) {
+ sockt->set_defaultparse(clif->parse);
+ if (sockt->make_listen_bind(clif->bind_ip,clif->map_port) == -1) {
ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",clif->map_port);
exit(EXIT_FAILURE);
}
diff --git a/src/map/clif.h b/src/map/clif.h
index c827406ca..66a749818 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -7,7 +7,7 @@
#include "map/map.h"
#include "map/packets_struct.h"
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h"
#include <stdarg.h>
@@ -558,11 +558,6 @@ struct merge_item {
};
/**
- * Vars
- **/
-struct s_packet_db packet_db[MAX_PACKET_DB + 1];
-
-/**
* Clif.c Interface
**/
struct clif_interface {
@@ -1322,10 +1317,15 @@ struct clif_interface {
void (*pNPCMarketPurchase) (int fd, struct map_session_data *sd);
};
-struct clif_interface *clif;
-
#ifdef HERCULES_CORE
+/**
+ * Vars
+ **/
+extern struct s_packet_db packet_db[MAX_PACKET_DB + 1];
+
void clif_defaults(void);
#endif // HERCULES_CORE
+HPShared struct clif_interface *clif;
+
#endif /* MAP_CLIF_H */
diff --git a/src/map/duel.c b/src/map/duel.c
index 4cd2e276f..762745b75 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -17,6 +17,7 @@
#include <time.h>
struct duel_interface duel_s;
+struct duel_interface *duel;
/*==========================================
* Duel organizing functions [LuzZza]
diff --git a/src/map/duel.h b/src/map/duel.h
index 0c55c1266..c77f1c351 100644
--- a/src/map/duel.h
+++ b/src/map/duel.h
@@ -5,7 +5,7 @@
#ifndef MAP_DUEL_H
#define MAP_DUEL_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct map_session_data;
@@ -42,10 +42,10 @@ struct duel_interface {
void (*final) (void);
};
-struct duel_interface *duel;
-
#ifdef HERCULES_CORE
void duel_defaults(void);
#endif // HERCULES_CORE
+HPShared struct duel_interface *duel;
+
#endif /* MAP_DUEL_H */
diff --git a/src/map/elemental.c b/src/map/elemental.c
index 459ce2a39..435dffaf4 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -42,6 +42,7 @@
#include <string.h>
struct elemental_interface elemental_s;
+struct elemental_interface *elemental;
int elemental_search_index(int class_) {
int i;
@@ -785,7 +786,7 @@ int read_elementaldb(void) {
sprintf(line, "%s/%s", map->db_path, "elemental_db.txt");
- if( runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up
+ if( core->runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up
memset(elemental->db,0,sizeof(elemental->db));
fp = fopen(line, "r");
diff --git a/src/map/elemental.h b/src/map/elemental.h
index 582e1059c..d040f8337 100644
--- a/src/map/elemental.h
+++ b/src/map/elemental.h
@@ -7,7 +7,7 @@
#include "map/status.h" // struct status_data, struct status_change
#include "map/unit.h" // struct unit_data
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // NAME_LENGTH
#include <stdarg.h>
@@ -120,10 +120,10 @@ struct elemental_interface {
int (*read_db) (void);
};
-struct elemental_interface *elemental;
-
#ifdef HERCULES_CORE
void elemental_defaults(void);
#endif // HERCULES_CORE
+HPShared struct elemental_interface *elemental;
+
#endif /* MAP_ELEMENTAL_H */
diff --git a/src/map/guild.c b/src/map/guild.c
index 5f6ce83c6..15c65ec98 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -36,6 +36,7 @@
#include <string.h>
struct guild_interface guild_s;
+struct guild_interface *guild;
/*==========================================
* Retrieves and validates the sd pointer for this guild member [Skotlex]
diff --git a/src/map/guild.h b/src/map/guild.h
index 18a25af58..a11585fbc 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -6,7 +6,7 @@
#define MAP_GUILD_H
#include "map/map.h" // EVENT_NAME_LENGTH, TBL_PC
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h"
@@ -163,10 +163,10 @@ struct guild_interface {
void (*castle_reconnect_sub) (void *key, void *data, va_list ap);
};
-struct guild_interface *guild;
-
#ifdef HERCULES_CORE
void guild_defaults(void);
#endif // HERCULES_CORE
+HPShared struct guild_interface *guild;
+
#endif /* MAP_GUILD_H */
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 305d60f5b..cc736708d 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -45,6 +45,8 @@
struct homunculus_interface homunculus_s;
struct homun_dbs homundbs;
+struct homunculus_interface *homun;
+
//Returns the viewdata for homunculus
struct view_data* homunculus_get_viewdata(int class_) {
if (homdb_checkid(class_))
diff --git a/src/map/homunculus.h b/src/map/homunculus.h
index 95b613fff..9d23fbe2c 100644
--- a/src/map/homunculus.h
+++ b/src/map/homunculus.h
@@ -7,6 +7,7 @@
#include "map/status.h" // struct status_data, struct status_change
#include "map/unit.h" // struct unit_data
+#include "common/hercules.h"
#include "common/mmo.h"
struct map_session_data;
@@ -160,10 +161,10 @@ struct homunculus_interface {
int8 (*get_intimacy_grade) (struct homun_data *hd);
};
-struct homunculus_interface *homun;
-
#ifdef HERCULES_CORE
void homunculus_defaults(void);
#endif // HERCULES_CORE
+HPShared struct homunculus_interface *homun;
+
#endif /* MAP_HOMUNCULUS_H */
diff --git a/src/map/instance.c b/src/map/instance.c
index 92acd1bbb..1fc396325 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -32,6 +32,7 @@
#include <time.h>
struct instance_interface instance_s;
+struct instance_interface *instance;
/// Checks whether given instance id is valid or not.
bool instance_is_valid(int instance_id) {
diff --git a/src/map/instance.h b/src/map/instance.h
index e17d6866f..589e1a511 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -6,7 +6,7 @@
#define MAP_INSTANCE_H
#include "map/script.h" // struct reg_db
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // struct point
struct HPluginData;
@@ -85,10 +85,10 @@ struct instance_interface {
int (*destroy_timer) (int tid, int64 tick, int id, intptr_t data);
};
-struct instance_interface *instance;
-
#ifdef HERCULES_CORE
void instance_defaults(void);
#endif // HERCULES_CORE
+HPShared struct instance_interface *instance;
+
#endif /* MAP_INSTANCE_H */
diff --git a/src/map/intif.c b/src/map/intif.c
index 26fd1949c..12f679552 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
struct intif_interface intif_s;
+struct intif_interface *intif;
#define inter_fd (chrif->fd) // alias
@@ -45,7 +46,7 @@ struct intif_interface intif_s;
int CheckForCharServer(void)
{
- return ((chrif->fd <= 0) || session[chrif->fd] == NULL || session[chrif->fd]->wdata == NULL);
+ return ((chrif->fd <= 0) || sockt->session[chrif->fd] == NULL || sockt->session[chrif->fd]->wdata == NULL);
}
// pet
@@ -2145,9 +2146,9 @@ void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) {
void intif_parse_MessageToFD(int fd) {
int u_fd = RFIFOL(fd,4);
- if( session[u_fd] && session[u_fd]->session_data ) {
+ if( sockt->session[u_fd] && sockt->session[u_fd]->session_data ) {
int aid = RFIFOL(fd,8);
- struct map_session_data * sd = session[u_fd]->session_data;
+ struct map_session_data * sd = sockt->session[u_fd]->session_data;
/* matching e.g. previous fd owner didn't dc during request or is still the same */
if( sd && sd->bl.id == aid ) {
char msg[512];
diff --git a/src/map/intif.h b/src/map/intif.h
index 3303feb6e..369ac1d9b 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -5,7 +5,7 @@
#ifndef MAP_INTIF_H
#define MAP_INTIF_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
/**
* Declarations
@@ -182,10 +182,10 @@ struct intif_interface {
void (*pDeleteHomunculusOk) (int fd);
};
-struct intif_interface *intif;
-
#ifdef HERCULES_CORE
void intif_defaults(void);
#endif // HERCULES_CORE
+HPShared struct intif_interface *intif;
+
#endif /* MAP_INTIF_H */
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index b0f687c0d..86f854ff7 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -24,6 +24,7 @@
//#define IRCBOT_DEBUG
struct irc_bot_interface irc_bot_s;
+struct irc_bot_interface *ircbot;
char send_string[IRC_MESSAGE_LENGTH];
@@ -41,9 +42,9 @@ int irc_connect_timer(int tid, int64 tick, int id, intptr_t data) {
ircbot->last_try = timer->gettick();
- if ((ircbot->fd = make_connection(ircbot->ip, channel->config->irc_server_port, &opt)) > 0) {
- session[ircbot->fd]->func_parse = ircbot->parse;
- session[ircbot->fd]->flag.server = 1;
+ if ((ircbot->fd = sockt->make_connection(ircbot->ip, channel->config->irc_server_port, &opt)) > 0) {
+ sockt->session[ircbot->fd]->func_parse = ircbot->parse;
+ sockt->session[ircbot->fd]->flag.server = 1;
timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0);
ircbot->isOn = true;
}
@@ -114,13 +115,13 @@ struct irc_func* irc_func_search(char* function_name) {
int irc_parse(int fd) {
char *parse_string = NULL, *str_safe = NULL;
- if (session[fd]->flag.eof) {
- do_close(fd);
+ if (sockt->session[fd]->flag.eof) {
+ sockt->close(fd);
ircbot->fd = 0;
ircbot->isOn = false;
ircbot->isIn = false;
ircbot->fails = 0;
- ircbot->ip = host2ip(channel->config->irc_server);
+ ircbot->ip = sockt->host2ip(channel->config->irc_server);
timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0);
return 0;
}
@@ -415,7 +416,7 @@ void irc_bot_init(bool minimal) {
if (!channel->config->irc)
return;
- if (!(ircbot->ip = host2ip(channel->config->irc_server))) {
+ if (!(ircbot->ip = sockt->host2ip(channel->config->irc_server))) {
ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", channel->config->irc_server);
channel->config->irc = false;
return;
@@ -454,7 +455,7 @@ void irc_bot_final(void) {
return;
if( ircbot->isOn ) {
ircbot->send("QUIT :Hercules is shutting down");
- do_close(ircbot->fd);
+ sockt->close(ircbot->fd);
}
for( i = 0; i < ircbot->funcs.size; i++ ) {
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index b0bfd72f8..a85fc46e8 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -6,7 +6,7 @@
#ifndef MAP_IRC_BOT_H
#define MAP_IRC_BOT_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#define IRC_NICK_LENGTH 40
#define IRC_IDENT_LENGTH 40
@@ -59,10 +59,10 @@ struct irc_bot_interface {
void (*usernick) (int fd, char *cmd, char *source, char *target, char *msg);
};
-struct irc_bot_interface *ircbot;
-
#ifdef HERCULES_CORE
void ircbot_defaults(void);
#endif // HERCULES_CORE
+HPShared struct irc_bot_interface *ircbot;
+
#endif /* MAP_IRC_BOT_H */
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 644c16a00..7f5c2224c 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -26,6 +26,7 @@
#include <string.h>
struct itemdb_interface itemdb_s;
+struct itemdb_interface *itemdb;
/**
* Search for item name
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index e50ebfd3d..a3edd451e 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -6,7 +6,7 @@
#define MAP_ITEMDB_H
/* #include "map/map.h" */
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/conf.h"
#include "common/db.h"
#include "common/mmo.h" // ITEM_NAME_LENGTH
@@ -618,10 +618,10 @@ struct itemdb_interface {
bool (*lookup_const) (const config_setting_t *it, const char *name, int *value);
};
-struct itemdb_interface *itemdb;
-
#ifdef HERCULES_CORE
void itemdb_defaults(void);
#endif // HERCULES_CORE
+HPShared struct itemdb_interface *itemdb;
+
#endif /* MAP_ITEMDB_H */
diff --git a/src/map/log.c b/src/map/log.c
index 0a9b16418..0c5977c05 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -23,6 +23,7 @@
#include <string.h>
struct log_interface log_s;
+struct log_interface *logs;
/// obtain log type character for item/zeny logs
char log_picktype2char(e_log_pick_type type) {
diff --git a/src/map/log.h b/src/map/log.h
index ef654149c..4b2b5d4d6 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -5,7 +5,7 @@
#ifndef MAP_LOG_H
#define MAP_LOG_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/sql.h"
/**
@@ -129,10 +129,10 @@ struct log_interface {
bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id);
};
-struct log_interface *logs;
-
#ifdef HERCULES_CORE
void log_defaults(void);
#endif // HERCULES_CORE
+HPShared struct log_interface *logs;
+
#endif /* MAP_LOG_H */
diff --git a/src/map/mail.c b/src/map/mail.c
index 184e2be8d..0bdad2877 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -19,6 +19,7 @@
#include <string.h>
struct mail_interface mail_s;
+struct mail_interface *mail;
void mail_clear(struct map_session_data *sd)
{
diff --git a/src/map/mail.h b/src/map/mail.h
index 4f325067d..128b1fbaa 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -5,7 +5,7 @@
#ifndef MAP_MAIL_H
#define MAP_MAIL_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct item;
struct mail_message;
@@ -23,10 +23,10 @@ struct mail_interface {
bool (*invalid_operation) (struct map_session_data *sd);
};
-struct mail_interface *mail;
-
#ifdef HERCULES_CORE
void mail_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mail_interface *mail;
+
#endif /* MAP_MAIL_H */
diff --git a/src/map/map.c b/src/map/map.c
index e43d4d7f6..a7b171ddf 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -69,6 +69,9 @@
struct map_interface map_s;
struct mapit_interface mapit_s;
+struct map_interface *map;
+struct mapit_interface *mapit;
+
/*==========================================
* server player count (of all mapservers)
*------------------------------------------*/
@@ -1799,7 +1802,7 @@ int map_quit(struct map_session_data *sd) {
if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */
bg->team_leave(sd,BGTL_QUIT);
- if (sd->state.autotrade && runflag != MAPSERVER_ST_SHUTDOWN && !channel->config->closing)
+ if (sd->state.autotrade && core->runflag != MAPSERVER_ST_SHUTDOWN && !channel->config->closing)
pc->autotrade_update(sd,PAUC_REMOVE);
skill->cooldown_save(sd);
@@ -3538,12 +3541,12 @@ int map_config_read(char *cfgName) {
*ptr = '\0';
if(strcmpi(w1,"timestamp_format")==0)
- safestrncpy(timestamp_format, w2, 20);
+ safestrncpy(showmsg->timestamp_format, w2, 20);
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,"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, "userid")==0)
chrif->setuserid(w2);
@@ -3593,7 +3596,7 @@ int map_config_read(char *cfgName) {
else if (strcmpi(w1, "use_grf") == 0)
map->enable_grf = config_switch(w2);
else if (strcmpi(w1, "console_msg_log") == 0)
- console_msg_log = atoi(w2);//[Ind]
+ showmsg->console_log = atoi(w2);//[Ind]
else if (strcmpi(w1, "default_language") == 0)
safestrncpy(map->default_lang_str, w2, sizeof(map->default_lang_str));
else if (strcmpi(w1, "import") == 0)
@@ -5542,9 +5545,9 @@ void set_server_type(void) {
/// Called when a terminate signal is received.
void do_shutdown(void)
{
- if( runflag != MAPSERVER_ST_SHUTDOWN )
+ if( core->runflag != MAPSERVER_ST_SHUTDOWN )
{
- runflag = MAPSERVER_ST_SHUTDOWN;
+ core->runflag = MAPSERVER_ST_SHUTDOWN;
ShowStatus("Shutting down...\n");
{
struct map_session_data* sd;
@@ -5552,7 +5555,7 @@ void do_shutdown(void)
for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) )
clif->GM_kick(NULL, sd);
mapit->free(iter);
- flush_fifos();
+ sockt->flush_fifos();
}
chrif->check_shutdown();
}
@@ -5612,60 +5615,6 @@ void map_cp_defaults(void) {
console->input->addCommand("gm:use",CPCMD_A(gm_use));
#endif
}
-/* Hercules Plugin Mananger */
-void map_hp_symbols(void) {
- /* full interfaces */
- HPM->share(atcommand,"atcommand");
- HPM->share(battle,"battle");
- HPM->share(bg,"battlegrounds");
- HPM->share(buyingstore,"buyingstore");
- HPM->share(channel,"channel");
- HPM->share(clif,"clif");
- HPM->share(chrif,"chrif");
- HPM->share(guild,"guild");
- HPM->share(gstorage,"gstorage");
- HPM->share(homun,"homun");
- HPM->share(map,"map");
- HPM->share(ircbot,"ircbot");
- HPM->share(itemdb,"itemdb");
- HPM->share(logs,"logs");
- HPM->share(mail,"mail");
- HPM->share(instance,"instance");
- HPM->share(script,"script");
- HPM->share(searchstore,"searchstore");
- HPM->share(skill,"skill");
- HPM->share(vending,"vending");
- HPM->share(pc,"pc");
- HPM->share(pcg,"pc_groups");
- HPM->share(party,"party");
- HPM->share(storage,"storage");
- HPM->share(trade,"trade");
- HPM->share(status,"status");
- HPM->share(chat, "chat");
- HPM->share(duel,"duel");
- HPM->share(elemental,"elemental");
- HPM->share(intif,"intif");
- HPM->share(mercenary,"mercenary");
- HPM->share(mob,"mob");
- HPM->share(unit,"unit");
- HPM->share(npc,"npc");
- HPM->share(mapreg,"mapreg");
- HPM->share(pet,"pet");
- HPM->share(path,"path");
- HPM->share(quest,"quest");
-#ifdef PCRE_SUPPORT
- HPM->share(npc_chat,"npc_chat");
- HPM->share(libpcre,"libpcre");
-#endif
- HPM->share(mapit,"mapit");
- HPM->share(mapindex,"mapindex");
- /* sql link */
- HPM->share(map->mysql_handle,"sql_handle");
- /* specific */
- HPM->share(atcommand->create,"addCommand");
- HPM->share(script->addScript,"addScript");
- HPM->share(HPM_map_add_group_permission,"addGroupPermission");
-}
void map_load_defaults(void) {
mapindex_defaults();
@@ -5720,7 +5669,7 @@ void map_load_defaults(void) {
*/
static CMDLINEARG(runonce)
{
- runflag = CORE_ST_STOP;
+ core->runflag = CORE_ST_STOP;
return true;
}
/**
@@ -5828,7 +5777,7 @@ static CMDLINEARG(logconfig)
static CMDLINEARG(scriptcheck)
{
map->minimal = true;
- runflag = CORE_ST_STOP;
+ core->runflag = CORE_ST_STOP;
map->scriptcheck = true;
return true;
}
@@ -5858,7 +5807,7 @@ static CMDLINEARG(generatetranslations) {
ShowError("export-dialog: failed to open '%s' for writing\n",script->lang_export_file);
}
- runflag = CORE_ST_STOP;
+ core->runflag = CORE_ST_STOP;
return true;
}
@@ -5902,7 +5851,6 @@ int do_init(int argc, char *argv[])
map->GRF_PATH_FILENAME = aStrdup("conf/grf-files.txt");
HPM_map_do_init();
- HPM->symbol_defaults_sub = map_hp_symbols;
cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT);
HPM->config_read();
@@ -5923,7 +5871,7 @@ int do_init(int argc, char *argv[])
if (!map->ip_set || !map->char_ip_set) {
char ip_str[16];
- ip2str(sockt->addr_[0], ip_str);
+ sockt->ip2str(sockt->addr_[0], ip_str);
ShowWarning("Not all IP addresses in /conf/map-server.conf configured, auto-detecting...\n");
@@ -6057,9 +6005,9 @@ int do_init(int argc, char *argv[])
ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port);
- if( runflag != CORE_ST_STOP ) {
- shutdown_callback = map->do_shutdown;
- runflag = MAPSERVER_ST_RUNNING;
+ if( core->runflag != CORE_ST_STOP ) {
+ core->shutdown_callback = map->do_shutdown;
+ core->runflag = MAPSERVER_ST_RUNNING;
}
map_cp_defaults();
diff --git a/src/map/map.h b/src/map/map.h
index 826548f49..d4ab954be 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -5,10 +5,8 @@
#ifndef MAP_MAP_H
#define MAP_MAP_H
-#include "config/core.h"
-
#include "map/atcommand.h"
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/core.h" // CORE_ST_LAST
#include "common/db.h"
#include "common/mapindex.h"
@@ -215,7 +213,13 @@ enum {
#define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 )
#define DEFAULT_AUTOSAVE_INTERVAL (5*60*1000)
// Specifies maps where players may hit each other
-#define map_flag_vs(m) (map->list[m].flag.pvp || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) || map->list[m].flag.battleground)
+#define map_flag_vs(m) ( \
+ map->list[m].flag.pvp \
+ || map->list[m].flag.gvg_dungeon \
+ || map->list[m].flag.gvg \
+ || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) \
+ || map->list[m].flag.battleground \
+ )
// Specifies maps that have special GvG/WoE restrictions
#define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle))
// Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status)
@@ -762,8 +766,6 @@ struct mapit_interface {
bool (*exists) (struct s_mapiterator* iter);
};
-struct mapit_interface *mapit;
-
#define mapit_getallusers() (mapit->alloc(MAPIT_NORMAL,BL_PC))
#define mapit_geteachpc() (mapit->alloc(MAPIT_NORMAL,BL_PC))
#define mapit_geteachmob() (mapit->alloc(MAPIT_NORMAL,BL_MOB))
@@ -1085,10 +1087,11 @@ END_ZEROED_BLOCK;
void (*zone_clear_single) (struct map_zone_data *zone);
};
-struct map_interface *map;
-
#ifdef HERCULES_CORE
void map_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mapit_interface *mapit;
+HPShared struct map_interface *map;
+
#endif /* MAP_MAP_H */
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index cafd25b64..09d051bab 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -6,7 +6,7 @@
#define MAP_MAPREG_H
#include "map/script.h" // struct reg_db
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct eri;
@@ -48,10 +48,10 @@ struct mapreg_interface {
bool (*config_read) (const char *w1, const char *w2);
};
-struct mapreg_interface *mapreg;
-
#ifdef HERCULES_CORE
void mapreg_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mapreg_interface *mapreg;
+
#endif /* MAP_MAPREG_H */
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index bed40e295..37c830e2e 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -21,6 +21,7 @@
#include <string.h>
struct mapreg_interface mapreg_s;
+struct mapreg_interface *mapreg;
#define MAPREG_AUTOSAVE_INTERVAL (300*1000)
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index c60234d5d..ff37f396d 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -44,6 +44,8 @@
struct mercenary_interface mercenary_s;
struct s_mercenary_db mercdb[MAX_MERCENARY_CLASS];
+struct mercenary_interface *mercenary;
+
int merc_search_index(int class_)
{
int i;
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index c96b5a5ef..9e0c59428 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -6,7 +6,7 @@
#include "map/status.h" // struct status_data, struct status_change
#include "map/unit.h" // struct unit_data
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct map_session_data;
@@ -97,10 +97,10 @@ struct mercenary_interface {
bool (*read_skill_db_sub) (char* str[], int columns, int current);
};
-struct mercenary_interface *mercenary;
-
#ifdef HERCULES_CORE
void mercenary_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mercenary_interface *mercenary;
+
#endif /* MAP_MERCENARY_H */
diff --git a/src/map/mob.c b/src/map/mob.c
index 8112c208c..f64c7e582 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -48,6 +48,7 @@
#include <string.h>
struct mob_interface mob_s;
+struct mob_interface *mob;
#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
diff --git a/src/map/mob.h b/src/map/mob.h
index 85d2bf9b8..4b8a054b5 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -8,7 +8,7 @@
#include "map/map.h" // struct block_list
#include "map/status.h" // struct status_data, struct status_change
#include "map/unit.h" // struct unit_data, view_data
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // struct item
#define MAX_RANDOMMONSTER 5
@@ -272,8 +272,8 @@ struct item_drop_list {
#define mob_stop_walking(md, type) (unit->stop_walking(&(md)->bl, (type)))
#define mob_stop_attack(md) (unit->stop_attack(&(md)->bl))
-#define mob_is_battleground(md) ( map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) )
-#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) )
+#define mob_is_battleground(md) (map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)))
+#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2))
#define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49))
struct mob_interface {
@@ -387,10 +387,10 @@ struct mob_interface {
void (*destroy_mob_db) (int index);
};
-struct mob_interface *mob;
-
#ifdef HERCULES_CORE
void mob_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mob_interface *mob;
+
#endif /* MAP_MOB_H */
diff --git a/src/map/npc.c b/src/map/npc.c
index 8733ee7e4..bb0e772ae 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -43,6 +43,7 @@
#include <time.h>
struct npc_interface npc_s;
+struct npc_interface *npc;
static int npc_id=START_NPC_NUM;
static int npc_warp=0;
diff --git a/src/map/npc.h b/src/map/npc.h
index bc779b56b..14b89d128 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -8,7 +8,7 @@
#include "map/map.h" // struct block_list
#include "map/status.h" // struct status_change
#include "map/unit.h" // struct unit_data
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct HPluginData;
@@ -279,12 +279,11 @@ struct npc_interface {
int (*secure_timeout_timer) (int tid, int64 tick, int id, intptr_t data);
};
-struct npc_interface *npc;
-
#ifdef HERCULES_CORE
void npc_defaults(void);
#endif // HERCULES_CORE
+HPShared struct npc_interface *npc;
/* comes from npc_chat.c */
#ifdef PCRE_SUPPORT
@@ -326,8 +325,6 @@ struct npc_chat_interface {
void (*finalize_pcrematch_entry) (struct pcrematch_entry* e);
};
-struct npc_chat_interface *npc_chat;
-
/**
* pcre interface (libpcre)
* so that plugins may share and take advantage of the core's pcre
@@ -344,14 +341,16 @@ struct pcre_interface {
int (*get_substring) (const char *subject, int *ovector, int stringcount, int stringnumber, const char **stringptr);
};
-struct pcre_interface *libpcre;
-
/**
* Also defaults libpcre
**/
#ifdef HERCULES_CORE
void npc_chat_defaults(void);
#endif // HERCULES_CORE
+
+HPShared struct npc_chat_interface *npc_chat;
+HPShared struct pcre_interface *libpcre;
+
#endif // PCRE_SUPPORT
#endif /* MAP_NPC_H */
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index 67b78dcea..0b9023ede 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -30,6 +30,8 @@
struct npc_chat_interface npc_chat_s;
struct pcre_interface libpcre_s;
+struct npc_chat_interface *npc_chat;
+struct pcre_interface *libpcre;
/**
* Written by MouseJstr in a vision... (2/21/2005)
diff --git a/src/map/party.c b/src/map/party.c
index 6b35debe5..472c03423 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -35,6 +35,7 @@
#include <string.h>
struct party_interface party_s;
+struct party_interface *party;
/*==========================================
* Fills the given party_member structure according to the sd provided.
diff --git a/src/map/party.h b/src/map/party.h
index 95faa2213..c7893add2 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -6,7 +6,7 @@
#define MAP_PARTY_H
#include "map/map.h" // TBL_PC
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h" // struct party
@@ -139,10 +139,10 @@ struct party_interface {
int (*db_final) (DBKey key, DBData *data, va_list ap);
};
-struct party_interface *party;
-
#ifdef HERCULES_CORE
void party_defaults(void);
#endif // HERCULES_CORE
+HPShared struct party_interface *party;
+
#endif /* MAP_PARTY_H */
diff --git a/src/map/path.c b/src/map/path.c
index 3ded5423e..723fd8e8f 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -29,6 +29,7 @@
#define DIR_EAST 8
struct path_interface path_s;
+struct path_interface *path;
/// @name Structures and defines for A* pathfinding
/// @{
diff --git a/src/map/path.h b/src/map/path.h
index bbd81b8c6..2ece8f84b 100644
--- a/src/map/path.h
+++ b/src/map/path.h
@@ -6,7 +6,7 @@
#define MAP_PATH_H
#include "map/map.h" // enum cell_chk
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#define MOVE_COST 10
#define MOVE_DIAGONAL_COST 14
@@ -53,10 +53,10 @@ struct path_interface {
int (*distance_client) (int dx, int dy);
};
-struct path_interface *path;
-
#ifdef HERCULES_CORE
void path_defaults(void);
#endif // HERCULES_CORE
+HPShared struct path_interface *path;
+
#endif /* MAP_PATH_H */
diff --git a/src/map/pc.c b/src/map/pc.c
index ad32217b8..49b8f1f94 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -45,7 +45,7 @@
#include "common/nullpo.h"
#include "common/random.h"
#include "common/showmsg.h"
-#include "common/socket.h" // session[]
+#include "common/socket.h"
#include "common/strlib.h" // safestrncpy()
#include "common/sysinfo.h"
#include "common/timer.h"
@@ -57,6 +57,7 @@
#include <time.h>
struct pc_interface pc_s;
+struct pc_interface *pc;
//Converts a class to its array index for CLASS_COUNT defined arrays.
//Note that it does not do a validity check for speed purposes, where parsing
@@ -1007,7 +1008,7 @@ int pc_isequip(struct map_session_data *sd,int n)
bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) {
int i;
int64 tick = timer->gettick();
- uint32 ip = session[sd->fd]->client_addr;
+ uint32 ip = sockt->session[sd->fd]->client_addr;
sd->login_id2 = login_id2;
@@ -3268,23 +3269,17 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->skillblown[i].val = val;
}
break;
- #ifndef RENEWAL_CAST
+#ifndef RENEWAL_CAST
case SP_VARCASTRATE:
- #endif
+#endif
case SP_CASTRATE:
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
if (i == ARRAYLENGTH(sd->skillcast)) {
//Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 %s reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
-
- #ifndef RENEWAL_CAST
- "bCastRate",
- #else
- "bVariableCastrate",
- #endif
-
+ ShowDebug("script->run: bonus2 %s reached its limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ type == SP_CASTRATE ? "bCastRate" : "bVariableCastrate",
ARRAYLENGTH(sd->skillcast), type2, val);
break;
}
@@ -9014,7 +9009,7 @@ int pc_readregistry(struct map_session_data *sd, int64 reg) {
ShowError("pc_readregistry: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg)));
//This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again.
//intif->request_registry(sd,type==3?4:type);
- set_eof(sd->fd);
+ sockt->eof(sd->fd);
return 0;
}
@@ -9035,7 +9030,7 @@ char* pc_readregistry_str(struct map_session_data *sd, int64 reg) {
ShowError("pc_readregistry_str: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg)));
//This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again.
//intif->request_registry(sd,type==3?4:type);
- set_eof(sd->fd);
+ sockt->eof(sd->fd);
return NULL;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index d35c29bc7..85bbd2016 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -5,8 +5,6 @@
#ifndef MAP_PC_H
#define MAP_PC_H
-#include "config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT
-
#include "map/battle.h" // battle
#include "map/battleground.h" // enum bg_queue_types
#include "map/buyingstore.h" // struct s_buyingstore
@@ -19,7 +17,7 @@
#include "map/status.h" // enum sc_type, OPTION_*
#include "map/unit.h" // struct unit_data, struct view_data
#include "map/vending.h" // struct s_vending
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/ers.h" // struct eri
#include "common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS
@@ -1072,10 +1070,10 @@ END_ZEROED_BLOCK; /* End */
int (*check_job_name) (const char *name);
};
-struct pc_interface *pc;
-
#ifdef HERCULES_CORE
void pc_defaults(void);
#endif // HERCULES_CORE
+HPShared struct pc_interface *pc;
+
#endif /* MAP_PC_H */
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index f9a442d97..28bef6a85 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -21,6 +21,7 @@
static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd()
struct pc_groups_interface pcg_s;
+struct pc_groups_interface *pcg;
/**
* Returns dummy group.
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 4fee312a4..6f92a7955 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -5,7 +5,7 @@
#ifndef MAP_PC_GROUPS_H
#define MAP_PC_GROUPS_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/conf.h"
#include "common/db.h"
@@ -96,10 +96,10 @@ struct pc_groups_interface {
int (*get_idx) (GroupSettings *group);
};
-struct pc_groups_interface *pcg;
-
#ifdef HERCULES_CORE
void pc_groups_defaults(void);
#endif // HERCULES_CORE
+HPShared struct pc_groups_interface *pcg;
+
#endif /* MAP_PC_GROUPS_H */
diff --git a/src/map/pet.c b/src/map/pet.c
index b612a9505..1ac6d117a 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -37,6 +37,7 @@
#include <string.h>
struct pet_interface pet_s;
+struct pet_interface *pet;
#define MIN_PETTHINKTIME 100
diff --git a/src/map/pet.h b/src/map/pet.h
index 06302c9b2..84df856bf 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -8,7 +8,7 @@
#include "map/map.h" // struct block_list
#include "map/status.h" // enum sc_type
#include "map/unit.h" // struct unit_data
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // NAME_LENGTH, struct s_pet
#define MAX_PET_DB 300
@@ -153,10 +153,10 @@ struct pet_interface {
int (*read_db) ();
};
-struct pet_interface *pet;
-
#ifdef HERCULES_CORE
void pet_defaults(void);
#endif // HERCULES_CORE
+HPShared struct pet_interface *pet;
+
#endif /* MAP_PET_H */
diff --git a/src/map/quest.c b/src/map/quest.c
index 463a3395a..ddbd2f92d 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -39,6 +39,8 @@
struct quest_interface quest_s;
struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database
+struct quest_interface *quest;
+
/**
* Searches a quest by ID.
*
diff --git a/src/map/quest.h b/src/map/quest.h
index 9b5199625..ccb3e58f9 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -6,7 +6,7 @@
#define MAP_QUEST_H
#include "map/map.h" // TBL_PC
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/conf.h"
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1
@@ -61,10 +61,10 @@ struct quest_interface {
struct quest_db *(*read_db_sub) (config_setting_t *cs, int n, const char *source);
};
-struct quest_interface *quest;
-
#ifdef HERCULES_CORE
void quest_defaults(void);
#endif // HERCULES_CORE
+HPShared struct quest_interface *quest;
+
#endif /* MAP_QUEST_H */
diff --git a/src/map/script.c b/src/map/script.c
index 23c6af0f8..cbbf306d1 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -62,6 +62,7 @@
#endif
struct script_interface script_s;
+struct script_interface *script;
static inline int GETVALUE(const unsigned char* buf, int i) {
return (int)MakeDWord(MakeWord(buf[i], buf[i+1]), MakeWord(buf[i+2], 0));
@@ -18265,22 +18266,22 @@ BUILDIN(getcharip) {
}
/* check for sd and IP */
- if (!sd || !session[sd->fd]->client_addr)
+ if (!sd || !sockt->session[sd->fd]->client_addr)
{
script_pushconststr(st, "");
return true;
}
/* return the client ip_addr converted for output */
- if (sd && sd->fd && session[sd->fd])
+ if (sd && sd->fd && sockt->session[sd->fd])
{
/* initiliaze */
const char *ip_addr = NULL;
uint32 ip;
/* set ip, ip_addr and convert to ip and push str */
- ip = session[sd->fd]->client_addr;
- ip_addr = ip2str(ip, NULL);
+ ip = sockt->session[sd->fd]->client_addr;
+ ip_addr = sockt->ip2str(ip, NULL);
script_pushstrcopy(st, ip_addr);
}
diff --git a/src/map/script.h b/src/map/script.h
index b3d2a3c8a..ad8ae82cb 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -6,7 +6,7 @@
#define MAP_SCRIPT_H
#include "map/map.h" //EVENT_NAME_LENGTH
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h" // struct item
#include "common/sql.h" // Sql
@@ -773,10 +773,10 @@ struct script_interface {
void (*run_item_unequip_script) (struct map_session_data *sd, struct item_data *data, int oid);
};
-struct script_interface *script;
-
#ifdef HERCULES_CORE
void script_defaults(void);
#endif // HERCULES_CORE
+HPShared struct script_interface *script;
+
#endif /* MAP_SCRIPT_H */
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index b9e23ae82..46b102ad5 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -15,6 +15,7 @@
#include "common/strlib.h" // safestrncpy
struct searchstore_interface searchstore_s;
+struct searchstore_interface *searchstore;
/// retrieves search function by type
static inline searchstore_search_t searchstore_getsearchfunc(unsigned char type) {
diff --git a/src/map/searchstore.h b/src/map/searchstore.h
index 2778740a5..24d7665e0 100644
--- a/src/map/searchstore.h
+++ b/src/map/searchstore.h
@@ -6,7 +6,7 @@
#define MAP_SEARCHSTORE_H
#include "map/map.h" // MESSAGE_SIZE
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // MAX_SLOTS
#include <time.h>
@@ -95,10 +95,10 @@ struct searchstore_interface {
bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine);
};
-struct searchstore_interface *searchstore;
-
#ifdef HERCULES_CORE
void searchstore_defaults(void);
#endif // HERCULES_CORE
+HPShared struct searchstore_interface *searchstore;
+
#endif /* MAP_SEARCHSTORE_H */
diff --git a/src/map/skill.c b/src/map/skill.c
index e3f85f8d1..c647cc325 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -64,6 +64,8 @@
struct skill_interface skill_s;
struct s_skill_dbs skilldbs;
+struct skill_interface *skill;
+
//Since only mob-casted splash skills can hit ice-walls
static inline int splash_target(struct block_list* bl) {
#ifndef RENEWAL
@@ -18089,7 +18091,7 @@ void skill_init_unit_layout (void)
int i,j,pos = 0;
//when != it was already cleared during skill_defaults() no need to repeat
- if( runflag == MAPSERVER_ST_RUNNING )
+ if( core->runflag == MAPSERVER_ST_RUNNING )
memset(skill->dbs->unit_layout, 0, sizeof(skill->dbs->unit_layout));
// standard square layouts go first
@@ -18974,7 +18976,7 @@ void skill_readdb(bool minimal) {
db_clear(skill->name2id_db);
/* when != it was called during init and this procedure was already performed by skill_defaults() */
- if( runflag == MAPSERVER_ST_RUNNING ) {
+ if( core->runflag == MAPSERVER_ST_RUNNING ) {
memset(ZEROED_BLOCK_POS(skill->dbs), 0, ZEROED_BLOCK_SIZE(skill->dbs));
}
diff --git a/src/map/skill.h b/src/map/skill.h
index aa0188be6..1db03bcd1 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -5,11 +5,9 @@
#ifndef MAP_SKILL_H
#define MAP_SKILL_H
-#include "config/core.h" // RENEWAL_CAST
-
#include "map/map.h" // struct block_list
#include "map/status.h" // enum sc_type
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
#include "common/mmo.h" // MAX_SKILL, struct square
@@ -2084,10 +2082,10 @@ struct skill_interface {
void (*get_requirement_unknown) (struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req);
};
-struct skill_interface *skill;
-
#ifdef HERCULES_CORE
void skill_defaults(void);
#endif // HERCULES_CORE
+HPShared struct skill_interface *skill;
+
#endif /* MAP_SKILL_H */
diff --git a/src/map/status.c b/src/map/status.c
index e70fb1eb1..4fc975268 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -46,6 +46,8 @@
struct status_interface status_s;
struct s_status_dbs statusdbs;
+struct status_interface *status;
+
/**
* Returns the status change associated with a skill.
* @param skill The skill to look up
@@ -12300,7 +12302,7 @@ int status_readdb(void)
// initialize databases to default
//
- if( runflag == MAPSERVER_ST_RUNNING ) {//not necessary during boot
+ if( core->runflag == MAPSERVER_ST_RUNNING ) {//not necessary during boot
// reset job_db.conf data
memset(status->dbs->max_weight_base, 0, sizeof(status->dbs->max_weight_base));
memset(status->dbs->HP_table, 0, sizeof(status->dbs->HP_table));
diff --git a/src/map/status.h b/src/map/status.h
index 45a1300a0..274c64c5b 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -5,10 +5,8 @@
#ifndef MAP_STATUS_H
#define MAP_STATUS_H
-#include "config/core.h" // defType, RENEWAL, RENEWAL_ASPD
-
#include "common/conf.h"
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/mmo.h" // NEW_CARTS
struct block_list;
@@ -2085,10 +2083,10 @@ struct status_interface {
void (*read_job_db_sub) (int idx, const char *name, config_setting_t *jdb);
};
-struct status_interface *status;
-
#ifdef HERCULES_CORE
void status_defaults(void);
#endif // HERCULES_CORE
+HPShared struct status_interface *status;
+
#endif /* MAP_STATUS_H */
diff --git a/src/map/storage.c b/src/map/storage.c
index 95194bc47..fb6e2ed45 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -28,6 +28,9 @@
struct storage_interface storage_s;
struct guild_storage_interface gstorage_s;
+struct storage_interface *storage;
+struct guild_storage_interface *gstorage;
+
/*==========================================
* Sort items in the warehouse
*------------------------------------------*/
diff --git a/src/map/storage.h b/src/map/storage.h
index 5f2c69f56..37f894f76 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -5,7 +5,7 @@
#ifndef MAP_STORAGE_H
#define MAP_STORAGE_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct guild_storage;
@@ -38,7 +38,6 @@ struct storage_interface {
void (*sortitem) (struct item* items, unsigned int size);
int (*reconnect_sub) (DBKey key, DBData *data, va_list ap);
};
-struct storage_interface *storage;
struct guild_storage_interface {
struct DBMap* db; // int guild_id -> struct guild_storage*
@@ -63,11 +62,12 @@ struct guild_storage_interface {
DBData (*create) (DBKey key, va_list args);
};
-struct guild_storage_interface *gstorage;
-
#ifdef HERCULES_CORE
void storage_defaults(void);
void gstorage_defaults(void);
#endif // HERCULES_CORE
+HPShared struct storage_interface *storage;
+HPShared struct guild_storage_interface *gstorage;
+
#endif /* MAP_STORAGE_H */
diff --git a/src/map/trade.c b/src/map/trade.c
index 4dd6ffafa..8af3ddf4a 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -25,6 +25,7 @@
#include <string.h>
struct trade_interface trade_s;
+struct trade_interface *trade;
/*==========================================
* Initiates a trade request.
@@ -209,13 +210,13 @@ int impossible_trade_check(struct map_session_data *sd)
// if we block people
if (battle_config.ban_hack_trade < 0) {
chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0);
- set_eof(sd->fd); // forced to disconnect because of the hack
+ sockt->eof(sd->fd); // forced to disconnect because of the hack
// message about the ban
safestrncpy(message_to_gm, msg_txt(540), sizeof(message_to_gm)); // This player has been definitively blocked.
// if we ban people
} else if (battle_config.ban_hack_trade > 0) {
chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BAN, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second)
- set_eof(sd->fd); // forced to disconnect because of the hack
+ sockt->eof(sd->fd); // forced to disconnect because of the hack
// message about the ban
sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s).
} else
diff --git a/src/map/trade.h b/src/map/trade.h
index 85e73025c..010f67e26 100644
--- a/src/map/trade.h
+++ b/src/map/trade.h
@@ -5,6 +5,8 @@
#ifndef MAP_TRADE_H
#define MAP_TRADE_H
+#include "common/hercules.h"
+
//Max distance from traders to enable a trade to take place.
//TODO: battle_config candidate?
#define TRADE_DISTANCE 2
@@ -23,10 +25,10 @@ struct trade_interface {
void (*commit) (struct map_session_data *sd);
};
-struct trade_interface *trade;
-
#ifdef HERCULES_CORE
void trade_defaults(void);
#endif // HERCULES_CORE
+HPShared struct trade_interface *trade;
+
#endif /* MAP_TRADE_H */
diff --git a/src/map/unit.c b/src/map/unit.c
index 60911b85a..33360584a 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -49,6 +49,7 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1};
const short diry[8]={1,1,0,-1,-1,-1,0,1};
struct unit_interface unit_s;
+struct unit_interface *unit;
/**
* Returns the unit_data for the given block_list. If the object is using
diff --git a/src/map/unit.h b/src/map/unit.h
index 00fff5981..0d970ca16 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -8,7 +8,7 @@
#include "map/clif.h" // clr_type
#include "map/path.h" // struct walkpath_data
#include "map/skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
struct map_session_data;
struct block_list;
@@ -84,9 +84,6 @@ struct view_data {
unsigned dead_sit : 2;
};
-extern const short dirx[8];
-extern const short diry[8];
-
struct unit_interface {
int (*init) (bool minimal);
int (*final) (void);
@@ -139,8 +136,13 @@ struct unit_interface {
int (*free) (struct block_list *bl, clr_type clrtype);
};
-struct unit_interface *unit;
+#ifdef HERCULES_CORE
+extern const short dirx[8];
+extern const short diry[8];
void unit_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct unit_interface *unit;
#endif /* MAP_UNIT_H */
diff --git a/src/map/vending.c b/src/map/vending.c
index d0f0dee00..80c79984e 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -25,6 +25,7 @@
#include <string.h>
struct vending_interface vending_s;
+struct vending_interface *vending;
/// Returns an unique vending shop id.
static inline unsigned int getid(void) {
diff --git a/src/map/vending.h b/src/map/vending.h
index 189189227..2f624fac7 100644
--- a/src/map/vending.h
+++ b/src/map/vending.h
@@ -5,7 +5,7 @@
#ifndef MAP_VENDING_H
#define MAP_VENDING_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
#include "common/db.h"
struct map_session_data;
@@ -32,10 +32,10 @@ struct vending_interface {
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
};
-struct vending_interface *vending;
-
#ifdef HERCULES_CORE
void vending_defaults(void);
#endif // HERCULES_CORE
+HPShared struct vending_interface *vending;
+
#endif /* MAP_VENDING_H */