Skip to content

Clean up game_sa project round 10 #2828

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 9 commits into from
Dec 26, 2022
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
38 changes: 19 additions & 19 deletions Client/game_sa/C3DMarkerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ void C3DMarkerSA::SetMatrix(CMatrix* pMatrix)

void C3DMarkerSA::SetPosition(CVector* vecPosition)
{
this->GetInterface()->m_mat.vPos = *vecPosition;
GetInterface()->m_mat.vPos = *vecPosition;
}

CVector* C3DMarkerSA::GetPosition()
{
return &this->GetInterface()->m_mat.vPos;
return &GetInterface()->m_mat.vPos;
}

DWORD C3DMarkerSA::GetType()
{
return this->GetInterface()->m_nType;
return GetInterface()->m_nType;
}

void C3DMarkerSA::SetType(DWORD dwType)
{
this->GetInterface()->m_nType = (unsigned short)(dwType);
GetInterface()->m_nType = (unsigned short)(dwType);
}

bool C3DMarkerSA::IsActive()
{
return this->GetInterface()->m_bIsUsed;
return GetInterface()->m_bIsUsed;
}

DWORD C3DMarkerSA::GetIdentifier()
{
return this->GetInterface()->m_nIdentifier;
return GetInterface()->m_nIdentifier;
}

SharedUtil::SColor C3DMarkerSA::GetColor()
{
// From ABGR
unsigned long ulABGR = this->GetInterface()->rwColour;
unsigned long ulABGR = GetInterface()->rwColour;
SharedUtil::SColor color;
color.A = (ulABGR >> 24) & 0xff;
color.B = (ulABGR >> 16) & 0xff;
Expand All @@ -75,60 +75,60 @@ SharedUtil::SColor C3DMarkerSA::GetColor()
void C3DMarkerSA::SetColor(const SharedUtil::SColor color)
{
// To ABGR
this->GetInterface()->rwColour = (color.A << 24) | (color.B << 16) | (color.G << 8) | color.R;
GetInterface()->rwColour = (color.A << 24) | (color.B << 16) | (color.G << 8) | color.R;
}

void C3DMarkerSA::SetPulsePeriod(WORD wPulsePeriod)
{
this->GetInterface()->m_nPulsePeriod = wPulsePeriod;
GetInterface()->m_nPulsePeriod = wPulsePeriod;
}

void C3DMarkerSA::SetRotateRate(short RotateRate)
{
this->GetInterface()->m_nRotateRate = RotateRate;
GetInterface()->m_nRotateRate = RotateRate;
}

float C3DMarkerSA::GetSize()
{
return this->GetInterface()->m_fSize;
return GetInterface()->m_fSize;
}

void C3DMarkerSA::SetSize(float fSize)
{
this->GetInterface()->m_fSize = fSize;
GetInterface()->m_fSize = fSize;
}

float C3DMarkerSA::GetBrightness()
{
return this->GetInterface()->m_fBrightness;
return GetInterface()->m_fBrightness;
}

void C3DMarkerSA::SetBrightness(float fBrightness)
{
this->GetInterface()->m_fBrightness = fBrightness;
GetInterface()->m_fBrightness = fBrightness;
}

void C3DMarkerSA::SetCameraRange(float fCameraRange)
{
this->GetInterface()->m_fCameraRange = fCameraRange;
GetInterface()->m_fCameraRange = fCameraRange;
}

void C3DMarkerSA::SetPulseFraction(float fPulseFraction)
{
this->GetInterface()->m_fPulseFraction = fPulseFraction;
GetInterface()->m_fPulseFraction = fPulseFraction;
}

float C3DMarkerSA::GetPulseFraction()
{
return this->GetInterface()->m_fPulseFraction;
return GetInterface()->m_fPulseFraction;
}

void C3DMarkerSA::Disable()
{
this->GetInterface()->m_nIdentifier = 0;
GetInterface()->m_nIdentifier = 0;
}

void C3DMarkerSA::Reset()
{
this->internalInterface->m_lastPosition = this->internalInterface->m_mat.vPos;
internalInterface->m_lastPosition = internalInterface->m_mat.vPos;
}
4 changes: 2 additions & 2 deletions Client/game_sa/C3DMarkerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ class C3DMarkerSA : public C3DMarker
float GetPulseFraction();
void Disable();
void Reset();
void SetActive() { this->internalInterface->m_bIsUsed = true; };
RpClump* GetRwObject() { return this->internalInterface->m_pRwObject; }
void SetActive() { internalInterface->m_bIsUsed = true; }
RpClump* GetRwObject() { return internalInterface->m_pRwObject; }
};
2 changes: 1 addition & 1 deletion Client/game_sa/C3DMarkersSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ C3DMarkersSA::C3DMarkersSA()
{
for (int i = 0; i < MAX_3D_MARKERS; i++)
{
this->Markers[i] = new C3DMarkerSA((C3DMarkerSAInterface*)(ARRAY_3D_MARKERS + i * sizeof(C3DMarkerSAInterface)));
Markers[i] = new C3DMarkerSA((C3DMarkerSAInterface*)(ARRAY_3D_MARKERS + i * sizeof(C3DMarkerSAInterface)));
}
}

Expand Down
98 changes: 3 additions & 95 deletions Client/game_sa/CAutomobileSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,100 +12,8 @@
#include "StdInc.h"
#include "CAutomobileSA.h"

/**
* \todo Spawn automobiles with engine off
*/
CAutomobileSA::CAutomobileSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
CAutomobileSA::CAutomobileSA(CAutomobileSAInterface* pInterface)
{
// create our mirror classes
for (int i = 0; i < MAX_DOORS; i++)
this->door[i] = new CDoorSA(&((CAutomobileSAInterface*)this->GetInterface())->m_doors[i]);

}

CAutomobileSA::CAutomobileSA(CAutomobileSAInterface* automobile)
{
// just so it can be passed on to CVehicle
}

CAutomobileSA::~CAutomobileSA()
{
for (int i = 0; i < MAX_DOORS; i++)
{
if (this->door[i])
delete this->door[i];
}
}

bool CAutomobileSA::BurstTyre(DWORD dwTyreID)
{
DWORD dwThis = (DWORD)GetInterface();
DWORD dwFunc = FUNC_CAutomobile_BurstTyre;
bool bReturn;

_asm
{
mov ecx, dwThis
push dwTyreID
call dwFunc;
mov bReturn, al
}

return bReturn;
}

bool CAutomobileSA::BreakTowLink()
{
DWORD dwThis = (DWORD)GetInterface();
DWORD dwFunc = FUNC_CAutomobile_BreakTowLink;
bool bReturn;

_asm
{
mov ecx, dwThis
call dwFunc
mov bReturn, al
}

return bReturn;
}

bool CAutomobileSA::IsComponentPresent(int iComponentID)
{
DWORD dwThis = (DWORD)GetInterface();
DWORD dwFunc = FUNC_CAutomobile_IsComponentPresent;
bool bReturn;

_asm
{
mov ecx, dwThis
push iComponentID
call dwFunc
mov bReturn, al
}

return bReturn;
}

CPhysical* CAutomobileSA::SpawnFlyingComponent(int iCarNodeIndex, int iUnknown)
{
DWORD dwThis = (DWORD)GetInterface();
DWORD dwFunc = FUNC_CAutomobile_SpawnFlyingComponent;
CPhysical* pReturn;

_asm
{
mov ecx, dwThis
push iUnknown
push iCarNodeIndex
call dwFunc
mov pReturn, eax
}

return pReturn;
}

CDoor* CAutomobileSA::GetDoor(eDoors doorID)
{
return this->door[doorID];
SetInterface(pInterface);
Init();
}
20 changes: 3 additions & 17 deletions Client/game_sa/CAutomobileSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
#include "CDoorSA.h"
#include "CVehicleSA.h"

#define FUNC_CAutomobile_BurstTyre 0x6A32B0
#define FUNC_CAutomobile_BreakTowLink 0x6A4400
#define FUNC_CAutomobile_IsComponentPresent 0x6A2250
#define FUNC_CAutomobile_SetTaxiLight 0x6A3740
#define FUNC_CAutomobile_SpawnFlyingComponent 0x6A8580

#define MAX_PASSENGER_COUNT 8
#define MAX_DOORS 6 // also in CDamageManager
Expand Down Expand Up @@ -163,19 +159,9 @@ static_assert(sizeof(CAutomobileSAInterface) == 0x988, "Invalid size for CAutomo

class CAutomobileSA : public virtual CAutomobile, public virtual CVehicleSA
{
private:
CDoorSA* door[MAX_DOORS];

public:
CAutomobileSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
CAutomobileSA(CAutomobileSAInterface* automobile);
~CAutomobileSA();

bool BurstTyre(DWORD dwTyreID);
bool BreakTowLink();

bool IsComponentPresent(int iComponentID);
CPhysical* SpawnFlyingComponent(int iCarNodeIndex, int iUnknown);
CAutomobileSA() = default;
CAutomobileSA(CAutomobileSAInterface* pInterface);

CDoor* GetDoor(eDoors doorID);
CAutomobileSAInterface* GetAutomobileInterface() { return reinterpret_cast<CAutomobileSAInterface*>(GetInterface()); }
};
26 changes: 3 additions & 23 deletions Client/game_sa/CBikeSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,10 @@
#include "StdInc.h"
#include "CBikeSA.h"

CBikeSA::CBikeSA(CBikeSAInterface* bike)
CBikeSA::CBikeSA(CBikeSAInterface* pInterface)
{
this->m_pInterface = bike;
}

CBikeSA::CBikeSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
{
/*if(this->internalInterface)
{
// create the actual vehicle
DWORD dwFunc = FUNC_CBikeContructor;
DWORD dwThis = (DWORD)this->internalInterface;
_asm
{
mov ecx, dwThis
push MISSION_VEHICLE
push dwModelID
call dwFunc
}

this->SetEntityStatus(STATUS_ABANDONED); // so it actually shows up in the world

pGame->GetWorld()->Add((CEntitySA *)this);
}*/
SetInterface(pInterface);
Init();
}

CBikeHandlingEntry* CBikeSA::GetBikeHandlingData()
Expand Down
7 changes: 3 additions & 4 deletions Client/game_sa/CBikeSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ class CBikeSA : public virtual CBike, public virtual CVehicleSA
CBikeHandlingEntrySA* m_pBikeHandlingData = nullptr;

public:
CBikeSA(){};
CBikeSA(CBikeSAInterface* bike);
CBikeSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
CBikeSA() = default;
CBikeSA(CBikeSAInterface* pInterface);

CBikeSAInterface* GetBikeInterface() { return (CBikeSAInterface*)m_pInterface; };
CBikeSAInterface* GetBikeInterface() { return reinterpret_cast<CBikeSAInterface*>(GetInterface()); }

CBikeHandlingEntry* GetBikeHandlingData();
void SetBikeHandlingData(CBikeHandlingEntry* pHandling);
Expand Down
9 changes: 3 additions & 6 deletions Client/game_sa/CBmxSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
#include "StdInc.h"
#include "CBmxSA.h"

CBmxSA::CBmxSA(CBmxSAInterface* bmx)
{
this->m_pInterface = bmx;
}

CBmxSA::CBmxSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CBikeSA(dwModelID, ucVariation, ucVariation2)
CBmxSA::CBmxSA(CBmxSAInterface* pInterface)
{
SetInterface(pInterface);
Init();
}
7 changes: 3 additions & 4 deletions Client/game_sa/CBmxSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ class CBmxSAInterface : public CBikeSAInterface
// fill this
};

class CBmxSA : public virtual CBmx, public virtual CBikeSA
class CBmxSA final : public virtual CBmx, public virtual CBikeSA
{
public:
CBmxSA(CBmxSAInterface* bmx);
CBmxSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
CBmxSA(CBmxSAInterface* pInterface);

virtual ~CBmxSA(){};
CBmxSAInterface* GetBmxInterface() { return reinterpret_cast<CBmxSAInterface*>(GetInterface()); }
};
26 changes: 3 additions & 23 deletions Client/game_sa/CBoatSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,10 @@
#include "StdInc.h"
#include "CBoatSA.h"

CBoatSA::CBoatSA(CBoatSAInterface* boat)
CBoatSA::CBoatSA(CBoatSAInterface* pInterface)
{
this->m_pInterface = boat;
}

CBoatSA::CBoatSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
{
/*if(this->internalInterface)
{
// create the actual vehicle
DWORD dwFunc = FUNC_CBoatContructor;
DWORD dwThis = (DWORD)this->internalInterface;
_asm
{
mov ecx, dwThis
push MISSION_VEHICLE
push dwModelID
call dwFunc
}

this->SetEntityStatus(STATUS_ABANDONED); // so it actually shows up in the world

pGame->GetWorld()->Add((CEntitySA *)this);
} */
SetInterface(pInterface);
Init();
}

CBoatHandlingEntry* CBoatSA::GetBoatHandlingData()
Expand Down
Loading