Skip to content

Commit

Permalink
Merge branch 'master' into TheNormalnij/aggresive_restream
Browse files Browse the repository at this point in the history
  • Loading branch information
Dutchman101 authored Sep 4, 2024
2 parents a4d7aac + 9d65bb6 commit 1baa606
Show file tree
Hide file tree
Showing 81 changed files with 703 additions and 105 deletions.
9 changes: 8 additions & 1 deletion Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding)
// Remove plant
pGame->GetPlantManager()->RemovePlant(pInterface);

RemoveBuildingFromWorld(pInterface);
// Remove shadow
pInterface->RemoveShadows();

// Remove building from world
pGame->GetWorld()->Remove(pInterface, CBuildingPool_Destructor);

// Call virtual destructor
((void*(__thiscall*)(void*, char))pInterface->vtbl->SCALAR_DELETING_DESTRUCTOR)(pInterface, 0);

// Remove col reference
auto modelInfo = pGame->GetModelInfo(pBuilding->GetModelIndex());
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ CGameSA::CGameSA()
m_pPlantManager = new CPlantManagerSA();
m_pBuildingRemoval = new CBuildingRemovalSA();

m_pRenderer = std::make_unique<CRendererSA>();

// Normal weapon types (WEAPONSKILL_STD)
for (int i = 0; i < NUM_WeaponInfosStdSkill; i++)
{
Expand Down
6 changes: 5 additions & 1 deletion Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "CStreamingSA.h"
#include "CCoverManagerSA.h"
#include "CPlantManagerSA.h"
#include "CRendererSA.h"

class CAnimBlendClumpDataSAInterface;
class CObjectGroupPhysicalPropertiesSA;
Expand Down Expand Up @@ -172,7 +173,8 @@ class CGameSA : public CGame
CCoverManagerSA* GetCoverManager() const noexcept { return m_pCoverManager; };
CPlantManagerSA* GetPlantManager() const noexcept { return m_pPlantManager; };
CBuildingRemoval* GetBuildingRemoval() { return m_pBuildingRemoval; }

CRenderer* GetRenderer() const noexcept override { return m_pRenderer.get(); }

CWeaponInfo* GetWeaponInfo(eWeaponType weapon, eWeaponSkill skill = WEAPONSKILL_STD);
CModelInfo* GetModelInfo(DWORD dwModelID, bool bCanBeInvalid = false);
CObjectGroupPhysicalProperties* GetObjectGroupPhysicalProperties(unsigned char ucObjectGroup);
Expand Down Expand Up @@ -348,6 +350,8 @@ class CGameSA : public CGame
CPlantManagerSA* m_pPlantManager;
CBuildingRemoval* m_pBuildingRemoval;

std::unique_ptr<CRendererSA> m_pRenderer;

CPad* m_pPad;
CAERadioTrackManager* m_pCAERadioTrackManager;
CAudioEngine* m_pAudioEngine;
Expand Down
37 changes: 37 additions & 0 deletions Client/game_sa/CHeliSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,47 @@

class CHeliSAInterface : public CAutomobileSAInterface
{
public:
std::uint8_t m_heliFlags;

std::uint8_t _pad1[3];
std::uint32_t m_leftRightSkid;
std::uint32_t m_steeringUpDown;
std::uint32_t m_steeringLeftRight;
std::uint32_t m_accelerationBreakStatus;
std::uint32_t field_99C;
std::uint32_t m_rotorZ;
std::uint32_t m_secondRotorZ;
std::uint32_t m_maxAltitude;
std::uint32_t field_9AC;
std::uint32_t m_minAltitude;
std::uint32_t field_9B4;
std::uint8_t field_9B8;
std::uint8_t m_numSwatOccupants;
std::uint8_t m_swatIDs[4];

std::uint8_t _pad2[2];
std::uint32_t field_9C0[4];
std::uint32_t field_9D0;

std::uint32_t m_particlesList;
std::uint8_t field_9D8[24];
std::uint32_t field_9F0;
CVector m_searchLightTarget;
std::uint32_t m_searchLightIntensity;
std::uint32_t field_A04;
std::uint32_t field_A08;
std::uint32_t m_gunflashFx;
std::uint8_t m_firingMultiplier;
std::uint8_t m_searchLightEnabled;
std::uint8_t _pad3[2];
std::uint32_t field_A14;
};
static_assert(sizeof(CHeliSAInterface) == 0xA18, "Invalid size for CHeliSAInterface");

class CHeliSA final : public virtual CHeli, public virtual CAutomobileSA
{
public:
CHeliSA(CHeliSAInterface* pInterface);
CHeliSAInterface* GetHeliInterface() noexcept { return reinterpret_cast<CHeliSAInterface*>(GetInterface()); }
};
5 changes: 4 additions & 1 deletion Client/game_sa/CModelInfoSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,10 @@ void CModelInfoSA::RestoreAllObjectsPropertiesGroups()

eModelInfoType CModelInfoSA::GetModelType()
{
return ((eModelInfoType(*)())m_pInterface->VFTBL->GetModelType)();
if (auto pInterface = GetInterface())
return ((eModelInfoType(*)())pInterface->VFTBL->GetModelType)();

return eModelInfoType::UNKNOWN;
}

bool CModelInfoSA::IsTowableBy(CModelInfo* towingModel)
Expand Down
55 changes: 55 additions & 0 deletions Client/game_sa/CRendererSA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CRendererSA.cpp
* PURPOSE: Game renderer class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"
#include "CRendererSA.h"
#include "CModelInfoSA.h"
#include "CMatrix.h"
#include "gamesa_renderware.h"

CRendererSA::CRendererSA()
{
}

CRendererSA::~CRendererSA()
{
}

void CRendererSA::RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix)
{
CBaseModelInfoSAInterface* pModelInfoSAInterface = pModelInfo->GetInterface();
if (!pModelInfoSAInterface)
return;

RwObject* pRwObject = pModelInfoSAInterface->pRwObject;
if (!pRwObject)
return;

RwFrame* pFrame = RpGetFrame(pRwObject);

static RwMatrix rwMatrix;
rwMatrix.right = (RwV3d&)matrix.vRight;
rwMatrix.up = (RwV3d&)matrix.vFront;
rwMatrix.at = (RwV3d&)matrix.vUp;
rwMatrix.pos = (RwV3d&)matrix.vPos;
RwFrameTransform(pFrame, &rwMatrix, rwCOMBINEREPLACE);

if (pRwObject->type == RP_TYPE_ATOMIC)
{
RpAtomic* pRpAtomic = reinterpret_cast<RpAtomic*>(pRwObject);
pRpAtomic->renderCallback(reinterpret_cast<RpAtomic*>(pRwObject));
}
else
{
RpClump* pClump = reinterpret_cast<RpClump*>(pRwObject);
RpClumpRender(pClump);
}
}
23 changes: 23 additions & 0 deletions Client/game_sa/CRendererSA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CRendererSA.h
* PURPOSE: Game renderer class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#pragma once

#include <game/CRenderer.h>

class CRendererSA : public CRenderer
{
public:
CRendererSA();
~CRendererSA();

void RenderModel(CModelInfo* pModelInfo, const CMatrix& matrix) override;
};
7 changes: 7 additions & 0 deletions Client/game_sa/CVisibilityPluginsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "StdInc.h"
#include "CVisibilityPluginsSA.h"

#define FUNC_CVisibilityPlugins_InsertEntityIntoEntityList 0x733DD0

void CVisibilityPluginsSA::SetClumpAlpha(RpClump* pClump, int iAlpha)
{
DWORD dwFunc = FUNC_CVisiblityPlugins_SetClumpAlpha;
Expand Down Expand Up @@ -51,3 +53,8 @@ int CVisibilityPluginsSA::GetAtomicId(RwObject* pAtomic)
}
return iResult;
}

bool CVisibilityPluginsSA::InsertEntityIntoEntityList(void* entity, float distance, void* callback)
{
return ((bool(_cdecl*)(void*, float, void*))FUNC_CVisibilityPlugins_InsertEntityIntoEntityList)(entity, distance, callback);
}
2 changes: 2 additions & 0 deletions Client/game_sa/CVisibilityPluginsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ class CVisibilityPluginsSA : public CVisibilityPlugins
public:
void SetClumpAlpha(RpClump* pClump, int iAlpha);
int GetAtomicId(RwObject* pAtomic);

bool InsertEntityIntoEntityList(void* entity, float distance, void* callback);
};
4 changes: 4 additions & 0 deletions Client/game_sa/gamesa_renderware.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef RwFrame*(__cdecl* RwFrameAddChild_t)(RwFrame* parent, RwFrame* child);
typedef RwFrame*(__cdecl* RwFrameRemoveChild_t)(RwFrame* child);
typedef RwFrame*(__cdecl* RwFrameForAllObjects_t)(RwFrame* frame, void* callback, void* data);
typedef RwFrame*(__cdecl* RwFrameTranslate_t)(RwFrame* frame, const RwV3d* v, RwTransformOrder order);
typedef RwFrame*(__cdecl* RwFrameTransform_t)(RwFrame* frame, const RwMatrix* m, RwOpCombineType combine);
typedef RwFrame*(__cdecl* RwFrameScale_t)(RwFrame* frame, const RwV3d* v, RwTransformOrder order);
typedef RwFrame*(__cdecl* RwFrameUpdateObjects_t)(RwFrame*);
typedef RwFrame*(__cdecl* RwFrameCreate_t)();
Expand Down Expand Up @@ -69,6 +70,7 @@ typedef RwTexture*(__cdecl* RwTexDictionaryAddTexture_t)(RwTexDictionary* dict,
typedef RwTexDictionary*(__cdecl* RwTexDictionaryGetCurrent_t)();
typedef RwTexture*(__cdecl* RwTexDictionaryFindNamedTexture_t)(RwTexDictionary* dict, const char* name);
typedef void(__cdecl* RpPrtStdGlobalDataSetStreamEmbedded_t)(void* value);
typedef RpClump*(__cdecl* RpClumpRender_t)(RpClump* clump);
typedef RpWorld*(__cdecl* RpWorldAddAtomic_t)(RpWorld* world, RpAtomic* atomic);
typedef RpWorld*(__cdecl* RpWorldAddClump_t)(RpWorld* world, RpClump* clump);
typedef RpWorld*(__cdecl* RpWorldAddLight_t)(RpWorld* world, RpLight* light);
Expand Down Expand Up @@ -125,6 +127,7 @@ RWFUNC(RwStreamSkip_t RwStreamSkip, (RwStreamSkip_t)0xDEAD)
RWFUNC(RpClumpDestroy_t RpClumpDestroy, (RpClumpDestroy_t)0xDEAD)
RWFUNC(RpClumpGetNumAtomics_t RpClumpGetNumAtomics, (RpClumpGetNumAtomics_t)0xDEAD)
RWFUNC(RwFrameTranslate_t RwFrameTranslate, (RwFrameTranslate_t)0xDEAD)
RWFUNC(RwFrameTransform_t RwFrameTransform, (RwFrameTransform_t)0xDEAD)
RWFUNC(RpClumpForAllAtomics_t RpClumpForAllAtomics, (RpClumpForAllAtomics_t)0xDEAD)
RWFUNC(RwFrameAddChild_t RwFrameAddChild, (RwFrameAddChild_t)0xDEAD)
RWFUNC(RpClumpAddAtomic_t RpClumpAddAtomic, (RpClumpAddAtomic_t)0xDEAD)
Expand All @@ -138,6 +141,7 @@ RWFUNC(RwTexDictionaryAddTexture_t RwTexDictionaryAddTexture, (RwTexDictionaryAd
RWFUNC(RwTexDictionaryStreamWrite_t RwTexDictionaryStreamWrite, (RwTexDictionaryStreamWrite_t)0xDEAD)
RWFUNC(rwD3D9NativeTextureRead_t rwD3D9NativeTextureRead, (rwD3D9NativeTextureRead_t)0xDEAD)
RWFUNC(RpPrtStdGlobalDataSetStreamEmbedded_t RpPrtStdGlobalDataSetStreamEmbedded, (RpPrtStdGlobalDataSetStreamEmbedded_t)0xDEAD)
RWFUNC(RpClumpRender_t RpClumpRender, (RpClumpRender_t)0xDEAD)
RWFUNC(RpClumpRemoveAtomic_t RpClumpRemoveAtomic, (RpClumpRemoveAtomic_t)0xDEAD)
RWFUNC(RpAtomicClone_t RpAtomicClone, (RpAtomicClone_t)0xDEAD)
RWFUNC(RwTexDictionaryFindNamedTexture_t RwTexDictionaryFindNamedTexture, (RwTexDictionaryFindNamedTexture_t)0xDEAD)
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/gamesa_renderware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void InitRwFunctions()
RwStreamSkip = (RwStreamSkip_t)0x007ECD00;
RpClumpDestroy = (RpClumpDestroy_t)0x0074A310;
RpClumpGetNumAtomics = (RpClumpGetNumAtomics_t)0x007498E0;
RwFrameTransform = (RwFrameTransform_t)0x007F0F70;
RwFrameTranslate = (RwFrameTranslate_t)0x007F0E30;
RpClumpForAllAtomics = (RpClumpForAllAtomics_t)0x00749B70;
RwFrameAddChild = (RwFrameAddChild_t)0x007F0B00;
Expand All @@ -34,6 +35,7 @@ void InitRwFunctions()
RwTexDictionaryStreamWrite = (RwTexDictionaryStreamWrite_t)0x008049F0;
rwD3D9NativeTextureRead = (rwD3D9NativeTextureRead_t)0x004CD820;
RpPrtStdGlobalDataSetStreamEmbedded = (RpPrtStdGlobalDataSetStreamEmbedded_t)0x0041B350;
RpClumpRender = (RpClumpRender_t)0x00749B20;
RpClumpRemoveAtomic = (RpClumpRemoveAtomic_t)0x0074A4C0;
RpAtomicClone = (RpAtomicClone_t)0x00749E60;
RwTexDictionaryFindNamedTexture = (RwTexDictionaryFindNamedTexture_t)0x007F39F0;
Expand Down
8 changes: 4 additions & 4 deletions Client/loader/MainFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,15 +863,15 @@ void CheckDataFiles()
{
const char* expected;
const char* fileName;
} integrityCheckList[] = {{"36CB1B284BC7CBB4F25CD00BBB044550", "bass.dll"}, {"1B909B47946167D153FB94020393E781", "bass_aac.dll"},
{"E7E69A3B369F0ABA1A4A18C831BC4364", "bass_ac3.dll"}, {"E20A57EA7D845FADC9A48A0AA919121A", "bass_fx.dll"},
} integrityCheckList[] = {{"36CB1B284BC7CBB4F25CD00BBB044550", "bass.dll"}, {"80CDC5A50B27C47E53B99DE4D4523698", "bass_aac.dll"},
{"2757D3E0F63C8C62DB32F90D776AB815", "bass_ac3.dll"}, {"539BE2B8762FF618C3BA04B638FD4A8B", "bass_fx.dll"},
{"F47DCE69DAFAA06A55A4BC1F07F80C8A", "bassflac.dll"}, {"F246D72BA73E9624FE8BE66E785FB5C5", "bassmidi.dll"},
{"5DEEC10A943E352EF7E0223327E8B48C", "bassmix.dll"}, {"2F87C5E0A1B7B28C8FC0D7E74116DDFC", "bassopus.dll"},
{"0F1B2FC6C0C703A43A24DC05352E7ADA", "basswebm.dll"}, {"893113C6C49DC1E1EF288310E68DB306", "basswma.dll"},
{"C6A44FC3CF2F5801561804272217B14D", "D3DX9_42.dll"}, {"D439E8EDD8C93D7ADE9C04BCFE9197C6", "sa.dat"},
{"B33B21DB610116262D906305CE65C354", "D3DCompiler_42.dll"}, {"02ECD2919B3DAA59D6014EEFD29FC294", "tags.dll"},
{"B33B21DB610116262D906305CE65C354", "D3DCompiler_42.dll"}, {"7A1665DD46726DA4592E77DC05D114F8", "tags.dll"},
{"0B3DD892007FB366D1F52F2247C046F5", "d3dcompiler_43.dll"}, {"D5D8C8561C6DDA7EF0D7D6ABB0D772F4", "xinput1_3_mta.dll"},
{"7096EB0458485D89BB749474550C7651", "d3dcompiler_47.dll"}, {"E2BAC93166B0C2AD4D83E97FC1E88F8F", "XInput9_1_0_mta.dll"}};
{"7096EB0458485D89BB749474550C7651", "d3dcompiler_47.dll"}, {"87F689D5636B6F31DBB4B9CBF56E17E3", "XInput9_1_0_mta.dll"}};

for (const auto& item : integrityCheckList)
{
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/StdInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
#include <CScriptFile.h>
#include <CWeaponNames.h>
#include <CVehicleNames.h>
#include <CModelRenderer.h>
#include <lua/CLuaCFunctions.h>
#include <lua/CLuaArguments.h>
#include <lua/CLuaMain.h>
Expand Down
12 changes: 12 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ CClientGame::CClientGame(bool bLocalPlay) : m_ServerInfo(new CServerInfo())
// Singular file download manager
m_pSingularFileDownloadManager = new CSingularFileDownloadManager();

// 3D model renderer
m_pModelRenderer = std::make_unique<CModelRenderer>();

// Register the message and the net packet handler
g_pMultiplayer->SetPreWeaponFireHandler(CClientGame::PreWeaponFire);
g_pMultiplayer->SetPostWeaponFireHandler(CClientGame::PostWeaponFire);
Expand All @@ -267,6 +270,7 @@ CClientGame::CClientGame(bool bLocalPlay) : m_ServerInfo(new CServerInfo())
g_pMultiplayer->SetRender3DStuffHandler(CClientGame::StaticRender3DStuffHandler);
g_pMultiplayer->SetPreRenderSkyHandler(CClientGame::StaticPreRenderSkyHandler);
g_pMultiplayer->SetRenderHeliLightHandler(CClientGame::StaticRenderHeliLightHandler);
g_pMultiplayer->SetRenderEverythingBarRoadsHandler(CClientGame::StaticRenderEverythingBarRoadsHandler);
g_pMultiplayer->SetChokingHandler(CClientGame::StaticChokingHandler);
g_pMultiplayer->SetPreWorldProcessHandler(CClientGame::StaticPreWorldProcessHandler);
g_pMultiplayer->SetPostWorldProcessHandler(CClientGame::StaticPostWorldProcessHandler);
Expand Down Expand Up @@ -470,6 +474,7 @@ CClientGame::~CClientGame()
g_pMultiplayer->SetRender3DStuffHandler(NULL);
g_pMultiplayer->SetPreRenderSkyHandler(NULL);
g_pMultiplayer->SetRenderHeliLightHandler(nullptr);
g_pMultiplayer->SetRenderEverythingBarRoadsHandler(nullptr);
g_pMultiplayer->SetChokingHandler(NULL);
g_pMultiplayer->SetPreWorldProcessHandler(NULL);
g_pMultiplayer->SetPostWorldProcessHandler(NULL);
Expand Down Expand Up @@ -3546,6 +3551,11 @@ void CClientGame::StaticRenderHeliLightHandler()
g_pClientGame->GetManager()->GetPointLightsManager()->RenderHeliLightHandler();
}

void CClientGame::StaticRenderEverythingBarRoadsHandler()
{
g_pClientGame->GetModelRenderer()->Render();
}

bool CClientGame::StaticChokingHandler(unsigned char ucWeaponType)
{
return g_pClientGame->ChokingHandler(ucWeaponType);
Expand Down Expand Up @@ -3853,6 +3863,8 @@ void CClientGame::PostWorldProcessPedsAfterPreRenderHandler()
{
CLuaArguments Arguments;
m_pRootEntity->CallEvent("onClientPedsProcessed", Arguments, false);

g_pClientGame->GetModelRenderer()->Update();
}

void CClientGame::IdleHandler()
Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ class CClientGame
CRemoteCalls* GetRemoteCalls() { return m_pRemoteCalls; }
CResourceFileDownloadManager* GetResourceFileDownloadManager() { return m_pResourceFileDownloadManager; }

CModelRenderer* GetModelRenderer() const noexcept { return m_pModelRenderer.get(); }

SharedUtil::CAsyncTaskScheduler* GetAsyncTaskScheduler() { return m_pAsyncTaskScheduler; }

// Status toggles
Expand Down Expand Up @@ -504,6 +506,7 @@ class CClientGame
static void StaticRender3DStuffHandler();
static void StaticPreRenderSkyHandler();
static void StaticRenderHeliLightHandler();
static void StaticRenderEverythingBarRoadsHandler();
static bool StaticChokingHandler(unsigned char ucWeaponType);
static void StaticPreWorldProcessHandler();
static void StaticPostWorldProcessHandler();
Expand Down Expand Up @@ -698,6 +701,8 @@ class CClientGame
CRemoteCalls* m_pRemoteCalls;
CResourceFileDownloadManager* m_pResourceFileDownloadManager;

std::unique_ptr<CModelRenderer> m_pModelRenderer;

// Revised facilities
CServer m_Server;

Expand Down
Loading

0 comments on commit 1baa606

Please sign in to comment.