Skip to content

Commit 4dff64f

Browse files
authored
Clean up game_sa project (Round 10, PR #2828)
1 parent 8bb9187 commit 4dff64f

Some content is hidden

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

90 files changed

+966
-1270
lines changed

Client/game_sa/C3DMarkerSA.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,38 @@ void C3DMarkerSA::SetMatrix(CMatrix* pMatrix)
3232

3333
void C3DMarkerSA::SetPosition(CVector* vecPosition)
3434
{
35-
this->GetInterface()->m_mat.vPos = *vecPosition;
35+
GetInterface()->m_mat.vPos = *vecPosition;
3636
}
3737

3838
CVector* C3DMarkerSA::GetPosition()
3939
{
40-
return &this->GetInterface()->m_mat.vPos;
40+
return &GetInterface()->m_mat.vPos;
4141
}
4242

4343
DWORD C3DMarkerSA::GetType()
4444
{
45-
return this->GetInterface()->m_nType;
45+
return GetInterface()->m_nType;
4646
}
4747

4848
void C3DMarkerSA::SetType(DWORD dwType)
4949
{
50-
this->GetInterface()->m_nType = (unsigned short)(dwType);
50+
GetInterface()->m_nType = (unsigned short)(dwType);
5151
}
5252

5353
bool C3DMarkerSA::IsActive()
5454
{
55-
return this->GetInterface()->m_bIsUsed;
55+
return GetInterface()->m_bIsUsed;
5656
}
5757

5858
DWORD C3DMarkerSA::GetIdentifier()
5959
{
60-
return this->GetInterface()->m_nIdentifier;
60+
return GetInterface()->m_nIdentifier;
6161
}
6262

6363
SharedUtil::SColor C3DMarkerSA::GetColor()
6464
{
6565
// From ABGR
66-
unsigned long ulABGR = this->GetInterface()->rwColour;
66+
unsigned long ulABGR = GetInterface()->rwColour;
6767
SharedUtil::SColor color;
6868
color.A = (ulABGR >> 24) & 0xff;
6969
color.B = (ulABGR >> 16) & 0xff;
@@ -75,60 +75,60 @@ SharedUtil::SColor C3DMarkerSA::GetColor()
7575
void C3DMarkerSA::SetColor(const SharedUtil::SColor color)
7676
{
7777
// To ABGR
78-
this->GetInterface()->rwColour = (color.A << 24) | (color.B << 16) | (color.G << 8) | color.R;
78+
GetInterface()->rwColour = (color.A << 24) | (color.B << 16) | (color.G << 8) | color.R;
7979
}
8080

8181
void C3DMarkerSA::SetPulsePeriod(WORD wPulsePeriod)
8282
{
83-
this->GetInterface()->m_nPulsePeriod = wPulsePeriod;
83+
GetInterface()->m_nPulsePeriod = wPulsePeriod;
8484
}
8585

8686
void C3DMarkerSA::SetRotateRate(short RotateRate)
8787
{
88-
this->GetInterface()->m_nRotateRate = RotateRate;
88+
GetInterface()->m_nRotateRate = RotateRate;
8989
}
9090

9191
float C3DMarkerSA::GetSize()
9292
{
93-
return this->GetInterface()->m_fSize;
93+
return GetInterface()->m_fSize;
9494
}
9595

9696
void C3DMarkerSA::SetSize(float fSize)
9797
{
98-
this->GetInterface()->m_fSize = fSize;
98+
GetInterface()->m_fSize = fSize;
9999
}
100100

101101
float C3DMarkerSA::GetBrightness()
102102
{
103-
return this->GetInterface()->m_fBrightness;
103+
return GetInterface()->m_fBrightness;
104104
}
105105

106106
void C3DMarkerSA::SetBrightness(float fBrightness)
107107
{
108-
this->GetInterface()->m_fBrightness = fBrightness;
108+
GetInterface()->m_fBrightness = fBrightness;
109109
}
110110

111111
void C3DMarkerSA::SetCameraRange(float fCameraRange)
112112
{
113-
this->GetInterface()->m_fCameraRange = fCameraRange;
113+
GetInterface()->m_fCameraRange = fCameraRange;
114114
}
115115

116116
void C3DMarkerSA::SetPulseFraction(float fPulseFraction)
117117
{
118-
this->GetInterface()->m_fPulseFraction = fPulseFraction;
118+
GetInterface()->m_fPulseFraction = fPulseFraction;
119119
}
120120

121121
float C3DMarkerSA::GetPulseFraction()
122122
{
123-
return this->GetInterface()->m_fPulseFraction;
123+
return GetInterface()->m_fPulseFraction;
124124
}
125125

126126
void C3DMarkerSA::Disable()
127127
{
128-
this->GetInterface()->m_nIdentifier = 0;
128+
GetInterface()->m_nIdentifier = 0;
129129
}
130130

131131
void C3DMarkerSA::Reset()
132132
{
133-
this->internalInterface->m_lastPosition = this->internalInterface->m_mat.vPos;
133+
internalInterface->m_lastPosition = internalInterface->m_mat.vPos;
134134
}

Client/game_sa/C3DMarkerSA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ class C3DMarkerSA : public C3DMarker
7777
float GetPulseFraction();
7878
void Disable();
7979
void Reset();
80-
void SetActive() { this->internalInterface->m_bIsUsed = true; };
81-
RpClump* GetRwObject() { return this->internalInterface->m_pRwObject; }
80+
void SetActive() { internalInterface->m_bIsUsed = true; }
81+
RpClump* GetRwObject() { return internalInterface->m_pRwObject; }
8282
};

Client/game_sa/C3DMarkersSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ C3DMarkersSA::C3DMarkersSA()
1616
{
1717
for (int i = 0; i < MAX_3D_MARKERS; i++)
1818
{
19-
this->Markers[i] = new C3DMarkerSA((C3DMarkerSAInterface*)(ARRAY_3D_MARKERS + i * sizeof(C3DMarkerSAInterface)));
19+
Markers[i] = new C3DMarkerSA((C3DMarkerSAInterface*)(ARRAY_3D_MARKERS + i * sizeof(C3DMarkerSAInterface)));
2020
}
2121
}
2222

Client/game_sa/CAutomobileSA.cpp

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -12,100 +12,8 @@
1212
#include "StdInc.h"
1313
#include "CAutomobileSA.h"
1414

15-
/**
16-
* \todo Spawn automobiles with engine off
17-
*/
18-
CAutomobileSA::CAutomobileSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
15+
CAutomobileSA::CAutomobileSA(CAutomobileSAInterface* pInterface)
1916
{
20-
// create our mirror classes
21-
for (int i = 0; i < MAX_DOORS; i++)
22-
this->door[i] = new CDoorSA(&((CAutomobileSAInterface*)this->GetInterface())->m_doors[i]);
23-
24-
}
25-
26-
CAutomobileSA::CAutomobileSA(CAutomobileSAInterface* automobile)
27-
{
28-
// just so it can be passed on to CVehicle
29-
}
30-
31-
CAutomobileSA::~CAutomobileSA()
32-
{
33-
for (int i = 0; i < MAX_DOORS; i++)
34-
{
35-
if (this->door[i])
36-
delete this->door[i];
37-
}
38-
}
39-
40-
bool CAutomobileSA::BurstTyre(DWORD dwTyreID)
41-
{
42-
DWORD dwThis = (DWORD)GetInterface();
43-
DWORD dwFunc = FUNC_CAutomobile_BurstTyre;
44-
bool bReturn;
45-
46-
_asm
47-
{
48-
mov ecx, dwThis
49-
push dwTyreID
50-
call dwFunc;
51-
mov bReturn, al
52-
}
53-
54-
return bReturn;
55-
}
56-
57-
bool CAutomobileSA::BreakTowLink()
58-
{
59-
DWORD dwThis = (DWORD)GetInterface();
60-
DWORD dwFunc = FUNC_CAutomobile_BreakTowLink;
61-
bool bReturn;
62-
63-
_asm
64-
{
65-
mov ecx, dwThis
66-
call dwFunc
67-
mov bReturn, al
68-
}
69-
70-
return bReturn;
71-
}
72-
73-
bool CAutomobileSA::IsComponentPresent(int iComponentID)
74-
{
75-
DWORD dwThis = (DWORD)GetInterface();
76-
DWORD dwFunc = FUNC_CAutomobile_IsComponentPresent;
77-
bool bReturn;
78-
79-
_asm
80-
{
81-
mov ecx, dwThis
82-
push iComponentID
83-
call dwFunc
84-
mov bReturn, al
85-
}
86-
87-
return bReturn;
88-
}
89-
90-
CPhysical* CAutomobileSA::SpawnFlyingComponent(int iCarNodeIndex, int iUnknown)
91-
{
92-
DWORD dwThis = (DWORD)GetInterface();
93-
DWORD dwFunc = FUNC_CAutomobile_SpawnFlyingComponent;
94-
CPhysical* pReturn;
95-
96-
_asm
97-
{
98-
mov ecx, dwThis
99-
push iUnknown
100-
push iCarNodeIndex
101-
call dwFunc
102-
mov pReturn, eax
103-
}
104-
105-
return pReturn;
106-
}
107-
108-
CDoor* CAutomobileSA::GetDoor(eDoors doorID)
109-
{
110-
return this->door[doorID];
17+
SetInterface(pInterface);
18+
Init();
11119
}

Client/game_sa/CAutomobileSA.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
#include "CDoorSA.h"
1717
#include "CVehicleSA.h"
1818

19-
#define FUNC_CAutomobile_BurstTyre 0x6A32B0
20-
#define FUNC_CAutomobile_BreakTowLink 0x6A4400
21-
#define FUNC_CAutomobile_IsComponentPresent 0x6A2250
2219
#define FUNC_CAutomobile_SetTaxiLight 0x6A3740
23-
#define FUNC_CAutomobile_SpawnFlyingComponent 0x6A8580
2420

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

164160
class CAutomobileSA : public virtual CAutomobile, public virtual CVehicleSA
165161
{
166-
private:
167-
CDoorSA* door[MAX_DOORS];
168-
169162
public:
170-
CAutomobileSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
171-
CAutomobileSA(CAutomobileSAInterface* automobile);
172-
~CAutomobileSA();
173-
174-
bool BurstTyre(DWORD dwTyreID);
175-
bool BreakTowLink();
176-
177-
bool IsComponentPresent(int iComponentID);
178-
CPhysical* SpawnFlyingComponent(int iCarNodeIndex, int iUnknown);
163+
CAutomobileSA() = default;
164+
CAutomobileSA(CAutomobileSAInterface* pInterface);
179165

180-
CDoor* GetDoor(eDoors doorID);
166+
CAutomobileSAInterface* GetAutomobileInterface() { return reinterpret_cast<CAutomobileSAInterface*>(GetInterface()); }
181167
};

Client/game_sa/CBikeSA.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,10 @@
1212
#include "StdInc.h"
1313
#include "CBikeSA.h"
1414

15-
CBikeSA::CBikeSA(CBikeSAInterface* bike)
15+
CBikeSA::CBikeSA(CBikeSAInterface* pInterface)
1616
{
17-
this->m_pInterface = bike;
18-
}
19-
20-
CBikeSA::CBikeSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
21-
{
22-
/*if(this->internalInterface)
23-
{
24-
// create the actual vehicle
25-
DWORD dwFunc = FUNC_CBikeContructor;
26-
DWORD dwThis = (DWORD)this->internalInterface;
27-
_asm
28-
{
29-
mov ecx, dwThis
30-
push MISSION_VEHICLE
31-
push dwModelID
32-
call dwFunc
33-
}
34-
35-
this->SetEntityStatus(STATUS_ABANDONED); // so it actually shows up in the world
36-
37-
pGame->GetWorld()->Add((CEntitySA *)this);
38-
}*/
17+
SetInterface(pInterface);
18+
Init();
3919
}
4020

4121
CBikeHandlingEntry* CBikeSA::GetBikeHandlingData()

Client/game_sa/CBikeSA.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ class CBikeSA : public virtual CBike, public virtual CVehicleSA
9090
CBikeHandlingEntrySA* m_pBikeHandlingData = nullptr;
9191

9292
public:
93-
CBikeSA(){};
94-
CBikeSA(CBikeSAInterface* bike);
95-
CBikeSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
93+
CBikeSA() = default;
94+
CBikeSA(CBikeSAInterface* pInterface);
9695

97-
CBikeSAInterface* GetBikeInterface() { return (CBikeSAInterface*)m_pInterface; };
96+
CBikeSAInterface* GetBikeInterface() { return reinterpret_cast<CBikeSAInterface*>(GetInterface()); }
9897

9998
CBikeHandlingEntry* GetBikeHandlingData();
10099
void SetBikeHandlingData(CBikeHandlingEntry* pHandling);

Client/game_sa/CBmxSA.cpp

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

15-
CBmxSA::CBmxSA(CBmxSAInterface* bmx)
16-
{
17-
this->m_pInterface = bmx;
18-
}
19-
20-
CBmxSA::CBmxSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CBikeSA(dwModelID, ucVariation, ucVariation2)
15+
CBmxSA::CBmxSA(CBmxSAInterface* pInterface)
2116
{
17+
SetInterface(pInterface);
18+
Init();
2219
}

Client/game_sa/CBmxSA.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ class CBmxSAInterface : public CBikeSAInterface
1919
// fill this
2020
};
2121

22-
class CBmxSA : public virtual CBmx, public virtual CBikeSA
22+
class CBmxSA final : public virtual CBmx, public virtual CBikeSA
2323
{
2424
public:
25-
CBmxSA(CBmxSAInterface* bmx);
26-
CBmxSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2);
25+
CBmxSA(CBmxSAInterface* pInterface);
2726

28-
virtual ~CBmxSA(){};
27+
CBmxSAInterface* GetBmxInterface() { return reinterpret_cast<CBmxSAInterface*>(GetInterface()); }
2928
};

Client/game_sa/CBoatSA.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,10 @@
1212
#include "StdInc.h"
1313
#include "CBoatSA.h"
1414

15-
CBoatSA::CBoatSA(CBoatSAInterface* boat)
15+
CBoatSA::CBoatSA(CBoatSAInterface* pInterface)
1616
{
17-
this->m_pInterface = boat;
18-
}
19-
20-
CBoatSA::CBoatSA(eVehicleTypes dwModelID, unsigned char ucVariation, unsigned char ucVariation2) : CVehicleSA(dwModelID, ucVariation, ucVariation2)
21-
{
22-
/*if(this->internalInterface)
23-
{
24-
// create the actual vehicle
25-
DWORD dwFunc = FUNC_CBoatContructor;
26-
DWORD dwThis = (DWORD)this->internalInterface;
27-
_asm
28-
{
29-
mov ecx, dwThis
30-
push MISSION_VEHICLE
31-
push dwModelID
32-
call dwFunc
33-
}
34-
35-
this->SetEntityStatus(STATUS_ABANDONED); // so it actually shows up in the world
36-
37-
pGame->GetWorld()->Add((CEntitySA *)this);
38-
} */
17+
SetInterface(pInterface);
18+
Init();
3919
}
4020

4121
CBoatHandlingEntry* CBoatSA::GetBoatHandlingData()

0 commit comments

Comments
 (0)