-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLuaScript.h
executable file
·112 lines (79 loc) · 2.61 KB
/
LuaScript.h
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
103
104
105
106
107
108
109
110
111
112
//
//---------------------------------------------------------------------------
#ifndef LuaScriptH
#define LuaScriptH
//---------------------------------------------------------------------------
struct User;
struct Script;
//---------------------------------------------------------------------------
struct ScriptBot {
char *sNick;
char *sMyINFO;
ScriptBot *prev, *next;
bool bIsOP;
ScriptBot();
~ScriptBot();
static ScriptBot * CreateScriptBot(char * sNick, const size_t &szNickLen, char * sDescription, const size_t &szDscrLen, char * sEmail, const size_t &szEmailLen, const bool &bOP);
};
//------------------------------------------------------------------------------
struct ScriptTimer {
static char sDefaultTimerFunc[];
#ifdef _WIN32
UINT_PTR uiTimerId;
#else
timer_t TimerId;
#endif
char * sFunctionName;
int iFunctionRef;
ScriptTimer *prev, *next;
ScriptTimer();
~ScriptTimer();
#ifdef _WIN32
static ScriptTimer * CreateScriptTimer(UINT_PTR uiTmrId, char * sFunctName, const size_t &szLen, const int &iRef);
#else
static ScriptTimer * CreateScriptTimer(char * sFunctName, const size_t &szLen, const int &iRef);
#endif
};
//------------------------------------------------------------------------------
struct Script {
enum LuaFunctions {
ONSTARTUP = 0x1,
ONEXIT = 0x2,
ONERROR = 0x4,
USERCONNECTED = 0x8,
REGCONNECTED = 0x10,
OPCONNECTED = 0x20,
USERDISCONNECTED = 0x40,
REGDISCONNECTED = 0x80,
OPDISCONNECTED = 0x100
};
uint32_t ui32DataArrivals;
char * sName;
lua_State * LUA;
Script *prev, *next;
ScriptBot *BotList;
ScriptTimer *TimerList;
uint16_t ui16Functions;
bool bEnabled, bRegUDP, bProcessed;
Script();
~Script();
static Script * CreateScript(char *Name, const bool &enabled);
};
//------------------------------------------------------------------------------
bool ScriptStart(Script * cur);
void ScriptStop(Script * cur);
int ScriptGetGC(Script * cur);
void ScriptOnStartup(Script * cur);
void ScriptOnExit(Script * cur);
void ScriptPushUser(lua_State * L, User * u, const bool &bFullTable = false);
void ScriptPushUserExtended(lua_State * L, User * u, const int &iTable);
User * ScriptGetUser(lua_State * L, const int &iTop, const char * sFunction);
void ScriptError(Script * cur);
#ifdef _WIN32
void ScriptOnTimer(const UINT_PTR &uiTimerId);
#else
void ScriptOnTimer(ScriptTimer * AccTimer);
#endif
int ScriptTraceback(lua_State * L);
//------------------------------------------------------------------------------
#endif