From 6b9f58446c46877ecfc5fe40847636145acf5af8 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 4 Aug 2013 12:19:25 -0300 Subject: HPM Update - Custom Packet Support - Custom Data Struct Support (currently append-able to map_session_data and socket_data) - Char Server Support - Login Server Support http://hercules.ws/board/topic/1934-hercules-plugin-manager-update/ Documentation will soon be updated in http://hercules.ws/wiki/HPM Signed-off-by: shennetsind --- src/common/malloc.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/common/malloc.h b/src/common/malloc.h index 834781905..bc8aa9a20 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -67,18 +67,21 @@ void malloc_defaults(void); struct malloc_interface { + void (*init) (void); + void (*final) (void); + /* */ void* (*malloc )(size_t size, const char *file, int line, const char *func); void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func); void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func); char* (*astrdup )(const char *p, const char *file, int line, const char *func); void (*free )(void *p, const char *file, int line, const char *func); - + /* */ void (*memory_check)(void); bool (*verify_ptr)(void* ptr); size_t (*usage) (void); - void (*init) (void); - void (*final) (void); -} iMalloc_s; + /* */ + void (*post_shutdown) (void); +}; void memmgr_report (int extra); -- cgit v1.2.3-70-g09d2 From 12dce46d611d6ea7c772174ebbd555fa10fead99 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 18 Nov 2013 08:53:22 +0100 Subject: Sanitized and improved several macros through the code - Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru --- src/char/char.c | 2 +- src/char/char.h | 2 +- src/char/inter.h | 9 ++-- src/common/HPM.c | 1 + src/common/HPM.h | 24 +++++------ src/common/HPMi.h | 32 +++++++------- src/common/cbasetypes.h | 10 +++-- src/common/console.c | 4 ++ src/common/core.c | 2 +- src/common/db.c | 2 +- src/common/db.h | 12 +++--- src/common/ers.h | 10 ++--- src/common/grfio.h | 2 +- src/common/malloc.c | 64 ++++++++++++++-------------- src/common/malloc.h | 16 +++---- src/common/mapindex.h | 2 +- src/common/mempool.c | 10 ++--- src/common/mmo.h | 2 +- src/common/netbuffer.h | 10 ++--- src/common/network.c | 2 +- src/common/raconf.c | 29 ++++++------- src/common/showmsg.c | 111 +++++++++++++++++++----------------------------- src/common/socket.c | 26 ++++++------ src/common/socket.h | 21 ++++----- src/common/spinlock.h | 4 +- src/common/sql.h | 14 ++---- src/common/strlib.h | 32 +++++++------- src/common/timer.h | 2 +- src/common/utils.h | 2 +- src/config/const.h | 7 --- src/login/login.h | 4 +- src/map/atcommand.c | 69 ++++++++++++++---------------- src/map/battle.c | 50 ++++++++++++++-------- src/map/battle.h | 14 +++--- src/map/chrif.c | 2 +- src/map/clif.c | 4 +- src/map/clif.h | 2 +- src/map/elemental.h | 4 +- src/map/homunculus.h | 2 +- src/map/intif.c | 2 +- src/map/intif.h | 6 +-- src/map/itemdb.h | 75 ++++++++++++++++---------------- src/map/map.c | 4 +- src/map/map.h | 18 ++++---- src/map/mob.c | 2 +- src/map/mob.h | 7 +-- src/map/path.h | 12 +++--- src/map/pc.h | 30 ++++++------- src/map/pet.h | 4 +- src/map/script.c | 15 ++++--- src/map/script.h | 37 ++++++++-------- src/map/skill.c | 36 ++++++++-------- src/map/status.c | 32 ++++++++------ src/map/status.h | 106 ++++++++++++++++++++++----------------------- 54 files changed, 495 insertions(+), 508 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/char/char.c b/src/char/char.c index f1b95474e..a1c6f73b1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3933,7 +3933,7 @@ int parse_char(int fd) while( RFIFOREST(fd) >= 2 ) { //For use in packets that depend on an sd being present [Skotlex] - #define FIFOSD_CHECK(rest) { if(RFIFOREST(fd) < rest) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,rest); return 0; } } + #define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0) if( HPM->packetsc[hpParse_Char] ) { if( (i = HPM->parse_packets(fd,hpParse_Char)) ) { diff --git a/src/char/char.h b/src/char/char.h index c7a387645..c6aa1b66d 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -48,7 +48,7 @@ DBMap* online_char_db; // int account_id -> struct online_char_data* #define MAX_MAP_SERVERS 2 -#define DEFAULT_AUTOSAVE_INTERVAL 300*1000 +#define DEFAULT_AUTOSAVE_INTERVAL (300*1000) enum { TABLE_INVENTORY, diff --git a/src/char/inter.h b/src/char/inter.h index 88501c9a0..9b958dc72 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -30,13 +30,12 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type uint64 inter_chk_lastuid(int8 flag, uint64 value); #ifdef NSI_UNIQUE_ID - #define updateLastUid(val_) inter_chk_lastuid(1, val_) - #define dbUpdateUid(handler_)\ - { \ + #define updateLastUid(val_) inter_chk_lastuid(1, (val_)) + #define dbUpdateUid(handler_) do { \ uint64 unique_id_ = inter_chk_lastuid(0, 0); \ - if (unique_id_ && SQL_ERROR == SQL->Query(handler_, "UPDATE `%s` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", interreg_db, unique_id_)) \ + if (unique_id_ && SQL_ERROR == SQL->Query((handler_), "UPDATE `%s` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", interreg_db, unique_id_)) \ Sql_ShowDebug(handler_);\ - } + } while(0) #else #define dbUpdateUid(handler_) #define updateLastUid(val_) diff --git a/src/common/HPM.c b/src/common/HPM.c index 1f4d4d532..641ffe2e6 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -108,6 +108,7 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) { return true; } +#undef HPM_POP struct hplugin *hplugin_load(const char* filename) { struct hplugin *plugin; struct hplugin_info *info; diff --git a/src/common/HPM.h b/src/common/HPM.h index 9a6bda713..5466693ab 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -12,29 +12,29 @@ #define WIN32_LEAN_AND_MEAN #endif #include - #define plugin_open(x) LoadLibraryA(x) - #define plugin_import(x,y,z) (z)GetProcAddress(x,y) - #define plugin_close(x) FreeLibrary(x) + #define plugin_open(x) LoadLibraryA(x) + #define plugin_import(x,y,z) (z)GetProcAddress((x),(y)) + #define plugin_close(x) FreeLibrary(x) - #define DLL_EXT ".dll" - #define DLL HINSTANCE + #define DLL_EXT ".dll" + #define DLL HINSTANCE #else // ! WIN32 #include #ifdef RTLD_DEEPBIND // Certain linux ditributions require this, but it's not available everywhere - #define plugin_open(x) dlopen(x,RTLD_NOW|RTLD_DEEPBIND) + #define plugin_open(x) dlopen((x),RTLD_NOW|RTLD_DEEPBIND) #else // ! RTLD_DEEPBIND - #define plugin_open(x) dlopen(x,RTLD_NOW) + #define plugin_open(x) dlopen((x),RTLD_NOW) #endif // RTLD_DEEPBIND - #define plugin_import(x,y,z) (z)dlsym(x,y) - #define plugin_close(x) dlclose(x) + #define plugin_import(x,y,z) (z)dlsym((x),(y)) + #define plugin_close(x) dlclose(x) #ifdef CYGWIN - #define DLL_EXT ".dll" + #define DLL_EXT ".dll" #else - #define DLL_EXT ".so" + #define DLL_EXT ".so" #endif - #define DLL void * + #define DLL void * #include // size_t diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 940782dce..7637dc832 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -47,9 +47,9 @@ struct hplugin_info { HPExport void *(*import_symbol) (char *name, unsigned int pID); HPExport Sql *mysql_handle; -#define GET_SYMBOL(n) import_symbol(n,HPMi->pid) +#define GET_SYMBOL(n) import_symbol((n),HPMi->pid) -#define SERVER_TYPE_ALL SERVER_TYPE_LOGIN|SERVER_TYPE_CHAR|SERVER_TYPE_MAP +#define SERVER_TYPE_ALL (SERVER_TYPE_LOGIN|SERVER_TYPE_CHAR|SERVER_TYPE_MAP) enum hp_event_types { HPET_INIT,/* server starts */ @@ -83,27 +83,27 @@ enum HPluginDataTypes { HPDT_NPCD, }; -#define addHookPre(tname,hook) HPMi->AddHook(HOOK_TYPE_PRE,tname,hook,HPMi->pid) -#define addHookPost(tname,hook) HPMi->AddHook(HOOK_TYPE_POST,tname,hook,HPMi->pid) +#define addHookPre(tname,hook) (HPMi->AddHook(HOOK_TYPE_PRE,(tname),(hook),HPMi->pid)) +#define addHookPost(tname,hook) (HPMi->AddHook(HOOK_TYPE_POST,(tname),(hook),HPMi->pid)) /* need better names ;/ */ /* will not run the original function after pre-hook processing is complete (other hooks will run) */ -#define hookStop() HPMi->HookStop(__func__,HPMi->pid) -#define hookStopped() HPMi->HookStopped() +#define hookStop() (HPMi->HookStop(__func__,HPMi->pid)) +#define hookStopped() (HPMi->HookStopped()) -#define addArg(name,param,func,help) HPMi->addArg(HPMi->pid,name,param,func,help) +#define addArg(name,param,func,help) (HPMi->addArg(HPMi->pid,(name),(param),(func),(help))) /* HPData handy redirects */ /* session[] */ -#define addToSession(ptr,data,index,autofree) HPMi->addToHPData(HPDT_SESSION,HPMi->pid,ptr,data,index,autofree) -#define getFromSession(ptr,index) HPMi->getFromHPData(HPDT_SESSION,HPMi->pid,ptr,index) -#define removeFromSession(ptr,index) HPMi->removeFromHPData(HPDT_SESSION,HPMi->pid,ptr,index) +#define addToSession(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_SESSION,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromSession(ptr,index) (HPMi->getFromHPData(HPDT_SESSION,HPMi->pid,(ptr),(index))) +#define removeFromSession(ptr,index) (HPMi->removeFromHPData(HPDT_SESSION,HPMi->pid,(ptr),(index))) /* map_session_data */ -#define addToMSD(ptr,data,index,autofree) HPMi->addToHPData(HPDT_MSD,HPMi->pid,ptr,data,index,autofree) -#define getFromMSD(ptr,index) HPMi->getFromHPData(HPDT_MSD,HPMi->pid,ptr,index) -#define removeFromMSD(ptr,index) HPMi->removeFromHPData(HPDT_MSD,HPMi->pid,ptr,index) +#define addToMSD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MSD,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromMSD(ptr,index) (HPMi->getFromHPData(HPDT_MSD,HPMi->pid,(ptr),(index))) +#define removeFromMSD(ptr,index) (HPMi->removeFromHPData(HPDT_MSD,HPMi->pid,(ptr),(index))) /* npc_data */ -#define addToNPCD(ptr,data,index,autofree) HPMi->addToHPData(HPDT_NPCD,HPMi->pid,ptr,data,index,autofree) -#define getFromNPCD(ptr,index) HPMi->getFromHPData(HPDT_NPCD,HPMi->pid,ptr,index) -#define removeFromNPCD(ptr,index) HPMi->removeFromHPData(HPDT_NPCD,HPMi->pid,ptr,index) +#define addToNPCD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_NPCD,HPMi->pid,(ptr),(data),(index),(autofree))) +#define getFromNPCD(ptr,index) (HPMi->getFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index))) +#define removeFromNPCD(ptr,index) (HPMi->removeFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index))) /* Hercules Plugin Mananger Include Interface */ HPExport struct HPMi_interface { diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index d2a0a5dd9..6de2ace01 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -293,7 +293,9 @@ typedef char bool; // if using macros then something that is type independent //#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) // Avoid "value computed is not used" warning and generates the same assembly code -#define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b)) +//#define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b)) +// but is vulnerable to 'if (foo) swap(bar, baz); else quux();', causing the else to nest incorrectly. +#define swap(a,b) do { if ((a) != (b)) { (a) ^= (b); (b) ^= (a); (a) ^= (b); } } while(0) #if 0 //to be activated soon, more tests needed on how VS works with the macro above #ifdef WIN32 #undef swap @@ -313,7 +315,7 @@ typedef char bool; #endif #endif -#define swap_ptr(a,b) if ((a) != (b)) ((a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (b) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (a) = (void*)((intptr_t)(a) ^ (intptr_t)(b))) +#define swap_ptr(a,b) do { if ((a) != (b)) (a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)); (b) = (void*)((intptr_t)(a) ^ (intptr_t)(b)); (a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)); } while(0) #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -429,8 +431,8 @@ void SET_FUNCPOINTER(T1& var, T2 p) var = tmp.out; } #else -#define SET_POINTER(var,p) (var) = (p) -#define SET_FUNCPOINTER(var,p) (var) = (p) +#define SET_POINTER(var,p) ((var) = (p)) +#define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif diff --git a/src/common/console.c b/src/common/console.c index cb8ed5917..94824dc25 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -175,6 +175,10 @@ void console_load_defaults(void) { } } } +#undef CP_DEF_C +#undef CP_DEF_C2 +#undef CP_DEF_S +#undef CP_DEF void console_parse_create(char *name, CParseFunc func) { unsigned int i; char *tok; diff --git a/src/common/core.c b/src/common/core.c index a414a5d0b..dd839b372 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -53,7 +53,7 @@ char *SERVER_NAME = NULL; #endif #ifndef POSIX -#define compat_signal(signo, func) signal(signo, func) +#define compat_signal(signo, func) signal((signo), (func)) #else sigfunc *compat_signal(int signo, sigfunc *func) { struct sigaction sact, oact; diff --git a/src/common/db.c b/src/common/db.c index b3a58e0a4..c3ca7e0a4 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -315,7 +315,7 @@ static struct db_stats { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#define DB_COUNTSTAT(token) if (stats. ## token != UINT32_MAX) ++stats. ## token +#define DB_COUNTSTAT(token) do { if (stats. ## token != UINT32_MAX) ++stats. ## token ; } while(0) #else /* !defined(DB_ENABLE_STATS) */ #define DB_COUNTSTAT(token) #endif /* !defined(DB_ENABLE_STATS) */ diff --git a/src/common/db.h b/src/common/db.h index dffd2356d..b9d6af382 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -659,14 +659,14 @@ struct DBMap { #define stridb_alloc(opt,maxlen) DB->alloc(__FILE__,__func__,__LINE__,DB_ISTRING,(opt),(maxlen)) #define db_destroy(db) ( (db)->destroy((db),NULL) ) // Other macros -#define db_clear(db) ( (db)->clear(db,NULL) ) +#define db_clear(db) ( (db)->clear((db),NULL) ) #define db_size(db) ( (db)->size(db) ) #define db_iterator(db) ( (db)->iterator(db) ) -#define dbi_first(dbi) ( DB->data2ptr((dbi)->first(dbi,NULL)) ) -#define dbi_last(dbi) ( DB->data2ptr((dbi)->last(dbi,NULL)) ) -#define dbi_next(dbi) ( DB->data2ptr((dbi)->next(dbi,NULL)) ) -#define dbi_prev(dbi) ( DB->data2ptr((dbi)->prev(dbi,NULL)) ) -#define dbi_remove(dbi) ( (dbi)->remove(dbi,NULL) ) +#define dbi_first(dbi) ( DB->data2ptr((dbi)->first((dbi),NULL)) ) +#define dbi_last(dbi) ( DB->data2ptr((dbi)->last((dbi),NULL)) ) +#define dbi_next(dbi) ( DB->data2ptr((dbi)->next((dbi),NULL)) ) +#define dbi_prev(dbi) ( DB->data2ptr((dbi)->prev((dbi),NULL)) ) +#define dbi_remove(dbi) ( (dbi)->remove((dbi),NULL) ) #define dbi_exists(dbi) ( (dbi)->exists(dbi) ) #define dbi_destroy(dbi) ( (dbi)->destroy(dbi) ) diff --git a/src/common/ers.h b/src/common/ers.h index 51701d778..4ff2a6230 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -137,11 +137,11 @@ typedef struct eri { #else /* not DISABLE_ERS */ // These defines should be used to allow the code to keep working whenever // the system is disabled -# define ers_alloc(obj,type) (type *)(obj)->alloc(obj) -# define ers_free(obj,entry) (obj)->free((obj),(entry)) -# define ers_entry_size(obj) (obj)->entry_size(obj) -# define ers_destroy(obj) (obj)->destroy(obj) -# define ers_chunk_size(obj,size) (obj)->chunk_size(obj,size) +# define ers_alloc(obj,type) ((type *)(obj)->alloc(obj)) +# define ers_free(obj,entry) ((obj)->free((obj),(entry))) +# define ers_entry_size(obj) ((obj)->entry_size(obj)) +# define ers_destroy(obj) ((obj)->destroy(obj)) +# define ers_chunk_size(obj,size) ((obj)->chunk_size((obj),(size))) /** * Get a new instance of the manager that handles the specified entry size. diff --git a/src/common/grfio.h b/src/common/grfio.h index c5a56a14e..a88b20393 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -8,7 +8,7 @@ void grfio_init(const char* fname); void grfio_final(void); void* grfio_reads(const char* fname, int* size); char* grfio_find_file(const char* fname); -#define grfio_read(fn) grfio_reads(fn, NULL) +#define grfio_read(fn) grfio_reads((fn), NULL) unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); diff --git a/src/common/malloc.c b/src/common/malloc.c index 4d2c93b77..1cb7836ab 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -19,28 +19,28 @@ struct malloc_interface iMalloc_s; # include # include "memwatch.h" -# define MALLOC(n,file,line,func) mwMalloc((n),(file),(line)) -# define CALLOC(m,n,file,line,func) mwCalloc((m),(n),(file),(line)) -# define REALLOC(p,n,file,line,func) mwRealloc((p),(n),(file),(line)) -# define STRDUP(p,file,line,func) mwStrdup((p),(file),(line)) -# define FREE(p,file,line,func) mwFree((p),(file),(line)) -# define MEMORY_USAGE() 0 -# define MEMORY_VERIFY(ptr) mwIsSafeAddr(ptr, 1) -# define MEMORY_CHECK() CHECK() +# define MALLOC(n,file,line,func) mwMalloc((n),(file),(line)) +# define CALLOC(m,n,file,line,func) mwCalloc((m),(n),(file),(line)) +# define REALLOC(p,n,file,line,func) mwRealloc((p),(n),(file),(line)) +# define STRDUP(p,file,line,func) mwStrdup((p),(file),(line)) +# define FREE(p,file,line,func) mwFree((p),(file),(line)) +# define MEMORY_USAGE() (size_t)0 +# define MEMORY_VERIFY(ptr) mwIsSafeAddr((ptr), 1) +# define MEMORY_CHECK() CHECK() #elif defined(DMALLOC) # include # include # include "dmalloc.h" -# define MALLOC(n,file,line,func) dmalloc_malloc((file),(line),(n),DMALLOC_FUNC_MALLOC,0,0) -# define CALLOC(m,n,file,line,func) dmalloc_malloc((file),(line),(m)*(n),DMALLOC_FUNC_CALLOC,0,0) -# define REALLOC(p,n,file,line,func) dmalloc_realloc((file),(line),(p),(n),DMALLOC_FUNC_REALLOC,0) -# define STRDUP(p,file,line,func) strdup(p) -# define FREE(p,file,line,func) free(p) -# define MEMORY_USAGE() dmalloc_memory_allocated() -# define MEMORY_VERIFY(ptr) (dmalloc_verify(ptr) == DMALLOC_VERIFY_NOERROR) -# define MEMORY_CHECK() dmalloc_log_stats(); dmalloc_log_unfreed() +# define MALLOC(n,file,line,func) dmalloc_malloc((file),(line),(n),DMALLOC_FUNC_MALLOC,0,0) +# define CALLOC(m,n,file,line,func) dmalloc_malloc((file),(line),(m)*(n),DMALLOC_FUNC_CALLOC,0,0) +# define REALLOC(p,n,file,line,func) dmalloc_realloc((file),(line),(p),(n),DMALLOC_FUNC_REALLOC,0) +# define STRDUP(p,file,line,func) strdup(p) +# define FREE(p,file,line,func) free(p) +# define MEMORY_USAGE() dmalloc_memory_allocated() +# define MEMORY_VERIFY(ptr) (dmalloc_verify(ptr) == DMALLOC_VERIFY_NOERROR) +# define MEMORY_CHECK() do { dmalloc_log_stats(); dmalloc_log_unfreed() } while(0) #elif defined(GCOLLECT) @@ -50,24 +50,26 @@ struct malloc_interface iMalloc_s; # else # define RETURN_ADDR # endif -# define MALLOC(n,file,line,func) GC_debug_malloc((n), RETURN_ADDR (file),(line)) -# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), RETURN_ADDR (file),(line)) -# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), RETURN_ADDR (file),(line)) -# define STRDUP(p,file,line,func) GC_debug_strdup((p), RETURN_ADDR (file),(line)) -# define FREE(p,file,line,func) GC_debug_free(p) -# define MEMORY_USAGE() GC_get_heap_size() -# define MEMORY_VERIFY(ptr) (GC_base(ptr) != NULL) -# define MEMORY_CHECK() GC_gcollect() +# define MALLOC(n,file,line,func) GC_debug_malloc((n), RETURN_ADDR (file),(line)) +# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), RETURN_ADDR (file),(line)) +# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), RETURN_ADDR (file),(line)) +# define STRDUP(p,file,line,func) GC_debug_strdup((p), RETURN_ADDR (file),(line)) +# define FREE(p,file,line,func) GC_debug_free(p) +# define MEMORY_USAGE() GC_get_heap_size() +# define MEMORY_VERIFY(ptr) (GC_base(ptr) != NULL) +# define MEMORY_CHECK() GC_gcollect() + +# undef RETURN_ADDR #else -# define MALLOC(n,file,line,func) malloc(n) -# define CALLOC(m,n,file,line,func) calloc((m),(n)) -# define REALLOC(p,n,file,line,func) realloc((p),(n)) -# define STRDUP(p,file,line,func) strdup(p) -# define FREE(p,file,line,func) free(p) -# define MEMORY_USAGE() 0 -# define MEMORY_VERIFY(ptr) true +# define MALLOC(n,file,line,func) malloc(n) +# define CALLOC(m,n,file,line,func) calloc((m),(n)) +# define REALLOC(p,n,file,line,func) realloc((p),(n)) +# define STRDUP(p,file,line,func) strdup(p) +# define FREE(p,file,line,func) free(p) +# define MEMORY_USAGE() (size_t)0 +# define MEMORY_VERIFY(ptr) true # define MEMORY_CHECK() #endif diff --git a/src/common/malloc.h b/src/common/malloc.h index bc8aa9a20..cd0ef238b 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -30,11 +30,11 @@ #undef LOG_MEMMGR #endif -# define aMalloc(n) iMalloc->malloc (n,ALC_MARK) -# define aCalloc(m,n) iMalloc->calloc (m,n,ALC_MARK) -# define aRealloc(p,n) iMalloc->realloc (p,n,ALC_MARK) -# define aStrdup(p) iMalloc->astrdup (p,ALC_MARK) -# define aFree(p) iMalloc->free (p,ALC_MARK) +# define aMalloc(n) (iMalloc->malloc((n),ALC_MARK)) +# define aCalloc(m,n) (iMalloc->calloc((m),(n),ALC_MARK)) +# define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK)) +# define aStrdup(p) (iMalloc->astrdup((p),ALC_MARK)) +# define aFree(p) (iMalloc->free((p),ALC_MARK)) /////////////// Buffer Creation ///////////////// // Full credit for this goes to Shinomori [Ajarn] @@ -46,15 +46,15 @@ #else // others don't, so we emulate them -#define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc (size, sizeof(type)) +#define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc((size), sizeof(type)) #define DELETE_BUFFER(name) aFree(name) #endif ////////////// Others ////////////////////////// // should be merged with any of above later -#define CREATE(result, type, number) (result) = (type *) aCalloc ((number), sizeof(type)) -#define RECREATE(result, type, number) (result) = (type *) aRealloc ((result), sizeof(type) * (number)) +#define CREATE(result, type, number) ((result) = (type *) aCalloc((number), sizeof(type))) +#define RECREATE(result, type, number) ((result) = (type *) aRealloc((result), sizeof(type) * (number))) //////////////////////////////////////////////// diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 646f73f18..cf5486808 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -60,7 +60,7 @@ bool mapindex_exists(int id); const char* mapindex_getmapname(const char* string, char* output); const char* mapindex_getmapname_ext(const char* string, char* output); unsigned short mapindex_name2id(const char*); -#define mapindex_id2name(n) mapindex_id2name_sub(n,__FILE__, __LINE__, __func__) +#define mapindex_id2name(n) mapindex_id2name_sub((n),__FILE__, __LINE__, __func__) const char* mapindex_id2name_sub(unsigned short,const char *file, int line, const char *func); int mapindex_init(void); void mapindex_final(void); diff --git a/src/common/mempool.c b/src/common/mempool.c index 5eccbf178..4559d8f2a 100644 --- a/src/common/mempool.c +++ b/src/common/mempool.c @@ -30,16 +30,16 @@ #include "../common/malloc.h" #include "../common/mutex.h" -#define ALIGN16 ra_align(16) -#define ALIGN_TO(x, a) (x + ( a - ( x % a) ) ) -#define ALIGN_TO_16(x) ALIGN_TO(x, 16) +#define ALIGN16 ra_align(16) +#define ALIGN_TO(x, a) ((x) + ( (a) - ( (x) % (a)) ) ) +#define ALIGN_TO_16(x) ALIGN_TO((x), 16) #undef MEMPOOL_DEBUG #define MEMPOOLASSERT -#define NODE_TO_DATA(x) ( ((char*)x) + sizeof(struct node) ) -#define DATA_TO_NODE(x) ( (struct node*)(((char*)x) - sizeof(struct node)) ) +#define NODE_TO_DATA(x) ( ((char*)(x)) + sizeof(struct node) ) +#define DATA_TO_NODE(x) ( (struct node*)(((char*)(x)) - sizeof(struct node)) ) struct ra_align(16) node{ void *next; void *segment; diff --git a/src/common/mmo.h b/src/common/mmo.h index 309203aa8..5816b467c 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -112,7 +112,7 @@ #define MAX_STORAGE 600 #define MAX_GUILD_STORAGE 600 #define MAX_PARTY 12 -#define MAX_GUILD 16+10*6 // Increased max guild members +6 per 1 extension levels [Lupus] +#define MAX_GUILD (16+10*6) // Increased max guild members +6 per 1 extension levels [Lupus] #define MAX_GUILDPOSITION 20 // Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] #define MAX_GUILDEXPULSION 32 #define MAX_GUILDALLIANCE 16 diff --git a/src/common/netbuffer.h b/src/common/netbuffer.h index 844241226..6ddecfdd9 100644 --- a/src/common/netbuffer.h +++ b/src/common/netbuffer.h @@ -73,11 +73,9 @@ void netbuffer_incref( netbuf buf ); // Some Useful macros -#define NBUFP(netbuf,pos) (((uint8*)(netbuf->buf)) + (pos)) -#define NBUFB(netbuf,pos) (*(uint8*)((netbuf->buf) + (pos))) -#define NBUFW(netbuf,pos) (*(uint16*)((netbuf->buf) + (pos))) -#define NBUFL(netbuf,pos) (*(uint32*)((netbuf->buf) + (pos))) - - +#define NBUFP(netbuf,pos) (((uint8*)((netbuf)->buf)) + (pos)) +#define NBUFB(netbuf,pos) (*(uint8*)(((netbuf)->buf) + (pos))) +#define NBUFW(netbuf,pos) (*(uint16*)(((netbuf)->buf) + (pos))) +#define NBUFL(netbuf,pos) (*(uint32*)(((netbuf)->buf) + (pos))) #endif diff --git a/src/common/network.c b/src/common/network.c index 1f1621363..a40cbd602 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -50,7 +50,7 @@ SESSION g_Session[MAXCONN]; static bool onSend(int32 fd); -#define _network_free_netbuf_async( buf ) add_timer( 0, _network_async_free_netbuf_proc, 0, (intptr_t) buf) +#define _network_free_netbuf_async( buf ) add_timer( 0, _network_async_free_netbuf_proc, 0, (intptr_t)(buf)) static int _network_async_free_netbuf_proc(int tid, unsigned int tick, int id, intptr_t data){ // netbuf is in data netbuffer_put( (netbuf)data ); diff --git a/src/common/raconf.c b/src/common/raconf.c index f7d1284b7..abeed444b 100644 --- a/src/common/raconf.c +++ b/src/common/raconf.c @@ -382,21 +382,20 @@ static bool configParse(raconf inst, const char *fileName){ }//end: configParse() -#define MAKEKEY(dest, section, key) { size_t section_len, key_len; \ - if(section == NULL || *section == '\0'){ \ - strncpy(dest, "", 9); \ - section_len = 9; \ - }else{ \ - section_len = strlen(section); \ - strncpy(dest, section, section_len); \ - } \ - \ - dest[section_len] = '.'; \ - \ - key_len = strlen(key); \ - strncpy(&dest[section_len+1], key, key_len); \ - dest[section_len + key_len + 1] = '\0'; \ - } +#define MAKEKEY(dest, section, key) do { \ + size_t section_len_, key_len_; \ + if((section) == NULL || *(section) == '\0'){ \ + strncpy((dest), "", 9); \ + section_len_ = 9; \ + } else { \ + section_len_ = strlen(section); \ + strncpy((dest), (section), section_len_); \ + } \ + (dest)[section_len_] = '.'; \ + key_len_ = strlen(key); \ + strncpy(&(dest)[section_len_+1], (key), key_len_); \ + (dest)[section_len_ + key_len_ + 1] = '\0'; \ +} while(0) raconf raconf_parse(const char *file_name){ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 9e0f63003..14342fe5e 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -16,33 +16,17 @@ #include "../../3rdparty/libconfig/libconfig.h" #ifdef WIN32 - #include "../common/winapi.h" - - #ifdef DEBUGLOGMAP - #define DEBUGLOGPATH "log\\map-server.log" - #else - #ifdef DEBUGLOGCHAR - #define DEBUGLOGPATH "log\\char-server.log" - #else - #ifdef DEBUGLOGLOGIN - #define DEBUGLOGPATH "log\\login-server.log" - #endif - #endif - #endif -#else - #include - - #ifdef DEBUGLOGMAP - #define DEBUGLOGPATH "log/map-server.log" - #else - #ifdef DEBUGLOGCHAR - #define DEBUGLOGPATH "log/char-server.log" - #else - #ifdef DEBUGLOGLOGIN - #define DEBUGLOGPATH "log/login-server.log" - #endif - #endif - #endif +#include "../common/winapi.h" +#else // not WIN32 +#include +#endif // WIN32 + +#if defined(DEBUGLOGMAP) +#define DEBUGLOGPATH "log"PATHSEP_STR"map-server.log" +#elif defined(DEBUGLOGCHAR) +#define DEBUGLOGPATH "log"PATHSEP_STR"char-server.log" +#elif defined(DEBUGLOGLOGIN) +#define DEBUGLOGPATH "log"PATHSEP_STR"login-server.log" #endif /////////////////////////////////////////////////////////////////////////////// @@ -61,41 +45,40 @@ int console_msg_log = 0;//[Ind] msg error logging #define SBUF_SIZE 2054 // never put less that what's required for the debug message -#define NEWBUF(buf) \ - struct { \ - char s_[SBUF_SIZE]; \ - StringBuf *d_; \ - char *v_; \ - int l_; \ - } buf ={"",NULL,NULL,0}; \ +#define NEWBUF(buf) \ + struct { \ + char s_[SBUF_SIZE]; \ + StringBuf *d_; \ + char *v_; \ + int l_; \ + } buf ={"",NULL,NULL,0}; \ //define NEWBUF -#define BUFVPRINTF(buf,fmt,args) \ - buf.l_ = vsnprintf(buf.s_, SBUF_SIZE, fmt, args); \ - if( buf.l_ >= 0 && buf.l_ < SBUF_SIZE ) \ - {/* static buffer */ \ - buf.v_ = buf.s_; \ - } \ - else \ - {/* dynamic buffer */ \ - buf.d_ = StrBuf->Malloc(); \ - buf.l_ = StrBuf->Vprintf(buf.d_, fmt, args); \ - buf.v_ = StrBuf->Value(buf.d_); \ - ShowDebug("showmsg: dynamic buffer used, increase the static buffer size to %d or more.\n", buf.l_+1);\ - } \ -//define BUFVPRINTF - -#define BUFVAL(buf) buf.v_ -#define BUFLEN(buf) buf.l_ - -#define FREEBUF(buf) \ - if( buf.d_ ) \ - { \ - StrBuf->Free(buf.d_); \ - buf.d_ = NULL; \ - } \ - buf.v_ = NULL; \ -//define FREEBUF +#define BUFVPRINTF(buf,fmt,args) do { \ + (buf).l_ = vsnprintf((buf).s_, SBUF_SIZE, (fmt), args); \ + if( (buf).l_ >= 0 && (buf).l_ < SBUF_SIZE ) \ + {/* static buffer */ \ + (buf).v_ = (buf).s_; \ + } \ + else \ + {/* dynamic buffer */ \ + (buf).d_ = StrBuf->Malloc(); \ + (buf).l_ = StrBuf->Vprintf((buf).d_, (fmt), args); \ + (buf).v_ = StrBuf->Value((buf).d_); \ + ShowDebug("showmsg: dynamic buffer used, increase the static buffer size to %d or more.\n", (buf).l_+1); \ + } \ +} while(0) //define BUFVPRINTF + +#define BUFVAL(buf) ((buf).v_) +#define BUFLEN(buf) ((buf).l_) + +#define FREEBUF(buf) do {\ + if( (buf).d_ ) { \ + StrBuf->Free((buf).d_); \ + (buf).d_ = NULL; \ + } \ + (buf).v_ = NULL; \ +} while(0) //define FREEBUF /////////////////////////////////////////////////////////////////////////////// #ifdef _WIN32 @@ -666,14 +649,6 @@ int FPRINTF(FILE *file, const char *fmt, ...) #endif// not _WIN32 - - - - - - - - char timestamp_format[20] = ""; //For displaying Timestamps int _vShowMessage(enum msg_type flag, const char *string, va_list ap) diff --git a/src/common/socket.c b/src/common/socket.c index 6e877d9be..2ae9d44b3 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -157,19 +157,19 @@ char* sErr(int code) return sbuf; } -#define sBind(fd,name,namelen) bind(fd2sock(fd),name,namelen) -#define sConnect(fd,name,namelen) connect(fd2sock(fd),name,namelen) -#define sIoctl(fd,cmd,argp) ioctlsocket(fd2sock(fd),cmd,argp) -#define sListen(fd,backlog) listen(fd2sock(fd),backlog) -#define sRecv(fd,buf,len,flags) recv(fd2sock(fd),buf,len,flags) -#define sSelect select -#define sSend(fd,buf,len,flags) send(fd2sock(fd),buf,len,flags) -#define sSetsockopt(fd,level,optname,optval,optlen) setsockopt(fd2sock(fd),level,optname,optval,optlen) -#define sShutdown(fd,how) shutdown(fd2sock(fd),how) -#define sFD_SET(fd,set) FD_SET(fd2sock(fd),set) -#define sFD_CLR(fd,set) FD_CLR(fd2sock(fd),set) -#define sFD_ISSET(fd,set) FD_ISSET(fd2sock(fd),set) -#define sFD_ZERO FD_ZERO +#define sBind(fd,name,namelen) bind(fd2sock(fd),(name),(namelen)) +#define sConnect(fd,name,namelen) connect(fd2sock(fd),(name),(namelen)) +#define sIoctl(fd,cmd,argp) ioctlsocket(fd2sock(fd),(cmd),(argp)) +#define sListen(fd,backlog) listen(fd2sock(fd),(backlog)) +#define sRecv(fd,buf,len,flags) recv(fd2sock(fd),(buf),(len),(flags)) +#define sSelect select +#define sSend(fd,buf,len,flags) send(fd2sock(fd),(buf),(len),(flags)) +#define sSetsockopt(fd,level,optname,optval,optlen) setsockopt(fd2sock(fd),(level),(optname),(optval),(optlen)) +#define sShutdown(fd,how) shutdown(fd2sock(fd),(how)) +#define sFD_SET(fd,set) FD_SET(fd2sock(fd),(set)) +#define sFD_CLR(fd,set) FD_CLR(fd2sock(fd),(set)) +#define sFD_ISSET(fd,set) FD_ISSET(fd2sock(fd),(set)) +#define sFD_ZERO FD_ZERO ///////////////////////////////////////////////////////////////////// #else diff --git a/src/common/socket.h b/src/common/socket.h index 923fa2515..02817f653 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -24,18 +24,18 @@ struct HPluginData; // socket I/O macros #define RFIFOHEAD(fd) -#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0) +#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo((fd), (size)); }while(0) #define RFIFOP(fd,pos) (session[fd]->rdata + session[fd]->rdata_pos + (pos)) #define WFIFOP(fd,pos) (session[fd]->wdata + session[fd]->wdata_size + (pos)) -#define RFIFOB(fd,pos) (*(uint8*)RFIFOP(fd,pos)) -#define WFIFOB(fd,pos) (*(uint8*)WFIFOP(fd,pos)) -#define RFIFOW(fd,pos) (*(uint16*)RFIFOP(fd,pos)) -#define WFIFOW(fd,pos) (*(uint16*)WFIFOP(fd,pos)) -#define RFIFOL(fd,pos) (*(uint32*)RFIFOP(fd,pos)) -#define WFIFOL(fd,pos) (*(uint32*)WFIFOP(fd,pos)) -#define RFIFOQ(fd,pos) (*(uint64*)RFIFOP(fd,pos)) -#define WFIFOQ(fd,pos) (*(uint64*)WFIFOP(fd,pos)) +#define RFIFOB(fd,pos) (*(uint8*)RFIFOP((fd),(pos))) +#define WFIFOB(fd,pos) (*(uint8*)WFIFOP((fd),(pos))) +#define RFIFOW(fd,pos) (*(uint16*)RFIFOP((fd),(pos))) +#define WFIFOW(fd,pos) (*(uint16*)WFIFOP((fd),(pos))) +#define RFIFOL(fd,pos) (*(uint32*)RFIFOP((fd),(pos))) +#define WFIFOL(fd,pos) (*(uint32*)WFIFOP((fd),(pos))) +#define RFIFOQ(fd,pos) (*(uint64*)RFIFOP((fd),(pos))) +#define WFIFOQ(fd,pos) (*(uint64*)WFIFOP((fd),(pos))) #define RFIFOSPACE(fd) (session[fd]->max_rdata - session[fd]->rdata_size) #define WFIFOSPACE(fd) (session[fd]->max_wdata - session[fd]->wdata_size) @@ -146,8 +146,9 @@ void set_defaultparse(ParseFunc defaultparse); uint32 host2ip(const char* hostname); const char* ip2str(uint32 ip, char ip_str[16]); uint32 str2ip(const char* ip_str); +// Note: purposely returns four comma-separated arguments #define CONVIP(ip) ((ip)>>24)&0xFF,((ip)>>16)&0xFF,((ip)>>8)&0xFF,((ip)>>0)&0xFF -#define MAKEIP(a,b,c,d) (uint32)( ( ( (a)&0xFF ) << 24 ) | ( ( (b)&0xFF ) << 16 ) | ( ( (c)&0xFF ) << 8 ) | ( ( (d)&0xFF ) << 0 ) ) +#define MAKEIP(a,b,c,d) ((uint32)( ( ( (a)&0xFF ) << 24 ) | ( ( (b)&0xFF ) << 16 ) | ( ( (c)&0xFF ) << 8 ) | ( ( (d)&0xFF ) << 0 ) )) uint16 ntows(uint16 netshort); int socket_getips(uint32* ips, int max); diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 3419bfdd5..9b9e4ce94 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -52,8 +52,8 @@ static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){ } -#define getsynclock(l) { while(1){ if(InterlockedCompareExchange(l, 1, 0) == 0) break; rathread_yield(); } } -#define dropsynclock(l) { InterlockedExchange(l, 0); } +#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; rathread_yield(); } while(/*always*/1) +#define dropsynclock(l) do { InterlockedExchange((l), 0); } while(0) static forceinline void EnterSpinLock(PSPIN_LOCK lck){ int tid = rathread_get_tid(); diff --git a/src/common/sql.h b/src/common/sql.h index da00edf2d..1fb436853 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -11,7 +11,7 @@ // Return codes -#define SQL_ERROR -1 +#define SQL_ERROR (-1) #define SQL_SUCCESS 0 #define SQL_NO_DATA 100 @@ -277,7 +277,7 @@ void sql_defaults(void); #if defined(SQL_REMOVE_SHOWDEBUG) #define Sql_ShowDebug(self) (void)0 #else -#define Sql_ShowDebug(self) SQL->ShowDebug_(self, __FILE__, __LINE__) +#define Sql_ShowDebug(self) (SQL->ShowDebug_((self), __FILE__, __LINE__)) #endif void Sql_HerculesUpdateCheck(Sql* self); @@ -286,16 +286,10 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename); #if defined(SQL_REMOVE_SHOWDEBUG) #define SqlStmt_ShowDebug(self) (void)0 #else -#define SqlStmt_ShowDebug(self) SQL->StmtShowDebug_(self, __FILE__, __LINE__) -#endif /// Shows debug information (with statement). - - - - - +#define SqlStmt_ShowDebug(self) (SQL->StmtShowDebug_((self), __FILE__, __LINE__)) +#endif void Sql_Init(void); - #endif /* _COMMON_SQL_H_ */ diff --git a/src/common/strlib.h b/src/common/strlib.h index 5ef455a0e..0c3b0a486 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -168,28 +168,28 @@ void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ #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) - #define remove_control_chars(str) strlib->remove_control_chars(str) - #define trim(str) strlib->trim(str) - #define normalize_name(str,delims) strlib->normalize_name(str,delims) - #define stristr(haystack,needle) strlib->stristr(haystack,needle) + #define jstrescape(pt) (strlib->jstrescape(pt)) + #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) + #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) + #define remove_control_chars(str) (strlib->remove_control_chars(str)) + #define trim(str) (strlib->trim(str)) + #define normalize_name(str,delims) (strlib->normalize_name((str),(delims))) + #define stristr(haystack,needle) (strlib->stristr((haystack),(needle))) #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) - #define strnln(string,maxlen) strlib->strnlen(string,maxlen) + #define strnln(string,maxlen) (strlib->strnlen((string),(maxlen))) #endif #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 - #define strtoull(str,endptr,base) strlib->strtoull(str,endptr,base) + #define strtoull(str,endptr,base) (strlib->strtoull((str),(endptr),(base))) #endif - #define e_mail_check(email) strlib->e_mail_check(email) - #define config_switch(str) strlib->config_switch(str) - #define safestrncpy(dst,src,n) strlib->safestrncpy(dst,src,n) - #define safestrnlen(string,maxlen) strlib->safestrnlen(string,maxlen) - #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) + #define e_mail_check(email) (strlib->e_mail_check(email)) + #define config_switch(str) (strlib->config_switch(str)) + #define safestrncpy(dst,src,n) (strlib->safestrncpy((dst),(src),(n))) + #define safestrnlen(string,maxlen) (strlib->safestrnlen((string),(maxlen))) + #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 /* _STRLIB_H_ */ diff --git a/src/common/timer.h b/src/common/timer.h index 4a2bebe7d..9aa29861e 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -8,7 +8,7 @@ #define DIFF_TICK(a,b) ((a)-(b)) #define DIFF_TICK32(a,b) ((int32)((a)-(b))) -#define INVALID_TIMER -1 +#define INVALID_TIMER (-1) // timer flags enum { diff --git a/src/common/utils.h b/src/common/utils.h index 3e1463d6b..719e1e533 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -20,7 +20,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)); bool exists(const char* filename); //Caps values to min/max -#define cap_value(a, min, max) ((a >= max) ? max : (a <= min) ? min : a) +#define cap_value(a, min, max) (((a) >= (max)) ? (max) : ((a) <= (min)) ? (min) : (a)) /// calculates the value of A / B, in percent (rounded down) unsigned int get_percentage(const unsigned int A, const unsigned int B); diff --git a/src/config/const.h b/src/config/const.h index 6f0dc6311..fc82d66f9 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -114,13 +114,6 @@ #undef CONSOLE_INPUT #endif -#ifdef RENEWAL - #define ITEMDB_SQL_COLUMNS 24 -#else - #define ITEMDB_SQL_COLUMNS 22 -#endif - - /** * End of File **/ diff --git a/src/login/login.h b/src/login/login.h index 0a41b803f..15edb14dc 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -89,8 +89,8 @@ struct Login_Config { struct client_hash_node *client_hash_nodes; // linked list containg md5 hash for each gm group }; -#define sex_num2str(num) ( (num == SEX_FEMALE ) ? 'F' : (num == SEX_MALE ) ? 'M' : 'S' ) -#define sex_str2num(str) ( (str == 'F' ) ? SEX_FEMALE : (str == 'M' ) ? SEX_MALE : SEX_SERVER ) +#define sex_num2str(num) ( ((num) == SEX_FEMALE) ? 'F' : ((num) == SEX_MALE) ? 'M' : 'S' ) +#define sex_str2num(str) ( ((str) == 'F') ? SEX_FEMALE : ((str) == 'M') ? SEX_MALE : SEX_SERVER ) #define MAX_SERVERS 30 extern struct mmo_char_server server[MAX_SERVERS]; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4a471fe5d..3b06140d4 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -164,38 +164,32 @@ ACMD(send) clif->message(fd, msg_txt(i)); return false; } - -#define PARSE_ERROR(error,p) \ -{\ -clif->message(fd, (error));\ -sprintf(atcmd_output, ">%s", (p));\ -clif->message(fd, atcmd_output);\ -} - //define PARSE_ERROR - -#define CHECK_EOS(p) \ -if(*(p) == 0){\ -clif->message(fd, "Unexpected end of string");\ -return false;\ -} - //define CHECK_EOS - -#define SKIP_VALUE(p) \ -{\ -while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\ -while(*(p) && ISSPACE(*(p))) ++(p); /* space */\ -} - //define SKIP_VALUE - -#define GET_VALUE(p,num) \ -{\ -if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\ -PARSE_ERROR("Invalid number in:",(p));\ -return false;\ -}\ -} - //define GET_VALUE - + +#define PARSE_ERROR(error,p) do {\ + clif->message(fd, (error));\ + sprintf(atcmd_output, ">%s", (p));\ + clif->message(fd, atcmd_output);\ +} while(0) //define PARSE_ERROR + +#define CHECK_EOS(p) do { \ + if(*(p) == 0){ \ + clif->message(fd, "Unexpected end of string");\ + return false;\ + } \ +} while(0) //define CHECK_EOS + +#define SKIP_VALUE(p) do { \ + while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\ + while(*(p) && ISSPACE(*(p))) ++(p); /* space */\ +} while(0) //define SKIP_VALUE + +#define GET_VALUE(p,num) do { \ + if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\ + PARSE_ERROR("Invalid number in:",(p));\ + return false;\ + }\ +} while(0) //define GET_VALUE + if (type > 0 && type < MAX_PACKET_DB) { if(len) @@ -8585,10 +8579,11 @@ ACMD(unloadnpcfile) { return true; } ACMD(cart) { -#define MC_CART_MDFY(x,idx) \ -sd->status.skill[idx].id = x?MC_PUSHCART:0; \ -sd->status.skill[idx].lv = x?1:0; \ -sd->status.skill[idx].flag = x?1:0; +#define MC_CART_MDFY(x,idx) do { \ + sd->status.skill[idx].id = (x)?MC_PUSHCART:0; \ + sd->status.skill[idx].lv = (x)?1:0; \ + sd->status.skill[idx].flag = (x)?1:0; \ +} while(0) int val = atoi(message); bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true; @@ -9616,6 +9611,8 @@ void atcommand_basecommands(void) { return; } +#undef ACMD_DEF +#undef ACMD_DEF2 bool atcommand_add(char *name,AtCommandFunc func, bool replace) { AtCommandInfo* cmd; diff --git a/src/map/battle.c b/src/map/battle.c index cd8c36b69..78f54733c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3189,7 +3189,7 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) { return 0; } //For quick div adjustment. -#define damage_div_fix(dmg, div) { if (div > 1) (dmg)*=div; else if (div < 0) (div)*=-1; } +#define damage_div_fix(dmg, div) do { if ((div) > 1) (dmg)*=(div); else if ((div) < 0) (div)*=-1; } while(0) /*========================================== * battle_calc_magic_attack [DracoRPG] *------------------------------------------*/ @@ -3305,11 +3305,11 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage = 0; //reinitialize.. #endif //MATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc -#define MATK_RATE( a ) { ad.damage= ad.damage*(a)/100; } +#define MATK_RATE( a ) ( ad.damage= ad.damage*(a)/100 ) //Adds dmg%. 100 = +100% (double) damage. 10 = +10% damage -#define MATK_ADDRATE( a ) { ad.damage+= ad.damage*(a)/100; } +#define MATK_ADDRATE( a ) ( ad.damage+= ad.damage*(a)/100 ) //Adds an absolute value to damage. 100 = +100 damage -#define MATK_ADD( a ) { ad.damage+= a; } +#define MATK_ADD( a ) ( ad.damage+= (a) ) switch (skill_id) { //Calc base damage according to skill @@ -3499,6 +3499,9 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } return ad; +#undef MATK_RATE +#undef MATK_ADDRATE +#undef MATK_ADD } /*========================================== @@ -4359,19 +4362,19 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list //Assuming that 99% of the cases we will not need to check for the flag.rh... we don't. //ATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc -#define ATK_RATE( a ) { wd.damage= wd.damage*(a)/100 ; if(flag.lh) wd.damage2= wd.damage2*(a)/100; } -#define ATK_RATE2( a , b ) { wd.damage= wd.damage*(a)/100 ; if(flag.lh) wd.damage2= wd.damage2*(b)/100; } -#define ATK_RATER(a){ wd.damage = wd.damage*(a)/100;} -#define ATK_RATEL(a){ wd.damage2 = wd.damage2*(a)/100;} +#define ATK_RATE( a ) do { int64 temp__ = (a); wd.damage= wd.damage*temp__/100 ; if(flag.lh) wd.damage2= wd.damage2*temp__/100; } while(0) +#define ATK_RATE2( a , b ) do { wd.damage= wd.damage*(a)/100 ; if(flag.lh) wd.damage2= wd.damage2*(b)/100; } while(0) +#define ATK_RATER(a) ( wd.damage = wd.damage*(a)/100 ) +#define ATK_RATEL(a) ( wd.damage2 = wd.damage2*(a)/100 ) //Adds dmg%. 100 = +100% (double) damage. 10 = +10% damage -#define ATK_ADDRATE( a ) { wd.damage+= wd.damage*(a)/100 ; if(flag.lh) wd.damage2+= wd.damage2*(a)/100; } -#define ATK_ADDRATE2( a , b ) { wd.damage+= wd.damage*(a)/100 ; if(flag.lh) wd.damage2+= wd.damage2*(b)/100; } +#define ATK_ADDRATE( a ) do { int64 temp__ = (a); wd.damage+= wd.damage*temp__/100; if(flag.lh) wd.damage2+= wd.damage2*temp__/100; } while(0) +#define ATK_ADDRATE2( a , b ) do { wd.damage+= wd.damage*(a)/100 ; if(flag.lh) wd.damage2+= wd.damage2*(b)/100; } while(0) //Adds an absolute value to damage. 100 = +100 damage -#define ATK_ADD( a ) { wd.damage+= a; if (flag.lh) wd.damage2+= a; } -#define ATK_ADD2( a , b ) { wd.damage+= a; if (flag.lh) wd.damage2+= b; } +#define ATK_ADD( a ) do { int64 temp__ = (a); wd.damage += temp__; if (flag.lh) wd.damage2 += temp__; } while(0) +#define ATK_ADD2( a , b ) do { wd.damage += (a); if (flag.lh) wd.damage2 += (b); } while(0) #ifdef RENEWAL -#define GET_NORMAL_ATTACK( f ) { wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, f, wd.flag); } -#define GET_NORMAL_ATTACK2( f ) { wd.damage2 = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, f, wd.flag); } +#define GET_NORMAL_ATTACK( f ) ( wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (f), wd.flag) ) +#define GET_NORMAL_ATTACK2( f ) ( wd.damage2 = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, (f), wd.flag) ) #endif switch (skill_id) { //Calc base damage according to skill @@ -5070,7 +5073,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list )) && rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 ) { - ATK_RATER(50) + ATK_RATER(50); status_fix_damage(target,src,wd.damage,clif->damage(target,src,timer->gettick(),0,0,wd.damage,0,0,0)); clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1); if( --(tsc->data[SC_SWORDREJECT]->val3) <= 0 ) @@ -5147,9 +5150,9 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i sc = status->get_sc(bl); #ifdef RENEWAL -#define NORMALIZE_RDAMAGE(d){ trdamage += rdamage = max(1, min(max_reflect_damage, d)); } +#define NORMALIZE_RDAMAGE(d) ( trdamage += rdamage = max(1, min(max_reflect_damage, (d))) ) #else -#define NORMALIZE_RDAMAGE(d){ trdamage += rdamage = max(1, d); } +#define NORMALIZE_RDAMAGE(d) ( trdamage += rdamage = max(1, (d)) ) #endif if( sc && sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){ @@ -5214,6 +5217,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i } return max(0, trdamage); +#undef NORMALIZE_RDAMAGE } void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss) @@ -5468,7 +5472,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if( sc && sc->count ) { if (sc->data[SC_EXEEDBREAK]) { - ATK_RATER(sc->data[SC_EXEEDBREAK]->val1) + ATK_RATER(sc->data[SC_EXEEDBREAK]->val1); status_change_end(src, SC_EXEEDBREAK, INVALID_TIMER); } if( sc->data[SC_SPELLFIST] ) { @@ -5670,6 +5674,16 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t map->freeblock_unlock(); return wd.dmg_lv; } +#undef ATK_RATE +#undef ATK_RATE2 +#undef ATK_RATER +#undef ATK_RATEL +#undef ATK_ADDRATE +#undef ATK_ADDRATE2 +#undef ATK_ADD +#undef ATK_ADD2 +#undef GET_NORMAL_ATTACK +#undef GET_NORMAL_ATTACK2 int battle_check_undead(int race,int element) { diff --git a/src/map/battle.h b/src/map/battle.h index fd6699f4d..a8b291818 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -21,14 +21,14 @@ struct status_data; /** * Defines **/ -#define MIN_HAIR_STYLE battle_config.min_hair_style -#define MAX_HAIR_STYLE battle_config.max_hair_style -#define MIN_HAIR_COLOR battle_config.min_hair_color -#define MAX_HAIR_COLOR battle_config.max_hair_color -#define MIN_CLOTH_COLOR battle_config.min_cloth_color -#define MAX_CLOTH_COLOR battle_config.max_cloth_color +#define MIN_HAIR_STYLE (battle_config.min_hair_style) +#define MAX_HAIR_STYLE (battle_config.max_hair_style) +#define MIN_HAIR_COLOR (battle_config.min_hair_color) +#define MAX_HAIR_COLOR (battle_config.max_hair_color) +#define MIN_CLOTH_COLOR (battle_config.min_cloth_color) +#define MAX_CLOTH_COLOR (battle_config.max_cloth_color) -#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] +#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] /** * Enumerations diff --git a/src/map/chrif.c b/src/map/chrif.c index 5927e31bf..e9c3bbabf 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -88,7 +88,7 @@ struct chrif_interface chrif_s; //2b27: Incoming, chrif_authfail -> 'client authentication failed' //This define should spare writing the check in every function. [Skotlex] -#define chrif_check(a) { if(!chrif->isconnected()) return a; } +#define chrif_check(a) do { if(!chrif->isconnected()) return a; } while(0) /// Resets all the data. void chrif_reset(void) { diff --git a/src/map/clif.c b/src/map/clif.c index 84976d67c..913f55784 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18201,8 +18201,8 @@ void packetdb_loaddb(void) { memset(packet_db,0,sizeof(packet_db)); - #define packet(id, size, ...) packetdb_addpacket(id, size, ##__VA_ARGS__, 0xFFFF) - #define packetKeys(a,b,c) { clif->cryptKey[0] = a; clif->cryptKey[1] = b; clif->cryptKey[2] = c; } + #define packet(id, size, ...) packetdb_addpacket((id), (size), ##__VA_ARGS__, 0xFFFF) + #define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0) #include "packets.h" /* load structure data */ #undef packet #undef packetKeys diff --git a/src/map/clif.h b/src/map/clif.h index 88f3383d1..76d52311f 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -45,7 +45,7 @@ struct skill_cd; **/ #define packet_len(cmd) packet_db[cmd].len #define P2PTR(fd) RFIFO2PTR(fd) -#define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0; +#define clif_menuskill_clear(sd) ((sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0) #define HCHSYS_NAME_LENGTH 20 /** diff --git a/src/map/elemental.h b/src/map/elemental.h index 8ffffa5e3..830a6a577 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -21,8 +21,8 @@ #define EL_SKILLMODE_ASSIST 0x2 #define EL_SKILLMODE_AGGRESSIVE 0x4 -#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) -#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) +#define elemental_stop_walking(ed, type) (unit->stop_walking(&(ed)->bl, (type))) +#define elemental_stop_attack(ed) (unit->stop_attack(&(ed)->bl)) /** * Structures diff --git a/src/map/homunculus.h b/src/map/homunculus.h index b7906d4c8..117f9da8e 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -10,7 +10,7 @@ #include "pc.h" #define MAX_HOM_SKILL_REQUIRE 5 -#define homdb_checkid(id) (id >= HM_CLASS_BASE && id <= HM_CLASS_MAX) +#define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) #define homun_alive(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0) struct h_stats { diff --git a/src/map/intif.c b/src/map/intif.c index e6ff91af7..36ae753db 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -35,7 +35,7 @@ struct intif_interface intif_s; -#define inter_fd chrif->fd // alias +#define inter_fd (chrif->fd) // alias //----------------------------------------------------------------- // Send to inter server diff --git a/src/map/intif.h b/src/map/intif.h index 5e996b6fe..d0dfd25cd 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -22,9 +22,9 @@ struct auction_data; /** * Defines **/ -#define intif_rename_pc(sd, name) intif->rename(sd, 0, name) -#define intif_rename_pet(sd, name) intif->rename(sd, 1, name) -#define intif_rename_hom(sd, name) intif->rename(sd, 2, name) +#define intif_rename_pc(sd, name) (intif->rename((sd), 0, (name))) +#define intif_rename_pet(sd, name) (intif->rename((sd), 1, (name))) +#define intif_rename_hom(sd, name) (intif->rename((sd), 2, (name))) #define INTIF_PACKET_LEN_TABLE_SIZE 161 diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 3f31c79d4..4ee6637c1 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -28,7 +28,7 @@ struct item_package; #define CARD0_PET ((short)0xFF00) //Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex] -#define itemdb_isspecial(i) (i == CARD0_FORGE || i == CARD0_CREATE || i == CARD0_PET) +#define itemdb_isspecial(i) ((i) == CARD0_FORGE || (i) == CARD0_CREATE || (i) == CARD0_PET) //Use apple for unknown items. #define UNKNOWN_ITEM_ID 512 @@ -236,44 +236,45 @@ struct item_package { unsigned short must_qty; }; -#define itemdb_name(n) itemdb->search(n)->name -#define itemdb_jname(n) itemdb->search(n)->jname -#define itemdb_type(n) itemdb->search(n)->type -#define itemdb_atk(n) itemdb->search(n)->atk -#define itemdb_def(n) itemdb->search(n)->def -#define itemdb_look(n) itemdb->search(n)->look -#define itemdb_weight(n) itemdb->search(n)->weight -#define itemdb_equip(n) itemdb->search(n)->equip -#define itemdb_usescript(n) itemdb->search(n)->script -#define itemdb_equipscript(n) itemdb->search(n)->script -#define itemdb_wlv(n) itemdb->search(n)->wlv -#define itemdb_range(n) itemdb->search(n)->range -#define itemdb_slot(n) itemdb->search(n)->slot -#define itemdb_available(n) (itemdb->search(n)->flag.available) -#define itemdb_viewid(n) (itemdb->search(n)->view_id) -#define itemdb_autoequip(n) (itemdb->search(n)->flag.autoequip) -#define itemdb_is_rune(n) ((n >= ITEMID_NAUTHIZ && n <= ITEMID_HAGALAZ) || n == ITEMID_LUX_ANIMA) -#define itemdb_is_element(n) (n >= 990 && n <= 993) -#define itemdb_is_spellbook(n) (n >= 6188 && n <= 6205) -#define itemdb_is_poison(n) (n >= 12717 && n <= 12724) -#define itemid_isgemstone(id) ( (id) >= ITEMID_YELLOW_GEMSTONE && (id) <= ITEMID_BLUE_GEMSTONE ) -#define itemdb_iscashfood(id) ( (id) >= 12202 && (id) <= 12207 ) -#define itemdb_is_GNbomb(n) (n >= 13260 && n <= 13267) -#define itemdb_is_GNthrowable(n) (n >= 13268 && n <= 13290) +#define itemdb_name(n) (itemdb->search(n)->name) +#define itemdb_jname(n) (itemdb->search(n)->jname) +#define itemdb_type(n) (itemdb->search(n)->type) +#define itemdb_atk(n) (itemdb->search(n)->atk) +#define itemdb_def(n) (itemdb->search(n)->def) +#define itemdb_look(n) (itemdb->search(n)->look) +#define itemdb_weight(n) (itemdb->search(n)->weight) +#define itemdb_equip(n) (itemdb->search(n)->equip) +#define itemdb_usescript(n) (itemdb->search(n)->script) +#define itemdb_equipscript(n) (itemdb->search(n)->script) +#define itemdb_wlv(n) (itemdb->search(n)->wlv) +#define itemdb_range(n) (itemdb->search(n)->range) +#define itemdb_slot(n) (itemdb->search(n)->slot) +#define itemdb_available(n) (itemdb->search(n)->flag.available) +#define itemdb_viewid(n) (itemdb->search(n)->view_id) +#define itemdb_autoequip(n) (itemdb->search(n)->flag.autoequip) +#define itemdb_value_buy(n) (itemdb->search(n)->value_buy) +#define itemdb_value_sell(n) (itemdb->search(n)->value_sell) +#define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine) + +#define itemdb_is_rune(n) (((n) >= ITEMID_NAUTHIZ && (n) <= ITEMID_HAGALAZ) || (n) == ITEMID_LUX_ANIMA) +#define itemdb_is_element(n) ((n) >= 990 && (n) <= 993) +#define itemdb_is_spellbook(n) ((n) >= 6188 && (n) <= 6205) +#define itemdb_is_poison(n) ((n) >= 12717 && (n) <= 12724) +#define itemid_isgemstone(n) ((n) >= ITEMID_YELLOW_GEMSTONE && (n) <= ITEMID_BLUE_GEMSTONE) +#define itemdb_iscashfood(n) ((n) >= 12202 && (n) <= 12207) +#define itemdb_is_GNbomb(n) ((n) >= 13260 && (n) <= 13267) +#define itemdb_is_GNthrowable(n) ((n) >= 13268 && (n) <= 13290) -#define itemdb_value_buy(n) itemdb->search(n)->value_buy -#define itemdb_value_sell(n) itemdb->search(n)->value_sell -#define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine) //Item trade restrictions [Skotlex] -#define itemdb_isdropable(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->isdropable_sub) -#define itemdb_cantrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->cantrade_sub) -#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->canpartnertrade_sub) -#define itemdb_cansell(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cansell_sub) -#define itemdb_cancartstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cancartstore_sub) -#define itemdb_canstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->canstore_sub) -#define itemdb_canguildstore(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canguildstore_sub) -#define itemdb_canmail(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canmail_sub) -#define itemdb_canauction(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canauction_sub) +#define itemdb_isdropable(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->isdropable_sub)) +#define itemdb_cantrade(item, gmlv, gmlv2) (itemdb->isrestricted((item), (gmlv), (gmlv2), itemdb->cantrade_sub)) +#define itemdb_canpartnertrade(item, gmlv, gmlv2) (itemdb->isrestricted((item), (gmlv), (gmlv2), itemdb->canpartnertrade_sub)) +#define itemdb_cansell(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->cansell_sub)) +#define itemdb_cancartstore(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->cancartstore_sub)) +#define itemdb_canstore(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->canstore_sub)) +#define itemdb_canguildstore(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->canguildstore_sub)) +#define itemdb_canmail(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->canmail_sub)) +#define itemdb_canauction(item, gmlv) (itemdb->isrestricted((item), (gmlv), 0, itemdb->canauction_sub)) struct itemdb_interface { void (*init) (bool minimal); diff --git a/src/map/map.c b/src/map/map.c index 17648a661..099d2c6ea 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2095,9 +2095,7 @@ struct s_mapiterator /// @param _bl_ block_list /// @return true if it matches #define MAPIT_MATCHES(_mapit_,_bl_) \ - ( \ - ( (_bl_)->type & (_mapit_)->types /* type matches */ ) \ - ) + ( (_bl_)->type & (_mapit_)->types /* type matches */ ) /// Allocates a new iterator. /// Returns the new iterator. diff --git a/src/map/map.h b/src/map/map.h index 4cb00f144..6580d7e50 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -26,7 +26,7 @@ enum E_MAPSERVER_ST { }; #define MAX_NPC_PER_MAP 512 -#define AREA_SIZE battle_config.area_size +#define AREA_SIZE (battle_config.area_size) #define DAMAGELOG_SIZE 30 #define LOOTITEM_SIZE 10 #define MAX_MOBSKILL 50 @@ -39,7 +39,7 @@ enum E_MAPSERVER_ST { #define MAX_LEVEL 150 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 -#define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo] +#define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] #define BLOCK_SIZE 8 #define block_free_max 1048576 @@ -221,7 +221,7 @@ enum { #define CHAT_SIZE_MAX (255 + 1) // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) -#define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000 +#define DEFAULT_AUTOSAVE_INTERVAL (5*60*1000) // Specifies maps where players may hit each other #define map_flag_vs(m) (map->list[m].flag.pvp || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) || map->list[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions @@ -724,7 +724,7 @@ struct map_data_other_server { uint16 port; }; -#define map_id2index(id) map->list[(id)].index +#define map_id2index(id) (map->list[(id)].index) /// Bitfield of flags for the iterator. enum e_mapitflags { @@ -747,11 +747,11 @@ struct mapit_interface { struct mapit_interface *mapit; -#define mapit_getallusers() mapit->alloc(MAPIT_NORMAL,BL_PC) -#define mapit_geteachpc() mapit->alloc(MAPIT_NORMAL,BL_PC) -#define mapit_geteachmob() mapit->alloc(MAPIT_NORMAL,BL_MOB) -#define mapit_geteachnpc() mapit->alloc(MAPIT_NORMAL,BL_NPC) -#define mapit_geteachiddb() mapit->alloc(MAPIT_NORMAL,BL_ALL) +#define mapit_getallusers() (mapit->alloc(MAPIT_NORMAL,BL_PC)) +#define mapit_geteachpc() (mapit->alloc(MAPIT_NORMAL,BL_PC)) +#define mapit_geteachmob() (mapit->alloc(MAPIT_NORMAL,BL_MOB)) +#define mapit_geteachnpc() (mapit->alloc(MAPIT_NORMAL,BL_NPC)) +#define mapit_geteachiddb() (mapit->alloc(MAPIT_NORMAL,BL_ALL)) //Useful typedefs from jA [Skotlex] typedef struct map_session_data TBL_PC; diff --git a/src/map/mob.c b/src/map/mob.c index 4e648b2a6..b41dedac1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -52,7 +52,7 @@ struct mob_interface mob_s; #define MOB_LAZYSKILLPERC 0 // Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute) // Move probability for mobs away from players (rate of 1000 minute) // in Aegis, this is 100% for mobs that have been activated by players and none otherwise. -#define MOB_LAZYMOVEPERC(md) (md->state.spotted?1000:0) +#define MOB_LAZYMOVEPERC(md) ((md)->state.spotted?1000:0) #define MOB_MAX_DELAY (24*3600*1000) #define MAX_MINCHASE 30 //Max minimum chase value to use for mobs. #define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used? diff --git a/src/map/mob.h b/src/map/mob.h index 110d027ef..48a9f078e 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -37,7 +37,7 @@ #define MOB_CLONE_END MAX_MOB_DB //Used to determine default enemy type of mobs (for use in eachinrange calls) -#define DEFAULT_ENEMY_TYPE(md) (md->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER) +#define DEFAULT_ENEMY_TYPE(md) ((md)->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER) #define MAX_MOB_CHAT 250 //Max Skill's messages @@ -243,8 +243,9 @@ struct item_drop_list { }; -#define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) -#define mob_stop_attack(md) unit->stop_attack(&(md)->bl) +#define mob_stop_walking(md, type) (unit->stop_walking(&(md)->bl, (type))) +#define mob_stop_attack(md) (unit->stop_attack(&(md)->bl)) + #define mob_is_battleground(md) ( map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) #define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) diff --git a/src/map/path.h b/src/map/path.h index e872c8877..a889a6409 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -23,13 +23,13 @@ struct shootpath_data { int y[MAX_WALKPATH]; }; -#define check_distance_bl(bl1, bl2, distance) path->check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance) -#define check_distance_blxy(bl, x1, y1, distance) path->check_distance((bl)->x-(x1), (bl)->y-(y1), distance) -#define check_distance_xy(x0, y0, x1, y1, distance) path->check_distance((x0)-(x1), (y0)-(y1), distance) +#define check_distance_bl(bl1, bl2, distance) (path->check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)) +#define check_distance_blxy(bl, x1, y1, distance) (path->check_distance((bl)->x - (x1), (bl)->y - (y1), distance)) +#define check_distance_xy(x0, y0, x1, y1, distance) (path->check_distance((x0) - (x1), (y0) - (y1), distance)) -#define distance_bl(bl1, bl2) path->distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y) -#define distance_blxy(bl, x1, y1) path->distance((bl)->x-(x1), (bl)->y-(y1)) -#define distance_xy(x0, y0, x1, y1) path->distance((x0)-(x1), (y0)-(y1)) +#define distance_bl(bl1, bl2) (path->distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)) +#define distance_blxy(bl, x1, y1) (path->distance((bl)->x - (x1), (bl)->y - (y1))) +#define distance_xy(x0, y0, x1, y1) (path->distance((x0) - (x1), (y0) - (y1))) struct path_interface { // calculates destination cell for knockback diff --git a/src/map/pc.h b/src/map/pc.h index 71c76b643..f10bd0f59 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -615,8 +615,8 @@ enum equip_pos { // Rune Knight Dragon #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON ) -#define pc_stop_walking(sd, type) unit->stop_walking(&(sd)->bl, type) -#define pc_stop_attack(sd) unit->stop_attack(&(sd)->bl) +#define pc_stop_walking(sd, type) (unit->stop_walking(&(sd)->bl, (type))) +#define pc_stop_attack(sd) (unit->stop_attack(&(sd)->bl)) //Weapon check considering dual wielding. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \ @@ -633,7 +633,7 @@ enum equip_pos { || ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \ || ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \ ) -#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_) +#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)(class_)) // clientside display macros (values to the left/right of the "+") #ifdef RENEWAL @@ -671,18 +671,18 @@ enum equip_pos { #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp) #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp) -#define pc_readglobalreg(sd,reg) pc->readregistry(sd,reg,3) -#define pc_setglobalreg(sd,reg,val) pc->setregistry(sd,reg,val,3) -#define pc_readglobalreg_str(sd,reg) pc->readregistry_str(sd,reg,3) -#define pc_setglobalreg_str(sd,reg,val) pc->setregistry_str(sd,reg,val,3) -#define pc_readaccountreg(sd,reg) pc->readregistry(sd,reg,2) -#define pc_setaccountreg(sd,reg,val) pc->setregistry(sd,reg,val,2) -#define pc_readaccountregstr(sd,reg) pc->readregistry_str(sd,reg,2) -#define pc_setaccountregstr(sd,reg,val) pc->setregistry_str(sd,reg,val,2) -#define pc_readaccountreg2(sd,reg) pc->readregistry(sd,reg,1) -#define pc_setaccountreg2(sd,reg,val) pc->setregistry(sd,reg,val,1) -#define pc_readaccountreg2str(sd,reg) pc->readregistry_str(sd,reg,1) -#define pc_setaccountreg2str(sd,reg,val) pc->setregistry_str(sd,reg,val,1) +#define pc_readglobalreg(sd,reg) (pc->readregistry((sd),(reg),3)) +#define pc_setglobalreg(sd,reg,val) (pc->setregistry((sd),(reg),(val),3)) +#define pc_readglobalreg_str(sd,reg) (pc->readregistry_str((sd),(reg),3)) +#define pc_setglobalreg_str(sd,reg,val) (pc->setregistry_str((sd),(reg),(val),3)) +#define pc_readaccountreg(sd,reg) (pc->readregistry((sd),(reg),2)) +#define pc_setaccountreg(sd,reg,val) (pc->setregistry((sd),(reg),(val),2)) +#define pc_readaccountregstr(sd,reg) (pc->readregistry_str((sd),(reg),2)) +#define pc_setaccountregstr(sd,reg,val) (pc->setregistry_str((sd),(reg),(val),2)) +#define pc_readaccountreg2(sd,reg) (pc->readregistry((sd),(reg),1)) +#define pc_setaccountreg2(sd,reg,val) (pc->setregistry((sd),(reg),(val),1)) +#define pc_readaccountreg2str(sd,reg) (pc->readregistry_str((sd),(reg),1)) +#define pc_setaccountreg2str(sd,reg,val) (pc->setregistry_str((sd),(reg),(val),1)) struct skill_tree_entry { short id; diff --git a/src/map/pet.h b/src/map/pet.h index f9a756de2..f1a219700 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -98,8 +98,8 @@ struct pet_data { struct map_session_data *msd; }; -#define pet_stop_walking(pd, type) unit->stop_walking(&(pd)->bl, type) -#define pet_stop_attack(pd) unit->stop_attack(&(pd)->bl) +#define pet_stop_walking(pd, type) (unit->stop_walking(&(pd)->bl, (type))) +#define pet_stop_attack(pd) (unit->stop_attack(&(pd)->bl)) struct pet_interface { struct s_pet_db db[MAX_PET_DB]; diff --git a/src/map/script.c b/src/map/script.c index 0827258d7..0f2c86868 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -278,7 +278,7 @@ void disp_error_message2(const char *mes,const char *pos,int report) script->error_report = report; longjmp( script->error_jump, 1 ); } -#define disp_error_message(mes,pos) script->disp_error_message2(mes,pos,1) +#define disp_error_message(mes,pos) (script->disp_error_message2((mes),(pos),1)) void disp_warning_message(const char *mes, const char *pos) { script->warning(script->parser_current_src,script->parser_current_file,script->parser_current_line,mes,pos); @@ -3986,9 +3986,6 @@ const char *script_getfuncname(struct script_state *st) { // buildin functions // -#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args } -#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args } - ///////////////////////////////////////////////////////////////////// // NPC interaction // @@ -13016,7 +13013,7 @@ BUILDIN(isequippedcnt) } for (i=0; id!=0; i++) { - script_fetch(st,i+2, id) else id = 0; + script_fetch(st,i+2, id); if (id <= 0) continue; @@ -13074,7 +13071,7 @@ BUILDIN(isequipped) setitem_hash = sd->bonus.setitem_hash; setitem_hash2 = sd->bonus.setitem_hash2; for (i=0; id!=0; i++) { - script_fetch(st,i+2, id) else id = 0; + script_fetch(st,i+2, id); if (id <= 0) continue; flag = 0; @@ -13148,7 +13145,7 @@ BUILDIN(cardscnt) { sd = script->rid2sd(st); for (i=0; id!=0; i++) { - script_fetch(st,i+2, id) else id = 0; + script_fetch(st,i+2, id); if (id <= 0) continue; @@ -17961,6 +17958,8 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) return true; } +#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args } +#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args } void script_parse_builtin(void) { struct script_function BUILDIN[] = { // NPC interaction @@ -18504,6 +18503,8 @@ void script_parse_builtin(void) { } } } +#undef BUILDIN_DEF +#undef BUILDIN_DEF2 void script_label_add(int key, int pos) { int idx = script->label_count; diff --git a/src/map/script.h b/src/map/script.h index 0bb92c433..32426e988 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -22,9 +22,9 @@ struct eri; **/ // TODO: Remove temporary code #define ENABLE_CASE_CHECK -#define DeprecationWarning(func, bad, good, file, line) ShowWarning("%s: use of deprecated keyword '%s' (use '%s' instead) in file '%s', line '%d'. This will be a critical error in a near future.\n", func, bad, good, file, line); -#define DeprecationWarning2(func, bad, good, where) ShowWarning("%s: detected possible use of wrong case in a script. Found '%s', probably meant to be '%s' (in '%s'). If it is a local (.@) variable, and you're absolutely sure you used the correct case, please disragard this message, otherwise please correct your scripts, as this will become fatal in a near future.\n", func, bad, good, where); -#define disp_deprecation_message(func, good, p) disp_warning_message(func": use of deprecated keyword (use '"good"' instead). This will be a critical error in a near future.", p); +#define DeprecationWarning(func, bad, good, file, line) ShowWarning("%s: use of deprecated keyword '%s' (use '%s' instead) in file '%s', line '%d'. This will be a critical error in a near future.\n", (func), (bad), (good), (file), (line)); +#define DeprecationWarning2(func, bad, good, where) ShowWarning("%s: detected possible use of wrong case in a script. Found '%s', probably meant to be '%s' (in '%s'). This will become fatal in a near future.\n", (func), (bad), (good), (where)); +#define disp_deprecation_message(func, good, p) disp_warning_message(func": use of deprecated keyword (use '"good"' instead). This will be a critical error in a near future.", (p)); #define NUM_WHISPER_VAR 10 @@ -71,24 +71,24 @@ struct eri; /// Returns the index of the last data in the stack #define script_lastdata(st) ( (st)->end - (st)->start - 1 ) /// Pushes an int into the stack -#define script_pushint(st,val) script->push_val((st)->stack, C_INT, (val),NULL) +#define script_pushint(st,val) (script->push_val((st)->stack, C_INT, (val),NULL)) /// Pushes a string into the stack (script engine frees it automatically) -#define script_pushstr(st,val) script->push_str((st)->stack, C_STR, (val)) +#define script_pushstr(st,val) (script->push_str((st)->stack, C_STR, (val))) /// Pushes a copy of a string into the stack -#define script_pushstrcopy(st,val) script->push_str((st)->stack, C_STR, aStrdup(val)) +#define script_pushstrcopy(st,val) (script->push_str((st)->stack, C_STR, aStrdup(val))) /// Pushes a constant string into the stack (must never change or be freed) -#define script_pushconststr(st,val) script->push_str((st)->stack, C_CONSTSTR, (val)) +#define script_pushconststr(st,val) (script->push_str((st)->stack, C_CONSTSTR, (val))) /// Pushes a nil into the stack -#define script_pushnil(st) script->push_val((st)->stack, C_NOP, 0,NULL) +#define script_pushnil(st) (script->push_val((st)->stack, C_NOP, 0,NULL)) /// Pushes a copy of the data in the target index -#define script_pushcopy(st,i) script->push_copy((st)->stack, (st)->start + (i)) +#define script_pushcopy(st,i) (script->push_copy((st)->stack, (st)->start + (i))) -#define script_isstring(st,i) data_isstring(script_getdata(st,i)) -#define script_isint(st,i) data_isint(script_getdata(st,i)) +#define script_isstring(st,i) data_isstring(script_getdata((st),(i))) +#define script_isint(st,i) data_isint(script_getdata((st),(i))) -#define script_getnum(st,val) script->conv_num(st, script_getdata(st,val)) -#define script_getstr(st,val) script->conv_str(st, script_getdata(st,val)) -#define script_getref(st,val) ( script_getdata(st,val)->ref ) +#define script_getnum(st,val) (script->conv_num((st), script_getdata((st),(val)))) +#define script_getstr(st,val) (script->conv_str((st), script_getdata((st),(val)))) +#define script_getref(st,val) ( script_getdata((st),(val))->ref ) // Note: "top" functions/defines use indexes relative to the top of the stack // -1 is the index of the data at the top @@ -147,9 +147,12 @@ struct eri; #define BUILDIN(x) bool buildin_ ## x (struct script_state* st) #define BUILDIN_A(x) buildin_ ## x -#define script_fetch(st, n, t) \ - if( script_hasdata(st,n) ) \ - (t)=script_getnum(st,n); +#define script_fetch(st, n, t) do { \ + if( script_hasdata((st),(n)) ) \ + (t)=script_getnum((st),(n)); \ + else \ + (t) = 0; \ +} while(0) /** diff --git a/src/map/skill.c b/src/map/skill.c index fa26cdb12..c38363ef3 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -47,13 +47,13 @@ // ranges reserved for mapping skill ids to skilldb offsets #define HM_SKILLRANGEMIN 750 -#define HM_SKILLRANGEMAX HM_SKILLRANGEMIN + MAX_HOMUNSKILL -#define MC_SKILLRANGEMIN HM_SKILLRANGEMAX + 1 -#define MC_SKILLRANGEMAX MC_SKILLRANGEMIN + MAX_MERCSKILL -#define EL_SKILLRANGEMIN MC_SKILLRANGEMAX + 1 -#define EL_SKILLRANGEMAX EL_SKILLRANGEMIN + MAX_ELEMENTALSKILL -#define GD_SKILLRANGEMIN EL_SKILLRANGEMAX + 1 -#define GD_SKILLRANGEMAX GD_SKILLRANGEMIN + MAX_GUILDSKILL +#define HM_SKILLRANGEMAX (HM_SKILLRANGEMIN + MAX_HOMUNSKILL) +#define MC_SKILLRANGEMIN (HM_SKILLRANGEMAX + 1) +#define MC_SKILLRANGEMAX (MC_SKILLRANGEMIN + MAX_MERCSKILL) +#define EL_SKILLRANGEMIN (MC_SKILLRANGEMAX + 1) +#define EL_SKILLRANGEMAX (EL_SKILLRANGEMIN + MAX_ELEMENTALSKILL) +#define GD_SKILLRANGEMIN (EL_SKILLRANGEMAX + 1) +#define GD_SKILLRANGEMAX (GD_SKILLRANGEMIN + MAX_GUILDSKILL) #if GD_SKILLRANGEMAX > 999 #error GD_SKILLRANGEMAX is greater than 999 @@ -131,17 +131,17 @@ void skill_chk(uint16* skill_id) { *skill_id = skill->get_index(*skill_id); // checks/adjusts id } -#define skill_get(var,id) { skill->chk(&id); if(!id) return 0; return var; } -#define skill_get2(var,id,lv) { \ - skill->chk(&id); \ - if(!id) return 0; \ - if( lv > MAX_SKILL_LEVEL && var > 1 ) { \ - int lv2 = lv; lv = skill->db[id].max; \ - return (var) + ((lv2-lv)/2);\ +#define skill_get(var,id) do { skill->chk(&(id)); if(!(id)) return 0; return (var); } while(0) +#define skill_get2(var,id,lv) do { \ + skill->chk(&(id)); \ + if(!(id)) return 0; \ + if( (lv) > MAX_SKILL_LEVEL && (var) > 1 ) { \ + int lv2__ = (lv); (lv) = skill->db[(id)].max; \ + return (var) + ((lv2__-(lv))/2);\ } \ - return var;\ -} -#define skill_glv(lv) min(lv,MAX_SKILL_LEVEL-1) + return (var);\ +} while(0) +#define skill_glv(lv) min((lv),MAX_SKILL_LEVEL-1) // Skill DB int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); } int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); } @@ -9523,7 +9523,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char nullpo_ret(sd); //Simplify skill_failed code. -#define skill_failed(sd) { sd->menuskill_id = sd->menuskill_val = 0; } +#define skill_failed(sd) ( (sd)->menuskill_id = (sd)->menuskill_val = 0 ) if(skill_id != sd->menuskill_id) return 0; diff --git a/src/map/status.c b/src/map/status.c index a8389691f..d64986eca 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -102,10 +102,6 @@ int status_type2relevant_bl_types(int type) return status->RelevantBLTypes[type]; } -#define add_sc(skill,sc) set_sc(skill,sc,SI_BLANK,SCB_NONE) -// indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units -#define set_sc_with_vfx(skill, sc, icon, flag) set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT - static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { uint16 idx; if( (idx = skill->get_index(skill_id)) == 0 ) { @@ -128,6 +124,10 @@ static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { } void initChangeTables(void) { +#define add_sc(skill,sc) set_sc((skill),(sc),SI_BLANK,SCB_NONE) +// indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units +#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0) + int i; for (i = 0; i < SC_MAX; i++) @@ -1034,6 +1034,8 @@ void initChangeTables(void) { if( !battle_config.display_hallucination ) //Disable Hallucination. status->IconChangeTable[SC_ILLUSION] = SI_BLANK; +#undef add_sc +#undef set_sc_with_vfx } void initDummyData(void) @@ -8559,12 +8561,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_GENSOU: - #define PER( a ) do { \ - if( a <= 15 ) lv = 1; \ - else if( a <= 30 ) lv = 2; \ - else if( a <= 50 ) lv = 3; \ - else if( a <= 75 ) lv = 4; \ - } while(0) +#define PER( a, lvl ) do { \ + int temp__ = (a); \ + if( temp__ <= 15 ) (lvl) = 1; \ + else if( temp__ <= 30 ) (lvl) = 2; \ + else if( temp__ <= 50 ) (lvl) = 3; \ + else if( temp__ <= 75 ) (lvl) = 4; \ + else (lvl) = 5; \ +} while(0) { int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5; @@ -8572,13 +8576,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( rand()%100 > (25 + 10 * val1) - status_get_int(bl) / 2) return 0; - PER( 100 / (status_get_max_hp(bl) / hp) ); + PER( 100 / (status_get_max_hp(bl) / hp), lv ); status->heal(bl, (!(hp%2) ? (6-lv) *4 / 100 : -(lv*4) / 100), 0, 1); - PER( 100 / (status_get_max_sp(bl) / sp) ); + PER( 100 / (status_get_max_sp(bl) / sp), lv ); status->heal(bl, 0,(!(sp%2) ? (6-lv) *3 / 100 : -(lv*3) / 100), 1); } - #undef PER +#undef PER break; case SC_ANGRIFFS_MODUS: val2 = 50 + 20 * val1; //atk bonus @@ -10022,7 +10026,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { // set the next timer of the sce (don't assume the status still exists) #define sc_timer_next(t,f,i,d) do { \ if( (sce=sc->data[type]) ) \ - sce->timer = timer->add(t,f,i,d); \ + sce->timer = timer->add((t),(f),(i),(d)); \ else \ ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data); \ } while(0) diff --git a/src/map/status.h b/src/map/status.h index cdd5fa481..75582e9a4 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1764,67 +1764,67 @@ struct status_change { //Define for standard HP damage attacks. -#define status_fix_damage(src, target, hp, walkdelay) status->damage(src, target, hp, 0, walkdelay, 0) +#define status_fix_damage(src, target, hp, walkdelay) (status->damage((src), (target), (hp), 0, (walkdelay), 0)) //Define for standard HP/SP damage triggers. -#define status_zap(bl, hp, sp) status->damage(NULL, bl, hp, sp, 0, 1) +#define status_zap(bl, hp, sp) (status->damage(NULL, (bl), (hp), (sp), 0, 1)) //Easier handling of status->percent_change -#define status_percent_heal(bl, hp_rate, sp_rate) status->percent_change(NULL, bl, -(hp_rate), -(sp_rate), 0) -#define status_percent_damage(src, target, hp_rate, sp_rate, kill) status->percent_change(src, target, hp_rate, sp_rate, (kill)?1:2) +#define status_percent_heal(bl, hp_rate, sp_rate) (status->percent_change(NULL, (bl), -(hp_rate), -(sp_rate), 0)) +#define status_percent_damage(src, target, hp_rate, sp_rate, kill) (status->percent_change((src), (target), (hp_rate), (sp_rate), (kill)?1:2)) //Instant kill with no drops/exp/etc -#define status_kill(bl) status_percent_damage(NULL, bl, 100, 0, true) +#define status_kill(bl) status_percent_damage(NULL, (bl), 100, 0, true) -#define status_get_range(bl) status->get_status_data(bl)->rhw.range -#define status_get_hp(bl) status->get_status_data(bl)->hp -#define status_get_max_hp(bl) status->get_status_data(bl)->max_hp -#define status_get_sp(bl) status->get_status_data(bl)->sp -#define status_get_max_sp(bl) status->get_status_data(bl)->max_sp -#define status_get_str(bl) status->get_status_data(bl)->str -#define status_get_agi(bl) status->get_status_data(bl)->agi -#define status_get_vit(bl) status->get_status_data(bl)->vit -#define status_get_int(bl) status->get_status_data(bl)->int_ -#define status_get_dex(bl) status->get_status_data(bl)->dex -#define status_get_luk(bl) status->get_status_data(bl)->luk -#define status_get_hit(bl) status->get_status_data(bl)->hit -#define status_get_flee(bl) status->get_status_data(bl)->flee -#define status_get_mdef(bl) status->get_status_data(bl)->mdef -#define status_get_flee2(bl) status->get_status_data(bl)->flee2 -#define status_get_def2(bl) status->get_status_data(bl)->def2 -#define status_get_mdef2(bl) status->get_status_data(bl)->mdef2 -#define status_get_critical(bl) status->get_status_data(bl)->cri -#define status_get_batk(bl) status->get_status_data(bl)->batk -#define status_get_watk(bl) status->get_status_data(bl)->rhw.atk -#define status_get_watk2(bl) status->get_status_data(bl)->rhw.atk2 -#define status_get_matk_max(bl) status->get_status_data(bl)->matk_max -#define status_get_matk_min(bl) status->get_status_data(bl)->matk_min -#define status_get_lwatk(bl) status->get_status_data(bl)->lhw.atk -#define status_get_lwatk2(bl) status->get_status_data(bl)->lhw.atk2 -#define status_get_adelay(bl) status->get_status_data(bl)->adelay -#define status_get_amotion(bl) status->get_status_data(bl)->amotion -#define status_get_dmotion(bl) status->get_status_data(bl)->dmotion -#define status_get_element(bl) status->get_status_data(bl)->def_ele -#define status_get_element_level(bl) status->get_status_data(bl)->ele_lv -#define status_get_attack_sc_element(bl, sc) status->calc_attack_element(bl, sc, 0) -#define status_get_attack_element(bl) status->get_status_data(bl)->rhw.ele -#define status_get_attack_lelement(bl) status->get_status_data(bl)->lhw.ele -#define status_get_race(bl) status->get_status_data(bl)->race -#define status_get_size(bl) status->get_status_data(bl)->size -#define status_get_mode(bl) status->get_status_data(bl)->mode +#define status_get_range(bl) (status->get_status_data(bl)->rhw.range) +#define status_get_hp(bl) (status->get_status_data(bl)->hp) +#define status_get_max_hp(bl) (status->get_status_data(bl)->max_hp) +#define status_get_sp(bl) (status->get_status_data(bl)->sp) +#define status_get_max_sp(bl) (status->get_status_data(bl)->max_sp) +#define status_get_str(bl) (status->get_status_data(bl)->str) +#define status_get_agi(bl) (status->get_status_data(bl)->agi) +#define status_get_vit(bl) (status->get_status_data(bl)->vit) +#define status_get_int(bl) (status->get_status_data(bl)->int_) +#define status_get_dex(bl) (status->get_status_data(bl)->dex) +#define status_get_luk(bl) (status->get_status_data(bl)->luk) +#define status_get_hit(bl) (status->get_status_data(bl)->hit) +#define status_get_flee(bl) (status->get_status_data(bl)->flee) +#define status_get_mdef(bl) (status->get_status_data(bl)->mdef) +#define status_get_flee2(bl) (status->get_status_data(bl)->flee2) +#define status_get_def2(bl) (status->get_status_data(bl)->def2) +#define status_get_mdef2(bl) (status->get_status_data(bl)->mdef2) +#define status_get_critical(bl) (status->get_status_data(bl)->cri) +#define status_get_batk(bl) (status->get_status_data(bl)->batk) +#define status_get_watk(bl) (status->get_status_data(bl)->rhw.atk) +#define status_get_watk2(bl) (status->get_status_data(bl)->rhw.atk2) +#define status_get_matk_max(bl) (status->get_status_data(bl)->matk_max) +#define status_get_matk_min(bl) (status->get_status_data(bl)->matk_min) +#define status_get_lwatk(bl) (status->get_status_data(bl)->lhw.atk) +#define status_get_lwatk2(bl) (status->get_status_data(bl)->lhw.atk2) +#define status_get_adelay(bl) (status->get_status_data(bl)->adelay) +#define status_get_amotion(bl) (status->get_status_data(bl)->amotion) +#define status_get_dmotion(bl) (status->get_status_data(bl)->dmotion) +#define status_get_element(bl) (status->get_status_data(bl)->def_ele) +#define status_get_element_level(bl) (status->get_status_data(bl)->ele_lv) +#define status_get_attack_sc_element(bl, sc) (status->calc_attack_element((bl), (sc), 0)) +#define status_get_attack_element(bl) (status->get_status_data(bl)->rhw.ele) +#define status_get_attack_lelement(bl) (status->get_status_data(bl)->lhw.ele) +#define status_get_race(bl) (status->get_status_data(bl)->race) +#define status_get_size(bl) (status->get_status_data(bl)->size) +#define status_get_mode(bl) (status->get_status_data(bl)->mode) //Short version, receives rate in 1->100 range, and does not uses a flag setting. -#define sc_start(bl, type, rate, val1, tick) status->change_start(bl,type,100*(rate),val1,0,0,0,tick,0) -#define sc_start2(bl, type, rate, val1, val2, tick) status->change_start(bl,type,100*(rate),val1,val2,0,0,tick,0) -#define sc_start4(bl, type, rate, val1, val2, val3, val4, tick) status->change_start(bl,type,100*(rate),val1,val2,val3,val4,tick,0) +#define sc_start(bl, type, rate, val1, tick) (status->change_start((bl),(type),100*(rate),(val1),0,0,0,(tick),0)) +#define sc_start2(bl, type, rate, val1, val2, tick) (status->change_start((bl),(type),100*(rate),(val1),(val2),0,0,(tick),0)) +#define sc_start4(bl, type, rate, val1, val2, val3, val4, tick) (status->change_start((bl),(type),100*(rate),(val1),(val2),(val3),(val4),(tick),0)) -#define status_change_end(bl,type,tid) status->change_end_(bl,type,tid,__FILE__,__LINE__) +#define status_change_end(bl,type,tid) (status->change_end_((bl),(type),(tid),__FILE__,__LINE__)) -#define status_calc_bl(bl, flag) status->calc_bl_(bl, (enum scb_flag)(flag), SCO_NONE) -#define status_calc_mob(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) -#define status_calc_pet(pd, opt) status->calc_bl_(&(pd)->bl, SCB_ALL, opt) -#define status_calc_pc(sd, opt) status->calc_bl_(&(sd)->bl, SCB_ALL, opt) -#define status_calc_homunculus(hd, opt) status->calc_bl_(&(hd)->bl, SCB_ALL, opt) -#define status_calc_mercenary(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) -#define status_calc_elemental(ed, opt) status->calc_bl_(&(ed)->bl, SCB_ALL, opt) -#define status_calc_npc(nd, opt) status->calc_bl_(&(nd)->bl, SCB_ALL, opt) +#define status_calc_bl(bl, flag) (status->calc_bl_((bl), (enum scb_flag)(flag), SCO_NONE)) +#define status_calc_mob(md, opt) (status->calc_bl_(&(md)->bl, SCB_ALL, (opt))) +#define status_calc_pet(pd, opt) (status->calc_bl_(&(pd)->bl, SCB_ALL, (opt))) +#define status_calc_pc(sd, opt) (status->calc_bl_(&(sd)->bl, SCB_ALL, (opt))) +#define status_calc_homunculus(hd, opt) (status->calc_bl_(&(hd)->bl, SCB_ALL, (opt))) +#define status_calc_mercenary(md, opt) (status->calc_bl_(&(md)->bl, SCB_ALL, (opt))) +#define status_calc_elemental(ed, opt) (status->calc_bl_(&(ed)->bl, SCB_ALL, (opt))) +#define status_calc_npc(nd, opt) (status->calc_bl_(&(nd)->bl, SCB_ALL, (opt))) // bonus values and upgrade chances for refining equipment struct s_refine_info { -- cgit v1.2.3-70-g09d2 From 38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Tue, 17 Dec 2013 23:02:13 -0200 Subject: Speed up of several procedures that rely on ERS, _mreallocz ('z'ero) Made Possible Thanks to the Woonderful Haruna! <3 Commit also fixes an inconsistency in the ERS, where it'd start with clear memory but would use garbage upon resizing, also implements a new ERS option that clears entries as soon as pass by ers_free, so that they'll be all shinny for when ers_alloc reuses them. Signed-off-by: shennetsind --- src/common/HPM.c | 4 ++++ src/common/db.c | 6 +++--- src/common/ers.c | 4 ++++ src/common/ers.h | 9 +++++---- src/common/malloc.c | 33 +++++++++++++++++++++++++++++++++ src/common/malloc.h | 4 +++- src/map/map.c | 4 ++-- src/map/mapreg_sql.c | 2 +- src/map/mob.c | 3 +-- src/map/script.c | 3 +-- src/map/skill.c | 9 +++------ 11 files changed, 60 insertions(+), 21 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/common/HPM.c b/src/common/HPM.c index 8e41e5838..426fac94a 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -533,6 +533,9 @@ void* HPM_calloc(size_t num, size_t size, const char *file, int line, const char void* HPM_realloc(void *p, size_t size, const char *file, int line, const char *func) { return iMalloc->realloc(p,size,HPM_file2ptr(file),line,func); } +void* HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func) { + return iMalloc->reallocz(p,size,HPM_file2ptr(file),line,func); +} char* HPM_astrdup(const char *p, const char *file, int line, const char *func) { return iMalloc->astrdup(p,HPM_file2ptr(file),line,func); } @@ -705,6 +708,7 @@ void hpm_init(void) { HPMiMalloc->malloc = HPM_mmalloc; HPMiMalloc->calloc = HPM_calloc; HPMiMalloc->realloc = HPM_realloc; + HPMiMalloc->reallocz = HPM_reallocz; HPMiMalloc->astrdup = HPM_astrdup; sscanf(HPM_VERSION, "%u.%u", &HPM->version[0], &HPM->version[1]); diff --git a/src/common/db.c b/src/common/db.c index ba3fef97b..efe7ca8b2 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -2446,7 +2446,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt db->free_lock = 0; /* Other */ snprintf(ers_name, 50, "db_alloc:nodes:%s:%s:%d",func,file,line); - db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME); + db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME|ERS_OPT_CLEAN); db->cmp = DB->default_cmp(type); db->hash = DB->default_hash(type); db->release = DB->default_release(type, options); @@ -2609,8 +2609,8 @@ void* db_data2ptr(DBData *data) * @see #db_final(void) */ void db_init(void) { - db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_NONE); - db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_NONE); + db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_CLEAN); + db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_CLEAN); ers_chunk_size(db_alloc_ers, 50); DB_COUNTSTAT(db_init); } diff --git a/src/common/ers.c b/src/common/ers.c index 22269a51f..a7dad49ab 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -40,6 +40,7 @@ * @see common#ers.h * \*****************************************************************************/ #include +#include #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree @@ -238,6 +239,9 @@ static void ers_obj_free_entry(ERS self, void *entry) return; } + if( instance->Options & ERS_OPT_CLEAN ) + memset((unsigned char*)reuse + sizeof(struct ers_list), 0, instance->Cache->ObjectSize - sizeof(struct ers_list)); + reuse->Next = instance->Cache->ReuseList; instance->Cache->ReuseList = reuse; instance->Count--; diff --git a/src/common/ers.h b/src/common/ers.h index 4ff2a6230..e63711b81 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -71,10 +71,11 @@ #endif /* not ERS_ALIGN_ENTRY */ enum ERSOptions { - ERS_OPT_NONE = 0x0, - ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */ - ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */ - ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ + ERS_OPT_NONE = 0x0, + ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */ + ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */ + ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ + ERS_OPT_CLEAN = 0x8,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */ }; /** diff --git a/src/common/malloc.c b/src/common/malloc.c index 23e28a65f..875b87a15 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -369,6 +369,37 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c } } +/* a _mrealloc clone with the difference it 'z'eroes the newly created memory */ +void* _mreallocz(void *memblock, size_t size, const char *file, int line, const char *func ) { + size_t old_size; + void *p = NULL; + + if(memblock == NULL) { + p = iMalloc->malloc(size,file,line,func); + memset(p,0,size); + return p; + } + + old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head) + sizeof(long)))->size; + if( old_size == 0 ) { + old_size = ((struct unit_head_large *)((char *)memblock - sizeof(struct unit_head_large) + sizeof(long)))->size; + } + if(old_size > size) { + // Size reduction - return> as it is (negligence) + return memblock; + } else { + // Size Large + p = iMalloc->malloc(size,file,line,func); + if(p != NULL) { + memcpy(p,memblock,old_size); + memset(p+old_size,0,size-old_size); + } + iMalloc->free(memblock,file,line,func); + return p; + } +} + + char* _mstrdup(const char *p, const char *file, int line, const char *func ) { if(p == NULL) { @@ -822,12 +853,14 @@ void malloc_defaults(void) { iMalloc->malloc = _mmalloc; iMalloc->calloc = _mcalloc; iMalloc->realloc = _mrealloc; + iMalloc->reallocz= _mreallocz; iMalloc->astrdup = _mstrdup; iMalloc->free = _mfree; #else iMalloc->malloc = aMalloc_; iMalloc->calloc = aCalloc_; iMalloc->realloc = aRealloc_; + iMalloc->reallocz= aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */ iMalloc->astrdup = aStrdup_; iMalloc->free = aFree_; #endif diff --git a/src/common/malloc.h b/src/common/malloc.h index cd0ef238b..19b5213bb 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -33,6 +33,7 @@ # define aMalloc(n) (iMalloc->malloc((n),ALC_MARK)) # define aCalloc(m,n) (iMalloc->calloc((m),(n),ALC_MARK)) # define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK)) +# define aReallocz(p,n) (iMalloc->reallocz((p),(n),ALC_MARK)) # define aStrdup(p) (iMalloc->astrdup((p),ALC_MARK)) # define aFree(p) (iMalloc->free((p),ALC_MARK)) @@ -54,7 +55,7 @@ ////////////// Others ////////////////////////// // should be merged with any of above later #define CREATE(result, type, number) ((result) = (type *) aCalloc((number), sizeof(type))) -#define RECREATE(result, type, number) ((result) = (type *) aRealloc((result), sizeof(type) * (number))) +#define RECREATE(result, type, number) ((result) = (type *) aReallocz((result), sizeof(type) * (number))) //////////////////////////////////////////////// @@ -73,6 +74,7 @@ struct malloc_interface { void* (*malloc )(size_t size, const char *file, int line, const char *func); void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func); void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func); + void* (*reallocz)(void *p, size_t size, const char *file, int line, const char *func); char* (*astrdup )(const char *p, const char *file, int line, const char *func); void (*free )(void *p, const char *file, int line, const char *func); /* */ diff --git a/src/map/map.c b/src/map/map.c index 3a018828a..7ff4ebcc5 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5551,9 +5551,9 @@ int do_init(int argc, char *argv[]) map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); - map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); + map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_CLEAN); - map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); + map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_CLEAN); ers_chunk_size(map->flooritem_ers, 100); if (!minimal) { diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index c94e42d5d..6a13ef2a0 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -291,7 +291,7 @@ void mapreg_final(void) { void mapreg_init(void) { mapreg->db = idb_alloc(DB_OPT_BASE); mapreg->str_db = idb_alloc(DB_OPT_BASE); - mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE); + mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_CLEAN); mapreg->load(); diff --git a/src/map/mob.c b/src/map/mob.c index 90a967d61..d919e7478 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1768,7 +1768,6 @@ int mob_ai_hard(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop); - memset(&drop->item_data, 0, sizeof(struct item)); drop->item_data.nameid = nameid; drop->item_data.amount = qty; drop->item_data.identify = data ? itemdb->isidentified2(data) : itemdb->isidentified(nameid); @@ -4642,7 +4641,7 @@ int do_init_mob(bool minimal) { memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob - item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); + item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_CLEAN); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); mob->load(minimal); diff --git a/src/map/script.c b/src/map/script.c index aa8ac7f63..074348ef0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2940,7 +2940,6 @@ struct script_state* script_alloc_state(struct script_code* rootscript, int pos, struct script_state* st; st = ers_alloc(script->st_ers, struct script_state); - memset(st, 0, sizeof(struct script_state)); st->stack = ers_alloc(script->stack_ers, struct script_stack); st->stack->sp = 0; st->stack->sp_max = 64; @@ -4013,7 +4012,7 @@ void do_init_script(bool minimal) { script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); script->autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0); - script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_NONE); + script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_CLEAN); script->stack_ers = ers_new(sizeof(struct script_stack), "script.c::script_stack", ERS_OPT_NONE); ers_chunk_size(script->st_ers, 10); diff --git a/src/map/skill.c b/src/map/skill.c index 6893a9f57..71e343db0 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17141,10 +17141,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage cd = ers_alloc(skill->cd_ers, struct skill_cd); - - cd->cursor = 0; - memset(cd->entry, 0, sizeof(cd->entry)); - + idb_put( skill->cd_db, sd->status.char_id, cd ); } else { int i; @@ -18215,9 +18212,9 @@ int do_init_skill(bool minimal) { skill->cd_db = idb_alloc(DB_OPT_BASE); skill->usave_db = idb_alloc(DB_OPT_RELEASE_DATA); - skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_NONE); + skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_CLEAN); skill->timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE); - skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR); + skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR|ERS_OPT_CLEAN); skill->cd_entry_ers = ers_new(sizeof(struct skill_cd_entry),"skill.c::skill_cd_entry_ers",ERS_OPT_CLEAR); ers_chunk_size(skill->cd_ers, 25); -- cgit v1.2.3-70-g09d2 From d33469689ea8e671fa0d525d54bce6932dfe9107 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 2 Feb 2014 15:02:14 -0200 Subject: Introducing HPM Datacheck http://hercules.ws/board/topic/4283-introducing-hpm-datacheck/ Signed-off-by: shennetsind --- src/char/char.h | 6 ++-- src/char/int_auction.h | 6 ++-- src/char/int_elemental.h | 6 ++-- src/char/int_guild.h | 6 ++-- src/char/int_homun.h | 6 ++-- src/char/int_mail.h | 6 ++-- src/char/int_mercenary.h | 6 ++-- src/char/int_party.h | 6 ++-- src/char/int_pet.h | 6 ++-- src/char/int_quest.h | 6 ++-- src/char/int_storage.h | 6 ++-- src/char/inter.h | 6 ++-- src/char/pincode.h | 6 ++-- src/common/HPM.c | 26 ++++++++++++++++++ src/common/HPM.h | 8 ++++-- src/common/HPMi.h | 15 ++++++---- src/common/atomic.h | 6 ++-- src/common/cbasetypes.h | 6 ++-- src/common/conf.h | 6 ++-- src/common/console.h | 6 ++-- src/common/core.h | 6 ++-- src/common/db.h | 6 ++-- src/common/des.h | 6 ++-- src/common/ers.h | 6 ++-- src/common/grfio.h | 6 ++-- src/common/malloc.h | 6 ++-- src/common/mapindex.h | 6 ++-- src/common/md5calc.h | 6 ++-- src/common/mmo.h | 6 ++-- src/common/mutex.h | 6 ++-- src/common/nullpo.h | 6 ++-- src/common/random.h | 6 ++-- src/common/showmsg.h | 6 ++-- src/common/socket.h | 6 ++-- src/common/spinlock.h | 6 ++-- src/common/strlib.h | 6 ++-- src/common/thread.h | 6 ++-- src/common/timer.h | 8 ++++-- src/common/utils.h | 6 ++-- src/config/const.h | 7 +++-- src/login/account.h | 6 ++-- src/login/ipban.h | 6 ++-- src/login/login.h | 6 ++-- src/login/loginlog.h | 6 ++-- src/map/HPMmap.c | 71 ++++++++++++++++++++++++++++++++++++++++-------- src/map/HPMmap.h | 10 +++++-- src/map/atcommand.h | 6 ++-- src/map/battle.h | 6 ++-- src/map/battleground.h | 6 ++-- src/map/buyingstore.h | 6 ++-- src/map/chat.h | 6 ++-- src/map/chrif.h | 6 ++-- src/map/clif.h | 6 ++-- src/map/date.h | 6 ++-- src/map/duel.h | 6 ++-- src/map/elemental.h | 6 ++-- src/map/guild.h | 6 ++-- src/map/homunculus.h | 6 ++-- src/map/instance.h | 6 ++-- src/map/intif.h | 6 ++-- src/map/irc-bot.h | 6 ++-- src/map/itemdb.h | 6 ++-- src/map/log.h | 6 ++-- src/map/mail.h | 6 ++-- src/map/map.c | 2 ++ src/map/map.h | 6 ++-- src/map/mapreg.h | 6 ++-- src/map/mercenary.h | 6 ++-- src/map/mob.h | 6 ++-- src/map/npc.h | 6 ++-- src/map/packets.h | 6 ++-- src/map/packets_struct.h | 6 ++-- src/map/party.h | 6 ++-- src/map/path.h | 6 ++-- src/map/pc.h | 7 +++-- src/map/pc_groups.h | 6 ++-- src/map/pet.h | 6 ++-- src/map/quest.h | 6 ++-- src/map/script.h | 6 ++-- src/map/searchstore.h | 6 ++-- src/map/skill.h | 6 ++-- src/map/status.h | 6 ++-- src/map/storage.h | 6 ++-- src/map/trade.h | 7 +++-- src/map/unit.h | 11 ++++---- src/map/vending.h | 6 ++-- 86 files changed, 357 insertions(+), 265 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/char/char.h b/src/char/char.h index 3e3774c1f..06c0556c5 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CHAR_SQL_H_ -#define _CHAR_SQL_H_ +#ifndef _COMMON_CHAR_H_ +#define _COMMON_CHAR_H_ #include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST @@ -121,4 +121,4 @@ void global_accreg_to_login_start (int account_id, int char_id); void global_accreg_to_login_send (void); void global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string); -#endif /* _CHAR_SQL_H_ */ +#endif /* _COMMON_CHAR_H_ */ diff --git a/src/char/int_auction.h b/src/char/int_auction.h index bf26b152c..f10794f73 100644 --- a/src/char/int_auction.h +++ b/src/char/int_auction.h @@ -1,12 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_AUCTION_SQL_H_ -#define _INT_AUCTION_SQL_H_ +#ifndef _CHAR_INT_AUCTION_H_ +#define _CHAR_INT_AUCTION_H_ int inter_auction_parse_frommap(int fd); int inter_auction_sql_init(void); void inter_auction_sql_final(void); -#endif /* _INT_AUCTION_SQL_H_ */ +#endif /* _CHAR_INT_AUCTION_H_ */ diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index 7eb5c2958..c90891fc4 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_ELEMENTAL_SQL_H_ -#define _INT_ELEMENTAL_SQL_H_ +#ifndef _CHAR_INT_ELEMENTAL_H_ +#define _CHAR_INT_ELEMENTAL_H_ struct s_elemental; @@ -12,4 +12,4 @@ int inter_elemental_parse_frommap(int fd); bool mapif_elemental_delete(int ele_id); -#endif /* _INT_ELEMENTAL_SQL_H_ */ +#endif /* _CHAR_INT_ELEMENTAL_H_ */ diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 47c42dcc5..4eb7d310b 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_GUILD_SQL_H_ -#define _INT_GUILD_SQL_H_ +#ifndef _CHAR_INT_GUILD_H_ +#define _CHAR_INT_GUILD_H_ enum { GS_BASIC = 0x0001, @@ -34,4 +34,4 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char int inter_guild_CharOnline(int char_id, int guild_id); int inter_guild_CharOffline(int char_id, int guild_id); -#endif /* _INT_GUILD_SQL_H_ */ +#endif /* _CHAR_INT_GUILD_H_ */ diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 1c0d76269..561dc848f 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_HOMUN_SQL_H_ -#define _INT_HOMUN_SQL_H_ +#ifndef _CHAR_INT_HOMUN_H_ +#define _CHAR_INT_HOMUN_H_ struct s_homunculus; @@ -15,4 +15,4 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd); bool mapif_homunculus_delete(int homun_id); bool mapif_homunculus_rename(char *name); -#endif /* _INT_HOMUN_SQL_H_ */ +#endif /* _CHAR_INT_HOMUN_H_ */ diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 77db51e5b..7c06cdc1f 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_MAIL_SQL_H_ -#define _INT_MAIL_SQL_H_ +#ifndef _CHAR_INT_MAIL_H_ +#define _CHAR_INT_MAIL_H_ int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); @@ -13,4 +13,4 @@ void inter_mail_sql_final(void); int mail_savemessage(struct mail_message* msg); void mapif_Mail_new(struct mail_message *msg); -#endif /* _INT_MAIL_SQL_H_ */ +#endif /* _CHAR_INT_MAIL_H_ */ diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 01e4a841f..b614b8cf7 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_MERCENARY_SQL_H_ -#define _INT_MERCENARY_SQL_H_ +#ifndef _CHAR_INT_MERCENARY_H_ +#define _CHAR_INT_MERCENARY_H_ struct s_mercenary; @@ -17,4 +17,4 @@ bool mercenary_owner_delete(int char_id); bool mapif_mercenary_delete(int merc_id); -#endif /* _INT_MERCENARY_SQL_H_ */ +#endif /* _CHAR_INT_MERCENARY_H_ */ diff --git a/src/char/int_party.h b/src/char/int_party.h index d8cdcdc6a..84f00635a 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_PARTY_SQL_H_ -#define _INT_PARTY_SQL_H_ +#ifndef _CHAR_INT_PARTY_H_ +#define _CHAR_INT_PARTY_H_ //Party Flags on what to save/delete. enum { @@ -23,4 +23,4 @@ int inter_party_leave(int party_id,int account_id, int char_id); int inter_party_CharOnline(int char_id, int party_id); int inter_party_CharOffline(int char_id, int party_id); -#endif /* _INT_PARTY_SQL_H_ */ +#endif /* _CHAR_INT_PARTY_H_ */ diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 733468c77..a16cb7a37 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_PET_SQL_H_ -#define _INT_PET_SQL_H_ +#ifndef _CHAR_INT_PET_H_ +#define _CHAR_INT_PET_H_ struct s_pet; @@ -18,4 +18,4 @@ int inter_pet_sql_init(void); //Exported for use in the TXT-SQL converter. int inter_pet_tosql(int pet_id, struct s_pet *p); -#endif /* _INT_PET_SQL_H_ */ +#endif /* _CHAR_INT_PET_H_ */ diff --git a/src/char/int_quest.h b/src/char/int_quest.h index b0403f436..6267c74ad 100644 --- a/src/char/int_quest.h +++ b/src/char/int_quest.h @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _QUEST_H_ -#define _QUEST_H_ +#ifndef _CHAR_QUEST_H_ +#define _CHAR_QUEST_H_ int inter_quest_parse_frommap(int fd); -#endif +#endif /* _CHAR_QUEST_H_ */ diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 811608f82..1693499a5 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _INT_STORAGE_SQL_H_ -#define _INT_STORAGE_SQL_H_ +#ifndef _CHAR_INT_STORAGE_H_ +#define _CHAR_INT_STORAGE_H_ struct storage_data; struct guild_storage; @@ -19,4 +19,4 @@ int storage_fromsql(int account_id, struct storage_data* p); int storage_tosql(int account_id,struct storage_data *p); int guild_storage_tosql(int guild_id, struct guild_storage *p); -#endif /* _INT_STORAGE_SQL_H_ */ +#endif /* _CHAR_INT_STORAGE_H_ */ diff --git a/src/char/inter.h b/src/char/inter.h index 9b958dc72..2c07b20e2 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _INTER_SQL_H_ -#define _INTER_SQL_H_ +#ifndef _CHAR_INTER_H_ +#define _CHAR_INTER_H_ struct accreg; #include "../common/sql.h" @@ -41,4 +41,4 @@ uint64 inter_chk_lastuid(int8 flag, uint64 value); #define updateLastUid(val_) #endif -#endif /* _INTER_SQL_H_ */ +#endif /* _CHAR_INTER_H_ */ diff --git a/src/char/pincode.h b/src/char/pincode.h index a17f70de5..3b71eec7c 100644 --- a/src/char/pincode.h +++ b/src/char/pincode.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PINCODE_H_ -#define _PINCODE_H_ +#ifndef _CHAR_PINCODE_H_ +#define _CHAR_PINCODE_H_ #include "char.h" @@ -40,4 +40,4 @@ struct pincode_interface *pincode; void pincode_defaults(void); -#endif /* _PINCODE_H_ */ +#endif /* _CHAR_PINCODE_H_ */ diff --git a/src/common/HPM.c b/src/common/HPM.c index 1edf24901..cf296e593 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -116,6 +116,8 @@ struct hplugin *hplugin_load(const char* filename) { bool anyEvent = false; void **import_symbol_ref; Sql **sql_handle; + unsigned int *HPMDataCheckLen; + struct s_HPMDataCheck *HPMDataCheck; if( HPM->exists(filename) ) { ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); @@ -203,6 +205,24 @@ struct hplugin *hplugin_load(const char* filename) { if( !HPM->populate(plugin,filename) ) return NULL; + if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) { + ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename); + HPM->unload(plugin); + return NULL; + } + + if( !( HPMDataCheck = plugin_import(plugin->dll, "HPMDataCheck", struct s_HPMDataCheck *) ) ) { + ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename); + HPM->unload(plugin); + return NULL; + } + + if( !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,plugin->info->name) ) { + ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin), skipping...\n", filename); + HPM->unload(plugin); + return NULL; + } + /* id */ plugin->hpi->pid = plugin->idx; /* core */ @@ -255,6 +275,11 @@ void hplugins_config_read(void) { const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name FILE *fp; + if( !HPM->DataCheck ) { + ShowError("HPM:config_read: HPM->DataCheck not set! Failure\n"); + return; + } + /* yes its ugly, its temporary and will be gone as soon as the new inter-server.conf is set */ if( (fp = fopen("conf/import/plugins.conf","r")) ) { config_filename = "conf/import/plugins.conf"; @@ -829,4 +854,5 @@ void hpm_defaults(void) { HPM->grabHPData = hplugins_grabHPData; HPM->grabHPDataSub = NULL; HPM->parseConf = hplugins_parse_conf; + HPM->DataCheck = NULL; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 393f8f819..52ad24a03 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _HPM_H_ -#define _HPM_H_ +#ifndef _COMMON_HPM_H_ +#define _COMMON_HPM_H_ #include "../common/cbasetypes.h" #include "../common/HPMi.h" @@ -146,10 +146,12 @@ struct HPM_interface { bool (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); /* for custom config parsing */ bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point); + /* validates plugin data */ + bool (*DataCheck) (struct s_HPMDataCheck *src, unsigned int size, char *name); } HPM_s; struct HPM_interface *HPM; void hpm_defaults(void); -#endif /* _HPM_H_ */ +#endif /* _COMMON_HPM_H_ */ diff --git a/src/common/HPMi.h b/src/common/HPMi.h index fdb6ccf52..b33ad955c 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _HPMi_H_ -#define _HPMi_H_ +#ifndef _COMMON_HPMi_H_ +#define _COMMON_HPMi_H_ #include "../common/cbasetypes.h" #include "../common/core.h" @@ -20,7 +20,7 @@ struct map_session_data; #define HPExport #endif -#ifndef _SHOWMSG_H_ +#ifndef _COMMON_SHOWMSG_H_ HPExport void (*ShowMessage) (const char *, ...); HPExport void (*ShowStatus) (const char *, ...); HPExport void (*ShowSQL) (const char *, ...); @@ -45,6 +45,11 @@ struct hplugin_info { char* req_version; }; +struct s_HPMDataCheck { + char *name; + unsigned int size; +}; + HPExport void *(*import_symbol) (char *name, unsigned int pID); HPExport Sql *mysql_handle; @@ -187,8 +192,8 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef _HPM_H_ +#ifndef _COMMON_HPM_H_ HPExport struct HPMi_interface *HPMi; #endif -#endif /* _HPMi_H_ */ +#endif /* _COMMON_HPMi_H_ */ diff --git a/src/common/atomic.h b/src/common/atomic.h index 5a2ddb4f0..c2227a9d4 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -1,8 +1,8 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _rA_ATOMIC_H_ -#define _rA_ATOMIC_H_ +#ifndef _COMMON_ATOMIC_H_ +#define _COMMON_ATOMIC_H_ // Atomic Operations // (Interlocked CompareExchange, Add .. and so on ..) @@ -144,4 +144,4 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ #endif //endif compiler decission -#endif +#endif /* _COMMON_ATOMIC_H_ */ diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 977897506..654334a9b 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -1,5 +1,5 @@ -#ifndef _CBASETYPES_H_ -#define _CBASETYPES_H_ +#ifndef _COMMON_CBASETYPES_H_ +#define _COMMON_CBASETYPES_H_ /* +--------+-----------+--------+---------+ * | ILP32 | LP64 | ILP64 | (LL)P64 | @@ -431,4 +431,4 @@ void SET_FUNCPOINTER(T1& var, T2 p) #endif -#endif /* _CBASETYPES_H_ */ +#endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.h b/src/common/conf.h index 05e2b1ada..9aff3df47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONF_H_ -#define _CONF_H_ +#ifndef _COMMON_CONF_H_ +#define _COMMON_CONF_H_ #include "../common/cbasetypes.h" #include "../../3rdparty/libconfig/libconfig.h" @@ -94,4 +94,4 @@ struct libconfig_interface *libconfig; void libconfig_defaults(void); -#endif // _CONF_H_ +#endif // _COMMON_CONF_H_ diff --git a/src/common/console.h b/src/common/console.h index 1beed964a..513c769ff 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ +#ifndef _COMMON_CONSOLE_H_ +#define _COMMON_CONSOLE_H_ #include "../common/thread.h" #include "../common/mutex.h" @@ -72,4 +72,4 @@ struct console_interface *console; void console_defaults(void); -#endif /* _CONSOLE_H_ */ +#endif /* _COMMON_CONSOLE_H_ */ diff --git a/src/common/core.h b/src/common/core.h index 8fdcdcfc3..72f956e1d 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CORE_H_ -#define _CORE_H_ +#ifndef _COMMON_CORE_H_ +#define _COMMON_CORE_H_ #include "../common/db.h" #include "../common/mmo.h" @@ -50,4 +50,4 @@ enum E_CORE_ST { /// If NULL, runflag is set to CORE_ST_STOP instead. extern void (*shutdown_callback)(void); -#endif /* _CORE_H_ */ +#endif /* _COMMON_CORE_H_ */ diff --git a/src/common/db.h b/src/common/db.h index c00489b93..67abe6f19 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -39,8 +39,8 @@ * @encoding US-ASCII * * @see common#db.c * \*****************************************************************************/ -#ifndef _DB_H_ -#define _DB_H_ +#ifndef _COMMON_DB_H_ +#define _COMMON_DB_H_ #include "../common/cbasetypes.h" #include @@ -1548,4 +1548,4 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); -#endif /* _DB_H_ */ +#endif /* _COMMON_DB_H_ */ diff --git a/src/common/des.h b/src/common/des.h index e42136436..3f55448ba 100644 --- a/src/common/des.h +++ b/src/common/des.h @@ -1,7 +1,7 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _DES_H_ -#define _DES_H_ +#ifndef _COMMON_DES_H_ +#define _COMMON_DES_H_ /// One 64-bit block. @@ -12,4 +12,4 @@ void des_decrypt_block(BIT64* block); void des_decrypt(unsigned char* data, size_t size); -#endif // _DES_H_ +#endif // _COMMON_DES_H_ diff --git a/src/common/ers.h b/src/common/ers.h index d74ee02a5..4dae19f3b 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -37,8 +37,8 @@ * @author Flavio @ Amazon Project * * @encoding US-ASCII * \*****************************************************************************/ -#ifndef _ERS_H_ -#define _ERS_H_ +#ifndef _COMMON_ERS_H_ +#define _COMMON_ERS_H_ #include "../common/cbasetypes.h" @@ -180,4 +180,4 @@ void ers_report(void); void ers_force_destroy_all(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ -#endif /* _ERS_H_ */ +#endif /* _COMMON_ERS_H_ */ diff --git a/src/common/grfio.h b/src/common/grfio.h index a88b20393..4f5d0d6bc 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _GRFIO_H_ -#define _GRFIO_H_ +#ifndef _COMMON_GRFIO_H_ +#define _COMMON_GRFIO_H_ void grfio_init(const char* fname); void grfio_final(void); @@ -14,4 +14,4 @@ unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); -#endif /* _GRFIO_H_ */ +#endif /* _COMMON_GRFIO_H_ */ diff --git a/src/common/malloc.h b/src/common/malloc.h index 19b5213bb..7309bb0f7 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _MALLOC_H_ -#define _MALLOC_H_ +#ifndef _COMMON_MALLOC_H_ +#define _COMMON_MALLOC_H_ #include "../common/cbasetypes.h" @@ -88,4 +88,4 @@ struct malloc_interface { void memmgr_report (int extra); struct malloc_interface *iMalloc; -#endif /* _MALLOC_H_ */ +#endif /* _COMMON_MALLOC_H_ */ diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 98150f441..fa9b9e920 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAPINDEX_H_ -#define _MAPINDEX_H_ +#ifndef _COMMON_MAPINDEX_H_ +#define _COMMON_MAPINDEX_H_ #include "../common/db.h" #include "../common/mmo.h" @@ -90,4 +90,4 @@ struct mapindex_interface *mapindex; void mapindex_defaults(void); -#endif /* _MAPINDEX_H_ */ +#endif /* _COMMON_MAPINDEX_H_ */ diff --git a/src/common/md5calc.h b/src/common/md5calc.h index 323affa2c..d0caf6787 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -1,8 +1,8 @@ -#ifndef _MD5CALC_H_ -#define _MD5CALC_H_ +#ifndef _COMMON_MD5CALC_H_ +#define _COMMON_MD5CALC_H_ void MD5_String(const char * string, char * output); void MD5_Binary(const char * string, unsigned char * output); void MD5_Salt(unsigned int len, char * output); -#endif /* _MD5CALC_H_ */ +#endif /* _COMMON_MD5CALC_H_ */ diff --git a/src/common/mmo.h b/src/common/mmo.h index 573962601..2b66c516c 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MMO_H_ -#define _MMO_H_ +#ifndef _COMMON_MMO_H_ +#define _COMMON_MMO_H_ #include "cbasetypes.h" #include "../common/db.h" @@ -886,4 +886,4 @@ enum e_pc_reg_loading { #error MAX_ZENY is too big #endif -#endif /* _MMO_H_ */ +#endif /* _COMMON_MMO_H_ */ diff --git a/src/common/mutex.h b/src/common/mutex.h index 1999627cd..eeb24e6ff 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -1,8 +1,8 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _rA_MUTEX_H_ -#define _rA_MUTEX_H_ +#ifndef _COMMON_MUTEX_H_ +#define _COMMON_MUTEX_H_ typedef struct ramutex *ramutex; // Mutex @@ -89,4 +89,4 @@ void racond_signal( racond c ); void racond_broadcast( racond c ); -#endif +#endif /* _COMMON_MUTEX_H_ */ diff --git a/src/common/nullpo.h b/src/common/nullpo.h index 581252cca..fb1cf0feb 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef COMMON_NULLPO_H -#define COMMON_NULLPO_H +#ifndef _COMMON_NULLPO_H_ +#define _COMMON_NULLPO_H_ #include "../common/cbasetypes.h" @@ -125,4 +125,4 @@ void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title); -#endif /* COMMON_NULLPO_H */ +#endif /* _COMMON_NULLPO_H_ */ diff --git a/src/common/random.h b/src/common/random.h index 43dfd36c0..ab83fb4d4 100644 --- a/src/common/random.h +++ b/src/common/random.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _RANDOM_H_ -#define _RANDOM_H_ +#ifndef _COMMON_RANDOM_H_ +#define _COMMON_RANDOM_H_ #include "../common/cbasetypes.h" @@ -15,4 +15,4 @@ int32 rnd_value(int32 min, int32 max);// [min, max] double rnd_uniform(void);// [0.0, 1.0) double rnd_uniform53(void);// [0.0, 1.0) -#endif /* _RANDOM_H_ */ +#endif /* _COMMON_RANDOM_H_ */ diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 01eae4480..b59214ab0 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _SHOWMSG_H_ -#define _SHOWMSG_H_ +#ifndef _COMMON_SHOWMSG_H_ +#define _COMMON_SHOWMSG_H_ #ifndef _HPMi_H_ #include "../../3rdparty/libconfig/libconfig.h" @@ -104,4 +104,4 @@ extern void ClearScreen(void); #endif extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); -#endif /* _SHOWMSG_H_ */ +#endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.h b/src/common/socket.h index 6879d2e90..ca9141716 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _SOCKET_H_ -#define _SOCKET_H_ +#ifndef _COMMON_SOCKET_H_ +#define _COMMON_SOCKET_H_ #include "../common/cbasetypes.h" @@ -196,4 +196,4 @@ void socket_defaults(void); #define set_eof(fd) ( sockt->set_eof(fd) ) #endif /* _H_SOCKET_C_ */ -#endif /* _SOCKET_H_ */ +#endif /* _COMMON_SOCKET_H_ */ diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 9b9e4ce94..29fbb355b 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,6 +1,6 @@ #pragma once -#ifndef _rA_SPINLOCK_H_ -#define _rA_SPINLOCK_H_ +#ifndef _COMMON_SPINLOCK_H_ +#define _COMMON_SPINLOCK_H_ // // CAS based Spinlock Implementation @@ -101,4 +101,4 @@ static forceinline void LeaveSpinLock(PSPIN_LOCK lck){ -#endif +#endif /* _COMMON_SPINLOCK_H_ */ diff --git a/src/common/strlib.h b/src/common/strlib.h index 7a1066401..10844d257 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _STRLIB_H_ -#define _STRLIB_H_ +#ifndef _COMMON_STRLIB_H_ +#define _COMMON_STRLIB_H_ #include "../common/cbasetypes.h" #include @@ -191,4 +191,4 @@ void strlib_defaults(void); #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) #endif /* STRLIB_C */ -#endif /* _STRLIB_H_ */ +#endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/thread.h b/src/common/thread.h index a5a66e954..d6b2bbc6e 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -2,8 +2,8 @@ // For more information, see LICENCE in the main folder #pragma once -#ifndef _rA_THREAD_H_ -#define _rA_THREAD_H_ +#ifndef _COMMON_THREAD_H_ +#define _COMMON_THREAD_H_ #include "../common/cbasetypes.h" @@ -116,4 +116,4 @@ void rathread_init(); void rathread_final(); -#endif +#endif /* _COMMON_THREAD_H_ */ diff --git a/src/common/timer.h b/src/common/timer.h index af1a2b036..ab3ffc21f 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -1,8 +1,10 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _TIMER_H_ -#define _TIMER_H_ + +#ifndef _COMMON_TIMER_H_ +#define _COMMON_TIMER_H_ + #include "../common/cbasetypes.h" #define DIFF_TICK(a,b) ((a)-(b)) @@ -65,4 +67,4 @@ struct timer_interface *timer; void timer_defaults(void); -#endif /* _TIMER_H_ */ +#endif /* _COMMON_TIMER_H_ */ diff --git a/src/common/utils.h b/src/common/utils.h index 719e1e533..68dd01ac4 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _UTILS_H_ -#define _UTILS_H_ +#ifndef _COMMON_UTILS_H_ +#define _COMMON_UTILS_H_ #include "../common/cbasetypes.h" #include // FILE* @@ -54,4 +54,4 @@ struct HCache_interface *HCache; void HCache_defaults(void); -#endif /* _UTILS_H_ */ +#endif /* _COMMON_UTILS_H_ */ diff --git a/src/config/const.h b/src/config/const.h index fc82d66f9..6557cb987 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -1,8 +1,9 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _H_CONSTANTS_ -#define _H_CONSTANTS_ + +#ifndef _CONFIG_CONSTANTS_H_ +#define _CONFIG_CONSTANTS_H_ /** * Hercules configuration file (http://hercules.ws) @@ -117,4 +118,4 @@ /** * End of File **/ -#endif /* _H_CONSTANTS_ */ +#endif /* _CONFIG_CONSTANTS_H_ */ diff --git a/src/login/account.h b/src/login/account.h index 74a9e9626..234e7c0c1 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef __ACCOUNT_H_INCLUDED__ -#define __ACCOUNT_H_INCLUDED__ +#ifndef _LOGIN_ACCOUNT_H_ +#define _LOGIN_ACCOUNT_H_ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM @@ -139,4 +139,4 @@ Sql *account_db_sql_up(AccountDB* self); void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id); void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id); -#endif // __ACCOUNT_H_INCLUDED__ +#endif /* _LOGIN_ACCOUNT_H_ */ diff --git a/src/login/ipban.h b/src/login/ipban.h index b2a1a7d9e..e6851d8dd 100644 --- a/src/login/ipban.h +++ b/src/login/ipban.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef __IPBAN_H_INCLUDED__ -#define __IPBAN_H_INCLUDED__ +#ifndef _LOGIN_IPBAN_H_ +#define _LOGIN_IPBAN_H_ #include "../common/cbasetypes.h" @@ -22,4 +22,4 @@ void ipban_log(uint32 ip); bool ipban_config_read(const char* key, const char* value); -#endif // __IPBAN_H_INCLUDED__ +#endif /* _LOGIN_IPBAN_H_ */ diff --git a/src/login/login.h b/src/login/login.h index d6a021125..14c361a15 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _LOGIN_H_ -#define _LOGIN_H_ +#ifndef _LOGIN_LOGIN_H_ +#define _LOGIN_LOGIN_H_ #include "../common/mmo.h" // NAME_LENGTH,SEX_* #include "../common/core.h" // CORE_ST_LAST @@ -100,4 +100,4 @@ extern struct mmo_char_server server[MAX_SERVERS]; extern struct Login_Config login_config; -#endif /* _LOGIN_H_ */ +#endif /* _LOGIN_LOGIN_H_ */ diff --git a/src/login/loginlog.h b/src/login/loginlog.h index a1ffaae85..730fb6e62 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef __LOGINLOG_H_INCLUDED__ -#define __LOGINLOG_H_INCLUDED__ +#ifndef _LOGIN_LOGINLOG_H_ +#define _LOGIN_LOGINLOG_H_ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); @@ -12,4 +12,4 @@ bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); -#endif // __LOGINLOG_H_INCLUDED__ +#endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 4b1338b8d..1688f37ce 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -34,6 +34,8 @@ #include #include +#include "../plugins/HPMDataCheck.h" + struct HPM_atcommand_list { //tracking currently not enabled // - requires modifying how plugins calls atcommand creation @@ -46,6 +48,11 @@ struct HPM_atcommand_list { struct HPM_atcommand_list *atcommand_list = NULL; unsigned int atcommand_list_items = 0; +/** + * (char*) data name -> (unsigned int) HPMDataCheck[] index + **/ +DBMap *datacheck_db; + bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) { /* record address */ switch( type ) { @@ -113,20 +120,28 @@ void HPM_map_atcommands(void) { } } -void HPM_map_do_final(void) { - unsigned char i; +/** + * Called by HPM->DataCheck on a plugins incoming data, ensures data structs in use are matching! + **/ +bool HPM_map_DataCheck (struct s_HPMDataCheck *src, unsigned int size, char *name) { + unsigned int i, j; - if( atcommand_list ) - aFree(atcommand_list); - /** - * why is pcg->HPM being cleared here? because PCG's do_final is not final, - * is used on reload, and would thus cause plugin-provided permissions to go away - **/ - for( i = 0; i < pcg->HPMpermissions_count; i++ ) { - aFree(pcg->HPMpermissions[i].name); + for(i = 0; i < size; i++) { + + if( !strdb_exists(datacheck_db, src[i].name) ) { + ShowError("HPMDataCheck:%s: '%s' was not found\n",name,src[i].name); + return false; + } else { + j = strdb_uiget(datacheck_db, src[i].name);/* not double lookup; exists sets cache to found data */ + ShowDebug("Testing[%s/%s] %u vs %u\n",src[i].name,HPMDataCheck[j].name,src[i].size,HPMDataCheck[j].size); + if( src[i].size != HPMDataCheck[j].size ) { + ShowWarning("HPMDataCheck:%s: '%s' size mismatch %u != %u\n",name,src[i].name,src[i].size,HPMDataCheck[j].size); + return false; + } + } } - if( pcg->HPMpermissions ) - aFree(pcg->HPMpermissions); + + return true; } /** @@ -141,3 +156,35 @@ void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned in pcg->HPMpermissions[index].name = aStrdup(name); pcg->HPMpermissions[index].mask = mask; } + +void HPM_map_do_init(void) { + unsigned int i; + + /** + * Populates datacheck_db for easy lookup later on + **/ + datacheck_db = strdb_alloc(DB_OPT_BASE,0); + + for(i = 0; i < HPMDataCheckLen; i++) { + strdb_uiput(datacheck_db, HPMDataCheck[i].name, i); + } + +} + +void HPM_map_do_final(void) { + unsigned char i; + + if( atcommand_list ) + aFree(atcommand_list); + /** + * why is pcg->HPM being cleared here? because PCG's do_final is not final, + * is used on reload, and would thus cause plugin-provided permissions to go away + **/ + for( i = 0; i < pcg->HPMpermissions_count; i++ ) { + aFree(pcg->HPMpermissions[i].name); + } + if( pcg->HPMpermissions ) + aFree(pcg->HPMpermissions); + + db_destroy(datacheck_db); +} diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h index ff8cf4c74..f291575fb 100644 --- a/src/map/HPMmap.h +++ b/src/map/HPMmap.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _HPM_MAP_ -#define _HPM_MAP_ +#ifndef _MAP_HPMMAP_H_ +#define _MAP_HPMMAP_H_ #include "../common/cbasetypes.h" #include "../map/atcommand.h" @@ -22,4 +22,8 @@ void HPM_map_do_final(void); void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask); -#endif /* _HPM_MAP_ */ +bool HPM_map_DataCheck(struct s_HPMDataCheck *src, unsigned int size, char *name); + +void HPM_map_do_init(void); + +#endif /* _MAP_HPMMAP_H_ */ diff --git a/src/map/atcommand.h b/src/map/atcommand.h index f95940924..39f7cc2b2 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _ATCOMMAND_H_ -#define _ATCOMMAND_H_ +#ifndef _MAP_ATCOMMAND_H_ +#define _MAP_ATCOMMAND_H_ #include "../common/conf.h" #include "../common/db.h" @@ -121,4 +121,4 @@ void atcommand_defaults(void); /* stay here */ #define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) -#endif /* _ATCOMMAND_H_ */ +#endif /* _MAP_ATCOMMAND_H_ */ diff --git a/src/map/battle.h b/src/map/battle.h index 98f2e37e8..0fcef7292 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _BATTLE_H_ -#define _BATTLE_H_ +#ifndef _MAP_BATTLE_H_ +#define _MAP_BATTLE_H_ #include "../common/cbasetypes.h" #include "map.h" //ELE_MAX @@ -596,4 +596,4 @@ struct battle_interface { struct battle_interface *battle; void battle_defaults(void); -#endif /* _BATTLE_H_ */ +#endif /* _MAP_BATTLE_H_ */ diff --git a/src/map/battleground.h b/src/map/battleground.h index 4aeb9f879..ed7347566 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _BATTLEGROUND_H_ -#define _BATTLEGROUND_H_ +#ifndef _MAP_BATTLEGROUND_H_ +#define _MAP_BATTLEGROUND_H_ #include "../common/mmo.h" // struct party #include "clif.h" @@ -112,4 +112,4 @@ struct battleground_interface *bg; void battleground_defaults(void); -#endif /* _BATTLEGROUND_H_ */ +#endif /* _MAP_BATTLEGROUND_H_ */ diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index b0db40661..5141a1013 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _BUYINGSTORE_H_ -#define _BUYINGSTORE_H_ +#ifndef _MAP_BUYINGSTORE_H_ +#define _MAP_BUYINGSTORE_H_ /** * Declarations @@ -70,4 +70,4 @@ struct buyingstore_interface *buyingstore; void buyingstore_defaults (void); -#endif // _BUYINGSTORE_H_ +#endif // _MAP_BUYINGSTORE_H_ diff --git a/src/map/chat.h b/src/map/chat.h index fcbadf008..71e5a11ec 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CHAT_H_ -#define _CHAT_H_ +#ifndef _MAP_CHAT_H_ +#define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE @@ -55,4 +55,4 @@ struct chat_interface *chat; void chat_defaults(void); -#endif /* _CHAT_H_ */ +#endif /* _MAP_CHAT_H_ */ diff --git a/src/map/chrif.h b/src/map/chrif.h index 163fdf670..59e45a2ea 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CHRIF_H_ -#define _CHRIF_H_ +#ifndef _MAP_CHRIF_H_ +#define _MAP_CHRIF_H_ #include "../common/cbasetypes.h" #include @@ -148,4 +148,4 @@ void chrif_defaults(void); // There's no need for another function when a simple macro can do exactly the same effect #define chrif_char_offline(x) chrif->char_offline_nsd((x)->status.account_id,(x)->status.char_id) -#endif /* _CHRIF_H_ */ +#endif /* _MAP_CHRIF_H_ */ diff --git a/src/map/clif.h b/src/map/clif.h index 6405bbd3e..1e0319b7b 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CLIF_H_ -#define _CLIF_H_ +#ifndef _MAP_CLIF_H_ +#define _MAP_CLIF_H_ #include "../common/cbasetypes.h" #include "../common/db.h" @@ -1275,4 +1275,4 @@ struct clif_interface *clif; void clif_defaults(void); -#endif /* _CLIF_H_ */ +#endif /* _MAP_CLIF_H_ */ diff --git a/src/map/date.h b/src/map/date.h index cc19d88d1..02238d7ea 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _DATE_H_ -#define _DATE_H_ +#ifndef _MAP_DATE_H_ +#define _MAP_DATE_H_ int date_get_year(void); int date_get_month(void); @@ -15,4 +15,4 @@ int is_day_of_sun(void); int is_day_of_moon(void); int is_day_of_star(void); -#endif /* _DATE_H_ */ +#endif /* _MAP_DATE_H_ */ diff --git a/src/map/duel.h b/src/map/duel.h index d60c9531a..5405d2eee 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _DUEL_H_ -#define _DUEL_H_ +#ifndef _MAP_DUEL_H_ +#define _MAP_DUEL_H_ struct duel { int members_count; @@ -42,4 +42,4 @@ struct duel_interface *duel; void duel_defaults(void); -#endif /* _DUEL_H_ */ +#endif /* _MAP_DUEL_H_ */ diff --git a/src/map/elemental.h b/src/map/elemental.h index 830a6a577..6d04a41a5 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _ELEMENTAL_H_ -#define _ELEMENTAL_H_ +#ifndef _MAP_ELEMENTAL_H_ +#define _MAP_ELEMENTAL_H_ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data @@ -120,4 +120,4 @@ struct elemental_interface *elemental; void elemental_defaults(void); -#endif /* _ELEMENTAL_H_ */ +#endif /* _MAP_ELEMENTAL_H_ */ diff --git a/src/map/guild.h b/src/map/guild.h index 7878d75c3..b03bd664d 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _GUILD_H_ -#define _GUILD_H_ +#ifndef _MAP_GUILD_H_ +#define _MAP_GUILD_H_ //#include "../common/mmo.h" #include "map.h" // NAME_LENGTH @@ -173,4 +173,4 @@ struct guild_interface *guild; void guild_defaults(void); -#endif /* _GUILD_H_ */ +#endif /* _MAP_GUILD_H_ */ diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 117f9da8e..db250f511 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _HOMUNCULUS_H_ -#define _HOMUNCULUS_H_ +#ifndef _MAP_HOMUNCULUS_H_ +#define _MAP_HOMUNCULUS_H_ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data @@ -146,4 +146,4 @@ struct homunculus_interface *homun; void homunculus_defaults(void); -#endif /* _HOMUNCULUS_H_ */ +#endif /* _MAP_HOMUNCULUS_H_ */ diff --git a/src/map/instance.h b/src/map/instance.h index 764a55b2b..66a7d0d6c 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _INSTANCE_H_ -#define _INSTANCE_H_ +#ifndef _MAP_INSTANCE_H_ +#define _MAP_INSTANCE_H_ #define INSTANCE_NAME_LENGTH (60+1) @@ -82,4 +82,4 @@ struct instance_interface *instance; void instance_defaults(void); -#endif +#endif /* _MAP_INSTANCE_H_ */ diff --git a/src/map/intif.h b/src/map/intif.h index f0bb5c16e..290dcfcdc 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _INTIF_H_ -#define _INFIF_H_ +#ifndef _MAP_INTIF_H_ +#define _MAP_INTIF_H_ /** @@ -183,4 +183,4 @@ struct intif_interface *intif; void intif_defaults(void); -#endif /* _INTIF_H_ */ +#endif /* _MAP_INTIF_H_ */ diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 7d6a19eba..c15a5d46a 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -3,8 +3,8 @@ // Base Author: shennetsind @ http://hercules.ws -#ifndef _IRC_BOT_H_ -#define _IRC_BOT_H_ +#ifndef _MAP_IRC_BOT_H_ +#define _MAP_IRC_BOT_H_ #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 @@ -61,4 +61,4 @@ struct irc_bot_interface *ircbot; void ircbot_defaults(void); -#endif /* _IRC_BOT_H_ */ +#endif /* _MAP_IRC_BOT_H_ */ diff --git a/src/map/itemdb.h b/src/map/itemdb.h index b3ff606df..74ced13e0 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _ITEMDB_H_ -#define _ITEMDB_H_ +#ifndef _MAP_ITEMDB_H_ +#define _MAP_ITEMDB_H_ #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH @@ -582,4 +582,4 @@ struct itemdb_interface *itemdb; void itemdb_defaults(void); -#endif /* _ITEMDB_H_ */ +#endif /* _MAP_ITEMDB_H_ */ diff --git a/src/map/log.h b/src/map/log.h index 9864a54d7..b2cb92c20 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _LOG_H_ -#define _LOG_H_ +#ifndef _MAP_LOG_H_ +#define _MAP_LOG_H_ #include "../common/cbasetypes.h" #include "../common/sql.h" @@ -134,4 +134,4 @@ struct log_interface *logs; void log_defaults(void); -#endif /* _LOG_H_ */ +#endif /* _MAP_LOG_H_ */ diff --git a/src/map/mail.h b/src/map/mail.h index b2b9048cb..8df537ff3 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAIL_H_ -#define _MAIL_H_ +#ifndef _MAP_MAIL_H_ +#define _MAP_MAIL_H_ #include "../common/mmo.h" @@ -23,4 +23,4 @@ struct mail_interface *mail; void mail_defaults(void); -#endif /* _MAIL_H_ */ +#endif /* _MAP_MAIL_H_ */ diff --git a/src/map/map.c b/src/map/map.c index 33721b028..2be61587f 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5447,6 +5447,8 @@ int do_init(int argc, char *argv[]) map_load_defaults(); + HPM_map_do_init(); + HPM->DataCheck = HPM_map_DataCheck; HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; HPM->grabHPDataSub = HPM_map_grabHPData; diff --git a/src/map/map.h b/src/map/map.h index 130b181da..8faf6388e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_H_ -#define _MAP_H_ +#ifndef _MAP_MAP_H_ +#define _MAP_MAP_H_ #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST @@ -1066,4 +1066,4 @@ struct map_interface *map; void map_defaults(void); -#endif /* _MAP_H_ */ +#endif /* _MAP_MAP_H_ */ diff --git a/src/map/mapreg.h b/src/map/mapreg.h index 157e634cc..c92b6f602 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAPREG_H_ -#define _MAPREG_H_ +#ifndef _MAP_MAPREG_H_ +#define _MAP_MAPREG_H_ #include "../common/cbasetypes.h" #include "../common/db.h" @@ -51,4 +51,4 @@ struct mapreg_interface *mapreg; void mapreg_defaults(void); -#endif /* _MAPREG_H_ */ +#endif /* _MAP_MAPREG_H_ */ diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 3f2214b65..dd9266b2e 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MERCENARY_H_ -#define _MERCENARY_H_ +#ifndef _MAP_MERCENARY_H_ +#define _MAP_MERCENARY_H_ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data @@ -98,4 +98,4 @@ struct mercenary_interface *mercenary; void mercenary_defaults(void); -#endif /* _MERCENARY_H_ */ +#endif /* _MAP_MERCENARY_H_ */ diff --git a/src/map/mob.h b/src/map/mob.h index 9321cb4fd..80175b1db 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MOB_H_ -#define _MOB_H_ +#ifndef _MAP_MOB_H_ +#define _MAP_MOB_H_ #include "../common/mmo.h" // struct item #include "guild.h" // struct guardian_data @@ -364,4 +364,4 @@ struct mob_interface *mob; void mob_defaults(void); -#endif /* _MOB_H_ */ +#endif /* _MAP_MOB_H_ */ diff --git a/src/map/npc.h b/src/map/npc.h index 266d174fb..719974ac4 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _NPC_H_ -#define _NPC_H_ +#ifndef _MAP_NPC_H_ +#define _MAP_NPC_H_ #include "map.h" // struct block_list #include "status.h" // struct status_change @@ -346,4 +346,4 @@ struct pcre_interface *libpcre; void npc_chat_defaults(void); #endif -#endif /* _NPC_H_ */ +#endif /* _MAP_NPC_H_ */ diff --git a/src/map/packets.h b/src/map/packets.h index cea916f6d..4cf6f6d6a 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -3,8 +3,8 @@ //Included directly by clif.h in packet_loaddb() -#ifndef _PACKETS_H_ -#define _PACKETS_H_ +#ifndef _MAP_PACKETS_H_ +#define _MAP_PACKETS_H_ #ifndef packet #define packet(a,b,...) @@ -2693,4 +2693,4 @@ packet(0x020d,-1); packetKeys(OBFUSCATIONKEY1,OBFUSCATIONKEY2,OBFUSCATIONKEY3); #endif -#endif /* _PACKETS_H_ */ +#endif /* _MAP_PACKETS_H_ */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 1156f4465..4a599463a 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -3,8 +3,8 @@ /* Hercules Renewal: Phase Two http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ */ -#ifndef _PACKETS_STRUCT_H_ -#define _PACKETS_STRUCT_H_ +#ifndef _MAP_PACKETS_STRUCT_H_ +#define _MAP_PACKETS_STRUCT_H_ #include "../common/mmo.h" @@ -945,4 +945,4 @@ struct packet_npc_market_open { #pragma pack(pop) #endif // not NetBSD < 6 / Solaris -#endif /* _PACKETS_STRUCT_H_ */ +#endif /* _MAP_PACKETS_STRUCT_H_ */ diff --git a/src/map/party.h b/src/map/party.h index 051c98af2..05b5309e6 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PARTY_H_ -#define _PARTY_H_ +#ifndef _MAP_PARTY_H_ +#define _MAP_PARTY_H_ #include "../common/mmo.h" // struct party #include "../config/core.h" @@ -141,4 +141,4 @@ struct party_interface *party; void party_defaults(void); -#endif /* _PARTY_H_ */ +#endif /* _MAP_PARTY_H_ */ diff --git a/src/map/path.h b/src/map/path.h index a889a6409..0b67a0120 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PATH_H_ -#define _PATH_H_ +#ifndef _MAP_PATH_H_ +#define _MAP_PATH_H_ #include "map.h" // enum cell_chk @@ -46,4 +46,4 @@ struct path_interface *path; void path_defaults(void); -#endif /* _PATH_H_ */ +#endif /* _MAP_PATH_H_ */ diff --git a/src/map/pc.h b/src/map/pc.h index 487266646..03b3ddca0 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1,8 +1,9 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PC_H_ -#define _PC_H_ + +#ifndef _MAP_PC_H_ +#define _MAP_PC_H_ #include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus #include "../common/ers.h" @@ -1044,4 +1045,4 @@ struct pc_interface *pc; void pc_defaults(void); -#endif /* _PC_H_ */ +#endif /* _MAP_PC_H_ */ diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 3396512ea..5c03f999f 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PC_GROUPS_H_ -#define _PC_GROUPS_H_ +#ifndef _MAP_PC_GROUPS_H_ +#define _MAP_PC_GROUPS_H_ /// PC permissions enum e_pc_permission { @@ -92,4 +92,4 @@ struct pc_groups_interface *pcg; void pc_groups_defaults(void); -#endif // _PC_GROUPS_H_ +#endif /* _MAP_PC_GROUPS_H_ */ diff --git a/src/map/pet.h b/src/map/pet.h index f1a219700..537a50c4b 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _PET_H_ -#define _PET_H_ +#ifndef _MAP_PET_H_ +#define _MAP_PET_H_ #define MAX_PET_DB 300 #define MAX_PETLOOT_SIZE 30 @@ -152,4 +152,4 @@ struct pet_interface *pet; void pet_defaults(void); -#endif /* _PET_H_ */ +#endif /* _MAP_PET_H_ */ diff --git a/src/map/quest.h b/src/map/quest.h index 28815a6c3..e01e35619 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _QUEST_H_ -#define _QUEST_H_ +#ifndef _MAP_QUEST_H_ +#define _MAP_QUEST_H_ #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 @@ -48,4 +48,4 @@ struct quest_interface *quest; void quest_defaults(void); -#endif +#endif /* _MAP_QUEST_H_ */ diff --git a/src/map/script.h b/src/map/script.h index 97db2a775..b7e9e5741 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _SCRIPT_H_ -#define _SCRIPT_H_ +#ifndef _MAP_SCRIPT_H_ +#define _MAP_SCRIPT_H_ #include "../common/strlib.h" //StringBuf #include "../common/cbasetypes.h" @@ -700,4 +700,4 @@ struct script_interface *script; void script_defaults(void); -#endif /* _SCRIPT_H_ */ +#endif /* _MAP_SCRIPT_H_ */ diff --git a/src/map/searchstore.h b/src/map/searchstore.h index d7a327181..827e39053 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _SEARCHSTORE_H_ -#define _SEARCHSTORE_H_ +#ifndef _MAP_SEARCHSTORE_H_ +#define _MAP_SEARCHSTORE_H_ /** * Defines @@ -93,4 +93,4 @@ struct searchstore_interface *searchstore; void searchstore_defaults (void); -#endif // _SEARCHSTORE_H_ +#endif /* _MAP_SEARCHSTORE_H_ */ diff --git a/src/map/skill.h b/src/map/skill.h index 28cb548d2..78829f17e 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _SKILL_H_ -#define _SKILL_H_ +#ifndef _MAP_SKILL_H_ +#define _MAP_SKILL_H_ #include "../common/mmo.h" // MAX_SKILL, struct square #include "../common/db.h" @@ -2015,4 +2015,4 @@ struct skill_interface *skill; void skill_defaults(void); -#endif /* _SKILL_H_ */ +#endif /* _MAP_SKILL_H_ */ diff --git a/src/map/status.h b/src/map/status.h index f319b1506..d3148b4e0 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _STATUS_H_ -#define _STATUS_H_ +#ifndef _MAP_STATUS_H_ +#define _MAP_STATUS_H_ #include "../common/mmo.h" @@ -2012,4 +2012,4 @@ struct status_interface *status; void status_defaults(void); -#endif /* _STATUS_H_ */ +#endif /* _MAP_STATUS_H_ */ diff --git a/src/map/storage.h b/src/map/storage.h index 8a10c9f3b..8f9f904f6 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _STORAGE_H_ -#define _STORAGE_H_ +#ifndef _MAP_STORAGE_H_ +#define _MAP_STORAGE_H_ struct storage_data; struct guild_storage; @@ -59,4 +59,4 @@ struct guild_storage_interface *gstorage; void storage_defaults(void); void gstorage_defaults(void); -#endif /* _STORAGE_H_ */ +#endif /* _MAP_STORAGE_H_ */ diff --git a/src/map/trade.h b/src/map/trade.h index d0b900504..f2c0d4622 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -2,10 +2,11 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _TRADE_H_ -#define _TRADE_H_ +#ifndef _MAP_TRADE_H_ +#define _MAP_TRADE_H_ //Max distance from traders to enable a trade to take place. +//TODO: battle_config candidate? #define TRADE_DISTANCE 2 struct map_session_data; @@ -26,4 +27,4 @@ struct trade_interface *trade; void trade_defaults(void); -#endif /* _TRADE_H_ */ +#endif /* _MAP_TRADE_H_ */ diff --git a/src/map/unit.h b/src/map/unit.h index a2d743875..33fa4e052 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -1,8 +1,9 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams -#ifndef _UNIT_H_ -#define _UNIT_H_ +#ifndef _MAP_UNIT_H_ +#define _MAP_UNIT_H_ //#include "map.h" struct block_list; @@ -125,4 +126,4 @@ struct unit_interface *unit; void unit_defaults(void); -#endif /* _UNIT_H_ */ +#endif /* _MAP_UNIT_H_ */ diff --git a/src/map/vending.h b/src/map/vending.h index b760bf064..b2ba22955 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _VENDING_H_ -#define _VENDING_H_ +#ifndef _MAP_VENDING_H_ +#define _MAP_VENDING_H_ #include "../common/cbasetypes.h" #include "../common/db.h" @@ -35,4 +35,4 @@ struct vending_interface *vending; void vending_defaults(void); -#endif /* _VENDING_H_ */ +#endif /* _MAP_VENDING_H_ */ -- cgit v1.2.3-70-g09d2 From 68e7f53f05dd80e8b4ab9d84c9931df22a6b060c Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 10 Jul 2014 16:59:55 +0200 Subject: Fixed reserved __identifier violations - Complies with CERT DCL37-C - Fixes issue #293 (special thanks to elfring) Signed-off-by: Haru --- src/char/char.h | 6 +- src/char/int_auction.h | 6 +- src/char/int_elemental.h | 6 +- src/char/int_guild.h | 6 +- src/char/int_homun.h | 6 +- src/char/int_mail.h | 6 +- src/char/int_mercenary.h | 6 +- src/char/int_party.h | 6 +- src/char/int_pet.h | 6 +- src/char/int_quest.h | 6 +- src/char/int_storage.h | 6 +- src/char/inter.h | 6 +- src/char/pincode.h | 6 +- src/common/HPM.h | 6 +- src/common/HPMDataCheck.h | 144 ++++++++++++++++++------------------ src/common/HPMi.h | 6 +- src/common/atomic.h | 6 +- src/common/cbasetypes.h | 10 +-- src/common/conf.h | 6 +- src/common/console.h | 6 +- src/common/core.h | 6 +- src/common/db.h | 6 +- src/common/des.h | 6 +- src/common/ers.h | 6 +- src/common/grfio.c | 2 +- src/common/grfio.h | 6 +- src/common/malloc.c | 33 ++++----- src/common/malloc.h | 6 +- src/common/mapindex.h | 6 +- src/common/md5calc.h | 6 +- src/common/mmo.h | 6 +- src/common/mutex.h | 6 +- src/common/nullpo.h | 6 +- src/common/random.h | 6 +- src/common/showmsg.c | 30 ++++---- src/common/showmsg.h | 8 +- src/common/socket.c | 12 +-- src/common/socket.h | 10 +-- src/common/spinlock.h | 6 +- src/common/sql.h | 6 +- src/common/strlib.c | 6 +- src/common/strlib.h | 14 ++-- src/common/sysinfo.h | 6 +- src/common/thread.c | 10 +-- src/common/thread.h | 6 +- src/common/timer.c | 10 +-- src/common/timer.h | 6 +- src/common/utils.h | 6 +- src/config/classes/general.h | 6 +- src/config/const.h | 6 +- src/config/core.h | 6 +- src/config/renewal.h | 6 +- src/config/secure.h | 6 +- src/login/account.h | 6 +- src/login/ipban.h | 6 +- src/login/login.h | 6 +- src/login/loginlog.h | 6 +- src/map/HPMmap.h | 6 +- src/map/atcommand.c | 2 +- src/map/atcommand.h | 6 +- src/map/battle.c | 2 +- src/map/battle.h | 6 +- src/map/battleground.h | 6 +- src/map/buyingstore.h | 6 +- src/map/chat.h | 6 +- src/map/chrif.h | 6 +- src/map/clif.c | 2 +- src/map/clif.h | 6 +- src/map/date.h | 6 +- src/map/duel.h | 6 +- src/map/elemental.h | 6 +- src/map/guild.c | 6 +- src/map/guild.h | 6 +- src/map/homunculus.h | 6 +- src/map/instance.h | 6 +- src/map/intif.c | 2 +- src/map/intif.h | 6 +- src/map/irc-bot.h | 6 +- src/map/itemdb.h | 6 +- src/map/log.h | 6 +- src/map/mail.h | 6 +- src/map/map.h | 10 +-- src/map/mapreg.h | 6 +- src/map/mercenary.h | 6 +- src/map/mob.h | 6 +- src/map/npc.c | 2 +- src/map/npc.h | 6 +- src/map/packets.h | 6 +- src/map/packets_struct.h | 6 +- src/map/party.h | 6 +- src/map/path.h | 6 +- src/map/pc.c | 4 +- src/map/pc.h | 6 +- src/map/pc_groups.h | 6 +- src/map/pet.h | 6 +- src/map/quest.h | 6 +- src/map/script.c | 48 ++++++------ src/map/script.h | 6 +- src/map/searchstore.h | 6 +- src/map/skill.h | 6 +- src/map/status.h | 6 +- src/map/storage.c | 6 +- src/map/storage.h | 8 +- src/map/trade.h | 6 +- src/map/unit.h | 6 +- src/map/vending.h | 6 +- tools/HPMHookGen/HPMDataCheckGen.pl | 8 +- 107 files changed, 441 insertions(+), 446 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/char/char.h b/src/char/char.h index 09a78f6b9..5a70d2ca7 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_CHAR_H_ -#define _COMMON_CHAR_H_ +#ifndef COMMON_CHAR_H +#define COMMON_CHAR_H #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" @@ -123,4 +123,4 @@ void global_accreg_to_login_start (int account_id, int char_id); void global_accreg_to_login_send (void); void global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string); -#endif /* _COMMON_CHAR_H_ */ +#endif /* COMMON_CHAR_H */ diff --git a/src/char/int_auction.h b/src/char/int_auction.h index f10794f73..17fd75a58 100644 --- a/src/char/int_auction.h +++ b/src/char/int_auction.h @@ -1,12 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_AUCTION_H_ -#define _CHAR_INT_AUCTION_H_ +#ifndef CHAR_INT_AUCTION_H +#define CHAR_INT_AUCTION_H int inter_auction_parse_frommap(int fd); int inter_auction_sql_init(void); void inter_auction_sql_final(void); -#endif /* _CHAR_INT_AUCTION_H_ */ +#endif /* CHAR_INT_AUCTION_H */ diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c869e6fc2..e28cfedea 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_ELEMENTAL_H_ -#define _CHAR_INT_ELEMENTAL_H_ +#ifndef CHAR_INT_ELEMENTAL_H +#define CHAR_INT_ELEMENTAL_H #include "../common/cbasetypes.h" @@ -12,4 +12,4 @@ int inter_elemental_parse_frommap(int fd); bool mapif_elemental_delete(int ele_id); -#endif /* _CHAR_INT_ELEMENTAL_H_ */ +#endif /* CHAR_INT_ELEMENTAL_H */ diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 5e657ff06..bc457d86b 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_GUILD_H_ -#define _CHAR_INT_GUILD_H_ +#ifndef CHAR_INT_GUILD_H +#define CHAR_INT_GUILD_H enum { GS_BASIC = 0x0001, @@ -31,4 +31,4 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char int inter_guild_CharOnline(int char_id, int guild_id); int inter_guild_CharOffline(int char_id, int guild_id); -#endif /* _CHAR_INT_GUILD_H_ */ +#endif /* CHAR_INT_GUILD_H */ diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 9477f4f03..6fa4f9dc7 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_HOMUN_H_ -#define _CHAR_INT_HOMUN_H_ +#ifndef CHAR_INT_HOMUN_H +#define CHAR_INT_HOMUN_H #include "../common/cbasetypes.h" @@ -17,4 +17,4 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd); bool mapif_homunculus_delete(int homun_id); bool mapif_homunculus_rename(char *name); -#endif /* _CHAR_INT_HOMUN_H_ */ +#endif /* CHAR_INT_HOMUN_H */ diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 824ba48a3..8800061d7 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_MAIL_H_ -#define _CHAR_INT_MAIL_H_ +#ifndef CHAR_INT_MAIL_H +#define CHAR_INT_MAIL_H struct item; struct mail_message; @@ -16,4 +16,4 @@ void inter_mail_sql_final(void); int mail_savemessage(struct mail_message* msg); void mapif_Mail_new(struct mail_message *msg); -#endif /* _CHAR_INT_MAIL_H_ */ +#endif /* CHAR_INT_MAIL_H */ diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 195a83b34..b03c20de3 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_MERCENARY_H_ -#define _CHAR_INT_MERCENARY_H_ +#ifndef CHAR_INT_MERCENARY_H +#define CHAR_INT_MERCENARY_H #include "../common/cbasetypes.h" @@ -19,4 +19,4 @@ bool mercenary_owner_delete(int char_id); bool mapif_mercenary_delete(int merc_id); -#endif /* _CHAR_INT_MERCENARY_H_ */ +#endif /* CHAR_INT_MERCENARY_H */ diff --git a/src/char/int_party.h b/src/char/int_party.h index 33325b46b..2b24b1d1a 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_PARTY_H_ -#define _CHAR_INT_PARTY_H_ +#ifndef CHAR_INT_PARTY_H +#define CHAR_INT_PARTY_H //Party Flags on what to save/delete. enum { @@ -21,4 +21,4 @@ int inter_party_leave(int party_id,int account_id, int char_id); int inter_party_CharOnline(int char_id, int party_id); int inter_party_CharOffline(int char_id, int party_id); -#endif /* _CHAR_INT_PARTY_H_ */ +#endif /* CHAR_INT_PARTY_H */ diff --git a/src/char/int_pet.h b/src/char/int_pet.h index a16cb7a37..52642fc54 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_PET_H_ -#define _CHAR_INT_PET_H_ +#ifndef CHAR_INT_PET_H +#define CHAR_INT_PET_H struct s_pet; @@ -18,4 +18,4 @@ int inter_pet_sql_init(void); //Exported for use in the TXT-SQL converter. int inter_pet_tosql(int pet_id, struct s_pet *p); -#endif /* _CHAR_INT_PET_H_ */ +#endif /* CHAR_INT_PET_H */ diff --git a/src/char/int_quest.h b/src/char/int_quest.h index 6267c74ad..f0dd370ea 100644 --- a/src/char/int_quest.h +++ b/src/char/int_quest.h @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_QUEST_H_ -#define _CHAR_QUEST_H_ +#ifndef CHAR_QUEST_H +#define CHAR_QUEST_H int inter_quest_parse_frommap(int fd); -#endif /* _CHAR_QUEST_H_ */ +#endif /* CHAR_QUEST_H */ diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 1693499a5..1cef94d98 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHAR_INT_STORAGE_H_ -#define _CHAR_INT_STORAGE_H_ +#ifndef CHAR_INT_STORAGE_H +#define CHAR_INT_STORAGE_H struct storage_data; struct guild_storage; @@ -19,4 +19,4 @@ int storage_fromsql(int account_id, struct storage_data* p); int storage_tosql(int account_id,struct storage_data *p); int guild_storage_tosql(int guild_id, struct guild_storage *p); -#endif /* _CHAR_INT_STORAGE_H_ */ +#endif /* CHAR_INT_STORAGE_H */ diff --git a/src/char/inter.h b/src/char/inter.h index 5e655237e..ab2478ae6 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CHAR_INTER_H_ -#define _CHAR_INTER_H_ +#ifndef CHAR_INTER_H +#define CHAR_INTER_H #include "char.h" #include "../common/sql.h" @@ -30,4 +30,4 @@ extern Sql* lsql_handle; int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); -#endif /* _CHAR_INTER_H_ */ +#endif /* CHAR_INTER_H */ diff --git a/src/char/pincode.h b/src/char/pincode.h index 3b71eec7c..1ed05095e 100644 --- a/src/char/pincode.h +++ b/src/char/pincode.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CHAR_PINCODE_H_ -#define _CHAR_PINCODE_H_ +#ifndef CHAR_PINCODE_H +#define CHAR_PINCODE_H #include "char.h" @@ -40,4 +40,4 @@ struct pincode_interface *pincode; void pincode_defaults(void); -#endif /* _CHAR_PINCODE_H_ */ +#endif /* CHAR_PINCODE_H */ diff --git a/src/common/HPM.h b/src/common/HPM.h index 5667f605a..fe8d45066 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _COMMON_HPM_H_ -#define _COMMON_HPM_H_ +#ifndef COMMON_HPM_H +#define COMMON_HPM_H #ifndef HERCULES_CORE #error You should never include HPM.h from a plugin. @@ -158,4 +158,4 @@ struct HPM_interface *HPM; void hpm_defaults(void); -#endif /* _COMMON_HPM_H_ */ +#endif /* COMMON_HPM_H */ diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index c5ec3771d..79ec36472 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -3,140 +3,140 @@ // // NOTE: This file was auto-generated and should never be manually edited, // as it will get overwritten. -#ifndef _HPM_DATA_CHECK_H_ -#define _HPM_DATA_CHECK_H_ +#ifndef HPM_DATA_CHECK_H +#define HPM_DATA_CHECK_H HPExport const struct s_HPMDataCheck HPMDataCheck[] = { - #ifdef _COMMON_CONF_H_ + #ifdef COMMON_CONF_H { "libconfig_interface", sizeof(struct libconfig_interface) }, #else - #define _COMMON_CONF_H_ - #endif // _COMMON_CONF_H_ - #ifdef _COMMON_DB_H_ + #define COMMON_CONF_H + #endif // COMMON_CONF_H + #ifdef COMMON_DB_H { "DBData", sizeof(struct DBData) }, { "DBIterator", sizeof(struct DBIterator) }, { "DBMap", sizeof(struct DBMap) }, #else - #define _COMMON_DB_H_ - #endif // _COMMON_DB_H_ - #ifdef _COMMON_DES_H_ + #define COMMON_DB_H + #endif // COMMON_DB_H + #ifdef COMMON_DES_H { "BIT64", sizeof(struct BIT64) }, #else - #define _COMMON_DES_H_ - #endif // _COMMON_DES_H_ - #ifdef _COMMON_ERS_H_ + #define COMMON_DES_H + #endif // COMMON_DES_H + #ifdef COMMON_ERS_H { "eri", sizeof(struct eri) }, #else - #define _COMMON_ERS_H_ - #endif // _COMMON_ERS_H_ - #ifdef _COMMON_MAPINDEX_H_ + #define COMMON_ERS_H + #endif // COMMON_ERS_H + #ifdef COMMON_MAPINDEX_H { "mapindex_interface", sizeof(struct mapindex_interface) }, #else - #define _COMMON_MAPINDEX_H_ - #endif // _COMMON_MAPINDEX_H_ - #ifdef _COMMON_MMO_H_ + #define COMMON_MAPINDEX_H + #endif // COMMON_MAPINDEX_H + #ifdef COMMON_MMO_H { "quest", sizeof(struct quest) }, #else - #define _COMMON_MMO_H_ - #endif // _COMMON_MMO_H_ - #ifdef _COMMON_SOCKET_H_ + #define COMMON_MMO_H + #endif // COMMON_MMO_H + #ifdef COMMON_SOCKET_H { "socket_interface", sizeof(struct socket_interface) }, #else - #define _COMMON_SOCKET_H_ - #endif // _COMMON_SOCKET_H_ - #ifdef _COMMON_STRLIB_H_ + #define COMMON_SOCKET_H + #endif // COMMON_SOCKET_H + #ifdef COMMON_STRLIB_H { "StringBuf", sizeof(struct StringBuf) }, { "s_svstate", sizeof(struct s_svstate) }, #else - #define _COMMON_STRLIB_H_ - #endif // _COMMON_STRLIB_H_ - #ifdef _COMMON_SYSINFO_H_ + #define COMMON_STRLIB_H + #endif // COMMON_STRLIB_H + #ifdef COMMON_SYSINFO_H { "sysinfo_interface", sizeof(struct sysinfo_interface) }, #else - #define _COMMON_SYSINFO_H_ - #endif // _COMMON_SYSINFO_H_ - #ifdef _MAP_ATCOMMAND_H_ + #define COMMON_SYSINFO_H + #endif // COMMON_SYSINFO_H + #ifdef MAP_ATCOMMAND_H { "AliasInfo", sizeof(struct AliasInfo) }, { "atcommand_interface", sizeof(struct atcommand_interface) }, #else - #define _MAP_ATCOMMAND_H_ - #endif // _MAP_ATCOMMAND_H_ - #ifdef _MAP_BATTLE_H_ + #define MAP_ATCOMMAND_H + #endif // MAP_ATCOMMAND_H + #ifdef MAP_BATTLE_H { "Damage", sizeof(struct Damage) }, { "battle_interface", sizeof(struct battle_interface) }, #else - #define _MAP_BATTLE_H_ - #endif // _MAP_BATTLE_H_ - #ifdef _MAP_BUYINGSTORE_H_ + #define MAP_BATTLE_H + #endif // MAP_BATTLE_H + #ifdef MAP_BUYINGSTORE_H { "buyingstore_interface", sizeof(struct buyingstore_interface) }, { "s_buyingstore_item", sizeof(struct s_buyingstore_item) }, #else - #define _MAP_BUYINGSTORE_H_ - #endif // _MAP_BUYINGSTORE_H_ - #ifdef _MAP_CHRIF_H_ + #define MAP_BUYINGSTORE_H + #endif // MAP_BUYINGSTORE_H + #ifdef MAP_CHRIF_H { "auth_node", sizeof(struct auth_node) }, #else - #define _MAP_CHRIF_H_ - #endif // _MAP_CHRIF_H_ - #ifdef _MAP_CLIF_H_ + #define MAP_CHRIF_H + #endif // MAP_CHRIF_H + #ifdef MAP_CLIF_H { "clif_interface", sizeof(struct clif_interface) }, #else - #define _MAP_CLIF_H_ - #endif // _MAP_CLIF_H_ - #ifdef _MAP_ELEMENTAL_H_ + #define MAP_CLIF_H + #endif // MAP_CLIF_H + #ifdef MAP_ELEMENTAL_H { "elemental_skill", sizeof(struct elemental_skill) }, #else - #define _MAP_ELEMENTAL_H_ - #endif // _MAP_ELEMENTAL_H_ - #ifdef _MAP_GUILD_H_ + #define MAP_ELEMENTAL_H + #endif // MAP_ELEMENTAL_H + #ifdef MAP_GUILD_H { "eventlist", sizeof(struct eventlist) }, { "guardian_data", sizeof(struct guardian_data) }, #else - #define _MAP_GUILD_H_ - #endif // _MAP_GUILD_H_ - #ifdef _MAP_MAPREG_H_ + #define MAP_GUILD_H + #endif // MAP_GUILD_H + #ifdef MAP_MAPREG_H { "mapreg_save", sizeof(struct mapreg_save) }, #else - #define _MAP_MAPREG_H_ - #endif // _MAP_MAPREG_H_ - #ifdef _MAP_MAP_H_ + #define MAP_MAPREG_H + #endif // MAP_MAPREG_H + #ifdef MAP_MAP_H { "map_data_other_server", sizeof(struct map_data_other_server) }, #else - #define _MAP_MAP_H_ - #endif // _MAP_MAP_H_ - #ifdef _MAP_PACKETS_STRUCT_H_ + #define MAP_MAP_H + #endif // MAP_MAP_H + #ifdef MAP_PACKETS_STRUCT_H { "EQUIPSLOTINFO", sizeof(struct EQUIPSLOTINFO) }, #else - #define _MAP_PACKETS_STRUCT_H_ - #endif // _MAP_PACKETS_STRUCT_H_ - #ifdef _MAP_PC_H_ + #define MAP_PACKETS_STRUCT_H + #endif // MAP_PACKETS_STRUCT_H + #ifdef MAP_PC_H { "autotrade_vending", sizeof(struct autotrade_vending) }, { "item_cd", sizeof(struct item_cd) }, #else - #define _MAP_PC_H_ - #endif // _MAP_PC_H_ - #ifdef _MAP_SCRIPT_H_ + #define MAP_PC_H + #endif // MAP_PC_H + #ifdef MAP_SCRIPT_H { "Script_Config", sizeof(struct Script_Config) }, { "reg_db", sizeof(struct reg_db) }, { "script_interface", sizeof(struct script_interface) }, #else - #define _MAP_SCRIPT_H_ - #endif // _MAP_SCRIPT_H_ - #ifdef _MAP_SEARCHSTORE_H_ + #define MAP_SCRIPT_H + #endif // MAP_SCRIPT_H + #ifdef MAP_SEARCHSTORE_H { "searchstore_interface", sizeof(struct searchstore_interface) }, #else - #define _MAP_SEARCHSTORE_H_ - #endif // _MAP_SEARCHSTORE_H_ - #ifdef _MAP_SKILL_H_ + #define MAP_SEARCHSTORE_H + #endif // MAP_SEARCHSTORE_H + #ifdef MAP_SKILL_H { "skill_cd", sizeof(struct skill_cd) }, { "skill_condition", sizeof(struct skill_condition) }, { "skill_interface", sizeof(struct skill_interface) }, { "skill_unit_save", sizeof(struct skill_unit_save) }, #else - #define _MAP_SKILL_H_ - #endif // _MAP_SKILL_H_ + #define MAP_SKILL_H + #endif // MAP_SKILL_H }; HPExport unsigned int HPMDataCheckLen = ARRAYLENGTH(HPMDataCheck); -#endif /* _HPM_DATA_CHECK_H_ */ +#endif /* HPM_DATA_CHECK_H */ diff --git a/src/common/HPMi.h b/src/common/HPMi.h index b98e87d90..478cfbdd9 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _COMMON_HPMI_H_ -#define _COMMON_HPMI_H_ +#ifndef COMMON_HPMI_H +#define COMMON_HPMI_H #include "../common/cbasetypes.h" #include "../common/console.h" @@ -184,4 +184,4 @@ HPExport struct HPMi_interface { HPExport struct HPMi_interface *HPMi; #endif -#endif /* _COMMON_HPMI_H_ */ +#endif /* COMMON_HPMI_H */ diff --git a/src/common/atomic.h b/src/common/atomic.h index 526811a09..e73b1c464 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -1,8 +1,8 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_ATOMIC_H_ -#define _COMMON_ATOMIC_H_ +#ifndef COMMON_ATOMIC_H +#define COMMON_ATOMIC_H // Atomic Operations // (Interlocked CompareExchange, Add .. and so on ..) @@ -146,4 +146,4 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ #endif //endif compiler decision -#endif /* _COMMON_ATOMIC_H_ */ +#endif /* COMMON_ATOMIC_H */ diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ac65b08a8..42075de8e 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -1,5 +1,5 @@ -#ifndef _COMMON_CBASETYPES_H_ -#define _COMMON_CBASETYPES_H_ +#ifndef COMMON_CBASETYPES_H +#define COMMON_CBASETYPES_H /* +--------+-----------+--------+---------+ * | ILP32 | LP64 | ILP64 | (LL)P64 | @@ -444,9 +444,9 @@ void SET_FUNCPOINTER(T1& var, T2 p) /* pointer size fix which fixes several gcc warnings */ #ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) + #define h64BPTRSIZE(y) ((intptr)(y)) #else - #define __64BPTRSIZE(y) (y) + #define h64BPTRSIZE(y) (y) #endif -#endif /* _COMMON_CBASETYPES_H_ */ +#endif /* COMMON_CBASETYPES_H */ diff --git a/src/common/conf.h b/src/common/conf.h index 7c275bec2..c232a035c 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_CONF_H_ -#define _COMMON_CONF_H_ +#ifndef COMMON_CONF_H +#define COMMON_CONF_H #include "../common/cbasetypes.h" @@ -95,4 +95,4 @@ struct libconfig_interface *libconfig; void libconfig_defaults(void); -#endif // _COMMON_CONF_H_ +#endif // COMMON_CONF_H diff --git a/src/common/console.h b/src/common/console.h index 55a9a767c..062d48bbe 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _COMMON_CONSOLE_H_ -#define _COMMON_CONSOLE_H_ +#ifndef COMMON_CONSOLE_H +#define COMMON_CONSOLE_H #include "../config/core.h" // MAX_CONSOLE_INPUT @@ -93,4 +93,4 @@ struct console_interface *console; void console_defaults(void); -#endif /* _COMMON_CONSOLE_H_ */ +#endif /* COMMON_CONSOLE_H */ diff --git a/src/common/core.h b/src/common/core.h index ba75e6b01..a8337e1b9 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_CORE_H_ -#define _COMMON_CORE_H_ +#ifndef COMMON_CORE_H +#define COMMON_CORE_H #include "../common/db.h" #include "../common/mmo.h" @@ -47,4 +47,4 @@ enum E_CORE_ST { /// If NULL, runflag is set to CORE_ST_STOP instead. extern void (*shutdown_callback)(void); -#endif /* _COMMON_CORE_H_ */ +#endif /* COMMON_CORE_H */ diff --git a/src/common/db.h b/src/common/db.h index 4f8d6be79..ed87e474b 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -39,8 +39,8 @@ * @encoding US-ASCII * * @see common#db.c * \*****************************************************************************/ -#ifndef _COMMON_DB_H_ -#define _COMMON_DB_H_ +#ifndef COMMON_DB_H +#define COMMON_DB_H #include @@ -1549,4 +1549,4 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); -#endif /* _COMMON_DB_H_ */ +#endif /* COMMON_DB_H */ diff --git a/src/common/des.h b/src/common/des.h index 0f908a15b..2c7190f23 100644 --- a/src/common/des.h +++ b/src/common/des.h @@ -1,7 +1,7 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_DES_H_ -#define _COMMON_DES_H_ +#ifndef COMMON_DES_H +#define COMMON_DES_H #include "../common/cbasetypes.h" @@ -13,4 +13,4 @@ void des_decrypt_block(BIT64* block); void des_decrypt(unsigned char* data, size_t size); -#endif // _COMMON_DES_H_ +#endif // COMMON_DES_H diff --git a/src/common/ers.h b/src/common/ers.h index e11f7f37e..904f7fb81 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -37,8 +37,8 @@ * @author Flavio @ Amazon Project * * @encoding US-ASCII * \*****************************************************************************/ -#ifndef _COMMON_ERS_H_ -#define _COMMON_ERS_H_ +#ifndef COMMON_ERS_H +#define COMMON_ERS_H #include "../common/cbasetypes.h" @@ -175,4 +175,4 @@ void ers_report(void); void ers_final(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ -#endif /* _COMMON_ERS_H_ */ +#endif /* COMMON_ERS_H */ diff --git a/src/common/grfio.c b/src/common/grfio.c index f592812f6..6e628a512 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -23,7 +23,7 @@ //---------------------------- // file entry table struct //---------------------------- -typedef struct _FILELIST { +typedef struct FILELIST { int srclen; ///< compressed size int srclen_aligned; int declen; ///< original size diff --git a/src/common/grfio.h b/src/common/grfio.h index 930ed7e36..15659c17c 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_GRFIO_H_ -#define _COMMON_GRFIO_H_ +#ifndef COMMON_GRFIO_H +#define COMMON_GRFIO_H void grfio_init(const char* fname); void grfio_final(void); @@ -14,4 +14,4 @@ unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); -#endif /* _COMMON_GRFIO_H_ */ +#endif /* COMMON_GRFIO_H */ diff --git a/src/common/malloc.c b/src/common/malloc.c index fbe8e2d9d..3c9fa9c54 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -235,14 +235,13 @@ static size_t hash2size( unsigned short hash ) } } -void* _mmalloc(size_t size, const char *file, int line, const char *func ) -{ +void *mmalloc_(size_t size, const char *file, int line, const char *func) { struct block *block; short size_hash = size2hash( size ); struct unit_head *head; if (((long) size) < 0) { - ShowError("_mmalloc: %d\n", size); + ShowError("mmalloc_: %d\n", size); return NULL; } @@ -341,15 +340,13 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) return (char *)head + sizeof(struct unit_head) - sizeof(long); } -void* _mcalloc(size_t num, size_t size, const char *file, int line, const char *func ) -{ +void *mcalloc_(size_t num, size_t size, const char *file, int line, const char *func) { void *p = iMalloc->malloc(num * size,file,line,func); memset(p,0,num * size); return p; } -void* _mrealloc(void *memblock, size_t size, const char *file, int line, const char *func ) -{ +void *mrealloc_(void *memblock, size_t size, const char *file, int line, const char *func) { size_t old_size; if(memblock == NULL) { return iMalloc->malloc(size,file,line,func); @@ -373,8 +370,8 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c } } -/* a _mrealloc clone with the difference it 'z'eroes the newly created memory */ -void* _mreallocz(void *memblock, size_t size, const char *file, int line, const char *func ) { +/* a mrealloc_ clone with the difference it 'z'eroes the newly created memory */ +void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) { size_t old_size; void *p = NULL; @@ -404,8 +401,7 @@ void* _mreallocz(void *memblock, size_t size, const char *file, int line, const } -char* _mstrdup(const char *p, const char *file, int line, const char *func ) -{ +char *mstrdup_(const char *p, const char *file, int line, const char *func) { if(p == NULL) { return NULL; } else { @@ -416,8 +412,7 @@ char* _mstrdup(const char *p, const char *file, int line, const char *func ) } } -void _mfree(void *ptr, const char *file, int line, const char *func ) -{ +void mfree_(void *ptr, const char *file, int line, const char *func) { struct unit_head *head; if (ptr == NULL) @@ -852,12 +847,12 @@ void malloc_defaults(void) { // Athena's built-in Memory Manager #ifdef USE_MEMMGR - iMalloc->malloc = _mmalloc; - iMalloc->calloc = _mcalloc; - iMalloc->realloc = _mrealloc; - iMalloc->reallocz= _mreallocz; - iMalloc->astrdup = _mstrdup; - iMalloc->free = _mfree; + iMalloc->malloc = mmalloc_; + iMalloc->calloc = mcalloc_; + iMalloc->realloc = mrealloc_; + iMalloc->reallocz= mreallocz_; + iMalloc->astrdup = mstrdup_; + iMalloc->free = mfree_; #else iMalloc->malloc = aMalloc_; iMalloc->calloc = aCalloc_; diff --git a/src/common/malloc.h b/src/common/malloc.h index 7309bb0f7..8dace2d68 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_MALLOC_H_ -#define _COMMON_MALLOC_H_ +#ifndef COMMON_MALLOC_H +#define COMMON_MALLOC_H #include "../common/cbasetypes.h" @@ -88,4 +88,4 @@ struct malloc_interface { void memmgr_report (int extra); struct malloc_interface *iMalloc; -#endif /* _COMMON_MALLOC_H_ */ +#endif /* COMMON_MALLOC_H */ diff --git a/src/common/mapindex.h b/src/common/mapindex.h index fa9b9e920..446a2422d 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_MAPINDEX_H_ -#define _COMMON_MAPINDEX_H_ +#ifndef COMMON_MAPINDEX_H +#define COMMON_MAPINDEX_H #include "../common/db.h" #include "../common/mmo.h" @@ -90,4 +90,4 @@ struct mapindex_interface *mapindex; void mapindex_defaults(void); -#endif /* _COMMON_MAPINDEX_H_ */ +#endif /* COMMON_MAPINDEX_H */ diff --git a/src/common/md5calc.h b/src/common/md5calc.h index d0caf6787..740e2edcc 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -1,8 +1,8 @@ -#ifndef _COMMON_MD5CALC_H_ -#define _COMMON_MD5CALC_H_ +#ifndef COMMON_MD5CALC_H +#define COMMON_MD5CALC_H void MD5_String(const char * string, char * output); void MD5_Binary(const char * string, unsigned char * output); void MD5_Salt(unsigned int len, char * output); -#endif /* _COMMON_MD5CALC_H_ */ +#endif /* COMMON_MD5CALC_H */ diff --git a/src/common/mmo.h b/src/common/mmo.h index 8e57eee85..feeb06524 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_MMO_H_ -#define _COMMON_MMO_H_ +#ifndef COMMON_MMO_H +#define COMMON_MMO_H #include @@ -932,4 +932,4 @@ enum e_pc_reg_loading { #error MAX_ZENY is too big #endif -#endif /* _COMMON_MMO_H_ */ +#endif /* COMMON_MMO_H */ diff --git a/src/common/mutex.h b/src/common/mutex.h index ced91ab8e..d298c05af 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -1,8 +1,8 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_MUTEX_H_ -#define _COMMON_MUTEX_H_ +#ifndef COMMON_MUTEX_H +#define COMMON_MUTEX_H #include "../common/cbasetypes.h" @@ -90,4 +90,4 @@ void racond_signal(racond *c); void racond_broadcast(racond *c); -#endif /* _COMMON_MUTEX_H_ */ +#endif /* COMMON_MUTEX_H */ diff --git a/src/common/nullpo.h b/src/common/nullpo.h index fb1cf0feb..581252cca 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_NULLPO_H_ -#define _COMMON_NULLPO_H_ +#ifndef COMMON_NULLPO_H +#define COMMON_NULLPO_H #include "../common/cbasetypes.h" @@ -125,4 +125,4 @@ void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title); -#endif /* _COMMON_NULLPO_H_ */ +#endif /* COMMON_NULLPO_H */ diff --git a/src/common/random.h b/src/common/random.h index ab83fb4d4..15d7f8ab1 100644 --- a/src/common/random.h +++ b/src/common/random.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_RANDOM_H_ -#define _COMMON_RANDOM_H_ +#ifndef COMMON_RANDOM_H +#define COMMON_RANDOM_H #include "../common/cbasetypes.h" @@ -15,4 +15,4 @@ int32 rnd_value(int32 min, int32 max);// [min, max] double rnd_uniform(void);// [0.0, 1.0) double rnd_uniform53(void);// [0.0, 1.0) -#endif /* _COMMON_RANDOM_H_ */ +#endif /* COMMON_RANDOM_H */ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index ece10c1a8..b9bcef9b2 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -654,7 +654,7 @@ int FPRINTF(FILE *file, const char *fmt, ...) char timestamp_format[20] = ""; //For displaying Timestamps -int _vShowMessage(enum msg_type flag, const char *string, va_list ap) +int vShowMessage_(enum msg_type flag, const char *string, va_list ap) { va_list apcopy; char prefix[100]; @@ -663,7 +663,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) #endif if (!string || *string == '\0') { - ShowError("Empty string passed to _vShowMessage().\n"); + ShowError("Empty string passed to vShowMessage_().\n"); return 1; } if( @@ -734,7 +734,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) strcat(prefix,CL_RED"[Fatal Error]"CL_RESET":"); break; default: - ShowError("In function _vShowMessage() -> Invalid flag passed.\n"); + ShowError("In function vShowMessage_() -> Invalid flag passed.\n"); return 1; } @@ -782,12 +782,12 @@ void ClearScreen(void) ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } -int _ShowMessage(enum msg_type flag, const char *string, ...) +int ShowMessage_(enum msg_type flag, const char *string, ...) { int ret; va_list ap; va_start(ap, string); - ret = _vShowMessage(flag, string, ap); + ret = vShowMessage_(flag, string, ap); va_end(ap); return ret; } @@ -796,37 +796,37 @@ int _ShowMessage(enum msg_type flag, const char *string, ...) void ShowMessage(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_NONE, string, ap); + vShowMessage_(MSG_NONE, string, ap); va_end(ap); } void ShowStatus(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_STATUS, string, ap); + vShowMessage_(MSG_STATUS, string, ap); va_end(ap); } void ShowSQL(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_SQL, string, ap); + vShowMessage_(MSG_SQL, string, ap); va_end(ap); } void ShowInfo(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_INFORMATION, string, ap); + vShowMessage_(MSG_INFORMATION, string, ap); va_end(ap); } void ShowNotice(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_NOTICE, string, ap); + vShowMessage_(MSG_NOTICE, string, ap); va_end(ap); } void ShowWarning(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_WARNING, string, ap); + vShowMessage_(MSG_WARNING, string, ap); va_end(ap); } void ShowConfigWarning(config_setting_t *config, const char *string, ...) @@ -837,25 +837,25 @@ void ShowConfigWarning(config_setting_t *config, const char *string, ...) StrBuf->AppendStr(&buf, string); StrBuf->Printf(&buf, " (%s:%d)\n", config_setting_source_file(config), config_setting_source_line(config)); va_start(ap, string); - _vShowMessage(MSG_WARNING, StrBuf->Value(&buf), ap); + vShowMessage_(MSG_WARNING, StrBuf->Value(&buf), ap); va_end(ap); StrBuf->Destroy(&buf); } void ShowDebug(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_DEBUG, string, ap); + vShowMessage_(MSG_DEBUG, string, ap); va_end(ap); } void ShowError(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_ERROR, string, ap); + vShowMessage_(MSG_ERROR, string, ap); va_end(ap); } void ShowFatalError(const char *string, ...) { va_list ap; va_start(ap, string); - _vShowMessage(MSG_FATALERROR, string, ap); + vShowMessage_(MSG_FATALERROR, string, ap); va_end(ap); } diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 8008acf5a..83eb0ad89 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_SHOWMSG_H_ -#define _COMMON_SHOWMSG_H_ +#ifndef COMMON_SHOWMSG_H +#define COMMON_SHOWMSG_H #include @@ -115,6 +115,6 @@ extern void ClearScreen(void); HPExport void (*ShowFatalError) (const char *, ...); #endif -extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); +extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap); -#endif /* _COMMON_SHOWMSG_H_ */ +#endif /* COMMON_SHOWMSG_H */ diff --git a/src/common/socket.c b/src/common/socket.c index 58c2d5bf9..85f0aa0ce 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -5,9 +5,9 @@ #define HERCULES_CORE #include "../config/core.h" // SHOW_SERVER_STATS -#define _H_SOCKET_C_ +#define H_SOCKET_C #include "socket.h" -#undef _H_SOCKET_C_ +#undef H_SOCKET_C #include #include @@ -909,20 +909,20 @@ int do_sockets(int next) ////////////////////////////// // IP rules and DDoS protection -typedef struct _connect_history { - struct _connect_history* next; +typedef struct connect_history { + struct connect_history* next; uint32 ip; int64 tick; int count; unsigned ddos : 1; } ConnectHistory; -typedef struct _access_control { +typedef struct access_control { uint32 ip; uint32 mask; } AccessControl; -enum _aco { +enum aco { ACO_DENY_ALLOW, ACO_ALLOW_DENY, ACO_MUTUAL_FAILURE diff --git a/src/common/socket.h b/src/common/socket.h index 804b9284f..42b0efe3b 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_SOCKET_H_ -#define _COMMON_SOCKET_H_ +#ifndef COMMON_SOCKET_H +#define COMMON_SOCKET_H #include @@ -174,7 +174,7 @@ struct socket_interface *sockt; void socket_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef _H_SOCKET_C_ +#ifndef H_SOCKET_C #define make_listen_bind(ip, port) ( sockt->make_listen_bind(ip, port) ) #define make_connection(ip, port, opt) ( sockt->make_connection(ip, port, opt) ) #define realloc_fifo(fd, rfifo_size, wfifo_size) ( sockt->realloc_fifo(fd, rfifo_size, wfifo_size) ) @@ -194,6 +194,6 @@ void socket_defaults(void); #define ntows(netshort) ( sockt->ntows(netshort) ) #define getips(ips, max) ( sockt->getips(ips, max) ) #define set_eof(fd) ( sockt->set_eof(fd) ) -#endif /* _H_SOCKET_C_ */ +#endif /* H_SOCKET_C */ -#endif /* _COMMON_SOCKET_H_ */ +#endif /* COMMON_SOCKET_H */ diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 5d57c6462..bde36b8e5 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,5 +1,5 @@ -#ifndef _COMMON_SPINLOCK_H_ -#define _COMMON_SPINLOCK_H_ +#ifndef COMMON_SPINLOCK_H +#define COMMON_SPINLOCK_H // // CAS based Spinlock Implementation @@ -100,4 +100,4 @@ static forceinline void LeaveSpinLock(SPIN_LOCK *lck){ -#endif /* _COMMON_SPINLOCK_H_ */ +#endif /* COMMON_SPINLOCK_H */ diff --git a/src/common/sql.h b/src/common/sql.h index 3bdb76c74..f9593978c 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_SQL_H_ -#define _COMMON_SQL_H_ +#ifndef COMMON_SQL_H +#define COMMON_SQL_H #include // va_list @@ -291,4 +291,4 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename); void Sql_Init(void); -#endif /* _COMMON_SQL_H_ */ +#endif /* COMMON_SQL_H */ diff --git a/src/common/strlib.c b/src/common/strlib.c index 2ce8fd347..e2382e6fc 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -4,9 +4,9 @@ #define HERCULES_CORE -#define _H_STRLIB_C_ +#define H_STRLIB_C #include "strlib.h" -#undef _H_STRLIB_C_ +#undef H_STRLIB_C #include #include @@ -224,7 +224,7 @@ const char* stristr(const char* haystack, const char* needle) } #ifdef __WIN32 -char* _strtok_r(char *s1, const char *s2, char **lasts) { +char* strtok_r_(char *s1, const char *s2, char **lasts) { char *ret; if (s1 == NULL) diff --git a/src/common/strlib.h b/src/common/strlib.h index f39f27789..7f84d2893 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_STRLIB_H_ -#define _COMMON_STRLIB_H_ +#ifndef COMMON_STRLIB_H +#define COMMON_STRLIB_H #include #include @@ -12,8 +12,8 @@ #ifdef WIN32 #define HAVE_STRTOK_R - #define strtok_r(s,delim,save_ptr) _strtok_r((s),(delim),(save_ptr)) - char *_strtok_r(char* s1, const char* s2, char** lasts); + #define strtok_r(s,delim,save_ptr) strtok_r_((s),(delim),(save_ptr)) + char *strtok_r_(char* s1, const char* s2, char** lasts); #endif /// Bitfield determining the behavior of sv_parse and sv_split. @@ -159,7 +159,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 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))) @@ -183,6 +183,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 /* H_STRLIB_C */ -#endif /* _COMMON_STRLIB_H_ */ +#endif /* COMMON_STRLIB_H */ diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 24f794cb4..600206a21 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -2,8 +2,8 @@ // See the LICENSE file // Base Author: Haru @ http://hercules.ws -#ifndef _COMMON_SYSINFO_H_ -#define _COMMON_SYSINFO_H_ +#ifndef COMMON_SYSINFO_H +#define COMMON_SYSINFO_H /** * Provides various bits of information about the system Hercules is running on @@ -48,4 +48,4 @@ struct sysinfo_interface *sysinfo; void sysinfo_defaults(void); -#endif /* _COMMON_SYSINFO_H_ */ +#endif /* COMMON_SYSINFO_H */ diff --git a/src/common/thread.c b/src/common/thread.c index d8e0dbf0a..d680d0347 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -106,9 +106,9 @@ static void rat_thread_terminated(rAthread *handle) { }//end: rat_thread_terminated() #ifdef WIN32 -DWORD WINAPI _raThreadMainRedirector(LPVOID p){ +DWORD WINAPI raThreadMainRedirector(LPVOID p){ #else -static void *_raThreadMainRedirector( void *p ){ +static void *raThreadMainRedirector( void *p ){ sigset_t set; // on Posix Thread platforms #endif void *ret; @@ -145,7 +145,7 @@ static void *_raThreadMainRedirector( void *p ){ #else return ret; #endif -}//end: _raThreadMainRedirector() +}//end: raThreadMainRedirector() @@ -193,12 +193,12 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack handle->param = param; #ifdef WIN32 - handle->hThread = CreateThread(NULL, szStack, _raThreadMainRedirector, (void*)handle, 0, NULL); + handle->hThread = CreateThread(NULL, szStack, raThreadMainRedirector, (void*)handle, 0, NULL); #else pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, szStack); - if(pthread_create(&handle->hThread, &attr, _raThreadMainRedirector, (void*)handle) != 0){ + if(pthread_create(&handle->hThread, &attr, raThreadMainRedirector, (void*)handle) != 0){ handle->proc = NULL; handle->param = NULL; return NULL; diff --git a/src/common/thread.h b/src/common/thread.h index 3b5ce7476..f781cfbd0 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,8 +1,8 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_THREAD_H_ -#define _COMMON_THREAD_H_ +#ifndef COMMON_THREAD_H +#define COMMON_THREAD_H #include "../common/cbasetypes.h" @@ -115,4 +115,4 @@ void rathread_init(); void rathread_final(); -#endif /* _COMMON_THREAD_H_ */ +#endif /* COMMON_THREAD_H */ diff --git a/src/common/timer.c b/src/common/timer.c index ab0471d51..128fc4daf 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -107,7 +107,7 @@ char* search_timer_func_list(TimerFunc func) #if defined(ENABLE_RDTSC) static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0; -static __inline uint64 _rdtsc(){ +static __inline uint64 rdtsc_() { register union{ uint64 qw; uint32 dw[2]; @@ -127,14 +127,14 @@ static void rdtsc_calibrate(){ RDTSC_CLOCK = 0; for(i = 0; i < 5; i++){ - t1 = _rdtsc(); + t1 = rdtsc_(); usleep(1000000); //1000 MS - t2 = _rdtsc(); + t2 = rdtsc_(); RDTSC_CLOCK += (t2 - t1) / 1000; } RDTSC_CLOCK /= 5; - RDTSC_BEGINTICK = _rdtsc(); + RDTSC_BEGINTICK = rdtsc_(); ShowMessage(" done. (Frequency: %u Mhz)\n", (uint32)(RDTSC_CLOCK/1000) ); } @@ -175,7 +175,7 @@ static int64 sys_tick(void) { #elif defined(ENABLE_RDTSC) // RDTSC: Returns the number of CPU cycles since reset. Unreliable if // the CPU frequency is variable. - return (int64)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); + return (int64)((rdtsc_() - RDTSC_BEGINTICK) / RDTSC_CLOCK); #elif defined(HAVE_MONOTONIC_CLOCK) // Monotonic clock: Implementation-defined. // Clock that cannot be set and represents monotonic time since some diff --git a/src/common/timer.h b/src/common/timer.h index a07f81612..d0927adde 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_TIMER_H_ -#define _COMMON_TIMER_H_ +#ifndef COMMON_TIMER_H +#define COMMON_TIMER_H #include "../common/cbasetypes.h" @@ -67,4 +67,4 @@ struct timer_interface *timer; void timer_defaults(void); -#endif /* _COMMON_TIMER_H_ */ +#endif /* COMMON_TIMER_H */ diff --git a/src/common/utils.h b/src/common/utils.h index 823651163..421698d95 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _COMMON_UTILS_H_ -#define _COMMON_UTILS_H_ +#ifndef COMMON_UTILS_H +#define COMMON_UTILS_H #include // FILE* #include @@ -65,4 +65,4 @@ struct HCache_interface *HCache; void HCache_defaults(void); -#endif /* _COMMON_UTILS_H_ */ +#endif /* COMMON_UTILS_H */ diff --git a/src/config/classes/general.h b/src/config/classes/general.h index 147fddb55..b3da4a475 100644 --- a/src/config/classes/general.h +++ b/src/config/classes/general.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONFIG_GENERAL_H_ -#define _CONFIG_GENERAL_H_ +#ifndef CONFIG_GENERAL_H +#define CONFIG_GENERAL_H /** * Hercules configuration file (http://hercules.ws) @@ -31,4 +31,4 @@ * No settings past this point **/ -#endif // _CONFIG_GENERAL_H_ +#endif // CONFIG_GENERAL_H diff --git a/src/config/const.h b/src/config/const.h index 23467bfa6..2b5b180c4 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONFIG_CONSTANTS_H_ -#define _CONFIG_CONSTANTS_H_ +#ifndef CONFIG_CONSTANTS_H +#define CONFIG_CONSTANTS_H /** * Hercules configuration file (http://hercules.ws) @@ -103,4 +103,4 @@ /** * End of File **/ -#endif /* _CONFIG_CONSTANTS_H_ */ +#endif /* CONFIG_CONSTANTS_H */ diff --git a/src/config/core.h b/src/config/core.h index 24e9de710..ac59563b5 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONFIG_CORE_H_ -#define _CONFIG_CORE_H_ +#ifndef CONFIG_CORE_H +#define CONFIG_CORE_H /// Max number of items on @autolootid list #define AUTOLOOTITEM_SIZE 10 @@ -79,4 +79,4 @@ **/ #include "./const.h" -#endif // _CONFIG_CORE_H_ +#endif // CONFIG_CORE_H diff --git a/src/config/renewal.h b/src/config/renewal.h index 1c48b9f8a..939ad9b73 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONFIG_RENEWAL_H_ -#define _CONFIG_RENEWAL_H_ +#ifndef CONFIG_RENEWAL_H +#define CONFIG_RENEWAL_H /** * Hercules configuration file (http://hercules.ws) @@ -86,4 +86,4 @@ #endif // DISABLE_RENEWAL #undef DISABLE_RENEWAL -#endif // _CONFIG_RENEWAL_H_ +#endif // CONFIG_RENEWAL_H diff --git a/src/config/secure.h b/src/config/secure.h index 1a89e36cf..418d24751 100644 --- a/src/config/secure.h +++ b/src/config/secure.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _CONFIG_SECURE_H_ -#define _CONFIG_SECURE_H_ +#ifndef CONFIG_SECURE_H +#define CONFIG_SECURE_H /** * Hercules configuration file (http://hercules.ws) @@ -58,4 +58,4 @@ **/ #define ANTI_MAYAP_CHEAT -#endif // _CONFIG_SECURE_H_ +#endif // CONFIG_SECURE_H diff --git a/src/login/account.h b/src/login/account.h index a14595519..e15143ce9 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _LOGIN_ACCOUNT_H_ -#define _LOGIN_ACCOUNT_H_ +#ifndef LOGIN_ACCOUNT_H +#define LOGIN_ACCOUNT_H #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM @@ -140,4 +140,4 @@ Sql *account_db_sql_up(AccountDB* self); void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id); void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id); -#endif /* _LOGIN_ACCOUNT_H_ */ +#endif /* LOGIN_ACCOUNT_H */ diff --git a/src/login/ipban.h b/src/login/ipban.h index e6851d8dd..b4f3ac51b 100644 --- a/src/login/ipban.h +++ b/src/login/ipban.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _LOGIN_IPBAN_H_ -#define _LOGIN_IPBAN_H_ +#ifndef LOGIN_IPBAN_H +#define LOGIN_IPBAN_H #include "../common/cbasetypes.h" @@ -22,4 +22,4 @@ void ipban_log(uint32 ip); bool ipban_config_read(const char* key, const char* value); -#endif /* _LOGIN_IPBAN_H_ */ +#endif /* LOGIN_IPBAN_H */ diff --git a/src/login/login.h b/src/login/login.h index 447301ea4..9b9d1e82c 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _LOGIN_LOGIN_H_ -#define _LOGIN_LOGIN_H_ +#ifndef LOGIN_LOGIN_H +#define LOGIN_LOGIN_H #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" // NAME_LENGTH,SEX_* @@ -100,4 +100,4 @@ extern struct mmo_char_server server[MAX_SERVERS]; extern struct Login_Config login_config; -#endif /* _LOGIN_LOGIN_H_ */ +#endif /* LOGIN_LOGIN_H */ diff --git a/src/login/loginlog.h b/src/login/loginlog.h index a86ad431c..52e18f3d1 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _LOGIN_LOGINLOG_H_ -#define _LOGIN_LOGINLOG_H_ +#ifndef LOGIN_LOGINLOG_H +#define LOGIN_LOGINLOG_H #include "../common/cbasetypes.h" @@ -12,4 +12,4 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); -#endif /* _LOGIN_LOGINLOG_H_ */ +#endif /* LOGIN_LOGINLOG_H */ diff --git a/src/map/HPMmap.h b/src/map/HPMmap.h index f291575fb..99c4224ff 100644 --- a/src/map/HPMmap.h +++ b/src/map/HPMmap.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#ifndef _MAP_HPMMAP_H_ -#define _MAP_HPMMAP_H_ +#ifndef MAP_HPMMAP_H +#define MAP_HPMMAP_H #include "../common/cbasetypes.h" #include "../map/atcommand.h" @@ -26,4 +26,4 @@ bool HPM_map_DataCheck(struct s_HPMDataCheck *src, unsigned int size, char *name void HPM_map_do_init(void); -#endif /* _MAP_HPMMAP_H_ */ +#endif /* MAP_HPMMAP_H */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index d36e98c41..e22e2101c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8434,7 +8434,7 @@ ACMD(set) { if( is_str ) script->set_var(sd, reg, (void*) val); else - script->set_var(sd, reg, (void*)__64BPTRSIZE((atoi(val)))); + script->set_var(sd, reg, (void*)h64BPTRSIZE((atoi(val)))); } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index c8a1863af..356487bd1 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_ATCOMMAND_H_ -#define _MAP_ATCOMMAND_H_ +#ifndef MAP_ATCOMMAND_H +#define MAP_ATCOMMAND_H #include "pc_groups.h" #include "../common/conf.h" @@ -121,4 +121,4 @@ void atcommand_defaults(void); /* stay here */ #define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) -#endif /* _MAP_ATCOMMAND_H_ */ +#endif /* MAP_ATCOMMAND_H */ diff --git a/src/map/battle.c b/src/map/battle.c index e40d44549..7610d97b2 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6357,7 +6357,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range return path->search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL); } -static const struct _battle_data { +static const struct battle_data { const char* str; int* val; int defval; diff --git a/src/map/battle.h b/src/map/battle.h index fc916597d..aab94420a 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_BATTLE_H_ -#define _MAP_BATTLE_H_ +#ifndef MAP_BATTLE_H +#define MAP_BATTLE_H #include "map.h" //ELE_MAX #include "../common/cbasetypes.h" @@ -603,4 +603,4 @@ struct battle_interface { struct battle_interface *battle; void battle_defaults(void); -#endif /* _MAP_BATTLE_H_ */ +#endif /* MAP_BATTLE_H */ diff --git a/src/map/battleground.h b/src/map/battleground.h index ec0a86f14..c1d3be054 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_BATTLEGROUND_H_ -#define _MAP_BATTLEGROUND_H_ +#ifndef MAP_BATTLEGROUND_H +#define MAP_BATTLEGROUND_H #include "clif.h" #include "guild.h" @@ -122,4 +122,4 @@ struct battleground_interface *bg; void battleground_defaults(void); -#endif /* _MAP_BATTLEGROUND_H_ */ +#endif /* MAP_BATTLEGROUND_H */ diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 914631872..c981cc444 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_BUYINGSTORE_H_ -#define _MAP_BUYINGSTORE_H_ +#ifndef MAP_BUYINGSTORE_H +#define MAP_BUYINGSTORE_H #include "../common/cbasetypes.h" #include "../common/mmo.h" // MAX_SLOTS @@ -75,4 +75,4 @@ struct buyingstore_interface *buyingstore; void buyingstore_defaults (void); -#endif // _MAP_BUYINGSTORE_H_ +#endif // MAP_BUYINGSTORE_H diff --git a/src/map/chat.h b/src/map/chat.h index 6e4fae1c0..e055c04ed 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_CHAT_H_ -#define _MAP_CHAT_H_ +#ifndef MAP_CHAT_H +#define MAP_CHAT_H #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE #include "../common/cbasetypes.h" @@ -60,4 +60,4 @@ struct chat_interface *chat; void chat_defaults(void); -#endif /* _MAP_CHAT_H_ */ +#endif /* MAP_CHAT_H */ diff --git a/src/map/chrif.h b/src/map/chrif.h index 51ab0e9b9..11baaf5ff 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_CHRIF_H_ -#define _MAP_CHRIF_H_ +#ifndef MAP_CHRIF_H +#define MAP_CHRIF_H #include @@ -154,4 +154,4 @@ void chrif_defaults(void); // There's no need for another function when a simple macro can do exactly the same effect #define chrif_char_offline(x) chrif->char_offline_nsd((x)->status.account_id,(x)->status.char_id) -#endif /* _MAP_CHRIF_H_ */ +#endif /* MAP_CHRIF_H */ diff --git a/src/map/clif.c b/src/map/clif.c index 750689816..9e105e4a9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5651,7 +5651,7 @@ void clif_displaymessage_sprintf(const int fd, const char* mes, ...) { if( map->cpsd_active && fd == 0 ) { ShowInfo("HCP: "); va_start(ap,mes); - _vShowMessage(MSG_NONE,mes,ap); + vShowMessage_(MSG_NONE,mes,ap); va_end(ap); ShowMessage("\n"); } else if ( fd > 0 ) { diff --git a/src/map/clif.h b/src/map/clif.h index e1af44881..48316427f 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_CLIF_H_ -#define _MAP_CLIF_H_ +#ifndef MAP_CLIF_H +#define MAP_CLIF_H #include @@ -1290,4 +1290,4 @@ struct clif_interface *clif; void clif_defaults(void); -#endif /* _MAP_CLIF_H_ */ +#endif /* MAP_CLIF_H */ diff --git a/src/map/date.h b/src/map/date.h index b3ed59b2f..c3f353f64 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _MAP_DATE_H_ -#define _MAP_DATE_H_ +#ifndef MAP_DATE_H +#define MAP_DATE_H #include "../common/cbasetypes.h" @@ -17,4 +17,4 @@ bool is_day_of_sun(void); bool is_day_of_moon(void); bool is_day_of_star(void); -#endif /* _MAP_DATE_H_ */ +#endif /* MAP_DATE_H */ diff --git a/src/map/duel.h b/src/map/duel.h index 91dfa8f83..de2bd1bf6 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_DUEL_H_ -#define _MAP_DUEL_H_ +#ifndef MAP_DUEL_H +#define MAP_DUEL_H #include "../common/cbasetypes.h" @@ -46,4 +46,4 @@ struct duel_interface *duel; void duel_defaults(void); -#endif /* _MAP_DUEL_H_ */ +#endif /* MAP_DUEL_H */ diff --git a/src/map/elemental.h b/src/map/elemental.h index beddd3ea1..0c8fff8b3 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_ELEMENTAL_H_ -#define _MAP_ELEMENTAL_H_ +#ifndef MAP_ELEMENTAL_H +#define MAP_ELEMENTAL_H #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data @@ -121,4 +121,4 @@ struct elemental_interface *elemental; void elemental_defaults(void); -#endif /* _MAP_ELEMENTAL_H_ */ +#endif /* MAP_ELEMENTAL_H */ diff --git a/src/map/guild.c b/src/map/guild.c index 642c8993c..af29dc64e 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2015,8 +2015,8 @@ int guild_castledatasave(int castle_id, int index, int value) void guild_castle_reconnect_sub(void *key, void *data, va_list ap) { - int castle_id = GetWord((int)__64BPTRSIZE(key), 0); - int index = GetWord((int)__64BPTRSIZE(key), 1); + int castle_id = GetWord((int)h64BPTRSIZE(key), 0); + int index = GetWord((int)h64BPTRSIZE(key), 1); intif->guild_castle_datasave(castle_id, index, *(int *)data); aFree(data); } @@ -2037,7 +2037,7 @@ void guild_castle_reconnect(int castle_id, int index, int value) int *data; CREATE(data, int, 1); *data = value; - linkdb_replace(&gc_save_pending, (void*)__64BPTRSIZE((MakeDWord(castle_id, index))), data); + linkdb_replace(&gc_save_pending, (void*)h64BPTRSIZE((MakeDWord(castle_id, index))), data); } } diff --git a/src/map/guild.h b/src/map/guild.h index f9d97241d..126325eef 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_GUILD_H_ -#define _MAP_GUILD_H_ +#ifndef MAP_GUILD_H +#define MAP_GUILD_H #include "map.h" // EVENT_NAME_LENGTH, TBL_PC #include "../common/cbasetypes.h" @@ -167,4 +167,4 @@ struct guild_interface *guild; void guild_defaults(void); -#endif /* _MAP_GUILD_H_ */ +#endif /* MAP_GUILD_H */ diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 9eef6af5b..25ccabf48 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_HOMUNCULUS_H_ -#define _MAP_HOMUNCULUS_H_ +#ifndef MAP_HOMUNCULUS_H +#define MAP_HOMUNCULUS_H #include "pc.h" #include "status.h" // struct status_data, struct status_change @@ -148,4 +148,4 @@ struct homunculus_interface *homun; void homunculus_defaults(void); -#endif /* _MAP_HOMUNCULUS_H_ */ +#endif /* MAP_HOMUNCULUS_H */ diff --git a/src/map/instance.h b/src/map/instance.h index ae649eda7..2ee77d3e3 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_INSTANCE_H_ -#define _MAP_INSTANCE_H_ +#ifndef MAP_INSTANCE_H +#define MAP_INSTANCE_H #include "script.h" // struct reg_db #include "../common/cbasetypes.h" @@ -88,4 +88,4 @@ struct instance_interface *instance; void instance_defaults(void); -#endif /* _MAP_INSTANCE_H_ */ +#endif /* MAP_INSTANCE_H */ diff --git a/src/map/intif.c b/src/map/intif.c index 4dd0fa448..432154f04 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1067,7 +1067,7 @@ void intif_parse_Registers(int fd) ival = RFIFOL(fd, cursor); cursor += 4; - script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (void*)__64BPTRSIZE(ival), NULL); + script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (void*)h64BPTRSIZE(ival), NULL); } } diff --git a/src/map/intif.h b/src/map/intif.h index 42a38ad41..fe47d6537 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_INTIF_H_ -#define _MAP_INTIF_H_ +#ifndef MAP_INTIF_H +#define MAP_INTIF_H #include "../common/cbasetypes.h" @@ -186,4 +186,4 @@ struct intif_interface *intif; void intif_defaults(void); -#endif /* _MAP_INTIF_H_ */ +#endif /* MAP_INTIF_H */ diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 60f03fca5..0c26c3cd8 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -3,8 +3,8 @@ // Base Author: shennetsind @ http://hercules.ws -#ifndef _MAP_IRC_BOT_H_ -#define _MAP_IRC_BOT_H_ +#ifndef MAP_IRC_BOT_H +#define MAP_IRC_BOT_H #include "../common/cbasetypes.h" @@ -63,4 +63,4 @@ struct irc_bot_interface *ircbot; void ircbot_defaults(void); -#endif /* _MAP_IRC_BOT_H_ */ +#endif /* MAP_IRC_BOT_H */ diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 246ca1f54..2ad596ce1 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_ITEMDB_H_ -#define _MAP_ITEMDB_H_ +#ifndef MAP_ITEMDB_H +#define MAP_ITEMDB_H #include "map.h" #include "../common/cbasetypes.h" @@ -609,4 +609,4 @@ struct itemdb_interface *itemdb; void itemdb_defaults(void); -#endif /* _MAP_ITEMDB_H_ */ +#endif /* MAP_ITEMDB_H */ diff --git a/src/map/log.h b/src/map/log.h index ecfedeac2..6ab142f87 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_LOG_H_ -#define _MAP_LOG_H_ +#ifndef MAP_LOG_H +#define MAP_LOG_H #include "../common/cbasetypes.h" #include "../common/sql.h" @@ -133,4 +133,4 @@ struct log_interface *logs; void log_defaults(void); -#endif /* _MAP_LOG_H_ */ +#endif /* MAP_LOG_H */ diff --git a/src/map/mail.h b/src/map/mail.h index 30b032ef4..64b0f9779 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_MAIL_H_ -#define _MAP_MAIL_H_ +#ifndef MAP_MAIL_H +#define MAP_MAIL_H #include "../common/cbasetypes.h" @@ -27,4 +27,4 @@ struct mail_interface *mail; void mail_defaults(void); -#endif /* _MAP_MAIL_H_ */ +#endif /* MAP_MAIL_H */ diff --git a/src/map/map.h b/src/map/map.h index 38167597a..35fe0d7e1 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_MAP_H_ -#define _MAP_MAP_H_ +#ifndef MAP_MAP_H +#define MAP_MAP_H #include @@ -342,7 +342,7 @@ struct flooritem_data { struct item item_data; }; -enum _sp { +enum status_point_types { SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7 SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15 SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23 @@ -415,7 +415,7 @@ enum _sp { SP_LAST_KNOWN, }; -enum _look { +enum look { LOOK_BASE, LOOK_HAIR, LOOK_WEAPON, @@ -1071,4 +1071,4 @@ struct map_interface *map; void map_defaults(void); -#endif /* _MAP_MAP_H_ */ +#endif /* MAP_MAP_H */ diff --git a/src/map/mapreg.h b/src/map/mapreg.h index 2aa2943a2..59d226cda 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_MAPREG_H_ -#define _MAP_MAPREG_H_ +#ifndef MAP_MAPREG_H +#define MAP_MAPREG_H #include "script.h" // struct reg_db #include "../common/cbasetypes.h" @@ -50,4 +50,4 @@ struct mapreg_interface *mapreg; void mapreg_defaults(void); -#endif /* _MAP_MAPREG_H_ */ +#endif /* MAP_MAPREG_H */ diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 22399e289..270245e96 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -1,8 +1,8 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_MERCENARY_H_ -#define _MAP_MERCENARY_H_ +#ifndef MAP_MERCENARY_H +#define MAP_MERCENARY_H #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data @@ -99,4 +99,4 @@ struct mercenary_interface *mercenary; void mercenary_defaults(void); -#endif /* _MAP_MERCENARY_H_ */ +#endif /* MAP_MERCENARY_H */ diff --git a/src/map/mob.h b/src/map/mob.h index 7e222fa74..c8d43dbb2 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_MOB_H_ -#define _MAP_MOB_H_ +#ifndef MAP_MOB_H +#define MAP_MOB_H #include "map.h" // struct status_data, struct view_data, struct mob_skill #include "status.h" // struct status_data, struct status_change @@ -363,4 +363,4 @@ struct mob_interface *mob; void mob_defaults(void); -#endif /* _MAP_MOB_H_ */ +#endif /* MAP_MOB_H */ diff --git a/src/map/npc.c b/src/map/npc.c index bfac2b9d5..417aa6c61 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3368,7 +3368,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c } } - script->setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)__64BPTRSIZE(j), NULL); + script->setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)h64BPTRSIZE(j), NULL); aFree(temp); script->run_main(st); diff --git a/src/map/npc.h b/src/map/npc.h index 06a9312b5..4c904e1ac 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_NPC_H_ -#define _MAP_NPC_H_ +#ifndef MAP_NPC_H +#define MAP_NPC_H #include "map.h" // struct block_list #include "status.h" // struct status_change @@ -347,4 +347,4 @@ struct pcre_interface *libpcre; void npc_chat_defaults(void); #endif -#endif /* _MAP_NPC_H_ */ +#endif /* MAP_NPC_H */ diff --git a/src/map/packets.h b/src/map/packets.h index e995643d4..810f341d4 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -3,8 +3,8 @@ //Included directly by clif.h in packet_loaddb() -#ifndef _MAP_PACKETS_H_ -#define _MAP_PACKETS_H_ +#ifndef MAP_PACKETS_H +#define MAP_PACKETS_H #ifndef packet #define packet(a,b,...) @@ -3002,4 +3002,4 @@ packet(0x020d,-1); packetKeys(OBFUSCATIONKEY1,OBFUSCATIONKEY2,OBFUSCATIONKEY3); #endif -#endif /* _MAP_PACKETS_H_ */ +#endif /* MAP_PACKETS_H */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 403ab6fa3..55ab0c66a 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -3,8 +3,8 @@ /* Hercules Renewal: Phase Two http://hercules.ws/board/topic/383-hercules-renewal-phase-two/ */ -#ifndef _MAP_PACKETS_STRUCT_H_ -#define _MAP_PACKETS_STRUCT_H_ +#ifndef MAP_PACKETS_STRUCT_H +#define MAP_PACKETS_STRUCT_H #include "../common/mmo.h" @@ -962,4 +962,4 @@ struct packet_wis_end { #pragma pack(pop) #endif // not NetBSD < 6 / Solaris -#endif /* _MAP_PACKETS_STRUCT_H_ */ +#endif /* MAP_PACKETS_STRUCT_H */ diff --git a/src/map/party.h b/src/map/party.h index 1c58301d1..d62db23a7 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_PARTY_H_ -#define _MAP_PARTY_H_ +#ifndef MAP_PARTY_H +#define MAP_PARTY_H #include @@ -143,4 +143,4 @@ struct party_interface *party; void party_defaults(void); -#endif /* _MAP_PARTY_H_ */ +#endif /* MAP_PARTY_H */ diff --git a/src/map/path.h b/src/map/path.h index b48ff05fb..8d02e6558 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_PATH_H_ -#define _MAP_PATH_H_ +#ifndef MAP_PATH_H +#define MAP_PATH_H #include "map.h" // enum cell_chk #include "../common/cbasetypes.h" @@ -47,4 +47,4 @@ struct path_interface *path; void path_defaults(void); -#endif /* _MAP_PATH_H_ */ +#endif /* MAP_PATH_H */ diff --git a/src/map/pc.c b/src/map/pc.c index b8b6cda46..104a3cde0 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6230,7 +6230,7 @@ int pc_maxparameterincrease(struct map_session_data* sd, int type) { * Subtracts status points according to the cost of the increased stat points. * * @param sd The target character. - * @param type The stat to change (see enum _sp) + * @param type The stat to change (see enum status_point_types) * @param increase The stat increase (strictly positive) amount. * @retval true if the stat was increased by any amount. * @retval false if there were no changes. @@ -6289,7 +6289,7 @@ bool pc_statusup(struct map_session_data* sd, int type, int increase) { * Does not subtract status points for the cost of the modified stat points. * * @param sd The target character. - * @param type The stat to change (see enum _sp) + * @param type The stat to change (see enum status_point_types) * @param val The stat increase (or decrease) amount. * @return the stat increase amount. * @retval 0 if no changes were made. diff --git a/src/map/pc.h b/src/map/pc.h index 1789a8a7b..f33127036 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_PC_H_ -#define _MAP_PC_H_ +#ifndef MAP_PC_H +#define MAP_PC_H #include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT @@ -1026,4 +1026,4 @@ struct pc_interface *pc; void pc_defaults(void); -#endif /* _MAP_PC_H_ */ +#endif /* MAP_PC_H */ diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 7c8cdd82a..f52e2ba22 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_PC_GROUPS_H_ -#define _MAP_PC_GROUPS_H_ +#ifndef MAP_PC_GROUPS_H +#define MAP_PC_GROUPS_H #include "../common/cbasetypes.h" #include "../common/conf.h" @@ -96,4 +96,4 @@ struct pc_groups_interface *pcg; void pc_groups_defaults(void); -#endif /* _MAP_PC_GROUPS_H_ */ +#endif /* MAP_PC_GROUPS_H */ diff --git a/src/map/pet.h b/src/map/pet.h index 8dde0fac2..5c890ef85 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_PET_H_ -#define _MAP_PET_H_ +#ifndef MAP_PET_H +#define MAP_PET_H #include "map.h" // struct block_list #include "status.h" // enum sc_type @@ -158,4 +158,4 @@ struct pet_interface *pet; void pet_defaults(void); -#endif /* _MAP_PET_H_ */ +#endif /* MAP_PET_H */ diff --git a/src/map/quest.h b/src/map/quest.h index 87894d639..9d617e369 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_QUEST_H_ -#define _MAP_QUEST_H_ +#ifndef MAP_QUEST_H +#define MAP_QUEST_H #include "map.h" // TBL_PC #include "../common/cbasetypes.h" @@ -52,4 +52,4 @@ struct quest_interface *quest; void quest_defaults(void); -#endif /* _MAP_QUEST_H_ */ +#endif /* MAP_QUEST_H */ diff --git a/src/map/script.c b/src/map/script.c index c7e1dc1d2..8fb3975f8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1502,9 +1502,9 @@ const char* parse_syntax(const char* p) script->set_label(l,script->pos,p); } // check duplication of case label [Rayce] - if(linkdb_search(&script->syntax.curly[pos].case_label, (void*)__64BPTRSIZE(v)) != NULL) + if(linkdb_search(&script->syntax.curly[pos].case_label, (void*)h64BPTRSIZE(v)) != NULL) disp_error_message("parse_syntax: dup 'case'",p); - linkdb_insert(&script->syntax.curly[pos].case_label, (void*)__64BPTRSIZE(v), (void*)1); + linkdb_insert(&script->syntax.curly[pos].case_label, (void*)h64BPTRSIZE(v), (void*)1); sprintf(label,"set $@__SW%x_VAL,0;",script->syntax.curly[pos].index); script->syntax.curly[script->syntax.curly_count++].type = TYPE_NULL; @@ -2627,7 +2627,7 @@ void* get_val2(struct script_state* st, int64 uid, struct reg_db *ref) { script->push_val(st->stack, C_NAME, uid, ref); data = script_getdatatop(st, -1); script->get_val(st, data); - return (data->type == C_INT ? (void*)__64BPTRSIZE((int32)data->u.num) : (void*)__64BPTRSIZE(data->u.str)); // u.num is int32 because it comes from script->get_val + return (data->type == C_INT ? (void*)h64BPTRSIZE((int32)data->u.num) : (void*)h64BPTRSIZE(data->u.str)); // u.num is int32 because it comes from script->get_val } /** * Because, currently, array members with key 0 are indifferenciable from normal variables, we should ensure its actually in @@ -2648,7 +2648,7 @@ void script_array_ensure_zero(struct script_state *st, struct map_session_data * insert = true; script_removetop(st, -1, 0); } else { - int32 num = (int32)__64BPTRSIZE(script->get_val2(st, uid, ref)); + int32 num = (int32)h64BPTRSIZE(script->get_val2(st, uid, ref)); if( num ) insert = true; script_removetop(st, -1, 0); @@ -2917,7 +2917,7 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co } else {// integer variable // FIXME: This isn't safe, in 32bits systems we're converting a 64bit pointer // to a 32bit int, this will lead to overflows! [Panikon] - int val = (int)__64BPTRSIZE(value); + int val = (int)h64BPTRSIZE(value); if(script->str_data[script_getvarid(num)].type == C_PARAM) { if( pc->setparam(sd, script->str_data[script_getvarid(num)].val, val) == 0 ) { @@ -5665,7 +5665,7 @@ BUILDIN(input) else { int amount = sd->npc_amount; - script->set_reg(st, sd, uid, name, (void*)__64BPTRSIZE(cap_value(amount,min,max)), script_getref(st,2)); + script->set_reg(st, sd, uid, name, (void*)h64BPTRSIZE(cap_value(amount,min,max)), script_getref(st,2)); script_pushint(st, (amount > max ? 1 : amount < min ? -1 : 0)); } st->state = RUN; @@ -5753,7 +5753,7 @@ BUILDIN(setr) { if( is_string_variable(name) ) script->set_reg(st,sd,num,name,(void*)script_getstr(st,3),script_getref(st,2)); else - script->set_reg(st,sd,num,name,(void*)__64BPTRSIZE(script_getnum(st,3)),script_getref(st,2)); + script->set_reg(st,sd,num,name,(void*)h64BPTRSIZE(script_getnum(st,3)),script_getref(st,2)); return true; } @@ -5808,7 +5808,7 @@ BUILDIN(setarray) else {// int array for( i = 3; start < end; ++start, ++i ) - script->set_reg(st, sd, reference_uid(id, start), name, (void*)__64BPTRSIZE(script_getnum(st,i)), reference_getref(data)); + script->set_reg(st, sd, reference_uid(id, start), name, (void*)h64BPTRSIZE(script_getnum(st,i)), reference_getref(data)); } return true; } @@ -5850,7 +5850,7 @@ BUILDIN(cleararray) if( is_string_variable(name) ) v = (void*)script_getstr(st, 3); else - v = (void*)__64BPTRSIZE(script_getnum(st, 3)); + v = (void*)h64BPTRSIZE(script_getnum(st, 3)); end = start + script_getnum(st, 4); if( end > SCRIPT_MAX_ARRAYSIZE ) @@ -6425,9 +6425,9 @@ BUILDIN(checkweight2) slots = pc->inventoryblank(sd); for(i=0; iget_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it))); + nameid = (int32)h64BPTRSIZE(script->get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it))); script_removetop(st, -1, 0); - amount = (int32)__64BPTRSIZE(script->get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb))); + amount = (int32)h64BPTRSIZE(script->get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb))); script_removetop(st, -1, 0); if(fail) continue; //cpntonie to depop rest @@ -12412,18 +12412,18 @@ BUILDIN(undisguise) } /*========================================== - * Transform a bl to another _class, + * Transform a bl to another class, * @type unused *------------------------------------------*/ BUILDIN(classchange) { - int _class,type; + int class_,type; struct block_list *bl=map->id2bl(st->oid); if(bl==NULL) return true; - _class=script_getnum(st,2); + class_=script_getnum(st,2); type=script_getnum(st,3); - clif->class_change(bl,_class,type); + clif->class_change(bl,class_,type); return true; } @@ -13439,7 +13439,7 @@ BUILDIN(getmapxy) sd=script->rid2sd(st); else sd=NULL; - script->set_reg(st,sd,num,name,(void*)__64BPTRSIZE(x),script_getref(st,3)); + script->set_reg(st,sd,num,name,(void*)h64BPTRSIZE(x),script_getref(st,3)); //Set MapY num=st->stack->stack_data[st->start+4].u.num; @@ -13450,7 +13450,7 @@ BUILDIN(getmapxy) sd=script->rid2sd(st); else sd=NULL; - script->set_reg(st,sd,num,name,(void*)__64BPTRSIZE(y),script_getref(st,4)); + script->set_reg(st,sd,num,name,(void*)h64BPTRSIZE(y),script_getref(st,4)); //Return Success value script_pushint(st,0); @@ -13476,7 +13476,7 @@ BUILDIN(logmes) BUILDIN(summon) { - int _class, timeout=0; + int class_, timeout=0; const char *str,*event=""; TBL_PC *sd; struct mob_data *md; @@ -13486,7 +13486,7 @@ BUILDIN(summon) if (!sd) return true; str = script_getstr(st,2); - _class = script_getnum(st,3); + class_ = script_getnum(st,3); if( script_hasdata(st,4) ) timeout=script_getnum(st,4); if( script_hasdata(st,5) ) { @@ -13496,7 +13496,7 @@ BUILDIN(summon) clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick); - md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_MEDIUM, AI_NONE); + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, class_, event, SZ_MEDIUM, AI_NONE); if (md) { md->master_id=sd->bl.id; md->special_state.ai = AI_ATTACK; @@ -14400,7 +14400,7 @@ BUILDIN(sscanf) { if(sscanf(str, buf, &ref_int)==0) { break; } - script->set_reg(st, sd, reference_uid( reference_getid(data), reference_getindex(data) ), buf_p, (void *)__64BPTRSIZE(ref_int), reference_getref(data)); + script->set_reg(st, sd, reference_uid( reference_getid(data), reference_getindex(data) ), buf_p, (void *)h64BPTRSIZE(ref_int), reference_getref(data)); } arg++; @@ -14767,7 +14767,7 @@ BUILDIN(setd) if( is_string_variable(varname) ) { script->setd_sub(st, sd, varname, elem, (void *)script_getstr(st, 3), NULL); } else { - script->setd_sub(st, sd, varname, elem, (void *)__64BPTRSIZE(script_getnum(st, 3)), NULL); + script->setd_sub(st, sd, varname, elem, (void *)h64BPTRSIZE(script_getnum(st, 3)), NULL); } return true; @@ -14841,7 +14841,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) if( is_string_variable(name) ) script->setd_sub(st, sd, name, i, (void *)(str?str:""), reference_getref(data)); else - script->setd_sub(st, sd, name, i, (void *)__64BPTRSIZE((str?atoi(str):0)), reference_getref(data)); + script->setd_sub(st, sd, name, i, (void *)h64BPTRSIZE((str?atoi(str):0)), reference_getref(data)); } } if( i == max_rows && max_rows < SQL->NumRows(handle) ) { @@ -15395,7 +15395,7 @@ BUILDIN(searchitem) for( i = 0; i < count; ++start, ++i ) {// Set array - void* v = (void*)__64BPTRSIZE((int)items[i]->nameid); + void* v = (void*)h64BPTRSIZE((int)items[i]->nameid); script->set_reg(st, sd, reference_uid(id, start), name, v, reference_getref(data)); } diff --git a/src/map/script.h b/src/map/script.h index bb6cd6e11..48abf1487 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_SCRIPT_H_ -#define _MAP_SCRIPT_H_ +#ifndef MAP_SCRIPT_H +#define MAP_SCRIPT_H #include #include @@ -715,4 +715,4 @@ struct script_interface *script; void script_defaults(void); -#endif /* _MAP_SCRIPT_H_ */ +#endif /* MAP_SCRIPT_H */ diff --git a/src/map/searchstore.h b/src/map/searchstore.h index c9b93ba54..d8abde615 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_SEARCHSTORE_H_ -#define _MAP_SEARCHSTORE_H_ +#ifndef MAP_SEARCHSTORE_H +#define MAP_SEARCHSTORE_H #include @@ -99,4 +99,4 @@ struct searchstore_interface *searchstore; void searchstore_defaults (void); -#endif /* _MAP_SEARCHSTORE_H_ */ +#endif /* MAP_SEARCHSTORE_H */ diff --git a/src/map/skill.h b/src/map/skill.h index 6666fbbf2..70e5f4911 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_SKILL_H_ -#define _MAP_SKILL_H_ +#ifndef MAP_SKILL_H +#define MAP_SKILL_H #include "../config/core.h" // RENEWAL_CAST @@ -2021,4 +2021,4 @@ struct skill_interface *skill; void skill_defaults(void); -#endif /* _MAP_SKILL_H_ */ +#endif /* MAP_SKILL_H */ diff --git a/src/map/status.h b/src/map/status.h index 13d0a7841..bed0d9fbf 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_STATUS_H_ -#define _MAP_STATUS_H_ +#ifndef MAP_STATUS_H +#define MAP_STATUS_H #include "../config/core.h" // defType, RENEWAL, RENEWAL_ASPD @@ -2047,4 +2047,4 @@ struct status_interface *status; void status_defaults(void); -#endif /* _MAP_STATUS_H_ */ +#endif /* MAP_STATUS_H */ diff --git a/src/map/storage.c b/src/map/storage.c index f2f0d8986..217f14a3a 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -31,10 +31,10 @@ struct guild_storage_interface gstorage_s; /*========================================== * Sort items in the warehouse *------------------------------------------*/ -int storage_comp_item(const void *_i1, const void *_i2) +int storage_comp_item(const void *i1_, const void *i2_) { - struct item *i1 = (struct item *)_i1; - struct item *i2 = (struct item *)_i2; + struct item *i1 = (struct item *)i1_; + struct item *i2 = (struct item *)i2_; if (i1->nameid == i2->nameid) return 0; diff --git a/src/map/storage.h b/src/map/storage.h index 5edb68cfc..186f21263 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_STORAGE_H_ -#define _MAP_STORAGE_H_ +#ifndef MAP_STORAGE_H +#define MAP_STORAGE_H #include "../common/cbasetypes.h" #include "../common/db.h" @@ -25,7 +25,7 @@ struct storage_interface { int (*gettocart) (struct map_session_data *sd,int index,int amount); void (*close) (struct map_session_data *sd); void (*pc_quit) (struct map_session_data *sd, int flag); - int (*comp_item) (const void *_i1, const void *_i2); + int (*comp_item) (const void *i1_, const void *i2_); void (*sortitem) (struct item* items, unsigned int size); int (*reconnect_sub) (DBKey key, DBData *data, va_list ap); }; @@ -60,4 +60,4 @@ struct guild_storage_interface *gstorage; void storage_defaults(void); void gstorage_defaults(void); -#endif /* _MAP_STORAGE_H_ */ +#endif /* MAP_STORAGE_H */ diff --git a/src/map/trade.h b/src/map/trade.h index 143f26d74..f91ccd4a2 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_TRADE_H_ -#define _MAP_TRADE_H_ +#ifndef MAP_TRADE_H +#define MAP_TRADE_H //Max distance from traders to enable a trade to take place. //TODO: battle_config candidate? @@ -27,4 +27,4 @@ struct trade_interface *trade; void trade_defaults(void); -#endif /* _MAP_TRADE_H_ */ +#endif /* MAP_TRADE_H */ diff --git a/src/map/unit.h b/src/map/unit.h index f29a6903a..9b95bae41 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_UNIT_H_ -#define _MAP_UNIT_H_ +#ifndef MAP_UNIT_H +#define MAP_UNIT_H #include "clif.h" // clr_type #include "path.h" // struct walkpath_data @@ -124,4 +124,4 @@ struct unit_interface *unit; void unit_defaults(void); -#endif /* _MAP_UNIT_H_ */ +#endif /* MAP_UNIT_H */ diff --git a/src/map/vending.h b/src/map/vending.h index b65e888e3..63cb632a9 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -2,8 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifndef _MAP_VENDING_H_ -#define _MAP_VENDING_H_ +#ifndef MAP_VENDING_H +#define MAP_VENDING_H #include "../common/cbasetypes.h" #include "../common/db.h" @@ -36,4 +36,4 @@ struct vending_interface *vending; void vending_defaults(void); -#endif /* _MAP_VENDING_H_ */ +#endif /* MAP_VENDING_H */ diff --git a/tools/HPMHookGen/HPMDataCheckGen.pl b/tools/HPMHookGen/HPMDataCheckGen.pl index a79811c47..7ec1ba7e4 100644 --- a/tools/HPMHookGen/HPMDataCheckGen.pl +++ b/tools/HPMHookGen/HPMDataCheckGen.pl @@ -24,7 +24,7 @@ foreach my $file (@files) { my @filepath = split(/[\/\\]/, $data->{compounddef}->{location}->{file}); my $foldername = uc($filepath[-2]); my $filename = uc($filepath[-1]); $filename =~ s/-/_/g; $filename =~ s/\.[^.]*$//; - my $name = "_${foldername}_${filename}_H_"; + my $name = "${foldername}_${filename}_H"; push @{ $out{$name} }, $data->{compounddef}->{compoundname}; } @@ -37,8 +37,8 @@ print FH <<"EOF"; // // NOTE: This file was auto-generated and should never be manually edited, // as it will get overwritten. -#ifndef _HPM_DATA_CHECK_H_ -#define _HPM_DATA_CHECK_H_ +#ifndef HPM_DATA_CHECK_H +#define HPM_DATA_CHECK_H HPExport const struct s_HPMDataCheck HPMDataCheck[] = { @@ -63,6 +63,6 @@ print FH <<"EOF"; }; HPExport unsigned int HPMDataCheckLen = ARRAYLENGTH(HPMDataCheck); -#endif /* _HPM_DATA_CHECK_H_ */ +#endif /* HPM_DATA_CHECK_H */ EOF close(FH); -- cgit v1.2.3-70-g09d2