Skip to content

Commit 9f8a995

Browse files
authored
Merge branch 'master' into bugfix/fire_task
2 parents e882c0e + 0102dd2 commit 9f8a995

File tree

408 files changed

+26218
-33177
lines changed

Some content is hidden

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

408 files changed

+26218
-33177
lines changed

Client/core/CVersionUpdater.Util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
class CVersionUpdater;
1313

1414
// Update master info
15-
#define UPDATER_MASTER_URL1 "http://updatesa.mtasa.com/sa/master/?v=%VERSION%&id=%ID%"
16-
#define UPDATER_MASTER_URL2 "http://updatesa.multitheftauto.com/sa/master/?v=%VERSION%&id=%ID%"
15+
#define UPDATER_MASTER_URL1 "https://updatesa.mtasa.com/sa/master/?v=%VERSION%&id=%ID%"
16+
#define UPDATER_MASTER_URL2 "https://updatesa.multitheftauto.com/sa/master/?v=%VERSION%&id=%ID%"
1717

1818
/*
1919

Client/game_sa/CAnimManagerSA.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,10 @@ static const char* const kGateWayAnimationName = "run_wuzi";
3232

3333
CAnimManagerSA::CAnimManagerSA()
3434
{
35-
MemSetFast(m_pAnimAssocGroups, 0, sizeof(m_pAnimAssocGroups));
36-
MemSetFast(m_pAnimBlocks, 0, sizeof(m_pAnimBlocks));
3735
}
3836

3937
CAnimManagerSA::~CAnimManagerSA()
4038
{
41-
for (unsigned int i = 0; i < MAX_ANIM_GROUPS; i++)
42-
if (m_pAnimAssocGroups[i])
43-
delete m_pAnimAssocGroups[i];
44-
for (unsigned int i = 0; i < MAX_ANIM_BLOCKS; i++)
45-
if (m_pAnimBlocks[i])
46-
delete m_pAnimBlocks[i];
4739
}
4840

4941
void CAnimManagerSA::Initialize()

Client/game_sa/CAnimManagerSA.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,4 @@ class CAnimManagerSA : public CAnimManager
165165

166166
bool IsValidGroup(std::uint32_t uiAnimGroup) const;
167167
bool IsValidAnim(std::uint32_t uiAnimGroup, std::uint32_t uiAnimID) const;
168-
private:
169-
CAnimBlendAssocGroup* m_pAnimAssocGroups[MAX_ANIM_GROUPS];
170-
CAnimBlock* m_pAnimBlocks[MAX_ANIM_BLOCKS];
171168
};

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CPtrNodeSingleListSA.h"
1919
#include "MemSA.h"
2020
#include "CVehicleSA.h"
21+
#include "CBuildingRemovalSA.h"
2122

2223
extern CGameSA* pGame;
2324

@@ -48,6 +49,16 @@ inline bool CBuildingsPoolSA::AddBuildingToPool(CClientBuilding* pClientBuilding
4849
return true;
4950
}
5051

52+
CClientEntity* CBuildingsPoolSA::GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept
53+
{
54+
std::uint32_t poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndexSafe(pGameInterface);
55+
56+
if (poolIndex == static_cast<std::uint32_t>(-1))
57+
return nullptr;
58+
59+
return m_buildingPool.entities[poolIndex].pClientEntity;
60+
}
61+
5162
CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint16_t modelId, CVector* vPos, CVector4D* vRot, uint8_t interior)
5263
{
5364
if (!HasFreeBuildingSlot())
@@ -138,18 +149,11 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding)
138149
--m_buildingPool.count;
139150
}
140151

141-
void CBuildingsPoolSA::RemoveAllBuildings()
152+
void CBuildingsPoolSA::RemoveAllWithBackup()
142153
{
143154
if (m_pOriginalBuildingsBackup)
144155
return;
145156

146-
pGame->GetCoverManager()->RemoveAllCovers();
147-
pGame->GetPlantManager()->RemoveAllPlants();
148-
149-
// Remove all shadows
150-
using CStencilShadowObjects_dtorAll = void* (*)();
151-
((CStencilShadowObjects_dtorAll)0x711390)();
152-
153157
m_pOriginalBuildingsBackup = std::make_unique<std::array<std::pair<bool, CBuildingSAInterface>, MAX_BUILDINGS>>();
154158

155159
auto pBuildsingsPool = (*m_ppBuildingPoolInterface);
@@ -176,11 +180,14 @@ void CBuildingsPoolSA::RemoveAllBuildings()
176180
}
177181
}
178182

179-
void CBuildingsPoolSA::RestoreAllBuildings()
183+
void CBuildingsPoolSA::RestoreBackup()
180184
{
181185
if (!m_pOriginalBuildingsBackup)
182186
return;
183187

188+
auto* worldSA = pGame->GetWorld();
189+
auto* buildingRemovealSA = static_cast<CBuildingRemovalSA*>(pGame->GetBuildingRemoval());
190+
184191
auto& originalData = *m_pOriginalBuildingsBackup;
185192
auto pBuildsingsPool = (*m_ppBuildingPoolInterface);
186193
for (size_t i = 0; i < MAX_BUILDINGS; i++)
@@ -191,7 +198,8 @@ void CBuildingsPoolSA::RestoreAllBuildings()
191198
auto pBuilding = pBuildsingsPool->GetObject(i);
192199
*pBuilding = originalData[i].second;
193200

194-
pGame->GetWorld()->Add(pBuilding, CBuildingPool_Constructor);
201+
worldSA->Add(pBuilding, CBuildingPool_Constructor);
202+
buildingRemovealSA->AddDataBuilding(pBuilding);
195203
}
196204
}
197205

@@ -202,10 +210,7 @@ void CBuildingsPoolSA::RemoveBuildingFromWorld(CBuildingSAInterface* pBuilding)
202210
{
203211
// Remove building from world
204212
pGame->GetWorld()->Remove(pBuilding, CBuildingPool_Destructor);
205-
206-
pBuilding->DeleteRwObject();
207-
pBuilding->ResolveReferences();
208-
pBuilding->RemoveShadows();
213+
pBuilding->RemoveRWObjectWithReferencesCleanup();
209214
}
210215

211216
bool CBuildingsPoolSA::Resize(int size)
@@ -254,7 +259,7 @@ bool CBuildingsPoolSA::Resize(int size)
254259
newBytemap[i].bEmpty = true;
255260
}
256261

257-
const uint32_t offset = (uint32_t)newObjects - (uint32_t)oldPool;
262+
const std::uint32_t offset = (std::uint32_t)newObjects - (std::uint32_t)oldPool;
258263
if (oldPool != nullptr)
259264
{
260265
UpdateIplEntrysPointers(offset);
@@ -265,7 +270,7 @@ bool CBuildingsPoolSA::Resize(int size)
265270
UpdateBackupLodPointers(offset);
266271
}
267272

268-
pGame->GetPools()->GetDummyPool().UpdateBuildingLods(oldPool, newObjects);
273+
pGame->GetPools()->GetDummyPool().UpdateBuildingLods(offset);
269274

270275
RemoveVehicleDamageLinks();
271276
RemovePedsContactEnityLinks();

Client/game_sa/CBuildingsPoolSA.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ class CBuildingsPoolSA : public CBuildingsPool
2626
void RemoveBuilding(CBuilding* pBuilding);
2727
bool HasFreeBuildingSlot();
2828

29-
void RemoveAllBuildings() override;
30-
void RestoreAllBuildings() override;
29+
void RemoveAllWithBackup() override;
30+
void RestoreBackup() override;
3131
bool Resize(int size) override;
3232
int GetSize() const override { return (*m_ppBuildingPoolInterface)->m_nSize; };
33+
CClientEntity* GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept;
3334

3435
private:
3536
void RemoveBuildingFromWorld(CBuildingSAInterface* pBuilding);
@@ -40,8 +41,8 @@ class CBuildingsPoolSA : public CBuildingsPool
4041
void RemovePedsContactEnityLinks();
4142

4243
private:
43-
SVectorPoolData<CBuildingSA> m_buildingPool{MAX_BUILDINGS};
44-
CPoolSAInterface<CBuildingSAInterface>** m_ppBuildingPoolInterface;
44+
SVectorPoolData<CBuildingSA> m_buildingPool{MAX_BUILDINGS};
45+
CPoolSAInterface<CBuildingSAInterface>** m_ppBuildingPoolInterface;
4546

4647
std::unique_ptr<std::array<std::pair<bool, CBuildingSAInterface>, MAX_BUILDINGS>> m_pOriginalBuildingsBackup;
4748
};

Client/game_sa/CDummyPoolSA.cpp

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: game_sa/CDummyPoolSA.cpp
66
* PURPOSE: Dummy pool class
@@ -13,64 +13,96 @@
1313

1414
#include "StdInc.h"
1515
#include "CDummyPoolSA.h"
16+
#include "CGameSA.h"
17+
#include <game/CWorld.h>
18+
19+
extern CGameSA* pGame;
1620

1721
CDummyPoolSA::CDummyPoolSA()
1822
{
1923
m_ppDummyPoolInterface = (CPoolSAInterface<CEntitySAInterface>**)0xB744A0;
2024
}
2125

22-
void CDummyPoolSA::RemoveAllBuildingLods()
26+
void CDummyPoolSA::RemoveAllWithBackup()
2327
{
24-
if (m_pLodBackup)
28+
if (m_pOriginalElementsBackup)
2529
return;
2630

27-
m_pLodBackup = std::make_unique<std::array<CEntitySAInterface*, MAX_DUMMIES>>();
31+
m_pOriginalElementsBackup = std::make_unique<pool_backup_t>();
2832

29-
for (int i = 0; i < MAX_DUMMIES; i++)
33+
auto pDummyPool = (*m_ppDummyPoolInterface);
34+
for (auto i = 0; i < MAX_DUMMIES_DEFAULT; i++)
3035
{
31-
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
32-
(*m_pLodBackup)[i] = object->m_pLod;
33-
object->m_pLod = nullptr;
36+
if (pDummyPool->IsContains(i))
37+
{
38+
CEntitySAInterface* building = pDummyPool->GetObject(i);
39+
40+
pGame->GetWorld()->Remove(building, CDummyPool_Destructor);
41+
building->RemoveRWObjectWithReferencesCleanup();
42+
43+
pDummyPool->Release(i);
44+
45+
(*m_pOriginalElementsBackup)[i].first = true;
46+
(*m_pOriginalElementsBackup)[i].second = *building;
47+
}
48+
else
49+
{
50+
(*m_pOriginalElementsBackup)[i].first = false;
51+
}
3452
}
3553
}
3654

37-
void CDummyPoolSA::RestoreAllBuildingsLods()
55+
void CDummyPoolSA::RestoreBackup()
3856
{
39-
if (!m_pLodBackup)
57+
if (!m_pOriginalElementsBackup)
4058
return;
4159

42-
for (int i = 0; i < MAX_DUMMIES; i++)
60+
auto& originalData = *m_pOriginalElementsBackup;
61+
auto pDummyPool = (*m_ppDummyPoolInterface);
62+
for (auto i = 0; i < MAX_DUMMIES_DEFAULT; i++)
4363
{
44-
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
45-
object->m_pLod = (*m_pLodBackup)[i];
64+
if (originalData[i].first)
65+
{
66+
pDummyPool->AllocateAt(i);
67+
auto pDummy = pDummyPool->GetObject(i);
68+
*pDummy = originalData[i].second;
69+
70+
pGame->GetWorld()->Add(pDummy, CDummyPool_Constructor);
71+
}
4672
}
4773

48-
m_pLodBackup.release();
74+
m_pOriginalElementsBackup = nullptr;
4975
}
5076

51-
void CDummyPoolSA::UpdateBuildingLods(void* oldPool, void* newPool)
77+
void CDummyPoolSA::UpdateBuildingLods(const std::uint32_t offset)
5278
{
53-
const uint32_t offset = (uint32_t)newPool - (uint32_t)oldPool;
79+
if (m_pOriginalElementsBackup)
80+
UpdateBackupLodOffset(offset);
81+
else
82+
UpdateLodsOffestInPool(offset);
83+
}
5484

55-
if (m_pLodBackup)
85+
void CDummyPoolSA::UpdateBackupLodOffset(const std::uint32_t offset)
86+
{
87+
for (auto& it : *m_pOriginalElementsBackup)
5688
{
57-
for (int i = 0; i < MAX_DUMMIES; i++)
89+
if (it.first)
5890
{
59-
if ((*m_pLodBackup)[i] != nullptr)
60-
{
61-
(*m_pLodBackup)[i] = (CEntitySAInterface*)((uint32_t)(*m_pLodBackup)[i] + offset);
62-
}
91+
CEntitySAInterface* object = &it.second;
92+
CEntitySAInterface* lod = object->GetLod();
93+
if (lod)
94+
object->SetLod((CEntitySAInterface*)((std::uint32_t)lod + offset));
6395
}
6496
}
65-
else
97+
}
98+
99+
void CDummyPoolSA::UpdateLodsOffestInPool(const std::uint32_t offset)
100+
{
101+
for (auto i = 0; i < (*m_ppDummyPoolInterface)->Size(); i++)
66102
{
67-
for (int i = 0; i < MAX_DUMMIES; i++)
68-
{
69-
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
70-
if (object->m_pLod)
71-
{
72-
object->m_pLod = (CEntitySAInterface*)((uint32_t)object->m_pLod + offset);
73-
}
74-
}
103+
CEntitySAInterface* object = (*m_ppDummyPoolInterface)->GetObject(i);
104+
CEntitySAInterface* lod = object->GetLod();
105+
if (lod)
106+
object->SetLod((CEntitySAInterface*)((std::uint32_t)lod + offset));
75107
}
76108
}

Client/game_sa/CDummyPoolSA.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: game_sa/CDummyPoolSA.h
66
* PURPOSE: Dummy pool class
@@ -16,18 +16,25 @@
1616
#include "CPoolSAInterface.h"
1717
#include <memory>
1818

19-
class CDummyPoolSA : public CDummyPool
19+
constexpr std::size_t MAX_DUMMIES_DEFAULT = 2500;
20+
21+
class CDummyPoolSA final : public CDummyPool
2022
{
2123
public:
2224
CDummyPoolSA();
2325
~CDummyPoolSA() = default;
2426

25-
void RemoveAllBuildingLods();
26-
void RestoreAllBuildingsLods();
27-
void UpdateBuildingLods(void* oldPool, void* newPool);
27+
void RemoveAllWithBackup() override;
28+
void RestoreBackup() override;
29+
void UpdateBuildingLods(const std::uint32_t offset);
30+
31+
private:
32+
void UpdateBackupLodOffset(const std::uint32_t offest);
33+
void UpdateLodsOffestInPool(const std::uint32_t offset);
2834

2935
private:
3036
CPoolSAInterface<CEntitySAInterface>** m_ppDummyPoolInterface;
3137

32-
std::unique_ptr<std::array<CEntitySAInterface*, MAX_DUMMIES>> m_pLodBackup;
38+
using pool_backup_t = std::array<std::pair<bool, CEntitySAInterface>, MAX_DUMMIES_DEFAULT>;
39+
std::unique_ptr<pool_backup_t> m_pOriginalElementsBackup;
3340
};

0 commit comments

Comments
 (0)