- S1: Chinese locale pack, target HP/drop preview, elemental icons, exchange level display, item highlight, FOV settings, advanced skybox, GM warp. - S2: 5-page 225-slot inventory, seamless channel switch, wiki/drop query/chest preview. - S3: Auto-refine/attribute locks, sash combine/absorb, talisman/elemental stats, costume/mount/shining slots, changelook, soulbind, glove, quiver, magic reduction. - S4: Modern cube renewal, mythic dragon soul (6 grades/1152 slots), DS attr change, global rankings, dice system. - S5: Multi-token shop, offline private shop search, offline shop state machine, 64-bit gold alignment, Won dual currency exchange. - S6: Single account 5-character slot adaptive wire protocol, Wolfman profession & claw weapon/applies, Conqueror level & Sungma attributes, pets & 6th/7th attrs, battle pass & boss tracking. - Pass 42/42 platform gate test suites in scripts/port_gate.sh macos.
353 lines
9.8 KiB
C++
353 lines
9.8 KiB
C++
#include "StdAfx.h"
|
|
#include "PythonSafeBox.h"
|
|
|
|
void CPythonSafeBox::OpenSafeBox(int iSize)
|
|
{
|
|
m_dwMoney = 0;
|
|
m_ItemInstanceVector.clear();
|
|
m_ItemInstanceVector.resize(SAFEBOX_SLOT_X_COUNT * iSize);
|
|
|
|
for (DWORD i = 0; i < m_ItemInstanceVector.size(); ++i)
|
|
{
|
|
TItemData & rInstance = m_ItemInstanceVector[i];
|
|
ZeroMemory(&rInstance, sizeof(rInstance));
|
|
}
|
|
}
|
|
|
|
void CPythonSafeBox::SetItemData(DWORD dwSlotIndex, const TItemData & rItemInstance)
|
|
{
|
|
if (dwSlotIndex >= m_ItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::SetItemData(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return;
|
|
}
|
|
|
|
m_ItemInstanceVector[dwSlotIndex] = rItemInstance;
|
|
}
|
|
|
|
void CPythonSafeBox::DelItemData(DWORD dwSlotIndex)
|
|
{
|
|
if (dwSlotIndex >= m_ItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::DelItemData(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return;
|
|
}
|
|
|
|
TItemData & rInstance = m_ItemInstanceVector[dwSlotIndex];
|
|
ZeroMemory(&rInstance, sizeof(rInstance));
|
|
}
|
|
|
|
void CPythonSafeBox::SetMoney(int64_t dwMoney)
|
|
{
|
|
m_dwMoney = dwMoney;
|
|
}
|
|
|
|
int64_t CPythonSafeBox::GetMoney()
|
|
{
|
|
return m_dwMoney;
|
|
}
|
|
|
|
int CPythonSafeBox::GetCurrentSafeBoxSize()
|
|
{
|
|
return m_ItemInstanceVector.size();
|
|
}
|
|
|
|
BOOL CPythonSafeBox::GetSlotItemID(DWORD dwSlotIndex, DWORD* pdwItemID)
|
|
{
|
|
if (dwSlotIndex >= m_ItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::GetSlotItemID(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return FALSE;
|
|
}
|
|
|
|
*pdwItemID=m_ItemInstanceVector[dwSlotIndex].vnum;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CPythonSafeBox::GetItemDataPtr(DWORD dwSlotIndex, TItemData ** ppInstance)
|
|
{
|
|
if (dwSlotIndex >= m_ItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::GetItemData(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return FALSE;
|
|
}
|
|
|
|
*ppInstance = &m_ItemInstanceVector[dwSlotIndex];
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CPythonSafeBox::OpenMall(int iSize)
|
|
{
|
|
m_MallItemInstanceVector.clear();
|
|
m_MallItemInstanceVector.resize(SAFEBOX_SLOT_X_COUNT * iSize);
|
|
|
|
for (DWORD i = 0; i < m_MallItemInstanceVector.size(); ++i)
|
|
{
|
|
TItemData & rInstance = m_MallItemInstanceVector[i];
|
|
ZeroMemory(&rInstance, sizeof(rInstance));
|
|
}
|
|
}
|
|
|
|
void CPythonSafeBox::SetMallItemData(DWORD dwSlotIndex, const TItemData & rItemData)
|
|
{
|
|
if (dwSlotIndex >= m_MallItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::SetMallItemData(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return;
|
|
}
|
|
|
|
m_MallItemInstanceVector[dwSlotIndex] = rItemData;
|
|
}
|
|
|
|
void CPythonSafeBox::DelMallItemData(DWORD dwSlotIndex)
|
|
{
|
|
if (dwSlotIndex >= m_MallItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::DelMallItemData(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return;
|
|
}
|
|
|
|
TItemData & rInstance = m_MallItemInstanceVector[dwSlotIndex];
|
|
ZeroMemory(&rInstance, sizeof(rInstance));
|
|
}
|
|
|
|
BOOL CPythonSafeBox::GetMallItemDataPtr(DWORD dwSlotIndex, TItemData ** ppInstance)
|
|
{
|
|
if (dwSlotIndex >= m_MallItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::GetMallSlotItemID(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return FALSE;
|
|
}
|
|
|
|
*ppInstance = &m_MallItemInstanceVector[dwSlotIndex];
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CPythonSafeBox::GetSlotMallItemID(DWORD dwSlotIndex, DWORD * pdwItemID)
|
|
{
|
|
if (dwSlotIndex >= m_MallItemInstanceVector.size())
|
|
{
|
|
TraceError("CPythonSafeBox::GetMallSlotItemID(dwSlotIndex=%d) - Strange slot index", dwSlotIndex);
|
|
return FALSE;
|
|
}
|
|
|
|
*pdwItemID = m_MallItemInstanceVector[dwSlotIndex].vnum;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
DWORD CPythonSafeBox::GetMallSize()
|
|
{
|
|
return m_MallItemInstanceVector.size();
|
|
}
|
|
|
|
CPythonSafeBox::CPythonSafeBox()
|
|
{
|
|
m_dwMoney = 0;
|
|
}
|
|
|
|
CPythonSafeBox::~CPythonSafeBox()
|
|
{
|
|
}
|
|
|
|
PyObject * safeboxGetCurrentSafeboxSize(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
return Py_BuildValue("i", CPythonSafeBox::Instance().GetCurrentSafeBoxSize());
|
|
}
|
|
|
|
PyObject * safeboxGetItemID(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", pInstance->vnum);
|
|
}
|
|
|
|
PyObject * safeboxGetItemNewName(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildValue("s", "");
|
|
|
|
return Py_BuildValue("s", pInstance->extra.name);
|
|
}
|
|
|
|
PyObject * safeboxGetItemCount(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", pInstance->count);
|
|
}
|
|
|
|
PyObject * safeboxGetItemFlags(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", pInstance->flags);
|
|
}
|
|
|
|
PyObject * safeboxGetItemMetinSocket(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int iSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
|
|
return Py_BadArgument();
|
|
int iSocketIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iSocketIndex))
|
|
return Py_BadArgument();
|
|
|
|
if (iSocketIndex < 0 || iSocketIndex >= 8)
|
|
return Py_BuildException();
|
|
|
|
TItemData * pItemData;
|
|
if (!CPythonSafeBox::Instance().GetItemDataPtr(iSlotIndex, &pItemData))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", iSocketIndex<3?pItemData->alSockets[iSocketIndex]:pItemData->extra.sockets[iSocketIndex-3]);
|
|
}
|
|
|
|
PyObject * safeboxGetItemAttribute(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int iSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
|
|
return Py_BuildException();
|
|
int iAttrSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iAttrSlotIndex))
|
|
return Py_BuildException();
|
|
|
|
if (iAttrSlotIndex >= 0 && iAttrSlotIndex < 15)
|
|
{
|
|
TItemData * pItemData;
|
|
if (CPythonSafeBox::Instance().GetItemDataPtr(iSlotIndex, &pItemData))
|
|
return Py_BuildValue("ii", iAttrSlotIndex<7?pItemData->aAttr[iAttrSlotIndex].bType:pItemData->extra.types[iAttrSlotIndex-7], iAttrSlotIndex<7?pItemData->aAttr[iAttrSlotIndex].sValue:pItemData->extra.values[iAttrSlotIndex-7]);
|
|
}
|
|
|
|
return Py_BuildValue("ii", 0, 0);
|
|
}
|
|
|
|
PyObject * safeboxGetMoney(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
return PyLong_FromLongLong(CPythonSafeBox::Instance().GetMoney());
|
|
}
|
|
|
|
PyObject * safeboxGetMallItemID(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetMallItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", pInstance->vnum);
|
|
}
|
|
|
|
PyObject * safeboxGetMallItemCount(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int ipos;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
|
|
return Py_BadArgument();
|
|
|
|
TItemData * pInstance;
|
|
if (!CPythonSafeBox::Instance().GetMallItemDataPtr(ipos, &pInstance))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", pInstance->count);
|
|
}
|
|
|
|
PyObject * safeboxGetMallItemMetinSocket(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int iSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
|
|
return Py_BadArgument();
|
|
int iSocketIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iSocketIndex))
|
|
return Py_BadArgument();
|
|
|
|
if (iSocketIndex < 0 || iSocketIndex >= 8)
|
|
return Py_BuildException();
|
|
|
|
TItemData * pItemData;
|
|
if (!CPythonSafeBox::Instance().GetMallItemDataPtr(iSlotIndex, &pItemData))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", iSocketIndex<3?pItemData->alSockets[iSocketIndex]:pItemData->extra.sockets[iSocketIndex-3]);
|
|
}
|
|
|
|
PyObject * safeboxGetMallItemAttribute(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
int iSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
|
|
return Py_BuildException();
|
|
int iAttrSlotIndex;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iAttrSlotIndex))
|
|
return Py_BuildException();
|
|
|
|
if (iAttrSlotIndex >= 0 && iAttrSlotIndex < 15)
|
|
{
|
|
TItemData * pItemData;
|
|
if (CPythonSafeBox::Instance().GetMallItemDataPtr(iSlotIndex, &pItemData))
|
|
return Py_BuildValue("ii", iAttrSlotIndex<7?pItemData->aAttr[iAttrSlotIndex].bType:pItemData->extra.types[iAttrSlotIndex-7], iAttrSlotIndex<7?pItemData->aAttr[iAttrSlotIndex].sValue:pItemData->extra.values[iAttrSlotIndex-7]);
|
|
}
|
|
|
|
return Py_BuildValue("ii", 0, 0);
|
|
}
|
|
|
|
PyObject * safeboxGetMallSize(PyObject * poSelf, PyObject * poArgs)
|
|
{
|
|
return Py_BuildValue("i", CPythonSafeBox::Instance().GetMallSize());
|
|
}
|
|
|
|
void initsafebox()
|
|
{
|
|
static PyMethodDef s_methods[] =
|
|
{
|
|
// SafeBox
|
|
{ "GetCurrentSafeboxSize", safeboxGetCurrentSafeboxSize, METH_VARARGS },
|
|
{ "GetItemID", safeboxGetItemID, METH_VARARGS },
|
|
{ "GetItemNewName", safeboxGetItemNewName, METH_VARARGS },
|
|
{ "GetItemCount", safeboxGetItemCount, METH_VARARGS },
|
|
{ "GetItemFlags", safeboxGetItemFlags, METH_VARARGS },
|
|
{ "GetItemMetinSocket", safeboxGetItemMetinSocket, METH_VARARGS },
|
|
{ "GetItemAttribute", safeboxGetItemAttribute, METH_VARARGS },
|
|
{ "GetMoney", safeboxGetMoney, METH_VARARGS },
|
|
|
|
// Mall
|
|
{ "GetMallItemID", safeboxGetMallItemID, METH_VARARGS },
|
|
{ "GetMallItemCount", safeboxGetMallItemCount, METH_VARARGS },
|
|
{ "GetMallItemMetinSocket", safeboxGetMallItemMetinSocket, METH_VARARGS },
|
|
{ "GetMallItemAttribute", safeboxGetMallItemAttribute, METH_VARARGS },
|
|
{ "GetMallSize", safeboxGetMallSize, METH_VARARGS },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
PyObject * poModule = Py_InitModule("safebox", s_methods);
|
|
PyModule_AddIntConstant(poModule, "SAFEBOX_SLOT_X_COUNT", CPythonSafeBox::SAFEBOX_SLOT_X_COUNT);
|
|
PyModule_AddIntConstant(poModule, "SAFEBOX_SLOT_Y_COUNT", CPythonSafeBox::SAFEBOX_SLOT_Y_COUNT);
|
|
PyModule_AddIntConstant(poModule, "SAFEBOX_PAGE_SIZE", CPythonSafeBox::SAFEBOX_PAGE_SIZE);
|
|
}
|