diff --git a/configure.py b/configure.py index da965c58..02f577e5 100755 --- a/configure.py +++ b/configure.py @@ -350,7 +350,7 @@ LIBS = [ "MetroidPrime/Enemies/CMetroidPrimeEssence", "MetroidPrime/Enemies/CMetroidPrimeRelay", "MetroidPrime/Player/CPlayerDynamics", - ["MetroidPrime/ScriptObjects/CScriptMazeNode", False], + ["MetroidPrime/ScriptObjects/CScriptMazeNode", True], ["MetroidPrime/Weapons/WeaponTypes", False], "MetroidPrime/Enemies/COmegaPirate", "MetroidPrime/Enemies/CPhazonPool", diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index 38f5d668..358b9fdc 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -219,7 +219,7 @@ public: // TODO ? void AddThermalColdScale2(float s) { xf28_thermColdScale2 += s; } - bool IsGeneratingObject() const { return xf94_26_generatingObject; } + const bool IsGeneratingObject() const { return xf94_26_generatingObject; } void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; } void ApplyDamageToWorld(TUniqueId, const CActor&, const CVector3f&, const CDamageInfo& info, diff --git a/include/rstl/pointer_iterator.hpp b/include/rstl/pointer_iterator.hpp index eb2cbd2f..e77cac7c 100644 --- a/include/rstl/pointer_iterator.hpp +++ b/include/rstl/pointer_iterator.hpp @@ -80,8 +80,9 @@ public: pointer_iterator() : const_pointer_iterator< T, Vec, Alloc >(nullptr) {} pointer_iterator(T* begin) : const_pointer_iterator< T, Vec, Alloc >(begin) {} void operator=(const T& other) { rstl::construct(this->current, other); } - T& operator*() const { return *this->current; } - T* operator->() const { return this->current; } + T& operator*() { return *this->current; } + // TODO map says const, but breaks CScriptMazeNode::GenerateObjects + T* operator->() { return this->current; } pointer_iterator& operator++() { ++this->current; return *this; diff --git a/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp b/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp index 33e67184..4139e9ca 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp @@ -81,12 +81,12 @@ void CMazeState::Reset(int seed) { } } -SMazeCell& CMazeState::GetCell(uint col, uint row) { return x4_cells[col + row * skMazeCols]; } - const SMazeCell& CMazeState::GetCell(uint col, uint row) const { return x4_cells[col + row * skMazeCols]; } +SMazeCell& CMazeState::GetCell(uint col, uint row) { return x4_cells[col + row * skMazeCols]; } + static inline int GetRandom(CRandom16& rand, int offset) { int tmp = rand.Next(); return tmp - ((tmp / 5) * 5) + offset; @@ -256,26 +256,9 @@ CScriptMazeNode::CScriptMazeNode(TUniqueId uid, const rstl::string& name, const void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(*this); } -static inline TUniqueId GenerateObject(CStateManager& mgr, const TEditorId& eid) { - bool wasGeneratingObject = mgr.IsGeneratingObject(); - mgr.SetIsGeneratingObject(true); - TUniqueId objUid = mgr.GenerateObject(eid).second; - mgr.SetIsGeneratingObject(wasGeneratingObject); - return objUid; -} - -// struct GenerateObjectGuard { -// GenerateObjectGuard(CStateManager& mgr) : mgr(mgr), wasGenerating(mgr.IsGeneratingObject()) {} -// ~GenerateObjectGuard() { mgr.SetIsGeneratingObject(wasGenerating); } -// CStateManager& mgr; -// bool wasGenerating; -// }; - -// TODO non-matching -// https://decomp.me/scratch/IvHBz void CScriptMazeNode::GenerateObjects(CStateManager& mgr) { - rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin(); - for (; conn != GetConnectionList().end(); ++conn) { + rstl::vector< SConnection >::iterator conn = ConnectionList().begin(); + for (; conn != ConnectionList().end(); ++conn) { if (conn->x0_state != kSS_MaxReached || conn->x4_msg != kSM_Activate) { continue; } @@ -291,12 +274,10 @@ void CScriptMazeNode::GenerateObjects(CStateManager& mgr) { continue; } - TUniqueId objUid = GenerateObject(mgr, conn->x8_objId); - // TUniqueId objUid = kInvalidUniqueId; - // bool wasGeneratingObject = mgr.IsGeneratingObject(); - // mgr.SetIsGeneratingObject(true); - // TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second; - // mgr.SetIsGeneratingObject(wasGeneratingObject); + bool wasGeneratingObject = mgr.IsGeneratingObject(); + mgr.SetIsGeneratingObject(true); + TUniqueId objUid = mgr.GenerateObject(conn->x8_objId).second; + mgr.SetIsGeneratingObject(wasGeneratingObject); if (CActor* actor = static_cast< CActor* >(mgr.ObjectById(objUid))) { mgr.SendScriptMsg(actor, GetUniqueId(), kSM_Activate); @@ -379,7 +360,6 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C continue; } - // TUniqueId genObj = GenerateObject(mgr, conn->x8_objId); bool wasGeneratingObject = mgr.IsGeneratingObject(); mgr.SetIsGeneratingObject(true); TUniqueId genObj = mgr.GenerateObject(conn->x8_objId).second;