feat: implement offline shop and private shop search client subsystems (Stage 5 Part 2)

- Enable ENABLE_OFFLINESHOP_SYSTEM and ENABLE_SHOP_SEARCH_SYSTEM in Locale_inc.h
- Add CG57, CG58, CG143, GC47, GC48, GC156 packets and subheaders in Packet.h
- Implement PythonShop offline shop item/stock/money methods and Python bindings
- Implement PythonNetworkStream offline shop packet sending and receiving handlers
- Port PythonPrivateShopSearch and export privateShopSearch Python module
- Add PythonUtils PyTuple_GetLongLong for 64-bit yang input parsing
- Add Python UI module test assertions covering offline shop and search APIs
This commit is contained in:
shen
2026-10-20 03:38:34 -07:00
parent 9ef25b79d8
commit 18d9c89af8
20 changed files with 1741 additions and 1 deletions
+7
View File
@@ -2480,6 +2480,13 @@ void CInstanceBase::__UpdateEffectShown()
m_GraphicThingInstance.SetAttachingEffectShown(isShown && PORT_IsDisplayVisible());
}
#ifdef ENABLE_OFFLINESHOP_SYSTEM
BOOL CInstanceBase::IsShop()
{
return GetRace() >= 30000 && GetRace() <= 30020;
}
#endif
bool CInstanceBase::PORT_IsDisplayVisible()
{
// AVA2 CActorInstance::IsShop and InstanceBase::__CanRender, including
+3
View File
@@ -589,6 +589,9 @@ class CInstanceBase
BOOL IsResource();
BOOL IsNPC();
BOOL IsPC();
#ifdef ENABLE_OFFLINESHOP_SYSTEM
BOOL IsShop();
#endif
BOOL IsPoly();
BOOL IsWarp();
BOOL IsGoto();
+4
View File
@@ -7,4 +7,8 @@
#define ENABLE_ATTR_6TH_7TH
#define __BL_67_ATTR__
#define ENABLE_SPECIAL_STORAGE
#define ENABLE_OFFLINESHOP_SYSTEM
#ifdef ENABLE_OFFLINESHOP_SYSTEM
#define ENABLE_SHOP_SEARCH_SYSTEM
#endif
//#define ENABLE_DISCORD_RPC
+162
View File
@@ -81,6 +81,13 @@ enum
HEADER_CG_ADD_FLY_TARGETING = 53,
HEADER_CG_SHOOT = 54,
HEADER_CG_MYSHOP = 55,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
HEADER_CG_OFFLINE_SHOP = 57,
HEADER_CG_MY_OFFLINE_SHOP = 58,
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
HEADER_CG_SHOP_SEARCH = 143,
#endif
//HEADER_BLANK56 = 56,
//HEADER_BLANK57 = 57,
//HEADER_BLANK58 = 58,
@@ -232,6 +239,14 @@ enum
HEADER_GC_SCRIPT = 45,
HEADER_GC_QUEST_CONFIRM = 46,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
HEADER_GC_OFFLINE_SHOP = 47,
HEADER_GC_OFFLINE_SHOP_SIGN = 48,
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
HEADER_GC_SHOPSEARCH_SET = 156,
#endif
HEADER_GC_MOUNT = 61,
HEADER_GC_OWNERSHIP = 62,
HEADER_GC_TARGET = 63,
@@ -400,7 +415,12 @@ enum
PASS_MAX_NUM = 16,
CHAT_MAX_NUM = 128,
PATH_NODE_MAX_NUM = 64,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
OFFLINE_SHOP_HOST_ITEM_MAX_NUM = 80,
SHOP_SIGN_MAX_LEN = 45,
#else
SHOP_SIGN_MAX_LEN = 32,
#endif
PLAYER_PER_ACCOUNT3 = 3,
PLAYER_PER_ACCOUNT4 = 4,
@@ -717,12 +737,32 @@ enum
SHOP_SUBHEADER_CG_BUY,
SHOP_SUBHEADER_CG_SELL,
SHOP_SUBHEADER_CG_SELL2,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
SHOP_SUBHEADER_CG_ADD_ITEM,
SHOP_SUBHEADER_CG_REMOVE_ITEM,
SHOP_SUBHEADER_CG_DESTROY_OFFLINE_SHOP,
SHOP_SUBHEADER_CG_CHECK,
SHOP_SUBHEADER_CG_BUTTON,
SHOP_SUBHEADER_CG_CHANGE_TITLE,
SHOP_SUBHEADER_CG_TAKE_MONEY,
SHOP_SUBHEADER_CG_LOG_REMOVE,
SHOP_SUBHEADER_CG_CHANGE_DECORATION,
SHOP_SUBHEADER_CG_OPEN_SLOT,
SHOP_SUBHEADER_CG_GET_ITEM,
SHOP_SUBHEADER_CG_ADD_TIME,
SHOP_SUBHEADER_CG_OPEN_WITH_VID,
#endif
};
typedef struct command_shop
{
BYTE header;
BYTE subheader;
#ifdef ENABLE_OFFLINESHOP_SYSTEM
char title[50 + 1];
DWORD vid;
BYTE pos;
#endif
} TPacketCGShop;
enum
@@ -1894,6 +1934,14 @@ enum EPacketShopSubHeaders
SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY_EX,
SHOP_SUBHEADER_GC_START_ITEM_CURRENCY,
SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
SHOP_SUBHEADER_GC_REFRESH_MONEY,
SHOP_SUBHEADER_GC_CHECK_RESULT,
SHOP_SUBHEADER_GC_REFRESH_DISPLAY_COUNT,
SHOP_SUBHEADER_GC_REALWATCHER_COUNT,
SHOP_SUBHEADER_GC_REFRESH_COUNT,
SHOP_SUBHEADER_GC_CHANGE_TITLE,
#endif
};
typedef struct packet_shop
@@ -2336,6 +2384,120 @@ typedef struct SPacketGCShopSign
char szSign[SHOP_SIGN_MAX_LEN + 1];
} TPacketGCShopSign;
#ifdef ENABLE_OFFLINESHOP_SYSTEM
typedef struct packet_offline_shop_item
{
DWORD id;
DWORD vnum;
long long price;
int count;
BYTE display_pos;
long alSockets[ITEM_SOCKET_SLOT_MAX_NUM];
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_SLOT_MAX_NUM];
BYTE status;
char szBuyerName[CHARACTER_NAME_MAX_LEN+1];
#ifdef WJ_CHANGELOOK_SYSTEM
DWORD transmutation;
#endif
DWORD owner_id;
} TOfflineShopItemData;
typedef struct ShopLog {
char name[CHARACTER_NAME_MAX_LEN + 1];
char date[25];
DWORD itemVnum;
DWORD itemCount;
long long price;
} TShopLog;
typedef struct SShopDecoration {
char sign[SHOP_SIGN_MAX_LEN + 1];
DWORD owner_id;
BYTE vnum;
BYTE type;
} TShopDecoration;
typedef struct SOfflineShopItemTable
{
DWORD vnum;
int count;
TItemPos pos;
long long price;
BYTE display_pos;
} TOfflineShopItemTable;
typedef struct SOfflineShopAddItem
{
TItemPos bDisplayPos;
BYTE bPos;
long long lPrice;
} TOfflineShopAddItem;
typedef struct SPacketCGMyOfflineShop
{
BYTE bHeader;
char szSign[SHOP_SIGN_MAX_LEN + 1];
BYTE bCount;
DWORD shopVnum;
BYTE shopTitle;
} TPacketCGMyOfflineShop;
typedef struct packet_offline_shop_start
{
DWORD owner_vid;
TOfflineShopItemData items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
DWORD m_dwDisplayedCount;
char title[SHOP_SIGN_MAX_LEN + 1];
long long price;
DWORD m_dwRealWatcherCount;
TShopLog log[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
unsigned long long flag;
int time;
DWORD type;
bool IsOwner;
} TPacketGCOfflineShopStart;
typedef struct packet_offline_shop_update_item
{
BYTE pos;
TOfflineShopItemData item;
DWORD m_dwDisplayedCount;
DWORD m_dwRealWatcherCount;
char title[SHOP_SIGN_MAX_LEN + 1];
long long price;
TShopLog log;
unsigned long long flag;
int time;
DWORD type;
} TPacketGCOfflineShopUpdateItem;
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
typedef struct packet_priv_shop_item_set
{
BYTE header;
DWORD size;
} TPacketGCShopSearchItemSet;
typedef struct command_shop_search
{
BYTE header;
int ItemCat;
int SubCat;
char searchInput[50];
BYTE avg[2];
BYTE skill[2];
BYTE abs[2];
BYTE level[2];
BYTE refine[2];
BYTE sex;
BYTE enchant;
BYTE alchemy;
BYTE character;
long long price[2];
} TPacketCGShopSearch;
#endif
typedef struct SPacketGCTime
{
BYTE bHeader;
@@ -20,6 +20,9 @@
#include "PythonIME.h"
#include "PythonItem.h"
#include "PythonShop.h"
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
#include "PythonPrivateShopSearch.h"
#endif
#include "PythonExchange.h"
#include "PythonChat.h"
#include "PythonTextTail.h"
@@ -346,6 +349,9 @@ class CPythonApplication final : public CMSApplication, public CInputKeyboard, p
CPythonMessenger m_pyManager;
CPythonSafeBox m_pySafeBox;
CPythonGuild m_pyGuild;
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
CPythonPrivateShopSearch m_pyPrivateShopSearch;
#endif
CGuildMarkManager m_kGuildMarkManager;
CGuildMarkDownloader m_kGuildMarkDownloader;
@@ -1583,6 +1583,18 @@ void initapp()
PyModule_AddIntConstant(poModule, "ENABLE_SPECIAL_STORAGE", 0);
#endif
#ifdef ENABLE_OFFLINESHOP_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_OFFLINESHOP_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_OFFLINESHOP_SYSTEM", 0);
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_SHOP_SEARCH_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_SHOP_SEARCH_SYSTEM", 0);
#endif
#ifdef USE_OPENID
PyModule_AddIntConstant(poModule, "USE_OPENID", 1);
if (openid_test)
@@ -192,6 +192,13 @@ class CMainPacketHeaderMap : public CNetworkPacketHeaderMap
Set(HEADER_GC_AVA2_EVENTS,CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCAva2Events),DYNAMIC_SIZE_PACKET));
Set(HEADER_GC_SWITCHBOT, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCSwitchbot), DYNAMIC_SIZE_PACKET)); // PORT: AVA2 switchbot
Set(HEADER_GC_EXTENDED_POINTS, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCExtendedPointGold), STATIC_SIZE_PACKET)); // PORT: AVA2 64-bit gold
#ifdef ENABLE_OFFLINESHOP_SYSTEM
Set(HEADER_GC_OFFLINE_SHOP, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCShop), DYNAMIC_SIZE_PACKET));
Set(HEADER_GC_OFFLINE_SHOP_SIGN, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCShopSign), STATIC_SIZE_PACKET));
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
Set(HEADER_GC_SHOPSEARCH_SET, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCShopSearchItemSet), DYNAMIC_SIZE_PACKET));
#endif
}
};
@@ -917,6 +924,9 @@ CPythonNetworkStream::CPythonNetworkStream()
m_isStartGame = FALSE;
m_isEnableChatInsultFilter = FALSE;
m_bComboSkillFlag = FALSE;
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
m_isRefreshShopSearchWnd = false;
#endif
m_strPhase = "OffLine";
__InitializeGamePhase();
@@ -174,6 +174,29 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
bool SendShopSellPacket(BYTE bySlot);
bool SendShopSellPacketNew(BYTE bySlot, BYTE byCount);
#ifdef ENABLE_OFFLINESHOP_SYSTEM
// Offline Shop
bool SendOfflineShopEndPacket();
bool SendOfflineShopBuyPacket(DWORD vid, BYTE pos);
bool SendAddOfflineShopItem(TItemPos bDisplayPos, BYTE bPos, long long lPrice);
bool SendRemoveOfflineShopItem(BYTE bPos);
bool SendOpenShopSlot(BYTE bPos);
bool SendGetBackItems();
bool SendAddTime();
bool SendDestroyOfflineShop();
bool SendTakeOfflineMoney();
bool SendOfflineShopChangeTitle(const char* title);
bool SendOfflineShopCheck();
bool SendOfflineShopButton();
bool SendOfflineShopRemoveLogs();
bool SendOfflineOpenWithVID(DWORD vid);
bool SendOfflineShopChangeDecoration(const char* sign, DWORD vnum, DWORD type);
bool SendBuildOfflineShopPacket(const char* c_szName, const std::vector<TOfflineShopItemTable>& c_rSellingItemStock, DWORD shopVnum, BYTE shopTitle);
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
bool SendPrivateShopSearchInfo(TPacketCGShopSearch* p);
#endif
// Exchange
bool SendExchangeStartPacket(DWORD vid);
bool SendExchangeItemAddPacket(TItemPos ItemPos, BYTE byDisplayPos);
@@ -488,6 +511,14 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
bool RecvShopPacket();
bool RecvShopSignPacket();
#ifdef ENABLE_OFFLINESHOP_SYSTEM
bool RecvOfflineShopPacket();
bool RecvOfflineShopSignPacket();
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
bool RecvShopSearchSet();
void __RefreshShopSearchWindow();
#endif
bool RecvExchangePacket();
// Quest
@@ -735,6 +766,9 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
bool m_isEnableChatInsultFilter;
bool m_bComboSkillFlag;
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
bool m_isRefreshShopSearchWnd;
#endif
std::deque<std::string> m_kQue_stHack;
@@ -933,6 +933,196 @@ PyObject* netSendShopSellPacketNew(PyObject* poSelf, PyObject* poArgs)
return Py_BuildNone();
}
#ifdef ENABLE_OFFLINESHOP_SYSTEM
PyObject* netSendOfflineShopEndPacket(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::Instance();
rkNetStream.SendOfflineShopEndPacket();
return Py_BuildNone();
}
PyObject* netSendOfflineShopBuyPacket(PyObject* poSelf, PyObject* poArgs)
{
int vid;
if (!PyTuple_GetInteger(poArgs, 0, &vid))
return Py_BuildException();
int pos;
if (!PyTuple_GetInteger(poArgs, 1, &pos))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::Instance();
rkNetStream.SendOfflineShopBuyPacket((DWORD)vid, pos);
return Py_BuildNone();
}
PyObject* netSendAddOfflineShopItem(PyObject* poSelf, PyObject* poArgs)
{
int bDisplayPos;
int bPos;
long long iPrice;
int bWindowType;
if (!PyTuple_GetInteger(poArgs, 0, &bDisplayPos))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &bPos))
return Py_BuildException();
if (!PyTuple_GetLongLong(poArgs, 2, &iPrice))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 3, &bWindowType))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendAddOfflineShopItem(TItemPos(bWindowType, bDisplayPos), bPos, iPrice);
return Py_BuildNone();
}
PyObject* netSendRemoveOfflineShopItem(PyObject* poSelf, PyObject* poArgs)
{
int bPos;
if (!PyTuple_GetInteger(poArgs, 0, &bPos))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendRemoveOfflineShopItem(bPos);
return Py_BuildNone();
}
PyObject* netSendDestroyOfflineShop(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendDestroyOfflineShop();
return Py_BuildNone();
}
PyObject* netSendTakeOfflineMoney(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendTakeOfflineMoney();
return Py_BuildNone();
}
PyObject* netSendOfflineShopChangeTitle(PyObject* poSelf, PyObject* poArgs)
{
char* title;
if (!PyTuple_GetString(poArgs, 0, &title))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOfflineShopChangeTitle(title);
return Py_BuildNone();
}
PyObject* netSendOfflineShopCheck(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOfflineShopCheck();
return Py_BuildNone();
}
PyObject* netSendOfflineShopButton(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOfflineShopButton();
return Py_BuildNone();
}
PyObject* netSendOfflineShopRemoveLogs(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOfflineShopRemoveLogs();
return Py_BuildNone();
}
PyObject* netSendOpenShopSlot(PyObject* poSelf, PyObject* poArgs)
{
int bPos;
if (!PyTuple_GetInteger(poArgs, 0, &bPos))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOpenShopSlot(bPos);
return Py_BuildNone();
}
PyObject* netSendGetBackItems(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendGetBackItems();
return Py_BuildNone();
}
PyObject* netSendAddTime(PyObject* poSelf, PyObject* poArgs)
{
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendAddTime();
return Py_BuildNone();
}
PyObject* netSendOpenWithVID(PyObject* poSelf, PyObject* poArgs)
{
int vid;
if (!PyTuple_GetInteger(poArgs, 0, &vid))
return Py_BuildException();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::instance();
rkNetStream.SendOfflineOpenWithVID(vid);
return Py_BuildNone();
}
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
PyObject* netSendPrivateShopSearchInfo(PyObject* poSelf, PyObject* poArgs)
{
TPacketCGShopSearch p;
memset(&p, 0, sizeof(p));
p.header = HEADER_CG_SHOP_SEARCH;
if (!PyTuple_GetInteger(poArgs, 0, &p.ItemCat))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &p.SubCat))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 2, &p.avg[0]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 3, &p.avg[1]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 4, &p.skill[0]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 5, &p.skill[1]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 6, &p.abs[0]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 7, &p.abs[1]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 8, &p.level[0]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 9, &p.level[1]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 10, &p.refine[0]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 11, &p.refine[1]))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 12, &p.enchant))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 13, &p.alchemy))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 14, &p.sex))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 15, &p.character))
return Py_BuildException();
long long minYang = 0, maxYang = 0;
if (!PyTuple_GetLongLong(poArgs, 16, &minYang))
return Py_BuildException();
if (!PyTuple_GetLongLong(poArgs, 17, &maxYang))
return Py_BuildException();
char* searchInputConst;
if (!PyTuple_GetString(poArgs, 18, &searchInputConst))
return Py_BuildException();
strncpy(p.searchInput, searchInputConst, sizeof(p.searchInput) - 1);
p.price[0] = minYang;
p.price[1] = maxYang;
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::Instance();
rkNetStream.SendPrivateShopSearchInfo(&p);
return Py_BuildNone();
}
#endif
PyObject* netSendExchangeStartPacket(PyObject* poSelf, PyObject* poArgs)
{
int vid;
@@ -1868,6 +2058,25 @@ void initnet()
{ "SendShopBuyPacket", netSendShopBuyPacket, METH_VARARGS },
{ "SendShopSellPacket", netSendShopSellPacket, METH_VARARGS },
{ "SendShopSellPacketNew", netSendShopSellPacketNew, METH_VARARGS },
#ifdef ENABLE_OFFLINESHOP_SYSTEM
{ "SendOfflineShopEndPacket", netSendOfflineShopEndPacket, METH_VARARGS },
{ "SendOfflineShopBuyPacket", netSendOfflineShopBuyPacket, METH_VARARGS },
{ "SendAddOfflineShopItem", netSendAddOfflineShopItem, METH_VARARGS },
{ "SendRemoveOfflineShopItem", netSendRemoveOfflineShopItem, METH_VARARGS },
{ "SendDestroyOfflineShop", netSendDestroyOfflineShop, METH_VARARGS },
{ "SendTakeOfflineMoney", netSendTakeOfflineMoney, METH_VARARGS },
{ "SendOfflineShopChangeTitle", netSendOfflineShopChangeTitle, METH_VARARGS },
{ "SendOfflineShopCheck", netSendOfflineShopCheck, METH_VARARGS },
{ "SendOfflineShopButton", netSendOfflineShopButton, METH_VARARGS },
{ "SendOfflineShopRemoveLogs", netSendOfflineShopRemoveLogs, METH_VARARGS },
{ "SendOpenShopSlot", netSendOpenShopSlot, METH_VARARGS },
{ "SendGetBackItems", netSendGetBackItems, METH_VARARGS },
{ "SendAddTime", netSendAddTime, METH_VARARGS },
{ "SendOpenWithVID", netSendOpenWithVID, METH_VARARGS },
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
{ "SendPrivateShopSearchInfo", netSendPrivateShopSearchInfo, METH_VARARGS },
#endif
{ "SendExchangeStartPacket", netSendExchangeStartPacket, METH_VARARGS },
{ "SendExchangeItemAddPacket", netSendExchangeItemAddPacket, METH_VARARGS },
@@ -12,6 +12,9 @@
#include "PythonItem.h"
#include "PythonChat.h"
#include "PythonShop.h"
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
#include "PythonPrivateShopSearch.h"
#endif
#include "PythonExchange.h"
#include "PythonQuest.h"
#include "PythonEventManager.h"
@@ -655,6 +658,20 @@ void CPythonNetworkStream::GamePhase()
ret = RecvExtendedPointGoldPacket();
break;
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
case HEADER_GC_SHOPSEARCH_SET:
ret = RecvShopSearchSet();
break;
#endif
#ifdef ENABLE_OFFLINESHOP_SYSTEM
case HEADER_GC_OFFLINE_SHOP:
ret = RecvOfflineShopPacket();
break;
case HEADER_GC_OFFLINE_SHOP_SIGN:
ret = RecvOfflineShopSignPacket();
break;
#endif
default:
ret = RecvDefaultPacket(header);
break;
@@ -808,13 +825,26 @@ void CPythonNetworkStream::GamePhase()
m_isRefreshGuildWndGradePage=false;
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshGuildGradePage", Py_BuildValue("()"));
s_nextRefreshTime = curTime + 300;
}
}
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
if (m_isRefreshShopSearchWnd)
{
m_isRefreshShopSearchWnd = false;
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshShopSearch", Py_BuildValue("()"));
s_nextRefreshTime = curTime + 500;
}
#endif
}
void CPythonNetworkStream::__InitializeGamePhase()
{
__ServerTimeSync_Initialize();
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
m_isRefreshShopSearchWnd = false;
#endif
m_isRefreshStatus=false;
m_isRefreshCharacterWnd=false;
m_isRefreshEquipmentWnd=false;
@@ -4041,6 +4071,229 @@ bool CPythonNetworkStream::RecvShopSignPacket()
return true;
}
#ifdef ENABLE_OFFLINESHOP_SYSTEM
bool CPythonNetworkStream::RecvOfflineShopSignPacket()
{
TPacketGCShopSign p;
if (!Recv(sizeof(TPacketGCShopSign), &p))
return false;
CInstanceBase* pInstance = CPythonCharacterManager::instance().GetInstancePtr(p.dwVID);
if (pInstance)
{
if (pInstance->IsShop())
{
if (0 == strlen(p.szSign))
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_OfflineShop_Disappear", Py_BuildValue("(i)", p.dwVID));
else
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_OfflineShop_Appear", Py_BuildValue("(is)", p.dwVID, p.szSign));
}
}
return true;
}
bool CPythonNetworkStream::RecvOfflineShopPacket()
{
TPacketGCShop packet_shop;
if (!Recv(sizeof(packet_shop), &packet_shop))
return false;
std::vector<char> vecBuffer;
vecBuffer.clear();
int iSize = packet_shop.size - sizeof(packet_shop);
switch (packet_shop.subheader)
{
case SHOP_SUBHEADER_GC_REFRESH_MONEY:
case SHOP_SUBHEADER_GC_REFRESH_DISPLAY_COUNT:
case SHOP_SUBHEADER_GC_CHECK_RESULT:
case SHOP_SUBHEADER_GC_REFRESH_COUNT:
case SHOP_SUBHEADER_GC_REALWATCHER_COUNT:
case SHOP_SUBHEADER_GC_CHANGE_TITLE:
break;
default:
if (iSize > 0)
{
vecBuffer.resize(iSize);
if (!Recv(iSize, &vecBuffer[0]))
return false;
}
}
switch (packet_shop.subheader)
{
case SHOP_SUBHEADER_GC_START:
{
CPythonShop::Instance().Clear();
TPacketGCOfflineShopStart* pShopStartPacket = (TPacketGCOfflineShopStart*)vecBuffer.data();
for (BYTE iItemIndex = 0; iItemIndex < OFFLINE_SHOP_HOST_ITEM_MAX_NUM; ++iItemIndex)
CPythonShop::Instance().SetOfflineShopItemData(iItemIndex, pShopStartPacket->items[iItemIndex]);
CPythonShop::Instance().SetShopDisplayedCount(pShopStartPacket->m_dwDisplayedCount);
CPythonShop::Instance().SetRealWatcherCount(pShopStartPacket->m_dwRealWatcherCount);
CPythonShop::Instance().SetCurrentOfflineShopMoney(pShopStartPacket->price);
CPythonShop::Instance().SetShopSign(pShopStartPacket->title);
CPythonShop::Instance().SetShopFlag(pShopStartPacket->flag);
CPythonShop::Instance().SetShopType(pShopStartPacket->type);
CPythonShop::Instance().SetShopTime(pShopStartPacket->time);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "ClearOfflineShopLog", Py_BuildValue("()"));
for (int logIndex = OFFLINE_SHOP_HOST_ITEM_MAX_NUM-1; logIndex >= 0; --logIndex)
if (pShopStartPacket->log[logIndex].price != 0) {
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "AppendShopLog", Py_BuildValue("(ssiiL)", pShopStartPacket->log[logIndex].name, pShopStartPacket->log[logIndex].date, pShopStartPacket->log[logIndex].itemVnum, pShopStartPacket->log[logIndex].itemCount, pShopStartPacket->log[logIndex].price));
}
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "StartOfflineShop", Py_BuildValue("(ii)", pShopStartPacket->owner_vid, pShopStartPacket->IsOwner == true ? 1 : 0));
}
break;
case SHOP_SUBHEADER_GC_END:
{
CPythonShop::instance().Clear();
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "ClearOfflineShopLog", Py_BuildValue("()"));
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "EndOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_UPDATE_ITEM:
{
TPacketGCOfflineShopUpdateItem* pShopUpdateItemPacket = (TPacketGCOfflineShopUpdateItem*)vecBuffer.data();
CPythonShop::Instance().SetShopDisplayedCount(pShopUpdateItemPacket->m_dwDisplayedCount);
CPythonShop::Instance().SetRealWatcherCount(pShopUpdateItemPacket->m_dwRealWatcherCount);
CPythonShop::Instance().SetShopFlag(pShopUpdateItemPacket->flag);
CPythonShop::Instance().SetShopTime(pShopUpdateItemPacket->time);
CPythonShop::Instance().SetShopSign(pShopUpdateItemPacket->title);
CPythonShop::Instance().SetShopType(pShopUpdateItemPacket->type);
CPythonShop::Instance().SetOfflineShopItemData(pShopUpdateItemPacket->pos, pShopUpdateItemPacket->item);
CPythonShop::Instance().SetCurrentOfflineShopMoney(pShopUpdateItemPacket->price);
if (pShopUpdateItemPacket->log.price != 0) {
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "AppendShopLogFirst", Py_BuildValue("(ssiiL)", pShopUpdateItemPacket->log.name, pShopUpdateItemPacket->log.date, pShopUpdateItemPacket->log.itemVnum, pShopUpdateItemPacket->log.itemCount, pShopUpdateItemPacket->log.price));
}
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_MONEY"));
break;
case SHOP_SUBHEADER_GC_SOLD_OUT:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "SOLDOUT"));
break;
case SHOP_SUBHEADER_GC_OK:
break;
case SHOP_SUBHEADER_GC_INVENTORY_FULL:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "INVENTORY_FULL"));
break;
case SHOP_SUBHEADER_GC_INVALID_POS:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "INVALID_POS"));
break;
case SHOP_SUBHEADER_GC_REFRESH_MONEY:
{
long long llMoney = 0;
if (!Recv(sizeof(long long), &llMoney))
return false;
CPythonShop::Instance().SetCurrentOfflineShopMoney(llMoney);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_CHECK_RESULT:
{
BYTE bHasOfflineShop = 0;
if (!Recv(sizeof(BYTE), &bHasOfflineShop))
return false;
CPythonShop::instance().SetHasOfflineShop(bHasOfflineShop == 1 ? true : false);
}
break;
case SHOP_SUBHEADER_GC_REFRESH_DISPLAY_COUNT:
{
DWORD displayCount = 0;
if (!Recv(sizeof(DWORD), &displayCount))
return false;
CPythonShop::Instance().SetShopDisplayedCount(displayCount);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_REALWATCHER_COUNT:
{
DWORD realWatcher = 0;
if (!Recv(sizeof(DWORD), &realWatcher))
return false;
CPythonShop::Instance().SetRealWatcherCount(realWatcher);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_REFRESH_COUNT:
{
DWORD count[2] = { 0, 0 };
if (!Recv(sizeof(count), &count))
return false;
CPythonShop::Instance().SetShopDisplayedCount(count[0]);
CPythonShop::Instance().SetRealWatcherCount(count[1]);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
case SHOP_SUBHEADER_GC_CHANGE_TITLE:
{
char sign[SHOP_SIGN_MAX_LEN + 1];
if (!Recv(sizeof(sign), &sign))
return false;
CPythonShop::Instance().SetShopSign(sign);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshOfflineShop", Py_BuildValue("()"));
}
break;
default:
TraceError("CPythonNetworkStream::RecvOfflineShopPacket: Unknown subheader %d\n", packet_shop.subheader);
break;
}
return true;
}
#endif
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
void CPythonNetworkStream::__RefreshShopSearchWindow()
{
m_isRefreshShopSearchWnd = true;
}
bool CPythonNetworkStream::SendPrivateShopSearchInfo(TPacketCGShopSearch* p)
{
if (!__CanActMainInstance())
return true;
if (!Send(sizeof(TPacketCGShopSearch), p))
{
return false;
}
return true;
}
bool CPythonNetworkStream::RecvShopSearchSet()
{
TPacketGCShopSearchItemSet packet_item_set;
if (!Recv(sizeof(TPacketGCShopSearchItemSet), &packet_item_set))
return false;
WORD itemCount;
if (!Recv(sizeof(itemCount), &itemCount))
return false;
std::vector<TOfflineShopItemData> m_vec;
m_vec.resize(itemCount);
if (!Recv(itemCount * sizeof(TOfflineShopItemData), m_vec.data()))
return false;
for (WORD j = 0; j < itemCount; j++)
CPythonPrivateShopSearch::Instance().AddItemData(m_vec[j]);
__RefreshShopSearchWindow();
return true;
}
#endif
/////////////////////////////////////////////////////////////////////////
bool CPythonNetworkStream::RecvTimePacket()
@@ -998,3 +998,260 @@ bool CPythonNetworkStream::SendItemsPickUpPacket(std::vector<DWORD> itemVector)
return SendSequence();
}
#ifdef ENABLE_OFFLINESHOP_SYSTEM
bool CPythonNetworkStream::SendBuildOfflineShopPacket(const char* c_szName, const std::vector<TOfflineShopItemTable>& c_rSellingItemStock, DWORD shopVnum, BYTE shopTitle)
{
TPacketCGMyOfflineShop packet;
packet.bHeader = HEADER_CG_MY_OFFLINE_SHOP;
strncpy(packet.szSign, c_szName, SHOP_SIGN_MAX_LEN);
packet.bCount = c_rSellingItemStock.size();
packet.shopVnum = shopVnum;
packet.shopTitle = shopTitle;
if (!Send(sizeof(packet), &packet))
return false;
for (std::vector<TOfflineShopItemTable>::const_iterator itor = c_rSellingItemStock.begin(); itor < c_rSellingItemStock.end(); ++itor)
{
const TOfflineShopItemTable& c_rItem = *itor;
if (!Send(sizeof(c_rItem), &c_rItem))
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopEndPacket()
{
if (!__CanActMainInstance())
return true;
TPacketCGShop packet_shop;
packet_shop.header = HEADER_CG_OFFLINE_SHOP;
packet_shop.subheader = SHOP_SUBHEADER_CG_END;
if (!Send(sizeof(packet_shop), &packet_shop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopBuyPacket(DWORD vid, BYTE bPos)
{
if (!__CanActMainInstance())
return true;
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_BUY;
PacketShop.vid = vid;
PacketShop.pos = bPos;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendAddOfflineShopItem(TItemPos bDisplayPos, BYTE bPos, long long lPrice)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_ADD_ITEM;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
TOfflineShopAddItem pTable;
pTable.bDisplayPos = bDisplayPos;
pTable.bPos = bPos;
pTable.lPrice = lPrice;
if (!Send(sizeof(TOfflineShopAddItem), &pTable))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendRemoveOfflineShopItem(BYTE bPos)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_REMOVE_ITEM;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
if (!Send(sizeof(BYTE), &bPos))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOpenShopSlot(BYTE bPos)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_OPEN_SLOT;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
if (!Send(sizeof(BYTE), &bPos))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendGetBackItems()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_GET_ITEM;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendAddTime()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_ADD_TIME;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendDestroyOfflineShop()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_DESTROY_OFFLINE_SHOP;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendTakeOfflineMoney()
{
static DWORD s_LastTime = timeGetTime() - 5001;
if (timeGetTime() - s_LastTime < 5000)
return true;
s_LastTime = timeGetTime();
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_TAKE_MONEY;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopChangeTitle(const char* title)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_CHANGE_TITLE;
strncpy(PacketShop.title, title, sizeof(PacketShop.title));
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopCheck()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_CHECK;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopButton()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_BUTTON;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopRemoveLogs()
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_LOG_REMOVE;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineOpenWithVID(DWORD vid)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_OPEN_WITH_VID;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
if (!Send(sizeof(DWORD), &vid))
{
return false;
}
return SendSequence();
}
bool CPythonNetworkStream::SendOfflineShopChangeDecoration(const char* sign, DWORD vnum, DWORD type)
{
TPacketCGShop PacketShop;
PacketShop.header = HEADER_CG_OFFLINE_SHOP;
PacketShop.subheader = SHOP_SUBHEADER_CG_CHANGE_DECORATION;
if (!Send(sizeof(TPacketCGShop), &PacketShop))
{
return false;
}
TShopDecoration p;
snprintf(p.sign, sizeof(p.sign), "%s", sign);
p.vnum = vnum;
p.type = type;
if (!Send(sizeof(TShopDecoration), &p))
{
return false;
}
return SendSequence();
}
#endif
@@ -0,0 +1,220 @@
#include "StdAfx.h"
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
#include "PythonPrivateShopSearch.h"
#include "Packet.h"
CPythonPrivateShopSearch::CPythonPrivateShopSearch() {}
CPythonPrivateShopSearch::~CPythonPrivateShopSearch() {}
void CPythonPrivateShopSearch::AddItemData(TOfflineShopItemData& rItemData)
{
m_ItemInstanceVector.push_back(rItemData);
}
void CPythonPrivateShopSearch::ClearItemData()
{
m_ItemInstanceVector.clear();
}
DWORD CPythonPrivateShopSearch::GetItemDataPtr(DWORD index, TOfflineShopItemData** ppInstance)
{
if (index >= m_ItemInstanceVector.size())
{
*ppInstance = NULL;
return 0;
}
*ppInstance = &m_ItemInstanceVector.at(index);
return 1;
}
PyObject* privateShopSearchGetSearchItemMetinSocket(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 >= ITEM_SOCKET_SLOT_MAX_NUM)
return Py_BuildException();
TOfflineShopItemData* pItemData;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(iSlotIndex, &pItemData))
{
return Py_BuildException();
}
return Py_BuildValue("i", pItemData->alSockets[iSocketIndex]);
}
PyObject* privateShopSearchGetSearchItemAttribute(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 < ITEM_ATTRIBUTE_SLOT_MAX_NUM)
{
TOfflineShopItemData* pItemData;
if (CPythonPrivateShopSearch::Instance().GetItemDataPtr(iSlotIndex, &pItemData))
{
return Py_BuildValue("ii", pItemData->aAttr[iAttrSlotIndex].bType, pItemData->aAttr[iAttrSlotIndex].sValue);
}
}
return Py_BuildValue("ii", 0, 0);
}
PyObject* privateShopSearchGetItemCount(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonPrivateShopSearch::Instance().GetItemDataCount());
}
PyObject* privateShopSearchGetSearchItemCount(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return Py_BuildValue("i", pInstance->count);
}
PyObject* privateShopSearchGetSearchItemPrice(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return PyLong_FromLongLong(pInstance->price);
}
PyObject* privateShopSearchGetSearchItemShopVID(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return Py_BuildValue("i", pInstance->owner_id);
}
PyObject* privateShopSearchGetSearchItemPos(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return Py_BuildValue("i", pInstance->display_pos);
}
PyObject* privateShopSearchGetSearchItemVnum(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return Py_BuildValue("i", pInstance->vnum);
}
PyObject* privateShopSearchGetSearchItemID(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
return Py_BadArgument();
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
return Py_BuildException();
return Py_BuildValue("i", pInstance->id);
}
PyObject* privateShopSearchGetSearchItemBuyerName(PyObject* poSelf, PyObject* poArgs)
{
int ipos;
if (!PyTuple_GetInteger(poArgs, 0, &ipos))
{
return Py_BadArgument();
}
TOfflineShopItemData* pInstance;
if (!CPythonPrivateShopSearch::Instance().GetItemDataPtr(ipos, &pInstance))
{
return Py_BuildException();
}
return Py_BuildValue("s", pInstance->szBuyerName);
}
PyObject* privateShopSearchClearSearchItems(PyObject* poSelf, PyObject* poArgs)
{
CPythonPrivateShopSearch::Instance().ClearItemData();
return Py_BuildNone();
}
void initprivateShopSearch()
{
static PyMethodDef s_methods[] =
{
{ "GetItemCount", privateShopSearchGetItemCount, METH_VARARGS },
{ "GetSearchItemCount", privateShopSearchGetSearchItemCount, METH_VARARGS },
{ "GetSearchItemPrice", privateShopSearchGetSearchItemPrice, METH_VARARGS },
{ "GetSearchItemVnum", privateShopSearchGetSearchItemVnum, METH_VARARGS },
{ "GetSearchItemShopVID", privateShopSearchGetSearchItemShopVID, METH_VARARGS },
{ "ClearSearchItems", privateShopSearchClearSearchItems, METH_VARARGS },
{ "GetSearchItemMetinSocket", privateShopSearchGetSearchItemMetinSocket, METH_VARARGS },
{ "GetSearchItemAttribute", privateShopSearchGetSearchItemAttribute, METH_VARARGS },
{ "GetSearchItemPos", privateShopSearchGetSearchItemPos, METH_VARARGS },
{ "GetSearchItemSeller", privateShopSearchGetSearchItemBuyerName, METH_VARARGS },
{ "GetSearchItemID", privateShopSearchGetSearchItemID, METH_VARARGS },
{ NULL, NULL, NULL },
};
Py_InitModule("privateShopSearch", s_methods);
}
#endif
@@ -0,0 +1,20 @@
#pragma once
#ifdef ENABLE_SHOP_SEARCH_SYSTEM
#include "Packet.h"
#include <vector>
class CPythonPrivateShopSearch : public CSingleton<CPythonPrivateShopSearch>
{
public:
CPythonPrivateShopSearch();
virtual ~CPythonPrivateShopSearch();
void AddItemData(TOfflineShopItemData& rItemData);
void ClearItemData();
DWORD GetItemDataCount() { return m_ItemInstanceVector.size(); }
DWORD GetItemDataPtr(DWORD index, TOfflineShopItemData** ppInstance);
protected:
std::vector<TOfflineShopItemData> m_ItemInstanceVector;
};
#endif
+425
View File
@@ -2,6 +2,7 @@
#include "PythonShop.h"
#include "PythonNetworkStream.h"
#include <algorithm>
//BOOL CPythonShop::GetSlotItemID(DWORD dwSlotPos, DWORD* pdwItemID)
//{
@@ -209,6 +210,21 @@ void CPythonShop::Clear()
for (int i = 0; i < SHOP_TAB_COUNT_MAX; i++)
memset (m_aShoptabs[i].items, 0, sizeof(TShopItemData) * SHOP_HOST_ITEM_MAX_NUM);
#ifdef ENABLE_OFFLINESHOP_SYSTEM
ClearOfflineShopStock();
m_isOfflineShop = FALSE;
m_bHasOfflineShop = false;
m_llCurrentOfflineShopMoney = 0;
m_dwDisplayedCount = 0;
m_shopFlag = 0;
time = 0;
type = 0;
m_dwRealWatcherCount = 0;
SetShopSign("NONE");
for (int i = 0; i < SHOP_TAB_COUNT_MAX; i++)
memset(m_aOfflineShoptabs[i].items, 0, sizeof(TOfflineShopItemData) * OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
#endif
}
CPythonShop::CPythonShop(void)
@@ -419,6 +435,382 @@ PyObject* shopGetCountBuy(PyObject*,PyObject* args) {
int index;if(!PyTuple_GetInteger(args,0,&index))return Py_BuildException();
return Py_BuildValue("I",CPythonShop::Instance().GetItemCurrencyCount(index));
}
#ifdef ENABLE_OFFLINESHOP_SYSTEM
void CPythonShop::SetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData& c_rShopItemData)
{
BYTE tabIdx = dwIndex / OFFLINE_SHOP_HOST_ITEM_MAX_NUM;
DWORD dwSlotPos = dwIndex % OFFLINE_SHOP_HOST_ITEM_MAX_NUM;
SetOfflineShopItemData(tabIdx, dwSlotPos, c_rShopItemData);
}
void CPythonShop::SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData& c_rShopItemData)
{
if (tabIdx >= SHOP_TAB_COUNT_MAX || dwSlotPos >= OFFLINE_SHOP_HOST_ITEM_MAX_NUM)
{
TraceError("Out of Index. tabIdx(%d) must be less than %d. dwSlotPos(%d) must be less than %d", tabIdx, SHOP_TAB_COUNT_MAX, dwSlotPos, OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
return;
}
m_aOfflineShoptabs[tabIdx].items[dwSlotPos] = c_rShopItemData;
}
BOOL CPythonShop::GetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData** c_ppItemData)
{
BYTE tabIdx = dwIndex / OFFLINE_SHOP_HOST_ITEM_MAX_NUM;
DWORD dwSlotPos = dwIndex % OFFLINE_SHOP_HOST_ITEM_MAX_NUM;
return GetOfflineShopItemData(tabIdx, dwSlotPos, c_ppItemData);
}
BOOL CPythonShop::GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData** c_ppItemData)
{
if (tabIdx >= SHOP_TAB_COUNT_MAX || dwSlotPos >= OFFLINE_SHOP_HOST_ITEM_MAX_NUM)
{
TraceError("Out of Index. tabIdx(%d) must be less than %d. dwSlotPos(%d) must be less than %d", tabIdx, SHOP_TAB_COUNT_MAX, dwSlotPos, OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
return FALSE;
}
if (m_aOfflineShoptabs[tabIdx].items[dwSlotPos].vnum)
{
*c_ppItemData = &m_aOfflineShoptabs[tabIdx].items[dwSlotPos];
return TRUE;
}
*c_ppItemData = NULL;
return FALSE;
}
struct OfflineShopItemStockSortFunc
{
bool operator() (const TOfflineShopItemTable& rkLeft, const TOfflineShopItemTable& rkRight) const
{
return rkLeft.display_pos < rkRight.display_pos;
}
};
void CPythonShop::AddOfflineShopItemStock(TItemPos ItemPos, BYTE dwDisplayPos, long long dwPrice)
{
DelOfflineShopItemStock(ItemPos);
TOfflineShopItemTable SellingItem;
memset(&SellingItem, 0, sizeof(SellingItem));
SellingItem.vnum = 0;
SellingItem.count = 0;
SellingItem.pos = ItemPos;
SellingItem.price = dwPrice;
SellingItem.display_pos = dwDisplayPos;
m_OfflineShopItemStock.insert(std::make_pair(ItemPos, SellingItem));
}
void CPythonShop::DelOfflineShopItemStock(TItemPos ItemPos)
{
auto it = m_OfflineShopItemStock.find(ItemPos);
if (it != m_OfflineShopItemStock.end())
m_OfflineShopItemStock.erase(it);
}
long long CPythonShop::GetOfflineShopItemPrice(TItemPos ItemPos)
{
auto itor = m_OfflineShopItemStock.find(ItemPos);
if (m_OfflineShopItemStock.end() == itor)
return 0;
return itor->second.price;
}
void CPythonShop::BuildOfflineShop(const char* c_szName, DWORD shopVnum, BYTE shopTitle)
{
std::vector<TOfflineShopItemTable> ItemStock;
ItemStock.reserve(m_OfflineShopItemStock.size());
for (auto itor = m_OfflineShopItemStock.begin(); itor != m_OfflineShopItemStock.end(); ++itor)
{
ItemStock.push_back(itor->second);
}
std::sort(ItemStock.begin(), ItemStock.end(), OfflineShopItemStockSortFunc());
CPythonNetworkStream::Instance().SendBuildOfflineShopPacket(c_szName, ItemStock, shopVnum, shopTitle);
}
PyObject* shopIsOfflineShop(PyObject* poSelf, PyObject* poArgs)
{
CPythonShop& rkShop = CPythonShop::Instance();
return Py_BuildValue("i", rkShop.IsOfflineShop());
}
PyObject* shopGetOfflineShopItemID(PyObject* poSelf, PyObject* poArgs)
{
int nPos;
if (!PyTuple_GetInteger(poArgs, 0, &nPos))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(nPos, &c_pItemData))
return Py_BuildValue("i", c_pItemData->vnum);
return Py_BuildValue("i", 0);
}
PyObject* shopGetOfflineShopItemCount(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->count);
return Py_BuildValue("i", 0);
}
PyObject* shopGetOfflineShopItemVnum(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->vnum);
return Py_BuildValue("i", 0);
}
PyObject* shopGetOfflineShopItemPrice(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return PyLong_FromLongLong(c_pItemData->price);
return Py_BuildValue("i", 0);
}
PyObject* shopGetSign(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("s", CPythonShop::Instance().GetShopSign());
}
PyObject* shopGetOfflineShopItemMetinSocket(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
int iMetinSocketIndex;
if (!PyTuple_GetInteger(poArgs, 1, &iMetinSocketIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->alSockets[iMetinSocketIndex]);
return Py_BuildValue("i", 0);
}
PyObject* shopGetOfflineShopItemAttribute(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
int iAttrSlotIndex;
if (!PyTuple_GetInteger(poArgs, 1, &iAttrSlotIndex))
return Py_BuildException();
if (iAttrSlotIndex >= 0 && iAttrSlotIndex < ITEM_ATTRIBUTE_SLOT_MAX_NUM)
{
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("ii", c_pItemData->aAttr[iAttrSlotIndex].bType, c_pItemData->aAttr[iAttrSlotIndex].sValue);
}
return Py_BuildValue("ii", 0, 0);
}
PyObject* shopClearOfflineShopStock(PyObject* poSelf, PyObject* poArgs)
{
CPythonShop::Instance().ClearOfflineShopStock();
return Py_BuildNone();
}
PyObject* shopAddOfflineShopItemStock(PyObject* poSelf, PyObject* poArgs)
{
int bItemWindowType;
if (!PyTuple_GetInteger(poArgs, 0, &bItemWindowType))
return Py_BuildException();
int wItemSlotIndex;
if (!PyTuple_GetInteger(poArgs, 1, &wItemSlotIndex))
return Py_BuildException();
int iDisplaySlotIndex;
if (!PyTuple_GetInteger(poArgs, 2, &iDisplaySlotIndex))
return Py_BuildException();
long long iPrice;
if (!PyTuple_GetLongLong(poArgs, 3, &iPrice))
return Py_BuildException();
CPythonShop::Instance().AddOfflineShopItemStock(TItemPos(bItemWindowType, wItemSlotIndex), iDisplaySlotIndex, iPrice);
return Py_BuildNone();
}
PyObject* shopDelOfflineShopItemStock(PyObject* poSelf, PyObject* poArgs)
{
int bItemWindowType;
if (!PyTuple_GetInteger(poArgs, 0, &bItemWindowType))
return Py_BuildException();
int wItemSlotIndex;
if (!PyTuple_GetInteger(poArgs, 1, &wItemSlotIndex))
return Py_BuildException();
CPythonShop::Instance().DelOfflineShopItemStock(TItemPos(bItemWindowType, wItemSlotIndex));
return Py_BuildNone();
}
PyObject* shopGetOfflineShopItemPriceReal(PyObject* poSelf, PyObject* poArgs)
{
int bItemWindowType;
if (!PyTuple_GetInteger(poArgs, 0, &bItemWindowType))
return Py_BuildException();
int wItemSlotIndex;
if (!PyTuple_GetInteger(poArgs, 1, &wItemSlotIndex))
return Py_BuildException();
return PyLong_FromLongLong(CPythonShop::Instance().GetOfflineShopItemPrice(TItemPos(bItemWindowType, wItemSlotIndex)));
}
PyObject* shopGetOfflineShopItemGetStatus(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->status);
return Py_BuildValue("i", 0);
}
PyObject* shopGetOfflineShopItemGetBuyerName(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("s", c_pItemData->szBuyerName);
return Py_BuildValue("s", "None");
}
PyObject* shopBuildOfflineShop(PyObject* poSelf, PyObject* poArgs)
{
char* szName;
if (!PyTuple_GetString(poArgs, 0, &szName))
return Py_BuildException();
int szshopVnum;
if (!PyTuple_GetInteger(poArgs, 1, &szshopVnum))
return Py_BuildException();
int szshopTitle;
if (!PyTuple_GetInteger(poArgs, 2, &szshopTitle))
return Py_BuildException();
CPythonShop::Instance().BuildOfflineShop(szName, (DWORD)szshopVnum, szshopTitle);
return Py_BuildNone();
}
PyObject* shopGetDisplayedCount(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonShop::instance().GetShopDisplayedCount());
}
PyObject* shopGetOfflineShopID(PyObject* poSelf, PyObject* poArgs)
{
int iIndex;
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
return Py_BuildException();
const TOfflineShopItemData* c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->owner_id);
return Py_BuildValue("i", 0);
}
PyObject* shopGetCurrentOfflineShopMoney(PyObject* poSelf, PyObject* poArgs)
{
return PyLong_FromLongLong(CPythonShop::instance().GetCurrentOfflineShopMoney());
}
PyObject* shopHasOfflineShop(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonShop::instance().HasOfflineShop());
}
PyObject* shopChangeDecoration(PyObject* poSelf, PyObject* poArgs)
{
char* sign;
if (!PyTuple_GetString(poArgs, 0, &sign))
return Py_BuildException();
int vnum;
if (!PyTuple_GetInteger(poArgs, 1, &vnum))
return Py_BuildException();
int type;
if (!PyTuple_GetInteger(poArgs, 2, &type))
return Py_BuildException();
CPythonNetworkStream::instance().SendOfflineShopChangeDecoration(sign, vnum, type);
return Py_BuildNone();
}
PyObject* shopGetRealWatcherCount(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonShop::instance().GetRealWatcherCount());
}
PyObject* shopGetShopFlag(PyObject* poSelf, PyObject* poArgs)
{
return PyLong_FromUnsignedLongLong(CPythonShop::instance().GetShopFlag());
}
PyObject* shopSetShopFlag(PyObject* poSelf, PyObject* poArgs)
{
long long flag;
if (!PyTuple_GetLongLong(poArgs, 0, &flag))
return Py_BuildException();
CPythonShop::instance().SetShopFlag((unsigned long long)flag);
return Py_BuildNone();
}
PyObject* shopGetShopType(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonShop::instance().GetShopType());
}
PyObject* shopSetShopType(PyObject* poSelf, PyObject* poArgs)
{
int type;
if (!PyTuple_GetInteger(poArgs, 0, &type))
return Py_BuildException();
CPythonShop::instance().SetShopType(type);
return Py_BuildNone();
}
PyObject* shopGetShopTime(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("i", CPythonShop::instance().GetShopTime());
}
PyObject* shopSetShopTime(PyObject* poSelf, PyObject* poArgs)
{
int type;
if (!PyTuple_GetInteger(poArgs, 0, &type))
return Py_BuildException();
CPythonShop::instance().SetShopTime(type);
return Py_BuildNone();
}
#endif
void initshop()
{
static PyMethodDef s_methods[] =
@@ -446,6 +838,36 @@ void initshop()
{ "DelPrivateShopItemStock", shopDelPrivateShopItemStock, METH_VARARGS },
{ "GetPrivateShopItemPrice", shopGetPrivateShopItemPrice, METH_VARARGS },
{ "BuildPrivateShop", shopBuildPrivateShop, METH_VARARGS },
#ifdef ENABLE_OFFLINESHOP_SYSTEM
{ "IsOfflineShop", shopIsOfflineShop, METH_VARARGS },
{ "GetOfflineShopItemID", shopGetOfflineShopItemID, METH_VARARGS },
{ "GetOfflineShopItemCount", shopGetOfflineShopItemCount, METH_VARARGS },
{ "GetOfflineShopItemVnum", shopGetOfflineShopItemVnum, METH_VARARGS },
{ "GetOfflineShopItemPrice", shopGetOfflineShopItemPrice, METH_VARARGS },
{ "GetOfflineShopItemMetinSocket", shopGetOfflineShopItemMetinSocket, METH_VARARGS },
{ "GetOfflineShopItemAttribute", shopGetOfflineShopItemAttribute, METH_VARARGS },
{ "GetSign", shopGetSign, METH_VARARGS },
{ "ClearOfflineShopStock", shopClearOfflineShopStock, METH_VARARGS },
{ "AddOfflineShopItemStock", shopAddOfflineShopItemStock, METH_VARARGS },
{ "DelOfflineShopItemStock", shopDelOfflineShopItemStock, METH_VARARGS },
{ "GetOfflineShopItemPriceReal", shopGetOfflineShopItemPriceReal, METH_VARARGS },
{ "GetOfflineShopItemStatus", shopGetOfflineShopItemGetStatus, METH_VARARGS },
{ "GetOfflineShopItemBuyerName", shopGetOfflineShopItemGetBuyerName, METH_VARARGS },
{ "BuildOfflineShop", shopBuildOfflineShop, METH_VARARGS },
{ "GetDisplayedCount", shopGetDisplayedCount, METH_VARARGS },
{ "GetOfflineShopID", shopGetOfflineShopID, METH_VARARGS },
{ "GetCurrentOfflineShopMoney", shopGetCurrentOfflineShopMoney, METH_VARARGS },
{ "HasOfflineShop", shopHasOfflineShop, METH_VARARGS },
{ "GetRealWatcherCount", shopGetRealWatcherCount, METH_VARARGS },
{ "ChangeDecoration", shopChangeDecoration, METH_VARARGS },
{ "GetShopFlag", shopGetShopFlag, METH_VARARGS },
{ "SetShopFlag", shopSetShopFlag, METH_VARARGS },
{ "GetShopType", shopGetShopType, METH_VARARGS },
{ "SetShopType", shopSetShopType, METH_VARARGS },
{ "GetShopTime", shopGetShopTime, METH_VARARGS },
{ "SetShopTime", shopSetShopTime, METH_VARARGS },
#endif
{ NULL, NULL, NULL },
};
PyObject * poModule = Py_InitModule("shop", s_methods);
@@ -453,4 +875,7 @@ void initshop()
PyModule_AddIntConstant(poModule, "SHOP_SLOT_COUNT", SHOP_HOST_ITEM_MAX_NUM);
PyModule_AddIntConstant(poModule, "SHOP_COIN_TYPE_GOLD", SHOP_COIN_TYPE_GOLD);
PyModule_AddIntConstant(poModule, "SHOP_COIN_TYPE_SECONDARY_COIN", SHOP_COIN_TYPE_SECONDARY_COIN);
#ifdef ENABLE_OFFLINESHOP_SYSTEM
PyModule_AddIntConstant(poModule, "OFFLINE_SHOP_SLOT_COUNT", OFFLINE_SHOP_HOST_ITEM_MAX_NUM);
#endif
}
+56
View File
@@ -58,10 +58,66 @@ class CPythonShop : public CSingleton<CPythonShop>
int GetPrivateShopItemPrice(TItemPos ItemPos);
void BuildPrivateShop(const char * c_szName);
#ifdef ENABLE_OFFLINESHOP_SYSTEM
void SetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData& c_rShopItemData);
BOOL GetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData** c_ppItemData);
void SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData& c_rShopItemData);
BOOL GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData** c_ppItemData);
void SetShopDisplayedCount(DWORD dwDisplayedCount) { m_dwDisplayedCount = dwDisplayedCount; }
void SetShopSign(const char* g_sign) { strcpy(sign, g_sign); }
const char* GetShopSign() { return sign; }
DWORD GetShopDisplayedCount() { return m_dwDisplayedCount; }
BOOL IsOfflineShop() { return m_isOfflineShop; }
void ClearOfflineShopStock() { m_OfflineShopItemStock.clear(); }
void AddOfflineShopItemStock(TItemPos ItemPos, BYTE byDisplayPos, long long dwPrice);
void DelOfflineShopItemStock(TItemPos ItemPos);
long long GetOfflineShopItemPrice(TItemPos ItemPos);
BYTE GetOfflineShopItemStatus(TItemPos ItemPos);
void BuildOfflineShop(const char* c_szName, DWORD shopVnum, BYTE shopTitle);
void SetCurrentOfflineShopMoney(long long llMoney) { m_llCurrentOfflineShopMoney = llMoney; }
long long GetCurrentOfflineShopMoney() { return m_llCurrentOfflineShopMoney; }
bool HasOfflineShop() { return m_bHasOfflineShop; }
void SetHasOfflineShop(bool bStatus) { m_bHasOfflineShop = bStatus; }
DWORD GetRealWatcherCount() { return m_dwRealWatcherCount; }
void SetRealWatcherCount(DWORD p) { m_dwRealWatcherCount = p; }
unsigned long long GetShopFlag() { return m_shopFlag; }
void SetShopFlag(unsigned long long p) { m_shopFlag = p; }
int GetShopTime() { return time; }
void SetShopTime(int a) { time = a; }
DWORD GetShopType() { return type; }
void SetShopType(DWORD a) { type = a; }
#endif
protected:
BOOL CheckSlotIndex(DWORD dwIndex);
protected:
#ifdef ENABLE_OFFLINESHOP_SYSTEM
struct OfflineShopTab
{
TOfflineShopItemData items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
};
DWORD m_dwDisplayedCount;
DWORD m_dwRealWatcherCount;
OfflineShopTab m_aOfflineShoptabs[SHOP_TAB_COUNT_MAX];
std::map<TItemPos, TOfflineShopItemTable> m_OfflineShopItemStock;
BOOL m_isOfflineShop;
char sign[SHOP_SIGN_MAX_LEN + 1];
bool m_bHasOfflineShop;
long long m_llCurrentOfflineShopMoney;
unsigned long long m_shopFlag;
int time;
DWORD type;
#endif
BOOL m_isShoping;
BOOL m_isPrivateShop;
BOOL m_isMainPlayerPrivateShop;
+1
View File
@@ -73,6 +73,7 @@ void initSwitchbot(); // PORT: AVA2 switchbot
void initguild();
void initServerStateChecker();
void initRenderTarget(); // PORT: AVA2 CPythonRenderTargetModule
void initprivateShopSearch(); // PORT: AVA2 private shop search
extern const std::string& ApplicationStringTable_GetString(DWORD dwID);
extern const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey);