Advertisement
Guest User

offline_shop.cpp

a guest
Sep 8th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.53 KB | None | 0 0
  1. /*
  2. * Filename : offline_shop.cpp
  3. * Version : 0.1
  4. * Description : --
  5. */
  6.  
  7. #include "stdafx.h"
  8. #include "../../libgame/include/grid.h"
  9. #include "constants.h"
  10. #include "utils.h"
  11. #include "config.h"
  12. #include "desc.h"
  13. #include "desc_manager.h"
  14. #include "char.h"
  15. #include "char_manager.h"
  16. #include "item.h"
  17. #include "item_manager.h"
  18. #include "buffer_manager.h"
  19. #include "packet.h"
  20. #include "log.h"
  21. #include "db.h"
  22. #include "questmanager.h"
  23. #include "monarch.h"
  24. #include "mob_manager.h"
  25. #include "locale_service.h"
  26. #include "offline_shop.h"
  27. #include "p2p.h"
  28.  
  29.  
  30. COfflineShop::COfflineShop() : m_pkOfflineShopNPC(NULL)
  31. {
  32. m_pGrid = M2_NEW CGrid(12, 10);
  33. }
  34.  
  35.  
  36. COfflineShop::~COfflineShop()
  37. {
  38. TPacketGCShop pack;
  39. pack.header = HEADER_GC_OFFLINE_SHOP;
  40. pack.subheader = SHOP_SUBHEADER_GC_END;
  41. pack.size = sizeof(TPacketGCShop);
  42.  
  43. Broadcast(&pack, sizeof(pack));
  44.  
  45. for (GuestMapType::iterator it = m_map_guest.begin(); it != m_map_guest.end(); ++it)
  46. {
  47. LPCHARACTER ch = it->first;
  48. ch->SetOfflineShop(NULL);
  49. }
  50.  
  51. M2_DELETE(m_pGrid);
  52. }
  53.  
  54. void COfflineShop::SetOfflineShopNPC(LPCHARACTER npc)
  55. {
  56. m_pkOfflineShopNPC = npc;
  57. }
  58.  
  59. bool COfflineShop::AddGuest(LPCHARACTER ch, LPCHARACTER npc)
  60. {
  61. // If there is no ch, return false
  62. if (!ch)
  63. return false;
  64.  
  65. // If ch is exchanging, return false
  66. if (ch->GetExchange())
  67. return false;
  68.  
  69. // If target is shopping, return false
  70. if (ch->GetShop())
  71. return false;
  72.  
  73. // If target is look at private shop, return false
  74. if (ch->GetMyShop())
  75. return false;
  76.  
  77. // If target is look at offline shop, return false
  78. if (ch->GetOfflineShop())
  79. return false;
  80.  
  81. // Start process
  82. ch->SetOfflineShop(this);
  83. m_map_guest.insert(GuestMapType::value_type(ch, false));
  84.  
  85. TPacketGCShop pack;
  86. pack.header = HEADER_GC_OFFLINE_SHOP;
  87. pack.subheader = SHOP_SUBHEADER_GC_START;
  88.  
  89. TPacketGCOfflineShopStart pack2;
  90. memset(&pack2, 0, sizeof(pack2));
  91. pack2.owner_vid = npc->GetVID();
  92.  
  93. std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT pos,count,vnum,price,price_cheque,socket0,socket1,socket2, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3, applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7 FROM offline_shop_item%s WHERE owner_id = %u", get_table_postfix(), npc ? npc->GetOfflineShopRealOwner() : 0));
  94. if (pMsg->Get()->uiNumRows == 0)
  95. {
  96. DBManager::instance().DirectQuery("DELETE FROM player.offline_shop_npc WHERE owner_id = %u", npc->GetOfflineShopRealOwner());
  97. ch->SetOfflineShop(NULL);
  98. ch->SetOfflineShopOwner(NULL);
  99. M2_DESTROY_CHARACTER(npc);
  100. return false;
  101. }
  102.  
  103. MYSQL_ROW row;
  104. while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
  105. {
  106. BYTE bPos = 0;
  107. str_to_number(bPos, row[0]);
  108.  
  109. str_to_number(pack2.items[bPos].count, row[1]);
  110. str_to_number(pack2.items[bPos].vnum, row[2]);
  111. str_to_number(pack2.items[bPos].price, row[3]);
  112. str_to_number(pack2.items[bPos].price_cheque, row[4]);
  113.  
  114. DWORD alSockets[ITEM_SOCKET_MAX_NUM];
  115. for (int i = 0, n = 4; i < ITEM_SOCKET_MAX_NUM; ++i, n++)
  116. str_to_number(alSockets[i], row[n]);
  117.  
  118. TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
  119. for (int i = 0, iStartType = 7, iStartValue = 8; i < ITEM_ATTRIBUTE_MAX_NUM; ++i, iStartType += 2, iStartValue += 2)
  120. {
  121. str_to_number(aAttr[i].bType, row[iStartType]);
  122. str_to_number(aAttr[i].sValue, row[iStartValue]);
  123. }
  124.  
  125. thecore_memcpy(pack2.items[bPos].alSockets, alSockets, sizeof(pack2.items[bPos].alSockets));
  126. thecore_memcpy(pack2.items[bPos].aAttr, aAttr, sizeof(pack2.items[bPos].aAttr));
  127. }
  128.  
  129. pack.size = sizeof(pack) + sizeof(pack2);
  130. ch->GetDesc()->BufferedPacket(&pack, sizeof(TPacketGCShop));
  131. ch->GetDesc()->Packet(&pack2, sizeof(TPacketGCOfflineShopStart));
  132. return true;
  133. }
  134.  
  135. void COfflineShop::RemoveGuest(LPCHARACTER ch)
  136. {
  137. // If this offline shop is not equal to this, break it
  138. if (ch->GetOfflineShop() != this)
  139. return;
  140.  
  141. m_map_guest.erase(ch);
  142. ch->SetOfflineShop(NULL);
  143.  
  144. TPacketGCShop pack;
  145. pack.header = HEADER_GC_OFFLINE_SHOP;
  146. pack.subheader = SHOP_SUBHEADER_GC_END;
  147. pack.size = sizeof(TPacketGCShop);
  148.  
  149. ch->GetDesc()->Packet(&pack, sizeof(pack));
  150. }
  151.  
  152. void COfflineShop::RemoveAllGuest()
  153. {
  154. TPacketGCShop pack;
  155. pack.header = HEADER_GC_OFFLINE_SHOP;
  156. pack.subheader = SHOP_SUBHEADER_GC_END;
  157. pack.size = sizeof(TPacketGCShop);
  158.  
  159. Broadcast(&pack, sizeof(pack));
  160.  
  161. for (GuestMapType::iterator it = m_map_guest.begin(); it != m_map_guest.end(); ++it)
  162. {
  163. LPCHARACTER ch = it->first;
  164. ch->SetOfflineShop(NULL);
  165. }
  166. }
  167.  
  168. void COfflineShop::Destroy(LPCHARACTER npc)
  169. {
  170. DBManager::instance().DirectQuery("DELETE FROM %soffline_shop_npc WHERE owner_id = %u", get_table_postfix(), npc->GetOfflineShopRealOwner());
  171. RemoveAllGuest();
  172. M2_DESTROY_CHARACTER(npc);
  173. }
  174.  
  175. int COfflineShop::Buy(LPCHARACTER ch, BYTE bPos)
  176. {
  177. if (ch->GetOfflineShopOwner()->GetOfflineShopRealOwner() == ch->GetPlayerID())
  178. {
  179. ch->ChatPacket(CHAT_TYPE_INFO, "satin alamazsin.");
  180. return SHOP_SUBHEADER_GC_OK;
  181. }
  182.  
  183. if (bPos >= OFFLINE_SHOP_HOST_ITEM_MAX_NUM)
  184. {
  185. sys_log(0, "OfflineShop::Buy : gecersiz pozisyon %d : %s", bPos, ch->GetName());
  186. return SHOP_SUBHEADER_GC_INVALID_POS;
  187. }
  188.  
  189. sys_log(0, "OfflineShop::Buy : isim %s pos %d", ch->GetName(), bPos);
  190.  
  191. GuestMapType::iterator it = m_map_guest.find(ch);
  192. if (it == m_map_guest.end())
  193. return SHOP_SUBHEADER_GC_END;
  194.  
  195. char szQuery[1024];
  196. snprintf(szQuery, sizeof(szQuery), "SELECT pos,count,vnum,price,price_cheque,socket0,socket1,socket2, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3, applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7 FROM offline_shop_item%s WHERE owner_id = %u and pos = %d", get_table_postfix(), ch->GetOfflineShopOwner()->GetOfflineShopRealOwner(), bPos);
  197. std::auto_ptr<SQLMsg> pMsg(DBManager::Instance().DirectQuery(szQuery));
  198.  
  199. MYSQL_ROW row;
  200.  
  201. DWORD dwPrice = 0;
  202. DWORD dwPriceCheque = 0;
  203. DWORD dwItemVnum = 0;
  204. BYTE bCount = 0;
  205. DWORD alSockets[ITEM_SOCKET_MAX_NUM];
  206. TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
  207.  
  208. while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
  209. {
  210. str_to_number(bCount, row[1]);
  211. str_to_number(dwItemVnum, row[2]);
  212. str_to_number(dwPrice, row[3]);
  213. str_to_number(dwPriceCheque, row[4]);
  214.  
  215. // Set Sockets
  216. for (int i = 0, n = 4; i < ITEM_SOCKET_MAX_NUM; ++i, n++)
  217. str_to_number(alSockets[i], row[n]);
  218. // End Of Sockets
  219.  
  220. // Set Attributes
  221. for (int i = 0, iStartAttributeType = 7, iStartAttributeValue = 8; i < ITEM_ATTRIBUTE_MAX_NUM; ++i, iStartAttributeType += 2, iStartAttributeValue += 2)
  222. {
  223. str_to_number(aAttr[i].bType, row[iStartAttributeType]);
  224. str_to_number(aAttr[i].sValue, row[iStartAttributeValue]);
  225. }
  226. // End Of Set Attributes
  227. }
  228.  
  229. // Brazil server is not use gold option.
  230. if (!LC_IsBrazil())
  231. {
  232. if (ch->GetGold() < (int) dwPrice && ch->GetCheque() >= (int) dwPriceCheque)
  233. {
  234. sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
  235. return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
  236. }
  237.  
  238. if (ch->GetCheque() < (int) dwPriceCheque && ch->GetGold() >= (int) dwPrice)
  239. {
  240. sys_log(1, "Shop::Buy : Not enough won : %s has %d, price_cheque %d", ch->GetName(), ch->GetCheque(), dwPriceCheque);
  241. return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE;
  242. }
  243.  
  244. if (ch->GetGold() < (int) dwPrice && ch->GetCheque() < (int) dwPriceCheque)
  245. {
  246. sys_log(1, "Shop::Buy : Not enough won_money : %s has %d and %d, price %d and price_cheque %d", ch->GetName(), ch->GetGold(), ch->GetCheque(), dwPrice, dwPriceCheque);
  247. return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE_MONEY;
  248. }
  249. }
  250. else
  251. {
  252. int iItemCount = quest::CQuestManager::instance().GetCurrentCharacterPtr()->CountSpecifyItem(30183);
  253. if (iItemCount < static_cast<int>(dwPrice))
  254. {
  255. sys_log(1, "OfflineShop::Buy : Yetersiz : %s has %d, gold mask %u", ch->GetName(), iItemCount, dwPrice);
  256. return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
  257. }
  258. }
  259.  
  260. LPITEM pItem = ITEM_MANAGER::Instance().CreateItem(dwItemVnum, bCount);
  261. if (!pItem)
  262. return SHOP_SUBHEADER_GC_SOLD_OUT;
  263.  
  264. // Set Attributes, Sockets
  265. pItem->SetAttributes(aAttr);
  266. for (BYTE i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  267. pItem->SetSocket(i, alSockets[i]);
  268. // End Of Set Attributes, Sockets
  269.  
  270. // If item is a dragon soul item or normal item
  271. int iEmptyPos = 0;
  272. if (pItem->IsDragonSoul())
  273. iEmptyPos = ch->GetEmptyDragonSoulInventory(pItem);
  274. else
  275. iEmptyPos = ch->GetEmptyInventory(pItem->GetSize());
  276.  
  277. // If iEmptyPos is less than 0, return inventory is full
  278. if (iEmptyPos < 0)
  279. return SHOP_SUBHEADER_GC_INVENTORY_FULL;
  280.  
  281. // If item is a dragon soul, add this item in dragon soul inventory
  282. if (pItem->IsDragonSoul())
  283. pItem->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos));
  284. else
  285. pItem->AddToCharacter(ch, TItemPos(INVENTORY,iEmptyPos));
  286.  
  287. if (pItem)
  288. sys_log(0, "OFFLINE_SHOP: BUY: name %s %s(x %u):%u price %u", ch->GetName(), pItem->GetName(), pItem->GetCount(), pItem->GetID(), dwPrice);
  289.  
  290.  
  291. // Check if the player is online
  292. LPCHARACTER tch = CHARACTER_MANAGER::instance().FindByPID(ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
  293. if (!LC_IsBrazil())
  294. {
  295.  
  296. if (tch)
  297. {
  298. tch->PointChange(POINT_GOLD, dwPrice, false);
  299. tch->PointChange(POINT_CHEQUE, dwPriceCheque, false);
  300. }
  301. else
  302. DBManager::instance().DirectQuery("UPDATE player%s SET shop_gold = shop_gold + %u, shop_cheque = shop_cheque + %u WHERE id = %u", get_table_postfix(), dwPrice, dwPriceCheque, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
  303.  
  304. if (tch)
  305. {
  306. bool bIsOverFlow = tch->GetGold() + dwPrice > GOLD_MAX - 1 ? true : false;
  307. if (bIsOverFlow)
  308. DBManager::instance().DirectQuery("UPDATE player%s SET shop_gold = shop_gold + %u WHERE id = %u", get_table_postfix(), dwPrice, tch->GetPlayerID());
  309. else
  310. tch->PointChange(POINT_GOLD, dwPrice, false);
  311. }
  312. else
  313. DBManager::instance().DirectQuery("UPDATE player%s SET shop_gold = shop_gold + %u WHERE id = %u", get_table_postfix(), dwPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
  314. }
  315.  
  316. RemoveItem(ch->GetOfflineShopOwner()->GetOfflineShopRealOwner(), bPos);
  317. BroadcastUpdateItem(bPos, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner(), true);
  318. ch->PointChange(POINT_GOLD, -dwPrice, false);
  319. ch->PointChange(POINT_CHEQUE, -dwPriceCheque, false);
  320. ch->Save();
  321. LogManager::instance().ItemLog(ch, pItem, "BUY ITEM FROM OFFLINE SHOP", "");
  322.  
  323. BYTE bLeftItemCount = GetLeftItemCount(ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
  324. if (bLeftItemCount == 0)
  325. Destroy(ch->GetOfflineShopOwner());
  326.  
  327. return (SHOP_SUBHEADER_GC_OK);
  328. }
  329.  
  330. void COfflineShop::BroadcastUpdateItem(BYTE bPos, DWORD dwPID, bool bDestroy)
  331. {
  332. TPacketGCShop pack;
  333. TPacketGCShopUpdateItem pack2;
  334.  
  335. TEMP_BUFFER buf;
  336.  
  337. pack.header = HEADER_GC_OFFLINE_SHOP;
  338. pack.subheader = SHOP_SUBHEADER_GC_UPDATE_ITEM;
  339. pack.size = sizeof(pack) + sizeof(pack2);
  340. pack2.pos = bPos;
  341.  
  342. if (bDestroy)
  343. {
  344. pack2.item.vnum = 0;
  345. pack2.item.count = 0;
  346. pack2.item.price = 0;
  347. pack2.item.price_cheque = 0;
  348. memset(pack2.item.alSockets, 0, sizeof(pack2.item.alSockets));
  349. memset(pack2.item.aAttr, 0, sizeof(pack2.item.aAttr));
  350. }
  351. else
  352. {
  353. char szQuery[1024];
  354. snprintf(szQuery, sizeof(szQuery), "SELECT pos,count,vnum,price,price_cheque,socket0,socket1,socket2, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3, applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7 FROM offline_shop_item%s WHERE owner_id = %u and pos = %d", get_table_postfix(), dwPID, bPos);
  355. std::auto_ptr<SQLMsg> pMsg(DBManager::Instance().DirectQuery(szQuery));
  356. MYSQL_ROW row;
  357. while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
  358. {
  359. str_to_number(pack2.item.count, row[1]);
  360. str_to_number(pack2.item.vnum, row[2]);
  361. str_to_number(pack2.item.price, row[3]);
  362. str_to_number(pack2.item.price_cheque, row[4]);
  363.  
  364. // Set Sockets
  365. for (int i = 0, n = 4; i < ITEM_SOCKET_MAX_NUM; ++i, n++)
  366. str_to_number(pack2.item.alSockets[i], row[n]);
  367. // End Of Sockets
  368.  
  369. // Set Attributes
  370. for (int i = 0, iStartAttributeType = 7, iStartAttributeValue = 8; i < ITEM_ATTRIBUTE_MAX_NUM; ++i, iStartAttributeType += 2, iStartAttributeValue += 2)
  371. {
  372. str_to_number(pack2.item.aAttr[i].bType, row[iStartAttributeType]);
  373. str_to_number(pack2.item.aAttr[i].sValue, row[iStartAttributeValue]);
  374. }
  375. // End Of Set Attributes
  376. }
  377. }
  378.  
  379. buf.write(&pack, sizeof(pack));
  380. buf.write(&pack2, sizeof(pack2));
  381. Broadcast(buf.read_peek(), buf.size());
  382. }
  383.  
  384. void COfflineShop::BroadcastUpdatePrice(BYTE bPos, DWORD dwPrice, DWORD dwPriceCheque)
  385. {
  386. TPacketGCShop pack;
  387. TPacketGCShopUpdatePrice pack2;
  388.  
  389. TEMP_BUFFER buf;
  390.  
  391. pack.header = HEADER_GC_OFFLINE_SHOP;
  392. pack.subheader = SHOP_SUBHEADER_GC_UPDATE_PRICE;
  393. pack.size = sizeof(pack) + sizeof(pack2);
  394.  
  395. pack2.bPos = bPos;
  396. pack2.iPrice = dwPrice;
  397. pack2.iPriceCheque = dwPriceCheque;
  398.  
  399. buf.write(&pack, sizeof(pack));
  400. buf.write(&pack2, sizeof(pack2));
  401.  
  402. Broadcast(buf.read_peek(), buf.size());
  403. }
  404.  
  405. void COfflineShop::Refresh(LPCHARACTER ch)
  406. {
  407. TPacketGCShop pack;
  408. pack.header = HEADER_GC_OFFLINE_SHOP;
  409. pack.subheader = SHOP_SUBHEADER_GC_UPDATE_ITEM2;
  410.  
  411. TPacketGCOfflineShopStart pack2;
  412. memset(&pack2, 0, sizeof(pack2));
  413. pack2.owner_vid = 0;
  414.  
  415. std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT pos,count,vnum,price,price_cheque,socket0,socket1,socket2, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3, applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7 FROM offline_shop_item%s WHERE owner_id = %u", get_table_postfix(), ch->GetPlayerID()));
  416.  
  417. MYSQL_ROW row;
  418. while (NULL != (row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
  419. {
  420. BYTE bPos = 0;
  421. str_to_number(bPos, row[0]);
  422.  
  423. str_to_number(pack2.items[bPos].count, row[1]);
  424. str_to_number(pack2.items[bPos].vnum, row[2]);
  425. str_to_number(pack2.items[bPos].price, row[3]);
  426. str_to_number(pack2.items[bPos].price_cheque, row[4]);
  427.  
  428. DWORD alSockets[ITEM_SOCKET_MAX_NUM];
  429. for (int i = 0, n = 4; i < ITEM_SOCKET_MAX_NUM; ++i, n++)
  430. str_to_number(alSockets[i], row[n]);
  431.  
  432. TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
  433. for (int i = 0, iStartType = 7, iStartValue = 8; i < ITEM_ATTRIBUTE_MAX_NUM; ++i, iStartType += 2, iStartValue += 2)
  434. {
  435. str_to_number(aAttr[i].bType, row[iStartType]);
  436. str_to_number(aAttr[i].sValue, row[iStartValue]);
  437. }
  438.  
  439. thecore_memcpy(pack2.items[bPos].alSockets, alSockets, sizeof(pack2.items[bPos].alSockets));
  440. thecore_memcpy(pack2.items[bPos].aAttr, aAttr, sizeof(pack2.items[bPos].aAttr));
  441. }
  442.  
  443. pack.size = sizeof(pack) + sizeof(pack2);
  444. ch->GetDesc()->BufferedPacket(&pack, sizeof(TPacketGCShop));
  445. ch->GetDesc()->Packet(&pack2, sizeof(TPacketGCOfflineShopStart));
  446. }
  447.  
  448. bool COfflineShop::RemoveItem(DWORD dwVID, BYTE bPos)
  449. {
  450. std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("DELETE FROM %soffline_shop_item WHERE owner_id = %u and pos = %d", get_table_postfix(), dwVID, bPos));
  451. return pMsg->Get()->uiAffectedRows > 0;
  452. }
  453.  
  454. BYTE COfflineShop::GetLeftItemCount(DWORD dwPID)
  455. {
  456. std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM %soffline_shop_item WHERE owner_id = %u and status = 0", get_table_postfix(), dwPID));
  457. if (pMsg->Get()->uiNumRows == 0)
  458. return 0;
  459.  
  460. MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult);
  461. BYTE bCount = 0;
  462. str_to_number(bCount, row[0]);
  463. return bCount;
  464. }
  465.  
  466. void COfflineShop::Broadcast(const void * data, int bytes)
  467. {
  468. sys_log(1, "OfflineShop::Broadcast %p %d", data, bytes);
  469.  
  470. for (GuestMapType::iterator it = m_map_guest.begin(); it != m_map_guest.end(); ++it)
  471. {
  472. LPCHARACTER ch = it->first;
  473. if (ch->GetDesc())
  474. ch->GetDesc()->Packet(data, bytes);
  475. }
  476. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement