diff options
Diffstat (limited to 'src/common/core.c')
-rw-r--r-- | src/common/core.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/common/core.c b/src/common/core.c index 8bf381589..dcc96fa41 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -4,50 +4,45 @@ #define HERCULES_CORE -#include "../config/core.h" +#include "config/core.h" #include "core.h" -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "../common/cbasetypes.h" -#include "../common/console.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" -#include "../common/nullpo.h" +#include "common/cbasetypes.h" +#include "common/console.h" +#include "common/db.h" +#include "common/malloc.h" +#include "common/mmo.h" +#include "common/random.h" +#include "common/showmsg.h" +#include "common/strlib.h" +#include "common/sysinfo.h" +#include "common/nullpo.h" #ifndef MINICORE -# include "../common/HPM.h" -# include "../common/conf.h" -# include "../common/db.h" -# include "../common/ers.h" -# include "../common/socket.h" -# include "../common/sql.h" -# include "../common/thread.h" -# include "../common/timer.h" -# include "../common/utils.h" +# include "common/HPM.h" +# include "common/conf.h" +# include "common/ers.h" +# include "common/socket.h" +# include "common/sql.h" +# include "common/thread.h" +# include "common/timer.h" +# include "common/utils.h" #endif #ifndef _WIN32 # include <unistd.h> #else -# include "../common/winapi.h" // Console close event handling +# include "common/winapi.h" // Console close event handling #endif +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> /// 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 @@ -92,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; @@ -120,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: @@ -178,6 +173,7 @@ void core_defaults(void) { console_defaults(); strlib_defaults(); malloc_defaults(); + showmsg_defaults(); cmdline_defaults(); #ifndef MINICORE libconfig_defaults(); @@ -210,7 +206,7 @@ const char *cmdline_arg_source(struct CmdlineArgData *arg) { */ bool cmdline_arg_add(unsigned int pluginID, const char *name, char shortname, CmdlineExecFunc func, const char *help, unsigned int options) { struct CmdlineArgData *data = NULL; - + RECREATE(cmdline->args_data, struct CmdlineArgData, ++cmdline->args_data_count); data = &cmdline->args_data[cmdline->args_data_count-1]; data->pluginID = pluginID; @@ -231,7 +227,7 @@ static CMDLINEARG(help) ShowInfo("Usage: %s [options]\n", SERVER_NAME); ShowInfo("\n"); ShowInfo("Options:\n"); - + for (i = 0; i < cmdline->args_data_count; i++) { struct CmdlineArgData *data = &cmdline->args_data[i]; char altname[16], paramnames[256]; @@ -250,7 +246,7 @@ static CMDLINEARG(help) */ static CMDLINEARG(version) { - ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://hercules.ws/\n"); + ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://herc.ws/\n"); ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rizon.net/#Hercules\n"); ShowInfo("Open "CL_WHITE"readme.txt"CL_RESET" for more information.\n"); return false; @@ -319,7 +315,7 @@ int cmdline_exec(int argc, char **argv, unsigned int options) } if (options&CMDLINE_OPT_SILENT) { if (data->options&CMDLINE_OPT_SILENT) { - msg_silent = 0x7; // silence information and status messages + showmsg->silent = 0x7; // silence information and status messages break; } } else if ((data->options&CMDLINE_OPT_PREINIT) == (options&CMDLINE_OPT_PREINIT)) { @@ -362,6 +358,7 @@ void cmdline_final(void) } struct cmdline_interface cmdline_s; +struct cmdline_interface *cmdline; void cmdline_defaults(void) { @@ -389,22 +386,24 @@ 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(); iMalloc->init();// needed for Show* in display_title() [FlavioJS] + showmsg->init(); cmdline->init(); cmdline->exec(argc, argv, CMDLINE_OPT_SILENT); iMalloc->init_messages(); // Initialization messages (after buying us some time to suppress them if needed) - + sysinfo->init(); - if (!(msg_silent&0x1)) + if (!(showmsg->silent&0x1)) console->display_title(); usercheck(); @@ -441,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); } @@ -460,6 +459,7 @@ int main (int argc, char **argv) { //sysinfo->final(); Called by iMalloc->final() iMalloc->final(); + showmsg->final(); // Should be after iMalloc->final() return retval; } |