diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-26 10:37:45 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-03-26 10:37:45 +0000 |
commit | 49e9510c432987393d10ec1b8b1c2d416c9feb42 (patch) | |
tree | 4d930ebf1094ad5972cb8ba20b89d12ce74d4f3c /src/common | |
parent | fda87bd7ef5a71f4f5d5e604de1b15c58763efdd (diff) | |
download | hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.gz hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.bz2 hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.xz hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.zip |
Adjusted eAthena code to compile cleanly in C++ mode.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/db.c | 35 | ||||
-rw-r--r-- | src/common/mmo.h | 6 | ||||
-rw-r--r-- | src/common/plugin.h | 3 | ||||
-rw-r--r-- | src/common/plugins.c | 49 | ||||
-rw-r--r-- | src/common/plugins.h | 7 | ||||
-rw-r--r-- | src/common/strlib.c | 2 | ||||
-rw-r--r-- | src/common/strlib.h | 6 | ||||
-rw-r--r-- | src/common/timer.h | 2 |
8 files changed, 65 insertions, 45 deletions
diff --git a/src/common/db.c b/src/common/db.c index 77d3b7b2e..07adf73f1 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -107,6 +107,16 @@ #define HASH_SIZE (256+27) /** + * The color of individual nodes. + * @private + * @see struct dbn + */ +typedef enum node_color { + RED, + BLACK +} node_color; + +/** * A node in a RED-BLACK tree of the database. * @param parent Parent node * @param left Left child node @@ -127,7 +137,7 @@ typedef struct dbn { DBKey key; void *data; // Other - enum {RED, BLACK} color; + node_color color; unsigned deleted : 1; } *DBNode; @@ -503,7 +513,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root) y->parent = node->parent; // switch colors { - int tmp = y->color; + node_color tmp = y->color; y->color = node->color; node->color = tmp; } @@ -2112,7 +2122,7 @@ static DBType db_obj_type(DBMap* self) DBType type; DB_COUNTSTAT(db_type); - if (db == NULL) return -1; // nullpo candidate - TODO what should this return? + if (db == NULL) return (DBType)-1; // nullpo candidate - TODO what should this return? db_free_lock(db); type = db->type; @@ -2176,7 +2186,7 @@ DBOptions db_fix_options(DBType type, DBOptions options) switch (type) { case DB_INT: case DB_UINT: // Numeric database, do nothing with the keys - return options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY); + return (DBOptions)(options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY)); default: ShowError("db_fix_options: Unknown database type %u with options %x\n", type, options); @@ -2512,10 +2522,11 @@ void db_final(void) } // Link DB System - jAthena -void linkdb_insert( struct linkdb_node** head, void *key, void* data) { +void linkdb_insert( struct linkdb_node** head, void *key, void* data) +{ struct linkdb_node *node; if( head == NULL ) return ; - node = aMalloc( sizeof(struct linkdb_node) ); + node = (struct linkdb_node*)aMalloc( sizeof(struct linkdb_node) ); if( *head == NULL ) { // first node *head = node; @@ -2532,7 +2543,8 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data) { node->data = data; } -void* linkdb_search( struct linkdb_node** head, void *key) { +void* linkdb_search( struct linkdb_node** head, void *key) +{ int n = 0; struct linkdb_node *node; if( head == NULL ) return NULL; @@ -2556,7 +2568,8 @@ void* linkdb_search( struct linkdb_node** head, void *key) { return NULL; } -void* linkdb_erase( struct linkdb_node** head, void *key) { +void* linkdb_erase( struct linkdb_node** head, void *key) +{ struct linkdb_node *node; if( head == NULL ) return NULL; node = *head; @@ -2577,7 +2590,8 @@ void* linkdb_erase( struct linkdb_node** head, void *key) { return NULL; } -void linkdb_replace( struct linkdb_node** head, void *key, void *data ) { +void linkdb_replace( struct linkdb_node** head, void *key, void *data ) +{ int n = 0; struct linkdb_node *node; if( head == NULL ) return ; @@ -2603,7 +2617,8 @@ void linkdb_replace( struct linkdb_node** head, void *key, void *data ) { linkdb_insert( head, key, data ); } -void linkdb_final( struct linkdb_node** head ) { +void linkdb_final( struct linkdb_node** head ) +{ struct linkdb_node *node, *node2; if( head == NULL ) return ; node = *head; diff --git a/src/common/mmo.h b/src/common/mmo.h index 0d3ef44a6..845b73a7b 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -256,11 +256,11 @@ struct mmo_charstatus { bool show_equip; }; -enum mail_status { +typedef enum mail_status { MAIL_NEW, MAIL_UNREAD, MAIL_READ, -}; +} mail_status; struct mail_message { unsigned int id; @@ -271,7 +271,7 @@ struct mail_message { char title[MAIL_TITLE_LENGTH]; char body[MAIL_BODY_LENGTH]; - enum mail_status status; + mail_status status; unsigned int timestamp; // marks when the message was sent int zeny; diff --git a/src/common/plugin.h b/src/common/plugin.h index 8aef934d0..fd01be762 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -80,6 +80,9 @@ typedef void Plugin_Event_Func(void); #define PLUGIN_INFO struct _Plugin_Info plugin_info #define PLUGIN_EVENTS_TABLE struct _Plugin_Event_Table plugin_event_table[] + +#ifndef _PLUGINS_H_ void** plugin_call_table; +#endif #endif /* _PLUGIN_H_ */ diff --git a/src/common/plugins.c b/src/common/plugins.c index 58ab60b74..01a6194cd 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -38,6 +38,7 @@ Plugin* plugin_head = NULL; static Plugin_Info default_info = { "Unknown", PLUGIN_ALL, "0", PLUGIN_VERSION, "Unknown" }; +void** plugin_call_table; static size_t call_table_size = 0; static size_t max_call_table = 0; @@ -196,7 +197,7 @@ Plugin* plugin_open(const char* filename) // Retrieve plugin information plugin->state = 0; // initialising - DLL_SYM(info, plugin->dll, "plugin_info"); + info = (Plugin_Info*)DLL_SYM(plugin->dll, "plugin_info"); // For high priority plugins (those that are explicitly loaded from the conf file) // we'll ignore them even (could be a 3rd party dll file) if( !info ) @@ -225,20 +226,20 @@ Plugin* plugin_open(const char* filename) plugin->filename = aStrdup(filename); // Initialise plugin call table (For exporting procedures) - DLL_SYM(procs, plugin->dll, "plugin_call_table"); + procs = (void**)DLL_SYM(plugin->dll, "plugin_call_table"); if( procs ) *procs = plugin_call_table; //else ShowDebug("plugin_open: plugin_call_table not found\n"); // Register plugin events - DLL_SYM(events, plugin->dll, "plugin_event_table"); + events = (Plugin_Event_Table*)DLL_SYM(plugin->dll, "plugin_event_table"); if( events ){ int i = 0; //ShowDebug("plugin_open: parsing plugin_event_table\n"); while( events[i].func_name ){ if( strcmpi(events[i].event_name, EVENT_PLUGIN_TEST) == 0 ){ Plugin_Test_Func* test_func; - DLL_SYM(test_func, plugin->dll, events[i].func_name); + test_func = (Plugin_Test_Func*)DLL_SYM(plugin->dll, events[i].func_name); //ShowDebug("plugin_open: invoking "EVENT_PLUGIN_TEST" with %s()\n", events[i].func_name); if( test_func && test_func() == 0 ){ // plugin has failed test, disabling @@ -247,7 +248,7 @@ Plugin* plugin_open(const char* filename) } } else { Plugin_Event_Func* func; - DLL_SYM(func, plugin->dll, events[i].func_name); + func = (Plugin_Event_Func*)DLL_SYM(plugin->dll, events[i].func_name); if (func) register_plugin_event(func, events[i].event_name); } @@ -340,27 +341,27 @@ void plugins_init(void) register_plugin_func(EVENT_ATHENA_FINAL); // networking - export_symbol(RFIFOSKIP, SYMBOL_RFIFOSKIP); - export_symbol(WFIFOSET, SYMBOL_WFIFOSET); - export_symbol(do_close, SYMBOL_DELETE_SESSION); - export_symbol(session, SYMBOL_SESSION); - export_symbol(&fd_max, SYMBOL_FD_MAX); - export_symbol(addr_, SYMBOL_ADDR); + EXPORT_SYMBOL(RFIFOSKIP, SYMBOL_RFIFOSKIP); + EXPORT_SYMBOL(WFIFOSET, SYMBOL_WFIFOSET); + EXPORT_SYMBOL(do_close, SYMBOL_DELETE_SESSION); + EXPORT_SYMBOL(session, SYMBOL_SESSION); + EXPORT_SYMBOL(&fd_max, SYMBOL_FD_MAX); + EXPORT_SYMBOL(addr_, SYMBOL_ADDR); // timers - export_symbol(get_uptime, SYMBOL_GET_UPTIME); - export_symbol(delete_timer, SYMBOL_DELETE_TIMER); - export_symbol(add_timer_func_list, SYMBOL_ADD_TIMER_FUNC_LIST); - export_symbol(add_timer_interval, SYMBOL_ADD_TIMER_INTERVAL); - export_symbol(add_timer, SYMBOL_ADD_TIMER); - export_symbol((void*)get_svn_revision, SYMBOL_GET_SVN_REVISION); - export_symbol(gettick, SYMBOL_GETTICK); + EXPORT_SYMBOL(get_uptime, SYMBOL_GET_UPTIME); + EXPORT_SYMBOL(delete_timer, SYMBOL_DELETE_TIMER); + EXPORT_SYMBOL(add_timer_func_list, SYMBOL_ADD_TIMER_FUNC_LIST); + EXPORT_SYMBOL(add_timer_interval, SYMBOL_ADD_TIMER_INTERVAL); + EXPORT_SYMBOL(add_timer, SYMBOL_ADD_TIMER); + EXPORT_SYMBOL((void*)get_svn_revision, SYMBOL_GET_SVN_REVISION); + EXPORT_SYMBOL(gettick, SYMBOL_GETTICK); // core - export_symbol(parse_console, SYMBOL_PARSE_CONSOLE); - export_symbol(&runflag, SYMBOL_RUNFLAG); - export_symbol(arg_v, SYMBOL_ARG_V); - export_symbol(&arg_c, SYMBOL_ARG_C); - export_symbol(SERVER_NAME, SYMBOL_SERVER_NAME); - export_symbol(&SERVER_TYPE, SYMBOL_SERVER_TYPE); + EXPORT_SYMBOL(parse_console, SYMBOL_PARSE_CONSOLE); + EXPORT_SYMBOL(&runflag, SYMBOL_RUNFLAG); + EXPORT_SYMBOL(arg_v, SYMBOL_ARG_V); + EXPORT_SYMBOL(&arg_c, SYMBOL_ARG_C); + EXPORT_SYMBOL(SERVER_NAME, SYMBOL_SERVER_NAME); + EXPORT_SYMBOL(&SERVER_TYPE, SYMBOL_SERVER_TYPE); load_priority = 1; plugins_config_read(PLUGIN_CONF_FILENAME); diff --git a/src/common/plugins.h b/src/common/plugins.h index b4235e72d..9d93bcaa6 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -17,7 +17,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> #define DLL_OPEN(x) LoadLibrary(x) - #define DLL_SYM(x,y,z) (FARPROC)(x) = GetProcAddress(y,z) + #define DLL_SYM(x,y) GetProcAddress(x,y) #define DLL_CLOSE(x) FreeLibrary(x) char *DLL_ERROR(void); @@ -28,7 +28,7 @@ #include <dlfcn.h> #define DLL_OPEN(x) dlopen(x,RTLD_NOW) - #define DLL_SYM(x,y,z) (x) = (void *)dlsym(y,z) + #define DLL_SYM(x,y) dlsym(x,y) #define DLL_CLOSE(x) dlclose(x) #define DLL_ERROR dlerror @@ -60,7 +60,8 @@ int register_plugin_event(Plugin_Event_Func* func, char* name); int plugin_event_trigger(char* name); int export_symbol(void* var, size_t offset); -#define EXPORT_SYMBOL(s) export_symbol((s), -1); +#define EXPORT_SYMBOL(s,o) export_symbol((void*)(s),(o)); +#define EXPORT_SYMBOL2(s) EXPORT_SYMBOL((s), -1); Plugin* plugin_open(const char* filename); void plugin_load(const char* filename); diff --git a/src/common/strlib.c b/src/common/strlib.c index b65bc0c55..5b53a29da 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -241,7 +241,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) } #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char* string, size_t maxlen) diff --git a/src/common/strlib.h b/src/common/strlib.h index d1fb20d49..004fe6375 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -24,7 +24,7 @@ const char *stristr(const char *haystack, const char *needle); char* _strtok_r(char* s1, const char* s2, char** lasts); #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) size_t strnlen (const char* string, size_t maxlen); #endif @@ -49,7 +49,7 @@ int strline(const char* str, size_t pos); /// Bitfield determining the behaviour of sv_parse. -enum e_svopt +typedef enum e_svopt { // default: no escapes and no line terminator SV_NOESCAPE_NOTERMINATE = 0, @@ -59,7 +59,7 @@ enum e_svopt SV_TERMINATE_LF = 2, SV_TERMINATE_CRLF = 4, SV_TERMINATE_CR = 8, -}; +} e_svopt; /// Other escape sequences supported by the C compiler. #define SV_ESCAPE_C_SUPPORTED "abtnvfr\?\"'\\" diff --git a/src/common/timer.h b/src/common/timer.h index 7eedb689e..9c9d5c2b1 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -51,7 +51,7 @@ int add_timer_func_list(TimerFunc func, char* name); unsigned long get_uptime(void); unsigned int calc_times(void); -int do_timer(); +int do_timer(unsigned int tick); void timer_init(void); void timer_final(void); |