新增商城奖励系统

This commit is contained in:
小疯 2022-09-15 13:07:01 +08:00
parent eb080e87fb
commit aa7ab5ee96
8 changed files with 355 additions and 11 deletions

View File

@ -47,13 +47,47 @@ public:
return &cera_award_item;
}
void set_cera_award_package_begin_id(int id)
{
cera_award_package_begin_id = id;
}
void set_cera_award_package_end_id(int id)
{
cera_award_package_end_id = id;
}
int get_cera_award_package_begin_id()
{
return cera_award_package_begin_id;
}
int get_cera_award_package_end_id()
{
return cera_award_package_end_id;
}
bool add_cera_award_package_item(int count_, int item_id, int item_num)
{
cera_award_package_item.Push(count_, { item_id ,item_num });
}
Utils::TMap<int, AWARD_ITEM>* get_cera_award_package_item_map()
{
return &cera_award_package_item;
}
protected:
private:
int cera_award_begin_id; //É̳ǽ±Àø¿ªÊ¼id
int cera_award_end_id; //É̳ǽ±Àø½áÊøid
int cera_award_begin_id; //商城奖励开始id
int cera_award_end_id; //商城奖励结束id
int cera_award_package_begin_id; //商城礼包奖励开始id
int cera_award_package_end_id; //商城礼包奖励结束id
Utils::TMap<int, AWARD_ITEM> cera_award_item; // 次数 + 数据
Utils::TMap<int, AWARD_ITEM> cera_award_package_item; // 次数 + 数据
};

View File

@ -245,7 +245,6 @@ int Controller::hook_DisPatcher_ReturnToSelectCharacter_dispatch_sig(void* a1, C
void Controller::hook_importCashShopItemList(const std::string* str)
{
LOG("hook_importCashShopItemList :%s", str->c_str());
if (str == NULL) return;
if (*str == "[start end id]")
{
@ -254,23 +253,37 @@ void Controller::hook_importCashShopItemList(const std::string* str)
CGameDataManager::Get()->set_cera_award_begin_id(item_id_begin_);
CGameDataManager::Get()->set_cera_award_end_id(item_id_end_);
LOG("hook_importCashShopItemList item_id_begin_ :%d item_id_end_ :%d", item_id_begin_, item_id_end_);
}
else if (*str == "[reward item]")
{
int _total = ScanInt();
LOG("hook_importCashShopItemList _total :%d", _total);
for (int i = 0; i < _total; i++)
{
int count_ = ScanInt();
int item_id = ScanInt();
int item_num = ScanInt();
CGameDataManager::Get()->add_cera_awarw_item(count_, item_id, item_num);
LOG("hook_importCashShopItemList count_ :%d item_id :%d item_num :%d", count_, item_id, item_num);
}
}
else if (*str == "[start end package]")
{
int item_id_begin_ = ScanInt();
int item_id_end_ = ScanInt();
CGameDataManager::Get()->set_cera_award_package_begin_id(item_id_begin_);
CGameDataManager::Get()->set_cera_award_package_end_id(item_id_end_);
}
else if (*str == "[package item]")
{
int _total = ScanInt();
for (int i = 0; i < _total; i++)
{
int count_ = ScanInt();
int item_id = ScanInt();
int item_num = ScanInt();
CGameDataManager::Get()->add_cera_award_package_item(count_, item_id, item_num);
}
}
}
@ -334,6 +347,68 @@ void Controller::hook_ProcessIPG_ResultOutput(CUser* user, int Goods_No, int ite
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
}
//0817964F 0817967F
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return;
}
}
else if (Goods_No >= CGameDataManager::Get()->get_cera_award_package_begin_id() && Goods_No <= CGameDataManager::Get()->get_cera_award_package_end_id())
{
int cur_purchase_count = 1;
AWARD_ITEM BonusItem;
LOG("Size:%d", CGameDataManager::Get()->get_cera_award_package_item_map()->Size());
if (CGameDataManager::Get()->get_cera_award_package_item_map()->Find(cur_purchase_count, &BonusItem))
{
if (user->getCurCharacR())
{
if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
{
//if (item->is_stackable()
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
{
int inserted = -1;
Inven_Item v60 = {};
*(_DWORD*)((char*)&v60 + 2) = BonusItem.item_id;
*(_DWORD*)((char*)&v60 + 7) = BonusItem.item_num;
(*(void(**)(CItem*, Inven_Item*))(*(_DWORD*)item + 8))(item, &v60);
auto CurCharacInvenW = user->getCurCharacInvenW();
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
((WongWork::CMailBoxHelper*)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
}
else
{
user->SendUpdateItemList(1, 0, inserted);
}
}
}
}
}
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{

99
src/sdk/DBMgr.h Normal file
View File

@ -0,0 +1,99 @@
#pragma once
#ifndef __DBMGR_H__
#define __DBMGR_H__
class DBMgr
{
public:
unsigned char UnknownData_NULL[0x38];
public:
static DBMgr* G_CDBMgr()
{
return *(DBMgr**)base::GlobalData::s_db_mgr;
}
int setUserIdx(int a2)
{
return CallT<int>(base::DBMgr::setUserIdx, this, a2);
}
int activateGlobalDB()
{
return CallT<int>(base::DBMgr::activateGlobalDB, this);
}
DBMgr()
{
CallT<int>(base::DBMgr::DBMgr_make, this);
}
~DBMgr()
{
CallT<int>(base::DBMgr::DBMgr_destroy, this);
}
int Open(int a2, char* a3, char* a4, char* a5, char* a6, int a7)
{
return CallT<int>(base::DBMgr::Open, this, a2, a3, a4, a5, a6, a7);
}
int Open_2(int a2, char* a3, uint a4, char* a5, char* a6, char* a7, int a8)
{
return CallT<int>(base::DBMgr::Open_2, this, a2, a3, a4, a5, a6, a7, a8);
}
int Close()
{
return CallT<int>(base::DBMgr::Close, this);
}
int Close_2(int a2)
{
return CallT<int>(base::DBMgr::Close_2, this, a2);
}
int GetServerType(int a2)
{
return CallT<int>(base::DBMgr::GetServerType, this, a2);
}
int addUserDBInfo(int a2, int* a3)
{
return CallT<int>(base::DBMgr::addUserDBInfo, this, a2, a3);
}
int removeUserDBInfo(int a2)
{
return CallT<int>(base::DBMgr::removeUserDBInfo, this, a2);
}
int GetDBHandleServerGroup(int a2, int a3)
{
return CallT<int>(base::DBMgr::GetDBHandleServerGroup, this, a2, a3);
}
int SetQueryCounterPointer(int* a2) //CQueryCounter*
{
return CallT<int>(base::DBMgr::SetQueryCounterPointer, this, a2);
}
int GetDBHandle(int a2, int a3)
{
return CallT<int>(base::DBMgr::GetDBHandle, this, a2, a3);
}
int isActiveGlobalDB()
{
return CallT<int>(base::DBMgr::isActiveGlobalDB, this);
}
};
#endif // __DBMGR_H__

17
src/sdk/MySQL.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include "stdarg.h"
#ifndef __MYSQL_H__
#define __MYSQL_H__
class MySQL
{
public:
};
#endif // __MYSQL_H__

71
src/sdk/ShutdowManager.h Normal file
View File

@ -0,0 +1,71 @@
#pragma once
#ifndef __SHUTDOWMANAGER_H__
#define __SHUTDOWMANAGER_H__
class CShutdowManager
{
public:
static CShutdowManager* G_CShutdowManager()
{
return CallT<CShutdowManager*>(base::CShutdowManager::GetInstanceShutdowManager);
}
CShutdowManager()
{
CallT<int>(base::CShutdowManager::CShutdowManager_make, this);
}
int EnableShutdown(bool a2)
{
return CallT<int>(base::CShutdowManager::EnableShutdown, this, a2);
}
int GetLastMsgCount()
{
return CallT<int>(base::CShutdowManager::GetLastMsgCount, this);
}
int GetLastMsgResponseCount()
{
return CallT<int>(base::CShutdowManager::GetLastMsgResponseCount, this);
}
int IncrementLastMsgResponseCount()
{
return CallT<int>(base::CShutdowManager::IncrementLastMsgResponseCount, this);
}
int OnAllUserLogout()
{
return CallT<int>(base::CShutdowManager::OnAllUserLogout, this);
}
int Reset()
{
return CallT<int>(base::CShutdowManager::Reset, this);
}
int SendLastMsgDBQueue(CUser* a2)
{
return CallT<int>(base::CShutdowManager::SendLastMsgDBQueue, this, a2);
}
int SendShutdownSignal()
{
return CallT<int>(base::CShutdowManager::SendShutdownSignal, this);
}
int WaitUntilExitThread()
{
return CallT<int>(base::CShutdowManager::WaitUntilExitThread, this);
}
};
#endif // __SHUTDOWMANAGER_H__

View File

@ -9,7 +9,7 @@ class CSystemTime
public:
static CSystemTime* G_CSystemTime(void)
{
return *(CSystemTime**)base::CSystemTime::s_systemTime_;
return *(CSystemTime**)base::GlobalData::s_systemTime_;
}
CSystemTime()

View File

@ -32,7 +32,6 @@ namespace base
namespace CSystemTime
{
const int s_systemTime_ = 0x0941F714;
const int getCurSec = 0x080CBC9E;
const int getCurTickCount = 0x081458AC;
const int getCurDate = 0x0823445E;
@ -77,9 +76,27 @@ namespace base
//base
const int s_pSecuProtectionField = 0x0941F7CC;
const int s_pItemVendingMachine = 0x0941F760;
const int s_pSecuProtectionField = 0x0941F7CC; //0x18
const int s_pItemVendingMachine = 0x0941F760; //0x20
const int s_db_mgr = 0x0940BDAC; //0x38
const int s_pCeraShop = 0x0941F744; //0x8
const int s_pLogGameChannel = 0x0941F740; //0x10
const int s_systemTime_ = 0x0941F714;
}
namespace CShutdowManager
{
const int CShutdowManager_make = 0x082A6FA8;
const int EnableShutdown = 0x082A6F70;
const int GetLastMsgCount = 0x084ED1FE;
const int GetLastMsgResponseCount = 0x084ED20A;
const int IncrementLastMsgResponseCount = 0x084ED1EA;
const int OnAllUserLogout = 0x082A36BC;
const int Reset = 0x082A6F88;
const int SendLastMsgDBQueue = 0x082A37C8;
const int SendShutdownSignal = 0x082A35A6;
const int WaitUntilExitThread = 0x082A396E;
const int GetInstanceShutdowManager = 0x082A6FBB;
}
namespace CParty
@ -346,6 +363,33 @@ namespace base
}
}
namespace DBMgr
{
const int setUserIdx = 0x0818FB1A;
const int activateGlobalDB = 0x082A420C;
const int DBMgr_make = 0x083F48DE;
const int DBMgr_destroy = 0x083F4A1C;
const int Open = 0x083F4BC4;
const int Open_2 = 0x083F4D2E;
const int Close = 0x083F4EA6;
const int Close_2 = 0x083F4EE0;
const int GetServerType = 0x083F4F10;
const int addUserDBInfo = 0x083F4F9E;
const int removeUserDBInfo = 0x083F5038;
const int GetDBHandleServerGroup = 0x083F506C;
const int SetQueryCounterPointer = 0x083F5150;
const int GetDBHandle = 0x083F523E;
const int isActiveGlobalDB = 0x083F533C;
}
namespace MySQL
{
}
namespace CGM_Manager
{
const int isGM = 0x0829948C;

View File

@ -5,6 +5,7 @@
#include "ida_sdk.h"
#include <string>
template<typename R, typename A, typename ... ARG> R CallT(A call_addr, const ARG ... arguments)
{
if (!call_addr)
@ -161,6 +162,9 @@ public:
#include "Inventory.h"
#include "PacketBuf.h"
#include "SystemTime.h"
#include "DBMgr.h"
#include "MySQL.h"
#include "ShutdowManager.h"
inline int ScanInt(bool* a2 = NULL)
{