-
Notifications
You must be signed in to change notification settings - Fork 5
/
AlternativeWait.cpp
64 lines (55 loc) · 1.6 KB
/
AlternativeWait.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 "AlternativeWait.h"
#include "Interfaces.h"
void CmdWait(const CCommand &args)
{
if(!strlen(args.Arg(1)) || args.ArgC() == 0)
return;
//need to get cmd buffer
//Msg(args.GetCommandString());
int i = atoi(args.Arg(1));
CWaiter::g_pInstance->AddWait(args.GetCommandString(), i);
}
void CmdLoop(const CCommand &args)
{
if(!strlen(args.Arg(1)) || args.ArgC() == 0)
return;
}
CWaiter *CWaiter::g_pInstance;
CWaiter::CWaiter()
{
m_command = new ConCommand(PREFIX "wait", CmdWait, "Acts just like the standard wait command");
m_loopcmd = new ConCommand(PREFIX "loop", CmdLoop, "Runs the specified command after every amount of frames specified, can only be one instance");
g_pInstance = this;
}
CWaiter::~CWaiter()
{
Skim::ValveInterfaces::FreeConCMD(m_command);
Skim::ValveInterfaces::FreeConCMD(m_loopcmd);
}
void CWaiter::Run(CUserCmd* pCmd)
{
int i = m_vCommands.size();
if(!i)
return;
std::vector<WaitCmd_t> vtmp;
//Fire commands if wait is 0, otherwize decrement the command and add to temp
for (int j = 0; j < i; j++)
{
if(!m_vCommands[j].m_iWait)
{
Skim::ValveInterfaces::pEngine->ClientCmd_Unrestricted(m_vCommands[j].m_sCmd);
}
else{
m_vCommands[j].m_iWait--;
vtmp.push_back(m_vCommands[j]);
}
}
m_vCommands = vtmp;
}
void CWaiter::AddWait(const char* scmd, int iframes)
{
WaitCmd_t noe;
noe.m_iWait = iframes;
strcpy(noe.m_sCmd, scmd);
m_vCommands.push_back(noe);
}