Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/Engine/WorldModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private QuestList<Element> GetObjectsInScope(string scopeFunction)
{
if (Elements.ContainsKey(ElementType.Function, scopeFunction))
{
return (QuestList<Element>)RunProcedure(scopeFunction, true)!;
return (QuestList<Element>?)RunProcedure(scopeFunction, true) ?? new QuestList<Element>();
}
throw new Exception($"No function '{scopeFunction}'");
}
Expand Down Expand Up @@ -530,17 +530,16 @@ public void SendCommand(string command, int elapsedTime, IDictionary<string, str
{
TryFinishTurn();
}
if (State != GameState.Finished)
{
UpdateLists();
}
}
catch (Exception ex)
{
LogException(ex);
}

if (State != GameState.Finished)
{
UpdateLists();
}

ChangeThreadState(ThreadState.Ready);
}
else
Expand Down Expand Up @@ -1337,14 +1336,14 @@ public void Tick(int elapsedTime)
{
RunScript(timerScript.Value, timerScript.Key);
}

UpdateLists();
}
catch (Exception ex)
{
LogException(ex);
}

UpdateLists();

ChangeThreadState(ThreadState.Ready, false);
});

Expand Down Expand Up @@ -1414,11 +1413,18 @@ public void SetQuestionResponse(bool response)

private void RunCallbackAndFinishTurn(Callback callback)
{
RunScript(callback.Script, callback.Context);
TryFinishTurn();
if (State != GameState.Finished)
try
{
UpdateLists();
RunScript(callback.Script, callback.Context);
TryFinishTurn();
if (State != GameState.Finished)
{
UpdateLists();
}
}
catch (Exception ex)
{
LogException(ex);
}
ChangeThreadState(ThreadState.Ready);
SendNextTimerRequest();
Expand Down
Loading