AVA2 cross-platform client parity baseline
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
#include "StdAfx.h"
|
||||
#include "PythonBattlePass.h"
|
||||
#include "PythonNetworkStream.h"
|
||||
#include "Packet.h"
|
||||
|
||||
|
||||
CPythonBattlePass::CPythonBattlePass()
|
||||
: m_BattlePassHandler(NULL)
|
||||
{
|
||||
ClearData(BATTLEPASS_SUB_HEADER_CLEAR);
|
||||
ClearData(BATTLEPASS_SUB_HEADER_UPDATE_CLEAR);
|
||||
}
|
||||
|
||||
CPythonBattlePass::~CPythonBattlePass()
|
||||
{
|
||||
ClearData(BATTLEPASS_SUB_HEADER_CLEAR);
|
||||
ClearData(BATTLEPASS_SUB_HEADER_UPDATE_CLEAR);
|
||||
}
|
||||
|
||||
|
||||
void CPythonBattlePass::LoadingData(DWORD subheader)
|
||||
{
|
||||
if (m_BattlePassHandler)
|
||||
PyCallClassMemberFunc(m_BattlePassHandler, "BINARY_BATTLEPASS_LOADING", Py_BuildValue("(i)",subheader));
|
||||
}
|
||||
|
||||
void CPythonBattlePass::ClearData(DWORD subheader)
|
||||
{
|
||||
if(subheader == BATTLEPASS_SUB_HEADER_CLEAR)
|
||||
{
|
||||
battlepass_list.clear();
|
||||
time = 0;
|
||||
}else{
|
||||
battlepass_list_count.clear();
|
||||
}
|
||||
|
||||
}
|
||||
void CPythonBattlePass::ReceiveDataExtra(int time_get)
|
||||
{
|
||||
time = time_get;
|
||||
}
|
||||
|
||||
void CPythonBattlePass::ReceiveData(DWORD subheader,const TInfoBattlePass & data)
|
||||
{
|
||||
if(subheader == BATTLEPASS_SUB_HEADER_INFO)
|
||||
{
|
||||
battlepass_list.push_back(data);
|
||||
}else{
|
||||
battlepass_list_count.push_back(data);
|
||||
}
|
||||
}
|
||||
|
||||
int CPythonBattlePass::GetCountList()
|
||||
{
|
||||
return battlepass_list.size();
|
||||
}
|
||||
|
||||
const CPythonBattlePass::TInfoStrucDataBattlePass & CPythonBattlePass::GetList(DWORD subheader)
|
||||
{
|
||||
if(subheader == BATTLEPASS_SUB_HEADER_INFO){
|
||||
return battlepass_list;
|
||||
}else{
|
||||
return battlepass_list_count;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject * GetCountBattlePassList(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
return Py_BuildValue("i", CPythonBattlePass::Instance().GetCountList());
|
||||
}
|
||||
|
||||
PyObject * GetTimeBattlePass(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
return Py_BuildValue("i", CPythonBattlePass::Instance().GetTime());
|
||||
}
|
||||
|
||||
PyObject * GetBattlePassDates(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int index;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &index))
|
||||
return Py_BuildException();
|
||||
|
||||
const CPythonBattlePass::TInfoStrucDataBattlePass & data = CPythonBattlePass::Instance().GetList(BATTLEPASS_SUB_HEADER_INFO);
|
||||
|
||||
if (DWORD(index) >= data.size())
|
||||
{
|
||||
return Py_BuildValue("ii",0,0);
|
||||
}
|
||||
|
||||
const TInfoBattlePass & get_data = data[index];
|
||||
|
||||
return Py_BuildValue("ii",get_data.type,get_data.vnum);
|
||||
}
|
||||
|
||||
|
||||
PyObject * GetBattlePassDatesCount(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int index;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &index))
|
||||
return Py_BuildException();
|
||||
|
||||
const CPythonBattlePass::TInfoStrucDataBattlePass & data = CPythonBattlePass::Instance().GetList(BATTLEPASS_SUB_HEADER_UPDATE);
|
||||
|
||||
if (DWORD(index) >= data.size())
|
||||
{
|
||||
return Py_BuildValue("iii",0,0,0);
|
||||
}
|
||||
|
||||
const TInfoBattlePass & get_data = data[index];
|
||||
|
||||
return Py_BuildValue("iii",get_data.count,get_data.count_actual,get_data.reward_status);
|
||||
}
|
||||
|
||||
PyObject * GetBattlePassDatesItems(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int index;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &index))
|
||||
return Py_BuildException();
|
||||
|
||||
int index_item;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &index_item))
|
||||
return Py_BuildException();
|
||||
|
||||
const CPythonBattlePass::TInfoStrucDataBattlePass& data = CPythonBattlePass::Instance().GetList(BATTLEPASS_SUB_HEADER_INFO);
|
||||
|
||||
if (DWORD(index) >= data.size())
|
||||
{
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
if (index_item >= 4) {
|
||||
return Py_BuildValue("ii", 0,0);
|
||||
}
|
||||
|
||||
return Py_BuildValue("ii",data[index].data_item[index_item].vnum,data[index].data_item[index_item].count);
|
||||
}
|
||||
|
||||
PyObject * SetBattlePassHandler(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
PyObject * poEventHandler;
|
||||
if (!PyTuple_GetObject(poArgs, 0, &poEventHandler))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonBattlePass::Instance().SetBattlePassHandler(poEventHandler);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * BattlePassOpen(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
|
||||
CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance();
|
||||
rkNetStream.BattlePassOpen();
|
||||
return Py_BuildNone();
|
||||
|
||||
}
|
||||
|
||||
PyObject * BattlePassReceiveReward(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
int index;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &index))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance();
|
||||
rkNetStream.BattlePassReceiveReward(index);
|
||||
return Py_BuildNone();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void intbattlepass()
|
||||
{
|
||||
static PyMethodDef s_methods[] =
|
||||
{
|
||||
{ "CountDates", GetCountBattlePassList, METH_VARARGS },
|
||||
{ "GetDates", GetBattlePassDates, METH_VARARGS },
|
||||
{ "GetDatesItems", GetBattlePassDatesItems, METH_VARARGS },
|
||||
{ "GetDatesCount", GetBattlePassDatesCount, METH_VARARGS },
|
||||
{ "SetBattlePassHandler", SetBattlePassHandler, METH_VARARGS },
|
||||
{ "GetTime", GetTimeBattlePass, METH_VARARGS },
|
||||
{ "Open", BattlePassOpen, METH_VARARGS },
|
||||
{ "Reward", BattlePassReceiveReward, METH_VARARGS },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
PyObject * poModule = Py_InitModule("battlepass", s_methods);
|
||||
}
|
||||
Reference in New Issue
Block a user