nut容器完成
This commit is contained in:
parent
5ffa76fdef
commit
0f02f0fb62
|
|
@ -0,0 +1,104 @@
|
|||
#include "pch.h"
|
||||
#include "STL.h"
|
||||
|
||||
|
||||
int STL::Check_STL(std::string name,int Type,int idx)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
return Int_STL.count(name);
|
||||
break;
|
||||
case 1:
|
||||
return Float_STL.count(name);
|
||||
case 2:
|
||||
return String_STL.count(name);
|
||||
break;
|
||||
case 3:
|
||||
return Bool_STL.count(name);
|
||||
break;
|
||||
case 4:
|
||||
return IntArr_STL[name].count(idx);
|
||||
break;
|
||||
case 5:
|
||||
return FloatArr_STL[name].count(idx);
|
||||
break;
|
||||
case 6:
|
||||
return StringArr_STL[name].count(idx);
|
||||
break;
|
||||
case 7:
|
||||
return BoolArr_STL[name].count(idx);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void STL::BuildIntArr_STL(std::string name)
|
||||
{
|
||||
//aod.emplace(0, 0);
|
||||
IntArr_STL.emplace(name, aod);
|
||||
//aod.clear();
|
||||
}
|
||||
|
||||
void STL::BuildFloatArr_STL(std::string name)
|
||||
{
|
||||
//bod.emplace(0, 0.0);
|
||||
FloatArr_STL.emplace(name, bod);
|
||||
//bod.clear();
|
||||
}
|
||||
|
||||
void STL::BuildStringArr_STL(std::string name)
|
||||
{
|
||||
//cod.emplace(0, "zero");
|
||||
StringArr_STL.emplace(name, cod);
|
||||
//cod.clear();
|
||||
}
|
||||
|
||||
void STL::BuildBoolArr_STL(std::string name)
|
||||
{
|
||||
//dod.emplace(0, false);
|
||||
BoolArr_STL.emplace(name, dod);
|
||||
//dod.clear();
|
||||
}
|
||||
|
||||
void STL::SetIntArr_STL(std::string name, int idx, int value)
|
||||
{
|
||||
IntArr_STL[name][idx] = value;
|
||||
}
|
||||
|
||||
void STL::SetFloatArr_STL(std::string name, int idx, float value)
|
||||
{
|
||||
FloatArr_STL[name][idx] = value;
|
||||
}
|
||||
|
||||
void STL::SetStringArr_STL(std::string name, int idx, std::string value)
|
||||
{
|
||||
StringArr_STL[name][idx] = value;
|
||||
}
|
||||
|
||||
void STL::SetBoolArr_STL(std::string name, int idx, bool value)
|
||||
{
|
||||
BoolArr_STL[name][idx] = value;
|
||||
}
|
||||
|
||||
int STL::GetIntArr_STL(std::string name, int idx)
|
||||
{
|
||||
return IntArr_STL[name][idx];
|
||||
}
|
||||
|
||||
float STL::GetFloatArr_STL(std::string name, int idx)
|
||||
{
|
||||
return FloatArr_STL[name][idx];
|
||||
}
|
||||
|
||||
std::string STL::GetStringArr_STL(std::string name, int idx)
|
||||
{
|
||||
return StringArr_STL[name][idx];
|
||||
}
|
||||
|
||||
bool STL::GetBoolArr_STL(std::string name, int idx)
|
||||
{
|
||||
return BoolArr_STL[name][idx];
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
|
||||
//构造int类型容器
|
||||
static std::map<std::string, int>Int_STL;
|
||||
//构造float类型容器
|
||||
static std::map<std::string, float>Float_STL;
|
||||
//构造string类型容器
|
||||
static std::map<std::string, std::string>String_STL;
|
||||
//构造bool类型容器
|
||||
static std::map<std::string, bool>Bool_STL;
|
||||
|
||||
//构造intarr类型容器
|
||||
static std::map<std::string, std::map<int, int>>IntArr_STL;
|
||||
//构造floatarr类型容器
|
||||
static std::map<std::string, std::map<int, float>>FloatArr_STL;
|
||||
//构造stringarr类型容器
|
||||
static std::map<std::string, std::map<int, std::string>>StringArr_STL;
|
||||
//构造boolarr类型容器
|
||||
static std::map<std::string, std::map<int, bool>>BoolArr_STL;
|
||||
|
||||
|
||||
static std::map<int, int>aod;
|
||||
static std::map<int, float>bod;
|
||||
static std::map<int, std::string>cod;
|
||||
static std::map<int, bool>dod;
|
||||
|
||||
class STL
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//查询指定容器是否存在
|
||||
static int Check_STL(std::string name,int Type,int idx = 0);
|
||||
//static int Check_STL_Idx(std::string name,int idx);
|
||||
|
||||
|
||||
//构造 Int数组容器
|
||||
static void BuildIntArr_STL(std::string name);
|
||||
static void BuildFloatArr_STL(std::string name);
|
||||
static void BuildStringArr_STL(std::string name);
|
||||
static void BuildBoolArr_STL(std::string name);
|
||||
|
||||
//设置 Int数组容器
|
||||
static void SetIntArr_STL(std::string name,int idx,int value);
|
||||
static void SetFloatArr_STL(std::string name,int idx,float value);
|
||||
static void SetStringArr_STL(std::string name,int idx,std::string value);
|
||||
static void SetBoolArr_STL(std::string name,int idx,bool value);
|
||||
|
||||
//获取 Int数组容器
|
||||
static int GetIntArr_STL(std::string name, int idx);
|
||||
static float GetFloatArr_STL(std::string name, int idx);
|
||||
static std::string GetStringArr_STL(std::string name, int idx);
|
||||
static bool GetBoolArr_STL(std::string name, int idx);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "pch.h"
|
||||
#include "sock.h"
|
||||
|
||||
void sock::Pack_130_³é½±(int idx, int code, void* p3, void* p4)
|
||||
void sock::Pack_³é½±(int idx, int code, void* p3, void* p4)
|
||||
{
|
||||
std::cout << 666 << std::endl;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ void sock::R_Register_Pack()
|
|||
{
|
||||
auto Registerfunc = reinterpret_cast<register_pack_handler_t>(0x7186D0);
|
||||
|
||||
Registerfunc(130, Pack_130_³é½±, 0);
|
||||
Registerfunc(130, Pack_³é½±, 0);
|
||||
}
|
||||
|
||||
bool sock::net_get8(std::int8_t& v)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ private:
|
|||
|
||||
|
||||
public:
|
||||
static void Pack_130_³é½±(int idx, int code, void* p3, void* p4);
|
||||
static void Pack_³é½±(int idx, int code, void* p3, void* p4);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,74 @@
|
|||
#include "squirrel.h"
|
||||
#include "DNFTOOL.h"
|
||||
#include "RSAC.h"
|
||||
#include "STL.h"
|
||||
|
||||
int squirrel::SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
|
||||
{
|
||||
//wchar_t* 转 char*
|
||||
int size = wcslen(filename);
|
||||
char* fname = (char*)new char[size];
|
||||
DNFTOOL::UnicodeToAnsi(filename, fname, size);
|
||||
|
||||
FILE* file;
|
||||
file = fopen(fname, "rb+");
|
||||
LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
|
||||
if (file)
|
||||
{
|
||||
//求得文件的大小
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
//申请一块能装下整个文件的空间
|
||||
char* ar = (char*)malloc(sizeof(char) * size);
|
||||
//读文件,每次读一个,共读size次
|
||||
fread(ar, 1, size, file);
|
||||
|
||||
int skey[] = { 5,2,3,5,0 };//定义解密数组
|
||||
|
||||
Cutecode(ar, skey);//解密
|
||||
|
||||
FILE* outfile;
|
||||
outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+");
|
||||
int da = strlen(ar);
|
||||
fwrite(ar, 1, da, outfile);
|
||||
|
||||
fclose(outfile);//关闭文件
|
||||
free(ar);//释放内存
|
||||
|
||||
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//定义新的文件流
|
||||
|
||||
SQfseek(newfile, 0, 2);//定位到头
|
||||
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
|
||||
{
|
||||
fclose(file);//关闭文件
|
||||
SQ__Fclose(newfile);//关闭文件
|
||||
remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(file);//关闭文件
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int squirrel::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;
|
||||
}
|
||||
|
||||
//Test
|
||||
static int sq_Test(uint32_t v)
|
||||
{
|
||||
|
|
@ -474,72 +542,195 @@ static int SetSlot(uint32_t v)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int squirrel::SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
|
||||
|
||||
//查询 类型容器
|
||||
static int Get_STL(uint32_t v)
|
||||
{
|
||||
//wchar_t* 转 char*
|
||||
int size = wcslen(filename);
|
||||
char* fname = (char*)new char[size];
|
||||
DNFTOOL::UnicodeToAnsi(filename, fname, size);
|
||||
char* Name;
|
||||
int Type;
|
||||
int Idx;
|
||||
int ParameterNum = SQGetTop(v);
|
||||
|
||||
FILE* file;
|
||||
file = fopen(fname, "rb+");
|
||||
LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
|
||||
if (file)
|
||||
if (ParameterNum == 4)
|
||||
{
|
||||
//求得文件的大小
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
//申请一块能装下整个文件的空间
|
||||
char* ar = (char*)malloc(sizeof(char) * size);
|
||||
//读文件,每次读一个,共读size次
|
||||
fread(ar, 1, size, file);
|
||||
|
||||
int skey[] = { 5,2,3,5,0 };//定义解密数组
|
||||
|
||||
Cutecode(ar, skey);//解密
|
||||
|
||||
FILE* outfile;
|
||||
outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+");
|
||||
int da = strlen(ar);
|
||||
fwrite(ar, 1, da, outfile);
|
||||
|
||||
fclose(outfile);//关闭文件
|
||||
free(ar);//释放内存
|
||||
|
||||
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//定义新的文件流
|
||||
|
||||
SQfseek(newfile, 0, 2);//定位到头
|
||||
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
|
||||
//获取容器名字
|
||||
SQGetStringc(v, 2, &Name);
|
||||
//获取容器类型
|
||||
SQGetInt(v, 3, &Type);
|
||||
//获取查询号位
|
||||
SQGetInt(v, 4, &Idx);
|
||||
if (STL::Check_STL(Name, Type) == 0)
|
||||
{
|
||||
fclose(file);//关闭文件
|
||||
SQ__Fclose(newfile);//关闭文件
|
||||
remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(file);//关闭文件
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int squirrel::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);
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
}
|
||||
SQPop(v, 1);
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
SQPushInt(v, Int_STL[Name]);
|
||||
break;
|
||||
case 1:
|
||||
SQPushFloat(v, Float_STL[Name]);
|
||||
break;
|
||||
case 2:
|
||||
SQPushStringc(v, String_STL[Name].c_str(), strlen(String_STL[Name].c_str()));
|
||||
break;
|
||||
case 3:
|
||||
SQPushBool(v, Bool_STL[Name]);
|
||||
break;
|
||||
case 4:
|
||||
SQPushInt(v, STL::GetIntArr_STL(Name, Idx));
|
||||
break;
|
||||
case 5:
|
||||
SQPushFloat(v, STL::GetFloatArr_STL(Name, Idx));
|
||||
break;
|
||||
case 6:
|
||||
SQPushStringc(v, STL::GetStringArr_STL(Name, Idx).c_str(), strlen(STL::GetStringArr_STL(Name, Idx).c_str()));
|
||||
break;
|
||||
case 7:
|
||||
SQPushBool(v, STL::GetBoolArr_STL(Name, Idx));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//设置 类型容器
|
||||
static int Set_STL(uint32_t v)
|
||||
{
|
||||
char* Name;
|
||||
int Type;
|
||||
int Idx;
|
||||
int ParameterNum = SQGetTop(v);
|
||||
|
||||
int IntValue;
|
||||
float FloatValue;
|
||||
char* StrValue;
|
||||
bool BoolValue;
|
||||
if (ParameterNum == 5)
|
||||
{
|
||||
//获取容器名字
|
||||
SQGetStringc(v, 2, &Name);
|
||||
//获取容器类型
|
||||
SQGetInt(v, 3, &Type);
|
||||
//获取修改号位
|
||||
SQGetInt(v, 4, &Idx);
|
||||
|
||||
//获取修改值
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
SQGetInt(v, 5, &IntValue);
|
||||
Int_STL[Name] = IntValue;
|
||||
break;
|
||||
case 1:
|
||||
SQGetFloat(v, 5, &FloatValue);
|
||||
Float_STL[Name] = FloatValue;
|
||||
break;
|
||||
case 2:
|
||||
SQGetStringc(v, 5, &StrValue);
|
||||
String_STL[Name] = StrValue;
|
||||
break;
|
||||
case 3:
|
||||
SQGetBool(v, 5, &BoolValue);
|
||||
Bool_STL[Name] = BoolValue;
|
||||
break;
|
||||
case 4:
|
||||
SQGetInt(v, 5, &IntValue);
|
||||
STL::SetIntArr_STL(Name,Idx, IntValue);
|
||||
break;
|
||||
case 5:
|
||||
SQGetFloat(v, 5, &FloatValue);
|
||||
STL::SetFloatArr_STL(Name, Idx, FloatValue);
|
||||
break;
|
||||
case 6:
|
||||
SQGetStringc(v, 5, &StrValue);
|
||||
STL::SetStringArr_STL(Name, Idx, StrValue);
|
||||
break;
|
||||
case 7:
|
||||
SQGetBool(v, 5, &BoolValue);
|
||||
STL::SetBoolArr_STL(Name, Idx, BoolValue);
|
||||
break;
|
||||
default:
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//new 类型容器
|
||||
static int New_STL(uint32_t v)
|
||||
{
|
||||
char* Name;
|
||||
int Type;
|
||||
int ParameterNum = SQGetTop(v);
|
||||
if (ParameterNum == 3)
|
||||
{
|
||||
//获取容器名字
|
||||
SQGetStringc(v, 2, &Name);
|
||||
//获取容器类型
|
||||
SQGetInt(v, 3, &Type);
|
||||
if (STL::Check_STL(Name, Type) != 0)
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
}
|
||||
switch (Type)
|
||||
{
|
||||
case 0:
|
||||
Int_STL[Name] = 0;//单Int容器
|
||||
break;
|
||||
case 1:
|
||||
Float_STL[Name] = 0.0;//单Float容器
|
||||
break;
|
||||
case 2:
|
||||
String_STL[Name] = "zero";//单String容器
|
||||
break;
|
||||
case 3:
|
||||
Bool_STL[Name] = false;//单Bool容器
|
||||
break;
|
||||
case 4:
|
||||
STL::BuildIntArr_STL(Name);//Int数组容器
|
||||
break;
|
||||
case 5:
|
||||
STL::BuildFloatArr_STL(Name);//Float数组容器
|
||||
break;
|
||||
case 6:
|
||||
STL::BuildStringArr_STL(Name);//String数组容器
|
||||
break;
|
||||
case 7:
|
||||
STL::BuildBoolArr_STL(Name);//Bool数组容器
|
||||
break;
|
||||
default:
|
||||
SQPushBool(v, false);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
SQPushBool(v, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQPushBool(v, false);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//»ñÈ¡Squirrel v »ùÖ·
|
||||
inline uint32_t GetSqVm()
|
||||
{
|
||||
|
|
@ -578,4 +769,9 @@ void squirrel::R_Register_Nut()
|
|||
RegisterNutApi(L"L_cout", Lcout);
|
||||
RegisterNutApi(L"L_NewWindows", NewWindows);
|
||||
RegisterNutApi(L"L_SetSlot", SetSlot);
|
||||
|
||||
|
||||
RegisterNutApi(L"L_New_STL", New_STL);
|
||||
RegisterNutApi(L"L_Set_STL", Set_STL);
|
||||
RegisterNutApi(L"L_Get_STL", Get_STL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ typedef int(SqPushFunc)(uint32_t v, int idx);
|
|||
static SqPushFunc* SQPush = (SqPushFunc*)0x1358C90;
|
||||
//PushString
|
||||
typedef int(SqPushStringFunc)(uint32_t v, const wchar_t* s, int len);
|
||||
typedef int(SqPushStringFuncs)(uint32_t v, const char* s, int len);
|
||||
static SqPushStringFunc* SQPushString = (SqPushStringFunc*)0x1358A60;
|
||||
static SqPushStringFuncs* SQPushStringc = (SqPushStringFuncs*)0x1358A60;
|
||||
//PushInt
|
||||
typedef int(SqPushIntFunc)(uint32_t v, int sint);
|
||||
static SqPushIntFunc* SQPushInt = (SqPushIntFunc*)0x1358AD0;
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@
|
|||
<ClInclude Include="RSAC.h" />
|
||||
<ClInclude Include="sock.h" />
|
||||
<ClInclude Include="squirrel.h" />
|
||||
<ClInclude Include="STL.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
|
|
@ -193,6 +194,7 @@
|
|||
<ClCompile Include="RSAC.cpp" />
|
||||
<ClCompile Include="sock.cpp" />
|
||||
<ClCompile Include="squirrel.cpp" />
|
||||
<ClCompile Include="STL.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@
|
|||
<ClInclude Include="DNFTOOL.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="STL.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
|
@ -65,5 +68,8 @@
|
|||
<ClCompile Include="DNFTOOL.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="STL.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Reference in New Issue