forked from jewalky/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 5
/
screenshots.cpp
55 lines (49 loc) · 1.43 KB
/
screenshots.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
#include "screenshots.h"
#include <ctime>
#include "config_new.h"
static std::vector<ClientScreenshot> Screenshots;
static int ScreenshotUID = 0;
uint32_t ClientScreenshot_Enqueue(byte* gm, byte* target)
{
ClientScreenshot cs;
cs.SourcePlayer = gm;
cs.TargetPlayer = target;
cs.RequestedAt = time(NULL);
cs.UID = Config::IPAddressP << 16 | (++ScreenshotUID);
Screenshots.push_back(cs);
return cs.UID;
}
ClientScreenshot* ClientScreenshot_FindByUID(uint32_t uid)
{
for (std::vector<ClientScreenshot>::iterator it = Screenshots.begin(); it != Screenshots.end(); ++it)
{
ClientScreenshot& cs = (*it);
if (cs.UID == uid)
return &cs;
}
return nullptr;
}
void ClientScreenshot_Drop(uint32_t uid)
{
for (std::vector<ClientScreenshot>::iterator it = Screenshots.begin(); it != Screenshots.end(); ++it)
{
ClientScreenshot& cs = (*it);
if (cs.UID == uid)
{
std::vector<ClientScreenshot>::iterator prev = it-1;
Screenshots.erase(it);
it = prev;
}
}
}
void ClientScreenshot_DropPlayer(byte* player)
{
for (std::vector<ClientScreenshot>::iterator it = Screenshots.begin(); it != Screenshots.end(); ++it)
{
ClientScreenshot& cs = (*it);
if (cs.SourcePlayer == player)
cs.SourcePlayer = nullptr;
if (cs.TargetPlayer == player)
cs.TargetPlayer = nullptr;
}
}