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
+3 -10
View File
@@ -208,11 +208,8 @@ void disconnect(int onlyclean, int async)
}
#endif
if(!onlyclean) localconnect();
if(identexists("onDisconnect"))
{
defformatstring(ondisconnect)("onDisconnect %d", -1);
execute(ondisconnect);
}}
exechook(HOOK_SP_MP, "onDisconnect", "%d", -1);
}
void trydisconnect()
{
@@ -611,11 +608,7 @@ void gets2c() // get updates from the server
connpeer = NULL;
connected = 1;
conoutf(_("connected to server"));
if(identexists("onConnect"))
{
defformatstring(onconnect)("onConnect %d", -1);
execute(onconnect);
}
exechook(HOOK_SP_MP, "onConnect", "%d", -1);
throttle();
if(editmode) toggleedit(true);
break;