DNF_DLL/test/函数块.cpp

675 lines
13 KiB
C++
Raw Normal View History

2022-02-07 03:31:00 +08:00
#include "pch.h"
//<2F><>ȡEXEʹ<45><CAB9>ͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
int GetExeNutWrtNum(int Pos)
{
int num = *(int*)(0x40079F + (Pos * 4));
return num;
}
//дEXEʹ<45><CAB9>ͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
void SetExeNutWrtNum(int Pos, int num)
{
int* p = (int*)(0x40079F + (Pos * 4));
*p = num;
}
//<2F><>ȡNutͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
int GetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos )
{
int num = *(int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8));
return num;
}
//дNutͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
void SetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos, int num)
{
int* p = (int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8));
*p = num;
}
//<2F><><EFBFBD>ڴ<EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
int GetHook(int Addr, std::string <EFBFBD><EFBFBD>ַ)
{
size_t pos = <EFBFBD><EFBFBD>ַ.find("+");
size_t size = <EFBFBD><EFBFBD>ַ.size();
int GetHookArr[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
int i = 0;
while (pos != std::string::npos)
{
std::string x = <EFBFBD><EFBFBD>ַ.substr(0, pos);
GetHookArr[i] = stoi(x, 0, 16);
i++;
<EFBFBD><EFBFBD>ַ = <EFBFBD><EFBFBD>ַ.substr(pos + 1, size);
pos = <EFBFBD><EFBFBD>ַ.find("+");
}
int num;
num = *(int*)(Addr);
if (num != 0)
{
for (int z = 0; z < i; z++)
{
num = *(int*)(num + GetHookArr[z]);
}
}
return num;
}
2022-02-10 14:14:08 +08:00
//<2F><><EFBFBD>ܶ<EFBFBD>ȡ <20><><EFBFBD><EFBFBD> <20><>ַ
int DNFDeCode(int Address)
{
DWORD nEax, nEcx8, nEsi, nEdx, nTmp;
nEax = *(int*)(Address);
if (nEax == -1)
return nEax;
nEcx8 = *(int*)(Address + 8);
if (nEcx8 == -1)
return nEcx8;
nEsi = *(int*)(0x1AF8D78);
nEdx = nEax >> 16;
nTmp = (nEdx << 2) + nEsi + 36;
nEdx = *(int*)(nTmp);
if (nEdx == -1)
return nEdx;
nEax = nEax & 65535;
nTmp = (nEax << 2) + nEdx + 8468;
nEax = *(int*)(nTmp);
if (nEax == -1)
return nEax;
_asm
{
mov eax, nEax
movzx edx, ax
mov nEdx, edx
}
nEsi = nEdx << 16;
nEsi = nEsi | nEdx;
nEax = nEsi ^ nEcx8;
return nEax;
return 0;
}
//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
void DNFEnCode(int AddreSs, int Data)
{
long JEdi, JEcx, JEax, JEsi, JEdx, JSs;
JEcx = AddreSs;
JEax = *(int*)(0x1AF8DB8);
JEax = JEax + 1;
*(int*)(0x1AF8DB8) = JEax;
JEdx = JEax;
JEdx = JEdx >> 8;
JEdx = JEdx << 24;
JEdx = JEdx >> 24;
JEdx = *(int*)(JEdx * 2 + 0x1843F58);
JEdx = JEdx & 0xFFFF;
JEax = JEax << 24;
JEax = JEax >> 24;
JSs = *(int*)(JEax * 2 + 0x1844158);
JSs = JSs & 0xFFFF;
JEdx = JEdx ^ JSs;
JEax = JEdx;
JEax = JEax & 0xFFFF;
JEsi = Data;
JEdx = JEsi >> 16;
Sleep(10);
JSs = JEsi & 0xFFFF;
JEdx = JEdx + JSs;
JEdx = JEdx ^ JEax;
JEdi = JEdx;
JEdx = JEax;
JEax = JEax << 16;
JEax = JEax + JEdx;
JEsi = Data;
JEax = JEax ^ JEsi;
JEsi = AddreSs + 8;
*(int*)(JEsi) = JEax;
JEax = *(int*)(AddreSs);
JEsi = *(int*)(0x1AF8D78);
JEcx = JEdi;
JEcx = JEcx << 16;
JEcx = JEcx + JEdx;
JEdx = JEax;
JEdx = JEdx >> 16;
JEdx = *(int*)(JEsi + JEdx * 4 + 36);
JEax = JEax & 0xFFFF;
*(int*)(JEdx + JEax * 4 + 8468) = JEcx;
}
int GetEquAddr(int addr)
{
switch (addr)
{
case 1:
return 0x3038;
break;
case 2:
return 0x304C;
break;
case 3:
return 0x3048;
break;
case 4:
return 0x3050;
break;
case 5:
return 0x3044;
break;
case 6:
return 0x3040;
break;
case 7:
return 0x3058;
break;
case 8:
return 0x305C;
break;
case 9:
return 0x3054;
break;
case 10:
return 0x3060;
break;
case 11:
return 0x3064;
break;
case 12:
return 0x3038;
break;
case 13:
return 0x3008;
break;
case 14:
return 0x300C;
break;
case 15:
return 0x3010;
break;
case 16:
return 0x3014;
break;
case 17:
return 0x3018;
break;
case 18:
return 0x301C;
break;
case 19:
return 0x3020;
break;
case 20:
return 0x3024;
break;
case 21:
return 0x3028;
break;
case 22:
return 0x302C;
break;
case 23:
return 0x3030;
break;
case 24:
return 0x3068;
break;
case 25:
return 0x306C;
break;
case 26:
return 0x3070;
break;
case 27:
return 0x3074;
break;
}
return -1;
}
2022-02-14 23:35:11 +08:00
//<2F><><EFBFBD><EFBFBD>
static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
{
2022-02-15 20:31:51 +08:00
SQFILE* file = SQfopen(filename, L"rb+");
//FILE* file;
//file = fopen(filename, "rb");
2022-02-14 23:35:11 +08:00
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);
2022-02-21 11:50:52 +08:00
return 1;
2022-02-14 23:35:11 +08:00
}
if (uc != 0xBF)
{
SQ__Fclose(file);
2022-02-21 11:50:52 +08:00
return 1;
2022-02-14 23:35:11 +08:00
}
func = SQ_io_file_lexfeed_UTF8;
break;//UTF-8 ;
default: SQfseek(file, 0, 2); break; // ascii
}
2022-02-17 13:17:46 +08:00
SQfseek(file, 0, 1);//<2F><>λ<EFBFBD><CEBB>β
int length = SQftell(file);//<2F>õ<EFBFBD><C3B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
SQfseek(file, 0, 2);//<2F><>λ<EFBFBD><CEBB>ͷ
2022-02-15 00:51:34 +08:00
2022-02-17 13:17:46 +08:00
char* temp = new char[length+4];//newһ<77><D2BB><EFBFBD>µ<EFBFBD><C2B5>ַ<EFBFBD><D6B7><EFBFBD>
SQfread(temp, sizeof(temp), length, file);//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
temp[length] = '\0';//<2F><><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int key[] = { 5,2,3,5,0 };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Cutecode(temp, key);//<2F><><EFBFBD><EFBFBD>
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"wb+");//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD><C4BC><EFBFBD>
SQwrite(temp, sizeof(temp), strlen(temp), newfile);//д<><D0B4>
SQfseek(file, 0, 2);//<2F><>λ<EFBFBD><CEBB>ͷ
SQfseek(newfile, 0, 2);//<2F><>λ<EFBFBD><CEBB>ͷ
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
2022-02-14 23:35:11 +08:00
{
2022-02-17 13:17:46 +08:00
SQ__Fclose(file);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD>
SQ__Fclose(newfile);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD>
remove("ImagePacks2/sprite_interface_teart_zero.npk");//ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
2022-02-14 23:35:11 +08:00
return SQ_OK;
}
}
SQ__Fclose(file);
return -1;
}
2022-02-21 11:50:52 +08:00
return 1;
2022-02-14 23:35:11 +08:00
}
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;
}
2022-02-10 14:14:08 +08:00
//-------------------------------------------------------------------------------------------Squirrel
//<2F><>ȡSquirrel v <20><>ַ
inline uint32_t GetSqVm()
{
return *(uint32_t*)0x1AF3544;
}
//<2F><><EFBFBD><EFBFBD>nut<75>ӿ<EFBFBD>funcName<6D><65><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>funcAddr
void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
{
if (!v)
v = GetSqVm();
SQPushRootTable(v);
2022-02-13 19:54:59 +08:00
SQPushString(v, funcName, -1);
2022-02-10 14:14:08 +08:00
RealSqNewClosure(v, funcAddr, 0);
SQNewSlot(v, -3, false);
SQPopTop(v);
}
2022-02-13 10:09:55 +08:00
//Test
2022-02-14 23:35:11 +08:00
static int sq_Test(uint32_t v)
2022-02-13 10:09:55 +08:00
{
//sq_pushinteger(v, n1);
return 0;
}
2022-02-10 14:14:08 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetCharacterAttribute(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1 ,n2 ;
int num = SQGetTop(v);
2022-02-10 14:14:08 +08:00
int CharAddr = *(int*)(0x1AB7CDC);
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-10 14:14:08 +08:00
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
int SValue = (TValue + n1);
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
2022-02-14 23:35:11 +08:00
SQPushInt(v, (DNFDeCode(SValue)));
2022-02-10 14:14:08 +08:00
else
2022-02-14 23:35:11 +08:00
SQPushInt(v, (*(int*)(SValue)));
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
else if (num == 2)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
int Value = (CharAddr + n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, (DNFDeCode(Value)));
2022-02-10 14:14:08 +08:00
}
else
{
2022-02-14 23:35:11 +08:00
SQPushString(v, L"parameter error",-1);
2022-02-10 14:14:08 +08:00
}
return 1;
}
//д<><D0B4><EFBFBD><EFBFBD> <20><> װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SetCharacterAttribute(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1, n2, n3;
int num = SQGetTop(v);
2022-02-10 14:14:08 +08:00
int CharAddr = *(int*)(0x1AB7CDC);
2022-02-14 23:35:11 +08:00
if (num == 4)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
SQGetInt(v, 4, &n3);
2022-02-10 14:14:08 +08:00
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
int SValue = (TValue + n1);
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
DNFEnCode(SValue, n3);
else
*(int*)SValue = n3;
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
else if (num == 3)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-10 14:14:08 +08:00
int Value = (CharAddr + n1);
DNFEnCode(Value, n2);
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-10 14:14:08 +08:00
}
else
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownIndex(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1A5E258, "0xAC+0xD4+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetRegionIndex(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, *(int*)(GetHook(0x1A5E258, "0xAC+0xD8+")));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownXpos(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1AB7CE0, "0x2BC+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownYpos(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1AB7CE0, "0x2C0+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SendPackType(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendpacksType(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>Byte
2022-02-14 23:35:11 +08:00
static int SendPackByte(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksByte(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>Word
2022-02-14 23:35:11 +08:00
static int SendPackWord(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksWord(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>DWord
2022-02-14 23:35:11 +08:00
static int SendPackDWord(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksDWord(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SendPack(uint32_t v)
2022-02-10 14:14:08 +08:00
{
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
2022-02-13 10:09:55 +08:00
//<2F><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GivePlayerItem(uint32_t v)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
int n1,n2;
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-13 10:09:55 +08:00
_SendpacksType(*_SendClass, 0, 65);
_SendPacksDWord(*_SendClass, 0, 1);
_SendPacksDWord(*_SendClass, 0, n1);
_SendPacksDWord(*_SendClass, 0, n2);
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-13 10:09:55 +08:00
}
2022-02-14 23:35:11 +08:00
else
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-13 10:09:55 +08:00
}
return 1;
}
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GivePlayerEqu(uint32_t v)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
int n1, n2;
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-13 10:09:55 +08:00
_SendpacksType(*_SendClass, 0, 65);
_SendPacksDWord(*_SendClass, 0, 2);
_SendPacksDWord(*_SendClass, 0, n1);
_SendPacksDWord(*_SendClass, 0, n2);
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-13 10:09:55 +08:00
}
2022-02-14 23:35:11 +08:00
else
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-13 10:09:55 +08:00
}
return 1;
}
2022-02-13 19:54:59 +08:00
//ȥ<><C8A5><EFBFBD><EFBFBD>
static int GoDungeon(uint32_t v)
{
int n1 = 0;
int n2 = 0;
int n3 = 0;
int n4 = 0;
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 19:54:59 +08:00
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;
}
2022-02-14 23:35:11 +08:00
//Ldofile
static int LDofile(uint32_t v)
{
wchar_t* n1;
int num = SQGetTop(v);
if (num == 2)
{
SQGetString(v, 2, &n1);
SQPopTop(v);
2022-02-15 20:31:51 +08:00
/*
size_t len = wcslen(n1) + 1;
size_t converted = 0;
char* CStr;
CStr = (char*)malloc(len * sizeof(char));
wcstombs_s(&converted, CStr, len, n1, _TRUNCATE);
*/
2022-02-14 23:35:11 +08:00
SQdofile(v, n1, false, false);
SQPushBool(v, true);
}
else
{
SQPushBool(v, false);
}
return 1;
}
2022-02-10 14:14:08 +08:00
void RegisterNut()
{
2022-02-13 10:09:55 +08:00
RegisterNutApi(L"L_sq_Test", sq_Test);
2022-02-10 14:14:08 +08:00
RegisterNutApi(L"L_sq_GetCharacterAttribute", GetCharacterAttribute);
RegisterNutApi(L"L_sq_SetCharacterAttribute", SetCharacterAttribute);
RegisterNutApi(L"L_sq_GetTownIndex", GetTownIndex);
RegisterNutApi(L"L_sq_GetRegionIndex", GetRegionIndex);
RegisterNutApi(L"L_sq_GetTownXpos", GetTownXpos);
RegisterNutApi(L"L_sq_GetTownYpos", GetTownYpos);
RegisterNutApi(L"L_sq_SendPackType", SendPackType);
RegisterNutApi(L"L_sq_SendPackByte", SendPackByte);
RegisterNutApi(L"L_sq_SendPackWord", SendPackWord);
RegisterNutApi(L"L_sq_SendPackDWord", SendPackDWord);
RegisterNutApi(L"L_sq_SendPack", SendPack);
2022-02-13 10:09:55 +08:00
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
2022-02-13 19:54:59 +08:00
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
2022-02-14 23:35:11 +08:00
RegisterNutApi(L"L_sq_Dofile", LDofile);
2022-02-10 14:14:08 +08:00
}