Advertisement
Guest User

PythonShop.cpp

a guest
May 28th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.13 KB | None | 0 0
  1. [..]
  2. //find function CPythonShop::BuildPrivateShop and replace with this
  3. #ifdef ENABLE_OFFLINE_SHOP
  4. void CPythonShop::BuildPrivateShop(const char * c_szName,DWORD days)
  5. #else
  6. void CPythonShop::BuildPrivateShop(const char * c_szName)
  7. #endif
  8. {
  9.     std::vector<TShopItemTable> ItemStock;
  10.     ItemStock.reserve(m_PrivateShopItemStock.size());
  11.  
  12.     TPrivateShopItemStock::iterator itor = m_PrivateShopItemStock.begin();
  13.     for (; itor != m_PrivateShopItemStock.end(); ++itor)
  14.     {
  15.         ItemStock.push_back(itor->second);
  16.     }
  17.  
  18.     std::sort(ItemStock.begin(), ItemStock.end(), ItemStockSortFunc());
  19.     #ifdef ENABLE_OFFLINE_SHOP
  20.     CPythonNetworkStream::Instance().SendBuildPrivateShopPacket(c_szName, ItemStock,days);
  21.     #else
  22.     CPythonNetworkStream::Instance().SendBuildPrivateShopPacket(c_szName, ItemStock);
  23.     #endif
  24. }
  25.  
  26. //find function AddPrivateShopItemStock and replace
  27. #ifdef ENABLE_FULL_YANG
  28. void CPythonShop::AddPrivateShopItemStock(TItemPos ItemPos, BYTE dwDisplayPos, long long dwPrice)
  29. #else
  30. void CPythonShop::AddPrivateShopItemStock(TItemPos ItemPos, BYTE dwDisplayPos, DWORD dwPrice)
  31. #endif
  32. {
  33.     DelPrivateShopItemStock(ItemPos);
  34.  
  35.     TShopItemTable SellingItem;
  36.     SellingItem.vnum = 0;
  37.     SellingItem.count = 0;
  38.     SellingItem.pos = ItemPos;
  39.     SellingItem.price = dwPrice;
  40.     SellingItem.display_pos = dwDisplayPos;
  41.     m_PrivateShopItemStock.insert(make_pair(ItemPos, SellingItem));
  42. }
  43.  
  44.  
  45. //find function GetPrivateShopItemPrice and replace
  46. #ifdef ENABLE_FULL_YANG
  47. long long CPythonShop::GetPrivateShopItemPrice(TItemPos ItemPos)
  48. #else
  49. int CPythonShop::GetPrivateShopItemPrice(TItemPos ItemPos)
  50. #endif
  51. {
  52.     TPrivateShopItemStock::iterator itor = m_PrivateShopItemStock.find(ItemPos);
  53.  
  54.     if (m_PrivateShopItemStock.end() == itor)
  55.         return 0;
  56.  
  57.     TShopItemTable & rShopItemTable = itor->second;
  58.     return rShopItemTable.price;
  59. }
  60. //find shopBuildPrivateShop and replace
  61. PyObject * shopBuildPrivateShop(PyObject * poSelf, PyObject * poArgs)
  62. {
  63.     char * szName;
  64.     if (!PyTuple_GetString(poArgs, 0, &szName))
  65.         return Py_BuildException();
  66.     #ifdef ENABLE_OFFLINE_SHOP
  67.     int days;
  68.     if (!PyTuple_GetInteger(poArgs, 1, &days))
  69.         return Py_BuildException();
  70.     CPythonShop::Instance().BuildPrivateShop(szName,days);
  71.     #else
  72.     CPythonShop::Instance().BuildPrivateShop(szName);
  73.     #endif
  74.     return Py_BuildNone();
  75. }
  76.  
  77. PyObject * shopGetItemPrice(PyObject * poSelf, PyObject * poArgs)
  78. {
  79.     int iIndex;
  80.     if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
  81.         return Py_BuildException();
  82.  
  83.     const TShopItemData * c_pItemData;
  84.     if (CPythonShop::Instance().GetItemData(iIndex, &c_pItemData))
  85. #ifdef ENABLE_FULL_YANG
  86.         return Py_BuildValue("L", c_pItemData->price);
  87. #else
  88.         return Py_BuildValue("i", c_pItemData->price);
  89. #endif
  90.  
  91.     return Py_BuildValue("i", 0);
  92. }
  93. PyObject * shopGetPrivateShopItemPrice(PyObject * poSelf, PyObject * poArgs)
  94. {
  95.     BYTE bItemWindowType;
  96.     if (!PyTuple_GetInteger(poArgs, 0, &bItemWindowType))
  97.         return Py_BuildException();
  98.     WORD wItemSlotIndex;
  99.     if (!PyTuple_GetInteger(poArgs, 1, &wItemSlotIndex))
  100.         return Py_BuildException();
  101. #ifdef ENABLE_FULL_YANG
  102.     return Py_BuildValue("L", CPythonShop::Instance().GetPrivateShopItemPrice(TItemPos(bItemWindowType, wItemSlotIndex)));
  103. #else
  104.     return Py_BuildValue("i", CPythonShop::Instance().GetPrivateShopItemPrice(TItemPos(bItemWindowType, wItemSlotIndex)));
  105. #endif
  106.  
  107.     return Py_BuildValue("i", 0);
  108. }
  109. PyObject * shopAddPrivateShopItemStock(PyObject * poSelf, PyObject * poArgs)
  110. {
  111.     BYTE bItemWindowType;
  112.     if (!PyTuple_GetInteger(poArgs, 0, &bItemWindowType))
  113.         return Py_BuildException();
  114.     WORD wItemSlotIndex;
  115.     if (!PyTuple_GetInteger(poArgs, 1, &wItemSlotIndex))
  116.         return Py_BuildException();
  117.     int iDisplaySlotIndex;
  118.     if (!PyTuple_GetInteger(poArgs, 2, &iDisplaySlotIndex))
  119.         return Py_BuildException();
  120.  
  121. #ifdef ENABLE_FULL_YANG
  122.     PyObject* val;
  123.     if (!PyTuple_GetObject(poArgs, 3, &val))
  124.         return Py_BuildException();
  125.     long long iPrice = PyLong_AsLongLong(val);
  126. #else
  127.     int iPrice;
  128.     if (!PyTuple_GetInteger(poArgs, 3, &iPrice))
  129.         return Py_BuildException();
  130. #endif
  131.  
  132.     CPythonShop::Instance().AddPrivateShopItemStock(TItemPos(bItemWindowType, wItemSlotIndex), iDisplaySlotIndex, iPrice);
  133.  
  134.     return Py_BuildNone();
  135. }
  136. [..]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement