Skip to content

Commit 3940e18

Browse files
committed
Backport relevant changes from 'master' to release/1.6.0
1 parent 0dae3f7 commit 3940e18

File tree

343 files changed

+45884
-4418
lines changed

Some content is hidden

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

343 files changed

+45884
-4418
lines changed

Client/core/CCommandFuncs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ void CCommandFuncs::Reconnect(const char* szParameters)
318318
// Start the connect
319319
if (CCore::GetSingleton().GetConnectManager()->Reconnect(strHost.c_str(), usPort, strPassword.c_str(), false))
320320
{
321+
if (CCore::GetSingleton().GetConnectManager()->WasQuickConnect())
322+
{
323+
CCore::GetSingleton().GetConnectManager()->SetQuickConnect(false);
324+
}
321325
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: Reconnecting to %s:%u..."), strHost.c_str(), usPort);
322326
}
323327
else

Client/core/CConnectManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ class CConnectManager
2626

2727
bool Abort();
2828

29+
bool WasQuickConnect() const noexcept { return m_quickConnect; }
30+
2931
void DoPulse();
3032

3133
void OnServerExists();
3234

35+
void SetQuickConnect(bool quick) noexcept { m_quickConnect = quick; }
36+
3337
static void OpenServerFirewall(in_addr Address, ushort usHttpPort = 80, bool bHighPriority = false);
3438

3539
static bool StaticProcessPacket(unsigned char ucPacketID, class NetBitStreamInterface& bitStream);
@@ -59,4 +63,5 @@ class CConnectManager
5963
bool m_bNotifyServerBrowser;
6064

6165
bool CheckNickProvided(const char* szNick);
66+
bool m_quickConnect{false};
6267
};

Client/core/CMainMenu.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ bool CMainMenu::OnMenuClick(CGUIMouseEventArgs Args)
850850
}
851851

852852
break;
853+
case MENU_ITEM_QUICK_CONNECT:
854+
AskUserIfHeWantsToDisconnect(m_pHoveredItem->menuType);
855+
return true;
853856
default:
854857
break;
855858
}
@@ -914,7 +917,8 @@ bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement, bool left)
914917
ShowNetworkNotReadyWindow();
915918
return true;
916919
}
917-
920+
921+
g_pCore->GetConnectManager()->SetQuickConnect(true);
918922
g_pCore->GetCommands()->Execute("reconnect", "");
919923
}
920924
else
@@ -1262,6 +1266,9 @@ void CMainMenu::WantsToDisconnectCallBack(void* pData, uint uiButton)
12621266
case MENU_ITEM_DISCONNECT:
12631267
OnDisconnectButtonClick();
12641268
break;
1269+
case MENU_ITEM_QUICK_CONNECT:
1270+
OnQuickConnectButtonClick(nullptr, true);
1271+
break;
12651272
default:
12661273
break;
12671274
}

Client/core/DXHook/CProxyDirect3DDevice9.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ ULONG CProxyDirect3DDevice9::Release()
117117
// Call event handler
118118
CDirect3DEvents9::OnDirect3DDeviceDestroy(m_pDevice);
119119
delete this;
120+
return ulRefCount - 1;
120121
}
121122

122123
return m_pDevice->Release();

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/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ void CClientEntity::CallEventNoParent(const char* szName, const CLuaArguments& A
791791
// Call it on all our children
792792
if (!m_Children.empty())
793793
{
794-
for (CClientEntity* pEntity : *GetChildrenListSnapshot())
794+
CElementListSnapshotRef pChildrenSnapshot = GetChildrenListSnapshot();
795+
for (CClientEntity* pEntity : *pChildrenSnapshot)
795796
{
796797
if (!pEntity->IsBeingDeleted())
797798
{

Client/mods/deathmatch/logic/CClientExplosionManager.cpp

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ bool CClientExplosionManager::Hook_StaticExplosionCreation(CEntity* pGameExplodi
3939
return g_pExplosionManager->Hook_ExplosionCreation(pGameExplodingEntity, pGameCreator, vecPosition, explosionType);
4040
}
4141

42+
eWeaponType CClientExplosionManager::GetWeaponTypeFromExplosionType(const eExplosionType explosionType)
43+
{
44+
switch (explosionType) {
45+
case EXP_TYPE_GRENADE:
46+
return WEAPONTYPE_GRENADE;
47+
case EXP_TYPE_MOLOTOV:
48+
return WEAPONTYPE_MOLOTOV;
49+
case EXP_TYPE_ROCKET:
50+
case EXP_TYPE_ROCKET_WEAK:
51+
return WEAPONTYPE_ROCKET;
52+
case EXP_TYPE_TANK_GRENADE:
53+
return WEAPONTYPE_TANK_GRENADE;
54+
default:
55+
return WEAPONTYPE_EXPLOSION;
56+
}
57+
}
58+
4259
bool CClientExplosionManager::Hook_ExplosionCreation(CEntity* pGameExplodingEntity, CEntity* pGameCreator, const CVector& vecPosition,
4360
eExplosionType explosionType)
4461
{
@@ -53,7 +70,23 @@ bool CClientExplosionManager::Hook_ExplosionCreation(CEntity* pGameExplodingEnti
5370
CClientEntity* const pResponsible = pPools->GetClientEntity(reinterpret_cast<DWORD*>(pResponsibleGameEntity->GetInterface()));
5471

5572
if (!pResponsible)
56-
return false;
73+
{
74+
if (!pGameCreator)
75+
return false;
76+
77+
CClientPlayer* localPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer();
78+
if (!localPlayer || localPlayer->GetGameEntity() != pGameCreator)
79+
return false;
80+
81+
eWeaponType explosionWeaponType = GetWeaponTypeFromExplosionType(explosionType);
82+
83+
CLuaArguments arguments;
84+
arguments.PushNumber(vecPosition.fX);
85+
arguments.PushNumber(vecPosition.fY);
86+
arguments.PushNumber(vecPosition.fZ);
87+
arguments.PushNumber(explosionWeaponType);
88+
return localPlayer->CallEvent("onClientExplosion", arguments, true);
89+
}
5790

5891
// Determine the used weapon
5992
eWeaponType explosionWeaponType = WEAPONTYPE_EXPLOSION;
@@ -167,25 +200,22 @@ CExplosion* CClientExplosionManager::Create(eExplosionType explosionType, CVecto
167200
if (responsibleWeapon != WEAPONTYPE_UNARMED)
168201
m_LastWeaponType = responsibleWeapon;
169202
else
203+
m_LastWeaponType = GetWeaponTypeFromExplosionType(explosionType);
204+
205+
if (pCreator && pCreator->IsLocalEntity())
170206
{
171-
switch (explosionType)
207+
bool allowExplosion = Hook_ExplosionCreation(nullptr, pGameCreator, vecPosition, explosionType);
208+
if (!allowExplosion)
209+
return nullptr;
210+
}
211+
else if (!pCreator)
212+
{
213+
CClientPlayer* localPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer();
214+
if (localPlayer)
172215
{
173-
case EXP_TYPE_GRENADE:
174-
m_LastWeaponType = WEAPONTYPE_GRENADE;
175-
break;
176-
case EXP_TYPE_MOLOTOV:
177-
m_LastWeaponType = WEAPONTYPE_MOLOTOV;
178-
break;
179-
case EXP_TYPE_ROCKET:
180-
case EXP_TYPE_ROCKET_WEAK:
181-
m_LastWeaponType = WEAPONTYPE_ROCKET;
182-
break;
183-
case EXP_TYPE_TANK_GRENADE:
184-
m_LastWeaponType = WEAPONTYPE_TANK_GRENADE;
185-
break;
186-
default:
187-
m_LastWeaponType = WEAPONTYPE_EXPLOSION;
188-
break;
216+
bool allowExplosion = Hook_ExplosionCreation(nullptr, localPlayer->GetGameEntity(), vecPosition, explosionType);
217+
if (!allowExplosion)
218+
return nullptr;
189219
}
190220
}
191221

Client/mods/deathmatch/logic/CClientExplosionManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ class CClientExplosionManager
3434
CClientEntityPtr m_pLastCreator;
3535

3636
private:
37-
CClientManager* m_pManager;
37+
CClientManager* m_pManager;
38+
eWeaponType GetWeaponTypeFromExplosionType(const eExplosionType explosionType);
3839
};

0 commit comments

Comments
 (0)