Skip to content

Commit 7079e19

Browse files
committed
Review
1 parent 620f476 commit 7079e19

File tree

6 files changed

+50
-47
lines changed

6 files changed

+50
-47
lines changed

Client/game_sa/C3DMarkerSA.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,28 @@
1111

1212
#include "StdInc.h"
1313
#include "C3DMarkerSA.h"
14+
#include "CMatrix.h"
1415

1516
void C3DMarkerSA::GetMatrix(CMatrix* pMatrix)
1617
{
17-
CMatrix_Padded* mat = &GetInterface()->m_mat;
18-
MemCpyFast(&pMatrix->vPos, &mat->vPos, sizeof(CVector));
19-
MemCpyFast(&pMatrix->vFront, &mat->vFront, sizeof(CVector));
20-
MemCpyFast(&pMatrix->vRight, &mat->vRight, sizeof(CVector));
21-
MemCpyFast(&pMatrix->vUp, &mat->vUp, sizeof(CVector));
18+
CMatrixSAInterface* mat = &GetInterface()->m_mat;
19+
MemCpyFast(pMatrix, &mat->GetMatrix(), sizeof(CMatrix));
2220
}
2321

2422
void C3DMarkerSA::SetMatrix(CMatrix* pMatrix)
2523
{
26-
CMatrix_Padded* mat = &GetInterface()->m_mat;
27-
MemCpyFast(&mat->vPos, &pMatrix->vPos, sizeof(CVector));
28-
MemCpyFast(&mat->vFront, &pMatrix->vFront, sizeof(CVector));
29-
MemCpyFast(&mat->vRight, &pMatrix->vRight, sizeof(CVector));
30-
MemCpyFast(&mat->vUp, &pMatrix->vUp, sizeof(CVector));
24+
CMatrixSAInterface* mat = &GetInterface()->m_mat;
25+
mat->SetMatrix(pMatrix->vRight, pMatrix->vFront, pMatrix->vUp, pMatrix->vPos);
3126
}
3227

3328
void C3DMarkerSA::SetPosition(CVector* vecPosition)
3429
{
35-
GetInterface()->m_mat.vPos = *vecPosition;
30+
GetInterface()->m_mat.SetTranslateOnly(*vecPosition);
3631
}
3732

3833
CVector* C3DMarkerSA::GetPosition()
3934
{
40-
return &GetInterface()->m_mat.vPos;
35+
return &GetInterface()->m_mat.GetPosition();
4136
}
4237

4338
e3DMarkerType C3DMarkerSA::GetType() const
@@ -117,5 +112,5 @@ void C3DMarkerSA::Disable()
117112

118113
void C3DMarkerSA::Reset()
119114
{
120-
internalInterface->m_lastPosition = internalInterface->m_mat.vPos;
115+
internalInterface->m_lastPosition = internalInterface->m_mat.GetPosition();
121116
}

Client/game_sa/CMatrixSA.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#pragma once
1212
#include "CVector.h"
1313
#include "CRenderWareSA.h"
14+
#include "CMatrix.h"
1415

1516
class CMatrixSAInterface
1617
{
@@ -45,4 +46,17 @@ class CMatrixSAInterface
4546
m_up = up;
4647
m_pos = pos;
4748
}
49+
50+
CMatrix GetMatrix() const
51+
{
52+
CMatrix matrix;
53+
matrix.vRight = m_right;
54+
matrix.vFront = m_forward;
55+
matrix.vUp = m_up;
56+
matrix.vPos = m_pos;
57+
58+
return matrix;
59+
}
60+
61+
CVector GetPosition() const noexcept { return m_pos; }
4862
};

Client/game_sa/interfaces/C3DMarkerSAInterface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,31 @@
1313

1414
bool C3DMarkerSAInterface::AddMarker(std::uint32_t id, e3DMarkerType type, float size, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint16_t pulsePeriod, float pulseFraction, std::int16_t rotateRate)
1515
{
16-
// Call C3dMarker::AddMarker
1716
return ((bool(__thiscall*)(C3DMarkerSAInterface*, std::uint32_t, std::uint16_t, float, std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t, std::uint16_t, float, std::int16_t))0x722230)(this, id, static_cast<std::uint16_t>(type), size, r, g, b, a, pulsePeriod, pulseFraction, rotateRate);
1817
}
1918

2019
void C3DMarkerSAInterface::DeleteMarkerObject()
2120
{
22-
// Call C3dMarker::DeleteMarkerObject
2321
((void(__thiscall*)(C3DMarkerSAInterface*))0x722390)(this);
2422
}
2523

2624
bool C3DMarkerSAInterface::IsZCoordinateUpToDate() const
2725
{
28-
const CVector& pos = m_mat.vPos;
26+
const CVector& pos = m_mat.GetPosition();
2927
return m_LastMapReadX == static_cast<std::uint16_t>(pos.fX) && m_LastMapReadY == static_cast<std::uint16_t>(pos.fY);
3028
}
3129

3230
void C3DMarkerSAInterface::SetZCoordinateIfNotUpToDate(float newZPos)
3331
{
3432
if (!IsZCoordinateUpToDate())
35-
m_mat.vPos.fZ = newZPos;
33+
{
34+
CVector& pos = m_mat.GetPosition();
35+
pos.fZ = newZPos;
36+
}
3637
}
3738

3839
void C3DMarkerSAInterface::UpdateZCoordinate(CVector point, float zDistance)
3940
{
40-
// Call C3dMarker::UpdateZCoordinate
4141
((void(__thiscall*)(C3DMarkerSAInterface*, CVector, float))0x724D40)(this, point, zDistance);
4242
}
4343

Client/game_sa/interfaces/C3DMarkerSAInterface.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#pragma once
1313

1414
#include <game/C3DMarker.h>
15-
#include <CMatrix_Pad.h>
1615
#include "game/RenderWare.h"
16+
#include "../CMatrixSA.h"
1717

1818
class C3DMarkerSAInterface
1919
{
2020
public:
21-
CMatrix_Padded m_mat; // local space to world space transform
21+
CMatrixSAInterface m_mat; // local space to world space transform
2222
RpAtomic* m_pRwObject;
2323
RpMaterial* m_pMaterial;
2424
std::uint16_t m_nType; // e3DMarkerType
@@ -46,12 +46,12 @@ class C3DMarkerSAInterface
4646
std::uint32_t m_OnScreenTestTime; // time last screen check was done
4747

4848
public:
49-
bool AddMarker(std::uint32_t id, e3DMarkerType type, float size, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint16_t pulsePeriod,
49+
inline bool AddMarker(std::uint32_t id, e3DMarkerType type, float size, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint16_t pulsePeriod,
5050
float pulseFraction, std::int16_t rotateRate);
51-
void DeleteMarkerObject();
52-
bool IsZCoordinateUpToDate() const;
53-
void SetZCoordinateIfNotUpToDate(float newZPos);
54-
void UpdateZCoordinate(CVector point, float zDistance);
55-
void DeleteIfHasAtomic();
51+
inline void DeleteMarkerObject();
52+
inline bool IsZCoordinateUpToDate() const;
53+
inline void SetZCoordinateIfNotUpToDate(float newZPos);
54+
inline void UpdateZCoordinate(CVector point, float zDistance);
55+
inline void DeleteIfHasAtomic();
5656
};
5757
static_assert(sizeof(C3DMarkerSAInterface) == 0xA0, "Invalid size for C3DMarkerSAInterface");

Client/game_sa/premake5.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ project "Game SA"
2424

2525
includedirs {
2626
"../../Shared/sdk",
27-
".",
2827
"../sdk/",
29-
"./interfaces",
30-
"../../vendor/sparsehash/src/",
28+
"../../vendor/sparsehash/src/"
3129
}
3230

3331
files {

Shared/sdk/CMatrix_Pad.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto
3+
* PROJECT: Multi Theft Auto v1.0
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: sdk/CMatrix_Pad.h
66
* PURPOSE: 4x3 GTA padded matrix
77
*
8-
* Multi Theft Auto is available from https://www.multitheftauto.com/
8+
* Multi Theft Auto is available from http://www.multitheftauto.com/
99
*
1010
*****************************************************************************/
1111

@@ -20,19 +20,15 @@
2020
class CMatrix_Padded
2121
{
2222
public:
23-
CVector vRight; // right
24-
std::uint32_t pad_0; // flags?
25-
CVector vFront; // forward
26-
std::uint32_t pad_1;
27-
CVector vUp; // up
28-
std::uint32_t pad_2;
29-
CVector vPos; // translate
30-
std::uint32_t pad_3;
23+
CVector vRight; // 0 RIGHT
24+
DWORD dwPadRoll; // 12
25+
CVector vFront; // 16 FOREWARDS
26+
DWORD dwPadDirection; // 28
27+
CVector vUp; // 32 UP
28+
DWORD dwPadWas; // 44
29+
CVector vPos; // 48 TRANSLATE
30+
DWORD dwPadPos; // 60
3131

32-
void* attachedMatrix; // RwMatrix*
33-
bool ownsAttachedMatrix;
34-
35-
public:
3632
CMatrix_Padded() { memset(this, 0, sizeof(CMatrix_Padded)); }
3733

3834
CMatrix_Padded(const CMatrix& Matrix) { SetFromMatrix(Matrix); }
@@ -48,16 +44,16 @@ class CMatrix_Padded
4844
void SetFromMatrix(const CMatrix& Matrix)
4945
{
5046
vPos = Matrix.vPos;
51-
pad_3 = 0;
47+
dwPadPos = 0;
5248

5349
vFront = Matrix.vFront;
54-
pad_1 = 0;
50+
dwPadDirection = 0;
5551

5652
vUp = Matrix.vUp;
57-
pad_2 = 0;
53+
dwPadWas = 0;
5854

5955
vRight = Matrix.vRight;
60-
pad_0 = 0;
56+
dwPadRoll = 0;
6157
}
6258

6359
void SetFromMatrixSkipPadding(const CMatrix& Matrix)

0 commit comments

Comments
 (0)