Skip to content

Commit 46983e7

Browse files
authored
Merge branch 'master' into patch-5
2 parents d656704 + c939378 commit 46983e7

File tree

64 files changed

+96944
-96590
lines changed

Some content is hidden

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

64 files changed

+96944
-96590
lines changed

Client/core/CConnectManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13-
#include "net/packetenums.h"
13+
#include "net/Packets.h"
1414
using namespace std;
1515

1616
static CConnectManager* g_pConnectManager = NULL;

Client/core/CMainMenu.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
#define CORE_MTA_DISABLED_ALPHA 0.4f
4141
#define CORE_MTA_ENABLED_ALPHA 1.0f
4242

43-
#define CORE_MTA_ANIMATION_TIME 200
43+
#define CORE_MTA_ANIMATION_TIME_IN 200
44+
#define CORE_MTA_ANIMATION_TIME_OUT 100
4445
#define CORE_MTA_MOVE_ANIM_TIME 600
4546

4647
#define CORE_MTA_STATIC_BG "cgui\\images\\background.png"
@@ -517,11 +518,9 @@ void CMainMenu::Update()
517518

518519
if (m_pHoveredItem)
519520
{
520-
float fProgress = (m_pHoveredItem->image->GetAlpha() - CORE_MTA_NORMAL_ALPHA) / (CORE_MTA_HOVER_ALPHA - CORE_MTA_NORMAL_ALPHA);
521-
// Let's work out what the target progress should be by working out the time passed
522-
fProgress = ((float)ulTimePassed / CORE_MTA_ANIMATION_TIME) * (CORE_MTA_HOVER_ALPHA - CORE_MTA_NORMAL_ALPHA) + fProgress;
521+
float progress = m_pHoveredItem->animProgress + ((float)ulTimePassed / CORE_MTA_ANIMATION_TIME_IN);
523522
MapRemove(m_unhoveredItems, m_pHoveredItem);
524-
SetItemHoverProgress(m_pHoveredItem, fProgress, true);
523+
SetItemHoverProgress(m_pHoveredItem, progress, true);
525524
}
526525
}
527526
else if (m_pHoveredItem)
@@ -534,11 +533,10 @@ void CMainMenu::Update()
534533
std::set<sMenuItem*>::iterator it = m_unhoveredItems.begin();
535534
while (it != m_unhoveredItems.end())
536535
{
537-
float fProgress = ((*it)->image->GetAlpha() - CORE_MTA_NORMAL_ALPHA) / (CORE_MTA_HOVER_ALPHA - CORE_MTA_NORMAL_ALPHA);
538536
// Let's work out what the target progress should be by working out the time passed
539537
// Min of 0.5 progress fixes occasional graphical glitchekal
540-
fProgress = fProgress - std::min(0.5f, ((float)ulTimePassed / CORE_MTA_ANIMATION_TIME) * (CORE_MTA_HOVER_ALPHA - CORE_MTA_NORMAL_ALPHA));
541-
if (SetItemHoverProgress((*it), fProgress, false))
538+
float newProgress = (*it)->animProgress - std::min(0.5f, ((float)ulTimePassed / CORE_MTA_ANIMATION_TIME_OUT) * (CORE_MTA_HOVER_ALPHA - CORE_MTA_NORMAL_ALPHA));
539+
if (SetItemHoverProgress((*it), newProgress, false))
542540
{
543541
std::set<sMenuItem*>::iterator itToErase = it++;
544542
m_unhoveredItems.erase(itToErase);
@@ -1101,8 +1099,10 @@ bool CMainMenu::SetItemHoverProgress(sMenuItem* pItem, float fProgress, bool bHo
11011099
{
11021100
fProgress = Clamp<float>(0, fProgress, 1);
11031101

1104-
// Use OutQuad equation for easing, or OutQuad for unhovering
1105-
fProgress = bHovering ? -fProgress * (fProgress - 2) : fProgress * fProgress;
1102+
pItem->animProgress = fProgress;
1103+
1104+
// Always use OutQuad for both hovering and unhovering, to avoid animation glitches.
1105+
fProgress = -fProgress * (fProgress - 2);
11061106

11071107
// Work out the target scale
11081108
float fTargetScale = (CORE_MTA_HOVER_SCALE - CORE_MTA_NORMAL_SCALE) * (fProgress) + CORE_MTA_NORMAL_SCALE;
@@ -1121,7 +1121,7 @@ bool CMainMenu::SetItemHoverProgress(sMenuItem* pItem, float fProgress, bool bHo
11211121
pItem->image->SetSize(CVector2D(iSizeX, iSizeY), false);
11221122

11231123
// Return whether the hovering has maxed out
1124-
return bHovering ? (fProgress == 1) : (fProgress == 0);
1124+
return bHovering ? (pItem->animProgress >= 1.0) : (pItem->animProgress <= 0.0f);
11251125
}
11261126

11271127
void CMainMenu::SetNewsHeadline(int iIndex, const SString& strHeadline, const SString& strDate, bool bIsNew)

Client/core/CMainMenu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct sMenuItem
3333
int nativeSizeX;
3434
int nativeSizeY;
3535
CGUIStaticImage* image;
36+
float animProgress{};
3637
};
3738

3839
class CMainMenu

Client/core/CModManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ bool CModManager::TryStart()
165165
DWORD size = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorCode,
166166
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPSTR>(&buffer), 0, nullptr);
167167

168-
if (size > 0)
168+
if (buffer != nullptr && size > 0)
169169
{
170-
LocalFree(buffer);
171-
172170
std::string message{buffer, size};
173171
size_t length = message.find_last_not_of("\t\n\v\f\r ");
174172

173+
LocalFree(buffer);
174+
175175
if (length == std::string::npos)
176176
return false;
177177

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "MemSA.h"
2020
#include "CVehicleSA.h"
2121
#include "CBuildingRemovalSA.h"
22+
#include "CPlayerPedSA.h"
2223

2324
extern CGameSA* pGame;
2425

@@ -372,7 +373,9 @@ void CBuildingsPoolSA::RemovePedsContactEnityLinks()
372373
ped->pLastContactedEntity[2] = nullptr;
373374
ped->pLastContactedEntity[3] = nullptr;
374375
ped->m_ucCollisionState = 0;
375-
ped->pTargetedEntity = nullptr;
376+
377+
if (auto* playerPed = dynamic_cast<CPlayerPedSA*>(pedLinks->pEntity))
378+
playerPed->SetTargetedEntity(nullptr);
376379
}
377380
}
378381
}

Client/game_sa/CPedSA.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,6 @@ CEntity* CPedSA::GetContactEntity() const
380380
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(contactInterface));
381381
}
382382

383-
CEntity* CPedSA::GetTargetedEntity() const
384-
{
385-
CEntitySAInterface* targetInterface = GetPedInterface()->pTargetedEntity;
386-
if (!targetInterface)
387-
return nullptr;
388-
389-
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(targetInterface));
390-
}
391-
392-
void CPedSA::SetTargetedEntity(CEntity* targetEntity)
393-
{
394-
GetPedInterface()->pTargetedEntity = targetEntity ? targetEntity->GetInterface() : nullptr;
395-
}
396-
397383
void CPedSA::RemoveBodyPart(std::uint8_t boneID, std::uint8_t direction)
398384
{
399385
// char __thiscall CPed::RemoveBodyPart(CPed *this, int boneID, int localDir)

Client/game_sa/CPedSA.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class CPedSAInterface : public CPhysicalSAInterface
324324
int unk_75C;
325325
std::uint8_t lastWeaponDamage;
326326
std::uint8_t unk_761[3];
327-
CEntitySAInterface* pTargetedEntity;
327+
CEntitySAInterface* lastDamagedEntity;
328328
std::int16_t unk_768;
329329

330330
CVector vecTurretOffset;
@@ -424,9 +424,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
424424

425425
int GetRunState() const override { return GetPedInterface()->moveState; }
426426

427-
CEntity* GetTargetedEntity() const override;
428-
void SetTargetedEntity(CEntity* targetEntity) override;
429-
430427
bool GetCanBeShotInVehicle() const override{ return GetPedInterface()->pedFlags.bCanBeShotInVehicle; }
431428
bool GetTestForShotInVehicle() const override { return GetPedInterface()->pedFlags.bTestForShotInVehicle; }
432429

Client/game_sa/CPlayerPedSA.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,20 @@ void CPlayerPedSA::SetMoveAnim(eMoveAnim iAnimGroup)
300300
}
301301
}
302302

303+
CEntity* CPlayerPedSA::GetTargetedEntity() const
304+
{
305+
CEntitySAInterface* targetInterface = GetPlayerPedInterface()->mouseTargetEntity;
306+
if (!targetInterface)
307+
return nullptr;
308+
309+
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(targetInterface));
310+
}
311+
312+
void CPlayerPedSA::SetTargetedEntity(CEntity* targetEntity)
313+
{
314+
GetPlayerPedInterface()->mouseTargetEntity = targetEntity ? targetEntity->GetInterface() : nullptr;
315+
}
316+
303317
////////////////////////////////////////////////////////////////
304318
//
305319
// Hooks for CPlayerPedSA

Client/game_sa/CPlayerPedSA.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828

2929
#define SIZEOF_CPLAYERPED 1956
3030

31-
class CPlayerPedSAInterface : public CPedSAInterface // CPlayerPed 1956 bytes in SA
31+
class CPlayerPedSAInterface : public CPedSAInterface
3232
{
3333
public:
34+
CEntitySAInterface* mouseTargetEntity;
35+
std::uint8_t field_7A0[4];
3436
};
37+
static_assert(sizeof(CPlayerPedSAInterface) == 0x7A4, "Invalid size for CPlayerPedSAInterface");
3538

3639
class CPlayerPedSA : public virtual CPlayerPed, public virtual CPedSA
3740
{
@@ -52,7 +55,10 @@ class CPlayerPedSA : public virtual CPlayerPed, public virtual CPedSA
5255
eMoveAnim GetMoveAnim();
5356
void SetMoveAnim(eMoveAnim iAnimGroup);
5457

55-
CPlayerPedSAInterface* GetPlayerPedInterface() { return static_cast<CPlayerPedSAInterface*>(m_pInterface); };
58+
CEntity* GetTargetedEntity() const override;
59+
void SetTargetedEntity(CEntity* targetEntity) override;
60+
61+
CPlayerPedSAInterface* GetPlayerPedInterface() const noexcept { return static_cast<CPlayerPedSAInterface*>(m_pInterface); };
5662

5763
static void StaticSetHooks();
5864
};

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
//
1515

1616
IMPLEMENT_ENUM_BEGIN(eLuaType)
17-
ADD_ENUM(LUA_TNONE, "none")
18-
ADD_ENUM(LUA_TNIL, "nil")
19-
ADD_ENUM(LUA_TBOOLEAN, "boolean")
20-
ADD_ENUM(LUA_TLIGHTUSERDATA, "lightuserdata")
21-
ADD_ENUM(LUA_TNUMBER, "number")
22-
ADD_ENUM(LUA_TSTRING, "string")
23-
ADD_ENUM(LUA_TTABLE, "table")
24-
ADD_ENUM(LUA_TFUNCTION, "function")
25-
ADD_ENUM(LUA_TUSERDATA, "userdata")
26-
ADD_ENUM(LUA_TTHREAD, "thread")
17+
ADD_ENUM(static_cast<eLuaType>(LUA_TNONE), "none")
18+
ADD_ENUM(static_cast<eLuaType>(LUA_TNIL), "nil")
19+
ADD_ENUM(static_cast<eLuaType>(LUA_TBOOLEAN), "boolean")
20+
ADD_ENUM(static_cast<eLuaType>(LUA_TLIGHTUSERDATA), "lightuserdata")
21+
ADD_ENUM(static_cast<eLuaType>(LUA_TNUMBER), "number")
22+
ADD_ENUM(static_cast<eLuaType>(LUA_TSTRING), "string")
23+
ADD_ENUM(static_cast<eLuaType>(LUA_TTABLE), "table")
24+
ADD_ENUM(static_cast<eLuaType>(LUA_TFUNCTION), "function")
25+
ADD_ENUM(static_cast<eLuaType>(LUA_TUSERDATA), "userdata")
26+
ADD_ENUM(static_cast<eLuaType>(LUA_TTHREAD), "thread")
2727
IMPLEMENT_ENUM_END("lua-type")
2828

2929
IMPLEMENT_ENUM_BEGIN(CGUIVerticalAlign)
@@ -715,15 +715,15 @@ IMPLEMENT_ENUM_CLASS_END("client-model-type")
715715

716716
// Sound effects
717717
IMPLEMENT_ENUM_BEGIN(eSoundEffectType)
718-
ADD_ENUM(BASS_FX_DX8_CHORUS, "chorus")
719-
ADD_ENUM(BASS_FX_DX8_COMPRESSOR, "compressor")
720-
ADD_ENUM(BASS_FX_DX8_DISTORTION, "distortion")
721-
ADD_ENUM(BASS_FX_DX8_ECHO, "echo")
722-
ADD_ENUM(BASS_FX_DX8_FLANGER, "flanger")
723-
ADD_ENUM(BASS_FX_DX8_GARGLE, "gargle")
724-
ADD_ENUM(BASS_FX_DX8_I3DL2REVERB, "i3dl2reverb")
725-
ADD_ENUM(BASS_FX_DX8_PARAMEQ, "parameq")
726-
ADD_ENUM(BASS_FX_DX8_REVERB, "reverb")
718+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_CHORUS), "chorus")
719+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_COMPRESSOR), "compressor")
720+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_DISTORTION), "distortion")
721+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_ECHO), "echo")
722+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_FLANGER), "flanger")
723+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_GARGLE), "gargle")
724+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_I3DL2REVERB), "i3dl2reverb")
725+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_PARAMEQ), "parameq")
726+
ADD_ENUM(static_cast<eSoundEffectType>(BASS_FX_DX8_REVERB), "reverb")
727727
IMPLEMENT_ENUM_END("soundeffect-type")
728728

729729
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Chorus)

0 commit comments

Comments
 (0)