[10207] Implement ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD use instead sign of ExtendedCost field.

This commit is contained in:
VladimirMangos 2010-07-17 19:12:16 +04:00
parent 9882bc811f
commit 20a5551739
13 changed files with 42 additions and 35 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_10205_01_mangos_spell_area` bit(1) default NULL
`required_10207_01_mangos_npc_vendor` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -3921,7 +3921,7 @@ CREATE TABLE `npc_vendor` (
`item` mediumint(8) unsigned NOT NULL default '0',
`maxcount` tinyint(3) unsigned NOT NULL default '0',
`incrtime` int(10) unsigned NOT NULL default '0',
`ExtendedCost` mediumint(8) NOT NULL default '0' COMMENT 'negative if cost must exclude normal money cost',
`ExtendedCost` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`entry`,`item`,`ExtendedCost`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Npc System';

View file

@ -0,0 +1,7 @@
ALTER TABLE db_version CHANGE COLUMN required_10205_01_mangos_spell_area required_10207_01_mangos_npc_vendor bit;
UPDATE npc_vendor
SET ExtendedCost = abs(ExtendedCost) WHERE ExtendedCost < 0;
ALTER TABLE npc_vendor
CHANGE COLUMN `ExtendedCost` `ExtendedCost` mediumint(8) unsigned NOT NULL default '0';

View file

@ -109,6 +109,7 @@ pkgdata_DATA = \
10197_01_mangos_playercreateinfo.sql \
10203_01_mangos_item_template.sql \
10205_01_mangos_spell_area.sql \
10207_01_mangos_npc_vendor.sql \
README
## Additional files to include when running 'make dist'
@ -198,4 +199,5 @@ EXTRA_DIST = \
10197_01_mangos_playercreateinfo.sql \
10203_01_mangos_item_template.sql \
10205_01_mangos_spell_area.sql \
10207_01_mangos_npc_vendor.sql \
README

View file

@ -74,7 +74,7 @@ bool VendorItemData::RemoveItem( uint32 item_id )
return found;
}
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, int32 extendedCost) const
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const
{
for(VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i )
if((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)

View file

@ -276,17 +276,13 @@ enum AttackingTarget
// Vendors
struct VendorItem
{
VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, int32 _ExtendedCost)
VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
: item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
uint32 item;
uint32 maxcount; // 0 for infinity item amount
uint32 incrtime; // time for restore items amount if maxcount != 0
int32 ExtendedCost; // negative if need exclude normal item money cost
// helpers
uint32 IsExcludeMoneyPrice() const { return ExtendedCost < 0; }
uint32 GetExtendedCostId() const { return std::abs(ExtendedCost); }
uint32 ExtendedCost; // index in ItemExtendedCost.dbc
};
typedef std::vector<VendorItem*> VendorItemList;
@ -301,12 +297,12 @@ struct VendorItemData
}
bool Empty() const { return m_items.empty(); }
uint8 GetItemCount() const { return m_items.size(); }
void AddItem( uint32 item, uint32 maxcount, uint32 ptime, int32 ExtendedCost)
void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
{
m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
}
bool RemoveItem( uint32 item_id );
VendorItem const* FindItemCostPair(uint32 item_id, int32 extendedCost) const;
VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const;
void Clear()
{

View file

@ -781,7 +781,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
++count;
// reputation discount
uint32 price = crItem->IsExcludeMoneyPrice() ? 0 : uint32(floor(pProto->BuyPrice * discountMod));
uint32 price = (crItem->ExtendedCost == 0 || pProto->Flags2 & ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD) ? uint32(floor(pProto->BuyPrice * discountMod)) : 0;
data << uint32(vendorslot +1); // client size expected counting from 1
data << uint32(crItem->item);
@ -790,7 +790,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
data << uint32(price);
data << uint32(pProto->MaxDurability);
data << uint32(pProto->BuyCount);
data << uint32(crItem->GetExtendedCostId());
data << uint32(crItem->ExtendedCost);
}
}
}

View file

@ -484,7 +484,7 @@ enum ItemExtraFlags
ITEM_EXTRA_NON_CONSUMABLE = 0x01, // use as additional flag to spellcharges_N negative values, item not expire at no chanrges
ITEM_EXTRA_REAL_TIME_DURATION = 0x02, // if set and have Duration time, then offline time included in counting, if not set then counted only in game time
ITEM_EXTRA_ALL // all used flags, used for check DB data
ITEM_EXTRA_ALL = 0x03 // all used flags, used for check DB data (mask all above flags)
};
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform

View file

@ -1161,7 +1161,7 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args)
incrtime = atol(fincrtime);
char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
int32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
Creature* vendor = getSelectedCreature();

View file

@ -8178,7 +8178,7 @@ void ObjectMgr::LoadVendors()
uint32 item_id = fields[1].GetUInt32();
uint32 maxcount = fields[2].GetUInt32();
uint32 incrtime = fields[3].GetUInt32();
int32 ExtendedCost = fields[4].GetInt32();
uint32 ExtendedCost = fields[4].GetUInt32();
if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors))
continue;
@ -8456,12 +8456,12 @@ void ObjectMgr::LoadGossipMenuItems()
sLog.outString(">> Loaded %u gossip_menu_option entries", count);
}
void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, int32 extendedcost )
void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost )
{
VendorItemData& vList = m_mCacheVendorItemMap[entry];
vList.AddItem(item,maxcount,incrtime,extendedcost);
WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%i')",entry, item, maxcount,incrtime,extendedcost);
WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost);
}
bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item )
@ -8477,7 +8477,7 @@ bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item )
return true;
}
bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, int32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors ) const
bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors ) const
{
CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry);
if(!cInfo)
@ -8509,18 +8509,18 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
if(pl)
ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
else
sLog.outErrorDb("Table `npc_vendor` for vendor (Entry: %u) contain nonexistent item (%u), ignoring",vendor_entry,item_id);
sLog.outErrorDb("Table `npc_vendor` for vendor (Entry: %u) contain nonexistent item (%u), ignoring",
vendor_entry, item_id);
return false;
}
uint32 extCostId = std::abs(ExtendedCost); // negative exclude for vendor price money part
if(extCostId && !sItemExtendedCostStore.LookupEntry(extCostId))
if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
{
if(pl)
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,extCostId);
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,ExtendedCost);
else
sLog.outErrorDb("Table `npc_vendor` contain item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignoring",item_id,extCostId,vendor_entry);
sLog.outErrorDb("Table `npc_vendor` contain item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignoring",
item_id, ExtendedCost, vendor_entry);
return false;
}
@ -8529,7 +8529,8 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
if(pl)
ChatHandler(pl).PSendSysMessage("MaxCount!=0 (%u) but IncrTime==0", maxcount);
else
sLog.outErrorDb( "Table `npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignoring", maxcount, item_id, vendor_entry);
sLog.outErrorDb( "Table `npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignoring",
maxcount, item_id, vendor_entry);
return false;
}
else if(maxcount==0 && incrtime > 0)
@ -8537,7 +8538,8 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
if(pl)
ChatHandler(pl).PSendSysMessage("MaxCount==0 but IncrTime<>=0");
else
sLog.outErrorDb( "Table `npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignoring", item_id, vendor_entry);
sLog.outErrorDb( "Table `npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignoring",
item_id, vendor_entry);
return false;
}

View file

@ -939,9 +939,9 @@ class ObjectMgr
return &iter->second;
}
void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, int32 ExtendedCost);
void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost);
bool RemoveVendorItem(uint32 entry,uint32 item);
bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, int32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const;
bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const;
void LoadScriptNames();
ScriptNameMap &GetScriptNames() { return m_scriptNames; }

View file

@ -18539,7 +18539,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
return false;
}
if (uint32 extendedCostId = crItem->GetExtendedCostId())
if (uint32 extendedCostId = crItem->ExtendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (!iece)
@ -18581,7 +18581,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
}
uint32 price = crItem->IsExcludeMoneyPrice() ? 0 : pProto->BuyPrice * count;
uint32 price = (crItem->ExtendedCost == 0 || pProto->Flags2 & ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD) ? pProto->BuyPrice * count : 0;
// reputation discount
if (price)
@ -18604,7 +18604,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
ModifyMoney( -(int32)price );
if (uint32 extendedCostId = crItem->GetExtendedCostId())
if (uint32 extendedCostId = crItem->ExtendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (iece->reqhonorpoints)
@ -18649,7 +18649,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
ModifyMoney( -(int32)price );
if (uint32 extendedCostId = crItem->GetExtendedCostId())
if (uint32 extendedCostId = crItem->ExtendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (iece->reqhonorpoints)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10206"
#define REVISION_NR "10207"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10160_02_characters_pet_aura"
#define REVISION_DB_MANGOS "required_10205_01_mangos_spell_area"
#define REVISION_DB_MANGOS "required_10207_01_mangos_npc_vendor"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__