Avancement :
[code=cpp] /*
* Copyright © 2008-2011 TrinityCore <http://www.trinitycore.org/>
* Copyright © 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "Common.h"
#include "DatabaseEnv.h"
#include "SQLStorage.h"
#include "SQLStorageImpl.h"
#include "Log.h"
#include "MapManager.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "UpdateMask.h"
#include "World.h"
#include "Group.h"
#include "Guild.h"
#include "ArenaTeam.h"
#include "Transport.h"
#include "Language.h"
#include "GameEventMgr.h"
#include "Spell.h"
#include "Chat.h"
#include "AccountMgr.h"
#include "InstanceSaveMgr.h"
#include "SpellAuras.h"
#include "Util.h"
#include "WaypointManager.h"
#include "GossipDef.h"
#include "Vehicle.h"
#include "AchievementMgr.h"
#include "DisableMgr.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "PoolMgr.h"
#include "ObjectMgr.h"
#include "Conquest.h"
Conquest::~Conquest()
{
}
Conquest::Conquest()
{
}
void Conquest::LoadConquest()
{
sConquest->LoadConquestListArea();
}
void Conquest::ConquestUpdateFaction(Player* pPlayer)
{
uint32 pguid = pPlayer->GetGUID();
if (pPlayer->GetGuildIdFromDB(pguid)==0)
return;
if(sConquest->isOwnArea(pPlayer->GetGuildIdFromDB(pguid), pPlayer->GetAreaId()))
{
pPlayer->setFaction(CONQUEST_DEF);
return;
}
pPlayer->setFaction(CONQUEST_ATQ);
}
void Conquest::LoadConquestListArea()
{
uint32 oldMSTime = getMSTime();
m_cqarealist.clear(); //Clean for reload
QueryResult result = WorldDatabase.Query("SELECT auraId, guildId FROM conquest");
if (!result)
{
sLog->outString(">> Loaded 0 Conquest Area. DB table `conquest` is empty.");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field *fields = result->Fetch();
uint32 areaId = fields[0].GetUInt32();
uint32 guildId = fields[1].GetUInt32();
m_cqarealist[areaId] = guildId;
++count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u Conquest Area in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
bool Conquest::isConquestArea(uint32 areaId)
{
for (ConquestAreaList::const_iterator itr = m_cqarealist.begin(); itr != m_cqarealist.end(); ++itr)
{
if (itr->first == areaId)
return true;
}
return false;
}
bool Conquest::isOwnArea(uint32 guildId , uint32 areaId)
{
for (ConquestAreaList::const_iterator itr = m_cqarealist.begin(); itr != m_cqarealist.end(); ++itr)
{
if (itr->second == guildId && itr->first == areaId)
return true;
}
return false;
} [/code]