summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-11-19 02:20:07 -0200
committershennetsind <ind@henn.et>2013-11-19 02:20:07 -0200
commit242bc9fc39c90364dcf5f1a73a6d759efeef0ffd (patch)
tree0ac9e1e42c5db47d46f5a2d9e9d665b20fb46f63
parentd076f129c90ac9e3a96659488f702f81def1863a (diff)
parentcb85f27f1ee334982fc3f9dfc1ffe824a1f8905c (diff)
downloadhercules-242bc9fc39c90364dcf5f1a73a6d759efeef0ffd.tar.gz
hercules-242bc9fc39c90364dcf5f1a73a6d759efeef0ffd.tar.bz2
hercules-242bc9fc39c90364dcf5f1a73a6d759efeef0ffd.tar.xz
hercules-242bc9fc39c90364dcf5f1a73a6d759efeef0ffd.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
-rw-r--r--src/char/char.c2
-rw-r--r--src/char/char.h2
-rw-r--r--src/char/inter.h9
-rw-r--r--src/common/HPM.c1
-rw-r--r--src/common/HPM.h24
-rw-r--r--src/common/HPMi.h32
-rw-r--r--src/common/cbasetypes.h10
-rw-r--r--src/common/console.c4
-rw-r--r--src/common/core.c2
-rw-r--r--src/common/db.c2
-rw-r--r--src/common/db.h12
-rw-r--r--src/common/ers.h10
-rw-r--r--src/common/grfio.h2
-rw-r--r--src/common/malloc.c64
-rw-r--r--src/common/malloc.h16
-rw-r--r--src/common/mapindex.h2
-rw-r--r--src/common/mempool.c10
-rw-r--r--src/common/mmo.h2
-rw-r--r--src/common/netbuffer.h10
-rw-r--r--src/common/network.c2
-rw-r--r--src/common/raconf.c29
-rw-r--r--src/common/showmsg.c111
-rw-r--r--src/common/socket.c26
-rw-r--r--src/common/socket.h21
-rw-r--r--src/common/spinlock.h4
-rw-r--r--src/common/sql.h14
-rw-r--r--src/common/strlib.h32
-rw-r--r--src/common/timer.h2
-rw-r--r--src/common/utils.h2
-rw-r--r--src/config/const.h7
-rw-r--r--src/login/login.h4
-rw-r--r--src/map/atcommand.c91
-rw-r--r--src/map/battle.c88
-rw-r--r--src/map/battle.h14
-rw-r--r--src/map/chrif.c2
-rw-r--r--src/map/clif.c20
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/elemental.h4
-rw-r--r--src/map/homunculus.h2
-rw-r--r--src/map/intif.c2
-rw-r--r--src/map/intif.h6
-rw-r--r--src/map/itemdb.h402
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/map.h18
-rw-r--r--src/map/mob.c8
-rw-r--r--src/map/mob.h11
-rw-r--r--src/map/path.h12
-rw-r--r--src/map/pc.c89
-rw-r--r--src/map/pc.h30
-rw-r--r--src/map/pet.h4
-rw-r--r--src/map/script.c21
-rw-r--r--src/map/script.h37
-rw-r--r--src/map/skill.c242
-rw-r--r--src/map/skill.h11
-rw-r--r--src/map/status.c109
-rw-r--r--src/map/status.h106
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HookingPoints.inc1
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Hooks.inc25
59 files changed, 1035 insertions, 800 deletions
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 <windows.h>
- #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 <dlfcn.h>
#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 <string.h> // 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 <string.h>
# 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 <string.h>
# include <stdlib.h>
# 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, "<unnamed>", 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), "<unnamed>", 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 <unistd.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
+#include "../common/winapi.h"
+#else // not WIN32
+#include <unistd.h>
+#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 a2bea32a8..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)
@@ -1931,11 +1925,11 @@ ACMD(monster)
number = battle_config.atc_spawn_quantity_limit;
if (strcmpi(info->command, "monstersmall") == 0)
- size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
+ size = SZ_SMALL;
else if (strcmpi(info->command, "monsterbig") == 0)
size = SZ_BIG;
else
- size = SZ_SMALL;
+ size = SZ_MEDIUM;
if (battle_config.etc_log)
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
@@ -6255,7 +6249,7 @@ ACMD(summon)
return false;
}
- md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_MEDIUM, AI_NONE);
if(!md)
return false;
@@ -7311,15 +7305,15 @@ ACMD(size)
{
int size = 0;
- size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
+ size = cap_value(atoi(message),SZ_MEDIUM,SZ_BIG);
if(sd->state.size) {
- sd->state.size = SZ_SMALL;
+ sd->state.size = SZ_MEDIUM;
pc->setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
}
sd->state.size = size;
- if( size == SZ_MEDIUM )
+ if( size == SZ_SMALL )
clif->specialeffect(&sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&sd->bl,422,AREA);
@@ -7341,12 +7335,12 @@ ACMD(sizeall)
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
if( pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
- pl_sd->state.size = SZ_SMALL;
+ pl_sd->state.size = SZ_MEDIUM;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
pl_sd->state.size = size;
- if( size == SZ_MEDIUM )
+ if( size == SZ_SMALL )
clif->specialeffect(&pl_sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&pl_sd->bl,422,AREA);
@@ -7377,17 +7371,17 @@ ACMD(sizeguild)
return false;
}
- size = cap_value(size,SZ_SMALL,SZ_BIG);
+ size = cap_value(size,SZ_MEDIUM,SZ_BIG);
for( i = 0; i < g->max_member; i++ ) {
if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
- pl_sd->state.size = SZ_SMALL;
+ pl_sd->state.size = SZ_MEDIUM;
pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
pl_sd->state.size = size;
- if( size == SZ_MEDIUM )
+ if( size == SZ_SMALL )
clif->specialeffect(&pl_sd->bl,420,AREA);
else if( size == SZ_BIG )
clif->specialeffect(&pl_sd->bl,422,AREA);
@@ -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 53544d66b..812301cd6 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -764,18 +764,18 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target,
if(sc->data[SC_IMPOSITIO])
damage += sc->data[SC_IMPOSITIO]->val2;
if(sc->data[SC_DRUMBATTLE]){
- if(tstatus->size == SZ_SMALL)
+ if(tstatus->size == SZ_MEDIUM)
damage += sc->data[SC_DRUMBATTLE]->val2;
- else if(tstatus->size == SZ_MEDIUM)
+ else if(tstatus->size == SZ_SMALL)
damage += 10 * sc->data[SC_DRUMBATTLE]->val1;
//else no bonus for large target
}
if(sc->data[SC_GS_MADNESSCANCEL])
damage += 100;
if(sc->data[SC_GS_GATLINGFEVER]){
- if(tstatus->size == SZ_SMALL)
+ if(tstatus->size == SZ_MEDIUM)
damage += 10 * sc->data[SC_GS_GATLINGFEVER]->val1;
- else if(tstatus->size == SZ_MEDIUM)
+ else if(tstatus->size == SZ_SMALL)
damage += -5 * sc->data[SC_GS_GATLINGFEVER]->val1;
else
damage += sc->data[SC_GS_GATLINGFEVER]->val1;
@@ -2200,8 +2200,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
break;
case NC_ARMSCANNON:
switch( tst->size ) {
- case SZ_SMALL: skillratio += 100 + 500 * skill_lv; break;// Small
- case SZ_MEDIUM: skillratio += 100 + 400 * skill_lv; break;// Medium
+ case SZ_MEDIUM: skillratio += 100 + 500 * skill_lv; break;// Medium
+ case SZ_SMALL: skillratio += 100 + 400 * skill_lv; break;// Small
case SZ_BIG: skillratio += 100 + 300 * skill_lv; break;// Large
}
RE_LVL_DMOD(100);
@@ -2414,21 +2414,21 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
case GN_SLINGITEM_RANGEMELEEATK:
if( sd ) {
switch( sd->itemid ) {
- case 13260: // Apple Bomob
- case 13261: // Coconut Bomb
- case 13262: // Melon Bomb
- case 13263: // Pinapple Bomb
- skillratio += 400; // Unconfirded
+ case ITEMID_APPLE_BOMB:
+ case ITEMID_COCONUT_BOMB:
+ case ITEMID_MELON_BOMB:
+ case ITEMID_PINEAPPLE_BOMB:
+ skillratio += 400; // Unconfirmed
break;
- case 13264: // Banana Bomb 2000%
+ case ITEMID_BANANA_BOMB: // 2000%
skillratio += 1900;
break;
- case 13265: skillratio -= 75; break; // Black Lump 25%
- case 13266: skillratio -= 25; break; // Hard Black Lump 75%
- case 13267: skillratio += 100; break; // Extremely Hard Black Lump 200%
+ case ITEMID_BLACK_LUMP: skillratio -= 75; break; // 25%
+ case ITEMID_BLACK_HARD_LUMP: skillratio -= 25; break; // 75%
+ case ITEMID_VERY_HARD_LUMP: skillratio += 100; break; // 200%
}
} else
- skillratio += 300; // Bombs
+ skillratio += 300; // Bombs
break;
case SO_VARETYR_SPEAR://ATK [{( Striking Level x 50 ) + ( Varetyr Spear Skill Level x 50 )} x Caster Base Level / 100 ] %
skillratio += -100 + 50 * skill_lv + ( sd ? pc->checkskill(sd, SO_STRIKING) * 50 : 0 );
@@ -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
@@ -4438,10 +4441,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
i*=i;
ATK_ADD(i); //Add str bonus.
switch (tstatus->size) { //Size-fix. Is this modified by weapon perfection?
- case SZ_SMALL: //Small: 125%
+ case SZ_MEDIUM: //Medium: 125%
ATK_RATE(125);
break;
- //case SZ_MEDIUM: //Medium: 100%
+ //case SZ_SMALL: //Medium: 100%
case SZ_BIG: //Large: 75%
ATK_RATE(75);
break;
@@ -4566,7 +4569,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(sd->inventory_data[index]->weight * 7 / 100);
switch (tstatus->size) {
- case SZ_SMALL: //Small: 115%
+ case SZ_MEDIUM: //Medium: 115%
ATK_RATE(115);
break;
case SZ_BIG: //Large: 85%
@@ -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 32f29b73c..913f55784 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1332,7 +1332,7 @@ int clif_spawn(struct block_list *bl)
clif->spiritball(&sd->bl);
if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect(bl,423,AREA);
- else if(sd->state.size==SZ_MEDIUM)
+ else if(sd->state.size==SZ_SMALL)
clif->specialeffect(bl,421,AREA);
if( sd->bg_id && map->list[sd->bl.m].flag.battleground )
clif->sendbgemblem_area(sd);
@@ -1352,7 +1352,7 @@ int clif_spawn(struct block_list *bl)
TBL_MOB *md = ((TBL_MOB*)bl);
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_MEDIUM)
+ else if(md->special_state.size==SZ_SMALL)
clif->specialeffect(&md->bl,421,AREA);
}
break;
@@ -1361,7 +1361,7 @@ int clif_spawn(struct block_list *bl)
TBL_NPC *nd = ((TBL_NPC*)bl);
if( nd->size == SZ_BIG )
clif->specialeffect(&nd->bl,423,AREA);
- else if( nd->size == SZ_MEDIUM )
+ else if( nd->size == SZ_SMALL )
clif->specialeffect(&nd->bl,421,AREA);
}
break;
@@ -1560,7 +1560,7 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u
// clif_movepc(sd);
if(sd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect(&sd->bl,423,AREA);
- else if(sd->state.size==SZ_MEDIUM)
+ else if(sd->state.size==SZ_SMALL)
clif->specialeffect(&sd->bl,421,AREA);
}
break;
@@ -1569,7 +1569,7 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u
TBL_MOB *md = ((TBL_MOB*)bl);
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==SZ_MEDIUM)
+ else if(md->special_state.size==SZ_SMALL)
clif->specialeffect(&md->bl,421,AREA);
}
break;
@@ -4268,7 +4268,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
clif->getareachar_pc(sd, tsd);
if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris]
clif->specialeffect_single(bl,423,sd->fd);
- else if(tsd->state.size==SZ_MEDIUM)
+ else if(tsd->state.size==SZ_SMALL)
clif->specialeffect_single(bl,421,sd->fd);
if( tsd->bg_id && map->list[tsd->bl.m].flag.battleground )
clif->sendbgemblem_single(sd->fd,tsd);
@@ -4287,7 +4287,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
clif->dispchat((struct chat_data*)map->id2bl(nd->chat_id),sd->fd);
if( nd->size == SZ_BIG )
clif->specialeffect_single(bl,423,sd->fd);
- else if( nd->size == SZ_MEDIUM )
+ else if( nd->size == SZ_SMALL )
clif->specialeffect_single(bl,421,sd->fd);
}
break;
@@ -4296,7 +4296,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
TBL_MOB* md = (TBL_MOB*)bl;
if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris]
clif->specialeffect_single(bl,423,sd->fd);
- else if(md->special_state.size==SZ_MEDIUM)
+ else if(md->special_state.size==SZ_SMALL)
clif->specialeffect_single(bl,421,sd->fd);
#if PACKETVER >= 20120404
if( !(md->status.mode&MD_BOSS) ){
@@ -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..1030035ea 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -28,75 +28,292 @@ 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
enum item_itemid {
- ITEMID_HOLY_WATER = 523,
- ITEMID_EMPERIUM = 714,
- ITEMID_YELLOW_GEMSTONE = 715,
- ITEMID_RED_GEMSTONE = 716,
- ITEMID_BLUE_GEMSTONE = 717,
- ITEMID_TRAP = 1065,
- ITEMID_STRANGE_EMBRYO = 6415,
- ITEMID_FACE_PAINT = 6120,
- ITEMID_STONE = 7049,
- ITEMID_SKULL_ = 7420,
- ITEMID_TOKEN_OF_SIEGFRIED = 7621,
- ITEMID_TRAP_ALLOY = 7940,
- ITEMID_ANCILLA = 12333,
- ITEMID_REINS_OF_MOUNT = 12622,
- ITEMID_LOVE_ANGEL = 12287,
- ITEMID_SQUIRREL = 12288,
- ITEMID_GOGO = 12289,
- ITEMID_PICTURE_DIARY = 12304,
- ITEMID_MINI_HEART = 12305,
- ITEMID_NEWCOMER = 12306,
- ITEMID_KID = 12307,
- ITEMID_MAGIC_CASTLE = 12308,
- ITEMID_BULGING_HEAD = 12309,
+ ITEMID_RED_POTION = 501,
+ ITEMID_YELLOW_POTION = 503,
+ ITEMID_WHITE_POTION = 504,
+ ITEMID_BLUE_POTION = 505,
+ ITEMID_HOLY_WATER = 523,
+ ITEMID_RED_SLIM_POTION = 545,
+ ITEMID_YELLOW_SLIM_POTION = 546,
+ ITEMID_WHITE_SLIM_POTION = 547,
+ ITEMID_WING_OF_FLY = 601,
+ ITEMID_WING_OF_BUTTERFLY = 602,
+ ITEMID_BRANCH_OF_DEAD_TREE = 604,
+ ITEMID_ANODYNE = 605,
+ ITEMID_ALOEBERA = 606,
+ ITEMID_EMPTY_BOTTLE = 713,
+ ITEMID_EMPERIUM = 714,
+ ITEMID_YELLOW_GEMSTONE = 715,
+ ITEMID_RED_GEMSTONE = 716,
+ ITEMID_BLUE_GEMSTONE = 717,
+ ITEMID_ORIDECON_STONE = 756,
+ ITEMID_ALCHOL = 970,
+ ITEMID_ORIDECON = 984,
+ ITEMID_BOODY_RED = 990,
+ ITEMID_CRYSTAL_BLUE = 991,
+ ITEMID_WIND_OF_VERDURE = 992,
+ ITEMID_YELLOW_LIVE = 993,
+ ITEMID_FLAME_HEART = 994,
+ ITEMID_MISTIC_FROZEN = 995,
+ ITEMID_ROUGH_WIND = 996,
+ ITEMID_GREAT_NATURE = 997,
+ ITEMID_IRON = 998,
+ ITEMID_STEEL = 999,
+ ITEMID_STAR_CRUMB = 1000,
+ ITEMID_IRON_ORE = 1002,
+ ITEMID_PHRACON = 1010,
+ ITEMID_EMVERETARCON = 1011,
+ ITEMID_TRAP = 1065,
+ ITEMID_STRANGE_EMBRYO = 6415,
+ ITEMID_FACE_PAINT = 6120,
+ ITEMID_STONE = 7049,
+ ITEMID_FIRE_BOTTLE = 7135,
+ ITEMID_ACID_BOTTLE = 7136,
+ ITEMID_MENEATER_PLANT_BOTTLE = 7137,
+ ITEMID_MINI_BOTTLE = 7138,
+ ITEMID_COATING_BOTTLE = 7139,
+ ITEMID_FRAGMENT_OF_CRYSTAL = 7321,
+ ITEMID_SKULL_ = 7420,
+ ITEMID_TOKEN_OF_SIEGFRIED = 7621,
+ ITEMID_TRAP_ALLOY = 7940,
+ ITEMID_RED_POUCH_OF_SURPRISE = 12024,
+ ITEMID_BLOODY_DEAD_BRANCH = 12103,
+ ITEMID_PORING_BOX = 12109,
+ ITEMID_MERCENARY_RED_POTION = 12184,
+ ITEMID_MERCENARY_BLUE_POTION = 12185,
+ ITEMID_BATTLE_MANUAL = 12208,
+ ITEMID_BUBBLE_GUM = 12210,
+ ITEMID_GIANT_FLY_WING = 12212,
+ ITEMID_NEURALIZER = 12213,
+ ITEMID_M_CENTER_POTION = 12241,
+ ITEMID_M_AWAKENING_POTION = 12242,
+ ITEMID_M_BERSERK_POTION = 12243,
+ ITEMID_COMP_BATTLE_MANUAL = 12263,
+ ITEMID_COMP_BUBBLE_GUM = 12264,
+ ITEMID_LOVE_ANGEL = 12287,
+ ITEMID_SQUIRREL = 12288,
+ ITEMID_GOGO = 12289,
+ ITEMID_PICTURE_DIARY = 12304,
+ ITEMID_MINI_HEART = 12305,
+ ITEMID_NEWCOMER = 12306,
+ ITEMID_KID = 12307,
+ ITEMID_MAGIC_CASTLE = 12308,
+ ITEMID_BULGING_HEAD = 12309,
+ ITEMID_THICK_MANUAL50 = 12312,
+ ITEMID_ANCILLA = 12333,
+ ITEMID_BLACK_THING = 12435,
+ ITEMID_REINS_OF_MOUNT = 12622,
+ ITEMID_NOBLE_NAMEPLATE = 12705,
+ ITEMID_DUN_TELE_SCROLL1 = 14527,
+ ITEMID_BATTLE_MANUAL25 = 14532,
+ ITEMIDBATTLE_MANUAL100 = 14533,
+ ITEMID_BATTLE_MANUAL_X3 = 14545,
+ ITEMID_DUN_TELE_SCROLL2 = 14581,
+ ITEMID_WOB_RUNE = 14582,
+ ITEMID_WOB_SCHWALTZ = 14583,
+ ITEMID_WOB_RACHEL = 14584,
+ ITEMID_WOB_LOCAL = 14585,
+ ITEMID_SIEGE_TELEPORT_SCROLL = 14591,
+ ITEMID_JOB_MANUAL50 = 14592,
+};
+
+enum cards_item_list {
+ ITEMID_GHOSTRING_CARD = 4047,
+ ITEMID_PHREEONI_CARD = 4121,
+ ITEMID_MISTRESS_CARD = 4132,
+ ITEMID_ORC_LOAD_CARD = 4135,
+ ITEMID_ORC_HERO_CARD = 4143,
+ ITEMID_TAO_GUNKA_CARD = 4302,
};
/**
- * Rune Knight
+ * Mechanic
**/
+enum mechanic_item_list {
+ ITEMID_ACCELERATOR = 2800,
+ ITEMID_HOVERING_BOOSTER, // 2801
+ ITEMID_SUICIDAL_DEVICE, // 2802
+ ITEMID_SHAPE_SHIFTER, // 2803
+ ITEMID_COOLING_DEVICE, // 2804
+ ITEMID_MAGNETIC_FIELD_GENERATOR, // 2805
+ ITEMID_BARRIER_BUILDER, // 2806
+ ITEMID_REPAIR_KIT, // 2807
+ ITEMID_CAMOUFLAGE_GENERATOR, // 2808
+ ITEMID_HIGH_QUALITY_COOLER, // 2809
+ ITEMID_SPECIAL_COOLER, // 2810
+ ITEMID_MONKEY_SPANNER = 6186,
+};
+
+/**
+ * Spell Books
+ */
+enum spell_book_item_list {
+ ITEMID_MAGIC_BOOK_FB = 6189,
+ ITEMID_MAGIC_BOOK_CB, // 6190
+ ITEMID_MAGIC_BOOK_LB, // 6191
+ ITEMID_MAGIC_BOOK_SG, // 6192
+ ITEMID_MAGIC_BOOK_LOV, // 6193
+ ITEMID_MAGIC_BOOK_MS, // 6194
+ ITEMID_MAGIC_BOOK_CM, // 6195
+ ITEMID_MAGIC_BOOK_TV, // 6196
+ ITEMID_MAGIC_BOOK_TS, // 6197
+ ITEMID_MAGIC_BOOK_JT, // 6198
+ ITEMID_MAGIC_BOOK_WB, // 6199
+ ITEMID_MAGIC_BOOK_HD, // 6200
+ ITEMID_MAGIC_BOOK_ES, // 6201
+ ITEMID_MAGIC_BOOK_ES_, // 6202
+ ITEMID_MAGIC_BOOK_CL, // 6203
+ ITEMID_MAGIC_BOOK_CR, // 6204
+ ITEMID_MAGIC_BOOK_DL, // 6205
+};
-enum {
- ITEMID_NAUTHIZ = 12725,
- ITEMID_RAIDO,
- ITEMID_BERKANA,
- ITEMID_ISA,
- ITEMID_OTHILA,
- ITEMID_URUZ,
- ITEMID_THURISAZ,
- ITEMID_WYRD,
- ITEMID_HAGALAZ,
- ITEMID_LUX_ANIMA = 22540,
-} rune_list;
+/**
+ * Mercenary Scrolls
+ */
+enum mercenary_scroll_item_list {
+ ITEMID_BOW_MERCENARY_SCROLL1 = 12153,
+ ITEMID_BOW_MERCENARY_SCROLL2, // 12154
+ ITEMID_BOW_MERCENARY_SCROLL3, // 12155
+ ITEMID_BOW_MERCENARY_SCROLL4, // 12156
+ ITEMID_BOW_MERCENARY_SCROLL5, // 12157
+ ITEMID_BOW_MERCENARY_SCROLL6, // 12158
+ ITEMID_BOW_MERCENARY_SCROLL7, // 12159
+ ITEMID_BOW_MERCENARY_SCROLL8, // 12160
+ ITEMID_BOW_MERCENARY_SCROLL9, // 12161
+ ITEMID_BOW_MERCENARY_SCROLL10, // 12162
+ ITEMID_SWORDMERCENARY_SCROLL1, // 12163
+ ITEMID_SWORDMERCENARY_SCROLL2, // 12164
+ ITEMID_SWORDMERCENARY_SCROLL3, // 12165
+ ITEMID_SWORDMERCENARY_SCROLL4, // 12166
+ ITEMID_SWORDMERCENARY_SCROLL5, // 12167
+ ITEMID_SWORDMERCENARY_SCROLL6, // 12168
+ ITEMID_SWORDMERCENARY_SCROLL7, // 12169
+ ITEMID_SWORDMERCENARY_SCROLL8, // 12170
+ ITEMID_SWORDMERCENARY_SCROLL9, // 12171
+ ITEMID_SWORDMERCENARY_SCROLL10, // 12172
+ ITEMID_SPEARMERCENARY_SCROLL1, // 12173
+ ITEMID_SPEARMERCENARY_SCROLL2, // 12174
+ ITEMID_SPEARMERCENARY_SCROLL3, // 12175
+ ITEMID_SPEARMERCENARY_SCROLL4, // 12176
+ ITEMID_SPEARMERCENARY_SCROLL5, // 12177
+ ITEMID_SPEARMERCENARY_SCROLL6, // 12178
+ ITEMID_SPEARMERCENARY_SCROLL7, // 12179
+ ITEMID_SPEARMERCENARY_SCROLL8, // 12180
+ ITEMID_SPEARMERCENARY_SCROLL9, // 12181
+ ITEMID_SPEARMERCENARY_SCROLL10, // 12182
+};
/**
- * Mechanic
+ * Cash Food
+ */
+enum cash_food_item_list {
+ ITEMID_STR_DISH10_ = 12202,
+ ITEMID_AGI_DISH10_, // 12203
+ ITEMID_INT_DISH10_, // 12204
+ ITEMID_DEX_DISH10_, // 12205
+ ITEMID_LUK_DISH10_, // 12206
+ ITEMID_VIT_DISH10_, // 12207
+};
+
+/**
+ * GC Poison
+ */
+enum poison_item_list {
+ ITEMID_POISON_PARALYSIS = 12717,
+ ITEMID_POISON_LEECH, // 12718
+ ITEMID_POISON_OBLIVION, // 12719
+ ITEMID_POISON_CONTAMINATION, // 12720
+ ITEMID_POISON_NUMB, // 12721
+ ITEMID_POISON_FEVER, // 12722
+ ITEMID_POISON_LAUGHING, // 12723
+ ITEMID_POISON_FATIGUE, // 12724
+};
+
+
+/**
+ * Rune Knight
**/
-enum {
- ITEMID_ACCELERATOR = 2800,
- ITEMID_HOVERING_BOOSTER,
- ITEMID_SUICIDAL_DEVICE,
- ITEMID_SHAPE_SHIFTER,
- ITEMID_COOLING_DEVICE,
- ITEMID_MAGNETIC_FIELD_GENERATOR,
- ITEMID_BARRIER_BUILDER,
- ITEMID_REPAIR_KIT,
- ITEMID_CAMOUFLAGE_GENERATOR,
- ITEMID_HIGH_QUALITY_COOLER,
- ITEMID_SPECIAL_COOLER,
- ITEMID_MONKEY_SPANNER = 6186,
-} mecha_item_list;
-
-enum {
+enum rune_item_list {
+ ITEMID_NAUTHIZ = 12725,
+ ITEMID_RAIDO, // 12726
+ ITEMID_BERKANA, // 12727
+ ITEMID_ISA, // 12728
+ ITEMID_OTHILA, // 12729
+ ITEMID_URUZ, // 12730
+ ITEMID_THURISAZ, // 12731
+ ITEMID_WYRD, // 12732
+ ITEMID_HAGALAZ, // 12733
+ ITEMID_LUX_ANIMA = 22540,
+};
+
+/**
+ * Geneticist
+ */
+enum geneticist_item_list {
+ /// Pharmacy / Cooking
+ ITEMID_SEED_OF_HORNY_PLANT = 6210,
+ ITEMID_BLOODSUCK_PLANT_SEED, // 6211
+ ITEMID_BOMB_MUSHROOM_SPORE, // 6212
+ ITEMID_HP_INCREASE_POTIONS = 12422,
+ ITEMID_HP_INCREASE_POTIONM, // 12423
+ ITEMID_HP_INCREASE_POTIONL, // 12424
+ ITEMID_SP_INCREASE_POTIONS, // 12425
+ ITEMID_SP_INCREASE_POTIONM, // 12426
+ ITEMID_SP_INCREASE_POTIONL, // 12427
+ ITEMID_ENRICH_WHITE_POTIONZ, // 12428
+ ITEMID_SAVAGE_BBQ, // 12429
+ ITEMID_WUG_BLOOD_COCKTAIL, // 12430
+ ITEMID_MINOR_BRISKET, // 12431
+ ITEMID_SIROMA_ICETEA, // 12432
+ ITEMID_DROCERA_HERB_STEW, // 12433
+ ITEMID_PETTI_TAIL_NOODLE, // 12434
+ ITEMID_VITATA500, // 12436
+ ITEMID_ENRICH_CELERMINE_JUICE, // 12437
+ ITEMID_CURE_FREE, // 12475
+ /// Bombs
+ ITEMID_APPLE_BOMB = 13260,
+ ITEMID_COCONUT_BOMB, // 13261
+ ITEMID_MELON_BOMB, // 13262
+ ITEMID_PINEAPPLE_BOMB, // 13263
+ ITEMID_BANANA_BOMB, // 13264
+ ITEMID_BLACK_LUMP, // 13265
+ ITEMID_BLACK_HARD_LUMP, // 13266
+ ITEMID_VERY_HARD_LUMP, // 13267
+ /// Throwables
+ ITEMID_MYSTERIOUS_POWDER, // 13268
+ ITEMID_BOOST500_TO_THROW, // 13269
+ ITEMID_FULL_SWINGK_TO_THROW, // 13270
+ ITEMID_MANA_PLUS_TO_THROW, // 13271
+ ITEMID_CURE_FREE_TO_THROW, // 13272
+ ITEMID_STAMINA_UP_M_TO_THROW, // 13273
+ ITEMID_DIGESTIVE_F_TO_THROW, // 13274
+ ITEMID_HP_INC_POTS_TO_THROW, // 13275
+ ITEMID_HP_INC_POTM_TO_THROW, // 13276
+ ITEMID_HP_INC_POTL_TO_THROW, // 13277
+ ITEMID_SP_INC_POTS_TO_THROW, // 13278
+ ITEMID_SP_INC_POTM_TO_THROW, // 13279
+ ITEMID_SP_INC_POTL_TO_THROW, // 13280
+ ITEMID_EN_WHITE_POTZ_TO_THROW, // 13281
+ ITEMID_VITATA500_TO_THROW, // 13282
+ ITEMID_EN_CEL_JUICE_TO_THROW, // 13283
+ ITEMID_SAVAGE_BBQ_TO_THROW, // 13284
+ ITEMID_WUG_COCKTAIL_TO_THROW, // 13285
+ ITEMID_M_BRISKET_TO_THROW, // 13286
+ ITEMID_SIROMA_ICETEA_TO_THROW, // 13287
+ ITEMID_DROCERA_STEW_TO_THROW, // 13288
+ ITEMID_PETTI_NOODLE_TO_THROW, // 13289
+ ITEMID_BLACK_THING_TO_THROW, // 13290
+};
+
+enum item_nouse_list {
NOUSE_SITTING = 0x01,
-} item_nouse_list;
+};
//
enum e_chain_cache {
@@ -236,44 +453,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_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_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) >= ITEMID_BOODY_RED && (n) <= ITEMID_YELLOW_LIVE)
+#define itemdb_is_spellbook(n) ((n) >= ITEMID_MAGIC_BOOK_FB && (n) <= ITEMID_MAGIC_BOOK_DL)
+#define itemdb_is_poison(n) ((n) >= ITEMID_POISON_PARALYSIS && (n) <= ITEMID_POISON_FATIGUE)
+#define itemid_isgemstone(n) ((n) >= ITEMID_YELLOW_GEMSTONE && (n) <= ITEMID_BLUE_GEMSTONE)
+#define itemdb_iscashfood(n) ((n) >= ITEMID_STR_DISH10_ && (n) <= ITEMID_VIT_DISH10_)
+#define itemdb_is_GNbomb(n) ((n) >= ITEMID_APPLE_BOMB && (n) <= ITEMID_VERY_HARD_LUMP)
+#define itemdb_is_GNthrowable(n) ((n) >= ITEMID_MYSTERIOUS_POWDER && (n) <= ITEMID_BLACK_THING_TO_THROW)
+
//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 c3c6fceee..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?
@@ -2183,7 +2183,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
// change experience for different sized monsters [Valaris]
if (battle_config.mob_size_influence) {
switch( md->special_state.size ) {
- case SZ_MEDIUM:
+ case SZ_SMALL:
per /= 2.;
break;
case SZ_BIG:
@@ -2304,7 +2304,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
// change drops depending on monsters size [Valaris]
if (battle_config.mob_size_influence)
{
- if (md->special_state.size == SZ_MEDIUM && drop_rate >= 2)
+ if (md->special_state.size == SZ_SMALL && drop_rate >= 2)
drop_rate /= 2;
else if( md->special_state.size == SZ_BIG)
drop_rate *= 2;
@@ -3470,7 +3470,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
sd->fd = fd;
//Finally, spawn it.
- md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_MEDIUM, AI_NONE);
if (!md) return 0; //Failed?
md->special_state.clone = 1;
diff --git a/src/map/mob.h b/src/map/mob.h
index 61f718c30..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
@@ -63,8 +63,8 @@ enum MobDamageLogFlag
};
enum size {
- SZ_SMALL = 0,
- SZ_MEDIUM,
+ SZ_MEDIUM = 0,
+ SZ_SMALL,
SZ_BIG,
};
@@ -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.c b/src/map/pc.c
index b930ffaad..02b4d0692 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -938,12 +938,10 @@ int pc_isequip(struct map_session_data *sd,int n)
clif->msg(sd, 0x6ED);
return 0;
}
-#ifdef RENEWAL
if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax){
clif->msg(sd, 0x6ED);
return 0;
}
-#endif
if(item->sex != 2 && sd->status.sex != item->sex)
return 0;
@@ -4209,89 +4207,87 @@ int pc_isUseitem(struct map_session_data *sd,int n)
return 0; // You cannot use this item while sitting.
}
- switch( nameid ) //@TODO, lot oh harcoded nameid here
- {
- case 605: // Anodyne
+ switch( nameid ) { // TODO: Is there no better way to handle this, other than hardcoding item IDs?
+ case ITEMID_ANODYNE:
if( map_flag_gvg2(sd->bl.m) )
return 0;
- case 606:
+ case ITEMID_ALOEBERA:
if( pc_issit(sd) )
return 0;
break;
- case 601: // Fly Wing
- case 12212: // Giant Fly Wing
+ case ITEMID_WING_OF_FLY:
+ case ITEMID_GIANT_FLY_WING:
if( map->list[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) {
clif->skill_mapinfomessage(sd,0);
return 0;
}
- case 602: // ButterFly Wing
- case 14527: // Dungeon Teleport Scroll
- case 14581: // Dungeon Teleport Scroll
- case 14582: // Yellow Butterfly Wing
- case 14583: // Green Butterfly Wing
- case 14584: // Red Butterfly Wing
- case 14585: // Blue Butterfly Wing
- case 14591: // Siege Teleport Scroll
+ case ITEMID_WING_OF_BUTTERFLY:
+ case ITEMID_DUN_TELE_SCROLL1:
+ case ITEMID_DUN_TELE_SCROLL2:
+ case ITEMID_WOB_RUNE: // Yellow Butterfly Wing
+ case ITEMID_WOB_SCHWALTZ: // Green Butterfly Wing
+ case ITEMID_WOB_RACHEL: // Red Butterfly Wing
+ case ITEMID_WOB_LOCAL: // Blue Butterfly Wing
+ case ITEMID_SIEGE_TELEPORT_SCROLL:
if( sd->duel_group && !battle_config.duel_allow_teleport )
{
clif->message(sd->fd, msg_txt(663));
return 0;
}
- if( nameid != 601 && nameid != 12212 && map->list[sd->bl.m].flag.noreturn )
+ if( nameid != ITEMID_WING_OF_FLY && nameid != ITEMID_GIANT_FLY_WING && map->list[sd->bl.m].flag.noreturn )
return 0;
break;
- case 604: // Dead Branch
- case 12024: // Red Pouch
- case 12103: // Bloody Branch
- case 12109: // Poring Box
+ case ITEMID_BRANCH_OF_DEAD_TREE:
+ case ITEMID_RED_POUCH_OF_SURPRISE:
+ case ITEMID_BLOODY_DEAD_BRANCH:
+ case ITEMID_PORING_BOX:
if( map->list[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) )
return 0;
break;
- case 12210: // Bubble Gum
- case 12264: // Comp Bubble Gum
+ case ITEMID_BUBBLE_GUM:
+ case ITEMID_COMP_BUBBLE_GUM:
if( sd->sc.data[SC_CASH_RECEIVEITEM] )
return 0;
break;
- case 12208: // Battle Manual
- case 12263: // Comp Battle Manual
- case 12312: // Thick Battle Manual
- case 12705: // Noble Nameplate
- case 14532: // Battle_Manual25
- case 14533: // Battle_Manual100
- case 14545: // Battle_Manual300
+ case ITEMID_BATTLE_MANUAL:
+ case ITEMID_COMP_BATTLE_MANUAL:
+ case ITEMID_THICK_MANUAL50:
+ case ITEMID_NOBLE_NAMEPLATE:
+ case ITEMID_BATTLE_MANUAL25:
+ case ITEMIDBATTLE_MANUAL100:
+ case ITEMID_BATTLE_MANUAL_X3:
if( sd->sc.data[SC_CASH_PLUSEXP] )
return 0;
break;
- case 14592: // JOB_Battle_Manual
+ case ITEMID_JOB_MANUAL50:
if( sd->sc.data[SC_CASH_PLUSONLYJOBEXP] )
return 0;
break;
// Mercenary Items
-
- case 12184: // Mercenary's Red Potion
- case 12185: // Mercenary's Blue Potion
- case 12241: // Mercenary's Concentration Potion
- case 12242: // Mercenary's Awakening Potion
- case 12243: // Mercenary's Berserk Potion
+ case ITEMID_MERCENARY_RED_POTION:
+ case ITEMID_MERCENARY_BLUE_POTION:
+ case ITEMID_M_CENTER_POTION:
+ case ITEMID_M_AWAKENING_POTION:
+ case ITEMID_M_BERSERK_POTION:
if( sd->md == NULL || sd->md->db == NULL )
return 0;
if (sd->md->sc.data[SC_BERSERK] || sd->md->sc.data[SC_SATURDAY_NIGHT_FEVER])
return 0;
- if( nameid == 12242 && sd->md->db->lv < 40 )
+ if( nameid == ITEMID_M_AWAKENING_POTION && sd->md->db->lv < 40 )
return 0;
- if( nameid == 12243 && sd->md->db->lv < 80 )
+ if( nameid == ITEMID_M_BERSERK_POTION && sd->md->db->lv < 80 )
return 0;
break;
- case 12213: //Neuralizer
+ case ITEMID_NEURALIZER:
if( !map->list[sd->bl.m].flag.reset )
return 0;
break;
}
- if( nameid >= 12153 && nameid <= 12182 && sd->md != NULL )
- return 0; // Mercenary Scrolls
+ if( nameid >= ITEMID_BOW_MERCENARY_SCROLL1 && nameid <= ITEMID_SPEARMERCENARY_SCROLL10 && sd->md != NULL ) // Mercenary Scrolls
+ return 0;
/**
* Only Rune Knights may use runes
@@ -4319,12 +4315,10 @@ int pc_isUseitem(struct map_session_data *sd,int n)
return 0;
}
-#ifdef RENEWAL
if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax){
clif->msg(sd, 0x6EE);
return 0;
}
-#endif
//Not equipable by class. [Skotlex]
if (!(
@@ -4356,8 +4350,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
}
//Dead Branch & Bloody Branch & Porings Box
- // FIXME: outdated, use constants or database
- if( nameid == 604 || nameid == 12103 || nameid == 12109 )
+ if( nameid == ITEMID_BRANCH_OF_DEAD_TREE || nameid == ITEMID_BLOODY_DEAD_BRANCH || nameid == ITEMID_PORING_BOX )
logs->branch(sd);
return 1;
@@ -5886,7 +5879,6 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
}
void pc_baselevelchanged(struct map_session_data *sd) {
-#ifdef RENEWAL
int i;
for( i = 0; i < EQI_MAX; i++ ) {
if( sd->equip_index[i] >= 0 ) {
@@ -5894,9 +5886,8 @@ void pc_baselevelchanged(struct map_session_data *sd) {
pc->unequipitem(sd, sd->equip_index[i], 3);
}
}
-#endif
-
}
+
int pc_checkjoblevelup(struct map_session_data *sd)
{
unsigned int next = pc->nextjobexp(sd);
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 8d07ca0d1..777179507 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
//
@@ -8540,7 +8537,7 @@ BUILDIN(monster)
int class_ = script_getnum(st,6);
int amount = script_getnum(st,7);
const char* event = "";
- unsigned int size = SZ_SMALL;
+ unsigned int size = SZ_MEDIUM;
unsigned int ai = AI_NONE;
int mob_id;
@@ -8650,7 +8647,7 @@ BUILDIN(areamonster)
int class_ = script_getnum(st,8);
int amount = script_getnum(st,9);
const char* event = "";
- unsigned int size = SZ_SMALL;
+ unsigned int size = SZ_MEDIUM;
unsigned int ai = AI_NONE;
int mob_id;
@@ -12980,7 +12977,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_SMALL, 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;
@@ -13024,7 +13021,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;
@@ -13082,7 +13079,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;
@@ -13156,7 +13153,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;
@@ -17969,6 +17966,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
@@ -18512,6 +18511,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 f468b5364..dcb29701f 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); }
@@ -1296,14 +1296,14 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
case GN_SLINGITEM_RANGEMELEEATK:
if( sd ) {
switch( sd->itemid ) { // Starting SCs here instead of do it in skill->additional_effect to simplify the code.
- case 13261:
+ case ITEMID_COCONUT_BOMB:
sc_start(bl, SC_STUN, 100, skill_lv, skill->get_time2(GN_SLINGITEM, skill_lv));
sc_start2(bl, SC_BLOODING, 100, skill_lv, src->id, skill->get_time2(GN_SLINGITEM, skill_lv));
break;
- case 13262:
+ case ITEMID_MELON_BOMB:
sc_start(bl, SC_MELON_BOMB, 100, skill_lv, skill->get_time(GN_SLINGITEM, skill_lv)); // Reduces ASPD and moviment speed
break;
- case 13264:
+ case ITEMID_BANANA_BOMB:
sc_start(bl, SC_BANANA_BOMB, 100, skill_lv, skill->get_time(GN_SLINGITEM, skill_lv)); // Reduces LUK ??Needed confirm it, may be it's bugged in kRORE?
sc_start(bl, SC_BANANA_BOMB_SITDOWN_POSTDELAY, 75, skill_lv, skill->get_time(GN_SLINGITEM_RANGEMELEEATK,skill_lv)); // Sitdown for 3 seconds.
break;
@@ -2188,7 +2188,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
//Spirit of Wizard blocks Kaite's reflection
if( type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD )
{ //Consume one Fragment per hit of the casted skill? [Skotlex]
- type = tsd?pc->search_inventory (tsd, 7321):0;
+ type = tsd?pc->search_inventory(tsd, ITEMID_FRAGMENT_OF_CRYSTAL):0;
if (type >= 0) {
if ( tsd ) pc->delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
dmg.damage = dmg.damage2 = 0;
@@ -5249,7 +5249,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case SA_SUMMONMONSTER:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE);
+ if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_MEDIUM, AI_NONE);
break;
case SA_LEVELUP:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -6568,7 +6568,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (sd) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
//Prepare 200 White Potions.
- if (!skill->produce_mix(sd, skill_id, 504, 0, 0, 0, 200))
+ if (!skill->produce_mix(sd, skill_id, ITEMID_WHITE_POTION, 0, 0, 0, 200))
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
break;
@@ -6576,28 +6576,28 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (sd) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
//Prepare 200 Slim White Potions.
- if (!skill->produce_mix(sd, skill_id, 547, 0, 0, 0, 200))
+ if (!skill->produce_mix(sd, skill_id, ITEMID_WHITE_SLIM_POTION, 0, 0, 0, 200))
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
break;
case AM_TWILIGHT3:
if (sd) {
- int ebottle = pc->search_inventory(sd,713);
+ int ebottle = pc->search_inventory(sd,ITEMID_EMPTY_BOTTLE);
if( ebottle >= 0 )
ebottle = sd->status.inventory[ebottle].amount;
//check if you can produce all three, if not, then fail:
- if (!skill->can_produce_mix(sd,970,-1, 100) //100 Alcohol
- || !skill->can_produce_mix(sd,7136,-1, 50) //50 Acid Bottle
- || !skill->can_produce_mix(sd,7135,-1, 50) //50 Flame Bottle
+ if (!skill->can_produce_mix(sd,ITEMID_ALCHOL,-1, 100) //100 Alcohol
+ || !skill->can_produce_mix(sd,ITEMID_ACID_BOTTLE,-1, 50) //50 Acid Bottle
+ || !skill->can_produce_mix(sd,ITEMID_FIRE_BOTTLE,-1, 50) //50 Flame Bottle
|| ebottle < 200 //200 empty bottle are required at total.
) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- skill->produce_mix(sd, skill_id, 970, 0, 0, 0, 100);
- skill->produce_mix(sd, skill_id, 7136, 0, 0, 0, 50);
- skill->produce_mix(sd, skill_id, 7135, 0, 0, 0, 50);
+ skill->produce_mix(sd, skill_id, ITEMID_ALCHOL, 0, 0, 0, 100);
+ skill->produce_mix(sd, skill_id, ITEMID_ACID_BOTTLE, 0, 0, 0, 50);
+ skill->produce_mix(sd, skill_id, ITEMID_FIRE_BOTTLE, 0, 0, 0, 50);
}
break;
case SA_DISPELL:
@@ -8995,7 +8995,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
sd->itemid = ammo_id;
if( itemdb_is_GNbomb(ammo_id) ) {
if(battle->check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy.
- if( ammo_id == 13263 )
+ if( ammo_id == ITEMID_PINEAPPLE_BOMB )
map->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag);
@@ -9114,7 +9114,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if(sd) {
struct mob_data *md;
- md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), 2308, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), 2308, "", SZ_MEDIUM, AI_NONE);
if( md ) {
md->master_id = src->id;
md->special_state.ai = AI_ZANZOU;
@@ -9303,7 +9303,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
for(i=0; i<qty[skill_lv - 1]; i++){ //easy way
- md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
+ md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), summons[skill_lv - 1], "", SZ_MEDIUM, AI_ATTACK);
if (md) {
md->master_id = src->id;
if (md->deletetimer != INVALID_TIMER)
@@ -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;
@@ -9962,7 +9962,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
struct mob_data *md;
// Correct info, don't change any of this! [celest]
- md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_MEDIUM, AI_NONE);
if (md) {
md->master_id = src->id;
md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA;
@@ -10059,7 +10059,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if (rnd()%100 < 50) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
} else {
- TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE);
+ TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_MEDIUM, AI_NONE);
int i;
if (!md) break;
if ((i = skill->get_time(skill_id, skill_lv)) > 0)
@@ -10191,7 +10191,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int class_ = 2042;
struct mob_data *md;
- md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_MEDIUM, AI_NONE);
if( md ) {
md->master_id = src->id;
md->special_state.ai = AI_FLORA;
@@ -14237,7 +14237,12 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s
*------------------------------------------*/
void skill_repairweapon (struct map_session_data *sd, int idx) {
int material;
- int materials[4] = { 1002, 998, 999, 756 };
+ int materials[4] = {
+ ITEMID_IRON_ORE,
+ ITEMID_IRON,
+ ITEMID_STEEL,
+ ITEMID_ORIDECON_STONE,
+ };
struct item *item;
struct map_session_data *target_sd;
@@ -14261,9 +14266,9 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
}
if ( target_sd->inventory_data[idx]->type == IT_WEAPON )
- material = materials [ target_sd->inventory_data[idx]->wlv - 1 ]; // Lv1/2/3/4 weapons consume 1 Iron Ore/Iron/Steel/Rough Oridecon
+ material = materials[ target_sd->inventory_data[idx]->wlv - 1 ]; // Lv1/2/3/4 weapons consume 1 Iron Ore/Iron/Steel/Rough Oridecon
else
- material = materials [2]; // Armors consume 1 Steel
+ material = materials[2]; // Armors consume 1 Steel
if ( pc->search_inventory(sd,material) < 0 ) {
clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0);
return;
@@ -14311,7 +14316,13 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
if (idx >= 0 && idx < MAX_INVENTORY)
{
int i = 0, ep = 0, per;
- int material[5] = { 0, 1010, 1011, 984, 984 };
+ int material[5] = {
+ 0,
+ ITEMID_PHRACON,
+ ITEMID_EMVERETARCON,
+ ITEMID_ORIDECON,
+ ITEMID_ORIDECON,
+ };
struct item *item;
struct item_data *ditem = sd->inventory_data[idx];
item = &sd->status.inventory[idx];
@@ -14326,8 +14337,8 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
clif->upgrademessage(sd->fd, 2, item->nameid);
return;
}
- if( (i = pc->search_inventory(sd, material [ditem->wlv])) < 0 ){
- clif->upgrademessage(sd->fd, 3, material [ditem->wlv]);
+ if( (i = pc->search_inventory(sd, material[ditem->wlv])) < 0 ){
+ clif->upgrademessage(sd->fd, 3, material[ditem->wlv]);
return;
}
@@ -16079,11 +16090,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
j = pc->search_inventory(sd,slot[i]);
if(j < 0)
continue;
- if(slot[i]==1000){ /* Star Crumb */
+ if( slot[i]==ITEMID_STAR_CRUMB ) {
pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
sc++;
}
- if(slot[i]>=994 && slot[i]<=997 && ele==0){ /* Flame Heart . . . Great Nature */
+ if( slot[i] >= ITEMID_FLAME_HEART && slot[i] <= ITEMID_GREAT_NATURE && ele == 0 ) {
static const int ele_table[4]={3,1,4,2};
pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
ele=ele_table[slot[i]-994];
@@ -16150,13 +16161,13 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
i = pc->checkskill(sd,skill_id);
make_per = sd->status.job_level*20 + st->dex*10 + st->luk*10; //Base chance
switch(nameid){
- case 998: // Iron
+ case ITEMID_IRON:
make_per += 4000+i*500; // Temper Iron bonus: +26/+32/+38/+44/+50
break;
- case 999: // Steel
+ case ITEMID_STEEL:
make_per += 3000+i*500; // Temper Steel bonus: +35/+40/+45/+50/+55
break;
- case 1000: //Star Crumb
+ case ITEMID_STAR_CRUMB:
make_per = 100000; // Star Crumbs are 100% success crafting rate? (made 1000% so it succeeds even after penalties) [Skotlex]
break;
default: // Enchanted Stones
@@ -16187,32 +16198,32 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
make_per += skill2_lv*100; //+1% bonus per level
}
switch(nameid){
- case 501: // Red Potion
- case 503: // Yellow Potion
- case 504: // White Potion
+ case ITEMID_RED_POTION:
+ case ITEMID_YELLOW_POTION:
+ case ITEMID_WHITE_POTION:
make_per += (1+rnd()%100)*10 + 2000;
break;
- case 970: // Alcohol
+ case ITEMID_ALCHOL:
make_per += (1+rnd()%100)*10 + 1000;
break;
- case 7135: // Bottle Grenade
- case 7136: // Acid Bottle
- case 7137: // Plant Bottle
- case 7138: // Marine Sphere Bottle
+ case ITEMID_FIRE_BOTTLE:
+ case ITEMID_ACID_BOTTLE:
+ case ITEMID_MENEATER_PLANT_BOTTLE:
+ case ITEMID_MINI_BOTTLE:
make_per += (1+rnd()%100)*10;
break;
- case 546: // Condensed Yellow Potion
+ case ITEMID_YELLOW_SLIM_POTION:
make_per -= (1+rnd()%50)*10;
break;
- case 547: // Condensed White Potion
- case 7139: // Glistening Coat
+ case ITEMID_WHITE_SLIM_POTION:
+ case ITEMID_COATING_BOTTLE:
make_per -= (1+rnd()%100)*10;
break;
//Common items, recieve no bonus or penalty, listed just because they are commonly produced
- case 505: // Blue Potion
- case 545: // Condensed Red Potion
- case 605: // Anodyne
- case 606: // Aloevera
+ case ITEMID_BLUE_POTION:
+ case ITEMID_RED_SLIM_POTION:
+ case ITEMID_ANODYNE:
+ case ITEMID_ALOEBERA:
default:
break;
}
@@ -16232,18 +16243,18 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
int C = 100 * cap_value(sd->itemid,0,100); //itemid depend on makerune()
int D = 2500;
switch (nameid) { //rune rank it_diff 9 craftable rune
- case ITEMID_RAIDO:
- case ITEMID_THURISAZ:
- case ITEMID_HAGALAZ:
- case ITEMID_OTHILA:
+ case ITEMID_RAIDO:
+ case ITEMID_THURISAZ:
+ case ITEMID_HAGALAZ:
+ case ITEMID_OTHILA:
D -= 500; //Rank C
- case ITEMID_ISA:
- case ITEMID_WYRD:
+ case ITEMID_ISA:
+ case ITEMID_WYRD:
D -= 500; //Rank B
- case ITEMID_NAUTHIZ:
- case ITEMID_URUZ:
+ case ITEMID_NAUTHIZ:
+ case ITEMID_URUZ:
D -= 500; //Rank A
- case ITEMID_BERKANA:
+ case ITEMID_BERKANA:
case ITEMID_LUX_ANIMA:
D -= 500; //Rank S
}
@@ -16279,22 +16290,28 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
(sd->status.base_level-100) + pc->checkskill(sd, AM_LEARNINGPOTION) + pc->checkskill(sd, CR_FULLPROTECTION)*(4+rnd()%6); // (Caster?s Base Level - 100) + (Potion Research x 5) + (Full Chemical Protection Skill Level) x (Random number between 4 ~ 10)
switch(nameid){// difficulty factor
- case 12422: case 12425:
- case 12428:
+ case ITEMID_HP_INCREASE_POTIONS:
+ case ITEMID_SP_INCREASE_POTIONS:
+ case ITEMID_ENRICH_WHITE_POTIONZ:
difficulty += 10;
break;
- case 6212: case 12426:
+ case ITEMID_BOMB_MUSHROOM_SPORE:
+ case ITEMID_SP_INCREASE_POTIONM:
difficulty += 15;
break;
- case 13264: case 12423:
- case 12427: case 12436:
+ case ITEMID_BANANA_BOMB:
+ case ITEMID_HP_INCREASE_POTIONM:
+ case ITEMID_SP_INCREASE_POTIONL:
+ case ITEMID_VITATA500:
difficulty += 20;
break;
- case 6210: case 6211:
- case 12437:
+ case ITEMID_SEED_OF_HORNY_PLANT:
+ case ITEMID_BLOODSUCK_PLANT_SEED:
+ case ITEMID_ENRICH_CELERMINE_JUICE:
difficulty += 30;
break;
- case 12424: case 12475:
+ case ITEMID_HP_INCREASE_POTIONL:
+ case ITEMID_CURE_FREE:
difficulty += 40;
break;
}
@@ -16321,18 +16338,23 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
qty = ~(5 + rnd()%5) + 1;
switch(nameid){// difficulty factor
- case 13260:
+ case ITEMID_APPLE_BOMB:
difficulty += 5;
break;
- case 13261: case 13262:
+ case ITEMID_COCONUT_BOMB:
+ case ITEMID_MELON_BOMB:
difficulty += 10;
break;
- case 12429: case 12430: case 12431:
- case 12432: case 12433: case 12434:
- case 13263:
+ case ITEMID_SAVAGE_BBQ:
+ case ITEMID_WUG_BLOOD_COCKTAIL:
+ case ITEMID_MINOR_BRISKET:
+ case ITEMID_SIROMA_ICETEA:
+ case ITEMID_DROCERA_HERB_STEW:
+ case ITEMID_PETTI_TAIL_NOODLE:
+ case ITEMID_PINEAPPLE_BOMB:
difficulty += 15;
break;
- case 13264:
+ case ITEMID_BANANA_BOMB:
difficulty += 20;
break;
}
@@ -16466,7 +16488,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
}
if (rnd()%10000 < make_per || qty == 1) { //Success
tmp_item.amount++;
- if(nameid < 545 || nameid > 547)
+ if(nameid < ITEMID_RED_SLIM_POTION || nameid > ITEMID_WHITE_SLIM_POTION)
continue;
if( skill_id != AM_PHARMACY &&
skill_id != AM_TWILIGHT1 &&
@@ -16589,7 +16611,13 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
break;
case GN_MIX_COOKING: {
struct item tmp_item;
- const int compensation[5] = {13265, 13266, 13267, 12435, 13268};
+ const int compensation[5] = {
+ ITEMID_BLACK_LUMP,
+ ITEMID_BLACK_HARD_LUMP,
+ ITEMID_VERY_HARD_LUMP,
+ ITEMID_BLACK_THING,
+ ITEMID_MYSTERIOUS_POWDER,
+ };
int rate = rnd()%500;
memset(&tmp_item,0,sizeof(tmp_item));
if( rate < 50) i = 4;
@@ -16674,14 +16702,14 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) {
}
switch( nameid )
{ // t_lv used to take duration from skill->get_time2
- case PO_PARALYSE: type = SC_PARALYSE; break;
- case PO_PYREXIA: type = SC_PYREXIA; break;
- case PO_DEATHHURT: type = SC_DEATHHURT; break;
- case PO_LEECHESEND: type = SC_LEECHESEND; break;
- case PO_VENOMBLEED: type = SC_VENOMBLEED; break;
- case PO_TOXIN: type = SC_TOXIN; break;
- case PO_MAGICMUSHROOM: type = SC_MAGICMUSHROOM; break;
- case PO_OBLIVIONCURSE: type = SC_OBLIVIONCURSE; break;
+ case ITEMID_POISON_PARALYSIS: type = SC_PARALYSE; break;
+ case ITEMID_POISON_FEVER: type = SC_PYREXIA; break;
+ case ITEMID_POISON_CONTAMINATION: type = SC_DEATHHURT; break;
+ case ITEMID_POISON_LEECH: type = SC_LEECHESEND; break;
+ case ITEMID_POISON_FATIGUE: type = SC_VENOMBLEED; break;
+ case ITEMID_POISON_NUMB: type = SC_TOXIN; break;
+ case ITEMID_POISON_LAUGHING: type = SC_MAGICMUSHROOM; break;
+ case ITEMID_POISON_OBLIVION: type = SC_OBLIVIONCURSE; break;
default:
clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -16737,10 +16765,10 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
sd->sc.comet_x = sd->sc.comet_y = 0;
sd->menuskill_val = 0;
- class_ = (nameid == 990 || nameid == 991) ? 2043 + nameid - 990 : (nameid == 992) ? 2046 : 2045;
+ class_ = (nameid == ITEMID_BOODY_RED || nameid == ITEMID_CRYSTAL_BLUE) ? 2043 + nameid - ITEMID_BOODY_RED : (nameid == ITEMID_WIND_OF_VERDURE) ? 2046 : 2045;
- md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_MEDIUM, AI_NONE);
if( md ) {
md->master_id = sd->bl.id;
md->special_state.ai = AI_FLORA;
@@ -16853,15 +16881,15 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
switch( nameid ) {
// Level 1
- case 994: product = 990; break; // Flame Heart -> Red Blood.
- case 995: product = 991; break; // Mystic Frozen -> Crystal Blue.
- case 996: product = 992; break; // Rough Wind -> Wind of Verdure.
- case 997: product = 993; break; // Great Nature -> Green Live.
+ case ITEMID_FLAME_HEART: product = ITEMID_BOODY_RED; break;
+ case ITEMID_MISTIC_FROZEN: product = ITEMID_CRYSTAL_BLUE; break;
+ case ITEMID_ROUGH_WIND: product = ITEMID_WIND_OF_VERDURE; break;
+ case ITEMID_GREAT_NATURE: product = ITEMID_YELLOW_LIVE; break;
// Level 2
- case 990: product = 994; break; // Red Blood -> Flame Heart.
- case 991: product = 995; break; // Crystal Blue -> Mystic Frozen.
- case 992: product = 996; break; // Wind of Verdure -> Rough Wind.
- case 993: product = 997; break; // Green Live -> Great Nature.
+ case ITEMID_BOODY_RED: product = ITEMID_FLAME_HEART; break;
+ case ITEMID_CRYSTAL_BLUE: product = ITEMID_MISTIC_FROZEN; break;
+ case ITEMID_WIND_OF_VERDURE: product = ITEMID_ROUGH_WIND; break;
+ case ITEMID_YELLOW_LIVE: product = ITEMID_GREAT_NATURE; break;
default:
clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0);
return 1;
diff --git a/src/map/skill.h b/src/map/skill.h
index 918216e8a..1b6f1e24c 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -1613,17 +1613,6 @@ enum {
UNT_MAX = 0x190
};
-enum gx_poison {
- PO_PARALYSE = 12717,
- PO_LEECHESEND,
- PO_OBLIVIONCURSE,
- PO_DEATHHURT,
- PO_TOXIN,
- PO_PYREXIA,
- PO_MAGICMUSHROOM,
- PO_VENOMBLEED
-};
-
/**
* Structures
**/
diff --git a/src/map/status.c b/src/map/status.c
index ef211e97e..d4e1d1b31 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)
@@ -2096,7 +2098,7 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
if (flag&2 && battle_config.mob_size_influence) {
// change for sized monsters [Valaris]
- if (md->special_state.size==SZ_MEDIUM) {
+ if (md->special_state.size==SZ_SMALL) {
mstatus->max_hp>>=1;
mstatus->max_sp>>=1;
if (!mstatus->max_hp) mstatus->max_hp = 1;
@@ -2402,13 +2404,13 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) {
//Give them all modes except these (useful for clones)
bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
- bstatus->size = (sd->class_&JOBL_BABY)?SZ_SMALL:SZ_MEDIUM;
+ bstatus->size = (sd->class_&JOBL_BABY)?SZ_MEDIUM:SZ_SMALL;
if (battle_config.character_size && (pc_isriding(sd) || pc_isridingdragon(sd)) ) { //[Lupus]
if (sd->class_&JOBL_BABY) {
if (battle_config.character_size&SZ_BIG)
bstatus->size++;
} else
- if(battle_config.character_size&SZ_MEDIUM)
+ if(battle_config.character_size&SZ_SMALL)
bstatus->size++;
}
bstatus->aspd_rate = 1000;
@@ -3432,50 +3434,43 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
if (!sc || !sc->count)
return;
- if (
- (sc->data[SC_POISON] && !sc->data[SC_SLOWPOISON])
- || (sc->data[SC_DPOISON] && !sc->data[SC_SLOWPOISON])
- || sc->data[SC_BERSERK]
- || sc->data[SC_TRICKDEAD]
- || sc->data[SC_BLOODING]
- || sc->data[SC_MAGICMUSHROOM]
- || sc->data[SC_RAISINGDRAGON]
- || sc->data[SC_SATURDAY_NIGHT_FEVER]
+ if ((sc->data[SC_POISON] && !sc->data[SC_SLOWPOISON])
+ || (sc->data[SC_DPOISON] && !sc->data[SC_SLOWPOISON])
+ || sc->data[SC_BERSERK]
+ || sc->data[SC_TRICKDEAD]
+ || sc->data[SC_BLOODING]
+ || sc->data[SC_MAGICMUSHROOM]
+ || sc->data[SC_RAISINGDRAGON]
+ || sc->data[SC_SATURDAY_NIGHT_FEVER]
) //No regen
regen->flag = 0;
- if (
- sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND]
- || (
- (bl->type == BL_PC && ((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK &&
- (sc->data[SC_EXTREMITYFIST] || (sc->data[SC_EXPLOSIONSPIRITS] && (!sc->data[SC_SOULLINK] || sc->data[SC_SOULLINK]->val2 != SL_MONK)))
- )
- ) //No natural SP regen
- regen->flag &=~RGN_SP;
-
- if(
- sc->data[SC_TENSIONRELAX]
+ if ( sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND]
+ || ( bl->type == BL_PC && (((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK
+ && (sc->data[SC_EXTREMITYFIST] || (sc->data[SC_EXPLOSIONSPIRITS] && (!sc->data[SC_SOULLINK] || sc->data[SC_SOULLINK]->val2 != SL_MONK)))
+ )
) {
+ regen->flag &=~RGN_SP; //No natural SP regen
+ }
+
+ if (sc->data[SC_TENSIONRELAX]) {
regen->rate.hp += 2;
if (regen->sregen)
regen->sregen->rate.hp += 3;
}
- if (sc->data[SC_MAGNIFICAT])
- {
+ if (sc->data[SC_MAGNIFICAT]) {
regen->rate.hp += 1;
regen->rate.sp += 1;
}
- if (sc->data[SC_GDSKILL_REGENERATION])
- {
+ if (sc->data[SC_GDSKILL_REGENERATION]) {
const struct status_change_entry *sce = sc->data[SC_GDSKILL_REGENERATION];
- if (!sce->val4)
- {
+ if (!sce->val4) {
regen->rate.hp += sce->val2;
regen->rate.sp += sce->val3;
} else
regen->flag&=~sce->val4; //Remove regen as specified by val4
}
- if(sc->data[SC_GENTLETOUCH_REVITALIZE]){
+ if(sc->data[SC_GENTLETOUCH_REVITALIZE]) {
regen->hp = cap_value(regen->hp*sc->data[SC_GENTLETOUCH_REVITALIZE]->val3/100, 1, SHRT_MAX);
regen->state.walk= 1;
}
@@ -8559,12 +8554,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 +8569,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
@@ -8876,18 +8873,18 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_ITEMSCRIPT:
if( sd ) {
switch( val1 ) {
- //case 4121://Phree
- //case 4047://Ghostring
- case 4302://Gunka
+ //case ITEMID_PHREEONI_CARD:
+ //case ITEMID_GHOSTRING_CARD:
+ case ITEMID_TAO_GUNKA_CARD:
clif->status_change(bl,SI_MVPCARD_TAOGUNKA,1,tick,0,0,0);
break;
- case 4132://Mistress
+ case ITEMID_MISTRESS_CARD:
clif->status_change(bl,SI_MVPCARD_MISTRESS,1,tick,0,0,0);
break;
- case 4143://Orc Hero
+ case ITEMID_ORC_HERO_CARD:
clif->status_change(bl,SI_MVPCARD_ORCHERO,1,tick,0,0,0);
break;
- case 4135://Orc Lord
+ case ITEMID_ORC_LOAD_CARD:
clif->status_change(bl,SI_MVPCARD_ORCLORD,1,tick,0,0,0);
break;
}
@@ -9732,18 +9729,18 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_ITEMSCRIPT:
if( sd ) {
switch( sce->val1 ) {
- //case 4121://Phree
- //case 4047://Ghostring
- case 4302://Gunka
+ //case ITEMID_PHREEONI_CARD:
+ //case ITEMID_GHOSTRING_CARD:
+ case ITEMID_TAO_GUNKA_CARD:
clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_TAOGUNKA);
break;
- case 4132://Mistress
+ case ITEMID_MISTRESS_CARD:
clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_MISTRESS);
break;
- case 4143://Orc Hero
+ case ITEMID_ORC_HERO_CARD:
clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_ORCHERO);
break;
- case 4135://Orc Lord
+ case ITEMID_ORC_LOAD_CARD:
clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_ORCLORD);
break;
}
@@ -10022,7 +10019,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 {
diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
index 9eb34a37f..42a881a49 100644
--- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
@@ -1561,6 +1561,8 @@ struct {
struct HPMHookPoint *HP_clif_pGMReqAccountName_post;
struct HPMHookPoint *HP_clif_pGMChangeMapType_pre;
struct HPMHookPoint *HP_clif_pGMChangeMapType_post;
+ struct HPMHookPoint *HP_clif_pGMFullStrip_pre;
+ struct HPMHookPoint *HP_clif_pGMFullStrip_post;
struct HPMHookPoint *HP_clif_pPMIgnore_pre;
struct HPMHookPoint *HP_clif_pPMIgnore_post;
struct HPMHookPoint *HP_clif_pPMIgnoreAll_pre;
@@ -6520,6 +6522,8 @@ struct {
int HP_clif_pGMReqAccountName_post;
int HP_clif_pGMChangeMapType_pre;
int HP_clif_pGMChangeMapType_post;
+ int HP_clif_pGMFullStrip_pre;
+ int HP_clif_pGMFullStrip_post;
int HP_clif_pPMIgnore_pre;
int HP_clif_pPMIgnore_post;
int HP_clif_pPMIgnoreAll_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
index 9635ba517..2dead85db 100644
--- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
@@ -790,6 +790,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->pGMRc, HP_clif_pGMRc) },
{ HP_POP(clif->pGMReqAccountName, HP_clif_pGMReqAccountName) },
{ HP_POP(clif->pGMChangeMapType, HP_clif_pGMChangeMapType) },
+ { HP_POP(clif->pGMFullStrip, HP_clif_pGMFullStrip) },
{ HP_POP(clif->pPMIgnore, HP_clif_pPMIgnore) },
{ HP_POP(clif->pPMIgnoreAll, HP_clif_pPMIgnoreAll) },
{ HP_POP(clif->pPMIgnoreList, HP_clif_pPMIgnoreList) },
diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc
index a6d58fb43..836e4e124 100644
--- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc
@@ -19773,6 +19773,31 @@ void HP_clif_pGMChangeMapType(int fd, struct map_session_data *sd) {
}
return;
}
+void HP_clif_pGMFullStrip(int fd, struct map_session_data *sd) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_clif_pGMFullStrip_pre ) {
+ void (*preHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pGMFullStrip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_pGMFullStrip_pre[hIndex].func;
+ preHookFunc(&fd, sd);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.clif.pGMFullStrip(fd, sd);
+ }
+ if( HPMHooks.count.HP_clif_pGMFullStrip_post ) {
+ void (*postHookFunc) (int *fd, struct map_session_data *sd);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pGMFullStrip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_pGMFullStrip_post[hIndex].func;
+ postHookFunc(&fd, sd);
+ }
+ }
+ return;
+}
void HP_clif_pPMIgnore(int fd, struct map_session_data *sd) {
int hIndex = 0;
if( HPMHooks.count.HP_clif_pPMIgnore_pre ) {