summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-11-18 08:53:22 +0100
committerHaru <haru@dotalux.com>2013-11-19 03:41:30 +0100
commit12dce46d611d6ea7c772174ebbd555fa10fead99 (patch)
tree8f953e4166750c2ec1cbd1df89717b8d5dc8f455 /src/map/script.c
parent51cbaf27c96e874850588ddcfa13b656db45bb2e (diff)
downloadhercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.gz
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.bz2
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.tar.xz
hercules-12dce46d611d6ea7c772174ebbd555fa10fead99.zip
Sanitized and improved several macros through the code
- Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 0827258d7..0f2c86868 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -278,7 +278,7 @@ void disp_error_message2(const char *mes,const char *pos,int report)
script->error_report = report;
longjmp( script->error_jump, 1 );
}
-#define disp_error_message(mes,pos) script->disp_error_message2(mes,pos,1)
+#define disp_error_message(mes,pos) (script->disp_error_message2((mes),(pos),1))
void disp_warning_message(const char *mes, const char *pos) {
script->warning(script->parser_current_src,script->parser_current_file,script->parser_current_line,mes,pos);
@@ -3986,9 +3986,6 @@ const char *script_getfuncname(struct script_state *st) {
// buildin functions
//
-#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args }
-#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args }
-
/////////////////////////////////////////////////////////////////////
// NPC interaction
//
@@ -13016,7 +13013,7 @@ BUILDIN(isequippedcnt)
}
for (i=0; id!=0; i++) {
- script_fetch(st,i+2, id) else id = 0;
+ script_fetch(st,i+2, id);
if (id <= 0)
continue;
@@ -13074,7 +13071,7 @@ BUILDIN(isequipped)
setitem_hash = sd->bonus.setitem_hash;
setitem_hash2 = sd->bonus.setitem_hash2;
for (i=0; id!=0; i++) {
- script_fetch(st,i+2, id) else id = 0;
+ script_fetch(st,i+2, id);
if (id <= 0)
continue;
flag = 0;
@@ -13148,7 +13145,7 @@ BUILDIN(cardscnt) {
sd = script->rid2sd(st);
for (i=0; id!=0; i++) {
- script_fetch(st,i+2, id) else id = 0;
+ script_fetch(st,i+2, id);
if (id <= 0)
continue;
@@ -17961,6 +17958,8 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)
return true;
}
+#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args }
+#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args }
void script_parse_builtin(void) {
struct script_function BUILDIN[] = {
// NPC interaction
@@ -18504,6 +18503,8 @@ void script_parse_builtin(void) {
}
}
}
+#undef BUILDIN_DEF
+#undef BUILDIN_DEF2
void script_label_add(int key, int pos) {
int idx = script->label_count;