-
-
Notifications
You must be signed in to change notification settings - Fork 546
Expand file tree
/
Copy pathCBuildingsPoolSA.h
More file actions
61 lines (50 loc) · 2.43 KB
/
CBuildingsPoolSA.h
File metadata and controls
61 lines (50 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CBuildingsPoolSA.h
* PURPOSE: Buildings pool class
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/
#pragma once
#include <game/CBuildingsPool.h>
#include <CVector.h>
#include "CPoolSAInterface.h"
#include "CBuildingSA.h"
class CBuildingsPoolSA : public CBuildingsPool
{
public:
CBuildingsPoolSA();
~CBuildingsPoolSA() = default;
CBuilding* AddBuilding(CClientBuilding*, uint16_t modelId, CVector* vPos, CVector* vRot, uint8_t interior);
void RemoveBuilding(CBuilding* pBuilding);
bool HasFreeBuildingSlot();
void RemoveAllWithBackup() override;
void RestoreBackup() override;
bool Resize(int size) override;
int GetSize() const override { return (m_ppBuildingPoolInterface && *m_ppBuildingPoolInterface) ? (*m_ppBuildingPoolInterface)->m_nSize : 0; };
CClientEntity* GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept;
private:
void RemoveBuildingFromWorld(CBuildingSAInterface* pBuilding);
bool AddBuildingToPool(CClientBuilding* pClientBuilding, CBuildingSA* pBuilding);
void UpdateIplEntrysPointers(uint32_t offset);
void UpdateBackupLodPointers(uint32_t offset);
void RemoveVehicleDamageLinks();
void RemovePedsContactEnityLinks();
void RemoveObjectEntityLinks();
void PurgeStaleSectorEntries(void* oldPool, int poolSize);
private:
SVectorPoolData<CBuildingSA> m_buildingPool{MAX_BUILDINGS};
CPoolSAInterface<CBuildingSAInterface>** m_ppBuildingPoolInterface;
using building_buffer_t = std::uint8_t[sizeof(CBuildingSAInterface)];
using backup_entry_t = std::pair<bool, building_buffer_t>;
using backup_container_t = std::vector<backup_entry_t>;
std::unique_ptr<backup_container_t> m_pOriginalBuildingsBackup;
std::unordered_map<CBuildingSAInterface*, CMatrix_Padded> m_buildingMatrix{};
// Set by RemoveAllWithBackup after sweeping stale entity links (vehicle damage,
// ped contact, object entity refs). Cleared by Resize to skip a redundant pass
// when SetBuildingPoolSize calls both in the same remove/resize cycle.
bool m_bLinkSweepsDone{false};
};