Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extract SA interfaces to separate files #1 (C3DMarkerSAInterface) #4063

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

Open
FileEX wants to merge 4 commits into multitheftauto:master
base: master
Choose a base branch
Loading
from FileEX:refactor/interfaces_cleanup_3dMarker
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Review
  • Loading branch information
FileEX committed Mar 12, 2025
commit 7079e1942f2e5dbddde6e061771c232cd61f1500

Some comments aren't visible on the classic Files Changed page.

21 changes: 8 additions & 13 deletions Client/game_sa/C3DMarkerSA.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,28 @@

#include "StdInc.h"
#include "C3DMarkerSA.h"
#include "CMatrix.h"

void C3DMarkerSA::GetMatrix(CMatrix* pMatrix)
{
CMatrix_Padded* mat = &GetInterface()->m_mat;
MemCpyFast(&pMatrix->vPos, &mat->vPos, sizeof(CVector));
MemCpyFast(&pMatrix->vFront, &mat->vFront, sizeof(CVector));
MemCpyFast(&pMatrix->vRight, &mat->vRight, sizeof(CVector));
MemCpyFast(&pMatrix->vUp, &mat->vUp, sizeof(CVector));
CMatrixSAInterface* mat = &GetInterface()->m_mat;
MemCpyFast(pMatrix, &mat->GetMatrix(), sizeof(CMatrix));
}

void C3DMarkerSA::SetMatrix(CMatrix* pMatrix)
{
CMatrix_Padded* mat = &GetInterface()->m_mat;
MemCpyFast(&mat->vPos, &pMatrix->vPos, sizeof(CVector));
MemCpyFast(&mat->vFront, &pMatrix->vFront, sizeof(CVector));
MemCpyFast(&mat->vRight, &pMatrix->vRight, sizeof(CVector));
MemCpyFast(&mat->vUp, &pMatrix->vUp, sizeof(CVector));
CMatrixSAInterface* mat = &GetInterface()->m_mat;
mat->SetMatrix(pMatrix->vRight, pMatrix->vFront, pMatrix->vUp, pMatrix->vPos);
}

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

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

e3DMarkerType C3DMarkerSA::GetType() const
Expand Down Expand Up @@ -117,5 +112,5 @@ void C3DMarkerSA::Disable()

void C3DMarkerSA::Reset()
{
internalInterface->m_lastPosition = internalInterface->m_mat.vPos;
internalInterface->m_lastPosition = internalInterface->m_mat.GetPosition();
}
14 changes: 14 additions & 0 deletions Client/game_sa/CMatrixSA.h
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once
#include "CVector.h"
#include "CRenderWareSA.h"
#include "CMatrix.h"

class CMatrixSAInterface
{
Expand Down Expand Up @@ -45,4 +46,17 @@ class CMatrixSAInterface
m_up = up;
m_pos = pos;
}

CMatrix GetMatrix() const
{
CMatrix matrix;
matrix.vRight = m_right;
matrix.vFront = m_forward;
matrix.vUp = m_up;
matrix.vPos = m_pos;

return matrix;
}

CVector GetPosition() const noexcept { return m_pos; }
};
10 changes: 5 additions & 5 deletions Client/game_sa/interfaces/C3DMarkerSAInterface.cpp
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@

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)
{
// Call C3dMarker::AddMarker
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);
}

void C3DMarkerSAInterface::DeleteMarkerObject()
{
// Call C3dMarker::DeleteMarkerObject
((void(__thiscall*)(C3DMarkerSAInterface*))0x722390)(this);
}

bool C3DMarkerSAInterface::IsZCoordinateUpToDate() const
{
const CVector& pos = m_mat.vPos;
const CVector& pos = m_mat.GetPosition();
return m_LastMapReadX == static_cast<std::uint16_t>(pos.fX) && m_LastMapReadY == static_cast<std::uint16_t>(pos.fY);
}

void C3DMarkerSAInterface::SetZCoordinateIfNotUpToDate(float newZPos)
{
if (!IsZCoordinateUpToDate())
m_mat.vPos.fZ = newZPos;
{
CVector& pos = m_mat.GetPosition();
pos.fZ = newZPos;
}
}

void C3DMarkerSAInterface::UpdateZCoordinate(CVector point, float zDistance)
{
// Call C3dMarker::UpdateZCoordinate
((void(__thiscall*)(C3DMarkerSAInterface*, CVector, float))0x724D40)(this, point, zDistance);
}

Expand Down
16 changes: 8 additions & 8 deletions Client/game_sa/interfaces/C3DMarkerSAInterface.h
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#pragma once

#include <game/C3DMarker.h>
#include <CMatrix_Pad.h>
#include "game/RenderWare.h"
#include "../CMatrixSA.h"

class C3DMarkerSAInterface
{
public:
CMatrix_Padded m_mat; // local space to world space transform
CMatrixSAInterface m_mat; // local space to world space transform
RpAtomic* m_pRwObject;
RpMaterial* m_pMaterial;
std::uint16_t m_nType; // e3DMarkerType
Expand Down Expand Up @@ -46,12 +46,12 @@ class C3DMarkerSAInterface
std::uint32_t m_OnScreenTestTime; // time last screen check was done

public:
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,
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,
float pulseFraction, std::int16_t rotateRate);
void DeleteMarkerObject();
bool IsZCoordinateUpToDate() const;
void SetZCoordinateIfNotUpToDate(float newZPos);
void UpdateZCoordinate(CVector point, float zDistance);
void DeleteIfHasAtomic();
inline void DeleteMarkerObject();
inline bool IsZCoordinateUpToDate() const;
inline void SetZCoordinateIfNotUpToDate(float newZPos);
inline void UpdateZCoordinate(CVector point, float zDistance);
inline void DeleteIfHasAtomic();
};
static_assert(sizeof(C3DMarkerSAInterface) == 0xA0, "Invalid size for C3DMarkerSAInterface");
4 changes: 1 addition & 3 deletions Client/game_sa/premake5.lua
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ project "Game SA"

includedirs {
"../../Shared/sdk",
".",
"../sdk/",
"./interfaces",
"../../vendor/sparsehash/src/",
"../../vendor/sparsehash/src/"
}

files {
Expand Down
32 changes: 14 additions & 18 deletions Shared/sdk/CMatrix_Pad.h
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: sdk/CMatrix_Pad.h
* PURPOSE: 4x3 GTA padded matrix
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

Expand All @@ -20,19 +20,15 @@
class CMatrix_Padded
{
public:
CVector vRight; // right
std::uint32_t pad_0; // flags?
CVector vFront; // forward
std::uint32_t pad_1;
CVector vUp; // up
std::uint32_t pad_2;
CVector vPos; // translate
std::uint32_t pad_3;
CVector vRight; // 0 RIGHT
DWORD dwPadRoll; // 12
CVector vFront; // 16 FOREWARDS
DWORD dwPadDirection; // 28
CVector vUp; // 32 UP
DWORD dwPadWas; // 44
CVector vPos; // 48 TRANSLATE
DWORD dwPadPos; // 60

void* attachedMatrix; // RwMatrix*
bool ownsAttachedMatrix;

public:
CMatrix_Padded() { memset(this, 0, sizeof(CMatrix_Padded)); }

CMatrix_Padded(const CMatrix& Matrix) { SetFromMatrix(Matrix); }
Expand All @@ -48,16 +44,16 @@ class CMatrix_Padded
void SetFromMatrix(const CMatrix& Matrix)
{
vPos = Matrix.vPos;
pad_3 = 0;
dwPadPos = 0;

vFront = Matrix.vFront;
pad_1 = 0;
dwPadDirection = 0;

vUp = Matrix.vUp;
pad_2 = 0;
dwPadWas = 0;

vRight = Matrix.vRight;
pad_0 = 0;
dwPadRoll = 0;
}

void SetFromMatrixSkipPadding(const CMatrix& Matrix)
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /