This repository has been archived by the owner on Sep 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
buffer_lazy.cpp
115 lines (97 loc) · 2.7 KB
/
buffer_lazy.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
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
*
* WHINE TEAM
* We Had Ini, Now Engine
*
*/
#ifndef __BUFFER_LAZY__
#define __BUFFER_LAZY__
#define SKIP_PRAGMAS
//#define FO2238
#ifdef FO2238
#include "../fonline2238.h"
#else
#include "../fonline_tla.h"
#endif
#ifdef __MAPPER
#error "This is NOT mapper dll"
#endif
#include <string>
using namespace std;
// There's a blood on this code.
bool ParseLocalScriptName( const ScriptString& scriptfunc, string& module, string& function )
{
int pos = scriptfunc.c_std_str().find_first_of( "@" );
if( pos > 0 )
{
string moduleName = scriptfunc.c_std_str().substr( 0, pos );
string functionDecl = "void ";
functionDecl += scriptfunc.c_std_str().substr( pos + 1 );
#if defined(__CLIENT)
functionDecl += "(int,int,int,string@,int[]@)";
#elif defined(__SERVER)
functionDecl += "(Critter&,int,int,int,string@,int[]@)";
#endif
module = moduleName;
function = functionDecl;
return( true );
}
else
return( false );
}
EXPORT bool Global_IsLocalScript( const ScriptString& scriptfunc )
{
string module;
string function;
if( ParseLocalScriptName( scriptfunc, module, function ))
{
asIScriptModule* as_module = ASEngine->GetModule( module.c_str(), asGM_ONLY_IF_EXISTS );
if( !as_module )
return( false );
asIScriptFunction* as_function = as_module->GetFunctionByDecl( function.c_str() );
if( as_function )
return( true );
}
return( false );
}
#if defined(__CLIENT)
EXPORT void Global_RunLocalScript( const ScriptString& scriptfunc, int p0, int p1, int p2, const ScriptString* p3, ScriptArray* p4 )
#elif defined(__SERVER)
EXPORT void Critter_RunLocalScript( Critter& cr, const ScriptString& scriptfunc, int p0, int p1, int p2, const ScriptString* p3, ScriptArray* p4 )
#endif
{
if( Global_IsLocalScript( scriptfunc ))
{
string module, function;
if( ParseLocalScriptName( scriptfunc, module, function ))
{
int bindId = FOnline->ScriptBind( module.c_str(), function.c_str(), true );
if( bindId > 0 && FOnline->ScriptPrepare( bindId ))
{
#ifdef __SERVER
FOnline->ScriptSetArgObject( &cr );
#endif
FOnline->ScriptSetArgInt( p0 );
FOnline->ScriptSetArgInt( p1 );
FOnline->ScriptSetArgInt( p2 );
FOnline->ScriptSetArgObject( (void*)p3 );
FOnline->ScriptSetArgObject( p4 );
FOnline->ScriptRunPrepared();
}
else
{
Log( "RunLocalScript : cannot bind module<%s> function<%s>\n",
module.c_str(), function.c_str() );
}
}
else
{
Log( "RunLocalScript : invalid function name<%s>\n", scriptfunc.c_str() );
}
}
else
{
Log( "RunLocalScript : function<%s> not found\n", scriptfunc.c_str() );
}
}
#endif // __BUFFER_LAZY__ //