mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Core/Guilds: replace container type for guilds (use vector instead of map).
Scripts/Misc: remove another warning (I can't pass by such things and I don't want to make separate commit for such changes). --HG-- branch : trunk
This commit is contained in:
@@ -290,7 +290,8 @@ ObjectMgr::~ObjectMgr()
|
||||
delete *itr;
|
||||
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
if (*itr)
|
||||
delete *itr;
|
||||
|
||||
for (ArenaTeamMap::iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
@@ -311,12 +312,12 @@ Group * ObjectMgr::GetGroupByGUID(uint32 guid) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Guild* ObjectMgr::GetGuildById(uint32 GuildId) const
|
||||
// Guild collection
|
||||
Guild* ObjectMgr::GetGuildById(uint32 guildId) const
|
||||
{
|
||||
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
|
||||
if (itr != mGuildMap.end())
|
||||
return itr->second;
|
||||
|
||||
// Make sure given index exists in collection
|
||||
if (guildId < uint32(mGuildMap.size()))
|
||||
return mGuildMap[guildId];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -326,42 +327,51 @@ Guild* ObjectMgr::GetGuildByName(const std::string& guildname) const
|
||||
std::transform(search.begin(), search.end(), search.begin(), ::toupper);
|
||||
for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
{
|
||||
std::string gname = itr->second->GetName();
|
||||
std::transform(gname.begin(), gname.end(), gname.begin(), ::toupper);
|
||||
if (search == gname)
|
||||
return itr->second;
|
||||
if (*itr)
|
||||
{
|
||||
std::string gname = (*itr)->GetName();
|
||||
std::transform(gname.begin(), gname.end(), gname.begin(), ::toupper);
|
||||
if (search == gname)
|
||||
return *itr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string ObjectMgr::GetGuildNameById(uint32 GuildId) const
|
||||
std::string ObjectMgr::GetGuildNameById(uint32 guildId) const
|
||||
{
|
||||
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
|
||||
if (itr != mGuildMap.end())
|
||||
return itr->second->GetName();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
return pGuild->GetName();
|
||||
return "";
|
||||
}
|
||||
|
||||
Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const
|
||||
{
|
||||
for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
if (itr->second->GetLeaderGUID() == guid)
|
||||
return itr->second;
|
||||
if ((*itr) && (*itr)->GetLeaderGUID() == guid)
|
||||
return *itr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjectMgr::AddGuild(Guild* guild)
|
||||
void ObjectMgr::AddGuild(Guild* pGuild)
|
||||
{
|
||||
mGuildMap[guild->GetId()] = guild;
|
||||
uint32 guildId = pGuild->GetId();
|
||||
// Allocate space if necessary
|
||||
if (guildId >= uint32(mGuildMap.size()))
|
||||
// Reserve a bit more space than necessary
|
||||
mGuildMap.resize(guildId + 512, NULL);
|
||||
mGuildMap[guildId] = pGuild;
|
||||
}
|
||||
|
||||
void ObjectMgr::RemoveGuild(uint32 Id)
|
||||
void ObjectMgr::RemoveGuild(uint32 guildId)
|
||||
{
|
||||
mGuildMap.erase(Id);
|
||||
// Make sure given index exists
|
||||
if (guildId < uint32(mGuildMap.size()))
|
||||
mGuildMap[guildId] = NULL;
|
||||
}
|
||||
|
||||
// Arena teams collection
|
||||
ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const
|
||||
{
|
||||
ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid);
|
||||
@@ -3504,7 +3514,9 @@ void ObjectMgr::LoadGuilds()
|
||||
return;
|
||||
}
|
||||
// 1. Load all guilds
|
||||
barGoLink bar(result->GetRowCount());
|
||||
uint64 rowCount = result->GetRowCount();
|
||||
mGuildMap.resize(uint32(rowCount), NULL); // Reserve space and initialize storage for loading guilds
|
||||
barGoLink bar(rowCount);
|
||||
do
|
||||
{
|
||||
bar.step();
|
||||
@@ -3520,10 +3532,9 @@ void ObjectMgr::LoadGuilds()
|
||||
}
|
||||
while (result->NextRow());
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded " UI64FMTD " guilds definitions", result->GetRowCount());
|
||||
sLog.outString(">> Loaded " UI64FMTD " guilds definitions", rowCount);
|
||||
sLog.outString();
|
||||
|
||||
uint64 rowCount = 0;
|
||||
// 2. Load all guild ranks
|
||||
sLog.outString("Loading guild ranks...");
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_RANKS);
|
||||
@@ -3545,6 +3556,7 @@ void ObjectMgr::LoadGuilds()
|
||||
}
|
||||
else
|
||||
{
|
||||
rowCount = 0;
|
||||
barGoLink bar(1);
|
||||
bar.step();
|
||||
}
|
||||
@@ -3720,20 +3732,20 @@ void ObjectMgr::LoadGuilds()
|
||||
sLog.outString();
|
||||
|
||||
// 9. Validate loaded guild data
|
||||
uint32 totalGuilds = 0;
|
||||
sLog.outString("Validating data of loaded guilds...");
|
||||
barGoLink barGuilds(mGuildMap.size());
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); )
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
{
|
||||
barGuilds.step();
|
||||
Guild* pGuild = itr->second;
|
||||
if (!pGuild->Validate())
|
||||
Guild* pGuild = *itr;
|
||||
if (pGuild && !pGuild->Validate())
|
||||
{
|
||||
++itr;
|
||||
mGuildMap.erase(pGuild->GetId());
|
||||
RemoveGuild(pGuild->GetId());
|
||||
delete pGuild;
|
||||
}
|
||||
else
|
||||
++itr;
|
||||
++totalGuilds;
|
||||
}
|
||||
// Cleanup
|
||||
// Delete orphan guild ranks
|
||||
@@ -3763,7 +3775,7 @@ void ObjectMgr::LoadGuilds()
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Successfully loaded %u guilds", uint32(mGuildMap.size()));
|
||||
sLog.outString(">> Successfully loaded %u guilds", totalGuilds);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadArenaTeams()
|
||||
|
||||
@@ -573,7 +573,7 @@ class ObjectMgr
|
||||
|
||||
typedef std::set<Group *> GroupSet;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, Guild *> GuildMap;
|
||||
typedef std::vector <Guild *> GuildMap;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamMap;
|
||||
|
||||
@@ -610,11 +610,11 @@ class ObjectMgr
|
||||
void RemoveGroup(Group* group) { mGroupSet.erase(group); }
|
||||
|
||||
Guild* GetGuildByLeader(uint64 const&guid) const;
|
||||
Guild* GetGuildById(uint32 GuildId) const;
|
||||
Guild* GetGuildById(uint32 guildId) const;
|
||||
Guild* GetGuildByName(const std::string& guildname) const;
|
||||
std::string GetGuildNameById(uint32 GuildId) const;
|
||||
void AddGuild(Guild* guild);
|
||||
void RemoveGuild(uint32 Id);
|
||||
std::string GetGuildNameById(uint32 guildId) const;
|
||||
void AddGuild(Guild* pGuild);
|
||||
void RemoveGuild(uint32 guildId);
|
||||
|
||||
ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
|
||||
ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
|
||||
|
||||
@@ -1128,7 +1128,7 @@ class spell_putricide_mutated_plague : public SpellScriptLoader
|
||||
multiplier = 3.0f;
|
||||
|
||||
damage *= int32(pow(multiplier, aurApp->GetBase()->GetStackAmount()));
|
||||
damage *= 1.5;
|
||||
damage = int32(damage * 1.5f);
|
||||
|
||||
aurApp->GetTarget()->CastCustomSpell(triggerSpell, SPELLVALUE_BASE_POINT0, damage, aurApp->GetTarget(), true, NULL, aurEff, GetCasterGUID());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user