#ifndef USER_CLASS_H
#define USER_CLASS_H
#include "base.h"
#include "enum.h"
#include "ida_sdk.h"
#include <string>
#include <vector>


template<typename R, typename A, typename ... ARG> R CallT(A call_addr, const ARG ... arguments)
{
	if (!call_addr)
	{
		return R();
	}
	const auto control = reinterpret_cast<R(*)(ARG...)>(call_addr);
	try
	{
		return control(arguments ...);
	}
	catch (...)
	{

	}
	return R();
}


class CAccountCargo;
class DB_UpdateAvatarJewelSlot;
class CInventory;
class CStackableItem;
class Inven_Item;
class CItem;
class CUserCharacInfo;
class CUser;
class PacketBuf;
class PacketGuard;
class InterfacePacketBuf;
class Dispatcher_ModItemAttr;
class stAvatarEmblemInfo_t;



#pragma pack(push, 0x01)

class DNFFLib
{
public:
	static int ConvertGBKtoUTF8(char* a2, char* a3)
	{
		return CallT<int>(base::DNFFLib::ConvertGBKtoUTF8, a2, a3);
	}

	static int ConvertUTF8toGBK(char* a2, char* a3)
	{
		return CallT<int>(base::DNFFLib::ConvertUTF8toGBK, a2, a3);
	}


};

namespace WongWork
{
	class CCeraShop
	{
	public:

		static CCeraShop* G_CCeraShop()
		{
			return *(CCeraShop**)base::GlobalData::s_pItemVendingMachine;
		}

		int _processCoin(CUser* a2, ushort a3, bool a4)
		{
			return CallT<int>(base::WongWork::CCeraShop::_processCoin, this, a2, a3, a4);
		}




	};

	class CMailBoxHelper
	{
	public:
		int ReqDBSendNewMailCashShop(Inven_Item * a2, uint a3, uint a4, bool a5, char const* a6, int a7)
		{
			return CallT<int>(base::WongWork::CMailBoxHelper::ReqDBSendNewMailCashShop, this, a2, a3, a4, a5, a6, a7);
		}


	};

	class CAvatarItemMgr
	{
	public:
		//获取时装插槽数据
		int getJewelSocketData(int a2)
		{
			return CallT<int>(base::WongWork::CAvatarItemMgr::getJewelSocketData, this, a2);
		}

		int setEmblemSocketData(int a2, stAvatarEmblemInfo_t * a3)
		{
			return CallT<int>(base::WongWork::CAvatarItemMgr::setEmblemSocketData, this, a2, a3);
		}


	};

	class CHackAnalyzer
	{
	public:
		int addServerHackCnt(CUserCharacInfo* a2, int a3, int a4, int a5, int a6)
		{
			typedef int (*__func)(WongWork::CHackAnalyzer* a1, CUserCharacInfo* a2, int a3, int a4, int a5, int a6);

			return CallT<int>(base::WongWork::CHackAnalyzer::addServerHackCnt, this, a2, a3, a4, a5, a6);
			return ((__func)base::WongWork::CHackAnalyzer::addServerHackCnt)(this, a2, a3, a4, a5, a6);
		}
	};
}

class CSecu_ProtectionField
{
public:

	static CSecu_ProtectionField* Get()
	{
		return (CSecu_ProtectionField*)(*(int*)base::GlobalData::s_pSecuProtectionField);
	}

	int Check(CUser* a2, int a3)
	{
		return CallT<int>(base::CSecu_ProtectionField::Check, this, a2, a3);
	}

};


struct EmblemInfo
{
	unsigned short												slot_type;
	unsigned int												slot_item_id;
};

struct stAvatarEmblemInfo_t
{
public:
	EmblemInfo													EmblemSocketData[0x05];

public:
	int init()
	{
		return CallT<int>(base::stAvatarEmblemInfo_t::init, this);
	}


};

class cUserHistoryLog
{
public:

};

class AvatarRechargeServer
{
public:

	static AvatarRechargeServer* Get()
	{
		return CallT<AvatarRechargeServer*>(base::AvatarRechargeServer::Get);
	}

	char SendDurability(CUser* a2, char a3, short a4, char a5, int a6)
	{
		return CallT<char>(base::AvatarRechargeServer::SendDurability, this, a2, a3, a4, a5, a6);
	}
};

#pragma pack(pop)


#include "User.h"
#include "AccountCargo.h"
#include "Item.h"
#include "DataManager.h"
#include "Inventory.h"
#include "PacketBuf.h"
#include "SystemTime.h"
#include "DBMgr.h"
#include "MySQL.h"
#include "ShutdowManager.h"

inline int ScanInt(bool* a2 = NULL)
{
	return CallT<int>(base::ScanInt, a2);
}

inline int ScanStr(std::string* a2)
{
	return CallT<int>(base::ScanStr, a2);
}


#endif // __DXFBASE_H__
