Skip to content

Commit 17bde89

Browse files
authored
Merge branch 'master' into startstop
2 parents ff5608d + 449cf0f commit 17bde89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5546
-5303
lines changed

Client/game_sa/CPedSA.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class CPedSAInterface : public CPhysicalSAInterface
261261
int unk_52C;
262262

263263
int pedState;
264-
int moveState;
264+
PedMoveState::Enum moveState;
265265
int swimmingMoveState;
266266

267267
int unk_53C;
@@ -276,10 +276,10 @@ class CPedSAInterface : public CPhysicalSAInterface
276276
float fRotationSpeed;
277277
float fMoveAnim;
278278

279-
CEntitySAInterface* pContactEntity;
279+
CEntitySAInterface* pContactEntity; // m_standingOnEntity
280280
CVector unk_56C;
281281
CVector unk_578;
282-
CEntitySAInterface* pLastContactEntity;
282+
CEntitySAInterface* pLastContactEntity; // m_contactEntity
283283

284284
CVehicleSAInterface* pLastVehicle;
285285
CVehicleSAInterface* pVehicle;
@@ -421,8 +421,9 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
421421
void SetFightingStyle(eFightingStyle style, std::uint8_t styleExtra = 6) override;
422422

423423
CEntity* GetContactEntity() const override;
424+
bool IsStandingOnEntity() const override { return GetPedInterface()->pContactEntity != nullptr; };
424425

425-
int GetRunState() const override { return GetPedInterface()->moveState; }
426+
PedMoveState::Enum GetMoveState() const override { return GetPedInterface()->moveState; }
426427

427428
bool GetCanBeShotInVehicle() const override{ return GetPedInterface()->pedFlags.bCanBeShotInVehicle; }
428429
bool GetTestForShotInVehicle() const override { return GetPedInterface()->pedFlags.bTestForShotInVehicle; }

Client/loader/MainFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ void CheckDataFiles()
977977
//////////////////////////////////////////////////////////
978978
void CheckLibVersions()
979979
{
980-
#if MTASA_VERSION_TYPE < VERSION_TYPE_UNTESTED
980+
#if MTASA_VERSION_TYPE >= VERSION_TYPE_UNTESTED
981981

982982
const char* moduleList[] = {"MTA\\loader.dll",
983983
"MTA\\cgui.dll",

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,9 +3551,9 @@ void CClientGame::StaticDeathHandler(CPed* pKilledPed, unsigned char ucDeathReas
35513551
g_pClientGame->DeathHandler(pKilledPed, ucDeathReason, ucBodyPart);
35523552
}
35533553

3554-
void CClientGame::StaticFireHandler(CFire* pFire)
3554+
bool CClientGame::StaticFireHandler(CEntitySAInterface* target, CEntitySAInterface* creator)
35553555
{
3556-
g_pClientGame->FireHandler(pFire);
3556+
return g_pClientGame->FireHandler(target, creator);
35573557
}
35583558

35593559
void CClientGame::StaticRender3DStuffHandler()
@@ -3813,10 +3813,22 @@ bool CClientGame::BreakTowLinkHandler(CVehicle* pTowedVehicle)
38133813
return true;
38143814
}
38153815

3816-
void CClientGame::FireHandler(CFire* pFire)
3816+
bool CClientGame::FireHandler(CEntitySAInterface* target, CEntitySAInterface* creator)
38173817
{
3818-
// Disable spreading fires
3819-
pFire->SetNumGenerationsAllowed(0);
3818+
CClientEntity* creatorClientEntity = g_pGame->GetPools()->GetClientEntity((DWORD*)creator);
3819+
CClientEntity* targetClientEntity = g_pGame->GetPools()->GetClientEntity((DWORD*)target);
3820+
3821+
if (creatorClientEntity && targetClientEntity && IS_PLAYER(targetClientEntity) && IS_PLAYER(creatorClientEntity))
3822+
{
3823+
CClientPlayer* targetPlayer = static_cast<CClientPlayer*>(targetClientEntity);
3824+
CClientPlayer* creatorPlayer = static_cast<CClientPlayer*>(creatorClientEntity);
3825+
3826+
CClientTeam* targetPlayerTeam = targetPlayer->GetTeam();
3827+
if (targetPlayerTeam && targetPlayer->IsOnMyTeam(creatorPlayer) && !targetPlayerTeam->GetFriendlyFire() && creatorPlayer != targetPlayer)
3828+
return false;
3829+
}
3830+
3831+
return true;
38203832
}
38213833

38223834
void CClientGame::ProjectileInitiateHandler(CClientProjectile* pProjectile)

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class CClientModelCacheManager;
5353
class CDebugHookManager;
5454
class CResourceFileDownloadManager;
5555
class CServerInfo;
56+
class CFire;
5657
enum class eAnimID;
5758

5859
struct SVehExtrapolateSettings
@@ -522,7 +523,7 @@ class CClientGame
522523

523524
static bool StaticDamageHandler(CPed* pDamagePed, CEventDamage* pEvent);
524525
static void StaticDeathHandler(CPed* pKilledPed, unsigned char ucDeathReason, unsigned char ucBodyPart);
525-
static void StaticFireHandler(CFire* pFire);
526+
static bool StaticFireHandler(CEntitySAInterface* target, CEntitySAInterface* creator);
526527
static bool StaticBreakTowLinkHandler(CVehicle* pTowedVehicle);
527528
static void StaticDrawRadarAreasHandler();
528529
static void StaticRender3DStuffHandler();
@@ -573,7 +574,7 @@ class CClientGame
573574

574575
bool DamageHandler(CPed* pDamagePed, CEventDamage* pEvent);
575576
void DeathHandler(CPed* pKilledPed, unsigned char ucDeathReason, unsigned char ucBodyPart);
576-
void FireHandler(CFire* pFire);
577+
bool FireHandler(CEntitySAInterface* target, CEntitySAInterface* creator);
577578
bool BreakTowLinkHandler(CVehicle* pTowedVehicle);
578579
void DrawRadarAreasHandler();
579580
void Render3DStuffHandler();

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,16 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
231231
m_MovementStateNames[MOVEMENTSTATE_JOG] = "jog";
232232
m_MovementStateNames[MOVEMENTSTATE_SPRINT] = "sprint";
233233
m_MovementStateNames[MOVEMENTSTATE_CROUCH] = "crouch";
234-
// These two are inactive for now
235234
m_MovementStateNames[MOVEMENTSTATE_CRAWL] = "crawl";
236235
m_MovementStateNames[MOVEMENTSTATE_ROLL] = "roll";
237236
m_MovementStateNames[MOVEMENTSTATE_JUMP] = "jump";
238237
m_MovementStateNames[MOVEMENTSTATE_FALL] = "fall";
239238
m_MovementStateNames[MOVEMENTSTATE_CLIMB] = "climb";
239+
m_MovementStateNames[MOVEMENTSTATE_SWIM] = "swim";
240+
m_MovementStateNames[MOVEMENTSTATE_WALK_TO_POINT] = "walk_to_point";
241+
m_MovementStateNames[MOVEMENTSTATE_ASCENT_JETPACK] = "ascent_jetpack";
242+
m_MovementStateNames[MOVEMENTSTATE_DESCENT_JETPACK] = "descent_jetpack";
243+
m_MovementStateNames[MOVEMENTSTATE_JETPACK] = "jetpack_flying";
240244

241245
// Create the player model
242246
if (m_bIsLocalPlayer)
@@ -2420,53 +2424,63 @@ eMovementState CClientPed::GetMovementState()
24202424
const char* szComplexTaskName = GetTaskManager()->GetActiveTask()->GetTaskName();
24212425
const char* szSimpleTaskName = GetTaskManager()->GetSimplestActiveTask()->GetTaskName();
24222426

2423-
// Is he climbing?
2424-
if (strcmp(szSimpleTaskName, "TASK_SIMPLE_CLIMB") == 0)
2427+
// Check tasks
2428+
if (strcmp(szSimpleTaskName, "TASK_SIMPLE_CLIMB") == 0) // Is he climbing?
24252429
return MOVEMENTSTATE_CLIMB;
2426-
2427-
// Is he jumping?
2428-
else if (strcmp(szComplexTaskName, "TASK_COMPLEX_JUMP") == 0)
2430+
else if (strcmp(szComplexTaskName, "TASK_COMPLEX_JUMP") == 0) // Is he jumping?
24292431
return MOVEMENTSTATE_JUMP;
2432+
else if (strcmp(szSimpleTaskName, "TASK_SIMPLE_GO_TO_POINT") == 0) // Entering vehicle (walking to the doors)?
2433+
return MOVEMENTSTATE_WALK_TO_POINT;
2434+
else if (strcmp(szSimpleTaskName, "TASK_SIMPLE_SWIM") == 0) // Is he swimming?
2435+
return MOVEMENTSTATE_SWIM;
2436+
else if (strcmp(szSimpleTaskName, "TASK_SIMPLE_JETPACK") == 0) // Is he flying?
2437+
{
2438+
if (cs.ButtonCross != 0)
2439+
return MOVEMENTSTATE_ASCENT_JETPACK;
2440+
else if (cs.ButtonSquare != 0)
2441+
return MOVEMENTSTATE_DESCENT_JETPACK;
2442+
else
2443+
return MOVEMENTSTATE_JETPACK;
2444+
}
24302445

2431-
// Is he falling?
2432-
else if (!IsOnGround() && !GetContactEntity())
2446+
// Check movement state
2447+
if (!IsOnGround() && !GetContactEntity() && !m_pPlayerPed->IsStandingOnEntity() && !m_pPlayerPed->IsInWater() && (strcmp(szSimpleTaskName, "TASK_SIMPLE_IN_AIR") == 0 || strcmp(szSimpleTaskName, "TASK_SIMPLE_FALL") == 0)) // Is he falling?
24332448
return MOVEMENTSTATE_FALL;
24342449

2435-
// Grab his controller state
2436-
bool bWalkKey = false;
2437-
if (GetType() == CCLIENTPLAYER)
2438-
bWalkKey = CClientPad::GetControlState("walk", cs, true);
2439-
else
2440-
m_Pad.GetControlState("walk", bWalkKey);
2450+
// Sometimes it returns 'fall' or 'walk', so it's better to return false instead
2451+
if (IsEnteringVehicle() || IsLeavingVehicle())
2452+
return MOVEMENTSTATE_UNKNOWN;
24412453

2442-
// Is he standing up?
24432454
if (!IsDucked())
24442455
{
2445-
unsigned int iRunState = m_pPlayerPed->GetRunState();
2456+
bool walking = false;
2457+
if (GetType() == CCLIENTPLAYER)
2458+
walking = CClientPad::GetControlState("walk", cs, true);
2459+
else
2460+
m_Pad.GetControlState("walk", walking);
24462461

2447-
// Is he moving the contoller at all?
2448-
if (iRunState == 1 && cs.LeftStickX == 0 && cs.LeftStickY == 0)
2449-
return MOVEMENTSTATE_STAND;
2450-
2451-
// Is he either pressing the walk key, or has run state 1?
2452-
if (iRunState == 1 || bWalkKey && iRunState == 6)
2453-
return MOVEMENTSTATE_WALK;
2454-
else if (iRunState == 4)
2455-
return MOVEMENTSTATE_POWERWALK;
2456-
else if (iRunState == 6)
2457-
return MOVEMENTSTATE_JOG;
2458-
else if (iRunState == 7)
2459-
return MOVEMENTSTATE_SPRINT;
2462+
switch (m_pPlayerPed->GetMoveState())
2463+
{
2464+
case PedMoveState::PEDMOVE_STILL:
2465+
return MOVEMENTSTATE_STAND;
2466+
case PedMoveState::PEDMOVE_WALK:
2467+
return (cs.LeftStickX == 0 && cs.LeftStickY == 0) ? MOVEMENTSTATE_STAND : MOVEMENTSTATE_WALK;
2468+
case PedMoveState::PEDMOVE_SPRINT:
2469+
return MOVEMENTSTATE_SPRINT;
2470+
case PedMoveState::PEDMOVE_RUN:
2471+
return walking ? MOVEMENTSTATE_WALK : MOVEMENTSTATE_JOG; // FileEX: It should be MOVEMENTSTATE_RUN, but we're keeping JOG for backward compatibility (PEDMOVE_JOG is unused in SA)
2472+
}
24602473
}
24612474
else
24622475
{
24632476
// Is he moving the contoller at all?
24642477
if (cs.LeftStickX == 0 && cs.LeftStickY == 0)
24652478
return MOVEMENTSTATE_CROUCH;
24662479
else
2467-
return MOVEMENTSTATE_CRAWL;
2480+
return (cs.LeftStickX != 0 && cs.RightShoulder1 != 0) ? MOVEMENTSTATE_ROLL : MOVEMENTSTATE_CRAWL;
24682481
}
24692482
}
2483+
24702484
return MOVEMENTSTATE_UNKNOWN;
24712485
}
24722486

@@ -6119,7 +6133,7 @@ bool CClientPed::ShouldBeStealthAiming()
61196133
{
61206134
// We need to be either crouched, walking or standing
61216135
SBindableGTAControl* pWalkControl = pKeyBinds->GetBindableFromControl("walk");
6122-
if (m_pPlayerPed->GetRunState() == 1 || m_pPlayerPed->GetRunState() == 4 || pWalkControl && pWalkControl->bState)
6136+
if (m_pPlayerPed->GetMoveState() == PedMoveState::PEDMOVE_STILL || m_pPlayerPed->GetMoveState() == PedMoveState::PEDMOVE_WALK || pWalkControl && pWalkControl->bState)
61236137
{
61246138
// Do we have a target ped?
61256139
CClientPed* pTargetPed = GetTargetedPed();

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,22 @@ enum eBodyPart
6666
enum eMovementState
6767
{
6868
MOVEMENTSTATE_UNKNOWN,
69-
MOVEMENTSTATE_STAND, // Standing still
70-
MOVEMENTSTATE_WALK, // Walking
71-
MOVEMENTSTATE_POWERWALK, // Walking quickly
72-
MOVEMENTSTATE_JOG, // Jogging
73-
MOVEMENTSTATE_SPRINT, // Sprinting
74-
MOVEMENTSTATE_CROUCH, // Crouching still
75-
MOVEMENTSTATE_CRAWL, // Crouch-moving
76-
MOVEMENTSTATE_ROLL, // Crouch-rolling (Needs adding)
77-
MOVEMENTSTATE_JUMP, // Jumping
78-
MOVEMENTSTATE_FALL, // Falling
79-
MOVEMENTSTATE_CLIMB // Climbing
69+
MOVEMENTSTATE_STAND, // Standing still
70+
MOVEMENTSTATE_WALK, // Walking
71+
MOVEMENTSTATE_POWERWALK, // Walking quickly
72+
MOVEMENTSTATE_JOG, // Jogging (Unused)
73+
MOVEMENTSTATE_SPRINT, // Sprinting
74+
MOVEMENTSTATE_CROUCH, // Crouching still
75+
MOVEMENTSTATE_CRAWL, // Crouch-moving
76+
MOVEMENTSTATE_ROLL, // Crouch-rolling
77+
MOVEMENTSTATE_JUMP, // Jumping
78+
MOVEMENTSTATE_FALL, // Falling
79+
MOVEMENTSTATE_CLIMB, // Climbing
80+
MOVEMENTSTATE_SWIM, // Swimming
81+
MOVEMENTSTATE_WALK_TO_POINT, // Entering vehicle (walking to the door)
82+
MOVEMENTSTATE_ASCENT_JETPACK, // Ascending with jetpack
83+
MOVEMENTSTATE_DESCENT_JETPACK, // Descending with jetpack
84+
MOVEMENTSTATE_JETPACK, // Jetpack flying
8085
};
8186

8287
enum eDeathAnims

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,38 @@ void CPacketHandler::Packet_PlayerList(NetBitStreamInterface& bitStream)
10001000
pPlayer->GiveWeapon(static_cast<eWeaponType>(weaponType.data.ucWeaponType), 1);
10011001
}
10021002
}
1003+
1004+
// Animation
1005+
if (bitStream.ReadBit())
1006+
{
1007+
std::string blockName, animName;
1008+
int time, blendTime;
1009+
bool looped, updatePosition, interruptable, freezeLastFrame, taskRestore;
1010+
float speed;
1011+
double startTime;
1012+
1013+
// Read data
1014+
bitStream.ReadString(blockName);
1015+
bitStream.ReadString(animName);
1016+
bitStream.Read(time);
1017+
bitStream.ReadBit(looped);
1018+
bitStream.ReadBit(updatePosition);
1019+
bitStream.ReadBit(interruptable);
1020+
bitStream.ReadBit(freezeLastFrame);
1021+
bitStream.Read(blendTime);
1022+
bitStream.ReadBit(taskRestore);
1023+
bitStream.Read(startTime);
1024+
bitStream.Read(speed);
1025+
1026+
// Run anim
1027+
CStaticFunctionDefinitions::SetPedAnimation(*pPlayer, blockName, animName.c_str(), time, blendTime, looped, updatePosition, interruptable,
1028+
freezeLastFrame);
1029+
pPlayer->m_AnimationCache.startTime = static_cast<std::int64_t>(startTime);
1030+
pPlayer->m_AnimationCache.speed = speed;
1031+
pPlayer->m_AnimationCache.progress = 0.0f;
1032+
1033+
pPlayer->SetHasSyncedAnim(true);
1034+
}
10031035
}
10041036

10051037
// Set move anim even if not spawned
@@ -3219,18 +3251,10 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
32193251
SRotationDegreesSync rotationDegrees(false);
32203252
bitStream.Read(&rotationDegrees);
32213253

3222-
// Read out the vehicle value as a char, then convert
3223-
unsigned char ucModel = 0xFF;
3224-
bitStream.Read(ucModel);
3225-
3226-
// The server appears to subtract 400 from the vehicle id before
3227-
// sending it to us, as to allow the value to fit into an unsigned
3228-
// char.
3229-
//
3230-
// Too bad this was never documented.
3231-
//
3232-
// --slush
3233-
unsigned short usModel = ucModel + 400;
3254+
// Read out the vehicle model
3255+
std::uint16_t usModel = 0xFFFF;
3256+
bitStream.Read(usModel);
3257+
32343258
if (!CClientVehicleManager::IsValidModel(usModel))
32353259
{
32363260
RaiseEntityAddError(39);

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ bool MinClientReqCheck(CScriptArgReader& argStream, const char* szVersionReq, co
12721272
{
12731273
if (pResource->GetMinClientReq() < szVersionReq)
12741274
{
1275-
#if MTASA_VERSION_TYPE < VERSION_TYPE_UNTESTED
1275+
#if MTASA_VERSION_TYPE >= VERSION_TYPE_UNTESTED
12761276
if (szReason)
12771277
argStream.SetVersionWarning(szVersionReq, "client", szReason);
12781278
#endif
@@ -1299,7 +1299,7 @@ void MinClientReqCheck(lua_State* luaVM, const char* szVersionReq, const char* s
12991299

13001300
if (pResource->GetMinClientReq() < szVersionReq)
13011301
{
1302-
#if MTASA_VERSION_TYPE < VERSION_TYPE_UNTESTED
1302+
#if MTASA_VERSION_TYPE >= VERSION_TYPE_UNTESTED
13031303
SString err("<min_mta_version> section in the meta.xml is incorrect or missing (expected at least client %s because %s)",
13041304
szVersionReq, szReason);
13051305
throw std::invalid_argument(err);

Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4495,6 +4495,17 @@ bool CLuaVehicleDefs::SetVehicleModelAudioSetting(const uint32_t uiModel, const
44954495
return false;
44964496
}
44974497

4498+
auto iter = g_pClientGame->GetVehicleManager()->IterBegin();
4499+
auto end = g_pClientGame->GetVehicleManager()->IterEnd();
4500+
for (; iter != end; ++iter)
4501+
{
4502+
CClientVehicle* pVehicle = *iter;
4503+
if (pVehicle && pVehicle->GetModel() == uiModel)
4504+
{
4505+
pVehicle->ApplyAudioSettings();
4506+
}
4507+
}
4508+
44984509
return true;
44994510
}
45004511

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,10 @@ void CMultiplayerSA::InitHooks()
15831583
MemCpy((void*)0x72565A, "\xDD\xD8\x90", 3);
15841584
MemCpy((void*)0x7259B0, "\xDD\xD8\x90", 3);
15851585
MemSet((void*)0x7258B8, 0x90, 6);
1586+
1587+
// Disable spreading fires (Moved from multiplayer_shotsync)
1588+
MemCpy((void*)0x53A23F, "\x33\xC0\x90\x90\x90", 5);
1589+
MemCpy((void*)0x53A00A, "\x33\xC0\x90\x90\x90", 5);
15861590

15871591
InitHooks_CrashFixHacks();
15881592
InitHooks_DeviceSelection();

0 commit comments

Comments
 (0)