Skip to content

Commit

Permalink
Use method access
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Aug 21, 2024
1 parent cb773fb commit 78d32b6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
40 changes: 22 additions & 18 deletions Client/game_sa/CDummyPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,32 @@ void CDummyPoolSA::UpdateBuildingLods(void* oldPool, void* newPool)
const std::uint32_t offset = (std::uint32_t)newPool - (std::uint32_t)oldPool;

if (m_pOriginalElementsBackup)
UpdateBackupLodOffset(offset);
else
UpdateLodsOffestInPool(offset);
}

void CDummyPoolSA::UpdateBackupLodOffset(const std::uint32_t offset)
{
for (auto i = 0; i < (*m_pOriginalElementsBackup).size(); i++)
{
for (auto i = 0; i < (*m_pOriginalElementsBackup).size(); i++)
if ((*m_pOriginalElementsBackup)[i].first)
{
if ((*m_pOriginalElementsBackup)[i].first)
{
CEntitySAInterface* object = &(*m_pOriginalElementsBackup)[i].second;
if (object->m_pLod)
{
object->m_pLod = (CEntitySAInterface*)((std::uint32_t)(object->m_pLod) + offset);
}
}
CEntitySAInterface* object = &(*m_pOriginalElementsBackup)[i].second;
CEntitySAInterface* lod = object->GetLod();
if (lod)
object->SetLod((CEntitySAInterface*)((std::uint32_t)lod + offset));
}
}
else
}

void CDummyPoolSA::UpdateLodsOffestInPool(const std::uint32_t offset)
{
for (auto i = 0; i < (*m_ppDummyPoolInterface)->Size(); i++)
{
for (auto i = 0; i < (*m_ppDummyPoolInterface)->Size(); i++)
{
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
if (object->m_pLod)
{
object->m_pLod = (CEntitySAInterface*)((std::uint32_t)object->m_pLod + offset);
}
}
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
CEntitySAInterface* lod = object->GetLod();
if (lod)
object->SetLod((CEntitySAInterface*)((std::uint32_t)lod + offset));
}
}
4 changes: 4 additions & 0 deletions Client/game_sa/CDummyPoolSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class CDummyPoolSA final : public CDummyPool
void RestoreBackup() override;
void UpdateBuildingLods(void* oldPool, void* newPool);

private:
void UpdateBackupLodOffset(const std::uint32_t offest);
void UpdateLodsOffestInPool(const std::uint32_t offset);

private:
CPoolSAInterface<CEntitySAInterface>** m_ppDummyPoolInterface;

Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CEntitySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ class CEntitySAInterface
// Functions to hide member variable misuse
//

void SetLod(CEntitySAInterface* pLod) noexcept { m_pLod = pLod; };
CEntitySAInterface* GetLod() const noexcept { return m_pLod; };

// Sets
void SetIsLowLodEntity() { numLodChildrenRendered = 0x40; }

Expand Down

0 comments on commit 78d32b6

Please sign in to comment.