|
Отвергнутые патчи Патчи, отвергнутые от приёма в GIT |
|
Опции темы | Поиск в этой теме | Опции просмотра |
21.05.2010, 01:53 | #1 |
Ученый
Регистрация: 17.05.2010
Сообщений: 148
Сказал(а) спасибо: 18
Поблагодарили 25 раз(а) в 22 сообщениях
|
[patch] Vendor
На оффе есть шмотки которые продаются у одног вендора за голд а у другого за баджики или еще за какие штуки.
например http://ru.wowhead.com/item=44128#sold-by и http://ru.wowhead.com/item=36908#sold-by В данной реализации таблици сделать такое невозможно написал маленький патчик. Код:
diff --git a/src/game/Creature.h b/src/game/Creature.h index 3bb0591..38177b0 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -276,13 +276,14 @@ enum AttackingTarget // Vendors struct VendorItem { - VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) - : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {} + VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint8 _UseBuyPrice, uint32 _ExtendedCost) + : item(_item), maxcount(_maxcount), incrtime(_incrtime), UseBuyPrice(_UseBuyPrice), ExtendedCost(_ExtendedCost) {} uint32 item; uint32 maxcount; // 0 for infinity item amount uint32 incrtime; // time for restore items amount if maxcount != 0 - uint32 ExtendedCost; + uint8 UseBuyPrice; + uint32 ExtendedCost; }; typedef std::vector<VendorItem*> VendorItemList; @@ -297,9 +298,9 @@ struct VendorItemData } bool Empty() const { return m_items.empty(); } uint8 GetItemCount() const { return m_items.size(); } - void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) + void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint8 UseBuyPrice, uint32 ExtendedCost) { - m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost)); + m_items.push_back(new VendorItem(item, maxcount, ptime, UseBuyPrice, ExtendedCost)); } bool RemoveItem( uint32 item_id ); VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const; diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 1d04c14..d3bd5b4 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -761,6 +761,7 @@ void WorldSession::SendListInventory(uint64 vendorguid) // reputation discount uint32 price = uint32(floor(pProto->BuyPrice * discountMod)); + if (!crItem->UseBuyPrice) price=0; data << uint32(vendorslot +1); // client size expected counting from 1 data << uint32(crItem->item); diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index ad9682f..7264660 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1128,6 +1128,11 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args) if (fincrtime) incrtime = atol(fincrtime); + char* fUseBuyPrice = strtok(NULL, " "); //add UseBuyPrice, default: 1 + uint8 UseBuyPrice = 1; + if (fUseBuyPrice) + UseBuyPrice = atol(fUseBuyPrice); + char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; @@ -1135,13 +1140,13 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args) uint32 vendor_entry = vendor ? vendor->GetEntry() : 0; - if(!sObjectMgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,extendedcost,m_session->GetPlayer())) + if(!sObjectMgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,UseBuyPrice,extendedcost,m_session->GetPlayer())) { SetSentErrorMessage(true); return false; } - sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); + sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,UseBuyPrice,extendedcost); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 7beae97..4aa7b96 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7988,7 +7988,7 @@ void ObjectMgr::LoadVendors() std::set<uint32> skip_vendors; - QueryResult *result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor"); + QueryResult *result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, UseBuyPrice, ExtendedCost FROM npc_vendor"); if( !result ) { barGoLink bar( 1 ); @@ -8012,14 +8012,15 @@ void ObjectMgr::LoadVendors() uint32 item_id = fields[1].GetUInt32(); uint32 maxcount = fields[2].GetUInt32(); uint32 incrtime = fields[3].GetUInt32(); - uint32 ExtendedCost = fields[4].GetUInt32(); - - if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors)) + uint8 UseBuyPrice = fields[4].GetUInt8(); + uint32 ExtendedCost = fields[5].GetUInt32(); + + if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,UseBuyPrice,ExtendedCost,NULL,&skip_vendors)) continue; VendorItemData& vList = m_mCacheVendorItemMap[entry]; - vList.AddItem(item_id,maxcount,incrtime,ExtendedCost); + vList.AddItem(item_id,maxcount,incrtime,UseBuyPrice,ExtendedCost); ++count; } while (result->NextRow()); @@ -8290,10 +8291,10 @@ void ObjectMgr::LoadGossipMenuItems() sLog.outString(">> Loaded %u gossip_menu_option entries", count); } -void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost ) +void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime,uint8 UseBuyPrice, uint32 extendedcost ) { VendorItemData& vList = m_mCacheVendorItemMap[entry]; - vList.AddItem(item,maxcount,incrtime,extendedcost); + vList.AddItem(item,maxcount,incrtime,UseBuyPrice,extendedcost); WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost); } @@ -8311,7 +8312,7 @@ bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item ) return true; } -bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors ) const +bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint8 UseBuyPrice, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors ) const { CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry); if(!cInfo) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index d1819a7..331a282 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -863,9 +863,9 @@ class ObjectMgr return &iter->second; } - void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost); + void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint8 UseBuyPrice, uint32 ExtendedCost); bool RemoveVendorItem(uint32 entry,uint32 item); - bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const; + bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint8 UseBuyPrice, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const; void LoadScriptNames(); ScriptNameMap &GetScriptNames() { return m_scriptNames; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 55fee16..4d135bc 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -18469,12 +18469,12 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 return false; } } - + uint32 price = pProto->BuyPrice * count; // reputation discount price = uint32(floor(price * GetReputationPriceDiscount(pCreature))); - + if (!crItem->UseBuyPrice) price=0; if (GetMoney() < price) { SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0); PHP код:
ЗЫ может лучше тупо запихнуть цену шмотки в таблицу npc_vendor? |
|
|
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
[mod]Title Vendor | Kirito | Скрипты | 2 | 31.10.2013 16:28 |
[10905] Fixed vendor templates work. | newsbot | CMaNGOS Commits | 0 | 21.12.2010 19:54 |
[10685] Fixed creature_template loading after vendor changes. | newsbot | CMaNGOS Commits | 0 | 05.11.2010 21:10 |
[9786] Fixed crash at drop vendor items (anorther way). | newsbot | CMaNGOS Commits | 0 | 24.04.2010 02:20 |
[9716] Allow to vendor have same items in list with different extanded price. | newsbot | CMaNGOS Commits | 0 | 10.04.2010 04:50 |