Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int CShop::Buy(LPCHARACTER ch, BYTE pos)
- {
- if (pos >= m_itemVector.size())
- {
- sys_log(0, "Shop::Buy : invalid position %d : %s", pos, ch->GetName());
- return SHOP_SUBHEADER_GC_INVALID_POS;
- }
- sys_log(0, "Shop::Buy : name %s pos %d", ch->GetName(), pos);
- GuestMapType::iterator it = m_map_guest.find(ch);
- if (it == m_map_guest.end())
- return SHOP_SUBHEADER_GC_END;
- SHOP_ITEM& r_item = m_itemVector[pos];
- #ifdef ENABLE_CHEQUE_SYSTEM
- if (r_item.price < 0 && r_item.cheque_price < 0)
- #else
- if (r_item.price < 0)
- #endif
- {
- LogManager::instance().HackLog("SHOP_BUY_GOLD_OVERFLOW", ch);
- return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
- }
- LPITEM pkSelectedItem = ITEM_MANAGER::instance().Find(r_item.itemid);
- if (IsPCShop())
- {
- if (!pkSelectedItem)
- {
- sys_log(0, "Shop::Buy : Critical: This user seems to be a hacker : invalid pcshop item : BuyerPID:%d SellerPID:%d",
- ch->GetPlayerID(),
- m_pkPC->GetPlayerID());
- return SHOP_SUBHEADER_GC_SOLD_OUT;
- }
- if ((pkSelectedItem->GetOwner() != m_pkPC))
- {
- sys_log(0, "Shop::Buy : Critical: This user seems to be a hacker : invalid pcshop item : BuyerPID:%d SellerPID:%d",
- ch->GetPlayerID(),
- m_pkPC->GetPlayerID());
- return SHOP_SUBHEADER_GC_SOLD_OUT;
- }
- }
- DWORD dwPrice = r_item.price;
- #ifdef ENABLE_MULTISHOP
- DWORD dwWItemVnum = r_item.wPriceVnum;
- DWORD dwWItemPrice = r_item.wPrice;
- #endif
- #ifdef ENABLE_CHEQUE_SYSTEM
- BYTE byChequePrice = r_item.cheque_price;
- #endif
- //if (it->second) // if other empire, price is triple
- //dwPrice *= 3;
- if (ch->GetGold() < (int) dwPrice)
- {
- sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
- return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
- }
- #ifdef ENABLE_MULTISHOP
- if (dwWItemVnum > 0)
- {
- if (ch->CountSpecifyItem(dwWItemVnum) < (int)dwWItemPrice)
- return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
- }
- else if (ch->GetGold() < (int) dwPrice)
- #else
- if (ch->GetGold() < (int) dwPrice)
- #endif
- #ifdef ENABLE_CHEQUE_SYSTEM
- if (ch->GetCheque() < byChequePrice)
- {
- sys_log(1, "Shop::Buy : Not enough cheque : %s has %d, price %d", ch->GetName(), ch->GetCheque(), byChequePrice);
- return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE;
- }
- #endif
- LPITEM item;
- if (m_pkPC) // ÇǾ¾°¡ ¿î¿µÇÏ´Â ¼¥Àº ÇǾ¾°¡ ½ÇÁ¦ ¾ÆÀÌÅÛÀ» °¡Áö°íÀÖ¾î¾ß ÇÑ´Ù.
- item = r_item.pkItem;
- else
- item = ITEM_MANAGER::instance().CreateItem(r_item.vnum, r_item.count);
- if (!item)
- return SHOP_SUBHEADER_GC_SOLD_OUT;
- if (!m_pkPC)
- {
- /*if (quest::CQuestManager::instance().GetEventFlag("hivalue_item_sell") == 0)
- {
- //ÃູÀÇ ±¸½½ && ¸¸³âÇÑö À̺¥Æ®
- if (item->GetVnum() == 70024 || item->GetVnum() == 70035)
- {
- return SHOP_SUBHEADER_GC_END;
- }
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment