Skip to content

Commit ce6b190

Browse files
committed
Merge remote-tracking branch 'mta_main/master' into TheNormalnij/remove_vtbl
2 parents a72a16f + a550bbf commit ce6b190

File tree

14 files changed

+93
-34
lines changed

14 files changed

+93
-34
lines changed

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ void CBuildingsPoolSA::RemoveAllBuildings()
151151

152152
RemoveBuildingFromWorld(building);
153153

154+
if (building->HasMatrix())
155+
building->RemoveMatrix();
156+
154157
pBuildsingsPool->Release(i);
155158

156159
(*m_pOriginalBuildingsBackup)[i].first = true;

Client/game_sa/CCameraSA.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,8 @@ void CCameraSA::ResetShakeCamera() noexcept
458458
{
459459
GetInterface()->m_fCamShakeForce = 0.0f;
460460
}
461+
462+
std::uint8_t CCameraSA::GetTransitionState()
463+
{
464+
return GetInterface()->m_uiTransitionState;
465+
}

Client/game_sa/CCameraSA.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ class CCameraSAInterface : public CPlaceableSAInterface
127127
bool m_bCooperativeCamMode;
128128
bool m_bAllowShootingWith2PlayersInCar;
129129
bool m_bDisableFirstPersonInCar;
130-
static bool m_bUseMouse3rdPerson;
131130

132131
// The following fields allow the level designers to specify the camera for 2 player games.
133132
short m_ModeForTwoPlayersSeparateCars;
@@ -417,4 +416,6 @@ class CCameraSA : public CCamera
417416

418417
void ShakeCamera(float radius, float x, float y, float z) noexcept override;
419418
void ResetShakeCamera() noexcept override;
419+
420+
std::uint8_t GetTransitionState();
420421
};

Client/game_sa/CEntitySA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class CEntitySAInterface : public CPlaceableSAInterface
216216
using CStencilShadow_dtorByOwner = void*(__cdecl*)(CEntitySAInterface * pEntity);
217217
((CStencilShadow_dtorByOwner)0x711730)(this);
218218
};
219-
219+
220220
bool IsUsesEntityDeleteRwObject() { return *(*reinterpret_cast<std::uint32_t**>(this) + 0x20) == 0x00534030; };
221221
};
222222
static_assert(sizeof(CEntitySAInterface) == 0x38, "Invalid size for CEntitySAInterface");

Client/game_sa/CHudSA.cpp

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "CHudSA.h"
1414
#include "CGameSA.h"
1515
#include "CCameraSA.h"
16+
#include "CPlayerInfoSA.h"
17+
#include "TaskAttackSA.h"
1618

1719
extern CGameSA* pGame;
1820

@@ -178,35 +180,51 @@ void CHudSA::ResetComponentAdjustment()
178180

179181
bool CHudSA::IsCrosshairVisible()
180182
{
181-
if (!IsComponentVisible(HUD_CROSSHAIR))
182-
return false;
183+
bool specialAiming = false;
184+
bool simpleAiming = false;
183185

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

187-
switch (cameraViewMode)
190+
// Get player
191+
CPed* playerPed = pGame->GetPedContext();
192+
CWeapon* weapon = nullptr;
193+
eWeaponType weaponType;
194+
195+
// Get player current weapon
196+
if (playerPed)
197+
{
198+
weapon = playerPed->GetWeapon(playerPed->GetCurrentWeaponSlot());
199+
if (weapon)
200+
weaponType = weapon->GetType();
201+
}
202+
203+
// Special aiming
204+
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)
205+
{
206+
if (weapon && cameraViewMode != MODE_1STPERSON && pGame->GetWeaponInfo(weaponType, WEAPONSKILL_STD)->GetFireType() != FIRETYPE_MELEE)
207+
specialAiming = true;
208+
}
209+
210+
// Simple aiming
211+
if (cameraViewMode == MODE_M16_1STPERSON_RUNABOUT || cameraViewMode == MODE_ROCKETLAUNCHER_RUNABOUT || cameraViewMode == MODE_ROCKETLAUNCHER_RUNABOUT_HS || cameraViewMode == MODE_SNIPER_RUNABOUT)
212+
simpleAiming = true;
213+
214+
if ((playerPed && weapon) && !playerPed->GetTargetedObject() && playerPed->GetPedInterface()->pPlayerData->m_bFreeAiming)
188215
{
189-
case MODE_SNIPER_RUNABOUT:
190-
case MODE_ROCKETLAUNCHER_RUNABOUT:
191-
case MODE_ROCKETLAUNCHER_RUNABOUT_HS:
192-
case MODE_M16_1STPERSON_RUNABOUT:
193-
case MODE_1STPERSON_RUNABOUT:
194-
case MODE_AIMWEAPON:
195-
case MODE_AIMWEAPON_ATTACHED:
196-
case MODE_AIMWEAPON_FROMCAR:
197-
case MODE_M16_1STPERSON:
198-
case MODE_HELICANNON_1STPERSON:
199-
case MODE_SNIPER:
200-
case MODE_ROCKETLAUNCHER:
201-
case MODE_ROCKETLAUNCHER_HS:
202-
case MODE_AIMING:
203-
case MODE_CAMERA:
204-
return true;
205-
default:
206-
break;
216+
CTaskSimpleUseGun* taskUseGun = playerPed->GetPedIntelligence()->GetTaskUseGun();
217+
if ((!taskUseGun || !taskUseGun->GetSkipAim()) && (cameraViewMode == MODE_AIMWEAPON || cameraViewMode == MODE_AIMWEAPON_FROMCAR || cameraViewMode == MODE_AIMWEAPON_ATTACHED))
218+
{
219+
if (playerPed->GetPedState() != PED_ENTER_CAR && playerPed->GetPedState() != PED_CARJACK)
220+
{
221+
if ((weaponType >= WEAPONTYPE_PISTOL && weaponType <= WEAPONTYPE_M4) || weaponType == WEAPONTYPE_TEC9 || weaponType == WEAPONTYPE_COUNTRYRIFLE || weaponType == WEAPONTYPE_MINIGUN || weaponType == WEAPONTYPE_FLAMETHROWER)
222+
simpleAiming = cameraViewMode != MODE_AIMWEAPON || camera->GetTransitionState() == 0;
223+
}
224+
}
207225
}
208226

209227
// Check CTheScripts::bDrawCrossHair
210228
std::uint8_t crossHairType = *reinterpret_cast<std::uint8_t*>(VAR_CTheScripts_bDrawCrossHair);
211-
return crossHairType > 0;
229+
return specialAiming || simpleAiming || crossHairType > 0;
212230
}

Client/game_sa/CPedIntelligenceSA.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "CPedSA.h"
1515
#include "CTaskManagementSystemSA.h"
1616
#include "CTaskManagerSA.h"
17+
#include "TaskAttackSA.h"
1718

1819
CPedIntelligenceSA::CPedIntelligenceSA(CPedIntelligenceSAInterface* pedIntelligenceSAInterface, CPed* ped)
1920
{
@@ -55,3 +56,16 @@ CTaskSAInterface* CPedIntelligenceSA::SetTaskDuckSecondary(unsigned short nLengt
5556
auto SetTaskDuckSecondary = (CTaskSAInterface * (__thiscall*)(CPedIntelligenceSAInterface*, unsigned short))0x601230;
5657
return SetTaskDuckSecondary(internalInterface, nLengthOfDuck);
5758
}
59+
60+
CTaskSimpleUseGun* CPedIntelligenceSA::GetTaskUseGun()
61+
{
62+
CTaskManager* taskMgr = GetTaskManager();
63+
if (!taskMgr)
64+
return nullptr;
65+
66+
CTask* secondaryTask = taskMgr->GetTaskSecondary(TASK_SECONDARY_ATTACK);
67+
if (secondaryTask && secondaryTask->GetTaskType() == TASK_SIMPLE_USE_GUN)
68+
return dynamic_cast<CTaskSimpleUseGun*>(secondaryTask);
69+
70+
return nullptr;
71+
}

Client/game_sa/CPedIntelligenceSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ class CPedIntelligenceSA : public CPedIntelligence
5454
CTaskManager* GetTaskManager();
5555
bool TestForStealthKill(CPed* pPed, bool bUnk);
5656
CTaskSAInterface* SetTaskDuckSecondary(unsigned short nLengthOfDuck);
57+
CTaskSimpleUseGun* GetTaskUseGun();
5758
};

Client/game_sa/CPedSA.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ class CPedSAInterface : public CPhysicalSAInterface // +1420 = curre
230230
int iMoveAnimGroup; // 1236
231231
BYTE bPad4b[52];
232232
CPedIKSAInterface pedIK; // 1292 (length 32 bytes)
233-
int bPad5[5];
233+
234+
std::uint32_t field_52C;
235+
ePedState pedState;
236+
eMoveState moveState;
237+
eMoveState swimmingMoveState;
238+
std::uint32_t field_53C;
234239

235240
float fHealth;
236241
int iUnknown121;
@@ -258,7 +263,8 @@ class CPedSAInterface : public CPhysicalSAInterface // +1420 = curre
258263
// weapons at +1440 ends at +1804
259264
BYTE bPad4[12];
260265
BYTE bCurrentWeaponSlot; // is actually here
261-
BYTE bPad6[20];
266+
BYTE bPad6[3];
267+
CEntitySAInterface* pTargetedObject;
262268
BYTE bFightingStyle; // 1837
263269
BYTE bFightingStyleExtra;
264270
BYTE bPad7[1];
@@ -408,5 +414,8 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
408414
std::unique_ptr<CPedIK> GetPedIK() { return std::make_unique<CPedIKSA>(GetPedIKInterface()); }
409415
static void StaticSetHooks();
410416

417+
CEntitySAInterface* GetTargetedObject() { return GetPedInterface()->pTargetedObject; }
418+
ePedState GetPedState() { return GetPedInterface()->pedState; }
419+
411420
void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;
412421
};

Client/game_sa/CPlaceableSA.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <CMatrix_Pad.h>
1111
#include <CVector.h>
1212

13-
constexpr std::uint32_t VTBL_CPlaceable = 0x863C40;
14-
1513
class CSimpleTransformSAInterface // 16 bytes
1614
{
1715
public:
@@ -24,8 +22,10 @@ class CPlaceableSAInterface
2422
public:
2523
virtual void* Destructor(bool free) = 0;
2624

27-
bool IsPlaceableVTBL() const { return *reinterpret_cast<const void* const*>(this) == (void*)VTBL_CPlaceable; };
28-
bool HasVTBL() const { return *reinterpret_cast<const void* const*>(this) != nullptr; };
25+
bool IsPlaceableVTBL() const { return *reinterpret_cast<const void* const*>(this) == (void*)0x863C40; }
26+
bool HasVTBL() const { return *reinterpret_cast<const void* const*>(this) != nullptr; }
27+
bool HasMatrix() const noexcept { return matrix != nullptr; }
28+
void RemoveMatrix() { ((void(__thiscall*)(void*))0x54F3B0)(this); }
2929

3030
public:
3131
CSimpleTransformSAInterface m_transform;

Client/game_sa/CPlayerInfoSA.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ class CPlayerPedDataSAInterface
4141

4242
CVector2D m_vecFightMovement; // 12
4343
float m_moveBlendRatio; // 20
44-
float m_fSprintEnergy; // 24
45-
// FLOAT m_fSprintControlCounter; // Removed arbitatrily to aligned next byte, should be here really
44+
float m_fTimeCanRun;
45+
float m_fSprintEnergy;
46+
4647
BYTE m_nChosenWeapon; // 28
4748
BYTE m_nCarDangerCounter; // 29
4849
BYTE m_pad0; // 30
@@ -68,8 +69,6 @@ class CPlayerPedDataSAInterface
6869
DWORD m_bInVehicleDontAllowWeaponChange : 1; // stop weapon change once driveby weapon has been given
6970
DWORD m_bRenderWeapon : 1; // set to false during cutscenes so that knuckledusters are not rendered
7071

71-
DWORD m_pad2; // 56
72-
7372
long m_PlayerGroup; // 60
7473

7574
DWORD m_AdrenalineEndTime; // 64

0 commit comments

Comments
 (0)