Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd committed Oct 8, 2024
2 parents 96dd1ee + 78f6d66 commit f9eaf3f
Show file tree
Hide file tree
Showing 39 changed files with 750 additions and 329 deletions.
340 changes: 169 additions & 171 deletions Client/core/CNickGen.cpp

Large diffs are not rendered by default.

35 changes: 1 addition & 34 deletions Client/game_sa/CAutomobileSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,6 @@
#define MAX_PASSENGER_COUNT 8
#define MAX_DOORS 6 // also in CDamageManager

namespace eCarNode
{
enum
{
NONE = 0,
CHASSIS = 1,
WHEEL_RF = 2,
WHEEL_RM = 3,
WHEEL_RB = 4,
WHEEL_LF = 5,
WHEEL_LM = 6,
WHEEL_LB = 7,
DOOR_RF = 8,
DOOR_RR = 9,
DOOR_LF = 10,
DOOR_LR = 11,
BUMP_FRONT = 12,
BUMP_REAR = 13,
WING_RF = 14,
WING_LF = 15,
BONNET = 16,
BOOT = 17,
WINDSCREEN = 18,
EXHAUST = 19,
MISC_A = 20,
MISC_B = 21,
MISC_C = 22,
MISC_D = 23,
MISC_E = 24,
NUM_NODES
};
};

class CBouncingPanelSAInterface
{
public:
Expand All @@ -70,7 +37,7 @@ class CAutomobileSAInterface : public CVehicleSAInterface
public:
CDamageManagerSAInterface m_damageManager;
CDoorSAInterface m_doors[MAX_DOORS];
RwFrame* m_aCarNodes[eCarNode::NUM_NODES];
RwFrame* m_aCarNodes[static_cast<std::size_t>(eCarNodes::NUM_NODES)];
CBouncingPanelSAInterface m_panels[3];
CDoorSAInterface m_swingingChassis;
CColPointSAInterface m_wheelColPoint[MAX_WHEELS];
Expand Down
18 changes: 17 additions & 1 deletion Client/game_sa/CBikeSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
#include <game/CBike.h>
#include "CVehicleSA.h"

enum class eBikeNodes
{
NONE = 0,
CHASSIS,
FORKS_FRONT,
FORKS_REAR,
WHEEL_FRONT,
WHEEL_REAR,
MUDGUARD,
HANDLEBARS,
MISC_A,
MISC_B,

NUM_NODES
};

struct sRideAnimData
{
int32 iAnimGroup;
Expand All @@ -29,7 +45,7 @@ static_assert(sizeof(sRideAnimData) == 0x1C, "Invalid size for sRideAnimData");
class CBikeSAInterface : public CVehicleSAInterface
{
public:
int32 m_apModelNodes[10];
RwFrame* m_apModelNodes[static_cast<std::size_t>(eBikeNodes::NUM_NODES)];
int8 m_bLeanMatrixCalculated;
int8 pad0[3]; // Maybe prev value is int32
int8 m_mLeanMatrix[72];
Expand Down
16 changes: 16 additions & 0 deletions Client/game_sa/CBmxSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
#include <game/CBmx.h>
#include "CBikeSA.h"

enum class eBmxNodes
{
NONE = 0,
CHASSIS,
FORKS_FRONT,
FORKS_REAR,
WHEEL_FRONT,
WHEEL_REAR,
HANDLEBARS,
CHAINSET,
PEDAL_R,
PEDAL_L,

NUM_NODES
};

class CBmxSAInterface : public CBikeSAInterface
{
// fill this
Expand Down
20 changes: 19 additions & 1 deletion Client/game_sa/CBoatSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,30 @@
#include <game/CBoat.h>
#include "CVehicleSA.h"

enum class eBoatNodes
{
NONE = 0,
MOVING,
WINDSCREEN,
RUDDER,
FLAP_LEFT,
FLAP_RIGHT,
REARFLAP_LEFT,
REARFLAP_RIGHT,
STATIC_PROP,
MOVING_PROP,
STATIC_PROP2,
MOVING_PROP2,

NUM_NODES
};

class CBoatSAInterface : public CVehicleSAInterface
{
public:
uint32 pad1[3]; // 1440
uint32 BoatFlags; // 1452
RwFrame* pBoatParts[11]; // 1456 [[ find out correct size
RwFrame* pBoatParts[static_cast<std::size_t>(eBoatNodes::NUM_NODES)]; // 1456
uint32 pad2[3]; // 1500
uint16 pad3; // 1512
uint8 pad4[2]; // 1514
Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ void CBuildingsPoolSA::RemoveAllBuildings()

RemoveBuildingFromWorld(building);

if (building->HasMatrix())
building->RemoveMatrix();

pBuildsingsPool->Release(i);

(*m_pOriginalBuildingsBackup)[i].first = true;
Expand Down
5 changes: 5 additions & 0 deletions Client/game_sa/CCameraSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,8 @@ void CCameraSA::ResetShakeCamera() noexcept
{
GetInterface()->m_fCamShakeForce = 0.0f;
}

std::uint8_t CCameraSA::GetTransitionState()
{
return GetInterface()->m_uiTransitionState;
}
13 changes: 3 additions & 10 deletions Client/game_sa/CCameraSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CCameraSAInterface
public:
// CPlaceable
CPlaceableSAInterface Placeable;
std::uint8_t specialPadding[4]; // Temporary padding due to incorrect CPlaceableSAInterface class
// End CPlaceable

// move these out the class, have decided to set up a mirrored enumerated type thingy at the top
Expand Down Expand Up @@ -131,16 +132,6 @@ class CCameraSAInterface
bool m_bCooperativeCamMode;
bool m_bAllowShootingWith2PlayersInCar;
bool m_bDisableFirstPersonInCar;
static bool m_bUseMouse3rdPerson;
#ifndef FINALBUILD
bool bStaticFrustum;
#endif

// for debug keyboard stuff
#ifndef MASTER
unsigned char display_kbd_debug;
float kbd_fov_value;
#endif // MASTER

// The following fields allow the level designers to specify the camera for 2 player games.
short m_ModeForTwoPlayersSeparateCars;
Expand Down Expand Up @@ -430,4 +421,6 @@ class CCameraSA : public CCamera

void ShakeCamera(float radius, float x, float y, float z) noexcept override;
void ResetShakeCamera() noexcept override;

std::uint8_t GetTransitionState();
};
6 changes: 5 additions & 1 deletion Client/game_sa/CEntitySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CPlaceableSAInterface // 20 bytes
class CEntitySAInterface
{
public:
CEntitySAInterfaceVTBL* vtbl; // the virtual table
CEntitySAInterfaceVTBL* vtbl; // the virtual table it should be in the CPlaceableSAInterface

CPlaceableSAInterface Placeable; // 4

Expand Down Expand Up @@ -242,6 +242,10 @@ class CEntitySAInterface
using vtbl_DeleteRwObject = void(__thiscall*)(CEntitySAInterface * pEntity);
((vtbl_DeleteRwObject)this->vtbl->DeleteRwObject)(this);
};

bool HasMatrix() const noexcept { return Placeable.matrix != nullptr; }

void RemoveMatrix() { ((void(__thiscall*)(void*))0x54F3B0)(this); }
};
static_assert(sizeof(CEntitySAInterface) == 0x38, "Invalid size for CEntitySAInterface");

Expand Down
62 changes: 40 additions & 22 deletions Client/game_sa/CHudSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "CHudSA.h"
#include "CGameSA.h"
#include "CCameraSA.h"
#include "CPlayerInfoSA.h"
#include "TaskAttackSA.h"

extern CGameSA* pGame;

Expand Down Expand Up @@ -178,35 +180,51 @@ void CHudSA::ResetComponentAdjustment()

bool CHudSA::IsCrosshairVisible()
{
if (!IsComponentVisible(HUD_CROSSHAIR))
return false;
bool specialAiming = false;
bool simpleAiming = false;

// Get camera view mode
CCamera* camera = pGame->GetCamera();
eCamMode cameraViewMode = static_cast<eCamMode>(camera->GetCam(camera->GetActiveCam())->GetMode());

switch (cameraViewMode)
// Get player
CPed* playerPed = pGame->GetPedContext();
CWeapon* weapon = nullptr;
eWeaponType weaponType;

// Get player current weapon
if (playerPed)
{
weapon = playerPed->GetWeapon(playerPed->GetCurrentWeaponSlot());
if (weapon)
weaponType = weapon->GetType();
}

// Special aiming
if (cameraViewMode == MODE_SNIPER || cameraViewMode == MODE_1STPERSON || cameraViewMode == MODE_ROCKETLAUNCHER || cameraViewMode == MODE_ROCKETLAUNCHER_HS || cameraViewMode == MODE_M16_1STPERSON || cameraViewMode == MODE_HELICANNON_1STPERSON || cameraViewMode == MODE_CAMERA)
{
if (weapon && cameraViewMode != MODE_1STPERSON && pGame->GetWeaponInfo(weaponType, WEAPONSKILL_STD)->GetFireType() != FIRETYPE_MELEE)
specialAiming = true;
}

// Simple aiming
if (cameraViewMode == MODE_M16_1STPERSON_RUNABOUT || cameraViewMode == MODE_ROCKETLAUNCHER_RUNABOUT || cameraViewMode == MODE_ROCKETLAUNCHER_RUNABOUT_HS || cameraViewMode == MODE_SNIPER_RUNABOUT)
simpleAiming = true;

if ((playerPed && weapon) && !playerPed->GetTargetedObject() && playerPed->GetPedInterface()->pPlayerData->m_bFreeAiming)
{
case MODE_SNIPER_RUNABOUT:
case MODE_ROCKETLAUNCHER_RUNABOUT:
case MODE_ROCKETLAUNCHER_RUNABOUT_HS:
case MODE_M16_1STPERSON_RUNABOUT:
case MODE_1STPERSON_RUNABOUT:
case MODE_AIMWEAPON:
case MODE_AIMWEAPON_ATTACHED:
case MODE_AIMWEAPON_FROMCAR:
case MODE_M16_1STPERSON:
case MODE_HELICANNON_1STPERSON:
case MODE_SNIPER:
case MODE_ROCKETLAUNCHER:
case MODE_ROCKETLAUNCHER_HS:
case MODE_AIMING:
case MODE_CAMERA:
return true;
default:
break;
CTaskSimpleUseGun* taskUseGun = playerPed->GetPedIntelligence()->GetTaskUseGun();
if ((!taskUseGun || !taskUseGun->GetSkipAim()) && (cameraViewMode == MODE_AIMWEAPON || cameraViewMode == MODE_AIMWEAPON_FROMCAR || cameraViewMode == MODE_AIMWEAPON_ATTACHED))
{
if (playerPed->GetPedState() != PED_ENTER_CAR && playerPed->GetPedState() != PED_CARJACK)
{
if ((weaponType >= WEAPONTYPE_PISTOL && weaponType <= WEAPONTYPE_M4) || weaponType == WEAPONTYPE_TEC9 || weaponType == WEAPONTYPE_COUNTRYRIFLE || weaponType == WEAPONTYPE_MINIGUN || weaponType == WEAPONTYPE_FLAMETHROWER)
simpleAiming = cameraViewMode != MODE_AIMWEAPON || camera->GetTransitionState() == 0;
}
}
}

// Check CTheScripts::bDrawCrossHair
std::uint8_t crossHairType = *reinterpret_cast<std::uint8_t*>(VAR_CTheScripts_bDrawCrossHair);
return crossHairType > 0;
return specialAiming || simpleAiming || crossHairType > 0;
}
14 changes: 14 additions & 0 deletions Client/game_sa/CPedIntelligenceSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "CPedSA.h"
#include "CTaskManagementSystemSA.h"
#include "CTaskManagerSA.h"
#include "TaskAttackSA.h"

CPedIntelligenceSA::CPedIntelligenceSA(CPedIntelligenceSAInterface* pedIntelligenceSAInterface, CPed* ped)
{
Expand Down Expand Up @@ -55,3 +56,16 @@ CTaskSAInterface* CPedIntelligenceSA::SetTaskDuckSecondary(unsigned short nLengt
auto SetTaskDuckSecondary = (CTaskSAInterface * (__thiscall*)(CPedIntelligenceSAInterface*, unsigned short))0x601230;
return SetTaskDuckSecondary(internalInterface, nLengthOfDuck);
}

CTaskSimpleUseGun* CPedIntelligenceSA::GetTaskUseGun()
{
CTaskManager* taskMgr = GetTaskManager();
if (!taskMgr)
return nullptr;

CTask* secondaryTask = taskMgr->GetTaskSecondary(TASK_SECONDARY_ATTACK);
if (secondaryTask && secondaryTask->GetTaskType() == TASK_SIMPLE_USE_GUN)
return dynamic_cast<CTaskSimpleUseGun*>(secondaryTask);

return nullptr;
}
1 change: 1 addition & 0 deletions Client/game_sa/CPedIntelligenceSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ class CPedIntelligenceSA : public CPedIntelligence
CTaskManager* GetTaskManager();
bool TestForStealthKill(CPed* pPed, bool bUnk);
CTaskSAInterface* SetTaskDuckSecondary(unsigned short nLengthOfDuck);
CTaskSimpleUseGun* GetTaskUseGun();
};
14 changes: 12 additions & 2 deletions Client/game_sa/CPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ class CPedSAInterface : public CPhysicalSAInterface // +1420 = curre
int iMoveAnimGroup; // 1236
BYTE bPad4b[52];
CPedIKSAInterface pedIK; // 1292 (length 32 bytes)
int bPad5[5];

std::uint32_t field_52C;
ePedState pedState;
eMoveState moveState;
eMoveState swimmingMoveState;
std::uint32_t field_53C;

float fHealth;
int iUnknown121;
Expand Down Expand Up @@ -258,7 +263,9 @@ class CPedSAInterface : public CPhysicalSAInterface // +1420 = curre
// weapons at +1440 ends at +1804
BYTE bPad4[12];
BYTE bCurrentWeaponSlot; // is actually here
BYTE bPad6[20];
BYTE bPad6[3];
CEntitySAInterface* pTargetedObject;
BYTE tempPad[13];
BYTE bFightingStyle; // 1837
BYTE bFightingStyleExtra;
BYTE bPad7[1];
Expand Down Expand Up @@ -408,5 +415,8 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
std::unique_ptr<CPedIK> GetPedIK() { return std::make_unique<CPedIKSA>(GetPedIKInterface()); }
static void StaticSetHooks();

CEntitySAInterface* GetTargetedObject() { return GetPedInterface()->pTargetedObject; }
ePedState GetPedState() { return GetPedInterface()->pedState; }

void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;
};
7 changes: 3 additions & 4 deletions Client/game_sa/CPlayerInfoSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class CPlayerPedDataSAInterface

CVector2D m_vecFightMovement; // 12
float m_moveBlendRatio; // 20
float m_fSprintEnergy; // 24
// FLOAT m_fSprintControlCounter; // Removed arbitatrily to aligned next byte, should be here really
float m_fTimeCanRun;
float m_fSprintEnergy;

BYTE m_nChosenWeapon; // 28
BYTE m_nCarDangerCounter; // 29
BYTE m_pad0; // 30
Expand All @@ -68,8 +69,6 @@ class CPlayerPedDataSAInterface
DWORD m_bInVehicleDontAllowWeaponChange : 1; // stop weapon change once driveby weapon has been given
DWORD m_bRenderWeapon : 1; // set to false during cutscenes so that knuckledusters are not rendered

DWORD m_pad2; // 56

long m_PlayerGroup; // 60

DWORD m_AdrenalineEndTime; // 64
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CPlayerPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CPlayerPedSA::CPlayerPedSA(unsigned int nModelIndex)
// Set default stuff
m_pData->m_bRenderWeapon = true;
m_pData->m_Wanted = pLocalWanted;
m_pData->m_fSprintEnergy = 1000.0f;
m_pData->m_fTimeCanRun = 1000.0f;

// Clothes pointers or we'll crash later (TODO: Wrap up with some cloth classes and make it unique per player)
m_pData->m_pClothes = pLocalClothes;
Expand Down
Loading

0 comments on commit f9eaf3f

Please sign in to comment.