| 3 |
tristanc |
1 |
#include "pch.h"
|
|
|
2 |
#pragma hdrstop
|
|
|
3 |
|
|
|
4 |
#include "FrameScript.h"
|
|
|
5 |
|
| 32 |
tristanc |
6 |
|
| 36 |
tristanc |
7 |
/******************************************************************************
|
| 31 |
tristanc |
8 |
*
|
|
|
9 |
* Client memory addresses
|
|
|
10 |
*
|
|
|
11 |
***/
|
| 3 |
tristanc |
12 |
|
| 32 |
tristanc |
13 |
#define FRAMESCRIPT_EXECUTE_PTR 0x00819210
|
|
|
14 |
#define FRAMESCRIPT_GETTEXT_PTR 0x00819D40
|
|
|
15 |
#define FRAMESCRIPT_REGISTERFUNCTION_PTR 0x00817F90
|
|
|
16 |
#define FRAMESCRIPT_SIGNALEVENT_PTR 0x00703E50
|
|
|
17 |
#define FRAMESCRIPT_SIGNALEVENT2_PTR 0x00703F50
|
|
|
18 |
#define FRAMESCRIPT_UNREGISTERFUNCTION_PTR 0x00817FD0
|
|
|
19 |
#define LUA_PUSHSTRING_PTR 0x0084E350
|
| 31 |
tristanc |
20 |
|
|
|
21 |
|
| 36 |
tristanc |
22 |
/******************************************************************************
|
| 3 |
tristanc |
23 |
*
|
| 31 |
tristanc |
24 |
* Client function pointers
|
| 3 |
tristanc |
25 |
*
|
|
|
26 |
***/
|
|
|
27 |
|
| 31 |
tristanc |
28 |
void (*FrameScript_ExecutePtr)(LPCSTR,LPCSTR,LPCSTR) = *(void(*)(LPCSTR,LPCSTR,LPCSTR))FRAMESCRIPT_EXECUTE_PTR;
|
| 3 |
tristanc |
29 |
|
| 31 |
tristanc |
30 |
PCHAR(*FrameScript_GetTextPtr)(LPCSTR,int,FRAMESCRIPT_GENDER) = *(PCHAR(*)(LPCSTR,int,FRAMESCRIPT_GENDER))FRAMESCRIPT_GETTEXT_PTR;
|
| 3 |
tristanc |
31 |
|
| 31 |
tristanc |
32 |
void (*FrameScript_RegisterFunctionPtr)(LPCSTR,int(*)(lua_State*)) = *(void(*)(LPCSTR,int(*)(lua_State *)))FRAMESCRIPT_REGISTERFUNCTION_PTR;
|
|
|
33 |
|
|
|
34 |
void (*FrameScript_SignalEventPtr)(SCRIPTEVENT) = *(void(*)(SCRIPTEVENT))FRAMESCRIPT_SIGNALEVENT_PTR;
|
|
|
35 |
|
|
|
36 |
void (*FrameScript_SignalEventPtr2)(SCRIPTEVENT,LPCSTR,...) = *(void (*)(SCRIPTEVENT,LPCSTR,...))FRAMESCRIPT_SIGNALEVENT2_PTR;
|
|
|
37 |
|
|
|
38 |
void (*FrameScript_UnregisterFunctionPtr)(LPCSTR) = *(void(*)(LPCSTR))FRAMESCRIPT_UNREGISTERFUNCTION_PTR;
|
|
|
39 |
|
|
|
40 |
void (*lua_pushstringPtr)(lua_State*,const char*) = *(void(*)(lua_State *,const char *))LUA_PUSHSTRING_PTR;
|
|
|
41 |
|
|
|
42 |
|
| 36 |
tristanc |
43 |
/******************************************************************************
|
| 3 |
tristanc |
44 |
*
|
| 31 |
tristanc |
45 |
* External
|
| 3 |
tristanc |
46 |
*
|
|
|
47 |
***/
|
|
|
48 |
|
| 36 |
tristanc |
49 |
//=============================================================================
|
| 3 |
tristanc |
50 |
void FrameScript_Execute (LPCSTR function, LPCSTR arguments, LPCSTR taint) {
|
|
|
51 |
FrameScript_ExecutePtr(function,arguments,taint);
|
|
|
52 |
}
|
|
|
53 |
|
| 36 |
tristanc |
54 |
//=============================================================================
|
| 32 |
tristanc |
55 |
PCHAR FrameScript_GetText (char const* text, int a2, FRAMESCRIPT_GENDER gender) {
|
| 3 |
tristanc |
56 |
return FrameScript_GetTextPtr(text,a2,gender);
|
|
|
57 |
}
|
|
|
58 |
|
| 36 |
tristanc |
59 |
//=============================================================================
|
| 3 |
tristanc |
60 |
void FrameScript_RegisterFunction (LPCSTR name, int (*fcn)(lua_State *)) {
|
|
|
61 |
FrameScript_RegisterFunctionPtr(name,fcn);
|
|
|
62 |
}
|
|
|
63 |
|
| 36 |
tristanc |
64 |
//=============================================================================
|
| 3 |
tristanc |
65 |
void FrameScript_SignalEvent (SCRIPTEVENT eventID) {
|
|
|
66 |
FrameScript_SignalEventPtr(eventID);
|
|
|
67 |
}
|
|
|
68 |
|
| 36 |
tristanc |
69 |
//=============================================================================
|
| 3 |
tristanc |
70 |
void FrameScript_SignalEvent (SCRIPTEVENT eventID, LPCSTR string, ...) {
|
|
|
71 |
va_list arglist;
|
|
|
72 |
va_start(arglist,string);
|
| 31 |
tristanc |
73 |
|
| 3 |
tristanc |
74 |
FrameScript_SignalEventPtr2(eventID,string,arglist);
|
| 31 |
tristanc |
75 |
|
| 3 |
tristanc |
76 |
va_end(arglist);
|
|
|
77 |
}
|
|
|
78 |
|
| 36 |
tristanc |
79 |
//=============================================================================
|
| 3 |
tristanc |
80 |
void FrameScript_UnregisterFunction (LPCSTR name) {
|
|
|
81 |
FrameScript_UnregisterFunctionPtr(name);
|
|
|
82 |
}
|
|
|
83 |
|
| 36 |
tristanc |
84 |
//=============================================================================
|
| 32 |
tristanc |
85 |
void _lua_pushstring(lua_State* L, char const* s) {
|
| 3 |
tristanc |
86 |
lua_pushstringPtr(L,s);
|
|
|
87 |
}
|
| 32 |
tristanc |
88 |
|