1212
This commit is contained in:
parent
366de77a2c
commit
bca515b799
|
|
@ -78,10 +78,13 @@ int HOOK()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void testcall()
|
void testcall()
|
||||||
{
|
{
|
||||||
|
//SQdofile(GetSqVm(), L"1.cpp", false, false);
|
||||||
|
//SQloadfile(GetSqVm(), L"1.cpp", false);
|
||||||
|
|
||||||
|
|
||||||
//SQDofile(GetSqVm(),L"1.cpp",0,0);
|
//SQDofile(GetSqVm(),L"1.cpp",0,0);
|
||||||
//std::cout << gm(0x186FB828) << std::endl;
|
//std::cout << gm(0x186FB828) << std::endl;
|
||||||
|
|
||||||
|
|
|
||||||
54
test/pch.h
54
test/pch.h
|
|
@ -56,8 +56,11 @@ static SqGetlocal* SQGetlocal = (SqGetlocal*)0x135AFD0;
|
||||||
typedef int (Sq_Wakeupvm)(uint32_t v, int n, int retval, int raiseerror);
|
typedef int (Sq_Wakeupvm)(uint32_t v, int n, int retval, int raiseerror);
|
||||||
static Sq_Wakeupvm* SQ_Wakeupvm = (Sq_Wakeupvm*)0x135B0D0;
|
static Sq_Wakeupvm* SQ_Wakeupvm = (Sq_Wakeupvm*)0x135B0D0;
|
||||||
//SQ_Call
|
//SQ_Call
|
||||||
typedef int (Sq_Call)(uint32_t v, int params, int retval, int raiseerror);
|
typedef int (Sq_CallFunc)(uint32_t v, int params, int retval, int raiseerror);
|
||||||
static Sq_Call* SQ_Call = (Sq_Call*)0x1359280;
|
static Sq_CallFunc* SQ_Call = (Sq_CallFunc*)0x1359280;
|
||||||
|
//SQ_Remove
|
||||||
|
typedef int (SQ_RemoveFunc)(uint32_t v, int idx);
|
||||||
|
static SQ_RemoveFunc* SQ_Remove = (SQ_RemoveFunc*)0x1359000;
|
||||||
//GetInt
|
//GetInt
|
||||||
typedef int(SqGetIntFunc)(uint32_t v, uint32_t stackIndex, int* sint);
|
typedef int(SqGetIntFunc)(uint32_t v, uint32_t stackIndex, int* sint);
|
||||||
static SqGetIntFunc* SQGetInt = (SqGetIntFunc*)0x1358D70;
|
static SqGetIntFunc* SQGetInt = (SqGetIntFunc*)0x1358D70;
|
||||||
|
|
@ -82,6 +85,9 @@ static SqGetUserpointerFunc* SQGetUserpointer = (SqGetUserpointerFunc*)0x1358F80
|
||||||
//GetTop
|
//GetTop
|
||||||
typedef int(SqGetTopFunc)(uint32_t v);
|
typedef int(SqGetTopFunc)(uint32_t v);
|
||||||
static SqGetTopFunc* SQGetTop = (SqGetTopFunc*)0x1358FC0;
|
static SqGetTopFunc* SQGetTop = (SqGetTopFunc*)0x1358FC0;
|
||||||
|
//Push
|
||||||
|
typedef int(SqPushFunc)(uint32_t v, int idx);
|
||||||
|
static SqPushFunc* SQPush = (SqPushFunc*)0x1358C90;
|
||||||
//PushString
|
//PushString
|
||||||
typedef int(SqPushStringFunc)(uint32_t v, const wchar_t* s, int len);
|
typedef int(SqPushStringFunc)(uint32_t v, const wchar_t* s, int len);
|
||||||
static SqPushStringFunc* SQPushString = (SqPushStringFunc*)0x1358A60;
|
static SqPushStringFunc* SQPushString = (SqPushStringFunc*)0x1358A60;
|
||||||
|
|
@ -95,6 +101,48 @@ static SqPushBoolFunc* SQPushBool = (SqPushBoolFunc*)0x1358B10;
|
||||||
typedef int(SqPushFloatFunc)(uint32_t v, float sfloat);
|
typedef int(SqPushFloatFunc)(uint32_t v, float sfloat);
|
||||||
static SqPushFloatFunc* SQPushFloat = (SqPushFloatFunc*)0x1358B60;
|
static SqPushFloatFunc* SQPushFloat = (SqPushFloatFunc*)0x1358B60;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//SQLOADFILE
|
||||||
|
typedef void* (SQLOADFILEFunc)(uint32_t v, const wchar_t* filename, bool printerror);
|
||||||
|
static SQLOADFILEFunc* SQLOADFILEF = (SQLOADFILEFunc*)0x13560E0;
|
||||||
|
//SQDOFILE
|
||||||
|
typedef void* (SQDOFILEFunc)(uint32_t v, const wchar_t* filename, bool retval, bool printerror);
|
||||||
|
static SQDOFILEFunc* SQDOFILE = (SQDOFILEFunc*)0x1356240;
|
||||||
|
|
||||||
|
|
||||||
|
//SQ_io_file_lexfeed_编码
|
||||||
|
//typedef int(LSQLEXREADFUNC)(int n);
|
||||||
|
typedef int(*LSQLEXREADFUNC)(int n);
|
||||||
|
static LSQLEXREADFUNC SQ_io_file_lexfeed_ASCII = (LSQLEXREADFUNC)0x1355F60;
|
||||||
|
static LSQLEXREADFUNC SQ_io_file_lexfeed_UCS2_BE = (LSQLEXREADFUNC)0x1356050;
|
||||||
|
static LSQLEXREADFUNC SQ_io_file_lexfeed_UCS2_LE = (LSQLEXREADFUNC)0x1356020;
|
||||||
|
static LSQLEXREADFUNC SQ_io_file_lexfeed_UTF8 = (LSQLEXREADFUNC)0x1355F90;
|
||||||
|
//SQfopen
|
||||||
|
typedef void* (SQfopenFunc)(const wchar_t* filename, const wchar_t* type);
|
||||||
|
static SQfopenFunc* SQfopen = (SQfopenFunc*)0x1355DC0;
|
||||||
|
//SQfread
|
||||||
|
typedef int(SQfreadFunc)(void* buffer, int a, int b, void* file);
|
||||||
|
static SQfreadFunc* SQfread = (SQfreadFunc*)0x1355DD0;
|
||||||
|
//SQfseek
|
||||||
|
typedef int(SQfseekFunc)(void* buffer, int a, int b);
|
||||||
|
static SQfseekFunc* SQfseek = (SQfseekFunc*)0x1355DF0;
|
||||||
|
//SQ_File_read
|
||||||
|
typedef int(SQ_File_readFunc)(void* file, void* afile, int a);
|
||||||
|
static SQ_File_readFunc* SQ_File_read = (SQ_File_readFunc*)0x1356090;
|
||||||
|
//SQ_Readclosure
|
||||||
|
typedef int(SQ_ReadclosureFunc)(uint32_t v, SQ_File_readFunc a, void* file);
|
||||||
|
static SQ_ReadclosureFunc* SQ_Readclosure = (SQ_ReadclosureFunc*)0x1359460;
|
||||||
|
//SQ_Fclose
|
||||||
|
typedef int(SQ__FcloseFunc)(void* file);
|
||||||
|
static SQ__FcloseFunc* SQ__Fclose = (SQ__FcloseFunc*)0x1355E70;
|
||||||
|
//SQ_Compile
|
||||||
|
typedef int(SQ_CompileFunc)(uint32_t v, LSQLEXREADFUNC FUNC, void* file, const wchar_t* filename, bool printerror);
|
||||||
|
static SQ_CompileFunc* SQ_Compile = (SQ_CompileFunc*)0x135A390;
|
||||||
|
//SQ_Throwerror
|
||||||
|
typedef int(SQ_ThrowerrorFunc)(uint32_t v, const wchar_t* error);
|
||||||
|
static SQ_ThrowerrorFunc* SQ_Throwerror = (SQ_ThrowerrorFunc*)0x13591A0;
|
||||||
|
|
||||||
//获取Squirrel v 基址
|
//获取Squirrel v 基址
|
||||||
inline uint32_t GetSqVm();
|
inline uint32_t GetSqVm();
|
||||||
|
|
||||||
|
|
@ -168,8 +216,6 @@ static int GoDungeon(uint32_t v)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//获取EXE使用头 号位数据
|
//获取EXE使用头 号位数据
|
||||||
int GetExeNutWrtNum(int Pos);
|
int GetExeNutWrtNum(int Pos);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
@ -112,12 +112,13 @@
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
<AdditionalDependencies>squirrel.lib;libMinHook.x86.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>squirrel.lib;libMinHook.x86.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
||||||
271
test/函数块.cpp
271
test/函数块.cpp
|
|
@ -237,6 +237,96 @@ int GetEquAddr(int addr)
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
//¼ÓÔØ
|
||||||
|
static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
|
||||||
|
{
|
||||||
|
void* file = SQfopen(filename, L"rb");
|
||||||
|
//void* file = (void*)"IIIAAA <- 66487";
|
||||||
|
int ret;
|
||||||
|
unsigned short us;
|
||||||
|
unsigned char uc;
|
||||||
|
LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
ret = SQfread(&us, 1, 2, file);
|
||||||
|
if (ret != 2)
|
||||||
|
{
|
||||||
|
us = 0;
|
||||||
|
}
|
||||||
|
if (us == 0xFAFA)
|
||||||
|
{
|
||||||
|
SQfseek(file, 0, 2);
|
||||||
|
if (SQ_Readclosure(v, SQ_File_read, file) > 0)
|
||||||
|
{
|
||||||
|
SQ__Fclose(file);
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (us)
|
||||||
|
{
|
||||||
|
case 0xFFFE: func = SQ_io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian;
|
||||||
|
case 0xFEFF: func = SQ_io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian;
|
||||||
|
case 0xBBEF:
|
||||||
|
if (SQfread(&uc, 1, sizeof(uc), file) == 0)
|
||||||
|
{
|
||||||
|
SQ__Fclose(file);
|
||||||
|
return SQ_Throwerror(v, _SC("io error"));
|
||||||
|
}
|
||||||
|
if (uc != 0xBF)
|
||||||
|
{
|
||||||
|
SQ__Fclose(file);
|
||||||
|
return SQ_Throwerror(v, _SC("Unrecognozed ecoding"));
|
||||||
|
}
|
||||||
|
func = SQ_io_file_lexfeed_UTF8;
|
||||||
|
break;//UTF-8 ;
|
||||||
|
default: SQfseek(file, 0, 2); break; // ascii
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SQ_Compile(v, func, file, filename, printerror) >= 0)
|
||||||
|
{
|
||||||
|
SQ__Fclose(file);
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SQ__Fclose(file);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return SQ_Throwerror(v, _SC("cannot open the file"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror)
|
||||||
|
{
|
||||||
|
if (SQloadfile(v, filename, printerror) >= 0)
|
||||||
|
{
|
||||||
|
SQPush(v, -2);
|
||||||
|
if ((int)SQ_Call(v, 1, retval, 1) >= 0)
|
||||||
|
{
|
||||||
|
SQ_Remove(v, -(retval != 0) - 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
SQPop(v, 1);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------Squirrel
|
//-------------------------------------------------------------------------------------------Squirrel
|
||||||
|
|
@ -256,209 +346,210 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
|
||||||
SQNewSlot(v, -3, false);
|
SQNewSlot(v, -3, false);
|
||||||
SQPopTop(v);
|
SQPopTop(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Test
|
//Test
|
||||||
static SQInteger sq_Test(uint32_t v)
|
static int sq_Test(uint32_t v)
|
||||||
{
|
{
|
||||||
|
|
||||||
//sq_pushinteger(v, n1);
|
//sq_pushinteger(v, n1);
|
||||||
|
SQdofile(v, L"1.cpp", false, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//读人物 或 装备属性
|
//读人物 或 装备属性
|
||||||
static SQInteger GetCharacterAttribute(HSQUIRRELVM v)
|
static int GetCharacterAttribute(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1 ,n2 ;
|
int n1 ,n2 ;
|
||||||
sq_getinteger(v, 2, &n1);
|
int num = SQGetTop(v);
|
||||||
sq_getinteger(v, 3, &n2);
|
|
||||||
int CharAddr = *(int*)(0x1AB7CDC);
|
int CharAddr = *(int*)(0x1AB7CDC);
|
||||||
if (n1 > 0 && n2 > 0 && n2 <= 27)
|
if (num == 3)
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
|
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
|
||||||
int SValue = (TValue + n1);
|
int SValue = (TValue + n1);
|
||||||
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
||||||
sq_pushinteger(v, (SQInteger)(DNFDeCode(SValue)));
|
SQPushInt(v, (DNFDeCode(SValue)));
|
||||||
else
|
else
|
||||||
sq_pushinteger(v, (SQInteger)(*(int*)(SValue)));
|
SQPushInt(v, (*(int*)(SValue)));
|
||||||
}
|
}
|
||||||
else if (n1 > 0)
|
else if (num == 2)
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
int Value = (CharAddr + n1);
|
int Value = (CharAddr + n1);
|
||||||
|
|
||||||
sq_pushinteger(v, (SQInteger)(DNFDeCode(Value)));
|
SQPushInt(v, (DNFDeCode(Value)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, -1);
|
SQPushString(v, L"parameter error",-1);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//写人物 或 装备属性
|
//写人物 或 装备属性
|
||||||
static SQInteger SetCharacterAttribute(HSQUIRRELVM v)
|
static int SetCharacterAttribute(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1, n2,n3;
|
int n1, n2, n3;
|
||||||
sq_getinteger(v, 2, &n1);
|
|
||||||
sq_getinteger(v, 3, &n2);
|
int num = SQGetTop(v);
|
||||||
sq_getinteger(v, 4, &n3);
|
|
||||||
|
|
||||||
std::cout << n1 << std::endl;
|
|
||||||
std::cout << n2 << std::endl;
|
|
||||||
std::cout << n3 << std::endl;
|
|
||||||
|
|
||||||
int CharAddr = *(int*)(0x1AB7CDC);
|
int CharAddr = *(int*)(0x1AB7CDC);
|
||||||
if (n1 > 0 && n2 > 0 && n3 > 0)
|
if (num == 4)
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
|
SQGetInt(v, 4, &n3);
|
||||||
|
|
||||||
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
|
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
|
||||||
int SValue = (TValue + n1);
|
int SValue = (TValue + n1);
|
||||||
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
||||||
//sq_pushinteger(v, (SQInteger)(DNFDeCode(SValue)));
|
|
||||||
DNFEnCode(SValue, n3);
|
DNFEnCode(SValue, n3);
|
||||||
else
|
else
|
||||||
//sq_pushinteger(v, (SQInteger)(*(int*)(SValue)));
|
|
||||||
*(int*)SValue = n3;
|
*(int*)SValue = n3;
|
||||||
sq_pushinteger(v, (SQInteger)1);
|
SQPushBool(v, true);
|
||||||
}
|
}
|
||||||
else if (n1 > 0 && n2 >0)
|
else if (num == 3)
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
|
|
||||||
int Value = (CharAddr + n1);
|
int Value = (CharAddr + n1);
|
||||||
DNFEnCode(Value, n2);
|
DNFEnCode(Value, n2);
|
||||||
sq_pushinteger(v, (SQInteger)1);
|
SQPushBool(v, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, -1);
|
SQPushBool(v, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sq_pushinteger(v, -1);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//获取城镇编号
|
//获取城镇编号
|
||||||
static SQInteger GetTownIndex(HSQUIRRELVM v)
|
static int GetTownIndex(uint32_t v)
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, GetHook(0x1A5E258, "0xAC+0xD4+"));
|
SQPushInt(v, GetHook(0x1A5E258, "0xAC+0xD4+"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//获取城镇区域编号
|
//获取城镇区域编号
|
||||||
static SQInteger GetRegionIndex(HSQUIRRELVM v)
|
static int GetRegionIndex(uint32_t v)
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, *(int*)(GetHook(0x1A5E258, "0xAC+0xD8+")));
|
SQPushInt(v, *(int*)(GetHook(0x1A5E258, "0xAC+0xD8+")));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//获取城镇X坐标
|
//获取城镇X坐标
|
||||||
static SQInteger GetTownXpos(HSQUIRRELVM v)
|
static int GetTownXpos(uint32_t v)
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, GetHook(0x1AB7CE0, "0x2BC+"));
|
SQPushInt(v, GetHook(0x1AB7CE0, "0x2BC+"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//获取城镇Y坐标
|
//获取城镇Y坐标
|
||||||
static SQInteger GetTownYpos(HSQUIRRELVM v)
|
static int GetTownYpos(uint32_t v)
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, GetHook(0x1AB7CE0, "0x2C0+"));
|
SQPushInt(v, GetHook(0x1AB7CE0, "0x2C0+"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发包类型
|
//发包类型
|
||||||
static SQInteger SendPackType(HSQUIRRELVM v)
|
static int SendPackType(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1;
|
int n1;
|
||||||
sq_getinteger(v, 2, &n1);
|
SQGetInt(v, 2, &n1);
|
||||||
_SendpacksType(*_SendClass, 0, n1);
|
_SendpacksType(*_SendClass, 0, n1);
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushInt(v, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发包Byte
|
//发包Byte
|
||||||
static SQInteger SendPackByte(HSQUIRRELVM v)
|
static int SendPackByte(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1;
|
int n1;
|
||||||
sq_getinteger(v, 2, &n1);
|
SQGetInt(v, 2, &n1);
|
||||||
_SendPacksByte(*_SendClass, 0, n1);
|
_SendPacksByte(*_SendClass, 0, n1);
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushInt(v, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发包Word
|
//发包Word
|
||||||
static SQInteger SendPackWord(HSQUIRRELVM v)
|
static int SendPackWord(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1;
|
int n1;
|
||||||
sq_getinteger(v, 2, &n1);
|
SQGetInt(v, 2, &n1);
|
||||||
_SendPacksWord(*_SendClass, 0, n1);
|
_SendPacksWord(*_SendClass, 0, n1);
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushInt(v, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发包DWord
|
//发包DWord
|
||||||
static SQInteger SendPackDWord(HSQUIRRELVM v)
|
static int SendPackDWord(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1;
|
int n1;
|
||||||
sq_getinteger(v, 2, &n1);
|
SQGetInt(v, 2, &n1);
|
||||||
_SendPacksDWord(*_SendClass, 0, n1);
|
_SendPacksDWord(*_SendClass, 0, n1);
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushInt(v, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发包
|
//发包
|
||||||
static SQInteger SendPack(HSQUIRRELVM v)
|
static int SendPack(uint32_t v)
|
||||||
{
|
{
|
||||||
_SendPacks();
|
_SendPacks();
|
||||||
sq_pushinteger(v, 1);
|
SQPushInt(v, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发物品给玩家
|
//发物品给玩家
|
||||||
static SQInteger GivePlayerItem(HSQUIRRELVM v)
|
static int GivePlayerItem(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1,n2;
|
int n1,n2;
|
||||||
|
|
||||||
|
int num = SQGetTop(v);
|
||||||
|
|
||||||
sq_getinteger(v, 2, &n1);
|
if (num == 3)
|
||||||
sq_getinteger(v, 3, &n2);
|
|
||||||
|
|
||||||
if (n1>0 && n2>0)
|
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
|
|
||||||
_SendpacksType(*_SendClass, 0, 65);
|
_SendpacksType(*_SendClass, 0, 65);
|
||||||
_SendPacksDWord(*_SendClass, 0, 1);
|
_SendPacksDWord(*_SendClass, 0, 1);
|
||||||
_SendPacksDWord(*_SendClass, 0, n1);
|
_SendPacksDWord(*_SendClass, 0, n1);
|
||||||
_SendPacksDWord(*_SendClass, 0, n2);
|
_SendPacksDWord(*_SendClass, 0, n2);
|
||||||
_SendPacks();
|
_SendPacks();
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushBool(v, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!n1 || !n2)
|
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, 0);
|
SQPushBool(v, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发装备给玩家
|
//发装备给玩家
|
||||||
static SQInteger GivePlayerEqu(HSQUIRRELVM v)
|
static int GivePlayerEqu(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n1, n2;
|
int n1, n2;
|
||||||
|
|
||||||
|
int num = SQGetTop(v);
|
||||||
|
|
||||||
sq_getinteger(v, 2, &n1);
|
if (num == 3)
|
||||||
sq_getinteger(v, 3, &n2);
|
|
||||||
|
|
||||||
if (n1 > 0 && n2 > 0)
|
|
||||||
{
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
|
|
||||||
_SendpacksType(*_SendClass, 0, 65);
|
_SendpacksType(*_SendClass, 0, 65);
|
||||||
_SendPacksDWord(*_SendClass, 0, 2);
|
_SendPacksDWord(*_SendClass, 0, 2);
|
||||||
_SendPacksDWord(*_SendClass, 0, n1);
|
_SendPacksDWord(*_SendClass, 0, n1);
|
||||||
_SendPacksDWord(*_SendClass, 0, n2);
|
_SendPacksDWord(*_SendClass, 0, n2);
|
||||||
_SendPacks();
|
_SendPacks();
|
||||||
|
|
||||||
sq_pushinteger(v, 1);
|
SQPushBool(v, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!n1 || !n2)
|
|
||||||
{
|
{
|
||||||
sq_pushinteger(v, 0);
|
SQPushBool(v, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -472,8 +563,7 @@ static int GoDungeon(uint32_t v)
|
||||||
int n3 = 0;
|
int n3 = 0;
|
||||||
int n4 = 0;
|
int n4 = 0;
|
||||||
|
|
||||||
int num;
|
int num = SQGetTop(v);
|
||||||
num = SQGetTop(v);
|
|
||||||
|
|
||||||
if (num == 2)
|
if (num == 2)
|
||||||
{
|
{
|
||||||
|
|
@ -506,6 +596,28 @@ static int GoDungeon(uint32_t v)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ldofile
|
||||||
|
static int LDofile(uint32_t v)
|
||||||
|
{
|
||||||
|
wchar_t* n1;
|
||||||
|
|
||||||
|
int num = SQGetTop(v);
|
||||||
|
|
||||||
|
if (num == 2)
|
||||||
|
{
|
||||||
|
SQGetString(v, 2, &n1);
|
||||||
|
SQPopTop(v);
|
||||||
|
SQdofile(v, n1, false, false);
|
||||||
|
SQPushBool(v, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SQPushBool(v, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterNut()
|
void RegisterNut()
|
||||||
{
|
{
|
||||||
RegisterNutApi(L"L_sq_Test", sq_Test);
|
RegisterNutApi(L"L_sq_Test", sq_Test);
|
||||||
|
|
@ -523,6 +635,7 @@ void RegisterNut()
|
||||||
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
|
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
|
||||||
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
|
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
|
||||||
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
|
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
|
||||||
|
RegisterNutApi(L"L_sq_Dofile", LDofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue