summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-05-10 17:17:13 +0200
committerHaru <haru@dotalux.com>2014-05-10 17:17:13 +0200
commit0ab52ac65bdba93be94e4149e267698d31b41d72 (patch)
treee7f0cd0d549c8a04a35693cc98b6b27c06eeb2ed /src/common
parent94657284973f4037596bae468ebfbee5c217e02b (diff)
downloadhercules-0ab52ac65bdba93be94e4149e267698d31b41d72.tar.gz
hercules-0ab52ac65bdba93be94e4149e267698d31b41d72.tar.bz2
hercules-0ab52ac65bdba93be94e4149e267698d31b41d72.tar.xz
hercules-0ab52ac65bdba93be94e4149e267698d31b41d72.zip
Re-commit of "Fixed order of includes in all source files"
This reverts commit 94657284973f4037596bae468ebfbee5c217e02b.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/HPM.c31
-rw-r--r--src/common/HPM.h6
-rw-r--r--src/common/HPMi.h16
-rw-r--r--src/common/cbasetypes.h6
-rw-r--r--src/common/conf.c3
-rw-r--r--src/common/conf.h1
-rw-r--r--src/common/console.c223
-rw-r--r--src/common/console.h21
-rw-r--r--src/common/core.c38
-rw-r--r--src/common/core.h3
-rw-r--r--src/common/db.c10
-rw-r--r--src/common/db.h3
-rw-r--r--src/common/des.c7
-rw-r--r--src/common/ers.c8
-rw-r--r--src/common/grfio.c17
-rw-r--r--src/common/malloc.c11
-rw-r--r--src/common/mapindex.c15
-rw-r--r--src/common/md5calc.c8
-rw-r--r--src/common/mmo.h6
-rw-r--r--src/common/mutex.c5
-rw-r--r--src/common/mutex.h1
-rw-r--r--src/common/nullpo.c6
-rw-r--r--src/common/random.c18
-rw-r--r--src/common/showmsg.c17
-rw-r--r--src/common/showmsg.h23
-rw-r--r--src/common/socket.c64
-rw-r--r--src/common/socket.h12
-rw-r--r--src/common/spinlock.h9
-rw-r--r--src/common/sql.c12
-rw-r--r--src/common/sql.h3
-rw-r--r--src/common/strlib.c13
-rw-r--r--src/common/strlib.h15
-rw-r--r--src/common/sysinfo.c32
-rw-r--r--src/common/sysinfo.h16
-rw-r--r--src/common/thread.c31
-rw-r--r--src/common/thread.h1
-rw-r--r--src/common/timer.c19
-rw-r--r--src/common/utils.c36
-rw-r--r--src/common/utils.h3
39 files changed, 434 insertions, 335 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 9ffce87de..00b92dc60 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -1,26 +1,31 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
+#define HERCULES_CORE
+
+#include "../config/core.h" // CONSOLE_INPUT
+#include "HPM.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "../common/cbasetypes.h"
-#include "../common/mmo.h"
+#include "../common/conf.h"
+#include "../common/console.h"
#include "../common/core.h"
#include "../common/malloc.h"
+#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/conf.h"
-#include "../common/utils.h"
-#include "../common/console.h"
-#include "../common/strlib.h"
#include "../common/sql.h"
+#include "../common/strlib.h"
#include "../common/sysinfo.h"
-#include "HPM.h"
+#include "../common/timer.h"
+#include "../common/utils.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#ifndef WIN32
-#include <unistd.h>
+# include <unistd.h>
#endif
struct malloc_interface iMalloc_HPM;
@@ -686,7 +691,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po
void hplugins_share_defaults(void) {
/* console */
#ifdef CONSOLE_INPUT
- HPM->share(console->addCommand,"addCPCommand");
+ HPM->share(console->input->addCommand,"addCPCommand");
#endif
/* our own */
HPM->share(hplugins_addpacket,"addPacket");
@@ -755,7 +760,7 @@ void hpm_init(void) {
HPM->symbol_defaults();
#ifdef CONSOLE_INPUT
- console->addCommand("plugins",CPCMD_A(plugins));
+ console->input->addCommand("plugins",CPCMD_A(plugins));
#endif
return;
}
diff --git a/src/common/HPM.h b/src/common/HPM.h
index 0f0df4cda..9c176cfd6 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -4,8 +4,12 @@
#ifndef _COMMON_HPM_H_
#define _COMMON_HPM_H_
-#include "../common/cbasetypes.h"
+#ifndef HERCULES_CORE
+#error You should never include HPM.h from a plugin.
+#endif
+
#include "../common/HPMi.h"
+#include "../common/cbasetypes.h"
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index 19206aeca..b98e87d90 100644
--- a/src/common/HPMi.h
+++ b/src/common/HPMi.h
@@ -5,8 +5,8 @@
#define _COMMON_HPMI_H_
#include "../common/cbasetypes.h"
-#include "../common/core.h"
#include "../common/console.h"
+#include "../common/core.h"
#include "../common/sql.h"
struct script_state;
@@ -20,18 +20,6 @@ struct map_session_data;
#define HPExport
#endif
-#ifndef _COMMON_SHOWMSG_H_
- HPExport void (*ShowMessage) (const char *, ...);
- HPExport void (*ShowStatus) (const char *, ...);
- HPExport void (*ShowSQL) (const char *, ...);
- HPExport void (*ShowInfo) (const char *, ...);
- HPExport void (*ShowNotice) (const char *, ...);
- HPExport void (*ShowWarning) (const char *, ...);
- HPExport void (*ShowDebug) (const char *, ...);
- HPExport void (*ShowError) (const char *, ...);
- HPExport void (*ShowFatalError) (const char *, ...);
-#endif
-
/* after */
#include "../common/showmsg.h"
@@ -192,7 +180,7 @@ HPExport struct HPMi_interface {
/* pc group permission */
void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask);
} HPMi_s;
-#ifndef _COMMON_HPM_H_
+#ifndef HERCULES_CORE
HPExport struct HPMi_interface *HPMi;
#endif
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index f44e80413..da0d6b307 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -442,5 +442,11 @@ void SET_FUNCPOINTER(T1& var, T2 p)
#define SET_FUNCPOINTER(var,p) ((var) = (p))
#endif
+/* pointer size fix which fixes several gcc warnings */
+#ifdef __64BIT__
+ #define __64BPTRSIZE(y) ((intptr)(y))
+#else
+ #define __64BPTRSIZE(y) (y)
+#endif
#endif /* _COMMON_CBASETYPES_H_ */
diff --git a/src/common/conf.c b/src/common/conf.c
index b816b2f7f..46a034497 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -2,7 +2,10 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+#define HERCULES_CORE
+
#include "conf.h"
+
#include "../../3rdparty/libconfig/libconfig.h"
#include "../common/showmsg.h" // ShowError
diff --git a/src/common/conf.h b/src/common/conf.h
index 9aff3df47..e5b637e47 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -6,6 +6,7 @@
#define _COMMON_CONF_H_
#include "../common/cbasetypes.h"
+
#include "../../3rdparty/libconfig/libconfig.h"
/**
diff --git a/src/common/console.c b/src/common/console.c
index d8f352c8a..6a82db555 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -2,42 +2,46 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+#define HERCULES_CORE
+
+#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT
+#include "console.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
#include "../common/cbasetypes.h"
-#include "../common/showmsg.h"
#include "../common/core.h"
+#include "../common/showmsg.h"
#include "../common/sysinfo.h"
-#include "../config/core.h"
-#include "console.h"
#ifndef MINICORE
- #include "../common/ers.h"
- #include "../common/malloc.h"
- #include "../common/atomic.h"
- #include "../common/spinlock.h"
- #include "../common/thread.h"
- #include "../common/mutex.h"
- #include "../common/timer.h"
- #include "../common/strlib.h"
- #include "../common/sql.h"
+# include "../common/atomic.h"
+# include "../common/ers.h"
+# include "../common/malloc.h"
+# include "../common/mutex.h"
+# include "../common/spinlock.h"
+# include "../common/sql.h"
+# include "../common/strlib.h"
+# include "../common/thread.h"
+# include "../common/timer.h"
#endif
-#include <stdio.h>
-#include <stdlib.h>
#if !defined(WIN32)
- #include <unistd.h>
- #include <sys/time.h>
+# include <sys/time.h>
+# include <unistd.h>
#else
- #include "../common/winapi.h" // Console close event handling
+# include "../common/winapi.h" // Console close event handling
+# ifdef CONSOLE_INPUT
+# include <conio.h> /* _kbhit() */
+# endif
#endif
+struct console_interface console_s;
#ifdef CONSOLE_INPUT
- #if defined(WIN32)
- #include <conio.h> /* _kbhit() */
- #endif
+struct console_input_interface console_input_s;
#endif
-struct console_interface console_s;
-
/*======================================
* CORE : Display title
*--------------------------------------*/
@@ -116,12 +120,12 @@ CPCMD_C(mem_report,server) {
**/
CPCMD(help) {
unsigned int i = 0;
- for ( i = 0; i < console->cmd_list_count; i++ ) {
- if( console->cmd_list[i]->next_count ) {
- ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd);
- console->parse_list_subs(console->cmd_list[i],2);
+ for ( i = 0; i < console->input->cmd_list_count; i++ ) {
+ if( console->input->cmd_list[i]->next_count ) {
+ ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd);
+ console->input->parse_list_subs(console->input->cmd_list[i],2);
} else {
- ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd);
+ ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd);
}
}
}
@@ -144,7 +148,7 @@ CPCMD_C(skip,update) {
ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n");
return;
}
- Sql_HerculesUpdateSkip(console->SQL, line);
+ Sql_HerculesUpdateSkip(console->input->SQL, line);
}
/**
@@ -206,7 +210,7 @@ void console_load_defaults(void) {
unsigned int i, len = ARRAYLENGTH(default_list);
struct CParseEntry *cmd;
- RECREATE(console->cmds,struct CParseEntry *, len);
+ RECREATE(console->input->cmds,struct CParseEntry *, len);
for(i = 0; i < len; i++) {
CREATE(cmd, struct CParseEntry, 1);
@@ -220,12 +224,12 @@ void console_load_defaults(void) {
cmd->next_count = 0;
- console->cmd_count++;
- console->cmds[i] = cmd;
+ console->input->cmd_count++;
+ console->input->cmds[i] = cmd;
default_list[i].self = cmd;
if( !default_list[i].connect ) {
- RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count);
- console->cmd_list[console->cmd_list_count - 1] = cmd;
+ RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count);
+ console->input->cmd_list[console->input->cmd_list_count - 1] = cmd;
}
}
@@ -233,11 +237,11 @@ void console_load_defaults(void) {
unsigned int k;
if( !default_list[i].connect )
continue;
- for(k = 0; k < console->cmd_count; k++) {
- if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) {
+ for(k = 0; k < console->input->cmd_count; k++) {
+ if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) {
cmd = default_list[i].self;
- RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count);
- console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd;
+ RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count);
+ console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd;
break;
}
}
@@ -256,23 +260,23 @@ void console_parse_create(char *name, CParseFunc func) {
safestrncpy(sublist, name, CP_CMD_LENGTH * 5);
tok = strtok(sublist,":");
- for ( i = 0; i < console->cmd_list_count; i++ ) {
- if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 )
+ for ( i = 0; i < console->input->cmd_list_count; i++ ) {
+ if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
break;
}
- if( i == console->cmd_list_count ) {
- RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count);
+ if( i == console->input->cmd_list_count ) {
+ RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count);
CREATE(cmd, struct CParseEntry, 1);
safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH);
cmd->next_count = 0;
- console->cmds[console->cmd_count - 1] = cmd;
- RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count);
- console->cmd_list[console->cmd_list_count - 1] = cmd;
- i = console->cmd_list_count - 1;
+ console->input->cmds[console->input->cmd_count - 1] = cmd;
+ RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count);
+ console->input->cmd_list[console->input->cmd_list_count - 1] = cmd;
+ i = console->input->cmd_list_count - 1;
}
- cmd = console->cmd_list[i];
+ cmd = console->input->cmd_list[i];
while( ( tok = strtok(NULL, ":") ) != NULL ) {
for(i = 0; i < cmd->next_count; i++) {
@@ -281,13 +285,13 @@ void console_parse_create(char *name, CParseFunc func) {
}
if ( i == cmd->next_count ) {
- RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count);
- CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1);
- safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH);
- console->cmds[console->cmd_count-1]->next_count = 0;
+ RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count);
+ CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1);
+ safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH);
+ console->input->cmds[console->input->cmd_count-1]->next_count = 0;
RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count);
- cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1];
- cmd = console->cmds[console->cmd_count-1];
+ cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1];
+ cmd = console->input->cmds[console->input->cmd_count-1];
continue;
}
@@ -302,7 +306,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) {
memset(msg, '-', depth);
snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd);
ShowInfo("%s subs\n",msg);
- console->parse_list_subs(cmd->u.next[i],depth + 1);
+ console->input->parse_list_subs(cmd->u.next[i],depth + 1);
} else {
memset(msg, '-', depth);
snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd);
@@ -320,21 +324,21 @@ void console_parse_sub(char *line) {
memcpy(bline, line, 200);
tok = strtok(line, " ");
- for ( i = 0; i < console->cmd_list_count; i++ ) {
- if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 )
+ for ( i = 0; i < console->input->cmd_list_count; i++ ) {
+ if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
break;
}
- if( i == console->cmd_list_count ) {
+ if( i == console->input->cmd_list_count ) {
ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line);
return;
}
- cmd = console->cmd_list[i];
+ cmd = console->input->cmd_list[i];
len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1;
- if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) {
+ if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) {
char *r = NULL;
if( (tok = strtok(NULL, " ")) ) {
r = bline;
@@ -351,7 +355,7 @@ void console_parse_sub(char *line) {
if( strcmpi("help",tok) == 0 ) {
if( cmd->next_count ) {
ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist);
- console->parse_list_subs(cmd,2);
+ console->input->parse_list_subs(cmd,2);
} else {
ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist);
}
@@ -392,95 +396,95 @@ void console_parse(char* line) {
}
void *cThread_main(void *x) {
- while( console->ptstate ) {/* loopx */
- if( console->key_pressed() ) {
+ while( console->input->ptstate ) {/* loopx */
+ if( console->input->key_pressed() ) {
char input[MAX_CONSOLE_INPUT];
- console->parse(input);
+ console->input->parse(input);
if( input[0] != '\0' ) {/* did we get something? */
- EnterSpinLock(&console->ptlock);
+ EnterSpinLock(&console->input->ptlock);
if( cinput.count == CONSOLE_PARSE_SIZE ) {
- LeaveSpinLock(&console->ptlock);
+ LeaveSpinLock(&console->input->ptlock);
continue;/* drop */
}
safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT);
- LeaveSpinLock(&console->ptlock);
+ LeaveSpinLock(&console->input->ptlock);
}
}
- ramutex_lock( console->ptmutex );
- racond_wait( console->ptcond, console->ptmutex, -1 );
- ramutex_unlock( console->ptmutex );
+ ramutex_lock( console->input->ptmutex );
+ racond_wait( console->input->ptcond, console->input->ptmutex, -1 );
+ ramutex_unlock( console->input->ptmutex );
}
return NULL;
}
int console_parse_timer(int tid, int64 tick, int id, intptr_t data) {
int i;
- EnterSpinLock(&console->ptlock);
+ EnterSpinLock(&console->input->ptlock);
for(i = 0; i < cinput.count; i++) {
- console->parse_sub(cinput.queue[i]);
+ console->input->parse_sub(cinput.queue[i]);
}
cinput.count = 0;
- LeaveSpinLock(&console->ptlock);
- racond_signal(console->ptcond);
+ LeaveSpinLock(&console->input->ptlock);
+ racond_signal(console->input->ptcond);
return 0;
}
void console_parse_final(void) {
- if( console->ptstate ) {
- InterlockedDecrement(&console->ptstate);
- racond_signal(console->ptcond);
+ if( console->input->ptstate ) {
+ InterlockedDecrement(&console->input->ptstate);
+ racond_signal(console->input->ptcond);
/* wait for thread to close */
- rathread_wait(console->pthread, NULL);
+ rathread_wait(console->input->pthread, NULL);
- racond_destroy(console->ptcond);
- ramutex_destroy(console->ptmutex);
+ racond_destroy(console->input->ptcond);
+ ramutex_destroy(console->input->ptmutex);
}
}
void console_parse_init(void) {
cinput.count = 0;
- console->ptstate = 1;
+ console->input->ptstate = 1;
- InitializeSpinLock(&console->ptlock);
+ InitializeSpinLock(&console->input->ptlock);
- console->ptmutex = ramutex_create();
- console->ptcond = racond_create();
+ console->input->ptmutex = ramutex_create();
+ console->input->ptcond = racond_create();
- if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){
+ if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){
ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n");
exit(EXIT_FAILURE);
}
- timer->add_func_list(console->parse_timer, "console_parse_timer");
- timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
+ timer->add_func_list(console->input->parse_timer, "console_parse_timer");
+ timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
}
void console_setSQL(Sql *SQL_handle) {
- console->SQL = SQL_handle;
+ console->input->SQL = SQL_handle;
}
#endif /* CONSOLE_INPUT */
void console_init (void) {
#ifdef CONSOLE_INPUT
- console->cmd_count = console->cmd_list_count = 0;
- console->load_defaults();
- console->parse_init();
+ console->input->cmd_count = console->input->cmd_list_count = 0;
+ console->input->load_defaults();
+ console->input->parse_init();
#endif
}
void console_final(void) {
#ifdef CONSOLE_INPUT
unsigned int i;
- console->parse_final();
- for( i = 0; i < console->cmd_count; i++ ) {
- if( console->cmds[i]->next_count )
- aFree(console->cmds[i]->u.next);
- aFree(console->cmds[i]);
+ console->input->parse_final();
+ for( i = 0; i < console->input->cmd_count; i++ ) {
+ if( console->input->cmds[i]->next_count )
+ aFree(console->input->cmds[i]->u.next);
+ aFree(console->input->cmds[i]);
}
- aFree(console->cmds);
- aFree(console->cmd_list);
+ aFree(console->input->cmds);
+ aFree(console->input->cmd_list);
#endif
}
void console_defaults(void) {
@@ -489,17 +493,20 @@ void console_defaults(void) {
console->final = console_final;
console->display_title = display_title;
#ifdef CONSOLE_INPUT
- console->parse_init = console_parse_init;
- console->parse_final = console_parse_final;
- console->parse_timer = console_parse_timer;
- console->pthread_main = cThread_main;
- console->parse = console_parse;
- console->parse_sub = console_parse_sub;
- console->key_pressed = console_parse_key_pressed;
- console->load_defaults = console_load_defaults;
- console->parse_list_subs = console_parse_list_subs;
- console->addCommand = console_parse_create;
- console->setSQL = console_setSQL;
- console->SQL = NULL;
+ console->input = &console_input_s;
+ console->input->parse_init = console_parse_init;
+ console->input->parse_final = console_parse_final;
+ console->input->parse_timer = console_parse_timer;
+ console->input->pthread_main = cThread_main;
+ console->input->parse = console_parse;
+ console->input->parse_sub = console_parse_sub;
+ console->input->key_pressed = console_parse_key_pressed;
+ console->input->load_defaults = console_load_defaults;
+ console->input->parse_list_subs = console_parse_list_subs;
+ console->input->addCommand = console_parse_create;
+ console->input->setSQL = console_setSQL;
+ console->input->SQL = NULL;
+#else
+ console->input = NULL;
#endif
}
diff --git a/src/common/console.h b/src/common/console.h
index 3d19ddc9d..d2c58f978 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -4,11 +4,13 @@
#ifndef _COMMON_CONSOLE_H_
#define _COMMON_CONSOLE_H_
-#include "../common/thread.h"
+#include "../config/core.h" // MAX_CONSOLE_INPUT
+
+#include "../common/cbasetypes.h"
#include "../common/mutex.h"
#include "../common/spinlock.h"
#include "../common/sql.h"
-#include "../config/core.h"
+#include "../common/thread.h"
/**
* Queue Max
@@ -47,11 +49,8 @@ struct {
unsigned short count;
} cinput;
-struct console_interface {
- void (*init) (void);
- void (*final) (void);
- void (*display_title) (void);
#ifdef CONSOLE_INPUT
+struct console_input_interface {
/* vars */
SPIN_LOCK ptlock;/* parse thread lock */
rAthread pthread;/* parse thread */
@@ -77,7 +76,17 @@ struct console_interface {
void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth);
void (*addCommand) (char *name, CParseFunc func);
void (*setSQL) (Sql *SQL_handle);
+};
+#else
+struct console_input_interface;
#endif
+
+struct console_interface {
+ void (*init) (void);
+ void (*final) (void);
+ void (*display_title) (void);
+
+ struct console_input_interface *input;
};
struct console_interface *console;
diff --git a/src/common/core.c b/src/common/core.c
index 49b272488..85f824866 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -2,36 +2,40 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/malloc.h"
-#include "../common/strlib.h"
+#define HERCULES_CORE
+
+#include "../config/core.h"
#include "core.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"
#ifndef MINICORE
- #include "../common/db.h"
- #include "../common/socket.h"
- #include "../common/timer.h"
- #include "../common/thread.h"
- #include "../common/sql.h"
- #include "../config/core.h"
- #include "../common/HPM.h"
- #include "../common/utils.h"
- #include "../common/conf.h"
- #include "../common/ers.h"
+# 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"
#endif
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <signal.h>
#include <string.h>
#ifndef _WIN32
-#include <unistd.h>
+# include <unistd.h>
#else
-#include "../common/winapi.h" // Console close event handling
+# include "../common/winapi.h" // Console close event handling
#endif
/// Called when a terminate signal is received.
diff --git a/src/common/core.h b/src/common/core.h
index e9f7c5961..ba75e6b01 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -7,11 +7,10 @@
#include "../common/db.h"
#include "../common/mmo.h"
-#include "../config/core.h"
/* so that developers with --enable-debug can raise signals from any section of the code they'd like */
#ifdef DEBUG
- #include <signal.h>
+# include <signal.h>
#endif
extern int arg_c;
diff --git a/src/common/db.c b/src/common/db.c
index 8d6b08815..1781aa96f 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -67,14 +67,18 @@
* @encoding US-ASCII
* @see #db.h
\*****************************************************************************/
+
+#define HERCULES_CORE
+
+#include "db.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include "db.h"
-#include "../common/mmo.h"
+#include "../common/ers.h"
#include "../common/malloc.h"
+#include "../common/mmo.h"
#include "../common/showmsg.h"
-#include "../common/ers.h"
#include "../common/strlib.h"
/*****************************************************************************\
diff --git a/src/common/db.h b/src/common/db.h
index 67abe6f19..0d2548806 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -42,9 +42,10 @@
#ifndef _COMMON_DB_H_
#define _COMMON_DB_H_
-#include "../common/cbasetypes.h"
#include <stdarg.h>
+#include "../common/cbasetypes.h"
+
/*****************************************************************************\
* (1) Section with public typedefs, enums, unions, structures and defines. *
* DBRelease - Enumeration of release options. *
diff --git a/src/common/des.c b/src/common/des.c
index ed6d098dc..7f952be76 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -1,8 +1,11 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#include "../common/cbasetypes.h"
-#include "../common/des.h"
+#define HERCULES_CORE
+
+#include "des.h"
+
+#include "../common/cbasetypes.h"
/// DES (Data Encryption Standard) algorithm, modified version.
/// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099.
diff --git a/src/common/ers.c b/src/common/ers.c
index 5a3d7314a..d9895e4f2 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -39,14 +39,18 @@
* @encoding US-ASCII *
* @see common#ers.h *
\*****************************************************************************/
+
+#define HERCULES_CORE
+
+#include "ers.h"
+
#include <stdlib.h>
#include <string.h>
#include "../common/cbasetypes.h"
#include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree
-#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL
#include "../common/nullpo.h"
-#include "ers.h"
+#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL
#ifndef DISABLE_ERS
diff --git a/src/common/grfio.c b/src/common/grfio.c
index bde0ed720..1111fb3f3 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -2,13 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/des.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/utils.h"
-#include "../common/nullpo.h"
+#define HERCULES_CORE
+
#include "grfio.h"
#include <stdio.h>
@@ -17,6 +12,14 @@
#include <sys/stat.h>
#include <zlib.h>
+#include "../common/cbasetypes.h"
+#include "../common/des.h"
+#include "../common/malloc.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+#include "../common/strlib.h"
+#include "../common/utils.h"
+
//----------------------------
// file entry table struct
//----------------------------
diff --git a/src/common/malloc.c b/src/common/malloc.c
index 5b39cbab6..13cf0b5ce 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -2,16 +2,19 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/malloc.h"
-#include "../common/core.h"
-#include "../common/showmsg.h"
-#include "../common/sysinfo.h"
+#define HERCULES_CORE
+
+#include "malloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include "../common/core.h"
+#include "../common/showmsg.h"
+#include "../common/sysinfo.h"
+
struct malloc_interface iMalloc_s;
////////////// Memory Libraries //////////////////
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 3128a3cb0..5c69c7063 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -2,16 +2,19 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/malloc.h"
-#include "../common/strlib.h"
-#include "../common/db.h"
+#define HERCULES_CORE
+
#include "mapindex.h"
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#include "../common/db.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/strlib.h"
/* mapindex.c interface source */
struct mapindex_interface mapindex_s;
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 05fde42cc..e7b506e27 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -6,11 +6,15 @@
*
***********************************************************/
-#include "../common/random.h"
+#define HERCULES_CORE
+
#include "md5calc.h"
-#include <string.h>
+
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#include "../common/random.h"
#ifndef UINT_MAX
#define UINT_MAX 4294967295U
diff --git a/src/common/mmo.h b/src/common/mmo.h
index d535d2874..1d826463e 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -5,10 +5,11 @@
#ifndef _COMMON_MMO_H_
#define _COMMON_MMO_H_
-#include "cbasetypes.h"
-#include "../common/db.h"
#include <time.h>
+#include "../common/cbasetypes.h"
+#include "../common/db.h"
+
// server->client protocol version
// 0 - pre-?
// 1 - ? - 0x196
@@ -96,6 +97,7 @@
//Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default )
#define MAX_BANK_ZENY 2100000000
+#define MAX_LEVEL 175
#define MAX_FAME 1000000000
#define MAX_CART 100
#define MAX_SKILL 1478
diff --git a/src/common/mutex.c b/src/common/mutex.c
index 0668dbc41..12524c3b7 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -1,6 +1,10 @@
// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
+#define HERCULES_CORE
+
+#include "mutex.h"
+
#ifdef WIN32
#include "../common/winapi.h"
#else
@@ -13,7 +17,6 @@
#include "../common/malloc.h"
#include "../common/showmsg.h"
#include "../common/timer.h"
-#include "../common/mutex.h"
struct ramutex{
#ifdef WIN32
diff --git a/src/common/mutex.h b/src/common/mutex.h
index eeb24e6ff..3b83b66d6 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -4,6 +4,7 @@
#ifndef _COMMON_MUTEX_H_
#define _COMMON_MUTEX_H_
+#include "../common/cbasetypes.h"
typedef struct ramutex *ramutex; // Mutex
typedef struct racond *racond; // Condition Var
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index 1cb471aff..1891835f1 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -2,10 +2,14 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+#define HERCULES_CORE
+
+#include "nullpo.h"
+
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
-#include "../common/nullpo.h"
+
#include "../common/showmsg.h"
/**
diff --git a/src/common/random.c b/src/common/random.c
index e46c52cad..7019a31f3 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -1,17 +1,23 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
+#define HERCULES_CORE
+
+#include "random.h"
+
+#include <time.h> // time
+
+#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
+
#include "../common/showmsg.h"
#include "../common/timer.h" // gettick
-#include "random.h"
+
#if defined(WIN32)
- #include "../common/winapi.h"
+# include "../common/winapi.h"
#elif defined(HAVE_GETPID) || defined(HAVE_GETTID)
- #include <sys/types.h>
- #include <unistd.h>
+# include <sys/types.h>
+# include <unistd.h>
#endif
-#include <time.h> // time
-#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
/// Initializes the random number generator with an appropriate seed.
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 14342fe5e..1dbcba282 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -2,23 +2,26 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/strlib.h" // StringBuf
+#define HERCULES_CORE
+
#include "showmsg.h"
-#include "core.h" //[Ind] - For SERVER_TYPE
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h> // atexit
#include <string.h>
-#include <stdarg.h>
#include <time.h>
-#include <stdlib.h> // atexit
#include "../../3rdparty/libconfig/libconfig.h"
+#include "../common/cbasetypes.h"
+#include "../common/core.h" //[Ind] - For SERVER_TYPE
+#include "../common/strlib.h" // StringBuf
+
#ifdef WIN32
-#include "../common/winapi.h"
+# include "../common/winapi.h"
#else // not WIN32
-#include <unistd.h>
+# include <unistd.h>
#endif // WIN32
#if defined(DEBUGLOGMAP)
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index 49fbc34fb..5b32f39ae 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -5,12 +5,14 @@
#ifndef _COMMON_SHOWMSG_H_
#define _COMMON_SHOWMSG_H_
-#ifndef _COMMON_HPMI_H_
- #include "../../3rdparty/libconfig/libconfig.h"
-#endif
-
#include <stdarg.h>
+#ifdef HERCULES_CORE
+# include "../../3rdparty/libconfig/libconfig.h"
+#else
+# include "../common/HPMi.h"
+#endif
+
// for help with the console colors look here:
// http://www.edoceo.com/liberum/?doc=printf-with-color
// some code explanation (used here):
@@ -90,7 +92,7 @@ enum msg_type {
};
extern void ClearScreen(void);
-#ifndef _COMMON_HPMI_H_
+#ifdef HERCULES_CORE
extern void ShowMessage(const char *, ...);
extern void ShowStatus(const char *, ...);
extern void ShowSQL(const char *, ...);
@@ -101,7 +103,18 @@ extern void ClearScreen(void);
extern void ShowError(const char *, ...);
extern void ShowFatalError(const char *, ...);
extern void ShowConfigWarning(config_setting_t *config, const char *string, ...);
+#else
+ HPExport void (*ShowMessage) (const char *, ...);
+ HPExport void (*ShowStatus) (const char *, ...);
+ HPExport void (*ShowSQL) (const char *, ...);
+ HPExport void (*ShowInfo) (const char *, ...);
+ HPExport void (*ShowNotice) (const char *, ...);
+ HPExport void (*ShowWarning) (const char *, ...);
+ HPExport void (*ShowDebug) (const char *, ...);
+ HPExport void (*ShowError) (const char *, ...);
+ HPExport void (*ShowFatalError) (const char *, ...);
#endif
+
extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap);
#endif /* _COMMON_SHOWMSG_H_ */
diff --git a/src/common/socket.c b/src/common/socket.c
index 35d350e95..3738f2c2a 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -2,48 +2,50 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h"
-#include "../common/timer.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../config/core.h"
-#include "../common/HPM.h"
+#define HERCULES_CORE
+#include "../config/core.h" // SHOW_SERVER_STATS
#define _H_SOCKET_C_
-
#include "socket.h"
+#undef _H_SOCKET_C_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include "../common/HPM.h"
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/strlib.h"
+#include "../common/timer.h"
+
#ifdef WIN32
- #include "../common/winapi.h"
+# include "../common/winapi.h"
#else
- #include <errno.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <net/if.h>
- #include <unistd.h>
- #include <sys/time.h>
- #include <sys/ioctl.h>
- #include <netdb.h>
- #include <arpa/inet.h>
-
- #ifndef SIOCGIFCONF
- #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori]
- #endif
- #ifndef FIONBIO
- #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS]
- #endif
-
- #ifdef HAVE_SETRLIMIT
- #include <sys/resource.h>
- #endif
+# include <arpa/inet.h>
+# include <errno.h>
+# include <net/if.h>
+# include <netdb.h>
+# include <netinet/in.h>
+# include <netinet/tcp.h>
+# include <sys/ioctl.h>
+# include <sys/socket.h>
+# include <sys/time.h>
+# include <unistd.h>
+
+# ifndef SIOCGIFCONF
+# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori]
+# endif
+# ifndef FIONBIO
+# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS]
+# endif
+
+# ifdef HAVE_SETRLIMIT
+# include <sys/resource.h>
+# endif
#endif
/**
diff --git a/src/common/socket.h b/src/common/socket.h
index 75adde4cf..804b9284f 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -5,19 +5,19 @@
#ifndef _COMMON_SOCKET_H_
#define _COMMON_SOCKET_H_
+#include <time.h>
+
#include "../common/cbasetypes.h"
#ifdef WIN32
- #include "../common/winapi.h"
+# include "../common/winapi.h"
typedef long in_addr_t;
#else
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
+# include <netinet/in.h>
+# include <sys/socket.h>
+# include <sys/types.h>
#endif
-#include <time.h>
-
struct HPluginData;
#define FIFOSIZE_SERVERLINK 256*1024
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index 29fbb355b..0058e1d83 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -1,4 +1,3 @@
-#pragma once
#ifndef _COMMON_SPINLOCK_H_
#define _COMMON_SPINLOCK_H_
@@ -15,14 +14,14 @@
//
//
+#include "../common/atomic.h"
+#include "../common/cbasetypes.h"
+#include "../common/thread.h"
+
#ifdef WIN32
#include "../common/winapi.h"
#endif
-#include "../common/cbasetypes.h"
-#include "../common/atomic.h"
-#include "../common/thread.h"
-
#ifdef WIN32
typedef struct __declspec( align(64) ) SPIN_LOCK{
diff --git a/src/common/sql.c b/src/common/sql.c
index 79ccc8e92..aeb56bff0 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -2,19 +2,23 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
+#define HERCULES_CORE
+
+#include "sql.h"
+
+#include <stdlib.h> // strtoul
+#include <string.h> // strlen/strnlen/memcpy/memset
+
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/timer.h"
-#include "sql.h"
#ifdef WIN32
-#include "../common/winapi.h"
+# include "../common/winapi.h" // Needed before mysql.h
#endif
#include <mysql.h>
-#include <string.h>// strlen/strnlen/memcpy/memset
-#include <stdlib.h>// strtoul
void hercules_mysql_error_handler(unsigned int ecode);
diff --git a/src/common/sql.h b/src/common/sql.h
index 1fb436853..807e0843c 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -5,10 +5,9 @@
#ifndef _COMMON_SQL_H_
#define _COMMON_SQL_H_
-#include "../common/cbasetypes.h"
#include <stdarg.h>// va_list
-
+#include "../common/cbasetypes.h"
// Return codes
#define SQL_ERROR (-1)
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 361595b07..e2e802915 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -2,16 +2,19 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#define STRLIB_C
+#define HERCULES_CORE
+
+#define _H_STRLIB_C_
#include "strlib.h"
+#undef _H_STRLIB_C_
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
#define J_MAX_MALLOC_SIZE 65535
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 10844d257..decf661a6 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -5,15 +5,16 @@
#ifndef _COMMON_STRLIB_H_
#define _COMMON_STRLIB_H_
-#include "../common/cbasetypes.h"
#include <stdarg.h>
+#include "../common/cbasetypes.h"
+
#ifndef __USE_GNU
- #define __USE_GNU // required to enable strnlen on some platforms
- #include <string.h>
- #undef __USE_GNU
+# define __USE_GNU // required to enable strnlen on some platforms
+# include <string.h>
+# undef __USE_GNU
#else
- #include <string.h>
+# include <string.h>
#endif
#ifdef WIN32
@@ -165,7 +166,7 @@ struct sv_interface *sv;
void strlib_defaults(void);
/* the purpose of these macros is simply to not make calling them be an annoyance */
-#ifndef STRLIB_C
+#ifndef _H_STRLIB_C_
#define jstrescape(pt) (strlib->jstrescape(pt))
#define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt)))
#define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size)))
@@ -189,6 +190,6 @@ void strlib_defaults(void);
#define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__))
#define strline(str,pos) (strlib->strline((str),(pos)))
#define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count)))
-#endif /* STRLIB_C */
+#endif /* _H_STRLIB_C_ */
#endif /* _COMMON_STRLIB_H_ */
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index a56896458..3fdfadb41 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -4,23 +4,39 @@
/// See sysinfo.h for a description of this file
-#define _COMMON_SYSINFO_P_
+#define HERCULES_CORE
+
#include "sysinfo.h"
-#undef _COMMON_SYSINFO_P_
+
+#include <stdio.h> // fopen
+#include <stdlib.h> // atoi
#include "../common/cbasetypes.h"
#include "../common/core.h"
-#include "../common/strlib.h"
#include "../common/malloc.h"
+#include "../common/strlib.h"
#ifdef WIN32
-#include <windows.h>
-#include <string.h> // strlen
+# include <string.h> // strlen
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
-#include <stdio.h> // fopen
-#include <stdlib.h> // atoi
+
+/// Private interface fields
+struct sysinfo_private {
+ char *platform;
+ char *osversion;
+ char *cpu;
+ int cpucores;
+ char *arch;
+ char *compiler;
+ char *cflags;
+ char *vcstype_name;
+ int vcstype;
+ char *vcsrevision_src;
+ char *vcsrevision_scripts;
+};
/// sysinfo.c interface source
struct sysinfo_interface sysinfo_s;
diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h
index 17faac26b..c0c4d276a 100644
--- a/src/common/sysinfo.h
+++ b/src/common/sysinfo.h
@@ -13,23 +13,7 @@
#include "../common/cbasetypes.h"
-#ifdef _COMMON_SYSINFO_P_
-struct sysinfo_private {
- char *platform;
- char *osversion;
- char *cpu;
- int cpucores;
- char *arch;
- char *compiler;
- char *cflags;
- char *vcstype_name;
- int vcstype;
- char *vcsrevision_src;
- char *vcsrevision_scripts;
-};
-#else
struct sysinfo_private;
-#endif
/**
* sysinfo.c interface
diff --git a/src/common/thread.c b/src/common/thread.c
index 4d110f2dd..4f73aa9b3 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -6,24 +6,27 @@
// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
+#define HERCULES_CORE
+
+#include "thread.h"
+
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+
#ifdef WIN32
-#include "../common/winapi.h"
-#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.)
-#define __thread __declspec( thread )
+# include "../common/winapi.h"
+# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.)
+# define __thread __declspec( thread )
#else
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <pthread.h>
-#include <sched.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <signal.h>
+# include <pthread.h>
+# include <sched.h>
#endif
-#include "cbasetypes.h"
-#include "malloc.h"
-#include "showmsg.h"
-#include "thread.h"
-
// When Compiling using MSC (on win32..) we know we have support in any case!
#ifdef _MSC_VER
#define HAS_TLS
diff --git a/src/common/thread.h b/src/common/thread.h
index d6b2bbc6e..887c03179 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -1,7 +1,6 @@
// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#pragma once
#ifndef _COMMON_THREAD_H_
#define _COMMON_THREAD_H_
diff --git a/src/common/timer.c b/src/common/timer.c
index 526854582..10f14b0f2 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -2,11 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/db.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/utils.h"
+#define HERCULES_CORE
+
#include "timer.h"
#include <stdio.h>
@@ -14,11 +11,17 @@
#include <string.h>
#include <time.h>
+#include "../common/cbasetypes.h"
+#include "../common/db.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+#include "../common/utils.h"
+
#ifdef WIN32
-#include "../common/winapi.h" // GetTickCount()
+# include "../common/winapi.h" // GetTickCount()
#else
-#include <unistd.h>
-#include <sys/time.h> // struct timeval, gettimeofday()
+# include <sys/time.h> // struct timeval, gettimeofday()
+# include <unistd.h>
#endif
struct timer_interface timer_s;
diff --git a/src/common/utils.c b/src/common/utils.c
index 47747dd32..84925f707 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -2,33 +2,35 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/mmo.h"
-#include "../common/malloc.h"
-#include "../common/showmsg.h"
-#include "../common/core.h"
-#include "socket.h"
+#define HERCULES_CORE
+
#include "utils.h"
-#include <stdio.h>
+#include <math.h> // floor()
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h> // floor()
+#include <sys/stat.h> // cache purposes [Ind/Hercules]
+
+#include "../common/cbasetypes.h"
+#include "../common/core.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
#ifdef WIN32
- #include "../common/winapi.h"
- #ifndef F_OK
- #define F_OK 0x0
- #endif /* F_OK */
+# include "../common/winapi.h"
+# ifndef F_OK
+# define F_OK 0x0
+# endif /* F_OK */
#else
- #include <unistd.h>
- #include <dirent.h>
- #include <sys/stat.h>
+# include <dirent.h>
+# include <sys/stat.h>
+# include <unistd.h>
#endif
-#include <sys/stat.h> // cache purposes [Ind/Hercules]
-
struct HCache_interface HCache_s;
/// Dumps given buffer into file pointed to by a handle.
diff --git a/src/common/utils.h b/src/common/utils.h
index f89546b8a..823651163 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -5,10 +5,11 @@
#ifndef _COMMON_UTILS_H_
#define _COMMON_UTILS_H_
-#include "../common/cbasetypes.h"
#include <stdio.h> // FILE*
#include <time.h>
+#include "../common/cbasetypes.h"
+
/* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */
#define HCACHE_KEY 'k'