summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-08-11 01:47:15 +0200
committerHaru <haru@dotalux.com>2015-08-15 00:51:44 +0200
commit22bd368e5d4d8d61a7189d03f52c3afd90c0729e (patch)
treeb8617bdfe901c41ff006d160b5bbceadb52f7bfb /src/common
parentbbf42063d78e393c2fc7a74b105aca6fb6357414 (diff)
downloadhercules-22bd368e5d4d8d61a7189d03f52c3afd90c0729e.tar.gz
hercules-22bd368e5d4d8d61a7189d03f52c3afd90c0729e.tar.bz2
hercules-22bd368e5d4d8d61a7189d03f52c3afd90c0729e.tar.xz
hercules-22bd368e5d4d8d61a7189d03f52c3afd90c0729e.zip
Added core HPM interface
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/HPM.c6
-rw-r--r--src/common/console.c2
-rw-r--r--src/common/core.c18
-rw-r--r--src/common/core.h29
4 files changed, 26 insertions, 29 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index d9abdfab7..b4594d1ca 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -752,11 +752,7 @@ void hplugins_share_defaults(void) {
HPM->share(hpm_add_arg,"addArg");
HPM->share(hplugins_addconf,"addConf");
/* core */
- HPM->share(&runflag,"runflag");
- HPM->share(arg_v,"arg_v");
- HPM->share(&arg_c,"arg_c");
- HPM->share(SERVER_NAME,"SERVER_NAME");
- HPM->share(&SERVER_TYPE,"SERVER_TYPE");
+ HPM->share(core,"core");
HPM->share(HPMiMalloc, "iMalloc");
HPM->share(cmdline,"cmdline");
/* console */
diff --git a/src/common/console.c b/src/common/console.c
index 5091d1a6c..0dd225d4d 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -102,7 +102,7 @@ int console_parse_key_pressed(void)
* Stops server
**/
CPCMD_C(exit,server) {
- runflag = 0;
+ core->runflag = 0;
}
/**
diff --git a/src/common/core.c b/src/common/core.c
index 2f89d004e..7f5a1da53 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -41,11 +41,8 @@
/// Called when a terminate signal is received.
void (*shutdown_callback)(void) = NULL;
-int runflag = CORE_ST_RUN;
-int arg_c = 0;
-char **arg_v = NULL;
-
-char *SERVER_NAME = NULL;
+struct core_interface core_s;
+struct core_interface *core = &core_s;
#ifndef MINICORE // minimalist Core
// Added by Gabuzomeu
@@ -90,7 +87,7 @@ static BOOL WINAPI console_handler(DWORD c_event) {
if( shutdown_callback != NULL )
shutdown_callback();
else
- runflag = CORE_ST_STOP;// auto-shutdown
+ core->runflag = CORE_ST_STOP;// auto-shutdown
break;
default:
return FALSE;
@@ -118,7 +115,7 @@ static void sig_proc(int sn) {
if( shutdown_callback != NULL )
shutdown_callback();
else
- runflag = CORE_ST_STOP;// auto-shutdown
+ core->runflag = CORE_ST_STOP;// auto-shutdown
break;
case SIGSEGV:
case SIGFPE:
@@ -389,8 +386,9 @@ int main (int argc, char **argv) {
SERVER_NAME = ++p1;
p2 = p1;
}
- arg_c = argc;
- arg_v = argv;
+ core->arg_c = argc;
+ core->arg_v = argv;
+ core->runflag = CORE_ST_RUN;
}
core_defaults();
@@ -442,7 +440,7 @@ int main (int argc, char **argv) {
do_init(argc,argv);
// Main runtime cycle
- while (runflag != CORE_ST_STOP) {
+ while (core->runflag != CORE_ST_STOP) {
int next = timer->perform(timer->gettick_nocache());
sockt->perform(next);
}
diff --git a/src/common/core.h b/src/common/core.h
index b0f0449a3..c92bf4fa6 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -57,28 +57,30 @@ struct cmdline_interface {
const char *(*arg_source) (struct CmdlineArgData *arg);
};
+struct core_interface {
+ int arg_c;
+ char **arg_v;
+ /// @see E_CORE_ST
+ int runflag;
+ char *server_name;
+ enum server_types server_type;
+
+ /// Called when a terminate signal is received. (Ctrl+C pressed)
+ /// If NULL, runflag is set to CORE_ST_STOP instead.
+ void (*shutdown_callback)(void);
+};
+
#define CMDLINEARG(x) bool cmdline_arg_ ## x (const char *name, const char *params)
+#define SERVER_NAME (core->server_name)
+#define SERVER_TYPE (core->server_type)
#ifdef HERCULES_CORE
-extern int arg_c;
-extern char **arg_v;
-
-/// @see E_CORE_ST
-extern int runflag;
-extern char *SERVER_NAME;
-
-enum server_types SERVER_TYPE;
-
extern void cmdline_args_init_local(void);
extern int do_init(int,char**);
extern void set_server_type(void);
extern void do_abort(void);
extern int do_final(void);
-/// Called when a terminate signal is received. (Ctrl+C pressed)
-/// If NULL, runflag is set to CORE_ST_STOP instead.
-extern void (*shutdown_callback)(void);
-
/// Special plugin ID assigned to the Hercules core
#define HPM_PID_CORE ((unsigned int)-1)
@@ -88,6 +90,7 @@ extern void (*shutdown_callback)(void);
void cmdline_defaults(void);
#endif // HERCULES_CORE
+HPShared struct core_interface *core;
HPShared struct cmdline_interface *cmdline;
#endif /* COMMON_CORE_H */