forked from Mirrors/openclonk
Replace various C4AulFunc::Exec with C4PropList::Call
In C4Control.cpp, this improves correctness by selecting the right global function instead of a random function.epoxy
parent
93bf8f4779
commit
ca9d95b25f
|
@ -489,10 +489,7 @@ void C4ControlPlayerMouse::Execute() const
|
|||
|
||||
// Do call
|
||||
if (!callback_name) return;
|
||||
if (callback_name[0] == '~') ++callback_name;
|
||||
C4AulFunc *callback = ::ScriptEngine.GetFirstFunc(::Strings.RegString(callback_name));
|
||||
if (!callback) return;
|
||||
callback->Exec(nullptr, &pars);
|
||||
::ScriptEngine.Call(callback_name, &pars);
|
||||
}
|
||||
|
||||
void C4ControlPlayerMouse::CompileFunc(StdCompiler *pComp)
|
||||
|
@ -701,9 +698,7 @@ void C4ControlPlayerAction::Execute() const
|
|||
|
||||
// Proxy the hostility change through C4Aul, in case a script wants to capture it
|
||||
C4AulParSet pars(C4VInt(source_player->Number), C4VInt(target_player->Number), C4VBool(param_int != 0));
|
||||
C4AulFunc *callback = ::ScriptEngine.GetFirstFunc(::Strings.RegString("SetHostility"));
|
||||
assert(callback); // this should always exist since the engine provides a default implementation
|
||||
callback->Exec(nullptr, &pars);
|
||||
::ScriptEngine.Call("SetHostility", &pars);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -718,9 +713,7 @@ void C4ControlPlayerAction::Execute() const
|
|||
|
||||
// Proxy the team switch through C4Aul, in case a script wants to capture it
|
||||
C4AulParSet pars(C4VInt(source_player->Number), C4VInt(target));
|
||||
C4AulFunc *callback = ::ScriptEngine.GetFirstFunc(::Strings.RegString("SetPlayerTeam"));
|
||||
assert(callback);
|
||||
callback->Exec(nullptr, &pars);
|
||||
::ScriptEngine.Call("SetPlayerTeam", &pars);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -728,9 +721,7 @@ void C4ControlPlayerAction::Execute() const
|
|||
{
|
||||
// Proxy the call through C4Aul, in case a script wants to capture it
|
||||
C4AulParSet pars(C4VInt(source_player->Number), C4VInt(target));
|
||||
C4AulFunc *callback = ::ScriptEngine.GetFirstFunc(::Strings.RegString("InitScenarioPlayer"));
|
||||
assert(callback);
|
||||
callback->Exec(nullptr, &pars);
|
||||
::ScriptEngine.Call("InitScenarioPlayer", &pars);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -738,9 +729,6 @@ void C4ControlPlayerAction::Execute() const
|
|||
{
|
||||
// Notify scripts about player control selection
|
||||
const char *callback_name = PSF_InitializePlayerControl;
|
||||
if (callback_name[0] == '~') ++callback_name;
|
||||
C4AulFunc *callback = ::ScriptEngine.GetFirstFunc(::Strings.RegString(callback_name));
|
||||
if (!callback) return;
|
||||
|
||||
C4AulParSet pars(C4VInt(source_player->Number));
|
||||
// If the player is using a control set, its name is stored in param_str
|
||||
|
@ -751,7 +739,7 @@ void C4ControlPlayerAction::Execute() const
|
|||
pars[3] = C4VBool(CPA_IPC_HasMouse == (param_int & CPA_IPC_HasMouse));
|
||||
pars[4] = C4VBool(CPA_IPC_HasGamepad == (param_int & CPA_IPC_HasGamepad));
|
||||
}
|
||||
callback->Exec(nullptr, &pars);
|
||||
::ScriptEngine.Call(callback_name, &pars);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -997,11 +997,7 @@ bool C4Object::ExecLife()
|
|||
if (::MaterialMap.Map[InMat].Incindiary)
|
||||
if (GetPropertyInt(P_ContactIncinerate) > 0)
|
||||
{
|
||||
C4AulFunc *pCallFunc = GetFunc(PSF_OnInIncendiaryMaterial);
|
||||
if (pCallFunc)
|
||||
{
|
||||
pCallFunc->Exec(this, &C4AulParSet());
|
||||
}
|
||||
Call(PSF_OnInIncendiaryMaterial, &C4AulParSet());
|
||||
}
|
||||
|
||||
// birthday
|
||||
|
|
|
@ -346,6 +346,10 @@ class C4AulScriptEngine : public C4AulScript
|
|||
{
|
||||
protected:
|
||||
C4AulFuncMap FuncLookUp;
|
||||
C4AulFunc * GetFirstFunc(C4String * Name)
|
||||
{ return FuncLookUp.GetFirstFunc(Name); }
|
||||
C4AulFunc * GetNextSNFunc(const C4AulFunc * After)
|
||||
{ return FuncLookUp.GetNextSNFunc(After); }
|
||||
C4Value GlobalPropList;
|
||||
C4AulScript *Child0, *ChildL; // tree structure
|
||||
|
||||
|
@ -373,12 +377,10 @@ public:
|
|||
void Link(C4DefList *rDefs); // link and parse all scripts
|
||||
void ReLink(C4DefList *rDefs); // unlink, link and parse all scripts
|
||||
virtual C4PropListStatic * GetPropList();
|
||||
C4Value Call(const char * k, C4AulParSet *pPars=0, bool fPassErrors=false)
|
||||
{ return GetPropList()->Call(k, pPars, fPassErrors); }
|
||||
using C4AulScript::ReloadScript;
|
||||
bool ReloadScript(const char *szScript, const char *szLanguage); // search script and reload, if found
|
||||
C4AulFunc * GetFirstFunc(C4String * Name)
|
||||
{ return FuncLookUp.GetFirstFunc(Name); }
|
||||
C4AulFunc * GetNextSNFunc(const C4AulFunc * After)
|
||||
{ return FuncLookUp.GetNextSNFunc(After); }
|
||||
|
||||
// For the list of functions in the PropertyDlg
|
||||
std::list<const char*> GetFunctionNames(C4PropList *);
|
||||
|
|
|
@ -618,7 +618,7 @@ C4AulTokenType C4AulParse::GetNextToken(OperatorPolicy Operator)
|
|||
if (C >= '!' && C <= '~')
|
||||
throw C4AulParseError(this, FormatString("unexpected character '%c' found", C).getData());
|
||||
else
|
||||
throw C4AulParseError(this, FormatString("unexpected character 0x%x found", (int)(unsigned char) C).getData());
|
||||
throw C4AulParseError(this, FormatString("unexpected character \\x%x found", (int)(unsigned char) C).getData());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue