-
Notifications
You must be signed in to change notification settings - Fork 0
/
Players.cpp
69 lines (60 loc) · 933 Bytes
/
Players.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
65
66
67
68
69
#include "Players.h"
PlayerList plist;
void PlayerList::AddPlayer(edict_t *pEntity)
{
PList[p_numb].entity = pEntity;
PList[p_numb].id = p_id;
p_id++;
p_numb++;
}
void PlayerList::DeletePlayer(edict_t *pEntity)
{
for(int i = 0; i < p_numb; i++)
{
if(PList[i].entity == pEntity)
{
while(i < p_numb)
{
PList[i] = PList[i + 1];
i++;
}
p_numb--;
}
}
}
int PlayerList::NextPlayer(edict_t **pEntity)
{
if(!p_numb)
{
*pEntity = NULL;
return 0;
}
if( !(*pEntity) )
{
*pEntity = PList[0].entity;
return PList[0].id;
}
for(int i = 0; i < p_numb; i++)
{
if(PList[i].entity == *pEntity)
{
if((i + 1) == p_numb)
*pEntity = NULL;
else
{
*pEntity = PList[i + 1].entity;
return PList[i + 1].id;
}
}
}
return 0;
}
edict_t* PlayerList::GetEntity(int id)
{
for(int i = 0; i < p_numb; i++)
{
if(PList[i].id == id)
return PList[i].entity;
}
return NULL;
}