-
Notifications
You must be signed in to change notification settings - Fork 1
/
UserContainer.cpp
102 lines (78 loc) · 1.66 KB
/
UserContainer.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
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
#ifndef _USERCONTAINER_
#include "UserContainer.h"
#endif
UserContainer::UserContainer()
{
}
UserContainer *UserContainer::Instance()
{
static UserContainer UC;
return &UC;
}
void UserContainer::AddUser(CCreature *pUser)
{
pContainer.push_back(pUser);
}
void UserContainer::DeleteUser(CCreature *pUser)
{
for (UCIT = pContainer.begin(); UCIT != pContainer.end(); UCIT++)
{
if (pUser == *UCIT)
{
pContainer.erase(UCIT);
}
}
}
bool UserContainer::UserExists(CCreature *pUser)
{
for (UCIT = pContainer.begin(); UCIT != pContainer.end(); UCIT++)
{
if (pUser == *UCIT)
{
return true;
}
}
return false;
}
CCreature *UserContainer::GetUserByName(wchar_t *szName)
{
for (UCIT = pContainer.begin(); UCIT != pContainer.end(); UCIT++)
{
CCreature *pCreature = reinterpret_cast<CCreature *>(*UCIT);
CSharedData *pSharedData = pCreature->GetSharedData();
if (wcscmp(pSharedData->wszName, szName) == 0)
{
return *UCIT;
}
}
return NULL;
}
CCreature *UserContainer::GetUserByObjId(int iObjId)
{
for (UCIT = pContainer.begin(); UCIT != pContainer.end(); UCIT++)
{
CCreature *pCreature = reinterpret_cast<CCreature *>(*UCIT);
CSharedData *pSharedData = pCreature->GetSharedData();
if (pSharedData->nObjectID == iObjId)
{
return *UCIT;
}
}
return NULL;
}
CCreature *UserContainer::GetUserByNpcIndex(int iNpcIndex)
{
for (UCIT = pContainer.begin(); UCIT != pContainer.end(); UCIT++)
{
CCreature *pCreature = reinterpret_cast<CCreature *>(*UCIT);
CSharedData *pSharedData = pCreature->GetSharedData();
if (pSharedData->nNpcIndex == iNpcIndex)
{
return *UCIT;
}
}
return NULL;
}
UserContainer::~UserContainer()
{
}