From 353dbadfe9d53d49ec3c5cd5c9f11032d76b672f Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 6 Jan 2017 17:58:05 -0800 Subject: [PATCH] Code cleanup and corrections --- Editor/ProjectResourceFactoryBase.cpp | 3 +- Runtime/AutoMapper/CMapWorldInfo.cpp | 2 +- Runtime/AutoMapper/CMapWorldInfo.hpp | 2 +- Runtime/CGameOptions.cpp | 249 ++++++++++++++++++++++---- Runtime/CGameOptions.hpp | 49 +++-- Runtime/CGameState.cpp | 2 +- Runtime/CGameState.hpp | 19 +- Runtime/Collision/CMaterialFilter.cpp | 8 +- Runtime/Collision/CMaterialFilter.hpp | 8 +- Runtime/GameGlobalObjects.cpp | 2 + Runtime/GameGlobalObjects.hpp | 2 + Runtime/Input/ControlMapper.cpp | 6 +- Runtime/Weapon/CGameProjectile.cpp | 7 +- Runtime/World/CActor.cpp | 2 +- Runtime/World/CGameArea.cpp | 5 + Runtime/World/CGameArea.hpp | 2 + Runtime/World/CPlayer.cpp | 4 +- Runtime/World/CPlayer.hpp | 9 + Runtime/World/CScriptDock.cpp | 8 +- Runtime/World/CScriptSpawnPoint.cpp | 61 ++++++- Runtime/World/CScriptSpawnPoint.hpp | 3 +- Runtime/World/CWorld.cpp | 186 ++++++++----------- Runtime/World/CWorld.hpp | 7 +- Runtime/World/ScriptLoader.cpp | 10 +- Runtime/rstl.hpp | 24 ++- 25 files changed, 478 insertions(+), 202 deletions(-) diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 86686ba07..c2f29b574 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -501,7 +501,8 @@ void ProjectResourceFactoryBase::AsyncTask::CookComplete() /* Ready for buffer transaction at this point */ u32 availSz = std::max(0, s32(fr.length()) - s32(x14_resOffset)); x14_resSize = std::min(x14_resSize, availSz); - x10_loadBuffer.reset(new u8[x14_resSize]); + u8* derp = new u8[x14_resSize]; + x10_loadBuffer.reset(std::move(derp)); m_bufTransaction = m_parent.m_clientProc.addBufferTransaction(m_cookedPath, x10_loadBuffer.get(), x14_resSize, x14_resOffset); diff --git a/Runtime/AutoMapper/CMapWorldInfo.cpp b/Runtime/AutoMapper/CMapWorldInfo.cpp index 3f5ed0c3e..17298025c 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.cpp +++ b/Runtime/AutoMapper/CMapWorldInfo.cpp @@ -19,7 +19,7 @@ CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& saveWor } -void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const +void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, ResId mlvlId) const { } diff --git a/Runtime/AutoMapper/CMapWorldInfo.hpp b/Runtime/AutoMapper/CMapWorldInfo.hpp index 16b4dee7e..0713740ab 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.hpp +++ b/Runtime/AutoMapper/CMapWorldInfo.hpp @@ -15,7 +15,7 @@ class CMapWorldInfo public: CMapWorldInfo()=default; CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, ResId mlvlId); - void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const; + void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, ResId mlvlId) const; bool IsMapped() const; void SetIsMapped(bool) const; void SetDoorVisited(TEditorId eid, bool val); diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index b90530a3f..544d9bb1e 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -4,6 +4,7 @@ #include "CSimplePool.hpp" #include "CSaveWorld.hpp" #include "CGameHintInfo.hpp" +//#include "Audio/CStreamedAudioManager.hpp" namespace urde { @@ -33,7 +34,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); cinematicCount += saveWorld->GetCinematicCount(); } @@ -45,7 +46,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); auto stateIt = cinematicStates.cbegin(); for (TEditorId cineId : saveWorld->GetCinematics()) @@ -78,7 +79,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); for (TEditorId cineId : saveWorld->GetCinematics()) w.WriteEncoded(GetCinematicState(world.first, cineId), 1); @@ -88,7 +89,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const bool CPersistentOptions::GetCinematicState(ResId mlvlId, TEditorId cineId) const { auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(), - [&](const std::pair& pair) -> bool + [&](const std::pair& pair) -> bool { return pair.first == mlvlId && pair.second == cineId; }); @@ -99,7 +100,7 @@ bool CPersistentOptions::GetCinematicState(ResId mlvlId, TEditorId cineId) const void CPersistentOptions::SetCinematicState(ResId mlvlId, TEditorId cineId, bool state) { auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(), - [&](const std::pair& pair) -> bool + [&](const std::pair& pair) -> bool { return pair.first == mlvlId && pair.second == cineId; }); @@ -118,19 +119,39 @@ CGameOptions::CGameOptions(CBitStreamReader& stream) x44_soundMode = ESoundMode(stream.ReadEncoded(2)); x48_ = stream.ReadEncoded(4); - x4c_ = stream.ReadEncoded(6); - x50_ = stream.ReadEncoded(6); - x54_ = stream.ReadEncoded(5); - x58_ = stream.ReadEncoded(7); + x4c_screenXOffset = stream.ReadEncoded(6); + x50_screenYOffset = stream.ReadEncoded(6); + x54_screenStretch = stream.ReadEncoded(5); + x58_sfxVol = stream.ReadEncoded(7); x5c_musicVol = stream.ReadEncoded(7); - x60_ = stream.ReadEncoded(8); - x64_ = stream.ReadEncoded(8); + x60_helmetAlpha = stream.ReadEncoded(8); + x64_hudAlpha = stream.ReadEncoded(8); - x68_24_ = stream.ReadEncoded(1); - x68_28_ = stream.ReadEncoded(1); - x68_25_ = stream.ReadEncoded(1); - x68_26_ = stream.ReadEncoded(1); - x68_27_ = stream.ReadEncoded(1); + x68_24_hudLag = stream.ReadEncoded(1); + x68_28_hintSystem = stream.ReadEncoded(1); + x68_25_invertY = stream.ReadEncoded(1); + x68_26_rumble = stream.ReadEncoded(1); + x68_27_swapBeamsControls = stream.ReadEncoded(1); +} + +void CGameOptions::ResetToDefaults() +{ + x48_ = 4; + x4c_screenXOffset = 0; + x50_screenYOffset = 0; + x54_screenStretch = 0; + x58_sfxVol = 0x7f; + x5c_musicVol = 0x7f; + x44_soundMode = ESoundMode::Stereo; + x60_helmetAlpha = 0xFF; + x64_hudAlpha = 0xFF; + x68_24_hudLag = true; + x68_25_invertY = false; + x68_26_rumble = true; + x68_27_swapBeamsControls = false; + x68_28_hintSystem = true; + InitSoundMode(); + EnsureSettings(); } void CGameOptions::PutTo(CBitStreamWriter& writer) const @@ -141,33 +162,199 @@ void CGameOptions::PutTo(CBitStreamWriter& writer) const writer.WriteEncoded(u32(x44_soundMode), 2); writer.WriteEncoded(x48_, 4); - writer.WriteEncoded(x4c_, 6); - writer.WriteEncoded(x50_, 6); - writer.WriteEncoded(x54_, 5); - writer.WriteEncoded(x58_, 7); + writer.WriteEncoded(x4c_screenXOffset, 6); + writer.WriteEncoded(x50_screenYOffset, 6); + writer.WriteEncoded(x54_screenStretch, 5); + writer.WriteEncoded(x58_sfxVol, 7); writer.WriteEncoded(x5c_musicVol, 7); - writer.WriteEncoded(x60_, 8); - writer.WriteEncoded(x64_, 8); + writer.WriteEncoded(x60_helmetAlpha, 8); + writer.WriteEncoded(x64_hudAlpha, 8); - writer.WriteEncoded(x68_24_, 1); - writer.WriteEncoded(x68_28_, 1); - writer.WriteEncoded(x68_25_, 1); - writer.WriteEncoded(x68_26_, 1); - writer.WriteEncoded(x68_27_, 1); + writer.WriteEncoded(x68_24_hudLag, 1); + writer.WriteEncoded(x68_28_hintSystem, 1); + writer.WriteEncoded(x68_25_invertY, 1); + writer.WriteEncoded(x68_26_rumble, 1); + writer.WriteEncoded(x68_27_swapBeamsControls, 1); } CGameOptions::CGameOptions() { - x68_24_ = true; - x68_26_ = true; - x68_28_ = true; + x68_24_hudLag = true; + x68_26_rumble = true; + x68_28_hintSystem = true; InitSoundMode(); } +float CGameOptions::sub8020F054() +{ + return (0.375f * 1.f) + (float(x48_) * 0.25f); +} + void CGameOptions::InitSoundMode() { /* If system is mono, force x44 to mono, otherwise honor user preference */ } +static float flt805A8844 = 0.f; +void CGameOptions::sub8020F098(int val, bool b) +{ + x48_ = zeus::clamp(0, val, 8); + + if (b) + flt805A8844 = sub8020F054(); +} + +void CGameOptions::SetScreenPositionX(s32 pos, bool apply) +{ + x4c_screenXOffset = zeus::clamp(-30, pos, 30); + + if (apply) + { + /* TOOD: CGraphics related funcs */ + } +} + +void CGameOptions::SetScreenPositionY(s32 pos, bool apply) +{ + x50_screenYOffset = zeus::clamp(-30, pos, 30); + + if (apply) + { + /* TOOD: CGraphics related funcs */ + } +} + +void CGameOptions::SetScreenStretch(s32 st, bool apply) +{ + x54_screenStretch = zeus::clamp(-10, st, 10); + + if (apply) + { + /* TOOD: CGraphics related funcs */ + } +} + +void CGameOptions::SetSfxVolume(s32 vol, bool apply) +{ + x58_sfxVol = zeus::clamp(0, vol, 0x7f); + +#if 0 + if (apply) + { + CAudioSys::SysSetSfxVolume(x58_sfxVol, 1, 1, 1); + CStreamedAudioManager::SetSfxVolume(x58_sfxVol); + CMoviePlayer::SetSfxVolume(x58_sfxVol); + } +#endif +} + +void CGameOptions::SetMusicVolume(s32 vol, bool apply) +{ + x5c_musicVol = zeus::clamp(0, vol, 0x7f); +# if 0 + if (apply) + CStreamedAudioManager::SetGlobalVolume(x5c_musicVol); +#endif +} + +void CGameOptions::SetHUDAlpha(u32 alpha) +{ + x64_hudAlpha = alpha; +} + +u32 CGameOptions::GetHUDAlpha() const +{ + return x64_hudAlpha; +} + +void CGameOptions::SetHelmetAlpha(u32 alpha) +{ + x60_helmetAlpha = alpha; +} + +u32 CGameOptions::GetHelmetAlpha() const +{ + return x60_helmetAlpha; +} + +void CGameOptions::SetHUDLag(bool lag) +{ + x68_24_hudLag = lag; +} + +bool CGameOptions::GetHUDLag() const +{ + return x68_24_hudLag; +} + +void CGameOptions::SetInvertYAxis(bool invert) +{ + x68_25_invertY = invert; +} + +bool CGameOptions::GetInvertYAxis() const +{ + return x68_25_invertY; +} + +void CGameOptions::SetIsRumbleEnabled(bool rumble) +{ + x68_26_rumble = rumble; +} + +bool CGameOptions::IsRumbleEnabled() const +{ + return x68_26_rumble; +} + +void CGameOptions::ToggleControls(bool swap) +{ + x68_27_swapBeamsControls = swap; + if (!swap) + SetControls(0); + else + SetControls(1); +} + +void CGameOptions::SetIsHintSystemEnabled(bool hints) +{ + x68_28_hintSystem = hints; +} + +bool CGameOptions::IsHintSystemEnabled() const +{ + return x68_28_hintSystem; +} + +void CGameOptions::SetControls(s32 controls) +{ + if (controls == 0) + g_currentPlayerControl = g_tweakPlayerControl; + else + g_currentPlayerControl = g_tweakPlayerControlAlt; + + ResetControllerAssets(); +} + +void CGameOptions::ResetControllerAssets() +{ +} + +void CGameOptions::EnsureSettings() +{ + sub8020F098(x48_, true); + SetScreenPositionX(x4c_screenXOffset, true); + SetScreenPositionY(x50_screenYOffset, true); + SetScreenStretch(x54_screenStretch, true); + SetSfxVolume(x58_sfxVol, true); + SetMusicVolume(x5c_musicVol, true); + //SetSurroundMode(x44_soundMode, true); + SetHUDAlpha(x64_hudAlpha); + SetHUDLag(x68_24_hudLag); + SetInvertYAxis(x68_25_invertY); + SetIsRumbleEnabled(x68_26_rumble); + SetIsHintSystemEnabled(x68_28_hintSystem); + ToggleControls(x68_27_swapBeamsControls); +} CHintOptions::CHintOptions(CBitStreamReader& stream) { @@ -205,7 +392,7 @@ void CHintOptions::SetNextHintTime() if (x10_nextHintIdx == -1) return; x0_hintStates[x10_nextHintIdx].x4_time = - g_MemoryCardSys->GetHints()[x10_nextHintIdx].GetTime() + 5.f; + g_MemoryCardSys->GetHints()[x10_nextHintIdx].GetTime() + 5.f; } } diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index e4240c8ac..7c2b0aad0 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -2,6 +2,7 @@ #define __URDE_CGAMEOPTIONS_HPP__ #include "RetroTypes.hpp" +#include "Audio/CAudioSys.hpp" namespace urde { @@ -73,23 +74,23 @@ private: bool x0_[64] = {}; ESoundMode x44_soundMode = ESoundMode::Stereo; u32 x48_ = 4; - u32 x4c_ = 0; - u32 x50_ = 0; - u32 x54_ = 0; - u32 x58_ = 0x7f; + s32 x4c_screenXOffset = 0; + s32 x50_screenYOffset = 0; + s32 x54_screenStretch = 0; + u32 x58_sfxVol = 0x7f; u32 x5c_musicVol = 0x7f; - u32 x60_ = 0xff; - u32 x64_ = 0xff; + u32 x60_helmetAlpha = 0xff; + u32 x64_hudAlpha = 0xff; union { struct { - bool x68_24_ : 1; - bool x68_25_ : 1; - bool x68_26_ : 1; - bool x68_27_ : 1; - bool x68_28_ : 1; + bool x68_24_hudLag : 1; + bool x68_25_invertY : 1; + bool x68_26_rumble : 1; + bool x68_27_swapBeamsControls : 1; + bool x68_28_hintSystem : 1; }; u16 _dummy = 0; }; @@ -101,9 +102,35 @@ private: public: CGameOptions(); CGameOptions(CBitStreamReader& stream); + void ResetToDefaults(); void InitSoundMode(); + void EnsureSettings(); void PutTo(CBitStreamWriter& writer) const; u32 GetMusicVolume() const { return x5c_musicVol; } + + float sub8020F054(); + void sub8020F098(int, bool); + void SetScreenPositionX(s32, bool); + void SetScreenPositionY(s32, bool); + void SetScreenStretch(s32, bool); + void SetSfxVolume(s32, bool); + void SetMusicVolume(s32, bool); + //void SetSurroundMode(CAudioSys::ESurroundModes, int); + void SetHUDAlpha(u32); + u32 GetHUDAlpha() const; + void SetHelmetAlpha(u32); + u32 GetHelmetAlpha() const; + void SetHUDLag(bool); + bool GetHUDLag() const; + void SetInvertYAxis(bool); + bool GetInvertYAxis() const; + void SetIsRumbleEnabled(bool); + bool IsRumbleEnabled() const; + void ToggleControls(bool); + void SetIsHintSystemEnabled(bool); + bool IsHintSystemEnabled() const; + void SetControls(s32); + void ResetControllerAssets(); }; class CHintOptions diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 7a3b3fde7..1fa370d48 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -84,7 +84,7 @@ void CWorldState::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const writer.WriteEncoded(x4_areaId, 32); writer.WriteEncoded(x10_, 32); x8_relayTracker->PutTo(writer, savw); - xc_mapWorldInfo->PutTo(writer, savw); + xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId); x14_layerState->PutTo(writer); } diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index fad70cdae..65397e7eb 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -20,14 +20,12 @@ class CWorldLayerState friend class CSaveWorldIntermediate; std::vector x0_areaLayers; DataSpec::WordBitmap x10_saveLayers; + public: CWorldLayerState() = default; CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld); - bool IsLayerActive(int areaIdx, int layerIdx) const - { - return (x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1; - } + bool IsLayerActive(int areaIdx, int layerIdx) const { return (x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1; } void SetLayerActive(int areaIdx, int layerIdx, bool active) { @@ -39,10 +37,7 @@ public: void InitializeWorldLayers(const std::vector& layers); - u32 GetAreaLayerCount(int areaIdx) const - { - return x0_areaLayers[areaIdx].m_layerCount; - } + u32 GetAreaLayerCount(int areaIdx) const { return x0_areaLayers[areaIdx].m_layerCount; } void PutTo(CBitStreamWriter& writer) const; }; @@ -55,10 +50,11 @@ class CWorldState std::shared_ptr xc_mapWorldInfo; u32 x10_; std::shared_ptr x14_layerState; + public: CWorldState(ResId id); CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld); - ResId GetWorldAssetId() const {return x0_mlvlId;} + ResId GetWorldAssetId() const { return x0_mlvlId; } void SetAreaId(TAreaId aid) { x4_areaId = aid; } TAreaId GetCurrentAreaId() const { return x4_areaId; } const std::shared_ptr& RelayTracker() const { return x8_relayTracker; } @@ -101,8 +97,8 @@ public: CGameState(); CGameState(CBitStreamReader& stream, u32 saveIdx); void SetCurrentWorldId(ResId id); - std::shared_ptr GetPlayerState() {return x98_playerState;} - std::shared_ptr GetWorldTransitionManager() {return x9c_transManager;} + std::shared_ptr GetPlayerState() { return x98_playerState; } + std::shared_ptr GetWorldTransitionManager() { return x9c_transManager; } void SetTotalPlayTime(float time); CPersistentOptions& SystemOptions() { return xa8_systemOptions; } CGameOptions& GameOptions() { return x17c_gameOptions; } @@ -137,7 +133,6 @@ public: }; static GameFileStateInfo LoadGameFileState(const u8* data); }; - } #endif // __URDE_CGAMESTATE_HPP__ diff --git a/Runtime/Collision/CMaterialFilter.cpp b/Runtime/Collision/CMaterialFilter.cpp index 99bce3113..4c5d0bcac 100644 --- a/Runtime/Collision/CMaterialFilter.cpp +++ b/Runtime/Collision/CMaterialFilter.cpp @@ -2,7 +2,7 @@ namespace urde { -const CMaterialFilter CMaterialFilter::skPassEverything({0x00000000FFFFFFFF}, {0}, CMaterialFilter::EFilterType::Zero); +const CMaterialFilter CMaterialFilter::skPassEverything({0x00000000FFFFFFFF}, {0}, CMaterialFilter::EFilterType::Include); CMaterialFilter::CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude, CMaterialFilter::EFilterType type) : x0_include(include), @@ -13,17 +13,17 @@ CMaterialFilter::CMaterialFilter(const CMaterialList& include, const CMaterialLi CMaterialFilter CMaterialFilter::MakeInclude(const CMaterialList& include) { - return CMaterialFilter(include, {EMaterialTypes::Unknown}, EFilterType::Zero); + return CMaterialFilter(include, {0ull}, EFilterType::Include); } CMaterialFilter CMaterialFilter::MakeExclude(const CMaterialList& exclude) { - return CMaterialFilter({u64(0x00000000FFFFFFFF)}, exclude, EFilterType::Two); + return CMaterialFilter({u64(0x00000000FFFFFFFF)}, exclude, EFilterType::Exclude); } CMaterialFilter CMaterialFilter::MakeIncludeExclude(const CMaterialList& include, const CMaterialList& exclude) { - return CMaterialFilter(include, exclude, EFilterType::Three); + return CMaterialFilter(include, exclude, EFilterType::IncludeExclude); } } diff --git a/Runtime/Collision/CMaterialFilter.hpp b/Runtime/Collision/CMaterialFilter.hpp index 7631c9760..8d35682ae 100644 --- a/Runtime/Collision/CMaterialFilter.hpp +++ b/Runtime/Collision/CMaterialFilter.hpp @@ -10,15 +10,15 @@ class CMaterialFilter public: enum class EFilterType { - Zero, + Include, One, - Two, - Three + Exclude, + IncludeExclude }; private: CMaterialList x0_include; CMaterialList x8_exclude; - EFilterType x10_type = EFilterType::Three; + EFilterType x10_type = EFilterType::IncludeExclude; public: static const CMaterialFilter skPassEverything; diff --git a/Runtime/GameGlobalObjects.cpp b/Runtime/GameGlobalObjects.cpp index cbd173d2a..1a545152c 100644 --- a/Runtime/GameGlobalObjects.cpp +++ b/Runtime/GameGlobalObjects.cpp @@ -21,6 +21,8 @@ class CStringTable* g_MainStringTable = nullptr; DataSpec::ITweakGame* g_tweakGame = nullptr; DataSpec::ITweakPlayer* g_tweakPlayer = nullptr; DataSpec::ITweakPlayerControl* g_tweakPlayerControl = nullptr; +DataSpec::ITweakPlayerControl* g_tweakPlayerControlAlt = nullptr; +DataSpec::ITweakPlayerControl* g_currentPlayerControl = nullptr; DataSpec::ITweakPlayerGun* g_tweakPlayerGun = nullptr; DataSpec::ITweakGunRes* g_tweakGunRes = nullptr; DataSpec::ITweakPlayerRes* g_tweakPlayerRes = nullptr; diff --git a/Runtime/GameGlobalObjects.hpp b/Runtime/GameGlobalObjects.hpp index 888048f44..e82e3e581 100644 --- a/Runtime/GameGlobalObjects.hpp +++ b/Runtime/GameGlobalObjects.hpp @@ -32,6 +32,8 @@ extern class CStringTable* g_MainStringTable; extern DataSpec::ITweakGame* g_tweakGame; extern DataSpec::ITweakPlayer* g_tweakPlayer; extern DataSpec::ITweakPlayerControl* g_tweakPlayerControl; +extern DataSpec::ITweakPlayerControl* g_tweakPlayerControlAlt; +extern DataSpec::ITweakPlayerControl* g_currentPlayerControl; extern DataSpec::ITweakPlayerGun* g_tweakPlayerGun; extern DataSpec::ITweakGunRes* g_tweakGunRes; extern DataSpec::ITweakPlayerRes* g_tweakPlayerRes; diff --git a/Runtime/Input/ControlMapper.cpp b/Runtime/Input/ControlMapper.cpp index a48934e59..3d99f033a 100644 --- a/Runtime/Input/ControlMapper.cpp +++ b/Runtime/Input/ControlMapper.cpp @@ -206,7 +206,7 @@ bool ControlMapper::GetPressInput(ECommands cmd, const CFinalInput& input) { if (!skCommandFilterFlag[int(cmd)]) return false; - EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(atUint32(cmd))); + EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd))); if (func > EFunctionList::MAX) return false; BoolReturnFn fn = skPressFuncs[int(func)]; @@ -219,7 +219,7 @@ bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input) { if (!skCommandFilterFlag[int(cmd)]) return false; - EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(atUint32(cmd))); + EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd))); if (func > EFunctionList::MAX) return false; BoolReturnFn fn = skDigitalFuncs[int(func)]; @@ -232,7 +232,7 @@ float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) { if (!skCommandFilterFlag[int(cmd)]) return 0.0; - EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(atUint32(cmd))); + EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd))); if (func > EFunctionList::MAX) return 0.0; FloatReturnFn fn = skAnalogFuncs[int(func)]; diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp index 117f14c4e..de38b8009 100644 --- a/Runtime/Weapon/CGameProjectile.cpp +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -8,10 +8,9 @@ CGameProjectile::CGameProjectile(bool active, const TToken&, u32 w1, bool b2, const zeus::CVector3f&, const rstl::optional_object>&, s16, bool b3) : CWeapon(owner, aid, uid, active, wType, name, xf, - CMaterialFilter(CMaterialList(EMaterialTypes::NonSolidDamageable, matType), - CMaterialList(EMaterialTypes::Projectile, EMaterialTypes::ProjectilePassthrough, matType, - EMaterialTypes::Solid), - CMaterialFilter::EFilterType::Three), + CMaterialFilter::MakeIncludeExclude( + {EMaterialTypes::NonSolidDamageable, matType}, + {EMaterialTypes::Projectile, EMaterialTypes::ProjectilePassthrough, matType, EMaterialTypes::Solid}), CMaterialList(), dInfo, EProjectileAttrib(w1) | GetBeamAttribType(wType), CModelData::CModelDataNull()) { } diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index ffe4e5317..d5ff607e3 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -20,7 +20,7 @@ CActor::CActor(TUniqueId uid, bool active, const std::string& name, const CEntit CModelData&& mData, const CMaterialList& list, const CActorParameters& params, TUniqueId otherUid) : CEntity(uid, info, active, name) , x68_material(MakeActorMaterialList(list, params)) -, x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Unknown})) +, x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull})) , xc6_(otherUid) { if (mData.x10_animData || mData.x1c_normalModel) diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 37b5e788c..d8e8469ac 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -654,6 +654,11 @@ void CGameArea::ReloadAllUnloadedTextures() { } +void CGameArea::PrepTokens() +{ + +} + u32 CGameArea::GetNumPartSizes() const { return hecl::SBig(*reinterpret_cast(x110_mreaSecBufs[0].first.get() + 60)); diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index 9fee6747e..a0c4a627a 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -274,6 +274,7 @@ public: void PreRender(); void AliveUpdate(float dt); void SetOcclusionState(EOcclusionState state); + EOcclusionState GetOcclusionState() const { return GetPostConstructed()->x10dc_occlusionState; } void RemoveStaticGeometry(); void AddStaticGeometry(); //void TransferTokensToARAM(); @@ -283,6 +284,7 @@ public: //void UnloadAllLoadedTextures(); //void ReloadAllLoadedTextures(); void ReloadAllUnloadedTextures(); + void PrepTokens(); u32 GetNumPartSizes() const; void AllocNewAreaData(int, int); bool Invalidate(CStateManager& mgr); diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 82cab9ab9..12446fe17 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -133,7 +133,7 @@ u16 CPlayer::GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, int, u1 u16 CPlayer::SfxIdFromMaterial(const CMaterialList& mat, const u16* idList, u32 tableLen, u16 defId) { u16 id = defId; - for (u32 i = 0 ; i < tableLen; ++i) + for (u32 i = 0; i < tableLen; ++i) { if (mat.HasMaterial(EMaterialTypes(i)) && idList[i] != 0xFFFF) id = idList[i]; @@ -359,4 +359,6 @@ void CPlayer::CVisorSteam::Update(float dt) x24_ = 0.1f; } + +void CPlayer::SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState, CStateManager&) {} } diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 7ce1af32e..8b26b2a04 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -45,6 +45,14 @@ public: { }; + enum class EPlayerMorphBallState + { + Unmorphed, + Morphed, + Morphing, + UnMorphing + }; + private: struct CVisorSteam { @@ -210,6 +218,7 @@ public: void UpdateScanningState(const CFinalInput& input, CStateManager& mgr, float); void ValidateScanning(const CFinalInput& input, CStateManager& mgr); void SetScanningState(EPlayerScanState, CStateManager& mgr); + void SetSpawnedMorphBallState(EPlayerMorphBallState, CStateManager&); bool GetExplorationMode() const; bool GetCombatMode() const; void RenderGun(CStateManager& mgr, const zeus::CVector3f&) const; diff --git a/Runtime/World/CScriptDock.cpp b/Runtime/World/CScriptDock.cpp index b7fcb960c..206681b93 100644 --- a/Runtime/World/CScriptDock.cpp +++ b/Runtime/World/CScriptDock.cpp @@ -105,7 +105,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat CMaterialList exclude = GetMaterialFilter().GetExcludeList(); CMaterialList include = GetMaterialFilter().GetIncludeList(); include.Add(EMaterialTypes::AIBlock); - SetMaterialFilter({include, exclude, CMaterialFilter::EFilterType::Three}); + SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude)); } break; case EScriptObjectMessage::SetToZero: @@ -147,10 +147,8 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat } else if (aid == 0 || (mgr.GetWorld()->GetNumAreas() <= aid || !mgr.WorldNC()->GetArea(aid)->GetActive())) return; -#if 0 - /* Propogate through area chain */ - sub800C40DC((msg == EScriptObjectMessage::Increment), mgr.GetWorld()->GetAreaAlways(aid), mgr.WorldNC()); -#endif + CWorld::PropogateAreaChain(CGameArea::EOcclusionState(msg == EScriptObjectMessage::Increment), + mgr.WorldNC()->GetArea(aid), mgr.WorldNC()); } break; default: diff --git a/Runtime/World/CScriptSpawnPoint.cpp b/Runtime/World/CScriptSpawnPoint.cpp index e7f39667a..a51966d78 100644 --- a/Runtime/World/CScriptSpawnPoint.cpp +++ b/Runtime/World/CScriptSpawnPoint.cpp @@ -1,15 +1,69 @@ #include "CScriptSpawnPoint.hpp" +#include "CStateManager.hpp" +#include "CWorld.hpp" +#include "CPlayer.hpp" namespace urde { CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, - const zeus::CTransform& xf, const std::vector& itemCounts, - bool defaultSpawn, bool active, bool b3) + const zeus::CTransform& xf, const std::vector& itemCounts, bool defaultSpawn, + bool active, bool morphed) : CEntity(uid, info, active, name), x34_xf(xf), x64_itemCounts(itemCounts) { x10c_24_firstSpawn = defaultSpawn; - x10c_25_ = b3; + x10c_25_morphed = morphed; +} + +void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) +{ + CEntity::AcceptScriptMsg(msg, objId, stateMgr); + + if (msg == EScriptObjectMessage::SetToZero || msg == EScriptObjectMessage::Reset) + { + if (msg == EScriptObjectMessage::Reset) + { + using EPlayerItemType = CPlayerState::EItemType; + const std::shared_ptr& plState = stateMgr.GetPlayerState(); + for (u32 i = 0; i < u32(EPlayerItemType::Max); ++i) + { + plState->ReInitalizePowerUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i))); + plState->ResetAndIncrPickUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i))); + } + } + + if (GetActive()) + { + CPlayer* player = stateMgr.Player(); + + if (x4_areaId != stateMgr.GetNextAreaId()) + { + CGameArea* area = stateMgr.WorldNC()->GetArea(x4_areaId); + if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::NotOccluded) + { + /* while (!area->TryTakingOutOfARAM()) {} */ + CWorld::PropogateAreaChain(CGameArea::EOcclusionState::Occluded, area, stateMgr.WorldNC()); + } + + stateMgr.SetCurrentAreaId(x4_areaId); + stateMgr.SetActorAreaId(*stateMgr.Player(), x4_areaId); + player->Teleport(GetTransform(), stateMgr, true); + player->SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState(x10c_25_morphed), stateMgr); + + if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::Occluded) + CWorld::PropogateAreaChain(CGameArea::EOcclusionState::NotOccluded, + stateMgr.WorldNC()->GetArea(stateMgr.GetNextAreaId()), + stateMgr.WorldNC()); + } + else + { + player->Teleport(GetTransform(), stateMgr, true); + player->SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState(x10c_25_morphed), stateMgr); + } + } + + CEntity::SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None); + } } u32 CScriptSpawnPoint::GetPowerup(CPlayerState::EItemType item) const @@ -19,5 +73,4 @@ u32 CScriptSpawnPoint::GetPowerup(CPlayerState::EItemType item) const return x64_itemCounts.front(); return x64_itemCounts[idx]; } - } diff --git a/Runtime/World/CScriptSpawnPoint.hpp b/Runtime/World/CScriptSpawnPoint.hpp index 1fea0be73..f3e8eb8be 100644 --- a/Runtime/World/CScriptSpawnPoint.hpp +++ b/Runtime/World/CScriptSpawnPoint.hpp @@ -17,7 +17,7 @@ class CScriptSpawnPoint : public CEntity struct { bool x10c_24_firstSpawn : 1; - bool x10c_25_ : 1; + bool x10c_25_morphed : 1; }; u8 _dummy = 0; }; @@ -26,6 +26,7 @@ public: const zeus::CTransform& xf, const std::vector& itemCounts, bool, bool, bool); + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); bool FirstSpawn() const { return x10c_24_firstSpawn; } const zeus::CTransform& GetTransform() const { return x34_xf; } u32 GetPowerup(CPlayerState::EItemType item) const; diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index 36282d130..03110f300 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -10,53 +10,30 @@ namespace urde { -CWorld::CSoundGroupData::CSoundGroupData(int grpId, ResId agsc) -: x0_groupId(grpId), x4_agscId(agsc) +CWorld::CSoundGroupData::CSoundGroupData(int grpId, ResId agsc) : x0_groupId(grpId), x4_agscId(agsc) { x1c_groupData = g_SimplePool->GetObj(SObjectTag{FOURCC('AGSC'), agsc}); } -CDummyWorld::CDummyWorld(ResId mlvlId, bool loadMap) -: x4_loadMap(loadMap), xc_mlvlId(mlvlId) +CDummyWorld::CDummyWorld(ResId mlvlId, bool loadMap) : x4_loadMap(loadMap), xc_mlvlId(mlvlId) { SObjectTag tag{FOURCC('MLVL'), mlvlId}; static_cast(g_ResFactory)->LoadResourceAsync(tag, x34_loadBuf); } -ResId CDummyWorld::IGetWorldAssetId() const -{ - return xc_mlvlId; -} +ResId CDummyWorld::IGetWorldAssetId() const { return xc_mlvlId; } -ResId CDummyWorld::IGetStringTableAssetId() const -{ - return x10_strgId; -} +ResId CDummyWorld::IGetStringTableAssetId() const { return x10_strgId; } -ResId CDummyWorld::IGetSaveWorldAssetId() const -{ - return x14_savwId; -} +ResId CDummyWorld::IGetSaveWorldAssetId() const { return x14_savwId; } -const CMapWorld* CDummyWorld::IGetMapWorld() const -{ - return x2c_mapWorld.GetObj(); -} +const CMapWorld* CDummyWorld::IGetMapWorld() const { return x2c_mapWorld.GetObj(); } -CMapWorld* CDummyWorld::IMapWorld() -{ - return x2c_mapWorld.GetObj(); -} +CMapWorld* CDummyWorld::IMapWorld() { return x2c_mapWorld.GetObj(); } -const IGameArea* CDummyWorld::IGetAreaAlways(TAreaId id) const -{ - return &x18_areas.at(id); -} +const IGameArea* CDummyWorld::IGetAreaAlways(TAreaId id) const { return &x18_areas.at(id); } -TAreaId CDummyWorld::IGetCurrentAreaId() const -{ - return x3c_curAreaId; -} +TAreaId CDummyWorld::IGetCurrentAreaId() const { return x3c_curAreaId; } TAreaId CDummyWorld::IGetAreaId(ResId id) const { @@ -85,7 +62,7 @@ std::vector CWorld::CRelay::ReadMemoryRelays(athena::io::MemoryR std::vector ret; u32 count = r.readUint32Big(); ret.reserve(count); - for (u32 i=0 ; i 10) { u32 audioGroupCount = r.readUint32Big(); - for (u32 i=0 ; i(resFactory).LoadResourceAsync(tag, x40_loadBuf); } -ResId CWorld::IGetWorldAssetId() const -{ - return x8_mlvlId; -} +ResId CWorld::IGetWorldAssetId() const { return x8_mlvlId; } -ResId CWorld::IGetStringTableAssetId() const -{ - return xc_strgId; -} +ResId CWorld::IGetStringTableAssetId() const { return xc_strgId; } -ResId CWorld::IGetSaveWorldAssetId() const -{ - return x10_savwId; -} +ResId CWorld::IGetSaveWorldAssetId() const { return x10_savwId; } -const CMapWorld* CWorld::IGetMapWorld() const -{ - return const_cast(this)->GetMapWorld(); -} +const CMapWorld* CWorld::IGetMapWorld() const { return const_cast(this)->GetMapWorld(); } -CMapWorld* CWorld::IMapWorld() -{ - return const_cast(GetMapWorld()); -} +CMapWorld* CWorld::IMapWorld() { return const_cast(GetMapWorld()); } -const CGameArea* CWorld::GetAreaAlways(TAreaId id) const -{ - return x18_areas.at(id).get(); -} +const CGameArea* CWorld::GetAreaAlways(TAreaId id) const { return x18_areas.at(id).get(); } -CGameArea* CWorld::GetArea(TAreaId id) -{ - return const_cast(GetAreaAlways(id)); -} +CGameArea* CWorld::GetArea(TAreaId id) { return const_cast(GetAreaAlways(id)); } -const IGameArea* CWorld::IGetAreaAlways(TAreaId id) const -{ - return GetAreaAlways(id); -} +const IGameArea* CWorld::IGetAreaAlways(TAreaId id) const { return GetAreaAlways(id); } -TAreaId CWorld::IGetCurrentAreaId() const -{ - return x68_curAreaId; -} +TAreaId CWorld::IGetCurrentAreaId() const { return x68_curAreaId; } TAreaId CWorld::IGetAreaId(ResId id) const { @@ -285,13 +229,9 @@ void CWorld::MoveToChain(CGameArea* area, EChain chain) x4c_chainHeads[int(chain)] = area; } -void CWorld::LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data) -{ -} +void CWorld::LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data) {} -void CWorld::LoadSoundGroups() -{ -} +void CWorld::LoadSoundGroups() {} bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) { @@ -338,12 +278,12 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) r.readUint32Big(); x18_areas.reserve(areaCount); - for (u32 i=0 ; i(r, i, version)); if (x48_chainCount < 5) { - for (int i=x48_chainCount ; i<5 ; ++i) + for (int i = x48_chainCount; i < 5; ++i) x4c_chainHeads[i] = nullptr; x48_chainCount = 5; } @@ -365,7 +305,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) { u32 audioGroupCount = r.readUint32Big(); x74_soundGroupData.reserve(audioGroupCount); - for (u32 i=0 ; ixcc_docks) { u32 dockRefCount = dock.GetDockRefs().size(); - for (u32 i=0 ; iSetWhichMapAreasLoaded(*this, aid, 3); } -bool CWorld::ICheckWorldComplete() -{ - return CheckWorldComplete(nullptr, kInvalidAreaId, -1); -} +bool CWorld::ICheckWorldComplete() { return CheckWorldComplete(nullptr, kInvalidAreaId, -1); } -std::string CWorld::IGetDefaultAudioTrack() const -{ - return x84_defAudioTrack; -} +std::string CWorld::IGetDefaultAudioTrack() const { return x84_defAudioTrack; } -int CWorld::IGetAreaCount() const -{ - return x18_areas.size(); -} +int CWorld::IGetAreaCount() const { return x18_areas.size(); } -bool CWorld::DoesAreaExist(TAreaId area) const -{ - return (area >= 0 && area < x18_areas.size()); -} +bool CWorld::DoesAreaExist(TAreaId area) const { return (area >= 0 && area < x18_areas.size()); } +void CWorld::PropogateAreaChain(CGameArea::EOcclusionState occlusionState, CGameArea* area, CWorld* world) +{ + if (!area->GetPostConstructed() || occlusionState == area->GetOcclusionState()) + return; + + if (occlusionState == CGameArea::EOcclusionState::Occluded) + area->SetOcclusionState(CGameArea::EOcclusionState::Occluded); + + CGameArea* areaItr = world->x4c_chainHeads[3]; + + while (areaItr != skGlobalNonConstEnd) + { + if (areaItr == area) + { + areaItr = areaItr->x130_next; + continue; + } + if (areaItr->IsPostConstructed() && areaItr->GetOcclusionState() == CGameArea::EOcclusionState::Occluded) + areaItr->PrepTokens(); + areaItr = areaItr->x130_next; + } + + areaItr = world->x4c_chainHeads[3]; + + while (areaItr != skGlobalNonConstEnd) + { + if (areaItr == area) + { + areaItr = areaItr->x130_next; + continue; + } + + + if (area->IsPostConstructed() && areaItr->GetOcclusionState() == CGameArea::EOcclusionState::NotOccluded) + areaItr->PrepTokens(); + areaItr = areaItr->x130_next; + } + + if (occlusionState == CGameArea::EOcclusionState::NotOccluded) + area->SetOcclusionState(CGameArea::EOcclusionState::NotOccluded); +} } diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index 826e8b3df..7ab957d57 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -101,7 +101,8 @@ public: }; private: - + static constexpr CGameArea* skGlobalEnd = nullptr; + static constexpr CGameArea* skGlobalNonConstEnd = nullptr; enum class Phase { Loading, @@ -177,6 +178,10 @@ public: bool ICheckWorldComplete(); std::string IGetDefaultAudioTrack() const; int IGetAreaCount() const; + + static void PropogateAreaChain(CGameArea::EOcclusionState, CGameArea*, CWorld*); + static const CGameArea* GetAliveAreasEnd() { return skGlobalEnd; } + static CGameArea* AliveAreasEnd() { return skGlobalNonConstEnd; } }; struct CWorldLayers diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index b3fffe128..86dbfb462 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -827,14 +827,14 @@ CEntity* ScriptLoader::LoadSpawnPoint(CStateManager& mgr, CInputStream& in, int for (int i = 0; i < propCount - 6; ++i) itemCounts.push_back(in.readUint32Big()); - bool b1 = in.readBool(); - bool b2 = in.readBool(); - bool b3 = false; + bool defaultSpawn = in.readBool(); + bool active = in.readBool(); + bool morphed = false; if (propCount > 34) - b3 = in.readBool(); + morphed = in.readBool(); return new CScriptSpawnPoint(mgr.AllocateUniqueId(), *name, info, - ConvertEditorEulerToTransform4f(rotation, position), itemCounts, b1, b2, b3); + ConvertEditorEulerToTransform4f(rotation, position), itemCounts, defaultSpawn, active, morphed); } CEntity* ScriptLoader::LoadCameraHint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) diff --git a/Runtime/rstl.hpp b/Runtime/rstl.hpp index 444f65a0c..2607dcf13 100644 --- a/Runtime/rstl.hpp +++ b/Runtime/rstl.hpp @@ -18,10 +18,30 @@ template class reserved_vector : public std::vector { public: - reserved_vector() {this->reserve(N);} - reserved_vector(size_t n, const T& val) : std::vector(n, val) { } + reserved_vector() { this->reserve(N); } + reserved_vector(size_t n, const T& val) : std::vector(n, val) {} }; +template +class prereserved_vector +{ + size_t x0_size = 1; + T x4_data[N]; + +public: + void set_size(size_t n) + { + if (n <= N) + x0_size = n; + } + + void set_data(const T* data) { memmove(x4_data, data, sizeof(T) * x0_size); } + + size_t size() const { return x0_size; } + + T& back() const { x4_data[(x0_size == 0) ? 0 : x0_size - 1]; } + T& front() const { return x4_data[0]; } +}; } #endif // __RSTL_HPP__