* added script preload cmd #escape-all=0/1 to autoescape parts of scripts, to ease up hooking and related... what needs escaping in general

* added first part of a script to help with other scripts hooking
This commit is contained in:
false_genesis 2008-02-19 22:42:14 +00:00
parent d295e30b3f
commit f865fb10a6
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#script=IsHooked
// @def: script name
return ?{ScriptHasLine,{${@def}} #tag:hook:${@caller}}
#script=HookStart
// @def: script name
appenddef,{${@def}} #tag:hook:${@caller}
set,{#HookHelper::CurScript} ${@def}
#script=HookEnd
set,sc ${@0}
default,sc ${#HookHelper::CurScript}
appenddef,{${sc}} #tag:hook-end:${@caller}
unset ${sc}
unset sc
#script=HookAdd
// @def: script line
// @0: script name
set,sc ${@0}
default,sc ${#HookHelper::CurScript}
appenddef,{${sc}} ${@def}
unset sc
#script=HookAddList
// @def: list name
// @0: script name
set,sc ${@0}
set,l ?{globname,{${@caller}} ${@def}}
default,sc ${#HookHelper::CurScript}
set,i 0
loop
if ?{bigger_eq,${i} ?{llen ${l}}}
exitloop
endif
HookAdd,{${sc}} ?{lindex,{${l}} ${i}}
add,i 1
endloop
unset sc
#script=HookStartOpcode
// @def: opcode name
HookStart OPCODE::${@def}
//////////////////////////////////////////////////////////
#comments-start
TODO:
- add UnHook[,which_script] hook_name
- add UnHookAll which_script
- Add HookStartAfter
#comments-end

View File

@ -260,6 +260,7 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn){
bool load_debug=false,load_notify=false,cantload=false; bool load_debug=false,load_notify=false,cantload=false;
bool line_strip = true; // true by default bool line_strip = true; // true by default
bool commented = false; bool commented = false;
bool escape_all = false;
char z; char z;
unsigned int absline=0; unsigned int absline=0;
DefScript *curScript = NULL; DefScript *curScript = NULL;
@ -363,6 +364,10 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn){
{ {
line_strip = isTrue(value); line_strip = isTrue(value);
} }
else if(label=="escape-all")
{
escape_all = isTrue(value);
}
else if(line=="debug") else if(line=="debug")
{ {
if(curScript) if(curScript)
@ -392,6 +397,11 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn){
continue; // line was an option, not script content continue; // line was an option, not script content
} }
if(escape_all)
{
line = EscapeString(line);
}
// help with loading lines where a space or tab have accidently been put after the cmd // help with loading lines where a space or tab have accidently been put after the cmd
std::string tline=stringToLower(line); std::string tline=stringToLower(line);
if(memcmp(tline.c_str(),"else ",5)==0 || memcmp(tline.c_str(),"else\t",5)==0) tline="else"; if(memcmp(tline.c_str(),"else ",5)==0 || memcmp(tline.c_str(),"else\t",5)==0) tline="else";