Skip to content

Commit d308c45

Browse files
authored
Merge branch 'master' into bugfix/dimension_stream
2 parents 7e72b9f + 6aa763f commit d308c45

File tree

53 files changed

+100760
-100673
lines changed

Some content is hidden

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

53 files changed

+100760
-100673
lines changed

Client/core/CMainMenu.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,14 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
842842
case MENU_ITEM_MAP_EDITOR:
843843
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
844844
return true;
845+
case MENU_ITEM_DISCONNECT:
846+
if (g_pCore->GetCVars()->GetValue("ask_before_disconnect", true))
847+
{
848+
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
849+
return true;
850+
}
851+
852+
break;
845853
default:
846854
break;
847855
}
@@ -863,7 +871,7 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
863871
switch (m_pHoveredItem->menuType)
864872
{
865873
case MENU_ITEM_DISCONNECT:
866-
OnDisconnectButtonClick(pElement);
874+
OnDisconnectButtonClick();
867875
break;
868876
case MENU_ITEM_QUICK_CONNECT:
869877
OnQuickConnectButtonClick(pElement, Args.button == LeftButton);
@@ -948,7 +956,7 @@ void CMainMenu::HideServerInfo()
948956
m_ServerInfo.Hide();
949957
}
950958

951-
bool CMainMenu::OnDisconnectButtonClick(CGUIElement* pElement)
959+
bool CMainMenu::OnDisconnectButtonClick()
952960
{
953961
// Return if we haven't faded in yet
954962
if (m_ucFade != FADE_VISIBLE)
@@ -1251,6 +1259,9 @@ void CMainMenu::WantsToDisconnectCallBack(void* pData, uint uiButton)
12511259
case MENU_ITEM_MAP_EDITOR:
12521260
OnEditorButtonClick();
12531261
break;
1262+
case MENU_ITEM_DISCONNECT:
1263+
OnDisconnectButtonClick();
1264+
break;
12541265
default:
12551266
break;
12561267
}

Client/core/CMainMenu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class CMainMenu
8989
bool OnResumeButtonClick(CGUIElement* pElement);
9090
bool OnBrowseServersButtonClick(CGUIElement* pElement);
9191
bool OnHostGameButtonClick();
92-
bool OnDisconnectButtonClick(CGUIElement* pElement);
92+
bool OnDisconnectButtonClick();
9393
bool OnEditorButtonClick();
9494
bool OnSettingsButtonClick(CGUIElement* pElement);
9595
bool OnAboutButtonClick(CGUIElement* pElement);

Client/core/CSettings.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ void CSettings::CreateGUI()
411411
m_pPhotoSavingCheckbox->GetPosition(vecTemp, false);
412412
m_pPhotoSavingCheckbox->AutoSize(NULL, 20.0f);
413413

414+
m_pCheckBoxAskBeforeDisconnect = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Ask before disconnecting from server using main menu"), true));
415+
m_pCheckBoxAskBeforeDisconnect->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
416+
m_pCheckBoxAskBeforeDisconnect->GetPosition(vecTemp, false);
417+
m_pCheckBoxAskBeforeDisconnect->AutoSize(NULL, 20.0f);
418+
414419
m_pCheckBoxCustomizedSAFiles = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Use customized GTA:SA files"), true));
415420
m_pCheckBoxCustomizedSAFiles->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 20.0f));
416421
m_pCheckBoxCustomizedSAFiles->GetPosition(vecTemp, false);
@@ -3080,6 +3085,10 @@ void CSettings::LoadData()
30803085
CVARS_GET("allow_discord_rpc", bAllowDiscordRPC);
30813086
m_pCheckBoxAllowDiscordRPC->SetSelected(bAllowDiscordRPC);
30823087

3088+
bool bAskBeforeDisconnect;
3089+
CVARS_GET("ask_before_disconnect", bAskBeforeDisconnect);
3090+
m_pCheckBoxAskBeforeDisconnect->SetSelected(bAskBeforeDisconnect);
3091+
30833092
// Customized sa files
30843093
m_pCheckBoxCustomizedSAFiles->SetSelected(GetApplicationSettingInt("customized-sa-files-request") != 0);
30853094
m_pCheckBoxCustomizedSAFiles->SetVisible(GetApplicationSettingInt("customized-sa-files-show") != 0);
@@ -3557,6 +3566,9 @@ void CSettings::SaveData()
35573566
}
35583567
}
35593568

3569+
bool bAskBeforeDisconnect = m_pCheckBoxAskBeforeDisconnect->GetSelected();
3570+
CVARS_SET("ask_before_disconnect", bAskBeforeDisconnect);
3571+
35603572
// Grass
35613573
bool bGrassEnabled = m_pCheckBoxGrass->GetSelected();
35623574
CVARS_SET("grass", bGrassEnabled);

Client/core/CSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class CSettings
216216
CGUICheckBox* m_pWin8ColorCheckBox;
217217
CGUICheckBox* m_pWin8MouseCheckBox;
218218
CGUICheckBox* m_pPhotoSavingCheckbox;
219+
CGUICheckBox* m_pCheckBoxAskBeforeDisconnect;
219220
CGUICheckBox* m_pProcessAffinityCheckbox;
220221
CGUILabel* m_pUpdateBuildTypeLabel;
221222
CGUIComboBox* m_pUpdateBuildTypeCombo;

Client/game_sa/CGameSA.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,9 @@ void CGameSA::SetIgnoreFireStateEnabled(bool isEnabled)
889889
MemSet((void*)0x64F3DB, 0x90, 14); // CCarEnterExit::IsPlayerToQuitCarEnter
890890

891891
MemSet((void*)0x685A7F, 0x90, 14); // CTaskSimplePlayerOnFoot::ProcessPlayerWeapon
892+
893+
MemSet((void*)0x53A899, 0x90, 5); // CFire::ProcessFire
894+
MemSet((void*)0x53A990, 0x90, 5); // CFire::ProcessFire
892895
}
893896
else
894897
{
@@ -899,6 +902,9 @@ void CGameSA::SetIgnoreFireStateEnabled(bool isEnabled)
899902
MemCpy((void*)0x64F3DB, "\x8B\x85\x90\x04\x00\x00\x85\xC0\x0F\x85\x1B\x01\x00\x00", 14);
900903

901904
MemCpy((void*)0x685A7F, "\x8B\x86\x30\x07\x00\x00\x85\xC0\x0F\x85\x1D\x01\x00\x00", 14);
905+
906+
MemCpy((void*)0x53A899, "\xE8\x82\xF7\x0C\x00", 5);
907+
MemCpy((void*)0x53A990, "\xE8\x8B\xF6\x0C\x00", 5);
902908
}
903909

904910
m_isIgnoreFireStateEnabled = isEnabled;

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ void CMultiplayerSA::InitHooks()
15951595
InitHooks_ObjectStreamerOptimization();
15961596

15971597
InitHooks_Postprocess();
1598+
InitHooks_Explosions();
15981599
}
15991600

16001601
// Used to store copied pointers for explosions in the FxSystem

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class CMultiplayerSA : public CMultiplayer
8181
void InitHooks_ObjectStreamerOptimization();
8282
void InitHooks_Postprocess();
8383
void InitHooks_DeviceSelection();
84+
void InitHooks_Explosions();
8485
CRemoteDataStorage* CreateRemoteDataStorage();
8586
void DestroyRemoteDataStorage(CRemoteDataStorage* pData);
8687
void AddRemoteDataStorage(CPlayerPed* pPed, CRemoteDataStorage* pData);
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: multiplayer_sa/CMultiplayerSA_Explosions.cpp
6+
*
7+
* Multi Theft Auto is available from https://www.multitheftauto.com/
8+
*
9+
*****************************************************************************/
10+
#include "StdInc.h"
11+
12+
//////////////////////////////////////////////////////////////////////////////////////////
13+
//
14+
// CWorld::TriggerExplosion
15+
//
16+
// Fix for multiple damage instances in certain areas during explosions (GH #4125, #997)
17+
//
18+
//////////////////////////////////////////////////////////////////////////////////////////
19+
#define HOOKPOS_CWorld_TriggerExplosion 0x56B82E
20+
#define HOOKSIZE_CWorld_TriggerExplosion 8
21+
static constexpr std::uintptr_t RETURN_CWorld_TriggerExplosion = 0x56B836;
22+
static void _declspec(naked) HOOK_CWorld_TriggerExplosion()
23+
{
24+
_asm
25+
{
26+
mov [esp+1Ch-8h], eax
27+
mov [esp+1Ch-10h], ecx
28+
29+
// Call SetNextScanCode
30+
mov ecx, 0x4072E0
31+
call ecx
32+
mov ecx, esi
33+
34+
// SetNextScanCode overwrote the result of the cmp instruction at 0x56B82A
35+
// so we call it again
36+
cmp esi, eax
37+
jmp RETURN_CWorld_TriggerExplosion
38+
}
39+
}
40+
41+
#define HOOKPOS_CWorld_TriggerExplosionSectorList 0x5677F4
42+
#define HOOKSIZE_CWorld_TriggerExplosionSectorList 7
43+
static constexpr std::uintptr_t RETURN_CWorld_TriggerExplosionSectorList = 0x5677FB;
44+
static constexpr std::uintptr_t SKIP_CWorld_TriggerExplosionSectorList = 0x568473;
45+
static void _declspec(naked) HOOK_CWorld_TriggerExplosionSectorList()
46+
{
47+
_asm
48+
{
49+
// check entity->m_nScanCode == CWorld::ms_nCurrentScanCode
50+
mov ecx, dword ptr ds:[0xB7CD78]
51+
cmp [esi+2Ch], ecx
52+
jz skip
53+
54+
// set entity current scan code
55+
mov [esi+2Ch], ecx
56+
57+
mov al, [esi+36h]
58+
and al, 7
59+
cmp al, 4
60+
jmp RETURN_CWorld_TriggerExplosionSectorList
61+
62+
skip:
63+
jmp SKIP_CWorld_TriggerExplosionSectorList
64+
}
65+
}
66+
67+
//////////////////////////////////////////////////////////////////////////////////////////
68+
//
69+
// CMultiplayerSA::InitHooks_Explosions
70+
//
71+
// Setup hooks
72+
//
73+
//////////////////////////////////////////////////////////////////////////////////////////
74+
void CMultiplayerSA::InitHooks_Explosions()
75+
{
76+
EZHookInstall(CWorld_TriggerExplosion);
77+
EZHookInstall(CWorld_TriggerExplosionSectorList);
78+
}

0 commit comments

Comments
 (0)