5 |
|
#include "Daodan_BSL.h" |
6 |
|
#include "Daodan_Utility.h" |
7 |
|
#include "Daodan_Console.h" |
8 |
< |
#include "BFW_ScriptingLanguage.h" |
8 |
> |
#include "BFW_ScriptLang.h" |
9 |
|
#include "Oni.h" |
10 |
|
#include "Oni_Character.h" |
11 |
|
#include "dSFMT\dSFMT.h" |
12 |
|
|
13 |
|
uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
14 |
|
{ |
15 |
– |
if (numargs < 2) |
16 |
– |
return 1; |
15 |
|
ret->value_int32 = args[0].value_int32 * args[1].value_int32; |
16 |
|
ret->type = sl_int32; |
17 |
|
return 0; |
19 |
|
|
20 |
|
uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
21 |
|
{ |
24 |
– |
if (numargs < 2) |
25 |
– |
return 1; |
26 |
– |
|
22 |
|
double val1; |
23 |
|
double val2; |
24 |
|
|
39 |
|
|
40 |
|
uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
41 |
|
{ |
47 |
– |
if (numargs < 2) |
48 |
– |
return 1; |
42 |
|
ret->value_int32 = args[0].value_int32 / args[1].value_int32; |
43 |
|
ret->type = sl_int32; |
44 |
|
return 0; |
46 |
|
|
47 |
|
uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
48 |
|
{ |
56 |
– |
if (numargs < 2) |
57 |
– |
return 1; |
58 |
– |
|
49 |
|
double val1; |
50 |
|
double val2; |
51 |
|
|
66 |
|
|
67 |
|
uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
68 |
|
{ |
79 |
– |
if (numargs < 2) |
80 |
– |
return 1; |
81 |
– |
|
69 |
|
int32_t start = 0; |
70 |
|
int32_t end = 0; |
71 |
|
|
113 |
|
{ |
114 |
|
if (numargs < 2) |
115 |
|
return 1; |
116 |
< |
|
116 |
> |
|
117 |
|
char output[255]; |
118 |
|
int i; |
119 |
|
for(i = 1; i < numargs; i++) { |
127 |
|
*/ |
128 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
129 |
|
{ |
130 |
+ |
DDrConsole_PrintF("%d", numargs); |
131 |
+ |
|
132 |
+ |
if (numargs < 1 || args[0].type != sl_str32) |
133 |
+ |
{ |
134 |
+ |
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
135 |
+ |
return 0; |
136 |
+ |
} |
137 |
+ |
|
138 |
+ |
if (!args[0].value_str32) |
139 |
+ |
args[0].value_str32 = ""; |
140 |
+ |
|
141 |
|
int ffi_ret; |
142 |
|
char* str = NULL; |
143 |
|
int size = 0; |
171 |
|
} |
172 |
|
|
173 |
|
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK) |
174 |
< |
MessageBox(0, "", "", 0); |
174 |
> |
return 1; |
175 |
|
ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); |
176 |
|
str = malloc(ffi_ret + 1); |
177 |
|
size = ffi_ret + 1; |
195 |
|
SLrScript_Command_Register_ReturnType("chr_getkills","Gets the number of kills a character has", "[chrindex:int]", sl_int32, bsl_getkills); |
196 |
|
SLrScript_Command_Register_ReturnType("chr_getdamage","Gets the amount of damage a character has caused", "[chrindex:int]", sl_int32, bsl_getdamage); |
197 |
|
|
198 |
< |
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "str1:format", sl_str32, bsl_sprintf); |
198 |
> |
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
199 |
|
} |