Skip to content

Commit 03553dd

Browse files
committed
Made sure the script was respected.
1 parent eb05b79 commit 03553dd

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

Source/Activities/GAScripted.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -193,34 +193,12 @@ bool GAScripted::SceneIsCompatible(Scene* pScene, int teams) {
193193
}
194194

195195
// If it hasn't been yet, run the file that specifies the Lua functions for this' operating logic (including the scene test function)
196-
if (!g_LuaMan.GetMasterScriptState().GlobalIsDefined(m_LuaClassName)) {
197-
// Temporarily store this Activity so the Lua state can access it
198-
g_LuaMan.GetMasterScriptState().SetTempEntity(this);
199-
// Define the var that will hold the script file definitions..
200-
// it's OK if the script fails, then the scene is still deemed compatible
201-
if (g_LuaMan.GetMasterScriptState().RunScriptString(m_LuaClassName + " = ToGameActivity(LuaMan.TempEntity);") < 0) {
202-
return true;
203-
}
204-
// Load and run the file, defining all the scripted functions of this Activity
205-
if (g_LuaMan.GetMasterScriptState().RunScriptFile(m_ScriptPath) < 0) {
206-
return true;
207-
}
208-
}
196+
RefreshActivityFunctions();
209197

210198
// Call the defined function, but only after first checking if it exists
211-
bool conditionMet = false;
199+
bool conditionMet = true;
212200
int error = RunLuaConditionalTest("IsCompatibleScene", conditionMet, {pScene}, {}, {});
213-
if (error < 0) {
214-
RTEAbort("Error")
215-
return false;
216-
} else if (error == 0) {
217-
//RTEAbort("Missing")
218-
conditionMet = true;
219-
} else {
220-
RTEAbort("Passed")
221-
}
222-
223-
if (!conditionMet) {
201+
if (error < 0 || !conditionMet) {
224202
return false;
225203
}
226204

Source/Managers/LuaMan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,14 @@ int LuaStateWrapper::RunScriptConditionalTestFunctionObject(const LuabindObjectW
677677
ZoneName(path.c_str(), path.length());
678678

679679
if (lua_pcall(m_State, argumentCount, LUA_MULTRET, -argumentCount - 2) > 0) {
680-
//returnParam = 1 == lua_toboolean(m_State, 1);
681680
m_LastError = lua_tostring(m_State, -1);
682681
lua_pop(m_State, 1);
683682
g_ConsoleMan.PrintString("ERROR: " + m_LastError);
684683
ClearErrors();
685684
status = -1;
686685
}
686+
687+
returnParam = 1 == lua_toboolean(m_State, -1);
687688
}
688689
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
689690

0 commit comments

Comments
 (0)