Skip to content

Commit 1baa606

Browse files
authored
Merge branch 'master' into TheNormalnij/aggresive_restream
2 parents a4d7aac + 9d65bb6 commit 1baa606

File tree

81 files changed

+703
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+703
-105
lines changed

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding)
101101
// Remove plant
102102
pGame->GetPlantManager()->RemovePlant(pInterface);
103103

104-
RemoveBuildingFromWorld(pInterface);
104+
// Remove shadow
105+
pInterface->RemoveShadows();
106+
107+
// Remove building from world
108+
pGame->GetWorld()->Remove(pInterface, CBuildingPool_Destructor);
109+
110+
// Call virtual destructor
111+
((void*(__thiscall*)(void*, char))pInterface->vtbl->SCALAR_DELETING_DESTRUCTOR)(pInterface, 0);
105112

106113
// Remove col reference
107114
auto modelInfo = pGame->GetModelInfo(pBuilding->GetModelIndex());

Client/game_sa/CGameSA.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ CGameSA::CGameSA()
145145
m_pPlantManager = new CPlantManagerSA();
146146
m_pBuildingRemoval = new CBuildingRemovalSA();
147147

148+
m_pRenderer = std::make_unique<CRendererSA>();
149+
148150
// Normal weapon types (WEAPONSKILL_STD)
149151
for (int i = 0; i < NUM_WeaponInfosStdSkill; i++)
150152
{

Client/game_sa/CGameSA.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CStreamingSA.h"
1818
#include "CCoverManagerSA.h"
1919
#include "CPlantManagerSA.h"
20+
#include "CRendererSA.h"
2021

2122
class CAnimBlendClumpDataSAInterface;
2223
class CObjectGroupPhysicalPropertiesSA;
@@ -172,7 +173,8 @@ class CGameSA : public CGame
172173
CCoverManagerSA* GetCoverManager() const noexcept { return m_pCoverManager; };
173174
CPlantManagerSA* GetPlantManager() const noexcept { return m_pPlantManager; };
174175
CBuildingRemoval* GetBuildingRemoval() { return m_pBuildingRemoval; }
175-
176+
CRenderer* GetRenderer() const noexcept override { return m_pRenderer.get(); }
177+
176178
CWeaponInfo* GetWeaponInfo(eWeaponType weapon, eWeaponSkill skill = WEAPONSKILL_STD);
177179
CModelInfo* GetModelInfo(DWORD dwModelID, bool bCanBeInvalid = false);
178180
CObjectGroupPhysicalProperties* GetObjectGroupPhysicalProperties(unsigned char ucObjectGroup);
@@ -348,6 +350,8 @@ class CGameSA : public CGame
348350
CPlantManagerSA* m_pPlantManager;
349351
CBuildingRemoval* m_pBuildingRemoval;
350352

353+
std::unique_ptr<CRendererSA> m_pRenderer;
354+
351355
CPad* m_pPad;
352356
CAERadioTrackManager* m_pCAERadioTrackManager;
353357
CAudioEngine* m_pAudioEngine;

Client/game_sa/CHeliSA.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,47 @@
1515

1616
class CHeliSAInterface : public CAutomobileSAInterface
1717
{
18+
public:
19+
std::uint8_t m_heliFlags;
20+
21+
std::uint8_t _pad1[3];
22+
std::uint32_t m_leftRightSkid;
23+
std::uint32_t m_steeringUpDown;
24+
std::uint32_t m_steeringLeftRight;
25+
std::uint32_t m_accelerationBreakStatus;
26+
std::uint32_t field_99C;
27+
std::uint32_t m_rotorZ;
28+
std::uint32_t m_secondRotorZ;
29+
std::uint32_t m_maxAltitude;
30+
std::uint32_t field_9AC;
31+
std::uint32_t m_minAltitude;
32+
std::uint32_t field_9B4;
33+
std::uint8_t field_9B8;
34+
std::uint8_t m_numSwatOccupants;
35+
std::uint8_t m_swatIDs[4];
36+
37+
std::uint8_t _pad2[2];
38+
std::uint32_t field_9C0[4];
39+
std::uint32_t field_9D0;
40+
41+
std::uint32_t m_particlesList;
42+
std::uint8_t field_9D8[24];
43+
std::uint32_t field_9F0;
44+
CVector m_searchLightTarget;
45+
std::uint32_t m_searchLightIntensity;
46+
std::uint32_t field_A04;
47+
std::uint32_t field_A08;
48+
std::uint32_t m_gunflashFx;
49+
std::uint8_t m_firingMultiplier;
50+
std::uint8_t m_searchLightEnabled;
51+
std::uint8_t _pad3[2];
52+
std::uint32_t field_A14;
1853
};
54+
static_assert(sizeof(CHeliSAInterface) == 0xA18, "Invalid size for CHeliSAInterface");
1955

2056
class CHeliSA final : public virtual CHeli, public virtual CAutomobileSA
2157
{
2258
public:
2359
CHeliSA(CHeliSAInterface* pInterface);
60+
CHeliSAInterface* GetHeliInterface() noexcept { return reinterpret_cast<CHeliSAInterface*>(GetInterface()); }
2461
};

Client/game_sa/CModelInfoSA.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,10 @@ void CModelInfoSA::RestoreAllObjectsPropertiesGroups()
20252025

20262026
eModelInfoType CModelInfoSA::GetModelType()
20272027
{
2028-
return ((eModelInfoType(*)())m_pInterface->VFTBL->GetModelType)();
2028+
if (auto pInterface = GetInterface())
2029+
return ((eModelInfoType(*)())pInterface->VFTBL->GetModelType)();
2030+
2031+
return eModelInfoType::UNKNOWN;
20292032
}
20302033

20312034
bool CModelInfoSA::IsTowableBy(CModelInfo* towingModel)

Client/game_sa/CRendererSA.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto v1.0
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: game_sa/CRendererSA.cpp
6+
* PURPOSE: Game renderer class
7+
*
8+
* Multi Theft Auto is available from http://www.multitheftauto.com/
9+
*
10+
*****************************************************************************/
11+
12+
#include "StdInc.h"
13+
#include "CRendererSA.h"
14+
#include "CModelInfoSA.h"
15+
#include "CMatrix.h"
16+
#include "gamesa_renderware.h"
17+
18+
CRendererSA::CRendererSA()
19+
{
20+
}
21+
22+
CRendererSA::~CRendererSA()
23+
{
24+
}
25+
26+
void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix)
27+
{
28+
CBaseModelInfoSAInterface* pModelInfoSAInterface = pModelInfo->GetInterface();
29+
if (!pModelInfoSAInterface)
30+
return;
31+
32+
RwObject* pRwObject = pModelInfoSAInterface->pRwObject;
33+
if (!pRwObject)
34+
return;
35+
36+
RwFrame* pFrame = RpGetFrame(pRwObject);
37+
38+
static RwMatrix rwMatrix;
39+
rwMatrix.right = (RwV3d&)matrix.vRight;
40+
rwMatrix.up = (RwV3d&)matrix.vFront;
41+
rwMatrix.at = (RwV3d&)matrix.vUp;
42+
rwMatrix.pos = (RwV3d&)matrix.vPos;
43+
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE);
44+
45+
if (pRwObject->type == RP_TYPE_ATOMIC)
46+
{
47+
RpAtomic* pRpAtomic = reinterpret_cast<RpAtomic*>(pRwObject);
48+
pRpAtomic->renderCallback(reinterpret_cast<RpAtomic*>(pRwObject));
49+
}
50+
else
51+
{
52+
RpClump* pClump = reinterpret_cast<RpClump*>(pRwObject);
53+
RpClumpRender(pClump);
54+
}
55+
}

Client/game_sa/CRendererSA.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto v1.0
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: game_sa/CRendererSA.h
6+
* PURPOSE: Game renderer class
7+
*
8+
* Multi Theft Auto is available from http://www.multitheftauto.com/
9+
*
10+
*****************************************************************************/
11+
12+
#pragma once
13+
14+
#include <game/CRenderer.h>
15+
16+
class CRendererSA : public CRenderer
17+
{
18+
public:
19+
CRendererSA();
20+
~CRendererSA();
21+
22+
void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) override;
23+
};

Client/game_sa/CVisibilityPluginsSA.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "StdInc.h"
1313
#include "CVisibilityPluginsSA.h"
1414

15+
#define FUNC_CVisibilityPlugins_InsertEntityIntoEntityList 0x733DD0
16+
1517
void CVisibilityPluginsSA::SetClumpAlpha(RpClump* pClump, int iAlpha)
1618
{
1719
DWORD dwFunc = FUNC_CVisiblityPlugins_SetClumpAlpha;
@@ -51,3 +53,8 @@ int CVisibilityPluginsSA::GetAtomicId(RwObject* pAtomic)
5153
}
5254
return iResult;
5355
}
56+
57+
bool CVisibilityPluginsSA::InsertEntityIntoEntityList(void* entity, float distance, void* callback)
58+
{
59+
return ((bool(_cdecl*)(void*, float, void*))FUNC_CVisibilityPlugins_InsertEntityIntoEntityList)(entity, distance, callback);
60+
}

Client/game_sa/CVisibilityPluginsSA.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ class CVisibilityPluginsSA : public CVisibilityPlugins
2121
public:
2222
void SetClumpAlpha(RpClump* pClump, int iAlpha);
2323
int GetAtomicId(RwObject* pAtomic);
24+
25+
bool InsertEntityIntoEntityList(void* entity, float distance, void* callback);
2426
};

Client/game_sa/gamesa_renderware.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ typedef RwFrame*(__cdecl* RwFrameAddChild_t)(RwFrame* parent, RwFrame* child);
3838
typedef RwFrame*(__cdecl* RwFrameRemoveChild_t)(RwFrame* child);
3939
typedef RwFrame*(__cdecl* RwFrameForAllObjects_t)(RwFrame* frame, void* callback, void* data);
4040
typedef RwFrame*(__cdecl* RwFrameTranslate_t)(RwFrame* frame, const RwV3d* v, RwTransformOrder order);
41+
typedef RwFrame*(__cdecl* RwFrameTransform_t)(RwFrame* frame, const RwMatrix* m, RwOpCombineType combine);
4142
typedef RwFrame*(__cdecl* RwFrameScale_t)(RwFrame* frame, const RwV3d* v, RwTransformOrder order);
4243
typedef RwFrame*(__cdecl* RwFrameUpdateObjects_t)(RwFrame*);
4344
typedef RwFrame*(__cdecl* RwFrameCreate_t)();
@@ -69,6 +70,7 @@ typedef RwTexture*(__cdecl* RwTexDictionaryAddTexture_t)(RwTexDictionary* dict,
6970
typedef RwTexDictionary*(__cdecl* RwTexDictionaryGetCurrent_t)();
7071
typedef RwTexture*(__cdecl* RwTexDictionaryFindNamedTexture_t)(RwTexDictionary* dict, const char* name);
7172
typedef void(__cdecl* RpPrtStdGlobalDataSetStreamEmbedded_t)(void* value);
73+
typedef RpClump*(__cdecl* RpClumpRender_t)(RpClump* clump);
7274
typedef RpWorld*(__cdecl* RpWorldAddAtomic_t)(RpWorld* world, RpAtomic* atomic);
7375
typedef RpWorld*(__cdecl* RpWorldAddClump_t)(RpWorld* world, RpClump* clump);
7476
typedef RpWorld*(__cdecl* RpWorldAddLight_t)(RpWorld* world, RpLight* light);
@@ -125,6 +127,7 @@ RWFUNC(RwStreamSkip_t RwStreamSkip, (RwStreamSkip_t)0xDEAD)
125127
RWFUNC(RpClumpDestroy_t RpClumpDestroy, (RpClumpDestroy_t)0xDEAD)
126128
RWFUNC(RpClumpGetNumAtomics_t RpClumpGetNumAtomics, (RpClumpGetNumAtomics_t)0xDEAD)
127129
RWFUNC(RwFrameTranslate_t RwFrameTranslate, (RwFrameTranslate_t)0xDEAD)
130+
RWFUNC(RwFrameTransform_t RwFrameTransform, (RwFrameTransform_t)0xDEAD)
128131
RWFUNC(RpClumpForAllAtomics_t RpClumpForAllAtomics, (RpClumpForAllAtomics_t)0xDEAD)
129132
RWFUNC(RwFrameAddChild_t RwFrameAddChild, (RwFrameAddChild_t)0xDEAD)
130133
RWFUNC(RpClumpAddAtomic_t RpClumpAddAtomic, (RpClumpAddAtomic_t)0xDEAD)
@@ -138,6 +141,7 @@ RWFUNC(RwTexDictionaryAddTexture_t RwTexDictionaryAddTexture, (RwTexDictionaryAd
138141
RWFUNC(RwTexDictionaryStreamWrite_t RwTexDictionaryStreamWrite, (RwTexDictionaryStreamWrite_t)0xDEAD)
139142
RWFUNC(rwD3D9NativeTextureRead_t rwD3D9NativeTextureRead, (rwD3D9NativeTextureRead_t)0xDEAD)
140143
RWFUNC(RpPrtStdGlobalDataSetStreamEmbedded_t RpPrtStdGlobalDataSetStreamEmbedded, (RpPrtStdGlobalDataSetStreamEmbedded_t)0xDEAD)
144+
RWFUNC(RpClumpRender_t RpClumpRender, (RpClumpRender_t)0xDEAD)
141145
RWFUNC(RpClumpRemoveAtomic_t RpClumpRemoveAtomic, (RpClumpRemoveAtomic_t)0xDEAD)
142146
RWFUNC(RpAtomicClone_t RpAtomicClone, (RpAtomicClone_t)0xDEAD)
143147
RWFUNC(RwTexDictionaryFindNamedTexture_t RwTexDictionaryFindNamedTexture, (RwTexDictionaryFindNamedTexture_t)0xDEAD)

0 commit comments

Comments
 (0)