From 2e11642e498042d5a8bb92194d254535e9e3c572 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Tue, 15 Mar 2022 09:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BE=99=E7=9B=92=E5=AE=8C=E6=88=90=E5=88=9D?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/DNFTOOL.h | 3 ++ test/STL.cpp | 78 +++++++++++++++++++++++++++++++ test/STL.h | 9 ++++ test/framework.h | 10 +++- test/sock.cpp | 40 +++------------- test/squirrel.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++---- 6 files changed, 212 insertions(+), 43 deletions(-) diff --git a/test/DNFTOOL.h b/test/DNFTOOL.h index 31d8e3a..516e06a 100644 --- a/test/DNFTOOL.h +++ b/test/DNFTOOL.h @@ -27,6 +27,9 @@ static SendPacksWORD _SendPacksWord = (SendPacksWORD)0x1128580; typedef int(__fastcall* SendPacksDWORD)(DWORD thisc, int Seat, int Parm); static SendPacksDWORD _SendPacksDWord = (SendPacksDWORD)0x11285B0; +//发包参数 char +typedef int(__fastcall* SendPacksChar)(DWORD thisc, int Seat, char* Parm,int Size); +static SendPacksChar _SendPacksChar = (SendPacksChar)0x11285E0; //公告Class this地址 typedef DWORD NoticeClass; diff --git a/test/STL.cpp b/test/STL.cpp index 7f7cbf2..f12c7fe 100644 --- a/test/STL.cpp +++ b/test/STL.cpp @@ -1,6 +1,84 @@ #include "pch.h" #include "STL.h" +void STL::SyncDargonBox_STL() +{ + DargonState_STL["dargonmap"].sync = 0; +} + +void STL::DrawDargonBox_STL(char* Buffer) +{ + std::cout << u8"插件收到的字符串:" << Buffer << std::endl; + rapidjson::Document Dom; + Dom.Parse(Buffer); + + //构造龙盒 模式 + //DrawDargonModel_STL(Dom["op"].GetInt()); + DargonModel_STL["op"] = Dom["op"].GetInt(); + + //构造res包 结构体 + Dargonresult Res_Buffer[10]; + if (DargonModel_STL["op"] == 4) + { + Res_Buffer[0].ItemIndex = Dom["result"][0]["item"].GetInt(); + Res_Buffer[0].ItemNum = Dom["result"][0]["num"].GetInt(); + Res_Buffer[0].ItemGrade = Dom["result"][0]["grade"].GetInt(); + } + if (DargonModel_STL["op"] == 6) + { + 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["lucky_value"].GetInt(); + M_Buffer.sync = 1; + for (int b = 0; b < 10; ++b) + { + M_Buffer.Result[b] = Res_Buffer[b]; + } + //构造 龙盒 奖励数据 + DargonState_STL["dargonmap"] = M_Buffer; +} + +int STL::SelectDargonBox_STL(int Type , int Index) +{ + switch (Type) + { + case 0://物品ID + return DargonState_STL["dargonmap"].Result[Index].ItemIndex; + break; + case 1://物品数量 + return DargonState_STL["dargonmap"].Result[Index].ItemNum; + break; + case 2://物品品级 + return DargonState_STL["dargonmap"].Result[Index].ItemGrade; + break; + case 3://幸运值 + return DargonState_STL["dargonmap"].LuckyValue; + break; + case 4://Sync + return DargonState_STL["dargonmap"].sync; + break; + default: + break; + } + return 404404404; +} + +void STL::DrawDargonModel_STL(int Value) +{ + DargonModel_STL["op"] = Value; +} + +int STL::SelectDargonModel_STL() +{ + return DargonModel_STL["op"]; +} int STL::Check_STL(std::string name,int Type,int idx) { diff --git a/test/STL.h b/test/STL.h index 65ff3ff..b5b67b1 100644 --- a/test/STL.h +++ b/test/STL.h @@ -32,6 +32,7 @@ struct DargonMap { int LuckyValue; Dargonresult Result[10]; + int sync; }; static std::mapDargonState_STL; static std::mapDargonModel_STL; @@ -73,5 +74,13 @@ public: static std::string GetStringArr_STL(std::string name, int idx); static bool GetBoolArr_STL(std::string name, int idx); + static void SyncDargonBox_STL();//同调龙盒包 + static void DrawDargonBox_STL(char* Buffer);//设置龙盒包 + static int SelectDargonBox_STL(int Type,int Index = 0);//获取龙盒包 + + static void DrawDargonModel_STL(int Value);//设置龙盒模式 + static int SelectDargonModel_STL();//获取龙盒模式 + + }; diff --git a/test/framework.h b/test/framework.h index 99e5944..41be2e2 100644 --- a/test/framework.h +++ b/test/framework.h @@ -11,4 +11,12 @@ //#include "squirrel.h" #include "hook.h" -#include "DNFTOOL.h" \ No newline at end of file +#include "DNFTOOL.h" + + +#include "rapidjson/document.h" +#include "rapidjson/writer.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/filereadstream.h" +#include "rapidjson/filewritestream.h" +#include "rapidjson/istreamwrapper.h" \ No newline at end of file diff --git a/test/sock.cpp b/test/sock.cpp index 032841e..be0ce79 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -1,13 +1,8 @@ #include "pch.h" #include "sock.h" -#include "rapidjson/document.h" -#include "rapidjson/writer.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/filereadstream.h" -#include "rapidjson/filewritestream.h" -#include "rapidjson/istreamwrapper.h" #include "STL.h" +#include "DNFTOOL.h" @@ -20,35 +15,12 @@ void sock::Pack_ Net_Get_Buffer(Buffer, Size); Buffer[Size] = '\0'; - rapidjson::Document Dom; - Dom.Parse(Buffer); - - - //构造龙盒 模式 - //DargonModel_STL.emplace("op", Dom["op"].GetInt()); - DargonModel_STL["op"] = Dom["op"].GetInt(); - std::cout << DargonModel_STL["op"] << std::endl; + STL::DrawDargonBox_STL(Buffer); /* - 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; - } + char* a = (char*)"{\"uid\":2,\"cid\":36,\"op\":1}"; + _SendpacksType(*_SendClass, 0, 130); + _SendPacksChar(*_SendClass, 0, a,strlen(a)); + _SendPacks(); */ std::cout << u8"130号收包成功" << std::endl; diff --git a/test/squirrel.cpp b/test/squirrel.cpp index 59a2869..780ee76 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -730,17 +730,50 @@ static int New_STL(uint32_t v) return 1; } - -//new -static int Get_DragonModel(uint32_t v) +//同步 龙盒数据包 +static int Sync_Dragon_Pack(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); + STL::SyncDargonBox_STL(); + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + return 1; +} + + +//获取 龙盒数据包 +static int Get_Dragon_Pack(uint32_t v) +{ + int Type; + int ParameterNum = SQGetTop(v); + if (ParameterNum == 2) + { + SQGetInt(v, 2, &Type); + + int Pack_Value; + //单抽模式 + Pack_Value = STL::SelectDargonBox_STL(Type); + SQPushInt(v, Pack_Value); + + return 1; + } + if (ParameterNum == 3) + { + int Index; + SQGetInt(v, 2, &Type); + SQGetInt(v, 3, &Index); + + int Pack_Value; + Pack_Value = STL::SelectDargonBox_STL(Type, Index); + + SQPushInt(v, Pack_Value); + return 1; } else { @@ -751,6 +784,68 @@ static int Get_DragonModel(uint32_t v) } +//发送 开龙盒 +static int Redom_Dragon(uint32_t v) +{ + int Type; + int ParameterNum = SQGetTop(v); + if (ParameterNum == 2) + { + SQGetInt(v, 2, &Type); + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + + writer.StartObject(); + writer.Key("op"); + writer.Int(Type); + writer.EndObject(); + + char* str = (char*)buffer.GetString(); + + _SendpacksType(*_SendClass, 0, 130); + _SendPacksChar(*_SendClass, 0, str,strlen(str)); + _SendPacks(); + } + else + { + SQPushBool(v, false); + } + return 1; + +} +//获取 龙盒 模式 +static int Get_DragonModel(uint32_t v) +{ + int Model = STL::SelectDargonModel_STL();//龙盒模式 + int ParameterNum = SQGetTop(v); + if (ParameterNum == 1) + { + SQPushInt(v, Model); + } + else + { + SQPushBool(v, false); + } + return 1; +} +//设置 龙盒 模式 +static int Set_DragonModel(uint32_t v) +{ + int Model; + int ParameterNum = SQGetTop(v); + if (ParameterNum == 2) + { + SQGetInt(v, 2, &Model); + STL::DrawDargonModel_STL(Model);//龙盒模式 + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + return 1; +} + //获取Squirrel v 基址 inline uint32_t GetSqVm() @@ -798,5 +893,9 @@ void squirrel::R_Register_Nut() - RegisterNutApi(L"L_Get_DragonModel", Get_DragonModel); + RegisterNutApi(L"L_Get_DragonModel", Get_DragonModel);//获取龙盒模式 + RegisterNutApi(L"L_Set_DragonModel", Set_DragonModel);//设置龙盒模式 + RegisterNutApi(L"L_Redom_Dragon", Redom_Dragon);//抽奖 + RegisterNutApi(L"L_Get_Dragon_Pack", Get_Dragon_Pack);//查询龙盒包 + RegisterNutApi(L"L_Sync_Dragon_Pack", Sync_Dragon_Pack);//同步龙盒包 }