Core/Gossip: Fixed incorrect gossip menu texts introduced after dropping npc_gossip table

This commit is contained in:
Shauren
2011-06-15 18:53:55 +02:00
parent 53e45b57f8
commit fb44a609ff
3 changed files with 15 additions and 30 deletions
+13 -15
View File
@@ -14277,15 +14277,12 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
ModifyMoney(-cost); ModifyMoney(-cost);
} }
uint32 Player::GetGossipTextId(WorldObject *pSource) uint32 Player::GetGossipTextId(WorldObject* source)
{ {
if (!pSource || pSource->GetTypeId() != TYPEID_UNIT || !pSource->ToCreature()->GetDBTableGUIDLow()) if (!source)
return DEFAULT_GOSSIP_MESSAGE; return DEFAULT_GOSSIP_MESSAGE;
if (uint32 pos = sObjectMgr->GetNpcGossip(pSource->ToCreature()->GetDBTableGUIDLow())) return GetGossipTextId(GetDefaultGossipMenuForSource(source));
return pos;
return DEFAULT_GOSSIP_MESSAGE;
} }
uint32 Player::GetGossipTextId(uint32 menuId) uint32 Player::GetGossipTextId(uint32 menuId)
@@ -14295,23 +14292,24 @@ uint32 Player::GetGossipTextId(uint32 menuId)
if (!menuId) if (!menuId)
return textId; return textId;
GossipMenusMapBounds pMenuBounds = sObjectMgr->GetGossipMenusMapBounds(menuId); GossipMenusMapBounds menuBounds = sObjectMgr->GetGossipMenusMapBounds(menuId);
for (GossipMenusMap::const_iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr) for (GossipMenusMap::const_iterator itr = menuBounds.first; itr != menuBounds.second; ++itr)
{
if (sConditionMgr->IsPlayerMeetToConditions(this, itr->second.conditions)) if (sConditionMgr->IsPlayerMeetToConditions(this, itr->second.conditions))
textId = itr->second.text_id; textId = itr->second.text_id;
}
return textId; return textId;
} }
uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource) uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source)
{ {
if (pSource->GetTypeId() == TYPEID_UNIT) switch (source->GetTypeId())
return pSource->ToCreature()->GetCreatureInfo()->GossipMenuId; {
else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) case TYPEID_UNIT:
return((GameObject*)pSource)->GetGOInfo()->GetGossipMenuId(); return source->ToCreature()->GetCreatureInfo()->GossipMenuId;
case TYPEID_GAMEOBJECT:
return source->ToGameObject()->GetGOInfo()->GetGossipMenuId();
}
return 0; return 0;
} }
+2 -2
View File
@@ -1339,8 +1339,8 @@ class Player : public Unit, public GridObject<Player>
void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId); void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId);
uint32 GetGossipTextId(uint32 menuId); uint32 GetGossipTextId(uint32 menuId);
uint32 GetGossipTextId(WorldObject *pSource); uint32 GetGossipTextId(WorldObject* source);
uint32 GetDefaultGossipMenuForSource(WorldObject *pSource); static uint32 GetDefaultGossipMenuForSource(WorldObject* source);
/*********************************************************/ /*********************************************************/
/*** QUEST SYSTEM ***/ /*** QUEST SYSTEM ***/
-13
View File
@@ -538,9 +538,6 @@ struct GraveYardData
}; };
typedef std::multimap<uint32, GraveYardData> GraveYardMap; typedef std::multimap<uint32, GraveYardData> GraveYardMap;
// NPC gossip text id
typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap;
typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap; typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap;
typedef UNORDERED_MAP<uint32, TrainerSpellData> CacheTrainerSpellMap; typedef UNORDERED_MAP<uint32, TrainerSpellData> CacheTrainerSpellMap;
@@ -1148,15 +1145,6 @@ class ObjectMgr
bool AddGameTele(GameTele& data); bool AddGameTele(GameTele& data);
bool DeleteGameTele(const std::string& name); bool DeleteGameTele(const std::string& name);
uint32 GetNpcGossip(uint32 entry) const
{
CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
if (iter == m_mCacheNpcTextIdMap.end())
return 0;
return iter->second;
}
TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const
{ {
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
@@ -1369,7 +1357,6 @@ class ObjectMgr
RespawnTimes mGORespawnTimes; RespawnTimes mGORespawnTimes;
ACE_Thread_Mutex m_GORespawnTimesMtx; ACE_Thread_Mutex m_GORespawnTimesMtx;
CacheNpcTextIdMap m_mCacheNpcTextIdMap;
CacheVendorItemMap m_mCacheVendorItemMap; CacheVendorItemMap m_mCacheVendorItemMap;
CacheTrainerSpellMap m_mCacheTrainerSpellMap; CacheTrainerSpellMap m_mCacheTrainerSpellMap;