Repository navigation
Expand file tree
/
Copy pathentityList.cpp
More file actions
108 lines (72 loc) · 1.67 KB
/
Copy pathentityList.cpp
File metadata and controls
108 lines (72 loc) · 1.67 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "pch.h"
#include "entityList.h"
EntityList* EntityList::instance;
Player * EntityList::_localPlayer;
EntityList::EntityList(MemoryManager mm, uintptr_t add) : address(add), memoryManager(mm)
{}
EntityList::~EntityList()
{
delete instance;
}
void EntityList::populate(int entityCount)
{
this->list.clear();
unsigned int i = 0;
while ( i < (unsigned)entityCount)
{
uintptr_t entAddress;
memoryManager.ReadMemValue( this->address + 4 * i, (void*)&entAddress, sizeof(entAddress));
i++;
uintptr_t vTableAdd;
BOOL s = memoryManager.ReadMemValue( entAddress, &vTableAdd, sizeof(vTableAdd));
if ((vTableAdd == 0x4E4A98 || vTableAdd == 0x4E4AC0) && s)
{
addNewEntity(entAddress);
}
}
std::cout << std::dec << "total " << list.size() << " players created" << std::endl;
}
void EntityList::addNewEntity(uintptr_t address)
{
for (auto& ent : list)
{
if (ent.dmAddress == address) return;
}
this->list.push_back(Player(address));
}
EntityList * EntityList::createInstance(MemoryManager mm , uintptr_t address)
{
if(instance == nullptr) instance = new EntityList(mm, address);
return instance;
}
EntityList * EntityList::getInstance()
{
return instance;
}
void EntityList::setAddress(uintptr_t address)
{
this->address = address;
}
std::vector<Player> * EntityList::getPlayers()
{
return &list;
}
int EntityList::getEnemyCount()
{
assert(_localPlayer != nullptr);
int count = 0;
for (auto& ent : list)
{
if (ent.getTeamID() != _localPlayer->getTeamID())
count++;
}
return count;
}
void EntityList::setLocalPlayer(Player* localPlayer)
{
_localPlayer = localPlayer;
}
Player * EntityList::getLocalPlayer()
{
return _localPlayer;
}