-
Notifications
You must be signed in to change notification settings - Fork 6
/
csdm_spawning.cpp
64 lines (49 loc) · 1.08 KB
/
csdm_spawning.cpp
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
#include "amxxmodule.h"
#include "csdm_spawning.h"
SpawnMngr g_SpawnMngr;
int g_SpawnMethod = -1;
SpawnMethod::SpawnMethod(const char *name, int callback)
{
m_Name.assign(name);
m_Callback = callback;
}
void SpawnMethod::Spawn(int player, bool fake)
{
MF_ExecuteForward(m_Callback, (cell)player, (cell)(fake ? 1 : 0));
}
const char *SpawnMethod::GetName()
{
return m_Name.c_str();
}
int SpawnMngr::AddMethod(const char *name, int callback)
{
SpawnMethod *pSpawn = new SpawnMethod(name, callback);
m_Methods.push_back(pSpawn);
return (int)m_Methods.size() - 1;
}
void SpawnMngr::SpawnPlayer(int method, int player, bool fake)
{
if (method < 0 || method >= (int)m_Methods.size())
return;
m_Methods[method]->Spawn(player, fake);
}
SpawnMethod *SpawnMngr::GetSpawn(int method)
{
if (method < 0 || method >= (int)m_Methods.size())
return NULL;
return m_Methods[method];
}
void SpawnMngr::Clear()
{
for (size_t i=0; i<m_Methods.size(); i++)
delete m_Methods[i];
m_Methods.clear();
}
size_t SpawnMngr::Spawns()
{
return m_Methods.size();
}
SpawnMngr::~SpawnMngr()
{
Clear();
}