summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-05-10 06:08:56 -0300
committerpanikon <panikon@zoho.com>2014-05-10 06:08:56 -0300
commit94657284973f4037596bae468ebfbee5c217e02b (patch)
treec99c1e3a39ad41183f2d70eb093df54ca60ad0fb /src/common
parenta1eba2e076401ddbc34e5a65e15bb0f418591b1a (diff)
downloadhercules-94657284973f4037596bae468ebfbee5c217e02b.tar.gz
hercules-94657284973f4037596bae468ebfbee5c217e02b.tar.bz2
hercules-94657284973f4037596bae468ebfbee5c217e02b.tar.xz
hercules-94657284973f4037596bae468ebfbee5c217e02b.zip
Revert "Fixed order of includes in all source files"
This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/
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, 335 insertions, 434 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 00b92dc60..9ffce87de 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -1,31 +1,26 @@
// 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/conf.h"
-#include "../common/console.h"
+#include "../common/mmo.h"
#include "../common/core.h"
#include "../common/malloc.h"
-#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
-#include "../common/sql.h"
-#include "../common/strlib.h"
-#include "../common/sysinfo.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/sysinfo.h"
+#include "HPM.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#ifndef WIN32
-# include <unistd.h>
+#include <unistd.h>
#endif
struct malloc_interface iMalloc_HPM;
@@ -691,7 +686,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->input->addCommand,"addCPCommand");
+ HPM->share(console->addCommand,"addCPCommand");
#endif
/* our own */
HPM->share(hplugins_addpacket,"addPacket");
@@ -760,7 +755,7 @@ void hpm_init(void) {
HPM->symbol_defaults();
#ifdef CONSOLE_INPUT
- console->input->addCommand("plugins",CPCMD_A(plugins));
+ console->addCommand("plugins",CPCMD_A(plugins));
#endif
return;
}
diff --git a/src/common/HPM.h b/src/common/HPM.h
index 9c176cfd6..0f0df4cda 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -4,12 +4,8 @@
#ifndef _COMMON_HPM_H_
#define _COMMON_HPM_H_
-#ifndef HERCULES_CORE
-#error You should never include HPM.h from a plugin.
-#endif
-
-#include "../common/HPMi.h"
#include "../common/cbasetypes.h"
+#include "../common/HPMi.h"
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
diff --git a/src/common/HPMi.h b/src/common/HPMi.h
index b98e87d90..19206aeca 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/console.h"
#include "../common/core.h"
+#include "../common/console.h"
#include "../common/sql.h"
struct script_state;
@@ -20,6 +20,18 @@ 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"
@@ -180,7 +192,7 @@ HPExport struct HPMi_interface {
/* pc group permission */
void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask);
} HPMi_s;
-#ifndef HERCULES_CORE
+#ifndef _COMMON_HPM_H_
HPExport struct HPMi_interface *HPMi;
#endif
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index da0d6b307..f44e80413 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -442,11 +442,5 @@ 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 46a034497..b816b2f7f 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -2,10 +2,7 @@
// 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 e5b637e47..9aff3df47 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -6,7 +6,6 @@
#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 6a82db555..d8f352c8a 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -2,46 +2,42 @@
// 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/core.h"
#include "../common/showmsg.h"
+#include "../common/core.h"
#include "../common/sysinfo.h"
+#include "../config/core.h"
+#include "console.h"
#ifndef MINICORE
-# 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"
+ #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"
#endif
+#include <stdio.h>
+#include <stdlib.h>
#if !defined(WIN32)
-# include <sys/time.h>
-# include <unistd.h>
+ #include <unistd.h>
+ #include <sys/time.h>
#else
-# include "../common/winapi.h" // Console close event handling
-# ifdef CONSOLE_INPUT
-# include <conio.h> /* _kbhit() */
-# endif
+ #include "../common/winapi.h" // Console close event handling
#endif
-struct console_interface console_s;
#ifdef CONSOLE_INPUT
-struct console_input_interface console_input_s;
+ #if defined(WIN32)
+ #include <conio.h> /* _kbhit() */
+ #endif
#endif
+struct console_interface console_s;
+
/*======================================
* CORE : Display title
*--------------------------------------*/
@@ -120,12 +116,12 @@ CPCMD_C(mem_report,server) {
**/
CPCMD(help) {
unsigned int i = 0;
- 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);
+ 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);
} else {
- ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd);
+ ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd);
}
}
}
@@ -148,7 +144,7 @@ CPCMD_C(skip,update) {
ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n");
return;
}
- Sql_HerculesUpdateSkip(console->input->SQL, line);
+ Sql_HerculesUpdateSkip(console->SQL, line);
}
/**
@@ -210,7 +206,7 @@ void console_load_defaults(void) {
unsigned int i, len = ARRAYLENGTH(default_list);
struct CParseEntry *cmd;
- RECREATE(console->input->cmds,struct CParseEntry *, len);
+ RECREATE(console->cmds,struct CParseEntry *, len);
for(i = 0; i < len; i++) {
CREATE(cmd, struct CParseEntry, 1);
@@ -224,12 +220,12 @@ void console_load_defaults(void) {
cmd->next_count = 0;
- console->input->cmd_count++;
- console->input->cmds[i] = cmd;
+ console->cmd_count++;
+ console->cmds[i] = cmd;
default_list[i].self = cmd;
if( !default_list[i].connect ) {
- RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count);
- console->input->cmd_list[console->input->cmd_list_count - 1] = cmd;
+ RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count);
+ console->cmd_list[console->cmd_list_count - 1] = cmd;
}
}
@@ -237,11 +233,11 @@ void console_load_defaults(void) {
unsigned int k;
if( !default_list[i].connect )
continue;
- for(k = 0; k < console->input->cmd_count; k++) {
- if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) {
+ for(k = 0; k < console->cmd_count; k++) {
+ if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) {
cmd = default_list[i].self;
- 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;
+ 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;
break;
}
}
@@ -260,23 +256,23 @@ void console_parse_create(char *name, CParseFunc func) {
safestrncpy(sublist, name, CP_CMD_LENGTH * 5);
tok = strtok(sublist,":");
- for ( i = 0; i < console->input->cmd_list_count; i++ ) {
- if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
+ for ( i = 0; i < console->cmd_list_count; i++ ) {
+ if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 )
break;
}
- if( i == console->input->cmd_list_count ) {
- RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count);
+ if( i == console->cmd_list_count ) {
+ RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count);
CREATE(cmd, struct CParseEntry, 1);
safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH);
cmd->next_count = 0;
- 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;
+ 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;
}
- cmd = console->input->cmd_list[i];
+ cmd = console->cmd_list[i];
while( ( tok = strtok(NULL, ":") ) != NULL ) {
for(i = 0; i < cmd->next_count; i++) {
@@ -285,13 +281,13 @@ void console_parse_create(char *name, CParseFunc func) {
}
if ( i == cmd->next_count ) {
- 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(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(cmd->u.next, struct CParseEntry *, ++cmd->next_count);
- cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1];
- cmd = console->input->cmds[console->input->cmd_count-1];
+ cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1];
+ cmd = console->cmds[console->cmd_count-1];
continue;
}
@@ -306,7 +302,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->input->parse_list_subs(cmd->u.next[i],depth + 1);
+ console->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);
@@ -324,21 +320,21 @@ void console_parse_sub(char *line) {
memcpy(bline, line, 200);
tok = strtok(line, " ");
- for ( i = 0; i < console->input->cmd_list_count; i++ ) {
- if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 )
+ for ( i = 0; i < console->cmd_list_count; i++ ) {
+ if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 )
break;
}
- if( i == console->input->cmd_list_count ) {
+ if( i == console->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->input->cmd_list[i];
+ cmd = console->cmd_list[i];
len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1;
- if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) {
+ if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) {
char *r = NULL;
if( (tok = strtok(NULL, " ")) ) {
r = bline;
@@ -355,7 +351,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->input->parse_list_subs(cmd,2);
+ console->parse_list_subs(cmd,2);
} else {
ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist);
}
@@ -396,95 +392,95 @@ void console_parse(char* line) {
}
void *cThread_main(void *x) {
- while( console->input->ptstate ) {/* loopx */
- if( console->input->key_pressed() ) {
+ while( console->ptstate ) {/* loopx */
+ if( console->key_pressed() ) {
char input[MAX_CONSOLE_INPUT];
- console->input->parse(input);
+ console->parse(input);
if( input[0] != '\0' ) {/* did we get something? */
- EnterSpinLock(&console->input->ptlock);
+ EnterSpinLock(&console->ptlock);
if( cinput.count == CONSOLE_PARSE_SIZE ) {
- LeaveSpinLock(&console->input->ptlock);
+ LeaveSpinLock(&console->ptlock);
continue;/* drop */
}
safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT);
- LeaveSpinLock(&console->input->ptlock);
+ LeaveSpinLock(&console->ptlock);
}
}
- ramutex_lock( console->input->ptmutex );
- racond_wait( console->input->ptcond, console->input->ptmutex, -1 );
- ramutex_unlock( console->input->ptmutex );
+ ramutex_lock( console->ptmutex );
+ racond_wait( console->ptcond, console->ptmutex, -1 );
+ ramutex_unlock( console->ptmutex );
}
return NULL;
}
int console_parse_timer(int tid, int64 tick, int id, intptr_t data) {
int i;
- EnterSpinLock(&console->input->ptlock);
+ EnterSpinLock(&console->ptlock);
for(i = 0; i < cinput.count; i++) {
- console->input->parse_sub(cinput.queue[i]);
+ console->parse_sub(cinput.queue[i]);
}
cinput.count = 0;
- LeaveSpinLock(&console->input->ptlock);
- racond_signal(console->input->ptcond);
+ LeaveSpinLock(&console->ptlock);
+ racond_signal(console->ptcond);
return 0;
}
void console_parse_final(void) {
- if( console->input->ptstate ) {
- InterlockedDecrement(&console->input->ptstate);
- racond_signal(console->input->ptcond);
+ if( console->ptstate ) {
+ InterlockedDecrement(&console->ptstate);
+ racond_signal(console->ptcond);
/* wait for thread to close */
- rathread_wait(console->input->pthread, NULL);
+ rathread_wait(console->pthread, NULL);
- racond_destroy(console->input->ptcond);
- ramutex_destroy(console->input->ptmutex);
+ racond_destroy(console->ptcond);
+ ramutex_destroy(console->ptmutex);
}
}
void console_parse_init(void) {
cinput.count = 0;
- console->input->ptstate = 1;
+ console->ptstate = 1;
- InitializeSpinLock(&console->input->ptlock);
+ InitializeSpinLock(&console->ptlock);
- console->input->ptmutex = ramutex_create();
- console->input->ptcond = racond_create();
+ console->ptmutex = ramutex_create();
+ console->ptcond = racond_create();
- if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){
+ if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){
ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n");
exit(EXIT_FAILURE);
}
- 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 */
+ 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 */
}
void console_setSQL(Sql *SQL_handle) {
- console->input->SQL = SQL_handle;
+ console->SQL = SQL_handle;
}
#endif /* CONSOLE_INPUT */
void console_init (void) {
#ifdef CONSOLE_INPUT
- console->input->cmd_count = console->input->cmd_list_count = 0;
- console->input->load_defaults();
- console->input->parse_init();
+ console->cmd_count = console->cmd_list_count = 0;
+ console->load_defaults();
+ console->parse_init();
#endif
}
void console_final(void) {
#ifdef CONSOLE_INPUT
unsigned int 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]);
+ 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]);
}
- aFree(console->input->cmds);
- aFree(console->input->cmd_list);
+ aFree(console->cmds);
+ aFree(console->cmd_list);
#endif
}
void console_defaults(void) {
@@ -493,20 +489,17 @@ void console_defaults(void) {
console->final = console_final;
console->display_title = display_title;
#ifdef CONSOLE_INPUT
- 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;
+ 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;
#endif
}
diff --git a/src/common/console.h b/src/common/console.h
index d2c58f978..3d19ddc9d 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -4,13 +4,11 @@
#ifndef _COMMON_CONSOLE_H_
#define _COMMON_CONSOLE_H_
-#include "../config/core.h" // MAX_CONSOLE_INPUT
-
-#include "../common/cbasetypes.h"
+#include "../common/thread.h"
#include "../common/mutex.h"
#include "../common/spinlock.h"
#include "../common/sql.h"
-#include "../common/thread.h"
+#include "../config/core.h"
/**
* Queue Max
@@ -49,8 +47,11 @@ 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 */
@@ -76,17 +77,7 @@ struct console_input_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 85f824866..49b272488 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -2,40 +2,36 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#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/malloc.h"
#include "../common/strlib.h"
+#include "core.h"
+#include "../common/console.h"
+#include "../common/random.h"
#include "../common/sysinfo.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/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"
#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 ba75e6b01..e9f7c5961 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -7,10 +7,11 @@
#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 1781aa96f..8d6b08815 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -67,18 +67,14 @@
* @encoding US-ASCII
* @see #db.h
\*****************************************************************************/
-
-#define HERCULES_CORE
-
-#include "db.h"
-
#include <stdio.h>
#include <stdlib.h>
-#include "../common/ers.h"
-#include "../common/malloc.h"
+#include "db.h"
#include "../common/mmo.h"
+#include "../common/malloc.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 0d2548806..67abe6f19 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -42,9 +42,8 @@
#ifndef _COMMON_DB_H_
#define _COMMON_DB_H_
-#include <stdarg.h>
-
#include "../common/cbasetypes.h"
+#include <stdarg.h>
/*****************************************************************************\
* (1) Section with public typedefs, enums, unions, structures and defines. *
diff --git a/src/common/des.c b/src/common/des.c
index 7f952be76..ed6d098dc 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -1,11 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-
-#define HERCULES_CORE
-
-#include "des.h"
-
#include "../common/cbasetypes.h"
+#include "../common/des.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 d9895e4f2..5a3d7314a 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -39,18 +39,14 @@
* @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/nullpo.h"
#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL
+#include "../common/nullpo.h"
+#include "ers.h"
#ifndef DISABLE_ERS
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 1111fb3f3..bde0ed720 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -2,8 +2,13 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
+#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"
#include "grfio.h"
#include <stdio.h>
@@ -12,14 +17,6 @@
#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 13cf0b5ce..5b39cbab6 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -2,19 +2,16 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
-#include "malloc.h"
+#include "../common/malloc.h"
+#include "../common/core.h"
+#include "../common/showmsg.h"
+#include "../common/sysinfo.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 5c69c7063..3128a3cb0 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -2,19 +2,16 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/malloc.h"
+#include "../common/strlib.h"
+#include "../common/db.h"
#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 e7b506e27..05fde42cc 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -6,15 +6,11 @@
*
***********************************************************/
-#define HERCULES_CORE
-
+#include "../common/random.h"
#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 1d826463e..d535d2874 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -5,10 +5,9 @@
#ifndef _COMMON_MMO_H_
#define _COMMON_MMO_H_
-#include <time.h>
-
-#include "../common/cbasetypes.h"
+#include "cbasetypes.h"
#include "../common/db.h"
+#include <time.h>
// server->client protocol version
// 0 - pre-?
@@ -97,7 +96,6 @@
//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 12524c3b7..0668dbc41 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -1,10 +1,6 @@
// 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
@@ -17,6 +13,7 @@
#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 3b83b66d6..eeb24e6ff 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -4,7 +4,6 @@
#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 1891835f1..1cb471aff 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -2,14 +2,10 @@
// 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 7019a31f3..e46c52cad 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -1,23 +1,17 @@
// 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 1dbcba282..14342fe5e 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -2,26 +2,23 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
+#include "../common/cbasetypes.h"
+#include "../common/strlib.h" // StringBuf
#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 5b32f39ae..49fbc34fb 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -5,14 +5,12 @@
#ifndef _COMMON_SHOWMSG_H_
#define _COMMON_SHOWMSG_H_
-#include <stdarg.h>
-
-#ifdef HERCULES_CORE
-# include "../../3rdparty/libconfig/libconfig.h"
-#else
-# include "../common/HPMi.h"
+#ifndef _COMMON_HPMI_H_
+ #include "../../3rdparty/libconfig/libconfig.h"
#endif
+#include <stdarg.h>
+
// for help with the console colors look here:
// http://www.edoceo.com/liberum/?doc=printf-with-color
// some code explanation (used here):
@@ -92,7 +90,7 @@ enum msg_type {
};
extern void ClearScreen(void);
-#ifdef HERCULES_CORE
+#ifndef _COMMON_HPMI_H_
extern void ShowMessage(const char *, ...);
extern void ShowStatus(const char *, ...);
extern void ShowSQL(const char *, ...);
@@ -103,18 +101,7 @@ 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 3738f2c2a..35d350e95 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -2,50 +2,48 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
+#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"
-#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 <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
+ #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
#endif
/**
diff --git a/src/common/socket.h b/src/common/socket.h
index 804b9284f..75adde4cf 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 <netinet/in.h>
-# include <sys/socket.h>
-# include <sys/types.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.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 0058e1d83..29fbb355b 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -1,3 +1,4 @@
+#pragma once
#ifndef _COMMON_SPINLOCK_H_
#define _COMMON_SPINLOCK_H_
@@ -14,14 +15,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 aeb56bff0..79ccc8e92 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -2,23 +2,19 @@
// 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" // Needed before mysql.h
+#include "../common/winapi.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 807e0843c..1fb436853 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -5,9 +5,10 @@
#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 e2e802915..361595b07 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -2,19 +2,16 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
-#define _H_STRLIB_C_
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+#define 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 decf661a6..10844d257 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -5,16 +5,15 @@
#ifndef _COMMON_STRLIB_H_
#define _COMMON_STRLIB_H_
-#include <stdarg.h>
-
#include "../common/cbasetypes.h"
+#include <stdarg.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
@@ -166,7 +165,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 _H_STRLIB_C_
+#ifndef 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)))
@@ -190,6 +189,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 /* _H_STRLIB_C_ */
+#endif /* STRLIB_C */
#endif /* _COMMON_STRLIB_H_ */
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index 3fdfadb41..a56896458 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -4,39 +4,23 @@
/// See sysinfo.h for a description of this file
-#define HERCULES_CORE
-
+#define _COMMON_SYSINFO_P_
#include "sysinfo.h"
-
-#include <stdio.h> // fopen
-#include <stdlib.h> // atoi
+#undef _COMMON_SYSINFO_P_
#include "../common/cbasetypes.h"
#include "../common/core.h"
-#include "../common/malloc.h"
#include "../common/strlib.h"
+#include "../common/malloc.h"
#ifdef WIN32
-# include <string.h> // strlen
-# include <windows.h>
+#include <windows.h>
+#include <string.h> // strlen
#else
-# include <unistd.h>
+#include <unistd.h>
#endif
-
-/// 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;
-};
+#include <stdio.h> // fopen
+#include <stdlib.h> // atoi
/// sysinfo.c interface source
struct sysinfo_interface sysinfo_s;
diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h
index c0c4d276a..17faac26b 100644
--- a/src/common/sysinfo.h
+++ b/src/common/sysinfo.h
@@ -13,7 +13,23 @@
#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 4f73aa9b3..4d110f2dd 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -6,27 +6,24 @@
// 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 887c03179..d6b2bbc6e 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -1,6 +1,7 @@
// 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 10f14b0f2..526854582 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -2,8 +2,11 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
+#include "../common/cbasetypes.h"
+#include "../common/db.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+#include "../common/utils.h"
#include "timer.h"
#include <stdio.h>
@@ -11,17 +14,11 @@
#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 <sys/time.h> // struct timeval, gettimeofday()
-# include <unistd.h>
+#include <unistd.h>
+#include <sys/time.h> // struct timeval, gettimeofday()
#endif
struct timer_interface timer_s;
diff --git a/src/common/utils.c b/src/common/utils.c
index 84925f707..47747dd32 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -2,35 +2,33 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#define HERCULES_CORE
-
+#include "../common/cbasetypes.h"
+#include "../common/mmo.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+#include "../common/core.h"
+#include "socket.h"
#include "utils.h"
-#include <math.h> // floor()
-#include <stdarg.h>
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#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"
+#include <math.h> // floor()
#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 <dirent.h>
-# include <sys/stat.h>
-# include <unistd.h>
+ #include <unistd.h>
+ #include <dirent.h>
+ #include <sys/stat.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 823651163..f89546b8a 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -5,11 +5,10 @@
#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'