Skip to content

Commit 4047184

Browse files
authored
Merge branch 'master' into attach
2 parents 2fddd18 + 5cdc04d commit 4047184

File tree

789 files changed

+14678
-11259
lines changed

Some content is hidden

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

789 files changed

+14678
-11259
lines changed

Client/cefweb/CWebView.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,9 @@ bool CWebView::OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin
996996
// //
997997
// //
998998
////////////////////////////////////////////////////////////////////
999-
bool CWebView::OnFileDialog(CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode, const CefString& title, const CefString& default_file_path,
1000-
const std::vector<CefString>& accept_filters, CefRefPtr<CefFileDialogCallback> callback)
999+
bool CWebView::OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode, const CefString& title, const CefString& default_file_path,
1000+
const std::vector<CefString>& accept_filters, const std::vector<CefString>& accept_extensions, const std::vector<CefString>& accept_descriptions,
1001+
CefRefPtr<CefFileDialogCallback> callback)
10011002
{
10021003
// Don't show the dialog
10031004
return true;

Client/cefweb/CWebView.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ class CWebView : public CWebViewInterface,
164164
bool& suppress_message) override;
165165

166166
// CefDialogHandler methods
167-
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode, const CefString& title, const CefString& default_file_path,
168-
const std::vector<CefString>& accept_filters, CefRefPtr<CefFileDialogCallback> callback) override;
167+
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode, const CefString& title, const CefString& default_file_path,
168+
const std::vector<CefString>& accept_filters, const std::vector<CefString>& accept_extensions, const std::vector<CefString>& accept_descriptions,
169+
CefRefPtr<CefFileDialogCallback> callback) override;
169170

170171
// CefDisplayHandler methods
171172
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title) override;

Client/core/CCore.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,19 @@ void CCore::UpdateRecentlyPlayed()
17871787
CCore::GetSingleton().SaveConfig();
17881788
}
17891789

1790+
void CCore::OnPostColorFilterRender()
1791+
{
1792+
if (!CGraphics::GetSingleton().HasLine3DPostFXQueueItems() && !CGraphics::GetSingleton().HasPrimitive3DPostFXQueueItems())
1793+
return;
1794+
1795+
CGraphics::GetSingleton().EnteringMTARenderZone();
1796+
1797+
CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
1798+
CGraphics::GetSingleton().DrawLine3DPostFXQueue();
1799+
1800+
CGraphics::GetSingleton().LeavingMTARenderZone();
1801+
}
1802+
17901803
void CCore::ApplyCoreInitSettings()
17911804
{
17921805
#if (_WIN32_WINNT >= _WIN32_WINNT_LONGHORN) // Windows Vista
@@ -2010,22 +2023,6 @@ void CCore::OnPreFxRender()
20102023
//
20112024
void CCore::OnPreHUDRender()
20122025
{
2013-
IDirect3DDevice9* pDevice = CGraphics::GetSingleton().GetDevice();
2014-
2015-
if (CGraphics::GetSingleton().HasLine3DPostFXQueueItems() || CGraphics::GetSingleton().HasPrimitive3DPostFXQueueItems())
2016-
{
2017-
/*
2018-
Although MTA render zones are expensive, we should use them twice in the bounds of the function
2019-
because some of render states from PostFX drain to the 2D part of the frame.
2020-
*/
2021-
CGraphics::GetSingleton().EnteringMTARenderZone();
2022-
2023-
CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue();
2024-
CGraphics::GetSingleton().DrawLine3DPostFXQueue();
2025-
2026-
CGraphics::GetSingleton().LeavingMTARenderZone();
2027-
}
2028-
20292026
CGraphics::GetSingleton().EnteringMTARenderZone();
20302027

20312028
// Maybe capture screen and other stuff

Client/core/CCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
289289
const SString& GetLastConnectedServerName() const { return m_strLastConnectedServerName; }
290290
void SetLastConnectedServerName(const SString& strServerName) { m_strLastConnectedServerName = strServerName; }
291291

292+
void OnPostColorFilterRender() override;
293+
292294
private:
293295
void ApplyCoreInitSettings();
294296

Client/core/premake5.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ project "Client Core"
1616
"../sdk",
1717
"../../vendor/tinygettext",
1818
"../../vendor/zlib",
19-
"../../vendor/jpeg-9e",
19+
"../../vendor/jpeg-9f",
2020
"../../vendor/pthreads/include",
2121
"../../vendor/sparsehash/src/",
2222
"../../vendor/detours/4.0.1/src",

Client/game_sa/CAnimManagerSA.cpp

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
5-
* FILE: game_sa/CAnimManagerSA.cpp
5+
* FILE: Client/game_sa/CAnimManagerSA.cpp
66
* PURPOSE: Animation manager
77
*
8-
* Multi Theft Auto is available from http://www.multitheftauto.com/
8+
* Multi Theft Auto is available from https://multitheftauto.com/
99
*
1010
*****************************************************************************/
1111

@@ -21,7 +21,14 @@
2121

2222
extern CGameSA* pGame;
2323

24-
using std::list;
24+
// This "gateway" animation will allow us to play custom animations by simply playing this animation
25+
// and then in AddAnimation and AddAnimationAndSync hook, we can return our custom animation in the
26+
// hook instead of run_wuzi. This will trick GTA SA into thinking that it is playing run_wuzi from
27+
// ped block, but in reality, it's playing our custom animation, and Of course, we can return run_wuzi
28+
// animation within the hook if we want to play it instead. Why run_wuzi? We can also use another animation,
29+
// but I've tested with this one mostly, so let's stick to this.
30+
static const char* const kGateWayBlockName = "ped";
31+
static const char* const kGateWayAnimationName = "run_wuzi";
2532

2633
CAnimManagerSA::CAnimManagerSA()
2734
{
@@ -195,7 +202,7 @@ int CAnimManagerSA::RegisterAnimBlock(const char* szName)
195202
return iReturn;
196203
}
197204

198-
std::unique_ptr<CAnimBlendAssocGroup> CAnimManagerSA::GetAnimBlendAssoc(AssocGroupId groupID)
205+
std::unique_ptr<CAnimBlendAssocGroup> CAnimManagerSA::GetAnimBlendAssoc(AssocGroupId groupID) const
199206
{
200207
CAnimBlendAssocGroupSAInterface* pInterface = nullptr;
201208
DWORD dwFunc = FUNC_CAnimManager_GetAnimBlendAssoc;
@@ -274,8 +281,12 @@ std::unique_ptr<CAnimBlendAssociation> CAnimManagerSA::CreateAnimAssociation(Ass
274281
return nullptr;
275282
}
276283

277-
CAnimManagerSA::StaticAssocIntface_type CAnimManagerSA::GetAnimStaticAssociation(eAnimGroup animGroup, eAnimID animID)
284+
CAnimManagerSA::StaticAssocIntface_type CAnimManagerSA::GetAnimStaticAssociation(eAnimGroup animGroup, eAnimID animID) const
278285
{
286+
// We check the validity of the group, avoid crashes due to an invalid group
287+
if (!IsValidGroup(static_cast<std::uint32_t>(animGroup)))
288+
return nullptr;
289+
279290
CAnimBlendStaticAssociationSAInterface* pInterface = nullptr;
280291
DWORD dwFunc = FUNC_CAnimManager_GetAnimAssociation;
281292
_asm
@@ -295,6 +306,10 @@ CAnimManagerSA::StaticAssocIntface_type CAnimManagerSA::GetAnimStaticAssociation
295306

296307
std::unique_ptr<CAnimBlendAssociation> CAnimManagerSA::GetAnimAssociation(AssocGroupId animGroup, const char* szAnimName)
297308
{
309+
// We check the validity of the group, avoid crashes due to an invalid group
310+
if (!IsValidGroup(animGroup))
311+
return nullptr;
312+
298313
CAnimBlendAssociationSAInterface* pInterface = nullptr;
299314
DWORD dwFunc = FUNC_CAnimManager_GetAnimAssociation_str;
300315
_asm
@@ -363,7 +378,7 @@ std::unique_ptr<CAnimBlendAssociation> CAnimManagerSA::AddAnimationAndSync(RpClu
363378
AnimationId animID)
364379
{
365380
if (!pClump)
366-
return NULL;
381+
return nullptr;
367382

368383
CAnimBlendAssociationSAInterface* pInterface = nullptr;
369384
DWORD dwFunc = FUNC_CAnimManager_AddAnimationAndSync;
@@ -387,8 +402,8 @@ std::unique_ptr<CAnimBlendAssociation> CAnimManagerSA::AddAnimationAndSync(RpClu
387402

388403
std::unique_ptr<CAnimBlendAssociation> CAnimManagerSA::BlendAnimation(RpClump* pClump, AssocGroupId animGroup, AnimationId animID, float fBlendDelta)
389404
{
390-
if (!pClump)
391-
return NULL;
405+
if (!pClump || !IsValidAnim(animGroup, animID))
406+
return nullptr;
392407

393408
CAnimBlendAssociationSAInterface* pInterface = nullptr;
394409
DWORD dwFunc = FUNC_CAnimManager_BlendAnimation;
@@ -495,7 +510,10 @@ void CAnimManagerSA::RemoveAnimBlock(int ID)
495510
AnimAssocDefinition* CAnimManagerSA::AddAnimAssocDefinition(const char* szBlockName, const char* szAnimName, AssocGroupId animGroup, AnimationId animID,
496511
AnimDescriptor* pDescriptor)
497512
{
498-
AnimAssocDefinition* pReturn;
513+
if (!IsValidAnim(animGroup, animID))
514+
return nullptr;
515+
516+
AnimAssocDefinition* pReturn{};
499517
DWORD dwFunc = FUNC_CAnimManager_AddAnimAssocDefinition;
500518
_asm
501519
{
@@ -508,7 +526,7 @@ AnimAssocDefinition* CAnimManagerSA::AddAnimAssocDefinition(const char* szBlockN
508526
mov pReturn, eax
509527
add esp, 0x14
510528
}
511-
return NULL;
529+
return pReturn;
512530
}
513531

514532
void CAnimManagerSA::ReadAnimAssociationDefinitions()
@@ -849,5 +867,33 @@ void CAnimManagerSA::DeleteCustomAnimSequenceInterface(CAnimBlendSequenceSAInter
849867

850868
bool CAnimManagerSA::isGateWayAnimationHierarchy(CAnimBlendHierarchySAInterface* pInterface)
851869
{
852-
return pGame->GetKeyGen()->GetUppercaseKey(m_kGateWayAnimationName.c_str()) == pInterface->uiHashKey;
870+
return pGame->GetKeyGen()->GetUppercaseKey(kGateWayAnimationName) == pInterface->uiHashKey;
871+
}
872+
873+
const char* CAnimManagerSA::GetGateWayBlockName() const
874+
{
875+
return kGateWayBlockName;
876+
}
877+
878+
const char* CAnimManagerSA::GetGateWayAnimationName() const
879+
{
880+
return kGateWayAnimationName;
881+
}
882+
883+
bool CAnimManagerSA::IsValidGroup(std::uint32_t uiAnimGroup) const
884+
{
885+
const auto pGroup = GetAnimBlendAssoc(uiAnimGroup);
886+
return pGroup && pGroup->IsCreated();
887+
}
888+
889+
bool CAnimManagerSA::IsValidAnim(std::uint32_t uiAnimGroup, std::uint32_t uiAnimID) const
890+
{
891+
// We get an animation for the checks
892+
const auto pAnim = GetAnimStaticAssociation((eAnimGroup)uiAnimGroup, (eAnimID)uiAnimID);
893+
if (!pAnim)
894+
return false;
895+
896+
// We check the interface and sAnimID, if AnimID is not in GTA:SA, it will differ from our indicators in sAnimID
897+
const auto pInterface = pAnim->GetInterface();
898+
return pInterface && pInterface->sAnimID == uiAnimID;
853899
}

Client/game_sa/CAnimManagerSA.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
5-
* FILE: game_sa/CAnimManagerSA.h
5+
* FILE: Client/game_sa/CAnimManagerSA.h
66
* PURPOSE: Header file for animation manager class
77
*
8-
* Multi Theft Auto is available from http://www.multitheftauto.com/
8+
* Multi Theft Auto is available from https://multitheftauto.com/
99
*
1010
*****************************************************************************/
1111

@@ -94,14 +94,14 @@ class CAnimManagerSA : public CAnimManager
9494
int GetAnimationBlockIndex(const char* szName);
9595
int RegisterAnimBlock(const char* szName);
9696

97-
std::unique_ptr<CAnimBlendAssocGroup> GetAnimBlendAssoc(AssocGroupId groupID);
97+
std::unique_ptr<CAnimBlendAssocGroup> GetAnimBlendAssoc(AssocGroupId groupID) const;
9898
AssocGroupId GetFirstAssocGroup(const char* szName);
9999

100100
const char* GetAnimGroupName(AssocGroupId groupID);
101101
const char* GetAnimBlockName(AssocGroupId groupID);
102102

103103
std::unique_ptr<CAnimBlendAssociation> CreateAnimAssociation(AssocGroupId animGroup, AnimationId animID);
104-
StaticAssocIntface_type GetAnimStaticAssociation(eAnimGroup animGroup, eAnimID animID);
104+
StaticAssocIntface_type GetAnimStaticAssociation(eAnimGroup animGroup, eAnimID animID) const;
105105
std::unique_ptr<CAnimBlendAssociation> GetAnimAssociation(AssocGroupId animGroup, const char* szAnimName);
106106
std::unique_ptr<CAnimBlendAssociation> AddAnimation(RpClump* pClump, AssocGroupId animGroup, AnimationId animID);
107107
std::unique_ptr<CAnimBlendAssociation> AddAnimation(RpClump* pClump, CAnimBlendHierarchy*, int ID);
@@ -159,20 +159,13 @@ class CAnimManagerSA : public CAnimManager
159159
void DeleteCustomAnimHierarchyInterface(CAnimBlendHierarchySAInterface* pInterface);
160160
void DeleteCustomAnimSequenceInterface(CAnimBlendSequenceSAInterface* pInterface);
161161

162-
bool isGateWayAnimationHierarchy(CAnimBlendHierarchySAInterface* pInterface);
163-
const SString& GetGateWayBlockName() { return m_kGateWayBlockName; };
164-
const SString& GetGateWayAnimationName() { return m_kGateWayAnimationName; };
162+
bool isGateWayAnimationHierarchy(CAnimBlendHierarchySAInterface* pInterface);
163+
const char* GetGateWayBlockName() const;
164+
const char* GetGateWayAnimationName() const;
165165

166+
bool IsValidGroup(std::uint32_t uiAnimGroup) const;
167+
bool IsValidAnim(std::uint32_t uiAnimGroup, std::uint32_t uiAnimID) const;
166168
private:
167169
CAnimBlendAssocGroup* m_pAnimAssocGroups[MAX_ANIM_GROUPS];
168170
CAnimBlock* m_pAnimBlocks[MAX_ANIM_BLOCKS];
169-
170-
// This "gateway" animation will allow us to play custom animations by simply playing this animation
171-
// and then in AddAnimation and AddAnimationAndSync hook, we can return our custom animation in the
172-
// hook instead of run_wuzi. This will trick GTA SA into thinking that it is playing run_wuzi from
173-
// ped block, but in reality, it's playing our custom animation, and Of course, we can return run_wuzi
174-
// animation within the hook if we want to play it instead. Why run_wuzi? We can also use another animation,
175-
// but I've tested with this one mostly, so let's stick to this.
176-
const SString m_kGateWayBlockName = "ped";
177-
const SString m_kGateWayAnimationName = "run_wuzi";
178171
};

0 commit comments

Comments
 (0)