Skip to content

Commit eacdcd3

Browse files
committed
Merge branch 'bugfix/isPedOnGround' of https://github.com/FileEX/mtasa-blue into bugfix/isPedOnGround
2 parents a0e5e8d + 7d5c2fe commit eacdcd3

File tree

349 files changed

+47406
-6094
lines changed

Some content is hidden

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

349 files changed

+47406
-6094
lines changed

.github/workflows/codeql.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ jobs:
4747
build-mode: none
4848
- language: c-cpp
4949
build-mode: autobuild
50-
- language: javascript-typescript
51-
build-mode: none
52-
- language: python
53-
build-mode: none
5450
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
5551
# Use `c-cpp` to analyze code written in C, C++ or both
5652
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both

Client/core/CSteamClient.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,24 @@ bool CSteamClient::Load()
377377
return false;
378378
}
379379

380+
static auto pAddDllDirectory = ([]() -> decltype(&AddDllDirectory) {
381+
if (const HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); kernel32 != nullptr)
382+
{
383+
return reinterpret_cast<decltype(&AddDllDirectory)>(static_cast<void*>(GetProcAddress(kernel32, "AddDllDirectory")));
384+
}
385+
386+
return nullptr;
387+
})();
388+
389+
if (pAddDllDirectory == nullptr)
390+
{
391+
WriteErrorEvent("Your operating system is outdated and is missing the KB2533623 update package for AddDllDirectory");
392+
return false;
393+
}
394+
380395
WriteDebugEvent(SString("Using steamclient.dll: %s", *ToUTF8(steamClientPath.value())));
381396
SetEnvironmentVariableW(L"SteamAppId", L"" STEAM_GTASA_APP_ID);
382-
AddDllDirectory(steamDirPath.c_str());
397+
pAddDllDirectory(steamDirPath.c_str());
383398
{
384399
static wchar_t pathBuffer[65536];
385400
GetEnvironmentVariableW(L"PATH", pathBuffer, sizeof(pathBuffer) / sizeof(wchar_t));
@@ -425,7 +440,7 @@ bool CSteamClient::Load()
425440

426441
releaseLibraryLock.reset();
427442

428-
Native::CreateInterface = reinterpret_cast<decltype(Native::CreateInterface)>(GetProcAddress(dll, "CreateInterface"));
443+
Native::CreateInterface = reinterpret_cast<decltype(Native::CreateInterface)>(static_cast<void*>(GetProcAddress(dll, "CreateInterface")));
429444

430445
if (!Native::CreateInterface)
431446
{

Client/game_sa/CPoolsSA.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "CWorldSA.h"
2727

2828
#include "enums/VehicleClass.h"
29+
#include <new>
2930

3031
extern CGameSA* pGame;
3132

@@ -242,7 +243,7 @@ CObject* CPoolsSA::AddObject(CClientObject* pClientObject, DWORD dwModelID, bool
242243

243244
if (m_objectPool.ulCount < MAX_OBJECTS)
244245
{
245-
pObject = new CObjectSA(dwModelID, bBreakingDisabled);
246+
pObject = new (std::nothrow) CObjectSA(dwModelID, bBreakingDisabled);
246247

247248
if (pObject && AddObjectToPool(pClientObject, pObject))
248249
{

Client/game_sa/CRenderWareSA.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,18 @@ RpClump* CRenderWareSA::ReadDFF(const SString& strFilename, const SString& buffe
285285

286286
// rockstar's collision hack: set the global particle emitter to the modelinfo pointer of this model
287287
if (bLoadEmbeddedCollisions)
288+
{
289+
// Vehicles have their collision loaded through the CollisionModel plugin, so we need to remove the current collision to prevent a memory leak.
290+
// This needs to be done here before reading the stream data, because plugins are read in RpClumpStreamRead.
291+
CModelInfo* modelInfo = pGame->GetModelInfo(usModelID);
292+
if (modelInfo)
293+
{
294+
if (auto* modelInfoInterface = modelInfo->GetInterface())
295+
((void(__thiscall*)(CBaseModelInfoSAInterface*))0x4C4C40)(modelInfoInterface); // CBaseModelInfo::DeleteCollisionModel
296+
}
297+
288298
RpPrtStdGlobalDataSetStreamEmbedded((void*)pPool[usModelID]);
299+
}
289300

290301
// read the clump with all its extensions
291302
RpClump* pClump = RpClumpStreamRead(streamModel);

Client/game_sa/TaskJumpFallSA.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class CTaskSimpleClimbSAInterface : public CTaskSimpleSAInterface
3131
bool m_bChangePosition;
3232
bool m_bForceClimb;
3333
bool m_bInvalidClimb;
34-
char m_nHeightForAnim;
35-
char m_nHeightForPos;
34+
eClimbHeights m_nHeightForAnim;
35+
eClimbHeights m_nHeightForPos;
3636
unsigned char m_nSurfaceType;
3737
char m_nFallAfterVault;
3838
float m_fHandholdHeading;
@@ -49,6 +49,8 @@ class CTaskSimpleClimbSA : public virtual CTaskSimpleSA, public virtual CTaskSim
4949
CTaskSimpleClimbSA(){};
5050
CTaskSimpleClimbSA(CEntity* pClimbEnt, const CVector& vecTarget, float fHeading, unsigned char nSurfaceType, char nHeight = CLIMB_GRAB,
5151
const bool bForceClimb = false);
52+
53+
eClimbHeights GetHeightForPos() const override { return static_cast<const CTaskSimpleClimbSAInterface*>(GetInterface())->m_nHeightForPos; }
5254
};
5355

5456
// ##############################################################################

Client/loader/Dialogs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ const SDialogItemInfo g_NoAvDialogItems[] = {
101101
_td("MTA could not detect an anti-virus on your PC.\n\n"
102102
"Viruses interfere with MTA and degrade your gameplay experience.\n\n"
103103
"Press 'Help' for more information.")},
104-
{IDC_NOAV_OPT_SKIP, 0, _td("I have already installed an anti-virus")},
105-
{IDC_NOAV_OPT_BOTNET, 0,
104+
{IDC_NOAV_OPT_SKIP, 1, _td("I have already installed an anti-virus")},
105+
{IDC_NOAV_OPT_BOTNET, 1,
106106
_td("I will not install an anti-virus.\n"
107107
"I want my PC to lag and be part of a botnet.")},
108108
{IDC_BUTTON_HELP, 0, dialogStringsHelp},
@@ -618,8 +618,12 @@ void ShowNoAvDialog(HINSTANCE hInstance, bool bEnableScaremongering)
618618
hwndNoAvDialog = CreateDialogW(hInstance, MAKEINTRESOURCEW(IDD_NOAV_DIALOG), 0, DialogProc);
619619
dassert((GetWindowLongW(hwndNoAvDialog, GWL_STYLE) & WS_VISIBLE) == 0); // Should be Visible: False
620620
InitDialogStrings(hwndNoAvDialog, g_NoAvDialogItems);
621-
ShowWindow(GetDlgItem(hwndNoAvDialog, IDC_NOAV_OPT_SKIP), bEnableScaremongering ? SW_HIDE : SW_SHOW);
622-
ShowWindow(GetDlgItem(hwndNoAvDialog, IDC_NOAV_OPT_BOTNET), bEnableScaremongering ? SW_SHOW : SW_HIDE);
621+
const int textSourceItemId = bEnableScaremongering ? IDC_NOAV_OPT_BOTNET : IDC_NOAV_OPT_SKIP;
622+
{
623+
wchar_t text[256] = {};
624+
GetWindowTextW(GetDlgItem(hwndNoAvDialog, textSourceItemId), text, _countof(text));
625+
SetWindowTextW(GetDlgItem(hwndNoAvDialog, IDC_CHECK_NOT_AGAIN), text);
626+
}
623627
}
624628
ShowWindow(hwndNoAvDialog, SW_SHOW); // Show after all changes are complete
625629
SetForegroundWindow(hwndNoAvDialog);

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
241241
m_MovementStateNames[MOVEMENTSTATE_ASCENT_JETPACK] = "ascent_jetpack";
242242
m_MovementStateNames[MOVEMENTSTATE_DESCENT_JETPACK] = "descent_jetpack";
243243
m_MovementStateNames[MOVEMENTSTATE_JETPACK] = "jetpack_flying";
244+
m_MovementStateNames[MOVEMENTSTATE_HANGING] = "hanging";
244245

245246
// Create the player model
246247
if (m_bIsLocalPlayer)
@@ -2426,7 +2427,13 @@ eMovementState CClientPed::GetMovementState()
24262427

24272428
// Check tasks
24282429
if (strcmp(szSimpleTaskName, "TASK_SIMPLE_CLIMB") == 0) // Is he climbing?
2430+
{
2431+
CTaskSimpleClimb* climbingTask = dynamic_cast<CTaskSimpleClimb*>(GetTaskManager()->GetSimplestActiveTask());
2432+
if (climbingTask && climbingTask->GetHeightForPos() == eClimbHeights::CLIMB_GRAB)
2433+
return MOVEMENTSTATE_HANGING;
2434+
24292435
return MOVEMENTSTATE_CLIMB;
2436+
}
24302437
else if (strcmp(szComplexTaskName, "TASK_COMPLEX_JUMP") == 0) // Is he jumping?
24312438
return MOVEMENTSTATE_JUMP;
24322439
else if (strcmp(szSimpleTaskName, "TASK_SIMPLE_GO_TO_POINT") == 0) // Entering vehicle (walking to the doors)?
@@ -4995,10 +5002,7 @@ void CClientPed::DestroySatchelCharges(bool bBlow, bool bDestroy)
49955002
bool bCancelExplosion = !CallEvent("onClientExplosion", Arguments, true);
49965003

49975004
if (!bCancelExplosion)
4998-
{
49995005
m_pManager->GetExplosionManager()->Create(EXP_TYPE_GRENADE, vecPosition, this, true, -1.0f, false, WEAPONTYPE_REMOTE_SATCHEL_CHARGE);
5000-
g_pClientGame->SendExplosionSync(vecPosition, EXP_TYPE_GRENADE, this);
5001-
}
50025006
}
50035007
if (bDestroy)
50045008
{

Client/mods/deathmatch/logic/CClientPed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ enum eMovementState
8282
MOVEMENTSTATE_ASCENT_JETPACK, // Ascending with jetpack
8383
MOVEMENTSTATE_DESCENT_JETPACK, // Descending with jetpack
8484
MOVEMENTSTATE_JETPACK, // Jetpack flying
85+
MOVEMENTSTATE_HANGING, // Hanging from the whall during climbing task
8586
};
8687

8788
enum eDeathAnims

Client/mods/deathmatch/logic/CNetAPI.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,16 @@ void CNetAPI::WritePlayerPuresync(CClientPlayer* pPlayerModel, NetBitStreamInter
11191119
flags.data.bSyncingVelocity = (!flags.data.bIsOnGround || (pPlayerModel->GetPlayerSyncCount() % 4) == 0);
11201120
flags.data.bStealthAiming = (pPlayerModel->IsStealthAiming() == true);
11211121
flags.data.isReloadingWeapon = (pPlayerModel->IsReloadingWeapon() == true);
1122+
flags.data.animInterrupted = pPlayerModel->HasSyncedAnim() && (!pPlayerModel->IsRunningAnimation() || pPlayerModel->m_animationOverridedByClient);
11221123

1123-
if (pPlayerWeapon->GetSlot() > 15)
1124+
// The animation has been overwritten or interrupted by the client
1125+
if (flags.data.animInterrupted)
1126+
{
1127+
pPlayerModel->SetHasSyncedAnim(false);
1128+
pPlayerModel->m_animationOverridedByClient = false;
1129+
}
1130+
1131+
if (flags.data.bHasAWeapon && pPlayerWeapon->GetSlot() > 15)
11241132
flags.data.bHasAWeapon = false;
11251133

11261134
BitStream.Write(&flags);

Client/mods/deathmatch/logic/CResource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void CResource::Load()
258258
m_pResourceTXDRoot->SetParent(m_pResourceEntity);
259259
}
260260

261-
CLogger::LogPrintf("> Starting resource '%s'", *m_strResourceName);
261+
CLogger::LogPrintf("> Starting resource '%s'\n", *m_strResourceName);
262262

263263
// Flag resource files as readable
264264
for (std::list<CResourceConfigItem*>::iterator iter = m_ConfigFiles.begin(); iter != m_ConfigFiles.end(); ++iter)

0 commit comments

Comments
 (0)