Skip to content

Clean up game_sa project round 11 #3259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions Client/game_sa/CCameraSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

extern CGameSA* pGame;

unsigned long CCameraSA::FUNC_RwFrameGetLTM;
static bool bCameraClipObjects;
static bool bCameraClipVehicles;

Expand Down Expand Up @@ -358,16 +357,8 @@ float CCameraSA::GetCameraRotation()

RwMatrix* CCameraSA::GetLTM()
{
DWORD frame = *(DWORD*)(((DWORD)GetInterface()->m_pRwCamera) + 4);
DWORD dwReturn;
_asm
{
push frame
call FUNC_RwFrameGetLTM
add esp, 4
mov dwReturn, eax
}
return (RwMatrix*)dwReturn;
// RwFrameGetLTM
return ((RwMatrix*(_cdecl*)(void*))0x7F0990)(GetInterface()->m_pRwCamera->object.object.parent);
}

CEntity* CCameraSA::GetTargetEntity()
Expand Down
5 changes: 1 addition & 4 deletions Client/game_sa/CCameraSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class CCameraSAInterface
float m_fAttachedCamAngle; // for giving the attached camera a tilt.

// RenderWare camera pointer
DWORD* m_pRwCamera; // was RwCamera *
RwCamera* m_pRwCamera;
/// stuff for cut scenes
CEntitySAInterface* pTargetEntity;
CEntitySAInterface* pAttachedEntity;
Expand Down Expand Up @@ -426,7 +426,4 @@ class CCameraSA : public CCamera
void RestoreLastGoodState();
void SetShakeForce(float fShakeForce);
float GetShakeForce();

private:
static unsigned long FUNC_RwFrameGetLTM;
};
28 changes: 4 additions & 24 deletions Client/game_sa/CEntitySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

extern CGameSA* pGame;

unsigned long CEntitySA::FUNC_CClumpModelInfo__GetFrameFromId;
unsigned long CEntitySA::FUNC_RwFrameGetLTM;

void CEntitySAInterface::TransformFromObjectSpace(CVector& outPosn, CVector const& offset)
{
((void(__thiscall*)(CEntitySAInterface*, CVector&, CVector const&))0x533560)(this, outPosn, offset);
Expand Down Expand Up @@ -439,17 +436,8 @@ eEntityStatus CEntitySA::GetEntityStatus()

RwFrame* CEntitySA::GetFrameFromId(int id)
{
DWORD dwClump = (DWORD)m_pInterface->m_pRwObject;
DWORD dwReturn;
_asm
{
push id
push dwClump
call FUNC_CClumpModelInfo__GetFrameFromId
add esp, 8
mov dwReturn, eax
}
return (RwFrame*)dwReturn;
// CClumpModelInfo::GetFrameFromId
return ((RwFrame*(_cdecl*)(RpClump*, int))0x4C53C0)(m_pInterface->m_pRwObject, id);
}

RpClump* CEntitySA::GetRpClump()
Expand All @@ -459,16 +447,8 @@ RpClump* CEntitySA::GetRpClump()

RwMatrix* CEntitySA::GetLTMFromId(int id)
{
DWORD dwReturn;
RwFrame* frame = GetFrameFromId(id);
_asm
{
push frame
call FUNC_RwFrameGetLTM
add esp, 4
mov dwReturn, eax
}
return (RwMatrix*)dwReturn;
// RwFrameGetLTM
return ((RwMatrix*(_cdecl*)(RwFrame*))0x7F0990)(GetFrameFromId(id));
}

void CEntitySA::SetAlpha(DWORD dwAlpha)
Expand Down
3 changes: 0 additions & 3 deletions Client/game_sa/CEntitySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ class CEntitySA : public virtual CEntity
virtual void OnChangingPosition(const CVector& vecNewPosition) {}

private:
static unsigned long FUNC_CClumpModelInfo__GetFrameFromId;
static unsigned long FUNC_RwFrameGetLTM;

void* m_pStoredPointer;
CVector m_LastGoodPosition;
};
Expand Down
41 changes: 8 additions & 33 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "CHudSA.h"
#include "CKeyGenSA.h"
#include "CObjectGroupPhysicalPropertiesSA.h"
#include "COffsets.h"
#include "CPadSA.h"
#include "CPickupsSA.h"
#include "CPlayerInfoSA.h"
Expand All @@ -61,15 +60,6 @@
extern CGameSA* pGame;

unsigned int& CGameSA::ClumpOffset = *(unsigned int*)0xB5F878;
unsigned long* CGameSA::VAR_SystemTime;
unsigned long* CGameSA::VAR_IsAtMenu;
bool* CGameSA::VAR_IsForegroundWindow;
unsigned long* CGameSA::VAR_SystemState;
float* CGameSA::VAR_TimeScale;
float* CGameSA::VAR_FPS;
float* CGameSA::VAR_OldTimeStep;
float* CGameSA::VAR_TimeStep;
unsigned long* CGameSA::VAR_Framelimiter;

unsigned int OBJECTDYNAMICINFO_MAX = *(uint32_t*)0x59FB4C != 0x90909090 ? *(uint32_t*)0x59FB4C : 160; // default: 160

Expand All @@ -90,21 +80,6 @@ CGameSA::CGameSA()

SetInitialVirtualProtect();

// Initialize the offsets
eGameVersion version = FindGameVersion();
switch (version)
{
case VERSION_EU_10:
COffsets::Initialize10EU();
break;
case VERSION_US_10:
COffsets::Initialize10US();
break;
case VERSION_11:
COffsets::Initialize11();
break;
}

// Set the model ids for all the CModelInfoSA instances
for (unsigned int i = 0; i < modelInfoMax; i++)
{
Expand Down Expand Up @@ -142,7 +117,7 @@ CGameSA::CGameSA()
m_pCarEnterExit = new CCarEnterExitSA();
m_pControllerConfigManager = new CControllerConfigManagerSA();
m_pProjectileInfo = new CProjectileInfoSA();
m_pRenderWare = new CRenderWareSA(version);
m_pRenderWare = new CRenderWareSA();
m_pHandlingManager = new CHandlingManagerSA();
m_pEventList = new CEventListSA();
m_pGarages = new CGaragesSA((CGaragesSAInterface*)CLASS_CGarages);
Expand Down Expand Up @@ -363,12 +338,12 @@ void CGameSA::StartGame()
*/
void CGameSA::SetSystemState(eSystemState State)
{
*VAR_SystemState = (DWORD)State;
MemPutFast<DWORD>(0xC8D4C0, State); // gGameState
}

eSystemState CGameSA::GetSystemState()
{
return (eSystemState)*VAR_SystemState;
return *(eSystemState*)0xC8D4C0; // gGameState
}

/**
Expand Down Expand Up @@ -503,27 +478,27 @@ eGameVersion CGameSA::FindGameVersion()

float CGameSA::GetFPS()
{
return *VAR_FPS;
return *(float*)0xB7CB50; // CTimer::game_FPS
}

float CGameSA::GetTimeStep()
{
return *VAR_TimeStep;
return *(float*)0xB7CB5C; // CTimer::ms_fTimeStep
}

float CGameSA::GetOldTimeStep()
{
return *VAR_OldTimeStep;
return *(float*)0xB7CB54; // CTimer::ms_fOldTimeStep
}

float CGameSA::GetTimeScale()
{
return *VAR_TimeScale;
return *(float*)0xB7CB64; // CTimer::ms_fTimeScale
}

void CGameSA::SetTimeScale(float fTimeScale)
{
*VAR_TimeScale = fTimeScale;
MemPutFast<float>(0xB7CB64, fTimeScale); // CTimer::ms_fTimeScale
}

unsigned char CGameSA::GetBlurLevel()
Expand Down
13 changes: 2 additions & 11 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ class CGameSA : public CGame
int32_t GetBaseIDforSCM() { return *(int32_t*)(0x46A574 + 2); }
int32_t GetCountOfAllFileIDs() { return (*(char**)(0x5B8AFA + 2) - *(char**)(0x5B8B08 + 6)) / sizeof(CStreamingInfo); }

DWORD GetSystemTime() { return *VAR_SystemTime; }
DWORD GetSystemTime() { return *(DWORD*)0xB7CB84; } // CTimer::m_snTimeInMilliseconds

bool IsAtMenu() { return *VAR_IsAtMenu != 0; }
bool IsAtMenu() { return *(unsigned long*)0xBA677B != 0; } // FrontEndMenuManager + 0x33

void StartGame();
void SetSystemState(eSystemState State);
Expand Down Expand Up @@ -333,15 +333,6 @@ class CGameSA : public CGame
bool m_isFireballDestructEnabled{true};

static unsigned int& ClumpOffset;
static unsigned long* VAR_SystemTime;
static unsigned long* VAR_IsAtMenu;
static bool* VAR_IsForegroundWindow;
static unsigned long* VAR_SystemState;
static float* VAR_TimeScale;
static float* VAR_FPS;
static float* VAR_OldTimeStep;
static float* VAR_TimeStep;
static unsigned long* VAR_Framelimiter;

std::map<std::string, SCheatSA*> m_Cheats;

Expand Down
90 changes: 0 additions & 90 deletions Client/game_sa/COffsets.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions Client/game_sa/COffsets.h

This file was deleted.

Loading