cleaning up cubescript hooks

- provide a function to easily assemble and execute the command
- context-selective execution of hooks
- restrict potentially exploitable or harmful hooks to singleplayer-modes
This commit is contained in:
ac-stef
2014-11-12 17:06:35 +01:00
parent 41fd31deed
commit 8604c198e9
10 changed files with 48 additions and 109 deletions
+2 -10
View File
@@ -612,16 +612,8 @@ void keypress(int code, bool isdown, int cooked, SDLMod mod)
{
if(haskey) execbind(*haskey, isdown);
}
if(isdown && identexists("KEYPRESS")) // TODO: Remove this if its misued. e.x: /KEYPRESS = [ echo You pressed key code: $arg1 ] // Output: You pressed key code: 32 (if you press the spacebar)
{
defformatstring(kpi)("KEYPRESS %d", code);
execute(kpi);
}
if (!isdown && identexists("KEYRELEASE"))
{
defformatstring(kpo)("KEYRELEASE %d", code);
execute(kpo);
}
if(isdown) exechook(HOOK_SP, "KEYPRESS", "KEYPRESS %d", code);
else exechook(HOOK_SP, "KEYRELEASE", "%d", code);
}
char *getcurcommand()