Skip to content

Commit

Permalink
removed usages of prepareRunFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
markusobi committed Jan 7, 2019
1 parent ef1cc3b commit 33968d9
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion lib/ZenLib
2 changes: 0 additions & 2 deletions src/logic/DialogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ std::vector<ChoiceEntry> DialogManager::evaluateConditions(NpcHandle player,
int32_t valid = 0;
if (info.condition)
{
m_World.getScriptEngine().prepareRunFunction();
valid = m_World.getScriptEngine().runFunctionBySymIndex(info.condition);
}

Expand Down Expand Up @@ -241,7 +240,6 @@ void DialogManager::performChoice(size_t choice)
getVM().setInstance("other", ZMemory::toBigHandle(m_Interaction.player), Daedalus::IC_Npc);

// Call the script routine attached to the choice
m_World.getScriptEngine().prepareRunFunction();
size_t fnSym = choiceEntry.functionSym;
m_World.getScriptEngine().runFunctionBySymIndex(fnSym);

Expand Down
1 change: 0 additions & 1 deletion src/logic/MobController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ void MobController::callOnStateFunc(Handle::EntityHandle npc, int state)
s.setInstanceNPC("self", VobTypes::getScriptHandle(nv));
s.setInstanceItem("item", nv.playerController->getInteractItem());

s.prepareRunFunction();
s.runFunctionBySymIndex(idx);
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/logic/NpcScriptState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ bool Logic::NpcScriptState::startAIState(size_t symIdx, bool endOldState, bool i
m_CurrentState.isRoutineState = isRoutineState;

// Just call the function
s.prepareRunFunction();
s.setInstance("self", VobTypes::getScriptObject(vob).instanceSymbol);
s.runFunctionBySymIndex(symIdx);

Expand Down Expand Up @@ -245,7 +244,6 @@ bool NpcScriptState::doAIState(float deltaTime)
if (m_CurrentState.symIndex > 0)
{
// Call setup-function
s.prepareRunFunction();
s.runFunctionBySymIndex(m_CurrentState.symIndex);
}

Expand All @@ -261,7 +259,6 @@ bool NpcScriptState::doAIState(float deltaTime)
// Call looping-function
if (m_CurrentState.symLoop > 0)
{
s.prepareRunFunction();
end = s.runFunctionBySymIndex(m_CurrentState.symLoop) != 0;
}

Expand Down Expand Up @@ -295,7 +292,6 @@ bool NpcScriptState::doAIState(float deltaTime)
// Call end-function
if (m_CurrentState.symEnd > 0)
{
s.prepareRunFunction();
s.runFunctionBySymIndex(m_CurrentState.symEnd);
}

Expand Down Expand Up @@ -450,7 +446,6 @@ void NpcScriptState::reinitRoutine()

if (newSymFn != 0)
{
s.prepareRunFunction();
s.runFunctionBySymIndex(newSymFn);

LogInfo() << "Changed routine on "
Expand Down
4 changes: 0 additions & 4 deletions src/logic/PlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ bool PlayerController::EV_Manipulate(std::shared_ptr<EventMessages::ManipulateMe

if (message.symIdx != static_cast<size_t>(-1))
{
m_World.getScriptEngine().prepareRunFunction();
m_World.getScriptEngine().runFunctionBySymIndex(message.symIdx);
}
return false;
Expand Down Expand Up @@ -1302,7 +1301,6 @@ bool PlayerController::useItem(Daedalus::GameState::ItemHandle item)
if (data.on_state[0])
{
m_World.getScriptEngine().setInstanceNPC("self", getScriptHandle());
m_World.getScriptEngine().prepareRunFunction();
m_World.getScriptEngine().runFunctionBySymIndex(data.on_state[0]);

return true;
Expand Down Expand Up @@ -1337,8 +1335,6 @@ bool PlayerController::canUse(Daedalus::GameState::ItemHandle item)
s.setInstanceNPC("self", getScriptHandle());
s.setInstanceItem("item", item);

s.prepareRunFunction();

s.pushInt(data.cond_value[i]);
s.pushInt(data.cond_atr[i]);
s.pushInt(isPlayerControlled() ? 1 : 0);
Expand Down
10 changes: 0 additions & 10 deletions src/logic/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ bool ScriptEngine::initVMWithLoadedDAT()
return true;
}

void ScriptEngine::prepareRunFunction()
{
// Clean the VM for this run
m_pVM->pushState();
}

int32_t ScriptEngine::runFunction(const std::string& fname, bool clearDataStack)
{
assert(getVM().getDATFile().hasSymbolName(fname));
Expand Down Expand Up @@ -153,15 +147,13 @@ void ScriptEngine::initForWorld(const std::string& world, bool firstStart)
if (firstStart && m_pVM->getDATFile().hasSymbolName("startup_" + world))
{
LogInfo() << "Running: Startup_" << world;
prepareRunFunction();
runFunction("startup_" + world);
LogInfo() << "Done!";
}

if (m_pVM->getDATFile().hasSymbolName("init_" + world))
{
LogInfo() << "Running init_" << world;
prepareRunFunction();
runFunction("init_" + world);
LogInfo() << "Done!";
}
Expand Down Expand Up @@ -253,8 +245,6 @@ void ScriptEngine::onNPCInitialized(Daedalus::GameState::NpcHandle npc)

if (npcData.daily_routine != 0)
{
prepareRunFunction();

m_pVM->setInstance("self", ZMemory::toBigHandle(npc), Daedalus::IC_Npc);
m_pVM->setCurrentInstance(getSymbolIndexByName("self"));

Expand Down
1 change: 0 additions & 1 deletion src/target/REGoth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ void REGoth::initConsole()
return "error: could not find script functions";

int exp = std::stoi(args[1]);
s1.prepareRunFunction();
s1.pushInt(exp);
s1.runFunction(scriptName, false);

Expand Down

0 comments on commit 33968d9

Please sign in to comment.