mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7285] More code cleanups in static data structures use.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
b30d1e65a0
commit
8dc3586889
11 changed files with 50 additions and 89 deletions
|
|
@ -698,7 +698,7 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
|
|||
if(gso->Id==1)
|
||||
{
|
||||
uint32 textid=GetNpcTextId();
|
||||
GossipText * gossiptext=objmgr.GetGossipText(textid);
|
||||
GossipText const* gossiptext=objmgr.GetGossipText(textid);
|
||||
if(!gossiptext)
|
||||
cantalking=false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,10 +194,7 @@ void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flag
|
|||
|
||||
void PlayerMenu::SendTalking( uint32 textID )
|
||||
{
|
||||
GossipText *pGossip;
|
||||
std::string GossipStr;
|
||||
|
||||
pGossip = objmgr.GetGossipText(textID);
|
||||
GossipText const* pGossip = objmgr.GetGossipText(textID);
|
||||
|
||||
WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size
|
||||
data << textID; // can be < 0
|
||||
|
|
@ -257,14 +254,11 @@ void PlayerMenu::SendTalking( uint32 textID )
|
|||
|
||||
data << pGossip->Options[i].Language;
|
||||
|
||||
data << pGossip->Options[i].Emotes[0]._Delay;
|
||||
data << pGossip->Options[i].Emotes[0]._Emote;
|
||||
|
||||
data << pGossip->Options[i].Emotes[1]._Delay;
|
||||
data << pGossip->Options[i].Emotes[1]._Emote;
|
||||
|
||||
data << pGossip->Options[i].Emotes[2]._Delay;
|
||||
data << pGossip->Options[i].Emotes[2]._Emote;
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
data << pGossip->Options[i].Emotes[j]._Delay;
|
||||
data << pGossip->Options[i].Emotes[j]._Emote;
|
||||
}
|
||||
}
|
||||
}
|
||||
pSession->SendPacket( &data );
|
||||
|
|
|
|||
|
|
@ -237,18 +237,19 @@ struct Loot
|
|||
// void clear();
|
||||
void clear()
|
||||
{
|
||||
items.clear(); gold = 0; PlayersLooting.clear();
|
||||
for (QuestItemMap::iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
PlayerQuestItems.clear();
|
||||
|
||||
for (QuestItemMap::iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
PlayerFFAItems.clear();
|
||||
|
||||
for (QuestItemMap::iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
PlayerQuestItems.clear();
|
||||
PlayerFFAItems.clear();
|
||||
PlayerNonQuestNonFFAConditionalItems.clear();
|
||||
|
||||
PlayersLooting.clear();
|
||||
items.clear();
|
||||
quest_items.clear();
|
||||
gold = 0;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ struct GossipTextOption
|
|||
|
||||
struct GossipText
|
||||
{
|
||||
uint32 Text_ID;
|
||||
GossipTextOption Options[8];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -140,24 +140,10 @@ ObjectMgr::ObjectMgr()
|
|||
ObjectMgr::~ObjectMgr()
|
||||
{
|
||||
for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++i )
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
mQuestTemplates.clear( );
|
||||
|
||||
for( GossipTextMap::iterator i = mGossipText.begin( ); i != mGossipText.end( ); ++i )
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
mGossipText.clear( );
|
||||
|
||||
mAreaTriggers.clear();
|
||||
|
||||
for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++i )
|
||||
{
|
||||
delete[] i->second;
|
||||
}
|
||||
petInfo.clear();
|
||||
|
||||
// free only if loaded
|
||||
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
|
||||
|
|
@ -4064,7 +4050,7 @@ void ObjectMgr::LoadInstanceTemplate()
|
|||
// entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid)
|
||||
// entry->resetTimeRaid store reset time for normal raid only
|
||||
// for current state entry->resetTimeRaid == entry->resetTimeHeroic in case raid instances with heroic mode.
|
||||
// but at some point wee need implement reset time dependen from raid insatance mode
|
||||
// but at some point wee need implement reset time dependent from raid instance mode
|
||||
if(temp->reset_delay == 0)
|
||||
{
|
||||
// use defaults from the DBC
|
||||
|
|
@ -4087,21 +4073,11 @@ void ObjectMgr::LoadInstanceTemplate()
|
|||
sLog.outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::AddGossipText(GossipText *pGText)
|
||||
GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const
|
||||
{
|
||||
ASSERT( pGText->Text_ID );
|
||||
ASSERT( mGossipText.find(pGText->Text_ID) == mGossipText.end() );
|
||||
mGossipText[pGText->Text_ID] = pGText;
|
||||
}
|
||||
|
||||
GossipText *ObjectMgr::GetGossipText(uint32 Text_ID)
|
||||
{
|
||||
GossipTextMap::const_iterator itr;
|
||||
for (itr = mGossipText.begin(); itr != mGossipText.end(); ++itr)
|
||||
{
|
||||
if(itr->second->Text_ID == Text_ID)
|
||||
return itr->second;
|
||||
}
|
||||
GossipTextMap::const_iterator itr = mGossipText.find(Text_ID);
|
||||
if(itr != mGossipText.end())
|
||||
return &itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -4134,30 +4110,29 @@ void ObjectMgr::LoadGossipText()
|
|||
|
||||
bar.step();
|
||||
|
||||
pGText = new GossipText;
|
||||
pGText->Text_ID = fields[cic++].GetUInt32();
|
||||
uint32 Text_ID = fields[cic++].GetUInt32();
|
||||
if(!Text_ID)
|
||||
{
|
||||
sLog.outErrorDb("Table `npc_text` has record wit reserved id 0, ignore.");
|
||||
continue;
|
||||
}
|
||||
|
||||
GossipText& gText = mGossipText[Text_ID];
|
||||
|
||||
for (int i=0; i< 8; i++)
|
||||
{
|
||||
pGText->Options[i].Text_0 = fields[cic++].GetCppString();
|
||||
pGText->Options[i].Text_1 = fields[cic++].GetCppString();
|
||||
gText.Options[i].Text_0 = fields[cic++].GetCppString();
|
||||
gText.Options[i].Text_1 = fields[cic++].GetCppString();
|
||||
|
||||
pGText->Options[i].Language = fields[cic++].GetUInt32();
|
||||
pGText->Options[i].Probability = fields[cic++].GetFloat();
|
||||
gText.Options[i].Language = fields[cic++].GetUInt32();
|
||||
gText.Options[i].Probability = fields[cic++].GetFloat();
|
||||
|
||||
pGText->Options[i].Emotes[0]._Delay = fields[cic++].GetUInt32();
|
||||
pGText->Options[i].Emotes[0]._Emote = fields[cic++].GetUInt32();
|
||||
|
||||
pGText->Options[i].Emotes[1]._Delay = fields[cic++].GetUInt32();
|
||||
pGText->Options[i].Emotes[1]._Emote = fields[cic++].GetUInt32();
|
||||
|
||||
pGText->Options[i].Emotes[2]._Delay = fields[cic++].GetUInt32();
|
||||
pGText->Options[i].Emotes[2]._Emote = fields[cic++].GetUInt32();
|
||||
for(int j=0; j < 3; ++j)
|
||||
{
|
||||
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt32();
|
||||
gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pGText->Text_ID ) continue;
|
||||
AddGossipText( pGText );
|
||||
|
||||
} while( result->NextRow() );
|
||||
|
||||
sLog.outString();
|
||||
|
|
|
|||
|
|
@ -403,8 +403,7 @@ class ObjectMgr
|
|||
return false;
|
||||
}
|
||||
|
||||
void AddGossipText(GossipText *pGText);
|
||||
GossipText *GetGossipText(uint32 Text_ID);
|
||||
GossipText const* GetGossipText(uint32 Text_ID) const;
|
||||
|
||||
WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team);
|
||||
bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true);
|
||||
|
|
@ -748,7 +747,7 @@ class ObjectMgr
|
|||
|
||||
QuestMap mQuestTemplates;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;
|
||||
typedef UNORDERED_MAP<uint32, GossipText> GossipTextMap;
|
||||
typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap;
|
||||
typedef UNORDERED_MAP<uint32, std::string> ItemTextMap;
|
||||
typedef std::set<uint32> TavernAreaTriggerSet;
|
||||
|
|
@ -758,8 +757,6 @@ class ObjectMgr
|
|||
GuildMap mGuildMap;
|
||||
ArenaTeamMap mArenaTeamMap;
|
||||
|
||||
ItemMap mItems;
|
||||
|
||||
ItemTextMap mItemTexts;
|
||||
|
||||
QuestAreaTriggerMap mQuestAreaTriggerMap;
|
||||
|
|
|
|||
|
|
@ -12299,7 +12299,7 @@ void Player::SendPreparedQuest( uint64 guid )
|
|||
if( pCreature )
|
||||
{
|
||||
uint32 textid = pCreature->GetNpcTextId();
|
||||
GossipText * gossiptext = objmgr.GetGossipText(textid);
|
||||
GossipText const* gossiptext = objmgr.GetGossipText(textid);
|
||||
if( !gossiptext )
|
||||
{
|
||||
qe._Delay = 0; //TEXTEMOTE_MESSAGE; //zyg: player emote
|
||||
|
|
|
|||
|
|
@ -321,8 +321,6 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
|
|||
|
||||
uint32 textID;
|
||||
uint64 guid;
|
||||
GossipText *pGossip;
|
||||
std::string GossipStr;
|
||||
|
||||
recv_data >> textID;
|
||||
sLog.outDetail("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);
|
||||
|
|
@ -330,7 +328,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
|
|||
recv_data >> guid;
|
||||
GetPlayer()->SetUInt64Value(UNIT_FIELD_TARGET, guid);
|
||||
|
||||
pGossip = objmgr.GetGossipText(textID);
|
||||
GossipText const* pGossip = objmgr.GetGossipText(textID);
|
||||
|
||||
WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size
|
||||
data << textID;
|
||||
|
|
@ -392,14 +390,11 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
|
|||
|
||||
data << pGossip->Options[i].Language;
|
||||
|
||||
data << pGossip->Options[i].Emotes[0]._Delay;
|
||||
data << pGossip->Options[i].Emotes[0]._Emote;
|
||||
|
||||
data << pGossip->Options[i].Emotes[1]._Delay;
|
||||
data << pGossip->Options[i].Emotes[1]._Emote;
|
||||
|
||||
data << pGossip->Options[i].Emotes[2]._Delay;
|
||||
data << pGossip->Options[i].Emotes[2]._Emote;
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
data << pGossip->Options[i].Emotes[j]._Delay;
|
||||
data << pGossip->Options[i].Emotes[j]._Emote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
|
|||
|
||||
for(SocialMap::iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
|
||||
{
|
||||
PlayerSocialMap::iterator itr2 = itr->second.m_playerSocialMap.find(guid);
|
||||
PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid);
|
||||
if(itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
|
||||
{
|
||||
Player *pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Unit::Unit()
|
|||
m_addDmgOnce = 0;
|
||||
|
||||
for(int i = 0; i < MAX_TOTEM; ++i)
|
||||
m_TotemSlot[i] = 0;
|
||||
m_TotemSlot[i] = 0;
|
||||
|
||||
m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
|
||||
//m_Aura = NULL;
|
||||
|
|
@ -111,9 +111,9 @@ Unit::Unit()
|
|||
m_ShapeShiftFormSpellId = 0;
|
||||
m_canModifyStats = false;
|
||||
|
||||
for (int i = 0; i < MAX_SPELL_IMMUNITY; i++)
|
||||
for (int i = 0; i < MAX_SPELL_IMMUNITY; ++i)
|
||||
m_spellImmune[i].clear();
|
||||
for (int i = 0; i < UNIT_MOD_END; i++)
|
||||
for (int i = 0; i < UNIT_MOD_END; ++i)
|
||||
{
|
||||
m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
|
||||
m_auraModifiersGroup[i][BASE_PCT] = 1.0f;
|
||||
|
|
@ -123,12 +123,12 @@ Unit::Unit()
|
|||
// implement 50% base damage from offhand
|
||||
m_auraModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5f;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < MAX_ATTACK; ++i)
|
||||
{
|
||||
m_weaponDamage[i][MINDAMAGE] = BASE_MINDAMAGE;
|
||||
m_weaponDamage[i][MAXDAMAGE] = BASE_MAXDAMAGE;
|
||||
}
|
||||
for (int i = 0; i < MAX_STATS; i++)
|
||||
for (int i = 0; i < MAX_STATS; ++i)
|
||||
m_createStats[i] = 0.0f;
|
||||
|
||||
m_attacking = NULL;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7284"
|
||||
#define REVISION_NR "7285"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue