mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Fix #1508
This commit is contained in:
parent
c7a1440131
commit
3e5a3609cc
7 changed files with 19 additions and 21 deletions
|
@ -59,6 +59,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
|
|||
* Use load camera instead of load screen by playing fixed camera from OnEnd() event and removing loadScreenFile field from level's gameflow entry.
|
||||
* Fixed DisplayString class not supporting some Unicode characters and empty lines in multiline strings.
|
||||
* Fixed DisplayString not being deallocated after showing.
|
||||
* Fixed GameVars not transferring between levels in hub mode.
|
||||
* Fixed incorrect behaviour of Moveable:GetJointRotation() function.
|
||||
* Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions.
|
||||
* Fixed Util.HasLineOfSight() not taking static meshes into consideration.
|
||||
|
|
|
@ -376,7 +376,6 @@ unsigned CALLBACK GameMain(void *)
|
|||
GameStatus DoLevel(int levelIndex, bool loadGame)
|
||||
{
|
||||
bool isTitle = !levelIndex;
|
||||
auto loadType = loadGame ? LevelLoadType::Load : (SaveGame::IsOnHub(levelIndex) ? LevelLoadType::Hub : LevelLoadType::New);
|
||||
|
||||
TENLog(isTitle ? "DoTitle" : "DoLevel", LogLevel::Info);
|
||||
|
||||
|
@ -392,7 +391,7 @@ GameStatus DoLevel(int levelIndex, bool loadGame)
|
|||
InitializeItemBoxData();
|
||||
|
||||
// Initialize scripting.
|
||||
InitializeScripting(levelIndex, loadType);
|
||||
InitializeScripting(levelIndex, loadGame);
|
||||
InitializeNodeScripts();
|
||||
|
||||
// Initialize menu and inventory state.
|
||||
|
@ -540,12 +539,12 @@ void CleanUp()
|
|||
ClearObjCamera();
|
||||
}
|
||||
|
||||
void InitializeScripting(int levelIndex, LevelLoadType type)
|
||||
void InitializeScripting(int levelIndex, bool loadGame)
|
||||
{
|
||||
TENLog("Loading level script...", LogLevel::Info);
|
||||
|
||||
g_GameStringsHandler->ClearDisplayStrings();
|
||||
g_GameScript->ResetScripts(!levelIndex || type != LevelLoadType::New);
|
||||
g_GameScript->ResetScripts(!levelIndex || loadGame);
|
||||
|
||||
const auto& level = *g_GameFlow->GetLevel(levelIndex);
|
||||
|
||||
|
@ -575,7 +574,7 @@ void InitializeScripting(int levelIndex, LevelLoadType type)
|
|||
}
|
||||
|
||||
// Play default background music.
|
||||
if (type != LevelLoadType::Load)
|
||||
if (!loadGame)
|
||||
PlaySoundTrack(level.GetAmbientTrack(), SoundTrackType::BGM, 0, SOUND_XFADETIME_LEVELJUMP);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,6 @@ enum class FreezeMode
|
|||
Player
|
||||
};
|
||||
|
||||
enum class LevelLoadType
|
||||
{
|
||||
New,
|
||||
Hub,
|
||||
Load
|
||||
};
|
||||
|
||||
enum CardinalDirection
|
||||
{
|
||||
NORTH,
|
||||
|
@ -106,8 +99,8 @@ void UpdateShatters();
|
|||
void CleanUp();
|
||||
|
||||
void InitializeOrLoadGame(bool loadGame);
|
||||
void InitializeScripting(int levelIndex, LevelLoadType type);
|
||||
void DeInitializeScripting(int levelIndex);
|
||||
void InitializeScripting(int levelIndex, bool loadGame);
|
||||
void DeInitializeScripting(int levelIndex, GameStatus reason);
|
||||
|
||||
void SetupInterpolation();
|
||||
|
||||
|
|
|
@ -1711,7 +1711,7 @@ static void ParseStatistics(const Save::SaveGame* s, bool isHub)
|
|||
SaveGame::Statistics.Game.Timer = s->game()->timer();
|
||||
}
|
||||
|
||||
static void ParseLua(const Save::SaveGame* s)
|
||||
static void ParseLua(const Save::SaveGame* s, bool hubMode)
|
||||
{
|
||||
// Event sets
|
||||
|
||||
|
@ -1815,7 +1815,7 @@ static void ParseLua(const Save::SaveGame* s)
|
|||
}
|
||||
}
|
||||
|
||||
g_GameScript->SetVariables(loadedVars);
|
||||
g_GameScript->SetVariables(loadedVars, hubMode);
|
||||
|
||||
auto populateCallbackVecs = [&s](auto callbackFunc)
|
||||
{
|
||||
|
@ -2679,7 +2679,7 @@ void SaveGame::Parse(const std::vector<byte>& buffer, bool hubMode)
|
|||
const Save::SaveGame* s = Save::GetSaveGame(buffer.data());
|
||||
|
||||
ParseLevel(s, hubMode);
|
||||
ParseLua(s);
|
||||
ParseLua(s, hubMode);
|
||||
ParseStatistics(s, hubMode);
|
||||
|
||||
// Effects and player data is ignored when loading hub.
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
virtual void ExecuteFunction(const std::string& luaFuncName, short idOne, short idTwo = 0) = 0;
|
||||
|
||||
virtual void GetVariables(std::vector<SavedVar>& vars) = 0;
|
||||
virtual void SetVariables(const std::vector<SavedVar>& vars) = 0;
|
||||
virtual void SetVariables(const std::vector<SavedVar>& vars, bool onlyLevelVars) = 0;
|
||||
|
||||
virtual void GetCallbackStrings(
|
||||
std::vector<std::string>& preStart,
|
||||
|
|
|
@ -485,9 +485,11 @@ void LogicHandler::FreeLevelScripts()
|
|||
}
|
||||
|
||||
// Used when loading.
|
||||
void LogicHandler::SetVariables(const std::vector<SavedVar>& vars)
|
||||
void LogicHandler::SetVariables(const std::vector<SavedVar>& vars, bool onlyLevelVars)
|
||||
{
|
||||
ResetGameTables();
|
||||
if (!onlyLevelVars)
|
||||
ResetGameTables();
|
||||
|
||||
ResetLevelTables();
|
||||
|
||||
std::unordered_map<unsigned int, sol::table> solTables;
|
||||
|
@ -565,6 +567,9 @@ void LogicHandler::SetVariables(const std::vector<SavedVar>& vars)
|
|||
for (auto& [first, second] : levelVars)
|
||||
(*m_handler.GetState())[ScriptReserved_LevelVars][first] = second;
|
||||
|
||||
if (onlyLevelVars)
|
||||
return;
|
||||
|
||||
sol::table gameVars = rootTable[ScriptReserved_GameVars];
|
||||
for (auto& [first, second] : gameVars)
|
||||
(*m_handler.GetState())[ScriptReserved_GameVars][first] = second;
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
void ExecuteFunction(const std::string& name, short idOne, short idTwo) override;
|
||||
|
||||
void GetVariables(std::vector<SavedVar>& vars) override;
|
||||
void SetVariables(const std::vector<SavedVar>& vars) override;
|
||||
void SetVariables(const std::vector<SavedVar>& vars, bool onlyLevelVars) override;
|
||||
void ResetVariables();
|
||||
|
||||
void SetCallbackStrings(const std::vector<std::string>& preStart,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue