This commit is contained in:
Lenheart 2022-02-13 19:54:59 +08:00
parent e30f6a5a26
commit feb4773c65
4 changed files with 68 additions and 10 deletions

View File

@ -27,7 +27,7 @@ uint32_t NewClosure(uint32_t v, void* f, int freeVarsCnt)
return MLnewclosure(v, f, freeVarsCnt);
}
static realSqPushString* MLSqPushString = NULL;
static SqPushStringFunc* MLSqPushString = NULL;
uint32_t NewPushString(uint32_t v, wchar_t* f, int freeVarsCnt)
{

View File

@ -28,12 +28,9 @@
//-------------------------------------------------------------------------------------------Squirrel
// Push 根表
typedef int(SqPushRootT)(uint32_t v);
static SqPushRootT* SQPushRootTable = (SqPushRootT*)0x1358C50;
// Push 函数名
typedef int(realSqPushString)(uint32_t v, const wchar_t* funcName, int a);
static realSqPushString* RealSqPushString = (realSqPushString*)0x1358A60;
// PushRoot
typedef int(SqPushRootFunc)(uint32_t v);
static SqPushRootFunc* SQPushRootTable = (SqPushRootFunc*)0x1358C50;
// Push 函数绑定闭包
typedef int(realSqNewClosure)(uint32_t v, void* funcAddr, int a);
static realSqNewClosure* RealSqNewClosure = (realSqNewClosure*)0x135B850;
@ -61,6 +58,24 @@ static SqGetUserdataFunc* SQGetUserdata = (SqGetUserdataFunc*)0x1358EC0;
//GetObjtypetag
typedef int(SqGetObjtypetagFunc)(uint32_t v, DWORD* up);
static SqGetObjtypetagFunc* SQGetObjtypetag = (SqGetObjtypetagFunc*)0x1358F20;
//GetUserpointer
typedef int(SqGetUserpointerFunc)(uint32_t v, uint32_t idx ,DWORD* up);
static SqGetUserpointerFunc* SQGetUserpointer = (SqGetUserpointerFunc*)0x1358F80;
//GetTop
typedef int(SqGetTopFunc)(uint32_t v);
static SqGetTopFunc* SQGetTop = (SqGetTopFunc*)0x1358FC0;
//PushString
typedef int(SqPushStringFunc)(uint32_t v, const wchar_t* s, int len);
static SqPushStringFunc* SQPushString = (SqPushStringFunc*)0x1358A60;
//PushInt
typedef int(SqPushIntFunc)(uint32_t v, int sint);
static SqPushIntFunc* SQPushInt = (SqPushIntFunc*)0x1358AD0;
//PushBool
typedef int(SqPushBoolFunc)(uint32_t v, bool sbool);
static SqPushBoolFunc* SQPushBool = (SqPushBoolFunc*)0x1358B10;
//PushFloat
typedef int(SqPushFloatFunc)(uint32_t v, float sfloat);
static SqPushFloatFunc* SQPushFloat = (SqPushFloatFunc*)0x1358B60;
//获取Squirrel v 基址
inline uint32_t GetSqVm();

View File

@ -97,7 +97,7 @@
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
@ -117,7 +117,7 @@
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>squirrel.lib;libMinHook.x86.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>

View File

@ -251,7 +251,7 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
if (!v)
v = GetSqVm();
SQPushRootTable(v);
RealSqPushString(v, funcName, -1);
SQPushString(v, funcName, -1);
RealSqNewClosure(v, funcAddr, 0);
SQNewSlot(v, -3, false);
SQPopTop(v);
@ -464,6 +464,48 @@ static SQInteger GivePlayerEqu(HSQUIRRELVM v)
return 1;
}
//È¥¸±±¾
static int GoDungeon(uint32_t v)
{
int n1 = 0;
int n2 = 0;
int n3 = 0;
int n4 = 0;
int num;
num = SQGetTop(v);
if (num == 2)
{
SQGetInt(v, 2, &n1);
}
else if (num == 5)
{
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
SQGetInt(v, 4, &n3);
SQGetInt(v, 5, &n4);
}
else
{
SQPushBool(v, false);
return 1;
}
_SendpacksType(*_SendClass, 0, 15);
_SendPacks();
_SendpacksType(*_SendClass, 0, 16);
_SendPacksWord(*_SendClass, 0, n1);
_SendPacksByte(*_SendClass, 0, n2);
_SendPacksByte(*_SendClass, 0, n3);
_SendPacksByte(*_SendClass, 0, n4);
_SendPacks();
SQPushBool(v, true);
return 1;
}
void RegisterNut()
{
RegisterNutApi(L"L_sq_Test", sq_Test);
@ -480,6 +522,7 @@ void RegisterNut()
RegisterNutApi(L"L_sq_SendPack", SendPack);
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
}