From ce6413df51c324ebc9e5af637474d651f300628d Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Fri, 11 Mar 2022 21:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=8C=96=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Dargon.h | 2 ++ test/STL.h | 17 +++++++++++ test/sock.cpp | 63 ++++++++++++++++++--------------------- test/sock.h | 2 ++ test/squirrel.cpp | 25 ++++++++++++++++ test/test.vcxproj | 7 +++-- test/test.vcxproj.filters | 3 ++ 7 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 test/Dargon.h diff --git a/test/Dargon.h b/test/Dargon.h new file mode 100644 index 0000000..c9c7883 --- /dev/null +++ b/test/Dargon.h @@ -0,0 +1,2 @@ +#pragma once +#include "framework.h" diff --git a/test/STL.h b/test/STL.h index 86fd449..65ff3ff 100644 --- a/test/STL.h +++ b/test/STL.h @@ -21,11 +21,27 @@ static std::map>StringArr_STL; static std::map>BoolArr_STL; +//¹¹Ôì ³é½± ÀàÐÍÈÝÆ÷ +struct Dargonresult +{ + int ItemIndex; + int ItemNum; + int ItemGrade; +}; +struct DargonMap +{ + int LuckyValue; + Dargonresult Result[10]; +}; +static std::mapDargonState_STL; +static std::mapDargonModel_STL; + static std::mapaod; static std::mapbod; static std::mapcod; static std::mapdod; + class STL { private: @@ -33,6 +49,7 @@ private: public: + //²éѯָ¶¨ÈÝÆ÷ÊÇ·ñ´æÔÚ static int Check_STL(std::string name,int Type,int idx = 0); //static int Check_STL_Idx(std::string name,int idx); diff --git a/test/sock.cpp b/test/sock.cpp index fa508dd..032841e 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -11,52 +11,47 @@ -//¹¹Ôì ³é½± ÀàÐÍÈÝÆ÷ -struct Dargonresult -{ - int ItemIndex; - int ItemNum; - int ItemGrade; -}; -struct DargonMap -{ - int Op; - int LuckyValue; - Dargonresult Result[10]; -}; -static std::mapDargon_STL; void sock::Pack_³é½±(int idx, int code, void* p3, void* p4) { DWORD Size; Net_Get_Dword(Size); - char* Buffer = new char[Size+1]; + char* Buffer = new char[Size + 1]; Net_Get_Buffer(Buffer, Size); Buffer[Size] = '\0'; rapidjson::Document Dom; Dom.Parse(Buffer); - //¹¹Ôìres°ü ½á¹¹Ìå - Dargonresult Res_Buffer[10]; - for (int i = 0; i < 10; ++i) - { - Res_Buffer[i].ItemIndex = Dom["result"][i]["item"].GetInt(); - Res_Buffer[i].ItemNum = Dom["result"][i]["num"].GetInt(); - Res_Buffer[i].ItemGrade = Dom["result"][i]["grade"].GetInt(); - } - //¹¹ÔìÁúºÐ×Ü ½á¹¹Ìå - DargonMap M_Buffer; - M_Buffer.Op = Dom["op"].GetInt(); - M_Buffer.LuckyValue = Dom["luckyvalue"].GetInt(); - for (int b = 0; b < 10; ++b) - { - M_Buffer.Result[b] = Res_Buffer[b]; - } - //¹¹Ôì ÁúºÐ map - Dargon_STL["dargonmap"] = M_Buffer; - + //¹¹ÔìÁúºÐ ģʽ + //DargonModel_STL.emplace("op", Dom["op"].GetInt()); + DargonModel_STL["op"] = Dom["op"].GetInt(); + std::cout << DargonModel_STL["op"] << std::endl; + /* + if (DargonModel_STL["op"] == 4 || DargonModel_STL["op"] == 6) + { + //¹¹Ôìres°ü ½á¹¹Ìå + Dargonresult Res_Buffer[10]; + for (int i = 0; i < 10; ++i) + { + Res_Buffer[i].ItemIndex = Dom["result"][i]["item"].GetInt(); + Res_Buffer[i].ItemNum = Dom["result"][i]["num"].GetInt(); + Res_Buffer[i].ItemGrade = Dom["result"][i]["grade"].GetInt(); + } + //¹¹ÔìÁúºÐ×Ü ½á¹¹Ìå + DargonMap M_Buffer; + M_Buffer.LuckyValue = Dom["luckyvalue"].GetInt(); + for (int b = 0; b < 10; ++b) + { + M_Buffer.Result[b] = Res_Buffer[b]; + } + //¹¹Ôì ÁúºÐ ½±ÀøÊý¾Ý + DargonState_STL["dargonmap"] = M_Buffer; + } + */ + std::cout << u8"130ºÅÊÕ°ü³É¹¦" << std::endl; + } void sock::R_Register_Pack() diff --git a/test/sock.h b/test/sock.h index af53869..ecab444 100644 --- a/test/sock.h +++ b/test/sock.h @@ -9,6 +9,8 @@ typedef void(__cdecl* pack_handler_t)(int idx, int err, void*, void*); typedef void(__cdecl* register_pack_handler_t)(int idx, pack_handler_t handler, int zero); + + class sock { private: diff --git a/test/squirrel.cpp b/test/squirrel.cpp index eddf596..59a2869 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -731,6 +731,27 @@ static int New_STL(uint32_t v) } +//new +static int Get_DragonModel(uint32_t v) +{ + int Model = DargonModel_STL["op"];//ÁúºÐģʽ + std::cout << DargonModel_STL["op"] << std::endl; + int ParameterNum = SQGetTop(v); + std::cout << ParameterNum << std::endl; + if (ParameterNum == 1) + { + SQPushInt(v, Model); + } + else + { + SQPushBool(v, false); + } + + return 1; +} + + + //»ñÈ¡Squirrel v »ùÖ· inline uint32_t GetSqVm() { @@ -774,4 +795,8 @@ void squirrel::R_Register_Nut() RegisterNutApi(L"L_New_STL", New_STL); RegisterNutApi(L"L_Set_STL", Set_STL); RegisterNutApi(L"L_Get_STL", Get_STL); + + + + RegisterNutApi(L"L_Get_DragonModel", Get_DragonModel); } diff --git a/test/test.vcxproj b/test/test.vcxproj index 4a3d644..b149029 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -115,11 +115,11 @@ true true true - WIN32;NDEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;%(PreprocessorDefinitions) true Use pch.h - MultiThreadedDebug + MultiThreaded ProgramDatabase Full @@ -131,6 +131,8 @@ false libMinHook.x86.lib;%(AdditionalDependencies) D:\hookDNF\DOF_DllHook\test;%(AdditionalLibraryDirectories) + + @@ -170,6 +172,7 @@ + diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters index b4f9b62..b260c0b 100644 --- a/test/test.vcxproj.filters +++ b/test/test.vcxproj.filters @@ -42,6 +42,9 @@ 头文件 + + 头文件 +