1211
This commit is contained in:
@@ -33,7 +33,7 @@ int squirrel::SQloadfile(uint32_t v, const wchar_t* filename, BOOL printerror)
|
||||
fwrite(ar, 1, da, outfile);
|
||||
|
||||
fclose(outfile);//关闭文件
|
||||
free(ar);//释放内存
|
||||
delete []ar;//释放内存
|
||||
|
||||
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb");//定义新的文件流
|
||||
|
||||
@@ -102,12 +102,173 @@ int squirrel::SQdofile(uint32_t v, const wchar_t* filename, BOOL retval, BOOL pr
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//获取对象地址
|
||||
int squirrel::GetObjectAddress(uint32_t v)
|
||||
{
|
||||
int objAddress = GetSqrObject(v, 2);
|
||||
SQPushInt(v, objAddress);
|
||||
return 1;
|
||||
}
|
||||
//获取对象名称
|
||||
int squirrel::GetObjectName(uint32_t v)
|
||||
{
|
||||
int objAddress = GetSqrObject(v, 2);
|
||||
int objNameAddress = *(int*)(objAddress + 0x258);
|
||||
char* str = DNFTOOL::UnicodeToUtf8((wchar_t*)objNameAddress);
|
||||
wchar_t* name = DNFTOOL::charTowchar_t(str);
|
||||
free (str);
|
||||
SQPushString(v, name, -1);
|
||||
delete[]name;
|
||||
return 1;
|
||||
}
|
||||
//获取对象等级
|
||||
int squirrel::GetObjectLevel(uint32_t v)
|
||||
{
|
||||
int objAddress = GetSqrObject(v, 2);
|
||||
int Level = DNFTOOL::DNFDeCode(objAddress + 0x1A4C);
|
||||
SQPushInt(v, Level);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
////GetBool
|
||||
//typedef DWORD(__fastcall _FontInit)(DWORD thisc, DWORD Seat);
|
||||
//static _FontInit* sub_11BE9A0 = (_FontInit*)0x11BE9A0;
|
||||
//static _FontInit* sub_11BE980 = (_FontInit*)0x11BE980;
|
||||
//static _FontInit* sub_1206570 = (_FontInit*)0x1206570;
|
||||
//
|
||||
//typedef DWORD(__fastcall _FontC)(DWORD thisc, DWORD Seat, DWORD Font);
|
||||
//static _FontC* sub_1206550 = (_FontC*)0x1206550;
|
||||
|
||||
//Test
|
||||
|
||||
|
||||
//窗口CALL
|
||||
typedef void(__fastcall* NNoticeTCall)(DWORD thisc, DWORD Seat, DWORD a1, wchar_t* a2, DWORD a3, DWORD a4, DWORD a5);
|
||||
static NNoticeTCall _ANoticeTcall = (NNoticeTCall)0xE6E070;
|
||||
|
||||
typedef int(_cdecl _sub7AAB60)(int a1);
|
||||
static _sub7AAB60* getitemimg = (_sub7AAB60*)0x7aab60;
|
||||
|
||||
int squirrel::sq_GetImg(uint32_t v)
|
||||
{
|
||||
int a1;
|
||||
SQGetInt(v, 2, &a1);
|
||||
|
||||
int img = getitemimg(a1);
|
||||
SQPushInt(v, img);
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef int(_cdecl _sub7AA800)(int a1, int a2, int a3, int a4, int a5, int a6, char a7);
|
||||
static _sub7AA800* drawimg = (_sub7AA800*)0x7aa800;
|
||||
|
||||
|
||||
int squirrel::sq_Test(uint32_t v)
|
||||
{
|
||||
int a1, a2, a3,a4,a5,a6,a7;
|
||||
SQGetInt(v, 2, &a1);
|
||||
SQGetInt(v, 3, &a2);
|
||||
SQGetInt(v, 4, &a3);
|
||||
SQGetInt(v, 5, &a4);
|
||||
SQGetInt(v, 6, &a5);
|
||||
SQGetInt(v, 7, &a6);
|
||||
SQGetInt(v, 8, &a7);
|
||||
|
||||
int img = getitemimg(a3);
|
||||
drawimg(a1, a2, img, a4, a5, a6, a7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//输出
|
||||
int squirrel::Sout(uint32_t v)
|
||||
{
|
||||
int Top = SQGetTop(v);
|
||||
if (Top <= 0)
|
||||
{
|
||||
SQ_Throwerror(v, L"Incorrect function argument");
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t* OutPutBuffer;
|
||||
SQGetString(v, 2, &OutPutBuffer);
|
||||
char* OutPutText = DNFTOOL::SquirrelU2W(OutPutBuffer);
|
||||
|
||||
std::vector<std::string> Data;
|
||||
DNFTOOL::Split(OutPutText, Data, "%L");
|
||||
delete []OutPutText;
|
||||
|
||||
if (Top != Data.size() + 1)
|
||||
{
|
||||
SQ_Throwerror(v, L"Incorrect function argument");
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Fnum = Data.size();
|
||||
if (Fnum > 1)Fnum -= 1;
|
||||
std::string Text = "";
|
||||
for (size_t i = 0; i < Fnum; i++)
|
||||
{
|
||||
std::string Parameter;
|
||||
//获取值的类型
|
||||
int ValueType = SQ_GetType(v, 3 + i);
|
||||
//判断值类型
|
||||
switch (ValueType)
|
||||
{
|
||||
case OT_INTEGER://int类型
|
||||
{
|
||||
int Value;
|
||||
SQGetInt(v, 3 + i, &Value);
|
||||
Parameter = std::to_string(Value);
|
||||
break;
|
||||
}
|
||||
case OT_FLOAT://float类型
|
||||
{
|
||||
FLOAT Value;
|
||||
SQGetFloat(v, 3 + i, &Value);
|
||||
std::ostringstream oss;
|
||||
oss << Value;
|
||||
std::string str(oss.str());
|
||||
Parameter = str;
|
||||
break;
|
||||
}
|
||||
case OT_BOOL://bool类型
|
||||
{
|
||||
BOOL Value;
|
||||
SQGetBool(v, 3 + i, &Value);
|
||||
switch (Value)
|
||||
{
|
||||
case true:
|
||||
Parameter = "true";
|
||||
break;
|
||||
case false:
|
||||
Parameter = "false";
|
||||
break;
|
||||
}
|
||||
//Parameter = std::to_string(Value);
|
||||
break;
|
||||
}
|
||||
case OT_STRING://string类型
|
||||
{
|
||||
wchar_t* Value;
|
||||
SQGetString(v, 3 + i, &Value);
|
||||
char* str = DNFTOOL::SquirrelU2W(Value);
|
||||
Parameter = str;
|
||||
delete []str;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Parameter = " ";
|
||||
break;
|
||||
}
|
||||
Text += Data[i];
|
||||
Text += Parameter;
|
||||
}
|
||||
std::cout << Text << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//读人物 或 装备属性
|
||||
int squirrel::GetCharacterAttribute(uint32_t v)
|
||||
{
|
||||
@@ -119,9 +280,11 @@ int squirrel::GetCharacterAttribute(uint32_t v)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
SQGetInt(v, 3, &n2);
|
||||
int TValue = *(int*)(CharAddr + DNFTOOL::GetEquAddr(n2));
|
||||
int TValue = *(int*)(CharAddr+DNFTOOL::GetEquAddr(n2));
|
||||
int SValue = (TValue + n1);
|
||||
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
||||
if(SValue < 0x400000)
|
||||
SQPushInt(v, 0);
|
||||
else if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4 && n1 != 0x854)
|
||||
SQPushInt(v, (DNFTOOL::DNFDeCode(SValue)));
|
||||
else
|
||||
SQPushInt(v, (*(int*)(SValue)));
|
||||
@@ -155,7 +318,9 @@ int squirrel::SetCharacterAttribute(uint32_t v)
|
||||
|
||||
int TValue = *(int*)(CharAddr + DNFTOOL::GetEquAddr(n2));
|
||||
int SValue = (TValue + n1);
|
||||
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
||||
if (SValue < 0x400000)
|
||||
SQPushBool(v, false);
|
||||
else if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
|
||||
DNFTOOL::DNFEnCode(SValue, n3);
|
||||
else
|
||||
*(int*)SValue = n3;
|
||||
@@ -224,6 +389,10 @@ int squirrel::GetFatigue(uint32_t v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//获取经验值
|
||||
@@ -249,6 +418,10 @@ int squirrel::GetExp(uint32_t v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -260,119 +433,107 @@ int squirrel::GetExp(uint32_t v)
|
||||
int squirrel::SendPackType(uint32_t v)
|
||||
{
|
||||
int n1;
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendpacksType(*_SendClass, 0, n1);
|
||||
int num = SQGetTop(v);
|
||||
if (num == 2)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendpacksType(*_SendClass, 0, n1);
|
||||
|
||||
SQPushInt(v, 1);
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//发包Byte
|
||||
int squirrel::SendPackByte(uint32_t v)
|
||||
{
|
||||
int n1;
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksByte(*_SendClass, 0, n1);
|
||||
|
||||
SQPushInt(v, 1);
|
||||
int num = SQGetTop(v);
|
||||
if (num == 2)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksByte(*_SendClass, 0, n1);
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//发包Word
|
||||
int squirrel::SendPackWord(uint32_t v)
|
||||
{
|
||||
int n1;
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksWord(*_SendClass, 0, n1);
|
||||
|
||||
SQPushInt(v, 1);
|
||||
int num = SQGetTop(v);
|
||||
if (num == 2)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksWord(*_SendClass, 0, n1);
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//发包DWord
|
||||
int squirrel::SendPackDWord(uint32_t v)
|
||||
{
|
||||
int n1;
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksDWord(*_SendClass, 0, n1);
|
||||
|
||||
SQPushInt(v, 1);
|
||||
int num = SQGetTop(v);
|
||||
if (num == 2)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
_SendPacksDWord(*_SendClass, 0, n1);
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//发包wchar_t* (转了char*)
|
||||
int squirrel::SendPackWChar(uint32_t v)
|
||||
{
|
||||
wchar_t* n1;
|
||||
|
||||
SQGetString(v, 2, &n1);
|
||||
|
||||
//wchar_t* 转 char*
|
||||
char* fname = DNFTOOL::wchar_tTochar(n1);
|
||||
_SendPacksChar(*_SendClass, 0, fname, strlen(fname));
|
||||
|
||||
SQPushInt(v, 1);
|
||||
int num = SQGetTop(v);
|
||||
if (num == 2)
|
||||
{
|
||||
SQGetString(v, 2, &n1);
|
||||
//wchar_t* 转 char*
|
||||
char* fname = DNFTOOL::wchar_tTochar(n1);
|
||||
_SendPacksChar(*_SendClass, 0, fname, strlen(fname));
|
||||
delete []fname;
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//发包
|
||||
int squirrel::SendPack(uint32_t v)
|
||||
{
|
||||
_SendPacks();
|
||||
SQPushInt(v, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//发物品给玩家
|
||||
int squirrel::GivePlayerItem(uint32_t v)
|
||||
{
|
||||
int n1, n2;
|
||||
|
||||
int num = SQGetTop(v);
|
||||
|
||||
if (num == 3)
|
||||
if (num == 1)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
SQGetInt(v, 3, &n2);
|
||||
|
||||
_SendpacksType(*_SendClass, 0, 65);
|
||||
_SendPacksDWord(*_SendClass, 0, 1);
|
||||
_SendPacksDWord(*_SendClass, 0, n1);
|
||||
_SendPacksDWord(*_SendClass, 0, n2);
|
||||
_SendPacks();
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
SQPushString(v, L"parameter error", -1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
//发装备给玩家
|
||||
int squirrel::GivePlayerEqu(uint32_t v)
|
||||
{
|
||||
int n1, n2;
|
||||
|
||||
int num = SQGetTop(v);
|
||||
|
||||
if (num == 3)
|
||||
{
|
||||
SQGetInt(v, 2, &n1);
|
||||
SQGetInt(v, 3, &n2);
|
||||
|
||||
_SendpacksType(*_SendClass, 0, 65);
|
||||
_SendPacksDWord(*_SendClass, 0, 2);
|
||||
_SendPacksDWord(*_SendClass, 0, n1);
|
||||
_SendPacksDWord(*_SendClass, 0, n2);
|
||||
_SendPacks();
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//去副本
|
||||
int squirrel::GoDungeon(uint32_t v)
|
||||
@@ -492,6 +653,128 @@ int squirrel::LDofile(uint32_t v)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//内存操作
|
||||
#if defined ADDRESS_API_SWITCH
|
||||
//读内存
|
||||
int squirrel::LReadAddress(uint32_t v)
|
||||
{
|
||||
//内存地址 int型
|
||||
int Address;
|
||||
|
||||
//获取参数个数
|
||||
int ParameterNum = SQGetTop(v);
|
||||
//1个参数时
|
||||
if (ParameterNum == 2)
|
||||
{
|
||||
//获取值的类型
|
||||
int ParameterType = SQ_GetType(v, 2);
|
||||
|
||||
switch (ParameterType)
|
||||
{
|
||||
case OT_INTEGER://int类型
|
||||
{
|
||||
//获取地址
|
||||
SQGetInt(v, 2, &Address);
|
||||
int Value = *(int*)Address;
|
||||
SQPushInt(v, Value);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case OT_STRING://String类型
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
if (ParameterNum == 3)
|
||||
{
|
||||
//地址
|
||||
int Address;
|
||||
//偏移
|
||||
wchar_t* offset;
|
||||
|
||||
SQGetInt(v, 2, &Address);
|
||||
SQGetString(v,3,&offset);
|
||||
|
||||
int Value = DNFTOOL::GetHook(Address, DNFTOOL::wchar_tTochar(offset));
|
||||
SQPushInt(v, Value);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//写内存
|
||||
int squirrel::LWriteAddress(uint32_t v)
|
||||
{
|
||||
//内存地址 int型
|
||||
int Address;
|
||||
|
||||
//获取参数个数
|
||||
int ParameterNum = SQGetTop(v);
|
||||
//1个参数时
|
||||
if (ParameterNum == 3)
|
||||
{
|
||||
//获取值的类型
|
||||
int ParameterType = SQ_GetType(v, 2);
|
||||
|
||||
switch (ParameterType)
|
||||
{
|
||||
case OT_INTEGER://int类型
|
||||
{
|
||||
//获取地址
|
||||
SQGetInt(v, 2, &Address);
|
||||
//获取修改的值
|
||||
int WriteValue;
|
||||
SQGetInt(v, 3, &WriteValue);
|
||||
|
||||
*(int*)Address = WriteValue;
|
||||
SQPushBool(v, true);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case OT_STRING://String类型
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
if (ParameterNum == 4)
|
||||
{
|
||||
//地址
|
||||
int Address;
|
||||
//偏移
|
||||
wchar_t* offset;
|
||||
//修改值
|
||||
int WriteValue;
|
||||
|
||||
SQGetInt(v, 2, &Address);
|
||||
SQGetString(v, 3, &offset);
|
||||
SQGetInt(v, 4, &WriteValue);
|
||||
|
||||
int SelectAddress = DNFTOOL::GetHook(Address, DNFTOOL::wchar_tTochar(offset),1);
|
||||
*(int*)SelectAddress = WriteValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Lcout
|
||||
int squirrel::Lcout(uint32_t v)
|
||||
{
|
||||
@@ -556,9 +839,6 @@ int squirrel::NewWindows(uint32_t v)
|
||||
SQGetInt(v, 4, &color);
|
||||
break;
|
||||
}
|
||||
|
||||
SQPopTop(v);
|
||||
|
||||
|
||||
DNFTOOL::WindowsNotice(str, type, color);
|
||||
|
||||
@@ -679,6 +959,24 @@ int squirrel::SetSlot(uint32_t v)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//设置项目名称颜色
|
||||
#if defined ITEMRARITY
|
||||
std::map< int, int>ItemColorMap;
|
||||
int squirrel::RegisterItemColor_STL(uint32_t v)
|
||||
{
|
||||
int ItemID, Clolr;
|
||||
int ParameterNum = SQGetTop(v);
|
||||
if (ParameterNum == 3)
|
||||
{
|
||||
SQGetInt(v, 2, &ItemID);
|
||||
SQGetInt(v, 3, &Clolr);
|
||||
ItemColorMap[ItemID] = Clolr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//普通 STL
|
||||
#if defined NORMAL_STL
|
||||
//查询 类型容器
|
||||
@@ -869,27 +1167,6 @@ int squirrel::New_STL(uint32_t v)
|
||||
//时间 STL
|
||||
#if defined TIME_STL
|
||||
extern std::map<wchar_t*, TimeSTLStruct>Time_STL;
|
||||
//时间容器线程
|
||||
void TimeSTL(LPVOID lpParam)
|
||||
{
|
||||
TimeSTLStruct *pack = (TimeSTLStruct*)lpParam;//得到传递的包
|
||||
std::wcout << "线程启动:" << pack->Name << std::endl;
|
||||
Time_STL[pack->Name].Static_Time = (int)GetTickCount64();//设置时间容器的基准时间
|
||||
while (true)//线程循环
|
||||
{
|
||||
Sleep(10);
|
||||
int N_Time = (int)GetTickCount64() - Time_STL[pack->Name].Static_Time;//得到现在的时间
|
||||
if (N_Time < Time_STL[pack->Name].Max_Time)//如果还没到 设定新的now时间
|
||||
{
|
||||
Time_STL[pack->Name].Now_Time = N_Time;
|
||||
}
|
||||
else//如果到了 设定now同步最大时间
|
||||
{
|
||||
Time_STL[pack->Name].Now_Time = Time_STL[pack->Name].Max_Time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//时间容器
|
||||
int squirrel::Timer_STL(uint32_t v)
|
||||
{
|
||||
@@ -909,7 +1186,8 @@ int squirrel::Timer_STL(uint32_t v)
|
||||
switch (Type)
|
||||
{
|
||||
case 0: //设置时间容器
|
||||
if (Time_STL.count(Name) != 0)//如果这个标识容器存在 就返回 否则创建
|
||||
{
|
||||
if (Time_STL.count(Name) == 1)//如果这个标识容器存在 就返回 否则创建
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
@@ -919,44 +1197,53 @@ int squirrel::Timer_STL(uint32_t v)
|
||||
pack.Max_Time = MaxTime;//设置 标识时间容器最大时间
|
||||
pack.Now_Time = 0;//设置 标识时间容器当前时间
|
||||
pack.Static_Time = 0;//设置 基础时间(用于运算)
|
||||
pack.Thand = NULL;//设置句柄为空
|
||||
Time_STL[Name] = pack;//设置包给标识时间容器
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1: //启动时间容器
|
||||
if (Time_STL[Name].Thand == NULL)//只有句柄为空的时候new线程
|
||||
{
|
||||
DWORD threadID;//线程ID
|
||||
Time_STL[Name].Now_Time = 0;//设置当前容器时间
|
||||
Time_STL[Name].Thand = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TimeSTL, &Time_STL[Name], 0, &threadID);//创建一个新线程 开始计算时间 并把线程赋予给容器
|
||||
}
|
||||
break;
|
||||
{
|
||||
if (Time_STL[Name].Static_Time != 0)break;//只有基础时间为0的时候记录当前时间标准
|
||||
Time_STL[Name].Static_Time = clock();
|
||||
|
||||
}
|
||||
break;
|
||||
case 2://获取时间容器
|
||||
SQPushInt(v, Time_STL[Name].Now_Time);//返回当前容器时间
|
||||
{
|
||||
int Time = clock() - Time_STL[Name].Static_Time + Time_STL[Name].Now_Time;
|
||||
if(Time_STL[Name].Static_Time + Time_STL[Name].Now_Time == 0)SQPushInt(v, 0);//没启动返回0
|
||||
else if (Time <= Time_STL[Name].Max_Time)SQPushInt(v, Time);//返回当前容器时间
|
||||
else SQPushInt(v, (int)Time_STL[Name].Max_Time);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3://重置时间容器
|
||||
//SuspendThread(Time_STL[Name].Thand);//挂起线程
|
||||
CloseHandle(Time_STL[Name].Thand);//销毁线程
|
||||
Time_STL[Name].Static_Time = 0;//基准时间设置为0
|
||||
Time_STL[Name].Thand = NULL;
|
||||
//ResumeThread(Time_STL[Name].Thand);//启动线程
|
||||
break;
|
||||
{
|
||||
Time_STL[Name].Static_Time = 0;
|
||||
}
|
||||
break;
|
||||
case 4://暂停时间容器
|
||||
SuspendThread(Time_STL[Name].Thand);//挂起线程
|
||||
break;
|
||||
{
|
||||
Time_STL[Name].Now_Time += clock() - Time_STL[Name].Static_Time;
|
||||
Time_STL[Name].Static_Time = 0;
|
||||
}
|
||||
break;
|
||||
case 5://继续时间容器
|
||||
Time_STL[Name].Static_Time = (int)GetTickCount64() - Time_STL[Name].Now_Time;//当前时间 减去容器时间
|
||||
ResumeThread(Time_STL[Name].Thand);//启动线程
|
||||
break;
|
||||
{
|
||||
if (Time_STL[Name].Static_Time != 0)break;//只有基础时间为0的时候记录当前时间标准
|
||||
Time_STL[Name].Static_Time = clock();
|
||||
}
|
||||
break;
|
||||
case 6://销毁时间容器
|
||||
CloseHandle(Time_STL[Name].Thand);//销毁线程
|
||||
Time_STL[Name].Thand = NULL;
|
||||
{
|
||||
Time_STL.erase(Name);//销毁容器
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
@@ -1104,6 +1391,7 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
SQGetString(v, 2, &WName);
|
||||
char* CName = DNFTOOL::wchar_tTochar(WName);
|
||||
std::string Name = CName;
|
||||
delete []CName;
|
||||
//获取值的类型
|
||||
int ValueType = SQ_GetType(v, 3);
|
||||
|
||||
@@ -1135,6 +1423,7 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
{
|
||||
wchar_t* buffer = DNFTOOL::charTowchar_t((char*)Json_STL[Name].c_str());
|
||||
SQPushString(v, buffer, wcslen(buffer));//传给nut
|
||||
delete []buffer;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
@@ -1162,8 +1451,9 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
|
||||
std::vector<std::string> Data;
|
||||
DNFTOOL::Split(key, Data);
|
||||
delete []key;
|
||||
rapidjson::Value Vbuffer;
|
||||
for (int i = 0; i < Data.size(); i++)
|
||||
for (unsigned int i = 0; i < Data.size(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -1171,7 +1461,12 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
}
|
||||
else if (DNFTOOL::isNum(Data[i].c_str()) != 0)
|
||||
{
|
||||
if(Vbuffer.Empty() == 0)Vbuffer = Vbuffer[atoi(Data[i].c_str())];
|
||||
if(Vbuffer.Empty() == 0 && Vbuffer.Size() > atoi(Data[i].c_str()))Vbuffer = Vbuffer[atoi(Data[i].c_str())];
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1180,17 +1475,18 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
|
||||
}
|
||||
|
||||
if (Vbuffer.Empty() == false || (Vbuffer.IsInt() && Vbuffer.GetInt()==0))
|
||||
if (Vbuffer.IsBool())
|
||||
{
|
||||
SQPushBool(v, Vbuffer.GetBool());
|
||||
return 1;
|
||||
}
|
||||
else if (Vbuffer.Empty() == false || (Vbuffer.IsInt() && Vbuffer.GetInt()==0))
|
||||
{
|
||||
if (Vbuffer.IsString())
|
||||
{
|
||||
wchar_t* buffer = DNFTOOL::charTowchar_t((char*)Vbuffer.GetString());
|
||||
SQPushString(v, buffer, wcslen(buffer));
|
||||
return 1;
|
||||
}
|
||||
if (Vbuffer.IsBool())
|
||||
{
|
||||
SQPushBool(v, Vbuffer.GetBool());
|
||||
delete []buffer;
|
||||
return 1;
|
||||
}
|
||||
if (Vbuffer.IsInt())
|
||||
@@ -1212,8 +1508,6 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else if (ParameterNum == 4)
|
||||
@@ -1222,6 +1516,7 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
SQGetString(v, 2, &WName);
|
||||
char* CName = DNFTOOL::wchar_tTochar(WName);
|
||||
std::string Name = CName;
|
||||
delete []CName;
|
||||
//获取Key 的名字
|
||||
wchar_t* keybuffer;
|
||||
SQGetString(v, 3, &keybuffer);
|
||||
@@ -1267,6 +1562,7 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
SQGetString(v, 4, &Value);
|
||||
char* str = DNFTOOL::wchar_tTochar(Value);
|
||||
BB.SetString(rapidjson::StringRef(str));
|
||||
delete []str;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1287,6 +1583,8 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
Dom.Accept(writer);
|
||||
Json_STL[Name] = jsonBuffer.GetString();
|
||||
SQPushBool(v, true);
|
||||
|
||||
delete []key;
|
||||
}
|
||||
else if (ParameterNum == 5)
|
||||
{
|
||||
@@ -1315,6 +1613,8 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
delete []CName;
|
||||
delete []Jso;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1329,8 +1629,8 @@ int squirrel::Jsoner_STL(uint32_t v)
|
||||
|
||||
//字符 STL
|
||||
#if defined CODE_STL
|
||||
extern std::vector<DrawCodestruct>DrawCodeT1_STL;
|
||||
extern std::vector<DrawCodestruct>DrawCodeT2_STL;
|
||||
extern std::vector< DrawCodestruct>DrawCodeT1_STL;
|
||||
extern std::vector< DrawCodestruct>DrawCodeT2_STL;
|
||||
int squirrel::Coder_STL(uint32_t v)
|
||||
{
|
||||
wchar_t* Str;
|
||||
@@ -1352,15 +1652,20 @@ int squirrel::Coder_STL(uint32_t v)
|
||||
SQGetInt(v, 5, &Color);
|
||||
//获取类型
|
||||
SQGetInt(v, 6, &Type);
|
||||
|
||||
|
||||
//松鼠 Wchar_t 转换为 Unicode
|
||||
wchar_t* str = DNFTOOL::SquirrelW2W(Str);
|
||||
char* OutPutText = DNFTOOL::SquirrelU2W(Str);
|
||||
std::string str = OutPutText;
|
||||
//wchar_t * str = DNFTOOL::char2wchar(OutPutText);
|
||||
delete []OutPutText;
|
||||
//delete Str;
|
||||
|
||||
DrawCodestruct Buffer;
|
||||
Buffer.str = str;
|
||||
Buffer.Xpos = XPos;
|
||||
Buffer.Ypos = YPos;
|
||||
Buffer.Color = Color;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
@@ -1374,6 +1679,7 @@ int squirrel::Coder_STL(uint32_t v)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
@@ -1386,6 +1692,8 @@ int squirrel::Coder_STL(uint32_t v)
|
||||
#endif
|
||||
|
||||
|
||||
typedef int(_Sq_Err)(uint32_t v);
|
||||
static _Sq_Err* Sq_Err = (_Sq_Err*)0x13542F0;
|
||||
|
||||
//获取Squirrel v 基址
|
||||
inline uint32_t GetSqVm()
|
||||
@@ -1407,6 +1715,14 @@ void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t
|
||||
void squirrel::R_Register_Nut()
|
||||
{
|
||||
RegisterNutApi(L"L_sq_Test", squirrel::sq_Test);
|
||||
RegisterNutApi(L"L_Sq_Err", Sq_Err);
|
||||
|
||||
RegisterNutApi(L"L_Sq_GetImg", sq_GetImg);
|
||||
|
||||
RegisterNutApi(L"L_Sq_GetObjectAddress", GetObjectAddress);
|
||||
RegisterNutApi(L"L_Sq_GetObjectName", GetObjectName);
|
||||
RegisterNutApi(L"L_Sq_GetObjectLevel", GetObjectLevel);
|
||||
|
||||
|
||||
//人物或装备属性 查看 修改 开启
|
||||
#if defined CHRATRBT_SWITCH
|
||||
@@ -1434,8 +1750,6 @@ void squirrel::R_Register_Nut()
|
||||
RegisterNutApi(L"L_sq_SendPackWChar", squirrel::SendPackWChar);//包数据DWord
|
||||
RegisterNutApi(L"L_sq_SendPack", squirrel::SendPack);//发包
|
||||
#if defined SEND_API_SWITCH
|
||||
RegisterNutApi(L"L_sq_GivePlayerItem", squirrel::GivePlayerItem);//给用户物品
|
||||
RegisterNutApi(L"L_sq_GivePlayerEqu", squirrel::GivePlayerEqu);//给用户装备
|
||||
RegisterNutApi(L"L_sq_GoDungeon", squirrel::GoDungeon);//去副本
|
||||
RegisterNutApi(L"L_sq_GoTown", squirrel::GoTown);//去城镇
|
||||
RegisterNutApi(L"L_sq_MoveTown", squirrel::MoveTown);//去城镇
|
||||
@@ -1446,8 +1760,14 @@ void squirrel::R_Register_Nut()
|
||||
RegisterNutApi(L"L_sq_Dofile", squirrel::LDofile);//加密读取
|
||||
#endif
|
||||
|
||||
#if defined ADDRESS_API_SWITCH
|
||||
RegisterNutApi(L"L_sq_RA", squirrel::LReadAddress);//读内存
|
||||
RegisterNutApi(L"L_sq_WA", squirrel::LWriteAddress);//写内存
|
||||
#endif
|
||||
|
||||
#if defined LCOUT_API_SWITCH
|
||||
RegisterNutApi(L"L_cout", squirrel::Lcout);//输出公告
|
||||
RegisterNutApi(L"Sout", squirrel::Sout);//输出
|
||||
#endif
|
||||
|
||||
#if defined NEW_WINDOW_API_SWITCH
|
||||
@@ -1480,6 +1800,11 @@ void squirrel::R_Register_Nut()
|
||||
RegisterNutApi(L"L_Code_STL", squirrel::Coder_STL);//字符容器
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ITEMRARITY
|
||||
RegisterNutApi(L"L_RegisterItemColor_STL", squirrel::RegisterItemColor_STL);//注册Item颜色
|
||||
#endif
|
||||
|
||||
//龙盒
|
||||
#if defined DRAGONBOX_SWITCH
|
||||
//RegisterNutApi(L"L_Get_DragonModel", squirrel::Get_DragonModel);//获取龙盒模式
|
||||
@@ -1489,3 +1814,49 @@ void squirrel::R_Register_Nut()
|
||||
//RegisterNutApi(L"L_Sync_Dragon_Pack", squirrel::Sync_Dragon_Pack);//同步龙盒包
|
||||
#endif
|
||||
}
|
||||
|
||||
//线程循环调用Sqr回调函数
|
||||
void squirrel::SqrCallBackFunc()
|
||||
{
|
||||
static int SqrCallBackFuncTimer = clock();
|
||||
int NowTime = clock();
|
||||
if ((NowTime - SqrCallBackFuncTimer) >= 2000)
|
||||
{
|
||||
uint32_t v = GetSqVm();
|
||||
DWORD Time = clock();
|
||||
DWORD VmTop = SQGetTop(v);
|
||||
//std::cout << "stack: " << VmTop << std::endl;
|
||||
SQPushRootTable(v);
|
||||
SQPushString(v, L"Lenheart", -1);
|
||||
SQ_Get(v, -2);
|
||||
SQPushRootTable(v);
|
||||
SQPushInt(v, VmTop);
|
||||
SQ_Call(v, 2, 0, 0);
|
||||
SQPop(v, 2);
|
||||
|
||||
SqrCallBackFuncTimer = NowTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void squirrel::InitGameScript()
|
||||
{
|
||||
uint32_t v = GetSqVm();
|
||||
|
||||
SQPushRootTable(v);
|
||||
SQPushString(v, L"dofile", -1);
|
||||
SQ_Get(v, -2);
|
||||
SQPushRootTable(v);
|
||||
SQPushString(v, L"sqr/DofileList.nut", -1);
|
||||
SQ_Call(v, 2, 0, 0);
|
||||
SQPop(v, 2);
|
||||
|
||||
SQPushRootTable(v);
|
||||
SQPushString(v, L"L_sq_Dofile", -1);
|
||||
SQ_Get(v, -2);
|
||||
SQPushRootTable(v);
|
||||
SQPushString(v, L"licbylist.dll", -1);
|
||||
SQ_Call(v, 2, 0, 0);
|
||||
SQPop(v, 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user