Skip to content
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

Refactoring Part 5 - CVehicleSA #3687

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Client/game_sa/CAutomobileSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CAutomobileSAInterface : public CVehicleSAInterface
float m_fMoveDirection;
int field_8B4[6];
int field_8C8[6];
float m_fBurningTime;
float m_burningTime;
CEntitySAInterface* m_pWheelCollisionEntity[4];
CVector m_vWheelCollisionPos[4];
char field_924;
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CEntitySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void CEntitySA::SetMatrix(CMatrix* matrix)
}
}

WORD CEntitySA::GetModelIndex()
WORD CEntitySA::GetModelIndex() const
{
return m_pInterface->m_nModelIndex;
}
Expand Down
11 changes: 9 additions & 2 deletions Client/game_sa/CEntitySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
#include <CVector2D.h>
#include <CVector.h>

template <typename ReturnType, typename... ArgsType>
inline ReturnType GTAFunction(DWORD function, ArgsType... args)
{
return (ReturnType(__thiscall*)(ArgsType...)function)(args);
};

#define FUNC_GetDistanceFromCentreOfMassToBaseOfModel 0x536BE0

#define FUNC_SetRwObjectAlpha 0x5332C0
Expand Down Expand Up @@ -253,7 +259,8 @@ class CEntitySA : public virtual CEntity
CEntitySAInterface* m_pInterface;

CEntitySA();
CEntitySAInterface* GetInterface() { return m_pInterface; };
CEntitySAInterface* GetInterface() { return m_pInterface; }
const CEntitySAInterface* GetInterface() const noexcept { return m_pInterface; }
void SetInterface(CEntitySAInterface* intInterface) { m_pInterface = intInterface; };

bool IsPed() { return GetEntityType() == ENTITY_TYPE_PED; }
Expand All @@ -277,7 +284,7 @@ class CEntitySA : public virtual CEntity
CMatrix* GetMatrix(CMatrix* matrix);
CMatrix* GetMatrixInternal(CMatrix* matrix);
void SetMatrix(CMatrix* matrix);
WORD GetModelIndex();
WORD GetModelIndex() const;
eEntityType GetEntityType();
bool IsOnScreen();
bool IsFullyVisible();
Expand Down
19 changes: 19 additions & 0 deletions Client/game_sa/CNodeSA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CPadSA.h
* PURPOSE: Header file for controller pad input class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#pragma once

class CNodeAddressSA
{
public:
std::uint16_t m_areaID;
std::uint16_t m_nodeID;
};
5 changes: 5 additions & 0 deletions Client/game_sa/CTrainSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ CTrainSA::CTrainSA(CTrainSAInterface* pInterface)
SetInterface(pInterface);
Init();
}

void __thiscall CTrainSAInterface::FindPositionOnTrackFromCoors()
{
GTAFunction<void, CTrainSAInterface*>(FUNC_CTrain_FindPositionOnTrackFromCoors, this);
}
3 changes: 3 additions & 0 deletions Client/game_sa/CTrainSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class CTrainSAInterface : public CVehicleSAInterface
CTrainSAInterface* m_nextCarriage;
CDoorSAInterface m_aDoors[MAX_DOORS];
RwFrame* m_aTrainNodes[eTrainNode::NUM_NODES];

public:
void __thiscall FindPositionOnTrackFromCoors();
};
static_assert(sizeof(CTrainSAInterface) == 0x6AC, "Invalid size for CTrainSAInterface");

Expand Down
Loading
Loading