Skip to content

Commit 0d55a24

Browse files
committed
Small fixes
1 parent dd0d38f commit 0d55a24

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

Client/game_sa/CBuildingsPoolSA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class CBuildingsPoolSA : public CBuildingsPool
4343
SVectorPoolData<CBuildingSA> m_buildingPool{MAX_BUILDINGS};
4444
CPoolSAInterface<CBuildingSAInterface>** m_ppBuildingPoolInterface;
4545

46-
typedef std::uint8_t building_buffer_t[sizeof(CBuildingSAInterface)];
47-
typedef std::array<std::pair<bool, building_buffer_t>, MAX_BUILDINGS> backup_array_t;
46+
using building_buffer_t = std::uint8_t[sizeof(CBuildingSAInterface)];
47+
using backup_array_t = std::array<std::pair<bool, building_buffer_t>, MAX_BUILDINGS>;
4848

4949
std::unique_ptr<backup_array_t> m_pOriginalBuildingsBackup;
5050
};

Client/game_sa/CEntitySA.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ class CEntitySAInterface : public CPlaceableSAInterface
216216
using CStencilShadow_dtorByOwner = void*(__cdecl*)(CEntitySAInterface * pEntity);
217217
((CStencilShadow_dtorByOwner)0x711730)(this);
218218
};
219-
220-
bool IsUsesEntityDeleteRwObject() const { return *reinterpret_cast<void**>(*reinterpret_cast<std::uint32_t const*>(this) + 0x20) == (void*)0x00534030; };
221219
};
222220
static_assert(sizeof(CEntitySAInterface) == 0x38, "Invalid size for CEntitySAInterface");
223221

Client/game_sa/CModelInfoSA.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,15 @@ void CModelInfoSA::StaticFlushPendingRestreamIPL()
985985
CEntitySAInterface* pEntity = (CEntitySAInterface*)pSectorEntry[0];
986986

987987
// Possible bug - pEntity seems to be invalid here occasionally
988-
if (!pEntity->IsUsesEntityDeleteRwObject())
988+
constexpr auto CEntity_DeleteRwObject_VTBL_OFFSET = 8;
989+
if (static_cast<std::size_t*>(pEntity->GetVTBL())[CEntity_DeleteRwObject_VTBL_OFFSET] != 0x00534030)
989990
{
990991
// Log info
991992
OutputDebugString(SString("Entity 0x%08x (with model %d) at ARRAY_StreamSectors[%d,%d] is invalid\n", pEntity, pEntity->m_nModelIndex,
992993
i / 2 % NUM_StreamSectorRows, i / 2 / NUM_StreamSectorCols));
993994
// Assert in debug
994995
#if MTA_DEBUG
995-
assert(pEntity->IsUsesEntityDeleteRwObject());
996+
assert(static_cast<std::size_t*>(pEntity->GetVTBL())[CEntity_DeleteRwObject_VTBL_OFFSET] != 0x00534030);
996997
#endif
997998
pSectorEntry = (DWORD*)pSectorEntry[1];
998999
continue;

Client/game_sa/CPlaceableSA.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ class CPlaceableSAInterface
2222
public:
2323
virtual void* Destructor(bool free) = 0;
2424

25-
bool IsPlaceableVTBL() const { return *reinterpret_cast<const void* const*>(this) == (void*)0x863C40; }
26-
bool HasVTBL() const { return *reinterpret_cast<const void* const*>(this) != nullptr; }
25+
void* GetVTBL() const { return *reinterpret_cast<void* const*>(this); }
26+
bool HasVTBL() const { return GetVTBL() != nullptr; }
27+
bool IsPlaceableVTBL() const { return GetVTBL() == (void*)0x863C40; }
28+
2729
bool HasMatrix() const noexcept { return matrix != nullptr; }
2830
void RemoveMatrix() { ((void(__thiscall*)(void*))0x54F3B0)(this); }
2931

Client/game_sa/CProjectileSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class CProjectileSAInterface : public CObjectSAInterface // entirely inherited from CObject
1818
{
1919
public:
20-
bool IsProjectableVTBL() const { return *reinterpret_cast<const std::uint32_t*>(this) == 0x867030; };
20+
bool IsProjectableVTBL() const { return GetVTBL() == (void*)0x867030; };
2121
};
2222

2323
class CProjectileSA : public virtual CProjectile, public virtual CObjectSA

0 commit comments

Comments
 (0)