浏览代码

- Follow-up to r15979, updated parse_simpleexpr to parse direction function invocation
- Added SCRIPT_CALLFUNC_CHECK macro to disable direct callback if affecting performance

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15981 54d463be-8e91-2dee-dedb-b68131a5f0ec

epoque11 13 年之前
父节点
当前提交
870a300ae5
共有 2 个文件被更改,包括 19 次插入0 次删除
  1. 7 0
      src/map/config/core.h
  2. 12 0
      src/map/script.c

+ 7 - 0
src/map/config/core.h

@@ -13,6 +13,13 @@
  **/
 #define AUTOLOOTITEM_SIZE 10
 
+/// leave this line uncommented to enable callfunc checks when processing scripts.
+/// while allowed, the script engine will attempt to match user-defined functions
+/// in scripts allowing direct function callback (without the use of callfunc.)
+/// this CAN affect performance, so if you find scripts running slower or find
+/// your map-server using more resources while this is active, comment the line
+#define SCRIPT_CALLFUNC_CHECK
+
 //Uncomment to enable the Cell Stack Limit mod.
 //It's only config is the battle_config cell_stack_limit.
 //Only chars affected are those defined in BL_CHAR (mobs and players currently)

+ 12 - 0
src/map/script.c

@@ -952,9 +952,12 @@ const char* parse_callfunc(const char* p, int require_paren)
 		if( *arg != '*' )
 			++arg; // count func as argument
 	} else {
+#ifdef SCRIPT_CALLFUNC_CHECK
 		const char* name = get_str(func);
 		if( strdb_get(userfunc_db, name) == NULL ) {
+#endif
 			disp_error_message("parse_line: expect command, missing function name or calling undeclared function",p);
+#ifdef SCRIPT_CALLFUNC_CHECK
 		} else {
 			int callfunc = search_str("callfunc");
 			add_scriptl(callfunc);
@@ -965,6 +968,7 @@ const char* parse_callfunc(const char* p, int require_paren)
 			arg = buildin_func[str_data[callfunc].val].arg;
 			if( *arg != '*' ) ++ arg;
 		}
+#endif
 	}
 
 	p = skip_word(p);
@@ -1104,6 +1108,14 @@ const char* parse_simpleexpr(const char *p)
 		l=add_word(p);
 		if( str_data[l].type == C_FUNC || str_data[l].type == C_USERFUNC || str_data[l].type == C_USERFUNC_POS)
 			return parse_callfunc(p,1);
+#ifdef SCRIPT_CALLFUNC_CHECK
+		else {
+			const char* name = get_str(l);
+			if( strdb_get(userfunc_db,name) != NULL ) {
+				return parse_callfunc(p,1);
+			}
+		}
+#endif
 
 		p=skip_word(p);
 		if( *p == '[' ){