Conflicts:
	src/server/game/Achievements/AchievementMgr.cpp
	src/server/game/Battlefield/Battlefield.h
	src/server/game/Battlegrounds/ArenaScore.h
	src/server/game/Battlegrounds/ArenaTeam.cpp
	src/server/game/Battlegrounds/ArenaTeam.h
	src/server/game/Battlegrounds/ArenaTeamMgr.cpp
	src/server/game/Battlegrounds/BattlegroundMgr.cpp
	src/server/game/Battlegrounds/BattlegroundMgr.h
	src/server/game/Battlegrounds/BattlegroundQueue.h
	src/server/game/Battlegrounds/BattlegroundScore.h
	src/server/game/Battlegrounds/Zones/BattlegroundAB.h
	src/server/game/Battlegrounds/Zones/BattlegroundAV.h
	src/server/game/Battlegrounds/Zones/BattlegroundEY.h
	src/server/game/Battlegrounds/Zones/BattlegroundIC.h
	src/server/game/Battlegrounds/Zones/BattlegroundSA.h
	src/server/game/Battlegrounds/Zones/BattlegroundWS.h
	src/server/game/DungeonFinding/LFG.h
	src/server/game/DungeonFinding/LFGMgr.cpp
	src/server/game/DungeonFinding/LFGMgr.h
	src/server/game/DungeonFinding/LFGQueue.cpp
	src/server/game/DungeonFinding/LFGQueue.h
	src/server/game/Entities/Corpse/Corpse.cpp
	src/server/game/Entities/Creature/Creature.cpp
	src/server/game/Entities/Creature/GossipDef.cpp
	src/server/game/Entities/Creature/GossipDef.h
	src/server/game/Entities/Creature/TemporarySummon.cpp
	src/server/game/Entities/DynamicObject/DynamicObject.cpp
	src/server/game/Entities/Object/Object.cpp
	src/server/game/Entities/Object/Object.h
	src/server/game/Entities/Object/ObjectDefines.h
	src/server/game/Entities/Object/Updates/UpdateData.cpp
	src/server/game/Entities/Player/Player.cpp
	src/server/game/Entities/Player/Player.h
	src/server/game/Entities/Unit/Unit.cpp
	src/server/game/Entities/Unit/Unit.h
	src/server/game/Globals/ObjectAccessor.cpp
	src/server/game/Globals/ObjectAccessor.h
	src/server/game/Globals/ObjectMgr.cpp
	src/server/game/Groups/Group.cpp
	src/server/game/Groups/Group.h
	src/server/game/Guilds/Guild.cpp
	src/server/game/Guilds/Guild.h
	src/server/game/Handlers/AuctionHouseHandler.cpp
	src/server/game/Handlers/BattleGroundHandler.cpp
	src/server/game/Handlers/CalendarHandler.cpp
	src/server/game/Handlers/CharacterHandler.cpp
	src/server/game/Handlers/ChatHandler.cpp
	src/server/game/Handlers/GroupHandler.cpp
	src/server/game/Handlers/GuildHandler.cpp
	src/server/game/Handlers/ItemHandler.cpp
	src/server/game/Handlers/LFGHandler.cpp
	src/server/game/Handlers/MailHandler.cpp
	src/server/game/Handlers/MiscHandler.cpp
	src/server/game/Handlers/MovementHandler.cpp
	src/server/game/Handlers/NPCHandler.cpp
	src/server/game/Handlers/PetHandler.cpp
	src/server/game/Handlers/QueryHandler.cpp
	src/server/game/Handlers/QuestHandler.cpp
	src/server/game/Handlers/TradeHandler.cpp
	src/server/game/Handlers/VehicleHandler.cpp
	src/server/game/Movement/Spline/MoveSplineInit.cpp
	src/server/game/Server/WorldSession.cpp
	src/server/game/Server/WorldSession.h
	src/server/game/Spells/Spell.cpp
	src/server/scripts/Commands/cs_debug.cpp
	src/server/scripts/Commands/cs_gm.cpp
	src/server/scripts/Commands/cs_misc.cpp
	src/server/scripts/Commands/cs_modify.cpp
	src/server/scripts/Commands/cs_reset.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
	src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp
	src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp
	src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
	src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp
	src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp
	src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp
	src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp
	src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp
	src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp
	src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp
	src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp
	src/server/scripts/EasternKingdoms/zone_tirisfal_glades.cpp
	src/server/scripts/Kalimdor/zone_azshara.cpp
	src/server/scripts/Kalimdor/zone_durotar.cpp
	src/server/scripts/Kalimdor/zone_moonglade.cpp
	src/server/scripts/Kalimdor/zone_orgrimmar.cpp
	src/server/scripts/Kalimdor/zone_ungoro_crater.cpp
	src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
	src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
	src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
	src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp
	src/server/scripts/Spells/spell_dk.cpp
	src/server/scripts/Spells/spell_generic.cpp
	src/server/shared/Packets/ByteBuffer.h
This commit is contained in:
Shauren committed 2014-09-20 11:05:30 +02:00
commit 8e288dd673
597 files changed
+9276 -9366

No files matched your search

+1 -1
View File
@@ -236,7 +236,7 @@ namespace VMAP
MapData::iterator map_iter = mapData.find(mapID);
if (map_iter == mapData.end())
{
printf("spawning Map %d\n", mapID);
printf("spawning Map %u\n", mapID);
mapData[mapID] = current = new MapSpawns();
}
else current = (*map_iter).second;
+3 -3
View File
@@ -164,7 +164,7 @@ void PetAI::UpdateAI(uint32 diff)
continue;
}
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE);
bool spellUsed = false;
// Some spells can target enemy or friendly (DK Ghoul's Leap)
@@ -192,7 +192,7 @@ void PetAI::UpdateAI(uint32 diff)
// No enemy, check friendly
if (!spellUsed)
{
for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
for (GuidSet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
{
Unit* ally = ObjectAccessor::GetUnit(*me, *tar);
@@ -215,7 +215,7 @@ void PetAI::UpdateAI(uint32 diff)
}
else if (me->GetVictim() && CanAttack(me->GetVictim()) && spellInfo->CanBeUsedInCombat())
{
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE);
if (spell->CanAutoCast(me->GetVictim()))
targetSpellStore.push_back(std::make_pair(me->GetVictim(), spell));
else
+1 -1
View File
@@ -57,7 +57,7 @@ class PetAI : public CreatureAI
void UpdateAllies();
TimeTracker i_tracker;
std::set<uint64> m_AllySet;
GuidSet m_AllySet;
uint32 m_updateAlliesTimer;
Unit* SelectNextTarget(bool allowAutoSelect) const;
+2 -2
View File
@@ -35,7 +35,7 @@ int TotemAI::Permissible(Creature const* creature)
return PERMIT_BASE_NO;
}
TotemAI::TotemAI(Creature* c) : CreatureAI(c), i_victimGuid(0)
TotemAI::TotemAI(Creature* c) : CreatureAI(c), i_victimGuid()
{
ASSERT(c->IsTotem());
}
@@ -90,7 +90,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
me->CastSpell(victim, me->ToTotem()->GetSpell(), false);
}
else
i_victimGuid = 0;
i_victimGuid.Clear();
}
void TotemAI::AttackStart(Unit* /*victim*/)
+1 -1
View File
@@ -39,7 +39,7 @@ class TotemAI : public CreatureAI
static int Permissible(Creature const* creature);
private:
uint64 i_victimGuid;
ObjectGuid i_victimGuid;
};
#endif
+2 -2
View File
@@ -137,8 +137,8 @@ class UnitAI
virtual void DoAction(int32 /*param*/) { }
virtual uint32 GetData(uint32 /*id = 0*/) const { return 0; }
virtual void SetData(uint32 /*id*/, uint32 /*value*/) { }
virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) { }
virtual uint64 GetGUID(int32 /*id*/ = 0) const { return 0; }
virtual void SetGUID(ObjectGuid /*guid*/, int32 /*id*/ = 0) { }
virtual ObjectGuid GetGUID(int32 /*id*/ = 0) const { return ObjectGuid::Empty; }
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
// Select the targets satisfying the predicate.
+1 -6
View File
@@ -38,16 +38,11 @@ void CreatureAI::OnCharmed(bool /*apply*/)
AISpellInfoType* UnitAI::AISpellInfo;
AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; }
void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= NULL*/)
void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= nullptr*/)
{
sCreatureTextMgr->SendChat(me, id, whisperTarget);
}
void CreatureAI::TalkToMap(uint8 id, WorldObject const* whisperTarget /*= NULL*/)
{
sCreatureTextMgr->SendChat(me, id, whisperTarget, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_MAP);
}
void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToNearestTarget /* = 50.0f*/)
{
if (!creature)
+3 -5
View File
@@ -78,8 +78,8 @@ class CreatureAI : public UnitAI
Creature* DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius = 5.0f, uint32 despawnTime = 30000, TempSummonType summonType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
public:
void Talk(uint8 id, WorldObject const* whisperTarget = NULL);
void TalkToMap(uint8 id, WorldObject const* whisperTarget = NULL);
void Talk(uint8 id, WorldObject const* whisperTarget = nullptr);
explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), m_MoveInLineOfSight_locked(false) { }
virtual ~CreatureAI() { }
@@ -165,14 +165,12 @@ class CreatureAI : public UnitAI
/// == Fields =======================================
// Pointer to controlled by AI creature
//Creature* const me;
virtual void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool /*apply*/) { }
virtual void OnSpellClick(Unit* /*clicker*/, bool& /*result*/) { }
virtual bool CanSeeAlways(WorldObject const* /*obj*/) { return false; }
protected:
virtual void MoveInLineOfSight(Unit* /*who*/);
@@ -311,8 +311,8 @@ void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o
if (Player* player = unit->ToPlayer())
player->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
else
TC_LOG_ERROR("scripts", "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.",
me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o);
TC_LOG_ERROR("scripts", "Creature %s Tried to teleport non-player unit (%s) to x: %f y:%f z: %f o: %f. Aborted.",
me->GetGUID().ToString().c_str(), unit->GetGUID().ToString().c_str(), x, y, z, o);
}
void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
@@ -40,7 +40,7 @@ class InstanceScript;
class SummonList
{
public:
typedef std::list<uint64> StorageType;
typedef GuidList StorageType;
typedef StorageType::iterator iterator;
typedef StorageType::const_iterator const_iterator;
typedef StorageType::size_type size_type;
@@ -104,7 +104,7 @@ public:
{
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
StorageType listCopy = storage_;
Trinity::Containers::RandomResizeList<uint64, Predicate>(listCopy, predicate, max);
Trinity::Containers::RandomResizeList<ObjectGuid, Predicate>(listCopy, predicate, max);
for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); )
{
Creature* summon = ObjectAccessor::GetCreature(*me, *i++);
@@ -126,7 +126,7 @@ class EntryCheckPredicate
{
public:
EntryCheckPredicate(uint32 entry) : _entry(entry) { }
bool operator()(uint64 guid) { return GUID_ENPART(guid) == _entry; }
bool operator()(ObjectGuid guid) { return guid.GetEntry() == _entry; }
private:
uint32 _entry;
@@ -135,7 +135,7 @@ class EntryCheckPredicate
class DummyEntryCheckPredicate
{
public:
bool operator()(uint64) { return true; }
bool operator()(ObjectGuid) { return true; }
};
struct ScriptedAI : public CreatureAI
@@ -23,10 +23,10 @@ SDComment:
SDCategory: Npc
EndScriptData */
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "Group.h"
#include "Player.h"
enum Points
{
@@ -35,7 +35,6 @@ enum Points
};
npc_escortAI::npc_escortAI(Creature* creature) : ScriptedAI(creature),
m_uiPlayerGUID(0),
m_uiWPWaitTimer(2500),
m_uiPlayerCheckTimer(1000),
m_uiEscortState(STATE_ESCORT_NONE),
@@ -430,7 +429,7 @@ void npc_escortAI::SetRun(bool on)
}
/// @todo get rid of this many variables passed in function.
void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, uint64 playerGUID /* = 0 */, Quest const* quest /* = NULL */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */)
void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, ObjectGuid playerGUID /* = 0 */, Quest const* quest /* = NULL */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */)
{
if (me->GetVictim())
{
@@ -486,7 +485,7 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
}
TC_LOG_DEBUG("scripts", "EscortAI started with " UI64FMTD " waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = " UI64FMTD "", uint64(WaypointList.size()), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID);
TC_LOG_DEBUG("scripts", "EscortAI started with " UI64FMTD " waypoints. ActiveAttacker = %d, Run = %d, %s", uint64(WaypointList.size()), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID.ToString().c_str());
CurrentWP = WaypointList.begin();
@@ -88,7 +88,7 @@ struct npc_escortAI : public ScriptedAI
virtual void WaypointReached(uint32 pointId) = 0;
virtual void WaypointStart(uint32 /*pointId*/) { }
void Start(bool isActiveAttacker = true, bool run = false, uint64 playerGUID = 0, Quest const* quest = NULL, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true);
void Start(bool isActiveAttacker = true, bool run = false, ObjectGuid playerGUID = ObjectGuid::Empty, Quest const* quest = NULL, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true);
void SetRun(bool on = true);
void SetEscortPaused(bool on);
@@ -103,7 +103,7 @@ struct npc_escortAI : public ScriptedAI
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
uint64 GetEventStarterGUID() { return m_uiPlayerGUID; }
ObjectGuid GetEventStarterGUID() { return m_uiPlayerGUID; }
protected:
Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); }
@@ -116,7 +116,7 @@ struct npc_escortAI : public ScriptedAI
void AddEscortState(uint32 escortState) { m_uiEscortState |= escortState; }
void RemoveEscortState(uint32 escortState) { m_uiEscortState &= ~escortState; }
uint64 m_uiPlayerGUID;
ObjectGuid m_uiPlayerGUID;
uint32 m_uiWPWaitTimer;
uint32 m_uiPlayerCheckTimer;
uint32 m_uiEscortState;
@@ -23,10 +23,10 @@ SDComment: This AI is under development
SDCategory: Npc
EndScriptData */
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedFollowerAI.h"
#include "Group.h"
#include "Player.h"
const float MAX_PLAYER_DISTANCE = 100.0f;
@@ -36,7 +36,6 @@ enum Points
};
FollowerAI::FollowerAI(Creature* creature) : ScriptedAI(creature),
m_uiLeaderGUID(0),
m_uiUpdateFollowTimer(2500),
m_uiFollowState(STATE_FOLLOW_NONE),
m_pQuestForFollow(NULL)
@@ -320,7 +319,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu
me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName().c_str(), m_uiLeaderGUID);
TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), m_uiLeaderGUID.ToString().c_str());
}
Player* FollowerAI::GetLeaderForFollower()
@@ -71,7 +71,7 @@ class FollowerAI : public ScriptedAI
bool AssistPlayerInCombat(Unit* who);
uint64 m_uiLeaderGUID;
ObjectGuid m_uiLeaderGUID;
uint32 m_uiUpdateFollowTimer;
uint32 m_uiFollowState;
+8 -8
View File
@@ -61,7 +61,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
mDespawnState = 0;
mEscortInvokerCheckTimer = 1000;
mFollowGuid = 0;
mFollowGuid.Clear();
mFollowDist = 0;
mFollowAngle = 0;
mFollowCredit = 0;
@@ -540,7 +540,7 @@ void SmartAI::JustRespawned()
mJustReset = true;
JustReachedHome();
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
mFollowGuid = 0;//do not reset follower on Reset(), we need it after combat evade
mFollowGuid.Clear();//do not reset follower on Reset(), we need it after combat evade
mFollowDist = 0;
mFollowAngle = 0;
mFollowCredit = 0;
@@ -674,8 +674,8 @@ void SmartAI::OnCharmed(bool apply)
{
GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply);
if (!apply && !me->IsInEvadeMode() && me->GetUInt64Value(UNIT_FIELD_CHARMEDBY))
if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetUInt64Value(UNIT_FIELD_CHARMEDBY)))
if (!apply && !me->IsInEvadeMode() && me->GetCharmerGUID())
if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetCharmerGUID()))
AttackStart(charmer);
}
@@ -694,11 +694,11 @@ void SmartAI::SetData(uint32 id, uint32 value)
GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value);
}
void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) { }
void SmartAI::SetGUID(ObjectGuid /*guid*/, int32 /*id*/) { }
uint64 SmartAI::GetGUID(int32 /*id*/) const
ObjectGuid SmartAI::GetGUID(int32 /*id*/) const
{
return 0;
return ObjectGuid::Empty;
}
void SmartAI::SetRun(bool run)
@@ -800,7 +800,7 @@ void SmartAI::StopFollow()
player->GroupEventHappens(mFollowCredit, me);
}
mFollowGuid = 0;
mFollowGuid.Clear();
mFollowDist = 0;
mFollowAngle = 0;
mFollowCredit = 0;
+3 -3
View File
@@ -154,10 +154,10 @@ class SmartAI : public CreatureAI
void SetData(uint32 id, uint32 value) override;
// Used in scripts to share variables
void SetGUID(uint64 guid, int32 id = 0) override;
void SetGUID(ObjectGuid guid, int32 id = 0) override;
// Used in scripts to share variables
uint64 GetGUID(int32 id = 0) const override;
ObjectGuid GetGUID(int32 id = 0) const override;
//core related
static int Permissible(const Creature*);
@@ -199,7 +199,7 @@ class SmartAI : public CreatureAI
uint32 mFollowArrivedTimer;
uint32 mFollowCredit;
uint32 mFollowArrivedEntry;
uint64 mFollowGuid;
ObjectGuid mFollowGuid;
float mFollowDist;
float mFollowAngle;
+17 -27
View File
@@ -51,9 +51,6 @@ SmartScript::SmartScript()
mUseTextTimer = false;
mTalkerEntry = 0;
mTemplate = SMARTAI_TEMPLATE_BASIC;
meOrigGUID = 0;
goOrigGUID = 0;
mLastInvoker = 0;
mScriptType = SMART_SCRIPT_TYPE_CREATURE;
isProcessingTimedActionList = false;
}
@@ -79,7 +76,7 @@ void SmartScript::OnReset()
}
}
ProcessEventsFor(SMART_EVENT_RESET);
mLastInvoker = 0;
mLastInvoker.Clear();
}
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
@@ -509,10 +506,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
go->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) != 0);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST:: %s: %u casts spell %u on target %u with castflags %u",
GetLogNameForGuid(me ? me->GetGUID() : go->GetGUID()), me ? me->GetGUIDLow() : go->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
(me ? me->GetGUID() : go->GetGUID()).GetTypeName(), me ? me->GetGUIDLow() : go->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
else
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str());
}
delete targets;
@@ -543,7 +540,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
else
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str());
}
delete targets;
@@ -939,9 +936,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!targets)
break;
instance->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: " UI64FMTD,
e.action.setInstanceData64.field, targets->front()->GetGUID());
instance->SetGuidData(e.action.setInstanceData64.field, targets->front()->GetGUID());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: %s",
e.action.setInstanceData64.field, targets->front()->GetGUID().ToString().c_str());
delete targets;
break;
@@ -1277,13 +1274,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
delete targets;
break;
}
case SMART_ACTION_STORE_VARIABLE_DECIMAL:
{
if (mStoredDecimals.find(e.action.storeVar.id) != mStoredDecimals.end())
mStoredDecimals.erase(e.action.storeVar.id);
mStoredDecimals[e.action.storeVar.id] = e.action.storeVar.number;
break;
}
case SMART_ACTION_STORE_TARGET_LIST:
{
ObjectList* targets = GetTargets(e, unit);
@@ -1568,20 +1558,20 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (IsCreature(*itr))
{
if (!meOrigGUID)
meOrigGUID = me ? me->GetGUID() : 0;
if (!goOrigGUID)
goOrigGUID = go ? go->GetGUID() : 0;
if (!meOrigGUID && me)
meOrigGUID = me->GetGUID();
if (!goOrigGUID && go)
goOrigGUID = go->GetGUID();
go = NULL;
me = (*itr)->ToCreature();
break;
}
else if (IsGameObject(*itr))
{
if (!meOrigGUID)
meOrigGUID = me ? me->GetGUID() : 0;
if (!goOrigGUID)
goOrigGUID = go ? go->GetGUID() : 0;
if (!meOrigGUID && me)
meOrigGUID = me->GetGUID();
if (!goOrigGUID && go)
goOrigGUID = go->GetGUID();
go = (*itr)->ToGameObject();
me = NULL;
break;
@@ -1723,7 +1713,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
unit->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) != 0);
}
else
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId()));
TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*it)->GetGUID().ToString().c_str());
}
}
@@ -2637,7 +2627,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
{
if (me)
{
uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID();
ObjectGuid charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID();
if (!charmerOrOwnerGuid)
charmerOrOwnerGuid = me->GetCreatorGUID();
@@ -197,14 +197,14 @@ class SmartScript
go = o;
}
}
goOrigGUID = 0;
meOrigGUID = 0;
goOrigGUID.Clear();
meOrigGUID.Clear();
}
//TIMED_ACTIONLIST (script type 9 aka script9)
void SetScript9(SmartScriptHolder& e, uint32 entry);
Unit* GetLastInvoker();
uint64 mLastInvoker;
ObjectGuid mLastInvoker;
private:
void IncPhase(int32 p = 1)
@@ -224,14 +224,13 @@ class SmartScript
SmartAIEventList mTimedActionList;
bool isProcessingTimedActionList;
Creature* me;
uint64 meOrigGUID;
ObjectGuid meOrigGUID;
GameObject* go;
uint64 goOrigGUID;
ObjectGuid goOrigGUID;
AreaTriggerEntry const* trigger;
SmartScriptType mScriptType;
uint32 mEventPhase;
std::unordered_map<int32, int32> mStoredDecimals;
uint32 mPathId;
SmartAIEventList mStoredEvents;
std::list<uint32>mRemIDs;
@@ -1055,7 +1055,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_DIE:
case SMART_ACTION_SET_IN_COMBAT_WITH_ZONE:
case SMART_ACTION_SET_ACTIVE:
case SMART_ACTION_STORE_VARIABLE_DECIMAL:
case SMART_ACTION_WP_RESUME:
case SMART_ACTION_KILL_UNIT:
case SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL:
@@ -480,7 +480,7 @@ enum SMART_ACTION
SMART_ACTION_SET_FLY = 60, // 0/1
SMART_ACTION_SET_SWIM = 61, // 0/1
SMART_ACTION_TELEPORT = 62, // mapID,
SMART_ACTION_STORE_VARIABLE_DECIMAL = 63, // varID, number
// 63 unused
SMART_ACTION_STORE_TARGET_LIST = 64, // varID,
SMART_ACTION_WP_RESUME = 65, // none
SMART_ACTION_SET_ORIENTATION = 66, //
@@ -1360,7 +1360,7 @@ struct SmartScriptHolder
typedef std::unordered_map<uint32, WayPoint*> WPPath;
typedef std::list<WorldObject*> ObjectList;
typedef std::list<uint64> GuidList;
class ObjectGuidList
{
ObjectList* m_objectList;
@@ -1393,7 +1393,7 @@ public:
if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr))
m_objectList->push_back(obj);
else
TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr);
TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: %s", itr->ToString().c_str());
}
}
+1 -2
View File
@@ -81,8 +81,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
{
do
{
uint32 guidLow = (*result)[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
ObjectGuid guid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
// Kick if player is online
if (Player* p = ObjectAccessor::FindPlayer(guid))
+30 -30
View File
@@ -504,37 +504,37 @@ void AchievementMgr<Guild>::ResetAchievementCriteria(AchievementCriteriaTypes /*
}
template<class T>
void AchievementMgr<T>::DeleteFromDB(uint32 /*lowguid*/)
void AchievementMgr<T>::DeleteFromDB(ObjectGuid /*guid*/)
{
}
template<>
void AchievementMgr<Player>::DeleteFromDB(uint32 lowguid)
void AchievementMgr<Player>::DeleteFromDB(ObjectGuid guid)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT);
stmt->setUInt32(0, lowguid);
stmt->setUInt32(0, guid.GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
stmt->setUInt32(0, lowguid);
stmt->setUInt32(0, guid.GetCounter());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
template<>
void AchievementMgr<Guild>::DeleteFromDB(uint32 lowguid)
void AchievementMgr<Guild>::DeleteFromDB(ObjectGuid guid)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GUILD_ACHIEVEMENTS);
stmt->setUInt32(0, lowguid);
stmt->setUInt32(0, guid.GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GUILD_ACHIEVEMENT_CRITERIA);
stmt->setUInt32(0, lowguid);
stmt->setUInt32(0, guid.GetCounter());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
@@ -557,11 +557,11 @@ void AchievementMgr<Player>::SaveToDB(SQLTransaction& trans)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT);
stmt->setUInt16(0, iter->first);
stmt->setUInt32(1, GetOwner()->GetGUID());
stmt->setUInt32(1, GetOwner()->GetGUID().GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT);
stmt->setUInt32(0, GetOwner()->GetGUID());
stmt->setUInt32(0, GetOwner()->GetGUID().GetCounter());
stmt->setUInt16(1, iter->first);
stmt->setUInt32(2, uint32(iter->second.date));
trans->Append(stmt);
@@ -578,14 +578,14 @@ void AchievementMgr<Player>::SaveToDB(SQLTransaction& trans)
continue;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA);
stmt->setUInt32(0, GetOwner()->GetGUID());
stmt->setUInt32(0, GetOwner()->GetGUID().GetCounter());
stmt->setUInt16(1, iter->first);
trans->Append(stmt);
if (iter->second.counter)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS);
stmt->setUInt32(0, GetOwner()->GetGUID());
stmt->setUInt32(0, GetOwner()->GetGUID().GetCounter());
stmt->setUInt16(1, iter->first);
stmt->setUInt32(2, iter->second.counter);
stmt->setUInt32(3, uint32(iter->second.date));
@@ -616,8 +616,8 @@ void AchievementMgr<Guild>::SaveToDB(SQLTransaction& trans)
stmt->setUInt32(0, GetOwner()->GetId());
stmt->setUInt16(1, itr->first);
stmt->setUInt32(2, itr->second.date);
for (std::set<uint64>::const_iterator gItr = itr->second.guids.begin(); gItr != itr->second.guids.end(); ++gItr)
guidstr << GUID_LOPART(*gItr) << ',';
for (GuidSet::const_iterator gItr = itr->second.guids.begin(); gItr != itr->second.guids.end(); ++gItr)
guidstr << gItr->GetCounter() << ',';
stmt->setString(3, guidstr.str());
trans->Append(stmt);
@@ -640,7 +640,7 @@ void AchievementMgr<Guild>::SaveToDB(SQLTransaction& trans)
stmt->setUInt16(1, itr->first);
stmt->setUInt64(2, itr->second.counter);
stmt->setUInt32(3, itr->second.date);
stmt->setUInt32(4, GUID_LOPART(itr->second.CompletedGUID));
stmt->setUInt32(4, itr->second.CompletedGUID.GetCounter());
trans->Append(stmt);
}
}
@@ -735,7 +735,7 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
ca.date = time_t(fields[1].GetUInt32());
Tokenizer guids(fields[2].GetString(), ' ');
for (uint32 i = 0; i < guids.size(); ++i)
ca.guids.insert(MAKE_NEW_GUID(atol(guids[i]), 0, HIGHGUID_PLAYER));
ca.guids.insert(ObjectGuid(HIGHGUID_PLAYER, uint32(atol(guids[i]))));
ca.changed = false;
@@ -753,7 +753,7 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
uint32 id = fields[0].GetUInt16();
uint32 counter = fields[1].GetUInt32();
time_t date = time_t(fields[2].GetUInt32());
uint64 guid = fields[3].GetUInt32();
uint32 guid = fields[3].GetUInt32();
AchievementCriteriaEntry const* criteria = sAchievementMgr->GetAchievementCriteria(id);
if (!criteria)
@@ -773,7 +773,7 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
CriteriaProgress& progress = m_criteriaProgress[id];
progress.counter = counter;
progress.date = date;
progress.CompletedGUID = MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER);
progress.CompletedGUID = ObjectGuid(HIGHGUID_PLAYER, guid);
progress.changed = false;
} while (criteriaResult->NextRow());
}
@@ -804,7 +804,7 @@ void AchievementMgr<Player>::Reset()
m_completedAchievements.clear();
_achievementPoints = 0;
m_criteriaProgress.clear();
DeleteFromDB(GetOwner()->GetGUIDLow());
DeleteFromDB(GetOwner()->GetGUID());
// re-fill data
CheckAllAchievementCriteria(GetOwner());
@@ -844,7 +844,7 @@ void AchievementMgr<Guild>::Reset()
_achievementPoints = 0;
m_completedAchievements.clear();
DeleteFromDB(GetOwner()->GetId());
DeleteFromDB(GetOwner()->GetGUID());
}
template<class T>
@@ -883,7 +883,7 @@ void AchievementMgr<T>::SendAchievementEarned(AchievementEntry const* achievemen
}
WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8);
data.append(GetOwner()->GetPackGUID());
data << GetOwner()->GetPackGUID();
data << uint32(achievement->ID);
data.AppendPackedTime(time(NULL));
data << uint32(0); // does not notify player ingame
@@ -933,7 +933,7 @@ void AchievementMgr<Player>::SendCriteriaUpdate(AchievementCriteriaEntry const*
// the counter is packed like a packed Guid
data.appendPackGUID(progress->counter);
data.appendPackGUID(GetOwner()->GetGUID());
data << GetOwner()->GetPackGUID();
if (!entry->timeLimit)
data << uint32(0);
else
@@ -950,7 +950,7 @@ void AchievementMgr<Guild>::SendCriteriaUpdate(AchievementCriteriaEntry const* e
//will send response to criteria progress request
WorldPacket data(SMSG_GUILD_CRITERIA_DATA, 3 + 1 + 1 + 8 + 8 + 4 + 4 + 4 + 4 + 4);
ObjectGuid counter = progress->counter; // for accessing every byte individually
ObjectGuid counter(progress->counter); // for accessing every byte individually
ObjectGuid guid = progress->CompletedGUID;
data.WriteBits(1, 21);
@@ -1047,12 +1047,12 @@ void AchievementMgr<T>::UpdateAchievementCriteria(AchievementCriteriaTypes type,
if (referencePlayer->IsGameMaster())
{
TC_LOG_DEBUG("achievement", "UpdateAchievementCriteria: [Player %s GM mode on] %s, %s (%u), " UI64FMTD ", " UI64FMTD ", " UI64FMTD
, referencePlayer->GetName().c_str(), GetLogNameForGuid(GetOwner()->GetGUID()), AchievementGlobalMgr::GetCriteriaTypeString(type), type, miscValue1, miscValue2, miscValue3);
, referencePlayer->GetName().c_str(), GetOwner()->GetGUID().ToString().c_str(), AchievementGlobalMgr::GetCriteriaTypeString(type), type, miscValue1, miscValue2, miscValue3);
return;
}
TC_LOG_DEBUG("achievement", "UpdateAchievementCriteria: %s, %s (%u), " UI64FMTD ", " UI64FMTD ", " UI64FMTD
, GetLogNameForGuid(GetOwner()->GetGUID()), AchievementGlobalMgr::GetCriteriaTypeString(type), type, miscValue1, miscValue2, miscValue3);
, GetOwner()->GetGUID().ToString().c_str(), AchievementGlobalMgr::GetCriteriaTypeString(type), type, miscValue1, miscValue2, miscValue3);
// Lua_GetGuildLevelEnabled() is checked in achievement UI to display guild tab
if (IsGuild<T>() && !sWorld->getBoolConfig(CONFIG_GUILD_LEVELING_ENABLED))
@@ -1660,8 +1660,8 @@ void AchievementMgr<T>::SetCriteriaProgress(AchievementCriteriaEntry const* entr
if (entry->timeLimit && timedIter == m_timedAchievements.end())
return;
TC_LOG_DEBUG("achievement", "SetCriteriaProgress(%u, " UI64FMTD ") for (%s GUID: %u)",
entry->ID, changeValue, GetLogNameForGuid(GetOwner()->GetGUID()), GUID_LOPART(GetOwner()->GetGUID()));
TC_LOG_DEBUG("achievement", "SetCriteriaProgress(%u, " UI64FMTD ") for (%s)",
entry->ID, changeValue, GetOwner()->GetGUID().ToString().c_str());
CriteriaProgress* progress = GetCriteriaProgress(entry);
if (!progress)
@@ -1899,7 +1899,7 @@ void AchievementMgr<Guild>::CompletedAchievement(AchievementEntry const* achieve
if (achievement->flags & ACHIEVEMENT_FLAG_SHOW_IN_GUILD_NEWS)
if (Guild* guild = referencePlayer->GetGuild())
guild->AddGuildNews(GUILD_NEWS_GUILD_ACHIEVEMENT, 0, achievement->flags & ACHIEVEMENT_FLAG_SHOW_IN_GUILD_HEADER, achievement->ID);
guild->AddGuildNews(GUILD_NEWS_GUILD_ACHIEVEMENT, ObjectGuid::Empty, achievement->flags & ACHIEVEMENT_FLAG_SHOW_IN_GUILD_HEADER, achievement->ID);
SendAchievementEarned(achievement);
CompletedAchievementData& ca = m_completedAchievements[achievement->ID];
@@ -1949,7 +1949,7 @@ void AchievementMgr<T>::SendAllAchievementData(Player* /*receiver*/) const
data.WriteBits(numCriteria, 21);
for (CriteriaProgressMap::const_iterator itr = m_criteriaProgress.begin(); itr != m_criteriaProgress.end(); ++itr)
{
counter = itr->second.counter;
counter.Set(itr->second.counter);
data.WriteBit(guid[4]);
data.WriteBit(counter[3]);
@@ -2052,7 +2052,7 @@ void AchievementMgr<Player>::SendAchievementInfo(Player* receiver, uint32 /*achi
data.WriteBit(guid[2]);
for (CriteriaProgressMap::const_iterator itr = m_criteriaProgress.begin(); itr != m_criteriaProgress.end(); ++itr)
{
counter = itr->second.counter;
counter.Set(itr->second.counter);
data.WriteBit(counter[5]);
data.WriteBit(counter[3]);
@@ -2159,7 +2159,7 @@ void AchievementMgr<Guild>::SendAchievementInfo(Player* receiver, uint32 achieve
if (progress == m_criteriaProgress.end())
continue;
counter = progress->second.counter;
counter.Set(progress->second.counter);
guid = progress->second.CompletedGUID;
criteriaBits.WriteBit(counter[4]);
@@ -26,6 +26,7 @@
#include "DatabaseEnv.h"
#include "DBCEnums.h"
#include "DBCStores.h"
#include "ObjectGuid.h"
class Unit;
class Player;
@@ -41,7 +42,7 @@ struct CriteriaProgress
{
uint64 counter;
time_t date; // latest update time.
uint64 CompletedGUID; // GUID of the player that completed this criteria (guild achievements)
ObjectGuid CompletedGUID; // GUID of the player that completed this criteria (guild achievements)
bool changed;
};
@@ -233,7 +234,7 @@ typedef std::unordered_map<uint32, AchievementRewardLocale> AchievementRewardLoc
struct CompletedAchievementData
{
time_t date;
std::set<uint64> guids;
GuidSet guids;
bool changed;
};
@@ -255,7 +256,7 @@ class AchievementMgr
~AchievementMgr();
void Reset();
static void DeleteFromDB(uint32 lowguid);
static void DeleteFromDB(ObjectGuid lowguid);
void LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult);
void SaveToDB(SQLTransaction& trans);
void ResetAchievementCriteria(AchievementCriteriaTypes type, uint64 miscValue1 = 0, uint64 miscValue2 = 0, bool evenIfCriteriaComplete = false);
@@ -92,7 +92,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
return;
uint32 bidderAccId = 0;
uint64 bidderGuid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
ObjectGuid bidderGuid(HIGHGUID_PLAYER, auction->bidder);
Player* bidder = ObjectAccessor::FindPlayer(bidderGuid);
// data for gm.log
std::string bidderName;
@@ -115,11 +115,12 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
if (logGmTrade)
{
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
std::string ownerName;
if (!sObjectMgr->GetPlayerNameByGUID(auction->owner, ownerName))
if (!sObjectMgr->GetPlayerNameByGUID(ownerGuid, ownerName))
ownerName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
uint32 ownerAccId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner);
uint32 ownerAccId = sObjectMgr->GetPlayerAccountIdByGUID(ownerGuid);
sLog->outCommand(bidderAccId, "GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidderName.c_str(), bidderAccId, pItem->GetTemplate()->Name1.c_str(), pItem->GetEntry(), pItem->GetCount(), auction->bid, ownerName.c_str(), ownerAccId);
@@ -150,7 +151,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTransaction& trans)
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
Player* owner = ObjectAccessor::FindPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist (online or offline)
@@ -162,7 +163,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTrans
//call this method to send mail to auction owner, when auction is successful, it does not clear ram
void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransaction& trans)
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
Player* owner = ObjectAccessor::FindPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
@@ -193,7 +194,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
if (!pItem)
return;
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
Player* owner = ObjectAccessor::FindPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
@@ -211,7 +212,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
//this function sends mail to old bidder
void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 newPrice, Player* newBidder, SQLTransaction& trans)
{
uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
ObjectGuid oldBidder_guid(HIGHGUID_PLAYER, auction->bidder);
Player* oldBidder = ObjectAccessor::FindPlayer(oldBidder_guid);
uint32 oldBidder_accId = 0;
@@ -233,7 +234,7 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new
//this function sends mail, when auction is cancelled to old bidder
void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQLTransaction& trans, Item* item)
{
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player* bidder = ObjectAccessor::FindPlayer(bidder_guid);
uint32 bidder_accId = 0;
@@ -291,7 +292,7 @@ void AuctionHouseMgr::LoadAuctionItems()
}
Item* item = NewItemOrBag(proto);
if (!item->LoadFromDB(item_guid, 0, fields, itemEntry))
if (!item->LoadFromDB(item_guid, ObjectGuid::Empty, fields, itemEntry))
{
delete item;
continue;
@@ -851,7 +852,7 @@ std::string AuctionEntry::BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint3
{
std::ostringstream strm;
strm.width(16);
strm << std::right << std::hex << MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); // HIGHGUID_PLAYER always present, even for empty guids
strm << std::right << std::hex << ObjectGuid(HIGHGUID_PLAYER, lowGuid).GetRawValue(); // HIGHGUID_PLAYER always present, even for empty guids
strm << std::dec << ':' << bid << ':' << buyout;
strm << ':' << deposit << ':' << cut;
return strm.str();
+23 -36
View File
@@ -37,7 +37,6 @@ Battlefield::Battlefield()
m_isActive = false;
m_DefenderTeam = TEAM_NEUTRAL;
m_Guid = 0;
m_TypeId = 0;
m_BattleId = 0;
m_ZoneId = 0;
@@ -57,7 +56,6 @@ Battlefield::Battlefield()
m_LastResurrectTimer = 30 * IN_MILLISECONDS;
m_StartGroupingTimer = 0;
m_StartGrouping = false;
StalkerGuid = 0;
}
Battlefield::~Battlefield()
@@ -300,7 +298,7 @@ void Battlefield::KickAfkPlayers()
KickPlayerFromBattlefield(*itr);
}
void Battlefield::KickPlayerFromBattlefield(uint64 guid)
void Battlefield::KickPlayerFromBattlefield(ObjectGuid guid)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
if (player->GetZoneId() == GetZoneId())
@@ -360,10 +358,7 @@ void Battlefield::DoPlaySoundToAll(uint32 SoundID)
data << uint32(SoundID);
data << uint64(0);
for (int team = 0; team < BG_TEAMS_COUNT; team++)
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SendDirectMessage(&data);
BroadcastPacketToWar(data);
}
bool Battlefield::HasPlayer(Player* player) const
@@ -446,18 +441,10 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
player->SendDirectMessage(&data);
}
void Battlefield::SendWarningToAllInZone(uint32 entry)
void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
{
if (Creature* stalker = GetCreature(StalkerGuid))
// FIXME: replaced CHAT_TYPE_END with CHAT_MSG_BG_SYSTEM_NEUTRAL to fix compile, it's a guessed change :/
sCreatureTextMgr->SendChat(stalker, (uint8) entry, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE);
}
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
{
if (player)
if (Creature* stalker = GetCreature(StalkerGuid))
sCreatureTextMgr->SendChat(stalker, (uint8)entry, player);
sCreatureTextMgr->SendChat(stalker, id, target);
}
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
@@ -503,17 +490,17 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive)
Group* Battlefield::GetFreeBfRaid(TeamId TeamId)
{
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
if (!group->IsFull())
return group;
return NULL;
}
Group* Battlefield::GetGroupPlayer(uint64 guid, TeamId TeamId)
Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId)
{
for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
if (group->IsMember(guid))
return group;
@@ -598,7 +585,7 @@ WorldSafeLocsEntry const* Battlefield::GetClosestGraveYard(Player* player)
return NULL;
}
void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid)
void Battlefield::AddPlayerToResurrectQueue(ObjectGuid npcGuid, ObjectGuid playerGuid)
{
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
@@ -613,7 +600,7 @@ void Battlefield::AddPlayerToResurrectQueue(uint64 npcGuid, uint64 playerGuid)
}
}
void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid)
void Battlefield::RemovePlayerFromResurrectQueue(ObjectGuid playerGuid)
{
for (uint8 i = 0; i < m_GraveyardList.size(); i++)
{
@@ -628,7 +615,7 @@ void Battlefield::RemovePlayerFromResurrectQueue(uint64 playerGuid)
}
}
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, uint64 guid)
void Battlefield::SendAreaSpiritHealerQueryOpcode(Player* player, ObjectGuid guid)
{
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
uint32 time = m_LastResurrectTimer; // resurrect every 30 seconds
@@ -645,8 +632,8 @@ BfGraveyard::BfGraveyard(Battlefield* battlefield)
m_Bf = battlefield;
m_GraveyardId = 0;
m_ControlTeam = TEAM_NEUTRAL;
m_SpiritGuide[0] = 0;
m_SpiritGuide[1] = 0;
m_SpiritGuide[0].Clear();
m_SpiritGuide[1].Clear();
}
void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId)
@@ -673,7 +660,7 @@ float BfGraveyard::GetDistance(Player* player)
return player->GetDistance2d(safeLoc->x, safeLoc->y);
}
void BfGraveyard::AddPlayer(uint64 playerGuid)
void BfGraveyard::AddPlayer(ObjectGuid playerGuid)
{
if (!m_ResurrectQueue.count(playerGuid))
{
@@ -684,7 +671,7 @@ void BfGraveyard::AddPlayer(uint64 playerGuid)
}
}
void BfGraveyard::RemovePlayer(uint64 playerGuid)
void BfGraveyard::RemovePlayer(ObjectGuid playerGuid)
{
m_ResurrectQueue.erase(m_ResurrectQueue.find(playerGuid));
@@ -756,7 +743,7 @@ void BfGraveyard::RelocateDeadPlayers()
}
}
bool BfGraveyard::HasNpc(uint64 guid)
bool BfGraveyard::HasNpc(ObjectGuid guid)
{
if (!m_SpiritGuide[0] || !m_SpiritGuide[1])
return false;
@@ -837,25 +824,25 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
return go;
}
Creature* Battlefield::GetCreature(uint64 GUID)
Creature* Battlefield::GetCreature(ObjectGuid guid)
{
if (!m_Map)
return NULL;
return m_Map->GetCreature(GUID);
return m_Map->GetCreature(guid);
}
GameObject* Battlefield::GetGameObject(uint64 GUID)
GameObject* Battlefield::GetGameObject(ObjectGuid guid)
{
if (!m_Map)
return NULL;
return m_Map->GetGameObject(GUID);
return m_Map->GetGameObject(guid);
}
// *******************************************************
// ******************* CapturePoint **********************
// *******************************************************
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID(0)
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID()
{
m_team = TEAM_NEUTRAL;
m_value = 0;
@@ -920,7 +907,7 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
TC_LOG_DEBUG("bg.battlefield", "Creating capture point %u", capturePoint->GetEntry());
m_capturePointGUID = MAKE_NEW_GUID(capturePoint->GetGUIDLow(), capturePoint->GetEntry(), HIGHGUID_GAMEOBJECT);
m_capturePointGUID = ObjectGuid(HIGHGUID_GAMEOBJECT, capturePoint->GetEntry(), capturePoint->GetGUIDLow());
// check info existence
GameObjectTemplate const* goinfo = capturePoint->GetGOInfo();
@@ -965,7 +952,7 @@ bool BfCapturePoint::DelCapturePoint()
capturePoint->Delete();
capturePoint = NULL;
}
m_capturePointGUID = 0;
m_capturePointGUID.Clear();
}
return true;
@@ -1101,7 +1088,7 @@ void BfCapturePoint::SendUpdateWorldState(uint32 field, uint32 value)
player->SendUpdateWorldState(field, value);
}
void BfCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid)
void BfCapturePoint::SendObjectiveComplete(uint32 id, ObjectGuid guid)
{
uint8 team;
switch (m_State)
+19 -21
View File
@@ -65,9 +65,8 @@ class Unit;
class Battlefield;
class BfGraveyard;
typedef std::set<uint64> GuidSet;
typedef std::vector<BfGraveyard*> GraveyardVect;
typedef std::map<uint64, time_t> PlayerTimerMap;
typedef std::map<ObjectGuid, time_t> PlayerTimerMap;
class BfCapturePoint
{
@@ -82,7 +81,7 @@ class BfCapturePoint
void SendUpdateWorldState(uint32 field, uint32 value);
// Send kill notify to players in the controlling faction
void SendObjectiveComplete(uint32 id, uint64 guid);
void SendObjectiveComplete(uint32 id, ObjectGuid guid);
// Used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player* player);
@@ -133,7 +132,7 @@ class BfCapturePoint
uint32 m_capturePointEntry;
// Gameobject related to that capture point
uint64 m_capturePointGUID;
ObjectGuid m_capturePointGUID;
};
class BfGraveyard
@@ -155,10 +154,10 @@ class BfGraveyard
void SetSpirit(Creature* spirit, TeamId team);
// Add a player to the graveyard
void AddPlayer(uint64 player_guid);
void AddPlayer(ObjectGuid player_guid);
// Remove a player from the graveyard
void RemovePlayer(uint64 player_guid);
void RemovePlayer(ObjectGuid player_guid);
// Resurrect players
void Resurrect();
@@ -167,10 +166,10 @@ class BfGraveyard
void RelocateDeadPlayers();
// Check if this graveyard has a spirit guide
bool HasNpc(uint64 guid);
bool HasNpc(ObjectGuid guid);
// Check if a player is in this graveyard's resurrect queue
bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
bool HasPlayer(ObjectGuid guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
// Get the graveyard's ID.
uint32 GetGraveyardId() const { return m_GraveyardId; }
@@ -178,7 +177,7 @@ class BfGraveyard
protected:
TeamId m_ControlTeam;
uint32 m_GraveyardId;
uint64 m_SpiritGuide[BG_TEAMS_COUNT];
ObjectGuid m_SpiritGuide[BG_TEAMS_COUNT];
GuidSet m_ResurrectQueue;
Battlefield* m_Bf;
};
@@ -223,7 +222,7 @@ class Battlefield : public ZoneScript
uint32 GetTypeId() { return m_TypeId; }
uint32 GetZoneId() { return m_ZoneId; }
uint64 GetGUID() { return m_Guid; }
ObjectGuid GetGUID() { return m_Guid; }
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
@@ -239,7 +238,7 @@ class Battlefield : public ZoneScript
* \brief Kick player from battlefield and teleport him to kick-point location
* \param guid : guid of player who must be kick
*/
void KickPlayerFromBattlefield(uint64 guid);
void KickPlayerFromBattlefield(ObjectGuid guid);
/// Called when player (player) enter in zone
void HandlePlayerEnterZone(Player* player, uint32 zone);
@@ -268,7 +267,7 @@ class Battlefield : public ZoneScript
*/
Group* GetFreeBfRaid(TeamId TeamId);
/// Return battlefield group where player is.
Group* GetGroupPlayer(uint64 guid, TeamId TeamId);
Group* GetGroupPlayer(ObjectGuid guid, TeamId TeamId);
/// Force player to join a battlefield group
bool AddOrSetPlayerToCorrectBfGroup(Player* player);
@@ -276,8 +275,8 @@ class Battlefield : public ZoneScript
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid);
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid);
void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); }
BfGraveyard* GetGraveyardById(uint32 id) const;
@@ -286,8 +285,8 @@ class Battlefield : public ZoneScript
Creature* SpawnCreature(uint32 entry, Position const& pos, TeamId /*teamId*/);
GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o);
Creature* GetCreature(uint64 GUID);
GameObject* GetGameObject(uint64 GUID);
Creature* GetCreature(ObjectGuid guid);
GameObject* GetGameObject(ObjectGuid guid);
// Script-methods
@@ -306,8 +305,7 @@ class Battlefield : public ZoneScript
/// Called when a player enter in battlefield zone
virtual void OnPlayerEnterZone(Player* /*player*/) { }
void SendWarningToAllInZone(uint32 entry);
void SendWarningToPlayer(Player* player, uint32 entry);
void SendWarning(uint8 id, WorldObject const* target = nullptr);
void PlayerAcceptInviteToQueue(Player* player);
void PlayerAcceptInviteToWar(Player* player);
@@ -323,7 +321,7 @@ class Battlefield : public ZoneScript
/// Return if we can use mount in battlefield
bool CanFlyIn() { return !m_isActive; }
void SendAreaSpiritHealerQueryOpcode(Player* player, uint64 guid);
void SendAreaSpiritHealerQueryOpcode(Player* player, ObjectGuid guid);
void StartBattle();
void EndBattle(bool endByTimer);
@@ -344,9 +342,9 @@ class Battlefield : public ZoneScript
void InitStalker(uint32 entry, Position const& pos);
protected:
uint64 m_Guid;
ObjectGuid m_Guid;
uint64 StalkerGuid;
ObjectGuid StalkerGuid;
uint32 m_Timer; // Global timer for event
bool m_IsEnabled;
bool m_isActive;
@@ -123,7 +123,7 @@ Battlefield* BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleId)
return NULL;
}
Battlefield* BattlefieldMgr::GetBattlefieldByGUID(uint64 guid)
Battlefield* BattlefieldMgr::GetBattlefieldByGUID(ObjectGuid guid)
{
for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
if ((*itr)->GetGUID() == guid)
+1 -1
View File
@@ -44,7 +44,7 @@ class BattlefieldMgr
// return assigned battlefield
Battlefield* GetBattlefieldToZoneId(uint32 zoneId);
Battlefield* GetBattlefieldByBattleId(uint32 battleId);
Battlefield* GetBattlefieldByGUID(uint64 guid);
Battlefield* GetBattlefieldByGUID(ObjectGuid guid);
ZoneScript* GetZoneScript(uint32 zoneId);
@@ -268,7 +268,7 @@ void BattlefieldWG::OnBattleStart()
// Initialize vehicle counter
UpdateCounterVehicle(true);
// Send start warning to all players
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_START);
SendWarning(BATTLEFIELD_WG_TEXT_START);
}
void BattlefieldWG::UpdateCounterVehicle(bool init)
@@ -301,7 +301,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
if (m_titansRelicGUID)
if (GameObject* relic = GetGameObject(m_titansRelicGUID))
relic->RemoveFromWorld();
m_titansRelicGUID = 0;
m_titansRelicGUID.Clear();
// Remove turret
for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
@@ -409,9 +409,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
}
if (!endByTimer) // win alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : BATTLEFIELD_WG_TEXT_WIN_KEEP + 1);
SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_WIN_KEEP : BATTLEFIELD_WG_TEXT_WIN_KEEP + 1);
else // defend alli/horde
SendWarningToAllInZone((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 1);
SendWarning((GetDefenderTeam() == TEAM_ALLIANCE) ? BATTLEFIELD_WG_TEXT_DEFEND_KEEP : BATTLEFIELD_WG_TEXT_DEFEND_KEEP + 1);
}
// *******************************************************
@@ -442,7 +442,7 @@ void BattlefieldWG::DoCompleteOrIncrementAchievement(uint32 achievement, Player*
void BattlefieldWG::OnStartGrouping()
{
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START);
SendWarning(BATTLEFIELD_WG_TEXT_WILL_START);
}
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const
@@ -689,7 +689,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_RECRUIT);
killer->CastSpell(killer, SPELL_CORPORAL, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_FIRSTRANK);
SendWarning(BATTLEFIELD_WG_TEXT_FIRSTRANK, killer);
}
else
killer->CastSpell(killer, SPELL_RECRUIT, true);
@@ -700,7 +700,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
{
killer->RemoveAura(SPELL_CORPORAL);
killer->CastSpell(killer, SPELL_LIEUTENANT, true);
SendWarningToPlayer(killer, BATTLEFIELD_WG_TEXT_SECONDRANK);
SendWarning(BATTLEFIELD_WG_TEXT_SECONDRANK, killer);
}
else
killer->CastSpell(killer, SPELL_CORPORAL, true);
@@ -1065,7 +1065,6 @@ BfWGGameObjectBuilding::BfWGGameObjectBuilding(BattlefieldWG* wg)
{
m_WG = wg;
m_Team = 0;
m_BuildGUID = 0;
m_Type = 0;
m_WorldState = 0;
m_State = 0;
@@ -1117,13 +1116,13 @@ void BfWGGameObjectBuilding::Damaged()
// Send warning message
if (m_NameId) // tower damage + name
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
for (uint64 guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
for (ObjectGuid guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
for (uint64 guid : m_TurretTopList)
for (ObjectGuid guid : m_TurretTopList)
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
@@ -1141,7 +1140,7 @@ void BfWGGameObjectBuilding::Destroyed()
// Warn players
if (m_NameId)
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
switch (m_Type)
{
@@ -1331,34 +1330,34 @@ void BfWGGameObjectBuilding::Init(GameObject* go, uint32 type, uint32 worldstate
void BfWGGameObjectBuilding::UpdateCreatureAndGo()
{
for (uint64 guid : m_CreatureTopList[m_WG->GetDefenderTeam()])
for (ObjectGuid guid : m_CreatureTopList[m_WG->GetDefenderTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
for (uint64 guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
for (ObjectGuid guid : m_CreatureTopList[m_WG->GetAttackerTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->ShowNpc(creature, true);
for (uint64 guid : m_CreatureBottomList[m_WG->GetDefenderTeam()])
for (ObjectGuid guid : m_CreatureBottomList[m_WG->GetDefenderTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
for (uint64 guid : m_CreatureBottomList[m_WG->GetAttackerTeam()])
for (ObjectGuid guid : m_CreatureBottomList[m_WG->GetAttackerTeam()])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->ShowNpc(creature, true);
for (uint64 guid : m_GameObjectList[m_WG->GetDefenderTeam()])
for (ObjectGuid guid : m_GameObjectList[m_WG->GetDefenderTeam()])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_ONE_DAY);
for (uint64 guid : m_GameObjectList[m_WG->GetAttackerTeam()])
for (ObjectGuid guid : m_GameObjectList[m_WG->GetAttackerTeam()])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
}
void BfWGGameObjectBuilding::UpdateTurretAttack(bool disable)
{
for (uint64 guid : m_TowerCannonBottomList)
for (ObjectGuid guid : m_TowerCannonBottomList)
{
if (Creature* creature = m_WG->GetCreature(guid))
{
@@ -1391,7 +1390,7 @@ void BfWGGameObjectBuilding::UpdateTurretAttack(bool disable)
}
}
for (uint64 guid : m_TurretTopList)
for (ObjectGuid guid : m_TurretTopList)
{
if (Creature* creature = m_WG->GetCreature(guid))
{
@@ -1448,7 +1447,7 @@ void WGWorkshop::GiveControlTo(uint8 team, bool init)
{
// Send warning message to all player to inform a faction attack to a workshop
// alliance / horde attacking a workshop
bf->SendWarningToAllInZone(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
bf->SendWarning(teamControl ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
break;
}
case BATTLEFIELD_WG_TEAM_ALLIANCE:
@@ -1460,7 +1459,7 @@ void WGWorkshop::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - alliance
bf->SendWarningToAllInZone(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
bf->SendWarning(team == BATTLEFIELD_WG_TEAM_ALLIANCE ? WorkshopsData[workshopId].text : WorkshopsData[workshopId].text + 1);
// Found associate graveyard and update it
if (workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -1492,7 +1491,6 @@ void WGWorkshop::Save()
WintergraspWorkshopData::WintergraspWorkshopData(BattlefieldWG* wg)
{
m_WG = wg;
m_BuildGUID = 0;
m_Type = 0;
m_State = 0;
m_WorldState = 0;
@@ -1532,28 +1530,28 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
{
// Send warning message to all player for inform a faction attack a workshop
// alliance / horde attacking workshop
m_WG->SendWarningToAllInZone(m_TeamControl ? m_NameId : m_NameId + 1);
m_WG->SendWarning(m_TeamControl ? m_NameId : m_NameId + 1);
break;
}
case BATTLEFIELD_WG_TEAM_ALLIANCE:
{
// Show Alliance creature
for (uint64 guid : m_CreatureOnPoint[TEAM_ALLIANCE])
for (ObjectGuid guid : m_CreatureOnPoint[TEAM_ALLIANCE])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->ShowNpc(creature, creature->GetEntry() != 30499);
// Hide Horde creature
for (uint64 guid : m_CreatureOnPoint[TEAM_HORDE])
for (ObjectGuid guid : m_CreatureOnPoint[TEAM_HORDE])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
// Show Alliance gameobject
for (uint64 guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
for (ObjectGuid guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
// Hide Horde gameobject
for (uint64 guid : m_GameObjectOnPoint[TEAM_HORDE])
for (ObjectGuid guid : m_GameObjectOnPoint[TEAM_HORDE])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_ONE_DAY);
@@ -1564,7 +1562,7 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - alliance
m_WG->SendWarningToAllInZone(m_NameId);
m_WG->SendWarning(m_NameId);
// Found associate graveyard and update it
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -1577,22 +1575,22 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
case BATTLEFIELD_WG_TEAM_HORDE:
{
// Show Horde creature
for (uint64 guid : m_CreatureOnPoint[TEAM_HORDE])
for (ObjectGuid guid : m_CreatureOnPoint[TEAM_HORDE])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->ShowNpc(creature, creature->GetEntry() != 30400);
// Hide Alliance creature
for (uint64 guid : m_CreatureOnPoint[TEAM_ALLIANCE])
for (ObjectGuid guid : m_CreatureOnPoint[TEAM_ALLIANCE])
if (Creature* creature = m_WG->GetCreature(guid))
m_WG->HideNpc(creature);
// Hide Alliance gameobject
for (uint64 guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
for (ObjectGuid guid : m_GameObjectOnPoint[TEAM_ALLIANCE])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_ONE_DAY);
// Show Horde gameobject
for (uint64 guid : m_GameObjectOnPoint[TEAM_HORDE])
for (ObjectGuid guid : m_GameObjectOnPoint[TEAM_HORDE])
if (GameObject* object = m_WG->GetGameObject(guid))
object->SetRespawnTime(RESPAWN_IMMEDIATELY);
@@ -1602,7 +1600,7 @@ void WintergraspWorkshopData::GiveControlTo(uint8 team, bool init)
// Warning message
if (!init) // workshop taken - horde
m_WG->SendWarningToAllInZone(m_NameId + 1);
m_WG->SendWarning(m_NameId + 1);
// Update graveyard control
if (m_Type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
@@ -383,7 +383,7 @@ class BattlefieldWG : public Battlefield
GameObject* GetRelic() { return GetGameObject(m_titansRelicGUID); }
/// Define relic object
void SetRelic(uint64 relicGUID) { m_titansRelicGUID = relicGUID; }
void SetRelic(ObjectGuid relicGUID) { m_titansRelicGUID = relicGUID; }
/// Check if players can interact with the relic (Only if the last door has been broken)
bool CanInteractWithRelic() { return m_isRelicInteractible; }
@@ -429,7 +429,7 @@ class BattlefieldWG : public Battlefield
uint32 m_tenacityStack;
uint32 m_saveTimer;
uint64 m_titansRelicGUID;
ObjectGuid m_titansRelicGUID;
};
uint32 const VehNumWorldState[] = { 3680, 3490 };
@@ -578,7 +578,7 @@ struct WintergraspBuildingSpawnData
struct WintergraspRebuildableBuildingData
{
uint64 Guid;
ObjectGuid Guid;
uint32 entry;
uint32 WorldState;
float x;
@@ -1068,7 +1068,7 @@ struct BfWGGameObjectBuilding
BattlefieldWG* m_WG;
// Linked gameobject
uint64 m_BuildGUID;
ObjectGuid m_BuildGUID;
// eWGGameObjectBuildingType
uint32 m_Type;
@@ -1132,7 +1132,7 @@ struct WGWorkshop
struct WintergraspWorkshopData
{
BattlefieldWG* m_WG; // Pointer to wintergrasp
uint64 m_BuildGUID;
ObjectGuid m_BuildGUID;
uint32 m_Type;
uint32 m_State; // For worldstate
uint32 m_WorldState;
+3 -3
View File
@@ -62,7 +62,7 @@ void Arena::AddPlayer(Player* player)
UpdateArenaWorldState();
}
void Arena::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
void Arena::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
@@ -94,7 +94,7 @@ void Arena::HandleKillPlayer(Player* player, Player* killer)
CheckWinConditions();
}
void Arena::RemovePlayerAtLeave(uint64 guid, bool transport, bool sendPacket)
void Arena::RemovePlayerAtLeave(ObjectGuid guid, bool transport, bool sendPacket)
{
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
{
@@ -180,7 +180,7 @@ void Arena::EndBattleground(uint32 winner)
if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
for (auto const& score : PlayerScores)
if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(score.first, 0, HIGHGUID_PLAYER)))
if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, score.first)))
{
TC_LOG_DEBUG("bg.arena", "Statistics match Type: %u for %s (GUID: %u, Team: %d, IP: %s): %s",
GetArenaType(), player->GetName().c_str(), score.first, player->GetArenaTeamId(GetArenaType() == 5 ? 2 : GetArenaType() == 3),
+2 -2
View File
@@ -42,7 +42,7 @@ class Arena : public Battleground
Arena();
void AddPlayer(Player* player) override;
void RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) override;
void RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) override;
void FillInitialWorldStates(WorldPacket& data) override;
void UpdateArenaWorldState();
@@ -50,7 +50,7 @@ class Arena : public Battleground
void HandleKillPlayer(Player* player, Player* killer) override;
private:
void RemovePlayerAtLeave(uint64 guid, bool transport, bool sendPacket) override;
void RemovePlayerAtLeave(ObjectGuid guid, bool transport, bool sendPacket) override;
void CheckWinConditions() override;
void EndBattleground(uint32 winner) override;
};
+1 -1
View File
@@ -28,7 +28,7 @@ struct ArenaScore : public BattlegroundScore
friend class Arena;
protected:
ArenaScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), TeamId(team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE) { }
ArenaScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), TeamId(team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE) { }
void AppendToPacket(WorldPacket& data, ByteBuffer& content) final override
{
+29 -31
View File
@@ -17,17 +17,17 @@
*/
#include "ObjectMgr.h"
#include "Player.h"
#include "WorldPacket.h"
#include "ArenaTeam.h"
#include "World.h"
#include "Group.h"
#include "ArenaTeamMgr.h"
#include "Player.h"
#include "WorldSession.h"
#include "Opcodes.h"
ArenaTeam::ArenaTeam()
: TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
: TeamId(0), Type(0), TeamName(), CaptainGuid(), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
BorderStyle(0), BorderColor(0)
{
Stats.WeekGames = 0;
@@ -41,16 +41,14 @@ ArenaTeam::ArenaTeam()
ArenaTeam::~ArenaTeam()
{ }
bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& arenaTeamName,
uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor,
uint8 borderStyle, uint32 borderColor)
bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
{
// Check if captain is present
if (!ObjectAccessor::FindPlayer(captainGuid))
return false;
// Check if arena team name is already taken
if (sArenaTeamMgr->GetArenaTeamByName(arenaTeamName))
if (sArenaTeamMgr->GetArenaTeamByName(teamName))
return false;
// Generate new arena team id
@@ -59,13 +57,13 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& arenaT
// Assign member variables
CaptainGuid = captainGuid;
Type = type;
TeamName = arenaTeamName;
TeamName = teamName;
BackgroundColor = backgroundColor;
EmblemStyle = emblemStyle;
EmblemColor = emblemColor;
BorderStyle = borderStyle;
BorderColor = borderColor;
uint32 captainLowGuid = GUID_LOPART(captainGuid);
uint32 captainLowGuid = captainGuid.GetCounter();
// Save arena team to db
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM);
@@ -88,7 +86,7 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& arenaT
return true;
}
bool ArenaTeam::AddMember(uint64 playerGuid)
bool ArenaTeam::AddMember(ObjectGuid playerGuid)
{
std::string playerName;
uint8 playerClass;
@@ -109,7 +107,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
// 0 1
// SELECT name, class FROM characters WHERE guid = ?
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_CLASS);
stmt->setUInt32(0, GUID_LOPART(playerGuid));
stmt->setUInt32(0, playerGuid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
@@ -122,7 +120,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
// Check if player is already in a similar arena team
if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
{
TC_LOG_DEBUG("bg.arena", "Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType());
TC_LOG_DEBUG("bg.arena", "Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), playerGuid.GetCounter(), GetType());
return false;
}
@@ -136,7 +134,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
// Try to get player's match maker rating from db and fall back to config setting if not found
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING);
stmt->setUInt32(0, GUID_LOPART(playerGuid));
stmt->setUInt32(0, playerGuid.GetCounter());
stmt->setUInt8(1, GetSlot());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -167,7 +165,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
// Save player's arena team membership to db
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER);
stmt->setUInt32(0, TeamId);
stmt->setUInt32(1, GUID_LOPART(playerGuid));
stmt->setUInt32(1, playerGuid.GetCounter());
CharacterDatabase.Execute(stmt);
// Inform player if online
@@ -181,7 +179,7 @@ bool ArenaTeam::AddMember(uint64 playerGuid)
player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
}
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), GUID_LOPART(playerGuid), GetType(), GetId(), GetName().c_str());
TC_LOG_INFO("bg.arena", "Player: %s [GUID: %u] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), playerGuid.GetCounter(), GetType(), GetId(), GetName().c_str());
return true;
}
@@ -195,7 +193,7 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult result)
TeamId = fields[0].GetUInt32();
TeamName = fields[1].GetString();
CaptainGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
CaptainGuid = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
Type = fields[3].GetUInt8();
BackgroundColor = fields[4].GetUInt32();
EmblemStyle = fields[5].GetUInt8();
@@ -234,7 +232,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
break;
ArenaTeamMember newMember;
newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
newMember.Guid = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32());
newMember.WeekGames = fields[2].GetUInt16();
newMember.WeekWins = fields[3].GetUInt16();
newMember.SeasonGames = fields[4].GetUInt16();
@@ -247,7 +245,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
// Delete member if character information is missing
if (newMember.Name.empty())
{
TC_LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newMember.Guid));
TC_LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.GetCounter());
DelMember(newMember.Guid, true);
continue;
}
@@ -284,7 +282,7 @@ bool ArenaTeam::SetName(std::string const& name)
return true;
}
void ArenaTeam::SetCaptain(uint64 guid)
void ArenaTeam::SetCaptain(ObjectGuid guid)
{
// Disable remove/promote buttons
Player* oldCaptain = ObjectAccessor::FindPlayer(GetCaptain());
@@ -296,7 +294,7 @@ void ArenaTeam::SetCaptain(uint64 guid)
// Update database
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN);
stmt->setUInt32(0, GUID_LOPART(guid));
stmt->setUInt32(0, guid.GetCounter());
stmt->setUInt32(1, GetId());
CharacterDatabase.Execute(stmt);
@@ -313,7 +311,7 @@ void ArenaTeam::SetCaptain(uint64 guid)
}
}
void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb)
{
// Remove member from team
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
@@ -337,7 +335,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBER);
stmt->setUInt32(0, GetId());
stmt->setUInt32(1, GUID_LOPART(guid));
stmt->setUInt32(1, guid.GetCounter());
CharacterDatabase.Execute(stmt);
}
}
@@ -347,7 +345,7 @@ void ArenaTeam::Disband(WorldSession* session)
// Broadcast update
if (session)
{
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), "");
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, ObjectGuid::Empty, 2, session->GetPlayerName(), GetName(), "");
if (Player* player = session->GetPlayer())
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId(), GetName().c_str());
}
@@ -471,7 +469,7 @@ void ArenaTeam::NotifyStatsChanged()
SendStats(player->GetSession());
}
void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
void ArenaTeam::Inspect(WorldSession* session, ObjectGuid guid)
{
ArenaTeamMember* member = GetMember(guid);
if (!member)
@@ -518,7 +516,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket* packet)
player->GetSession()->SendPacket(packet);
}
void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3)
void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3)
{
WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1+1+1);
data << uint8(event);
@@ -558,7 +556,7 @@ void ArenaTeam::MassInviteToEvent(WorldSession* session)
{
if (itr->Guid != session->GetPlayer()->GetGUID())
{
data.appendPackGUID(itr->Guid);
data << itr->Guid.WriteAsPacked();
data << uint8(0); // unk
}
}
@@ -594,7 +592,7 @@ uint8 ArenaTeam::GetTypeBySlot(uint8 slot)
return 0xFF;
}
bool ArenaTeam::IsMember(uint64 guid) const
bool ArenaTeam::IsMember(ObjectGuid guid) const
{
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
if (itr->Guid == guid)
@@ -781,7 +779,7 @@ void ArenaTeam::MemberLost(Player* player, uint32 againstMatchmakerRating, int32
}
}
void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 matchmakerRatingChange)
void ArenaTeam::OfflineMemberLost(ObjectGuid guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
{
// Called for offline player after ending rated arena match!
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
@@ -793,7 +791,7 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, i
itr->ModifyPersonalRating(NULL, mod, GetType());
// update matchmaker rating
itr->ModifyMatchmakerRating(matchmakerRatingChange, GetSlot());
itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot());
// update personal played stats
itr->WeekGames += 1;
@@ -856,11 +854,11 @@ void ArenaTeam::SaveToDB()
stmt->setUInt16(3, itr->SeasonGames);
stmt->setUInt16(4, itr->SeasonWins);
stmt->setUInt32(5, GetId());
stmt->setUInt32(6, GUID_LOPART(itr->Guid));
stmt->setUInt32(6, itr->Guid.GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHARACTER_ARENA_STATS);
stmt->setUInt32(0, GUID_LOPART(itr->Guid));
stmt->setUInt32(0, itr->Guid.GetCounter());
stmt->setUInt8(1, GetSlot());
stmt->setUInt16(2, itr->MatchMakerRating);
trans->Append(stmt);
@@ -902,7 +900,7 @@ ArenaTeamMember* ArenaTeam::GetMember(const std::string& name)
return NULL;
}
ArenaTeamMember* ArenaTeam::GetMember(uint64 guid)
ArenaTeamMember* ArenaTeam::GetMember(ObjectGuid guid)
{
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
if (itr->Guid == guid)
+22 -21
View File
@@ -21,6 +21,7 @@
#include "Define.h"
#include "QueryResult.h"
#include "ObjectGuid.h"
#include <list>
#include <string>
#include <map>
@@ -82,7 +83,7 @@ enum ArenaTeamTypes
struct ArenaTeamMember
{
uint64 Guid;
ObjectGuid Guid;
std::string Name;
uint8 Class;
uint16 WeekGames;
@@ -114,9 +115,7 @@ class ArenaTeam
ArenaTeam();
~ArenaTeam();
bool Create(uint64 captainGuid, uint8 type, std::string const& teamName,
uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor,
uint8 borderStyle, uint32 borderColor);
bool Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
void Disband(WorldSession* session);
void Disband();
@@ -127,25 +126,25 @@ class ArenaTeam
uint8 GetSlot() const { return GetSlotByType(GetType()); }
static uint8 GetSlotByType(uint32 type);
static uint8 GetTypeBySlot(uint8 slot);
uint64 GetCaptain() const { return CaptainGuid; }
ObjectGuid GetCaptain() const { return CaptainGuid; }
std::string const& GetName() const { return TeamName; }
const ArenaTeamStats& GetStats() const { return Stats; }
uint32 GetRating() const { return Stats.Rating; }
uint32 GetAverageMMR(Group* group) const;
void SetCaptain(uint64 guid);
void SetCaptain(ObjectGuid guid);
bool SetName(std::string const& name);
bool AddMember(uint64 PlayerGuid);
void DelMember(uint64 guid, bool cleanDb);
bool AddMember(ObjectGuid PlayerGuid);
void DelMember(ObjectGuid guid, bool cleanDb);
size_t GetMembersSize() const { return Members.size(); }
bool Empty() const { return Members.empty(); }
MemberList::iterator m_membersBegin() { return Members.begin(); }
MemberList::iterator m_membersEnd() { return Members.end(); }
bool IsMember(uint64 guid) const;
bool IsMember(ObjectGuid guid) const;
ArenaTeamMember* GetMember(uint64 guid);
ArenaTeamMember* GetMember(ObjectGuid guid);
ArenaTeamMember* GetMember(std::string const& name);
bool IsFighting() const;
@@ -156,7 +155,7 @@ class ArenaTeam
void SaveToDB();
void BroadcastPacket(WorldPacket* packet);
void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3);
void BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3);
void NotifyStatsChanged();
void MassInviteToEvent(WorldSession* session);
@@ -164,18 +163,20 @@ class ArenaTeam
void Roster(WorldSession* session);
void Query(WorldSession* session);
void SendStats(WorldSession* session);
void Inspect(WorldSession* session, uint64 guid);
void Inspect(WorldSession* session, ObjectGuid guid);
uint32 GetPoints(uint32 MemberRating);
int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating);
int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
void MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange);
int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
void OfflineMemberLost(ObjectGuid guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
static int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
static int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
static float GetChanceAgainst(uint32 ownRating, uint32 opponentRating);
int32 WonAgainst(uint32 ownMMRating, uint32 opponentMMRating, int32& rating_change);
void MemberWon(Player* player, uint32 againstMatchmakerRating, int32 matchmakerRatingChange = 12);
int32 LostAgainst(uint32 ownMMRating, uint32 opponentMMRating, int32& rating_change);
void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 matchmakerRatingChange = -12);
void OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 matchmakerRatingChange = -12);
void FinishWeek();
void FinishGame(int32 mod);
@@ -185,7 +186,7 @@ class ArenaTeam
uint32 TeamId;
uint8 Type;
std::string TeamName;
uint64 CaptainGuid;
ObjectGuid CaptainGuid;
uint32 BackgroundColor; // ARGB format
uint8 EmblemStyle; // icon id
@@ -59,7 +59,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByName(const std::string& arenaTeamName) co
return NULL;
}
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(ObjectGuid guid) const
{
for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
if (itr->second->GetCaptain() == guid)
+1 -1
View File
@@ -37,7 +37,7 @@ public:
ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const;
ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName) const;
ArenaTeam* GetArenaTeamByCaptain(uint64 guid) const;
ArenaTeam* GetArenaTeamByCaptain(ObjectGuid guid) const;
void LoadArenaTeams();
void AddArenaTeam(ArenaTeam* arenaTeam);
+50 -60
View File
@@ -43,7 +43,7 @@ namespace Trinity
class BattlegroundChatBuilder
{
public:
BattlegroundChatBuilder(ChatMsg msgtype, int32 textId, Player const* source, va_list* args = NULL)
BattlegroundChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, va_list* args = NULL)
: _msgtype(msgtype), _textId(textId), _source(source), _args(args) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
@@ -72,7 +72,7 @@ namespace Trinity
}
ChatMsg _msgtype;
int32 _textId;
uint32 _textId;
Player const* _source;
va_list* _args;
};
@@ -80,7 +80,7 @@ namespace Trinity
class Battleground2ChatBuilder
{
public:
Battleground2ChatBuilder(ChatMsg msgtype, int32 textId, Player const* source, int32 arg1, int32 arg2)
Battleground2ChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, uint32 arg1, uint32 arg2)
: _msgtype(msgtype), _textId(textId), _source(source), _arg1(arg1), _arg2(arg2) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
@@ -97,10 +97,10 @@ namespace Trinity
private:
ChatMsg _msgtype;
int32 _textId;
uint32 _textId;
Player const* _source;
int32 _arg1;
int32 _arg2;
uint32 _arg1;
uint32 _arg2;
};
} // namespace Trinity
@@ -114,7 +114,6 @@ void Battleground::BroadcastWorker(Do& _do)
Battleground::Battleground()
{
m_Guid = 0;
m_TypeID = BATTLEGROUND_TYPE_NONE;
m_RandomTypeID = BATTLEGROUND_TYPE_NONE;
m_InstanceID = 0;
@@ -137,7 +136,6 @@ Battleground::Battleground()
m_IsRated = false;
m_BuffChange = false;
m_IsRandom = false;
m_Name = "";
m_LevelMin = 0;
m_LevelMax = 0;
m_InBGFreeSlotQueue = false;
@@ -335,10 +333,10 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
{
if (GetReviveQueueSize())
{
for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
{
Creature* sh = NULL;
for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
for (GuidVector::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
{
Player* player = ObjectAccessor::FindPlayer(*itr2);
if (!player)
@@ -369,7 +367,7 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
}
else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
{
for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
for (GuidVector::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
if (!player)
@@ -595,7 +593,7 @@ inline void Battleground::_ProcessLeave(uint32 diff)
}
}
Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, char const* context) const
Player* Battleground::_GetPlayer(ObjectGuid guid, bool offlineRemove, char const* context) const
{
Player* player = NULL;
if (!offlineRemove)
@@ -603,7 +601,7 @@ Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, char const* co
player = ObjectAccessor::FindPlayer(guid);
if (!player)
TC_LOG_ERROR("bg.battleground", "Battleground::%s: player (GUID: %u) not found for BG (map: %u, instance id: %u)!",
context, GUID_LOPART(guid), m_MapId, m_InstanceID);
context, guid.GetCounter(), m_MapId, m_InstanceID);
}
return player;
}
@@ -655,7 +653,7 @@ void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player*
void Battleground::SendChatMessage(Creature* source, uint8 textId, WorldObject* target /*= NULL*/)
{
sCreatureTextMgr->SendChat(source, textId, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_MAP);
sCreatureTextMgr->SendChat(source, textId, target);
}
void Battleground::PlaySoundToAll(uint32 SoundID)
@@ -904,7 +902,7 @@ void Battleground::BlockMovement(Player* player)
player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
}
void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket)
{
uint32 team = GetPlayerTeam(guid);
bool participant = false;
@@ -918,7 +916,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
participant = true;
}
BattlegroundScoreMap::iterator itr2 = PlayerScores.find(GUID_LOPART(guid));
BattlegroundScoreMap::iterator itr2 = PlayerScores.find(guid.GetCounter());
if (itr2 != PlayerScores.end())
{
delete itr2->second; // delete player's score
@@ -1069,7 +1067,6 @@ void Battleground::AddPlayer(Player* player)
// score struct must be created in inherited class
uint64 guid = player->GetGUID();
uint32 team = player->GetBGTeam();
int32 primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec());
@@ -1079,7 +1076,7 @@ void Battleground::AddPlayer(Player* player)
bp.PrimaryTree = primaryTree;
// Add to list/maps
m_Players[guid] = bp;
m_Players[player->GetGUID()] = bp;
UpdatePlayersCountByTeam(team, false); // +1 player
@@ -1144,7 +1141,7 @@ void Battleground::AddPlayer(Player* player)
// this method adds player to his team's bg group, or sets his correct group if player is already in bg group
void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team)
{
uint64 playerGuid = player->GetGUID();
ObjectGuid playerGuid = player->GetGUID();
Group* group = GetBgRaid(team);
if (!group) // first player joined
{
@@ -1175,9 +1172,9 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team)
// This method should be called when player logs into running battleground
void Battleground::EventPlayerLoggedIn(Player* player)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
// player is correct pointer
for (std::deque<uint64>::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr)
for (GuidDeque::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr)
{
if (*itr == guid)
{
@@ -1194,7 +1191,7 @@ void Battleground::EventPlayerLoggedIn(Player* player)
// This method should be called when player logs out from running battleground
void Battleground::EventPlayerLoggedOut(Player* player)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsPlayerInBattleground(guid)) // Check if this player really is in battleground (might be a GM who teleported inside)
return;
@@ -1358,7 +1355,7 @@ bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value,
return true;
}
void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
void Battleground::AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid)
{
m_ReviveQueue[npc_guid].push_back(player_guid);
@@ -1369,15 +1366,15 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid
player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
}
void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid)
void Battleground::RemovePlayerFromResurrectQueue(ObjectGuid player_guid)
{
for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
{
for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
{
if (*itr2 == player_guid)
{
(itr->second).erase(itr2);
itr->second.erase(itr2);
if (Player* player = ObjectAccessor::FindPlayer(player_guid))
player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
return;
@@ -1386,14 +1383,14 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid)
}
}
void Battleground::RelocateDeadPlayers(uint64 queueIndex)
void Battleground::RelocateDeadPlayers(ObjectGuid guideGuid)
{
// Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex];
GuidVector& ghostList = m_ReviveQueue[guideGuid];
if (!ghostList.empty())
{
WorldSafeLocsEntry const* closestGrave = NULL;
for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr)
for (GuidVector::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
if (!player)
@@ -1482,7 +1479,7 @@ void Battleground::DoorClose(uint32 type)
}
else
TC_LOG_ERROR("bg.battleground", "Battleground::DoorClose: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID);
}
void Battleground::DoorOpen(uint32 type)
@@ -1494,7 +1491,7 @@ void Battleground::DoorOpen(uint32 type)
}
else
TC_LOG_ERROR("bg.battleground", "Battleground::DoorOpen: door gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID);
}
GameObject* Battleground::GetBGObject(uint32 type, bool logError)
@@ -1504,10 +1501,10 @@ GameObject* Battleground::GetBGObject(uint32 type, bool logError)
{
if (logError)
TC_LOG_ERROR("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID);
else
TC_LOG_INFO("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID);
}
return obj;
}
@@ -1519,10 +1516,10 @@ Creature* Battleground::GetBGCreature(uint32 type, bool logError)
{
if (logError)
TC_LOG_ERROR("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID);
else
TC_LOG_INFO("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID);
}
return creature;
}
@@ -1599,13 +1596,13 @@ bool Battleground::DelCreature(uint32 type)
if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]))
{
creature->AddObjectToRemoveList();
BgCreatures[type] = 0;
BgCreatures[type].Clear();
return true;
}
TC_LOG_ERROR("bg.battleground", "Battleground::DelCreature: creature (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgCreatures[type]), m_MapId, m_InstanceID);
BgCreatures[type] = 0;
type, BgCreatures[type].GetCounter(), m_MapId, m_InstanceID);
BgCreatures[type].Clear();
return false;
}
@@ -1618,12 +1615,12 @@ bool Battleground::DelObject(uint32 type)
{
obj->SetRespawnTime(0); // not save respawn time
obj->Delete();
BgObjects[type] = 0;
BgObjects[type].Clear();
return true;
}
TC_LOG_ERROR("bg.battleground", "Battleground::DelObject: gameobject (type: %u, GUID: %u) not found for BG (map: %u, instance id: %u)!",
type, GUID_LOPART(BgObjects[type]), m_MapId, m_InstanceID);
BgObjects[type] = 0;
type, BgObjects[type].GetCounter(), m_MapId, m_InstanceID);
BgObjects[type].Clear();
return false;
}
@@ -1634,7 +1631,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float
if (Creature* creature = AddCreature(entry, type, x, y, z, o, teamId))
{
creature->setDeathState(DEAD);
creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID());
creature->SetChannelObjectGuid(creature->GetGUID());
// aura
/// @todo Fix display here
// creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
@@ -1657,7 +1654,7 @@ bool Battleground::AddSpiritGuide(uint32 type, Position const& pos, TeamId teamI
return AddSpiritGuide(type, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamId);
}
void Battleground::SendMessageToAll(int32 entry, ChatMsg type, Player const* source)
void Battleground::SendMessageToAll(uint32 entry, ChatMsg type, Player const* source)
{
if (!entry)
return;
@@ -1667,7 +1664,7 @@ void Battleground::SendMessageToAll(int32 entry, ChatMsg type, Player const* sou
BroadcastWorker(bg_do);
}
void Battleground::PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...)
void Battleground::PSendMessageToAll(uint32 entry, ChatMsg type, Player const* source, ...)
{
if (!entry)
return;
@@ -1682,7 +1679,7 @@ void Battleground::PSendMessageToAll(int32 entry, ChatMsg type, Player const* so
va_end(ap);
}
void Battleground::SendWarningToAll(int32 entry, ...)
void Battleground::SendWarningToAll(uint32 entry, ...)
{
if (!entry)
return;
@@ -1708,7 +1705,7 @@ void Battleground::SendWarningToAll(int32 entry, ...)
}
}
void Battleground::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2)
void Battleground::SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* source, uint32 arg1, uint32 arg2)
{
Trinity::Battleground2ChatBuilder bg_builder(type, entry, source, arg1, arg2);
Trinity::LocalizedPacketDo<Trinity::Battleground2ChatBuilder> bg_do(bg_builder);
@@ -1722,17 +1719,10 @@ void Battleground::EndNow()
SetRemainingTime(0);
}
// To be removed
char const* Battleground::GetTrinityString(int32 entry)
{
// FIXME: now we have different DBC locales and need localized message for each target client
return sObjectMgr->GetTrinityStringForDBCLocale(entry);
}
// IMPORTANT NOTICE:
// buffs aren't spawned/despawned when players captures anything
// buffs are in their positions when battleground starts
void Battleground::HandleTriggerBuff(uint64 go_guid)
void Battleground::HandleTriggerBuff(ObjectGuid go_guid)
{
GameObject* obj = GetBgMap()->GetGameObject(go_guid);
if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned())
@@ -1745,7 +1735,7 @@ void Battleground::HandleTriggerBuff(uint64 go_guid)
if (index < 0)
{
TC_LOG_ERROR("bg.battleground", "Battleground::HandleTriggerBuff: cannot find buff gameobject (GUID: %u, entry: %u, type: %u) in internal data for BG (map: %u, instance id: %u)!",
GUID_LOPART(go_guid), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID);
go_guid.GetCounter(), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID);
return;
}
@@ -1805,7 +1795,7 @@ void Battleground::HandleKillPlayer(Player* victim, Player* killer)
// Return the player's team based on battlegroundplayer info
// Used in same faction arena matches mainly
uint32 Battleground::GetPlayerTeam(uint64 guid) const
uint32 Battleground::GetPlayerTeam(ObjectGuid guid) const
{
BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
if (itr != m_Players.end())
@@ -1818,7 +1808,7 @@ uint32 Battleground::GetOtherTeam(uint32 teamId) const
return teamId ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
}
bool Battleground::IsPlayerInBattleground(uint64 guid) const
bool Battleground::IsPlayerInBattleground(ObjectGuid guid) const
{
BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
if (itr != m_Players.end())
@@ -1863,13 +1853,13 @@ void Battleground::SetHoliday(bool is_holiday)
m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL;
}
int32 Battleground::GetObjectType(uint64 guid)
int32 Battleground::GetObjectType(ObjectGuid guid)
{
for (uint32 i = 0; i < BgObjects.size(); ++i)
if (BgObjects[i] == guid)
return i;
TC_LOG_ERROR("bg.battleground", "Battleground::GetObjectType: player used gameobject (GUID: %u) which is not in internal data for BG (map: %u, instance id: %u), cheating?",
GUID_LOPART(guid), m_MapId, m_InstanceID);
guid.GetCounter(), m_MapId, m_InstanceID);
return -1;
}
+27 -31
View File
@@ -240,7 +240,7 @@ class Battleground
/* Battleground */
// Get methods:
std::string const& GetName() const { return m_Name; }
uint64 GetGUID() { return m_Guid; }
ObjectGuid GetGUID() { return m_Guid; }
BattlegroundTypeId GetTypeID(bool GetRandom = false) const { return GetRandom ? m_RandomTypeID : m_TypeID; }
BattlegroundBracketId GetBracketId() const { return m_BracketId; }
uint32 GetInstanceID() const { return m_InstanceID; }
@@ -266,7 +266,7 @@ class Battleground
bool IsRandom() const { return m_IsRandom; }
// Set methods:
void SetGuid(uint64 newGuid) { m_Guid = newGuid; }
void SetGuid(ObjectGuid newGuid) { m_Guid = newGuid; }
void SetName(std::string const& name) { m_Name = name; }
void SetTypeID(BattlegroundTypeId TypeID) { m_TypeID = TypeID; }
void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; }
@@ -308,7 +308,7 @@ class Battleground
bool isBattleground() const { return !m_IsArena; }
bool isRated() const { return m_IsRated; }
typedef std::map<uint64, BattlegroundPlayer> BattlegroundPlayerMap;
typedef std::map<ObjectGuid, BattlegroundPlayer> BattlegroundPlayerMap;
BattlegroundPlayerMap const& GetPlayers() const { return m_Players; }
uint32 GetPlayersSize() const { return m_Players.size(); }
@@ -317,11 +317,11 @@ class Battleground
uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); }
void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid);
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid);
/// Relocate all players in ReviveQueue to the closest graveyard
void RelocateDeadPlayers(uint64 queueIndex);
void RelocateDeadPlayers(ObjectGuid guideGuid);
void StartBattleground();
@@ -365,12 +365,12 @@ class Battleground
virtual void EndBattleground(uint32 winner);
void BlockMovement(Player* player);
void SendWarningToAll(int32 entry, ...);
void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL);
void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...);
void SendWarningToAll(uint32 entry, ...);
void SendMessageToAll(uint32 entry, ChatMsg type, Player const* source = NULL);
void PSendMessageToAll(uint32 entry, ChatMsg type, Player const* source, ...);
// specialized version with 2 string id args
void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0);
void SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* source, uint32 strId1 = 0, uint32 strId2 = 0);
// Raid Group
Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; }
@@ -414,7 +414,7 @@ class Battleground
virtual void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/, WorldObject* /*invoker*/ = NULL) { }
// this function can be used by spell to interact with the BG map
virtual void DoAction(uint32 /*action*/, uint64 /*var*/) { }
virtual void DoAction(uint32 /*action*/, ObjectGuid /*var*/) { }
virtual void HandlePlayerResurrect(Player* /*player*/) { }
@@ -425,17 +425,15 @@ class Battleground
void AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team);
virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket);
virtual void RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket);
// can be extended in in BG subclass
void HandleTriggerBuff(uint64 go_guid);
void HandleTriggerBuff(ObjectGuid go_guid);
void SetHoliday(bool is_holiday);
/// @todo make this protected:
typedef std::vector<uint64> BGObjects;
typedef std::vector<uint64> BGCreatures;
BGObjects BgObjects;
BGCreatures BgCreatures;
GuidVector BgObjects;
GuidVector BgCreatures;
void SpawnBGObject(uint32 type, uint32 respawntime);
virtual bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0);
bool AddObject(uint32 type, uint32 entry, Position const& pos, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0);
@@ -445,19 +443,17 @@ class Battleground
bool DelObject(uint32 type);
virtual bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId = TEAM_NEUTRAL);
bool AddSpiritGuide(uint32 type, Position const& pos, TeamId teamId = TEAM_NEUTRAL);
int32 GetObjectType(uint64 guid);
int32 GetObjectType(ObjectGuid guid);
void DoorOpen(uint32 type);
void DoorClose(uint32 type);
//to be removed
const char* GetTrinityString(int32 entry);
virtual bool HandlePlayerUnderMap(Player* /*player*/) { return false; }
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
uint32 GetPlayerTeam(uint64 guid) const;
uint32 GetPlayerTeam(ObjectGuid guid) const;
uint32 GetOtherTeam(uint32 teamId) const;
bool IsPlayerInBattleground(uint64 guid) const;
bool IsPlayerInBattleground(ObjectGuid guid) const;
bool ToBeDeleted() const { return m_SetDeleteThis; }
void SetDeleteThis() { m_SetDeleteThis = true; }
@@ -465,8 +461,8 @@ class Battleground
void RewardXPAtKill(Player* killer, Player* victim);
bool CanAwardArenaPoints() const { return m_LevelMin >= BG_AWARD_ARENA_POINTS_MIN_LEVEL; }
virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; }
virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) { }
virtual ObjectGuid GetFlagPickerGUID(int32 /*team*/ = -1) const { return ObjectGuid::Empty; }
virtual void SetDroppedFlagGUID(ObjectGuid /*guid*/, int32 /*team*/ = -1) { }
virtual void HandleQuestComplete(uint32 /*questid*/, Player* /*player*/) { }
virtual bool CanActivateGO(int32 /*entry*/, uint32 /*team*/) const { return true; }
virtual bool IsSpellAllowed(uint32 /*spellId*/, Player const* /*player*/) const { return true; }
@@ -482,7 +478,7 @@ class Battleground
void EndNow();
void PlayerAddedToBGCheckIfBGIsRunning(Player* player);
Player* _GetPlayer(uint64 guid, bool offlineRemove, const char* context) const;
Player* _GetPlayer(ObjectGuid guid, bool offlineRemove, const char* context) const;
Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context) { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, const char* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char* context) const;
@@ -497,12 +493,12 @@ class Battleground
// Scorekeeping
BattlegroundScoreMap PlayerScores; // Player scores
// must be implemented in BG subclass
virtual void RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { }
virtual void RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) { }
// Player lists, those need to be accessible by inherited classes
BattlegroundPlayerMap m_Players;
BattlegroundPlayerMap m_Players;
// Spirit Guide guid + Player list GUIDS
std::map<uint64, std::vector<uint64> > m_ReviveQueue;
std::map<ObjectGuid, GuidVector> m_ReviveQueue;
// these are important variables used for starting messages
uint8 m_Events;
@@ -542,7 +538,7 @@ class Battleground
bool m_PrematureCountDown;
uint32 m_PrematureCountDownTimer;
std::string m_Name;
uint64 m_Guid;
ObjectGuid m_Guid;
/* Pre- and post-update hooks */
@@ -575,8 +571,8 @@ class Battleground
virtual void PostUpdateImpl(uint32 /* diff */) { }
// Player lists
std::vector<uint64> m_ResurrectQueue; // Player GUID
std::deque<uint64> m_OfflineQueue; // Player GUID
GuidVector m_ResurrectQueue; // Player GUID
GuidDeque m_OfflineQueue; // Player GUID
// Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction
// Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG
@@ -359,7 +359,7 @@ void BattlegroundMgr::BuildStatusFailedPacket(WorldPacket* data, Battleground* b
{
ObjectGuid guidBytes1 = player->GetGUID(); // player who caused the error
ObjectGuid guidBytes2 = bg->GetGUID();
ObjectGuid unkGuid3 = 0;
ObjectGuid unkGuid3;
data->Initialize(SMSG_BATTLEFIELD_STATUS_FAILED);
@@ -440,54 +440,50 @@ void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid)
*data << uint64(0);
}
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid)
void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
{
ObjectGuid guidBytes = guid;
data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8);
data->WriteBit(guidBytes[7]);
data->WriteBit(guidBytes[6]);
data->WriteBit(guidBytes[2]);
data->WriteBit(guidBytes[4]);
data->WriteBit(guidBytes[5]);
data->WriteBit(guidBytes[1]);
data->WriteBit(guidBytes[3]);
data->WriteBit(guidBytes[0]);
data->WriteBit(guid[7]);
data->WriteBit(guid[6]);
data->WriteBit(guid[2]);
data->WriteBit(guid[4]);
data->WriteBit(guid[5]);
data->WriteBit(guid[1]);
data->WriteBit(guid[3]);
data->WriteBit(guid[0]);
data->WriteByteSeq(guidBytes[4]);
data->WriteByteSeq(guidBytes[2]);
data->WriteByteSeq(guidBytes[5]);
data->WriteByteSeq(guidBytes[7]);
data->WriteByteSeq(guidBytes[0]);
data->WriteByteSeq(guidBytes[6]);
data->WriteByteSeq(guidBytes[1]);
data->WriteByteSeq(guidBytes[3]);
data->WriteByteSeq(guid[4]);
data->WriteByteSeq(guid[2]);
data->WriteByteSeq(guid[5]);
data->WriteByteSeq(guid[7]);
data->WriteByteSeq(guid[0]);
data->WriteByteSeq(guid[6]);
data->WriteByteSeq(guid[1]);
data->WriteByteSeq(guid[3]);
}
void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, uint64 guid)
void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, ObjectGuid guid)
{
ObjectGuid guidBytes = guid;
data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
data->WriteBit(guidBytes[0]);
data->WriteBit(guidBytes[4]);
data->WriteBit(guidBytes[3]);
data->WriteBit(guidBytes[5]);
data->WriteBit(guidBytes[7]);
data->WriteBit(guidBytes[6]);
data->WriteBit(guidBytes[2]);
data->WriteBit(guidBytes[1]);
data->WriteBit(guid[0]);
data->WriteBit(guid[4]);
data->WriteBit(guid[3]);
data->WriteBit(guid[5]);
data->WriteBit(guid[7]);
data->WriteBit(guid[6]);
data->WriteBit(guid[2]);
data->WriteBit(guid[1]);
data->WriteByteSeq(guidBytes[1]);
data->WriteByteSeq(guidBytes[5]);
data->WriteByteSeq(guidBytes[3]);
data->WriteByteSeq(guidBytes[2]);
data->WriteByteSeq(guidBytes[0]);
data->WriteByteSeq(guidBytes[7]);
data->WriteByteSeq(guidBytes[4]);
data->WriteByteSeq(guidBytes[6]);
data->WriteByteSeq(guid[1]);
data->WriteByteSeq(guid[5]);
data->WriteByteSeq(guid[3]);
data->WriteByteSeq(guid[2]);
data->WriteByteSeq(guid[0]);
data->WriteByteSeq(guid[7]);
data->WriteByteSeq(guid[4]);
data->WriteByteSeq(guid[6]);
}
Battleground* BattlegroundMgr::GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
@@ -656,7 +652,7 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
bg->SetRandomTypeID(bgTypeId);
bg->SetRated(isRated);
bg->SetRandom(isRandom);
bg->SetGuid(MAKE_NEW_GUID(bgTypeId, 0, HIGHGUID_BATTLEGROUND));
bg->SetGuid(ObjectGuid(HIGHGUID_BATTLEGROUND, uint32(bgTypeId)));
// Set up correct min/max player counts for scoreboards
if (bg->isArena())
@@ -759,7 +755,7 @@ bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate)
bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
bg->SetScriptId(bgTemplate->ScriptId);
bg->SetGuid(MAKE_NEW_GUID(bgTemplate->Id, 0, HIGHGUID_BATTLEGROUND));
bg->SetGuid(ObjectGuid(HIGHGUID_BATTLEGROUND, uint32(bgTemplate->Id)));
AddBattleground(bg);
@@ -866,7 +862,7 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
TC_LOG_INFO("server.loading", ">> Loaded %u battlegrounds in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId)
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId)
{
if (!player)
return;
@@ -879,8 +875,6 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
uint32 winnerHonor = (player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_FIRST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_LAST)) / CURRENCY_PRECISION;
uint32 loserHonor = (!player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST)) / CURRENCY_PRECISION;
ObjectGuid guidBytes = guid;
data->Initialize(SMSG_BATTLEFIELD_LIST);
*data << uint32(winnerConquest) // Winner Conquest Reward or Random Winner Conquest Reward
<< uint32(winnerConquest) // Winner Conquest Reward or Random Winner Conquest Reward
@@ -892,29 +886,29 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
<< uint8(bgTemplate->MaxLevel) // max level
<< uint8(bgTemplate->MinLevel); // min level
data->WriteBit(guidBytes[0]);
data->WriteBit(guidBytes[1]);
data->WriteBit(guidBytes[7]);
data->WriteBit(guid[0]);
data->WriteBit(guid[1]);
data->WriteBit(guid[7]);
data->WriteBit(0); // unk
data->WriteBit(0); // unk
size_t count_pos = data->bitwpos();
data->WriteBits(0, 24); // placeholder
data->WriteBit(guidBytes[6]);
data->WriteBit(guidBytes[4]);
data->WriteBit(guidBytes[2]);
data->WriteBit(guidBytes[3]);
data->WriteBit(guid[6]);
data->WriteBit(guid[4]);
data->WriteBit(guid[2]);
data->WriteBit(guid[3]);
data->WriteBit(0); // unk
data->WriteBit(guidBytes[5]);
data->WriteBit(guid[5]);
data->WriteBit(0); // unk
data->FlushBits();
data->WriteByteSeq(guidBytes[6]);
data->WriteByteSeq(guidBytes[1]);
data->WriteByteSeq(guidBytes[7]);
data->WriteByteSeq(guidBytes[5]);
data->WriteByteSeq(guid[6]);
data->WriteByteSeq(guid[1]);
data->WriteByteSeq(guid[7]);
data->WriteByteSeq(guid[5]);
BattlegroundDataContainer::iterator it = bgDataStore.find(bgTypeId);
if (it != bgDataStore.end())
@@ -932,10 +926,10 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
}
}
data->WriteByteSeq(guidBytes[0]);
data->WriteByteSeq(guidBytes[2]);
data->WriteByteSeq(guidBytes[4]);
data->WriteByteSeq(guidBytes[3]);
data->WriteByteSeq(guid[0]);
data->WriteByteSeq(guid[2]);
data->WriteByteSeq(guid[4]);
data->WriteByteSeq(guid[3]);
}
void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId)
@@ -953,7 +947,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
TC_LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName().c_str());
}
void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid)
void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid)
{
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
uint32 time_ = 30000 - bg->GetLastResurrectTime(); // resurrect every 30 seconds
@@ -70,14 +70,14 @@ class BattlegroundMgr
void Update(uint32 diff);
/* Packet Building */
void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, uint64 guid);
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid);
void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId);
void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, ObjectGuid guid);
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid);
void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId);
void BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result);
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType);
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId);
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid);
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
/* Battlegrounds */
Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
@@ -281,7 +281,7 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, Battleg
}
//remove player from queue and from group info, if group info is empty then remove it too
void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
{
int32 bracket_id = -1; // signed for proper for-loop finish
QueuedPlayersMap::iterator itr;
@@ -293,7 +293,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
std::string playerName = "Unknown";
if (Player* player = ObjectAccessor::FindPlayer(guid))
playerName = player->GetName();
TC_LOG_ERROR("bg.battleground", "BattlegroundQueue: couldn't find player %s (GUID: %u)", playerName.c_str(), GUID_LOPART(guid));
TC_LOG_ERROR("bg.battleground", "BattlegroundQueue: couldn't find player %s (GUID: %u)", playerName.c_str(), guid.GetCounter());
return;
}
@@ -328,10 +328,10 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
//player can't be in queue without group, but just in case
if (bracket_id == -1)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundQueue: ERROR Cannot find groupinfo for player GUID: %u", GUID_LOPART(guid));
TC_LOG_ERROR("bg.battleground", "BattlegroundQueue: ERROR Cannot find groupinfo for player GUID: %u", guid.GetCounter());
return;
}
TC_LOG_DEBUG("bg.battleground", "BattlegroundQueue: Removing player GUID %u, from bracket_id %u", GUID_LOPART(guid), (uint32)bracket_id);
TC_LOG_DEBUG("bg.battleground", "BattlegroundQueue: Removing player GUID %u, from bracket_id %u", guid.GetCounter(), (uint32)bracket_id);
// ALL variables are correctly set
// We can ignore leveling up in queue - it should not cause crash
@@ -339,7 +339,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
// if only one player there, remove group
// remove player queue info from group queue info
std::map<uint64, PlayerQueueInfo*>::iterator pitr = group->Players.find(guid);
std::map<ObjectGuid, PlayerQueueInfo*>::iterator pitr = group->Players.find(guid);
if (pitr != group->Players.end())
group->Players.erase(pitr);
@@ -361,7 +361,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
{
if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId))
{
TC_LOG_DEBUG("bg.battleground", "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating);
TC_LOG_DEBUG("bg.battleground", "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", guid.GetCounter(), group->OpponentsTeamRating);
if (Player* player = ObjectAccessor::FindPlayer(guid))
at->MemberLost(player, group->OpponentsMatchmakerRating);
else
@@ -403,7 +403,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
}
//returns true when player pl_guid is in queue and is invited to bgInstanceGuid
bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
bool BattlegroundQueue::IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
{
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid);
return (qItr != m_QueuedPlayers.end()
@@ -411,7 +411,7 @@ bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceG
&& qItr->second.GroupInfo->RemoveInviteTime == removeTime);
}
bool BattlegroundQueue::GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo)
bool BattlegroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo)
{
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(guid);
if (qItr == m_QueuedPlayers.end())
@@ -447,7 +447,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME;
// loop through the players
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
for (std::map<ObjectGuid, PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
{
// get the player
Player* player = ObjectAccessor::FindPlayer(itr->first);
@@ -40,7 +40,7 @@ struct PlayerQueueInfo // stores informatio
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
{
std::map<uint64, PlayerQueueInfo*> Players; // player queue info map
std::map<ObjectGuid, PlayerQueueInfo*> Players; // player queue info map
uint32 Team; // Player team (ALLIANCE/HORDE)
BattlegroundTypeId BgTypeId; // battleground type id
bool IsRated; // rated
@@ -79,13 +79,13 @@ class BattlegroundQueue
bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
GroupQueueInfo* AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);
void RemovePlayer(uint64 guid, bool decreaseInvitedCount);
bool IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
bool GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo);
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount);
bool IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id);
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const;
typedef std::map<uint64, PlayerQueueInfo> QueuedPlayersMap;
typedef std::map<ObjectGuid, PlayerQueueInfo> QueuedPlayersMap;
QueuedPlayersMap m_QueuedPlayers;
//do NOT use deque because deque.erase() invalidates ALL iterators
@@ -138,7 +138,7 @@ class BattlegroundQueue
class BGQueueInviteEvent : public BasicEvent
{
public:
BGQueueInviteEvent(uint64 pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) :
BGQueueInviteEvent(ObjectGuid pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) :
m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime)
{ }
virtual ~BGQueueInviteEvent() { }
@@ -146,7 +146,7 @@ class BGQueueInviteEvent : public BasicEvent
virtual bool Execute(uint64 e_time, uint32 p_time) override;
virtual void Abort(uint64 e_time) override;
private:
uint64 m_PlayerGuid;
ObjectGuid m_PlayerGuid;
uint32 m_BgInstanceGUID;
BattlegroundTypeId m_BgTypeId;
uint8 m_ArenaType;
@@ -161,7 +161,7 @@ class BGQueueInviteEvent : public BasicEvent
class BGQueueRemoveEvent : public BasicEvent
{
public:
BGQueueRemoveEvent(uint64 pl_guid, uint32 bgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime)
BGQueueRemoveEvent(ObjectGuid pl_guid, uint32 bgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime)
: m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_ArenaType(arenaType), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId)
{ }
@@ -170,7 +170,7 @@ class BGQueueRemoveEvent : public BasicEvent
virtual bool Execute(uint64 e_time, uint32 p_time) override;
virtual void Abort(uint64 e_time) override;
private:
uint64 m_PlayerGuid;
ObjectGuid m_PlayerGuid;
uint32 m_BgInstanceGUID;
uint8 m_ArenaType;
uint32 m_RemoveTime;
@@ -57,7 +57,7 @@ struct BattlegroundScore
friend class Battleground;
protected:
BattlegroundScore(uint64 playerGuid, uint32 team) : PlayerGuid(playerGuid), TeamId(team == ALLIANCE ? 1 : 0),
BattlegroundScore(ObjectGuid playerGuid, uint32 team) : PlayerGuid(playerGuid), TeamId(team == ALLIANCE ? 1 : 0),
KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0), DamageDone(0), HealingDone(0) { }
virtual ~BattlegroundScore() { }
@@ -227,7 +227,7 @@ void BattlegroundAB::AddPlayer(Player* player)
PlayerScores[player->GetGUIDLow()] = new BattlegroundABScore(player->GetGUID(), player->GetBGTeam());
}
void BattlegroundAB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
void BattlegroundAB::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/)
{
}
@@ -392,7 +392,7 @@ void BattlegroundAB::_NodeOccupied(uint8 node, Team team)
if (capturedNodes >= 4)
CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team);
Creature* trigger = BgCreatures[node+7] ? GetBGCreature(node+7) : NULL; // 0-6 spirit guides
Creature* trigger = !BgCreatures[node + 7] ? GetBGCreature(node + 7) : NULL; // 0-6 spirit guides
if (!trigger)
trigger = AddCreature(WORLD_TRIGGER, node+7, BG_AB_NodePositions[node], GetTeamIndexByTeamId(team));
@@ -242,7 +242,7 @@ struct BattlegroundABScore final : public BattlegroundScore
friend class BattlegroundAB;
protected:
BattlegroundABScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
BattlegroundABScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -283,7 +283,7 @@ class BattlegroundAB : public Battleground
void AddPlayer(Player* player) override;
void StartingEventCloseDoors() override;
void StartingEventOpenDoors() override;
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* Source, uint32 Trigger) override;
bool SetupBattleground() override;
void Reset() override;
@@ -119,7 +119,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
DelCreature(AV_CPLACE_TRIGGER16);
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
herold->AI()->TalkToMap(TEXT_STORMPIKE_GENERAL_DEAD);
herold->AI()->Talk(TEXT_STORMPIKE_GENERAL_DEAD);
}
else if (entry == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN])
{
@@ -138,7 +138,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
DelCreature(AV_CPLACE_TRIGGER18);
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
herold->AI()->TalkToMap(TEXT_FROSTWOLF_GENERAL_DEAD);
herold->AI()->Talk(TEXT_FROSTWOLF_GENERAL_DEAD);
}
else if (entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_N_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_A_4] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_H_4])
ChangeMineOwner(AV_NORTH_MINE, killer->GetTeam());
@@ -480,7 +480,7 @@ void BattlegroundAV::EndBattleground(uint32 winner)
Battleground::EndBattleground(winner);
}
void BattlegroundAV::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/)
void BattlegroundAV::RemovePlayer(Player* player, ObjectGuid /*guid*/, uint32 /*team*/)
{
if (!player)
{
@@ -603,7 +603,7 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
if (StaticNodeInfo const* nodeInfo = GetStaticNodeInfo(node))
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
herold->AI()->TalkToMap(owner == ALLIANCE ? nodeInfo->TextIds.AllianceCapture : nodeInfo->TextIds.HordeCapture);
herold->AI()->Talk(owner == ALLIANCE ? nodeInfo->TextIds.AllianceCapture : nodeInfo->TextIds.HordeCapture);
}
void BattlegroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
@@ -679,9 +679,9 @@ void BattlegroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial)
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
{
if (mine == AV_NORTH_MINE)
herold->AI()->TalkToMap(team == ALLIANCE ? TEXT_IRONDEEP_MINE_ALLIANCE_TAKEN : TEXT_IRONDEEP_MINE_HORDE_TAKEN);
herold->AI()->Talk(team == ALLIANCE ? TEXT_IRONDEEP_MINE_ALLIANCE_TAKEN : TEXT_IRONDEEP_MINE_HORDE_TAKEN);
else if (mine == AV_SOUTH_MINE)
herold->AI()->TalkToMap(team == ALLIANCE ? TEXT_COLDTOOTH_MINE_ALLIANCE_TAKEN : TEXT_COLDTOOTH_MINE_HORDE_TAKEN);
herold->AI()->Talk(team == ALLIANCE ? TEXT_COLDTOOTH_MINE_ALLIANCE_TAKEN : TEXT_COLDTOOTH_MINE_HORDE_TAKEN);
}
}
else
@@ -923,7 +923,7 @@ void BattlegroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
if (StaticNodeInfo const* nodeInfo = GetStaticNodeInfo(node))
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
herold->AI()->TalkToMap(team == ALLIANCE ? nodeInfo->TextIds.AllianceCapture : nodeInfo->TextIds.HordeCapture);
herold->AI()->Talk(team == ALLIANCE ? nodeInfo->TextIds.AllianceCapture : nodeInfo->TextIds.HordeCapture);
// update the statistic for the defending player
UpdatePlayerScore(player, IsTower(node) ? SCORE_TOWERS_DEFENDED : SCORE_GRAVEYARDS_DEFENDED, 1);
@@ -1014,7 +1014,7 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
if (StaticNodeInfo const* nodeInfo = GetStaticNodeInfo(node))
if (Creature* herold = GetBGCreature(AV_CPLACE_HERALD))
herold->AI()->TalkToMap(team == ALLIANCE ? nodeInfo->TextIds.AllianceAttack : nodeInfo->TextIds.HordeAttack);
herold->AI()->Talk(team == ALLIANCE ? nodeInfo->TextIds.AllianceAttack : nodeInfo->TextIds.HordeAttack);
// update the statistic for the assaulting player
UpdatePlayerScore(player, (IsTower(node)) ? SCORE_TOWERS_ASSAULTED : SCORE_GRAVEYARDS_ASSAULTED, 1);
@@ -1554,7 +1554,7 @@ struct BattlegroundAVScore final : public BattlegroundScore
friend class BattlegroundAV;
protected:
BattlegroundAVScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), TowersDefended(0), MinesCaptured(0) { }
BattlegroundAVScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), TowersDefended(0), MinesCaptured(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -1615,7 +1615,7 @@ class BattlegroundAV : public Battleground
void StartingEventCloseDoors() override;
void StartingEventOpenDoors() override;
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* player, uint32 trigger) override;
bool SetupBattleground() override;
void ResetBGSubclass() override;
@@ -24,7 +24,7 @@
class BattlegroundBFGScore final : public BattlegroundScore
{
protected:
BattlegroundBFGScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
BattlegroundBFGScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -46,8 +46,8 @@ BattlegroundEY::BattlegroundEY()
m_HonorScoreTics[TEAM_HORDE] = 0;
m_TeamPointsCount[TEAM_ALLIANCE] = 0;
m_TeamPointsCount[TEAM_HORDE] = 0;
m_FlagKeeper = 0;
m_DroppedFlagGUID = 0;
m_FlagKeeper.Clear();
m_DroppedFlagGUID.Clear();
m_FlagCapturedBgObjectType = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
m_FlagsTimer = 0;
@@ -171,7 +171,7 @@ void BattlegroundEY::CheckSomeoneJoinedPoint()
Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]);
if (!player)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j]));
TC_LOG_ERROR("bg.battleground", "BattlegroundEY:CheckSomeoneJoinedPoint: Player (%s) not found!", m_PlayersNearPoint[EY_POINTS_MAX][j].ToString().c_str());
++j;
continue;
}
@@ -211,7 +211,7 @@ void BattlegroundEY::CheckSomeoneLeftPoint()
Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]);
if (!player)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j]));
TC_LOG_ERROR("bg.battleground", "BattlegroundEY:CheckSomeoneLeftPoint Player (%s) not found!", m_PlayersNearPoint[i][j].ToString().c_str());
//move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
@@ -368,7 +368,7 @@ void BattlegroundEY::AddPlayer(Player* player)
m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID());
}
void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
void BattlegroundEY::RemovePlayer(Player* player, ObjectGuid guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
for (int j = EY_POINTS_MAX; j >= 0; --j)
@@ -385,7 +385,7 @@ void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
EventPlayerDroppedFlag(player);
else
{
SetFlagPicker(0);
SetFlagPicker(ObjectGuid::Empty);
RespawnFlag(true);
}
}
@@ -548,8 +548,8 @@ void BattlegroundEY::Reset()
m_HonorScoreTics[TEAM_HORDE] = 0;
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
m_FlagCapturedBgObjectType = 0;
m_FlagKeeper = 0;
m_DroppedFlagGUID = 0;
m_FlagKeeper.Clear();
m_DroppedFlagGUID.Clear();
m_PointAddingTimer = 0;
m_TowerCapCheckTimer = 0;
bool isBGWeekend = sBattlegroundMgr->IsBGWeekend(GetTypeID());
@@ -593,9 +593,9 @@ void BattlegroundEY::RespawnFlagAfterDrop()
if (obj)
obj->Delete();
else
TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Unknown dropped flag guid: %u", GUID_LOPART(GetDroppedFlagGUID()));
TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Unknown dropped flag (%s)", GetDroppedFlagGUID().ToString().c_str());
SetDroppedFlagGUID(0);
SetDroppedFlagGUID(ObjectGuid::Empty);
}
void BattlegroundEY::HandleKillPlayer(Player* player, Player* killer)
@@ -615,7 +615,7 @@ void BattlegroundEY::EventPlayerDroppedFlag(Player* player)
// just take off the aura
if (IsFlagPickedup() && GetFlagPickerGUID() == player->GetGUID())
{
SetFlagPicker(0);
SetFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
}
return;
@@ -627,7 +627,7 @@ void BattlegroundEY::EventPlayerDroppedFlag(Player* player)
if (GetFlagPickerGUID() != player->GetGUID())
return;
SetFlagPicker(0);
SetFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
m_FlagState = BG_EY_FLAG_STATE_ON_GROUND;
m_FlagsTimer = BG_EY_FLAG_RESPAWN_TIME;
@@ -795,7 +795,7 @@ void BattlegroundEY::EventPlayerCapturedFlag(Player* player, uint32 BgObjectType
if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != player->GetGUID())
return;
SetFlagPicker(0);
SetFlagPicker(ObjectGuid::Empty);
m_FlagState = BG_EY_FLAG_STATE_WAIT_RESPAWN;
player->RemoveAurasDueToSpell(BG_EY_NETHERSTORM_FLAG_SPELL);
@@ -328,7 +328,7 @@ struct BattlegroundEYScore final : public BattlegroundScore
friend class BattlegroundEY;
protected:
BattlegroundEYScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0) { }
BattlegroundEYScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -366,15 +366,14 @@ class BattlegroundEY : public Battleground
void StartingEventOpenDoors() override;
/* BG Flags */
uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const override { return m_FlagKeeper; }
void SetFlagPicker(uint64 guid) { m_FlagKeeper = guid; }
bool IsFlagPickedup() const { return m_FlagKeeper != 0; }
ObjectGuid GetFlagPickerGUID(int32 /*team*/ = -1) const override { return m_FlagKeeper; }
void SetFlagPicker(ObjectGuid guid) { m_FlagKeeper = guid; }
bool IsFlagPickedup() const { return !m_FlagKeeper.IsEmpty(); }
uint8 GetFlagState() const { return m_FlagState; }
void RespawnFlag(bool send_message);
void RespawnFlagAfterDrop();
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void HandleBuffUse(uint64 buff_guid);
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* Source, uint32 Trigger) override;
void HandleKillPlayer(Player* player, Player* killer) override;
WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
@@ -384,8 +383,8 @@ class BattlegroundEY : public Battleground
void EndBattleground(uint32 winner) override;
bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
void FillInitialWorldStates(WorldPacket& data) override;
void SetDroppedFlagGUID(uint64 guid, int32 /*TeamID*/ = -1) override { m_DroppedFlagGUID = guid;}
uint64 GetDroppedFlagGUID() const { return m_DroppedFlagGUID;}
void SetDroppedFlagGUID(ObjectGuid guid, int32 /*TeamID*/ = -1) override { m_DroppedFlagGUID = guid; }
ObjectGuid GetDroppedFlagGUID() const { return m_DroppedFlagGUID; }
/* Battleground Events */
void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) override;
@@ -420,8 +419,8 @@ class BattlegroundEY : public Battleground
uint32 m_Points_Trigger[EY_POINTS_MAX];
uint64 m_FlagKeeper; // keepers guid
uint64 m_DroppedFlagGUID;
ObjectGuid m_FlagKeeper; // keepers guid
ObjectGuid m_DroppedFlagGUID;
uint32 m_FlagCapturedBgObjectType; // type that should be despawned when flag is captured
uint8 m_FlagState; // for checking flag state
int32 m_FlagsTimer;
@@ -430,8 +429,7 @@ class BattlegroundEY : public Battleground
uint32 m_PointOwnedByTeam[EY_POINTS_MAX];
uint8 m_PointState[EY_POINTS_MAX];
int32 m_PointBarStatus[EY_POINTS_MAX];
typedef std::vector<uint64> PlayersNearPointType;
PlayersNearPointType m_PlayersNearPoint[EY_POINTS_MAX + 1];
GuidVector m_PlayersNearPoint[EY_POINTS_MAX + 1];
uint8 m_CurrentPointPlayersCount[2*EY_POINTS_MAX];
int32 m_PointAddingTimer;
@@ -68,7 +68,7 @@ void BattlegroundIC::HandlePlayerResurrect(Player* player)
player->CastSpell(player, SPELL_OIL_REFINERY, true);
}
void BattlegroundIC::DoAction(uint32 action, uint64 var)
void BattlegroundIC::DoAction(uint32 action, ObjectGuid var)
{
if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT)
return;
@@ -282,7 +282,7 @@ void BattlegroundIC::AddPlayer(Player* player)
player->CastSpell(player, SPELL_OIL_REFINERY, true);
}
void BattlegroundIC::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/)
void BattlegroundIC::RemovePlayer(Player* player, ObjectGuid /*guid*/, uint32 /*team*/)
{
if (player)
{
@@ -865,7 +865,7 @@ bool BattlegroundIC::IsSpellAllowed(uint32 spellId, Player const* player) const
case SPELL_QUARRY:
{
uint32 team = player->GetTeamId();
uint8 nodeType = spellId = SPELL_OIL_REFINERY ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeType = spellId == SPELL_OIL_REFINERY ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeState = team == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
return GetNodeState(nodeType) == nodeState;
}
@@ -853,7 +853,7 @@ struct BattlegroundICScore final : public BattlegroundScore
friend class BattlegroundIC;
protected:
BattlegroundICScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
BattlegroundICScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -897,7 +897,7 @@ class BattlegroundIC : public Battleground
void StartingEventOpenDoors() override;
void PostUpdateImpl(uint32 diff) override;
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* player, uint32 trigger) override;
bool SetupBattleground() override;
void SpawnLeader(uint32 teamid);
@@ -913,7 +913,7 @@ class BattlegroundIC : public Battleground
/* Scorekeeping */
void FillInitialWorldStates(WorldPacket& data) override;
void DoAction(uint32 action, uint64 var) override;
void DoAction(uint32 action, ObjectGuid var) override;
void HandlePlayerResurrect(Player* player) override;
@@ -506,7 +506,7 @@ void BattlegroundSA::AddPlayer(Player* player)
}
}
void BattlegroundSA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { }
void BattlegroundSA::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) { }
void BattlegroundSA::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/)
{
@@ -513,7 +513,7 @@ struct BattlegroundSAScore final : public BattlegroundScore
friend class BattlegroundSA;
protected:
BattlegroundSAScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), DemolishersDestroyed(0), GatesDestroyed(0) { }
BattlegroundSAScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), DemolishersDestroyed(0), GatesDestroyed(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -594,7 +594,7 @@ class BattlegroundSA : public Battleground
void EndBattleground(uint32 winner) override;
/// Called when a player leave battleground
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* Source, uint32 Trigger) override;
/* Scorekeeping */
@@ -24,7 +24,7 @@
class BattlegroundTPScore final : public BattlegroundScore
{
protected:
BattlegroundTPScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { }
BattlegroundTPScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -54,10 +54,10 @@ BattlegroundWS::BattlegroundWS()
_flagSpellForceTimer = 0;
_bothFlagsKept = false;
_flagDebuffState = 0;
m_FlagKeepers[TEAM_ALLIANCE] = 0;
m_FlagKeepers[TEAM_HORDE] = 0;
m_DroppedFlagGUID[TEAM_ALLIANCE] = 0;
m_DroppedFlagGUID[TEAM_HORDE] = 0;
m_FlagKeepers[TEAM_ALLIANCE].Clear();
m_FlagKeepers[TEAM_HORDE].Clear();
m_DroppedFlagGUID[TEAM_ALLIANCE].Clear();
m_DroppedFlagGUID[TEAM_HORDE].Clear();
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
_flagsTimer[TEAM_ALLIANCE] = 0;
@@ -278,9 +278,9 @@ void BattlegroundWS::RespawnFlagAfterDrop(uint32 team)
if (GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGUID(team)))
obj->Delete();
else
TC_LOG_ERROR("bg.battleground", "unknown droped flag bg, guid: %u", GUID_LOPART(GetDroppedFlagGUID(team)));
TC_LOG_ERROR("bg.battleground", "unknown dropped flag (%s)", GetDroppedFlagGUID(team).ToString().c_str());
SetDroppedFlagGUID(0, GetTeamIndexByTeamId(team));
SetDroppedFlagGUID(ObjectGuid::Empty, GetTeamIndexByTeamId(team));
_bothFlagsKept = false;
}
@@ -296,7 +296,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
{
if (!IsHordeFlagPickedup())
return;
SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
SetHordeFlagPicker(ObjectGuid::Empty); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// horde flag in base (but not respawned yet)
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Horde Flag from Player
@@ -315,7 +315,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
{
if (!IsAllianceFlagPickedup())
return;
SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
SetAllianceFlagPicker(ObjectGuid::Empty); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// alliance flag in base (but not respawned yet)
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Alliance Flag from Player
@@ -385,7 +385,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
if (GetFlagPickerGUID(TEAM_HORDE) == player->GetGUID())
{
SetHordeFlagPicker(0);
SetHordeFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
}
}
@@ -396,7 +396,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
if (GetFlagPickerGUID(TEAM_ALLIANCE) == player->GetGUID())
{
SetAllianceFlagPicker(0);
SetAllianceFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
}
}
@@ -411,7 +411,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
return;
if (GetFlagPickerGUID(TEAM_HORDE) == player->GetGUID())
{
SetHordeFlagPicker(0);
SetHordeFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
if (_flagDebuffState == 1)
player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
@@ -428,7 +428,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* player)
return;
if (GetFlagPickerGUID(TEAM_ALLIANCE) == player->GetGUID())
{
SetAllianceFlagPicker(0);
SetAllianceFlagPicker(ObjectGuid::Empty);
player->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
if (_flagDebuffState == 1)
player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
@@ -583,7 +583,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* player, GameObject* target
player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
}
void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
void BattlegroundWS::RemovePlayer(Player* player, ObjectGuid guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
if (IsAllianceFlagPickedup() && m_FlagKeepers[TEAM_ALLIANCE] == guid)
@@ -591,7 +591,7 @@ void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
if (!player)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundWS: Removing offline player who has the FLAG!!");
SetAllianceFlagPicker(0);
SetAllianceFlagPicker(ObjectGuid::Empty);
RespawnFlag(ALLIANCE, false);
}
else
@@ -602,7 +602,7 @@ void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
if (!player)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundWS: Removing offline player who has the FLAG!!");
SetHordeFlagPicker(0);
SetHordeFlagPicker(ObjectGuid::Empty);
RespawnFlag(HORDE, false);
}
else
@@ -731,10 +731,10 @@ void BattlegroundWS::Reset()
//call parent's class reset
Battleground::Reset();
m_FlagKeepers[TEAM_ALLIANCE] = 0;
m_FlagKeepers[TEAM_HORDE] = 0;
m_DroppedFlagGUID[TEAM_ALLIANCE] = 0;
m_DroppedFlagGUID[TEAM_HORDE] = 0;
m_FlagKeepers[TEAM_ALLIANCE].Clear();
m_FlagKeepers[TEAM_HORDE].Clear();
m_DroppedFlagGUID[TEAM_ALLIANCE].Clear();
m_DroppedFlagGUID[TEAM_HORDE].Clear();
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
m_TeamScores[TEAM_ALLIANCE] = 0;
@@ -152,7 +152,7 @@ struct BattlegroundWGScore final : public BattlegroundScore
friend class BattlegroundWS;
protected:
BattlegroundWGScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { }
BattlegroundWGScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { }
void UpdateScore(uint32 type, uint32 value) override
{
@@ -197,16 +197,16 @@ class BattlegroundWS : public Battleground
void StartingEventOpenDoors() override;
/* BG Flags */
uint64 GetFlagPickerGUID(int32 team) const override
ObjectGuid GetFlagPickerGUID(int32 team) const override
{
if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
return m_FlagKeepers[team];
return 0;
return ObjectGuid::Empty;
}
void SetAllianceFlagPicker(uint64 guid) { m_FlagKeepers[TEAM_ALLIANCE] = guid; }
void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[TEAM_HORDE] = guid; }
bool IsAllianceFlagPickedup() const { return m_FlagKeepers[TEAM_ALLIANCE] != 0; }
bool IsHordeFlagPickedup() const { return m_FlagKeepers[TEAM_HORDE] != 0; }
void SetAllianceFlagPicker(ObjectGuid guid) { m_FlagKeepers[TEAM_ALLIANCE] = guid; }
void SetHordeFlagPicker(ObjectGuid guid) { m_FlagKeepers[TEAM_HORDE] = guid; }
bool IsAllianceFlagPickedup() const { return !m_FlagKeepers[TEAM_ALLIANCE].IsEmpty(); }
bool IsHordeFlagPickedup() const { return !m_FlagKeepers[TEAM_HORDE].IsEmpty(); }
void RespawnFlag(uint32 Team, bool captured);
void RespawnFlagAfterDrop(uint32 Team);
uint8 GetFlagState(uint32 team) { return _flagState[GetTeamIndexByTeamId(team)]; }
@@ -216,7 +216,7 @@ class BattlegroundWS : public Battleground
void EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) override;
void EventPlayerCapturedFlag(Player* player);
void RemovePlayer(Player* player, uint64 guid, uint32 team) override;
void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
void HandleAreaTrigger(Player* player, uint32 trigger) override;
void HandleKillPlayer(Player* player, Player* killer) override;
bool SetupBattleground() override;
@@ -228,13 +228,13 @@ class BattlegroundWS : public Battleground
void SetLastFlagCapture(uint32 team) { _lastFlagCaptureTeam = team; }
void UpdateTeamScore(uint32 team);
bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
void SetDroppedFlagGUID(uint64 guid, int32 team = -1) override
void SetDroppedFlagGUID(ObjectGuid guid, int32 team = -1) override
{
if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
m_DroppedFlagGUID[team] = guid;
}
uint64 GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];}
ObjectGuid GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)]; }
void FillInitialWorldStates(WorldPacket& data) override;
/* Scorekeeping */
@@ -248,8 +248,8 @@ class BattlegroundWS : public Battleground
bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = nullptr, uint32 miscvalue1 = 0) override;
private:
uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde
uint64 m_DroppedFlagGUID[2];
ObjectGuid m_FlagKeepers[2]; // 0 - alliance, 1 - horde
ObjectGuid m_DroppedFlagGUID[2];
uint8 _flagState[2]; // for checking flag state
int32 _flagsTimer[2];
int32 _flagsDropTimer[2];
+31 -31
View File
@@ -58,7 +58,7 @@ void CalendarMgr::LoadFromDB()
Field* fields = result->Fetch();
uint64 eventId = fields[0].GetUInt64();
uint64 creatorGUID = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
ObjectGuid creatorGUID = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32());
std::string title = fields[2].GetString();
std::string description = fields[3].GetString();
CalendarEventType type = CalendarEventType(fields[4].GetUInt8());
@@ -91,8 +91,8 @@ void CalendarMgr::LoadFromDB()
uint64 inviteId = fields[0].GetUInt64();
uint64 eventId = fields[1].GetUInt64();
uint64 invitee = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
uint64 senderGUID = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER);
ObjectGuid invitee = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
ObjectGuid senderGUID = ObjectGuid(HIGHGUID_PLAYER, fields[3].GetUInt32());
CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8());
uint32 statusTime = fields[5].GetUInt32();
CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8());
@@ -146,7 +146,7 @@ void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite
}
}
void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
void CalendarMgr::RemoveEvent(uint64 eventId, ObjectGuid remover)
{
CalendarEvent* calendarEvent = GetEvent(eventId);
@@ -173,7 +173,7 @@ void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
// guild events only? check invite status here?
// When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki)
if (remover && invite->GetInviteeGUID() != remover)
mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED);
mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID().GetCounter()), calendarEvent, MAIL_CHECK_MASK_COPIED);
delete invite;
}
@@ -189,7 +189,7 @@ void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
_events.erase(calendarEvent);
}
void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover*/)
void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*remover*/)
{
CalendarEvent* calendarEvent = GetEvent(eventId);
@@ -228,7 +228,7 @@ void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT);
stmt->setUInt64(0, calendarEvent->GetEventId());
stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID()));
stmt->setUInt32(1, calendarEvent->GetCreatorGUID().GetCounter());
stmt->setString(2, calendarEvent->GetTitle());
stmt->setString(3, calendarEvent->GetDescription());
stmt->setUInt8(4, calendarEvent->GetType());
@@ -250,8 +250,8 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE);
stmt->setUInt64(0, invite->GetInviteId());
stmt->setUInt64(1, invite->GetEventId());
stmt->setUInt32(2, GUID_LOPART(invite->GetInviteeGUID()));
stmt->setUInt32(3, GUID_LOPART(invite->GetSenderGUID()));
stmt->setUInt32(2, invite->GetInviteeGUID().GetCounter());
stmt->setUInt32(3, invite->GetSenderGUID().GetCounter());
stmt->setUInt8(4, invite->GetStatus());
stmt->setUInt32(5, uint32(invite->GetStatusTime()));
stmt->setUInt8(6, invite->GetRank());
@@ -259,18 +259,18 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans)
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}
void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid)
void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid)
{
for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
if ((*itr)->GetCreatorGUID() == guid)
RemoveEvent((*itr)->GetEventId(), 0); // don't send mail if removing a character
RemoveEvent((*itr)->GetEventId(), ObjectGuid::Empty); // don't send mail if removing a character
CalendarInviteStore playerInvites = GetPlayerInvites(guid);
for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid);
}
void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId)
void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId)
{
for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement()))
@@ -340,7 +340,7 @@ uint64 CalendarMgr::GetFreeInviteId()
return inviteId;
}
CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid)
CalendarEventStore CalendarMgr::GetPlayerEvents(ObjectGuid guid)
{
CalendarEventStore events;
@@ -363,7 +363,7 @@ CalendarInviteStore const& CalendarMgr::GetEventInvites(uint64 eventId)
return _invites[eventId];
}
CalendarInviteStore CalendarMgr::GetPlayerInvites(uint64 guid)
CalendarInviteStore CalendarMgr::GetPlayerInvites(ObjectGuid guid)
{
CalendarInviteStore invites;
@@ -375,7 +375,7 @@ CalendarInviteStore CalendarMgr::GetPlayerInvites(uint64 guid)
return invites;
}
uint32 CalendarMgr::GetPlayerNumPending(uint64 guid)
uint32 CalendarMgr::GetPlayerNumPending(ObjectGuid guid)
{
CalendarInviteStore const& invites = GetPlayerInvites(guid);
@@ -397,10 +397,10 @@ uint32 CalendarMgr::GetPlayerNumPending(uint64 guid)
return pendingNum;
}
std::string CalendarEvent::BuildCalendarMailSubject(uint64 remover) const
std::string CalendarEvent::BuildCalendarMailSubject(ObjectGuid remover) const
{
std::ostringstream strm;
strm << remover << ':' << _title;
strm << remover.GetRawValue() << ':' << _title;
return strm.str();
}
@@ -423,13 +423,13 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite)
time_t statusTime = invite.GetStatusTime();
bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00
uint64 invitee = invite.GetInviteeGUID();
ObjectGuid invitee = invite.GetInviteeGUID();
Player* player = ObjectAccessor::FindPlayer(invitee);
uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee);
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1);
data.appendPackGUID(invitee);
data << invitee.WriteAsPacked();
data << uint64(invite.GetEventId());
data << uint64(invite.GetInviteId());
data << uint8(level);
@@ -474,7 +474,7 @@ void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEven
void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4);
data.appendPackGUID(invite.GetInviteeGUID());
data << invite.GetInviteeGUID().WriteAsPacked();
data << uint64(calendarEvent.GetEventId());
data.AppendPackedTime(calendarEvent.GetEventTime());
data << uint32(calendarEvent.GetFlags());
@@ -498,7 +498,7 @@ void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEve
void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags)
{
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1);
data.appendPackGUID(invite.GetInviteeGUID());
data << invite.GetInviteeGUID().WriteAsPacked();
data << uint64(invite.GetEventId());
data << uint32(flags);
data << uint8(1); // FIXME
@@ -509,7 +509,7 @@ void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEve
void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1);
data.appendPackGUID(invite.GetInviteeGUID());
data << invite.GetInviteeGUID().WriteAsPacked();
data << uint64(invite.GetEventId());
data << uint8(invite.GetRank());
data << uint8(1); // Unk boolean - Display to client?
@@ -533,8 +533,8 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEven
data << uint8(invite.GetStatus());
data << uint8(invite.GetRank());
data.appendPackGUID(calendarEvent.GetCreatorGUID());
data.appendPackGUID(invite.GetSenderGUID());
data << calendarEvent.GetCreatorGUID().WriteAsPacked();
data << invite.GetSenderGUID().WriteAsPacked();
if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
{
@@ -546,7 +546,7 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEven
player->SendDirectMessage(&data);
}
void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType)
void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType)
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
@@ -556,7 +556,7 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv
WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32);
data << uint8(sendType);
data.appendPackGUID(calendarEvent.GetCreatorGUID());
data << calendarEvent.GetCreatorGUID().WriteAsPacked();
data << uint64(calendarEvent.GetEventId());
data << calendarEvent.GetTitle();
data << calendarEvent.GetDescription();
@@ -575,13 +575,13 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv
for (CalendarInviteStore::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr)
{
CalendarInvite const* calendarInvite = (*itr);
uint64 inviteeGuid = calendarInvite->GetInviteeGUID();
ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID();
Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid);
uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid);
uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid);
data.appendPackGUID(inviteeGuid);
data << inviteeGuid.WriteAsPacked();
data << uint8(inviteeLevel);
data << uint8(calendarInvite->GetStatus());
data << uint8(calendarInvite->GetRank());
@@ -594,7 +594,7 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv
player->SendDirectMessage(&data);
}
void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status)
void CalendarMgr::SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
{
@@ -608,7 +608,7 @@ void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent
}
}
void CalendarMgr::SendCalendarClearPendingAction(uint64 guid)
void CalendarMgr::SendCalendarClearPendingAction(ObjectGuid guid)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
{
@@ -617,7 +617,7 @@ void CalendarMgr::SendCalendarClearPendingAction(uint64 guid)
}
}
void CalendarMgr::SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param /*= NULL*/)
void CalendarMgr::SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param /*= NULL*/)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
{
+26 -25
View File
@@ -21,6 +21,7 @@
#include "Common.h"
#include "DatabaseEnv.h"
#include "WorldPacket.h"
#include "ObjectGuid.h"
enum CalendarMailAnswers
{
@@ -141,10 +142,10 @@ struct CalendarInvite
_text = calendarInvite.GetText();
}
CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(NULL)),
CalendarInvite() : _inviteId(1), _eventId(0), _invitee(), _senderGUID(), _statusTime(time(NULL)),
_status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { }
CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime,
CalendarInvite(uint64 inviteId, uint64 eventId, ObjectGuid invitee, ObjectGuid senderGUID, time_t statusTime,
CalendarInviteStatus status, CalendarModerationRank rank, std::string text) :
_inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _statusTime(statusTime),
_status(status), _rank(rank), _text(text) { }
@@ -157,11 +158,11 @@ struct CalendarInvite
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetSenderGUID(uint64 guid) { _senderGUID = guid; }
uint64 GetSenderGUID() const { return _senderGUID; }
void SetSenderGUID(ObjectGuid guid) { _senderGUID = guid; }
ObjectGuid GetSenderGUID() const { return _senderGUID; }
void SetInvitee(uint64 guid) { _invitee = guid; }
uint64 GetInviteeGUID() const { return _invitee; }
void SetInvitee(ObjectGuid guid) { _invitee = guid; }
ObjectGuid GetInviteeGUID() const { return _invitee; }
void SetStatusTime(time_t statusTime) { _statusTime = statusTime; }
time_t GetStatusTime() const { return _statusTime; }
@@ -178,8 +179,8 @@ struct CalendarInvite
private:
uint64 _inviteId;
uint64 _eventId;
uint64 _invitee;
uint64 _senderGUID;
ObjectGuid _invitee;
ObjectGuid _senderGUID;
time_t _statusTime;
CalendarInviteStatus _status;
CalendarModerationRank _rank;
@@ -203,13 +204,13 @@ struct CalendarEvent
_description = calendarEvent.GetDescription();
}
CalendarEvent(uint64 eventId, uint64 creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId,
CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId,
time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) :
_eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId),
_eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title),
_description(description) { }
CalendarEvent() : _eventId(1), _creatorGUID(0), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0),
CalendarEvent() : _eventId(1), _creatorGUID(), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0),
_flags(0), _timezoneTime(0), _title(""), _description("") { }
~CalendarEvent();
@@ -217,8 +218,8 @@ struct CalendarEvent
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; }
uint64 GetCreatorGUID() const { return _creatorGUID; }
void SetCreatorGUID(ObjectGuid guid) { _creatorGUID = guid; }
ObjectGuid GetCreatorGUID() const { return _creatorGUID; }
void SetGuildId(uint32 guildId) { _guildId = guildId; }
uint32 GetGuildId() const { return _guildId; }
@@ -247,12 +248,12 @@ struct CalendarEvent
bool IsGuildEvent() const { return (_flags & CALENDAR_FLAG_GUILD_EVENT) != 0; }
bool IsGuildAnnouncement() const { return (_flags & CALENDAR_FLAG_WITHOUT_INVITES) != 0; }
std::string BuildCalendarMailSubject(uint64 remover) const;
std::string BuildCalendarMailSubject(ObjectGuid remover) const;
std::string BuildCalendarMailBody() const;
private:
uint64 _eventId;
uint64 _creatorGUID;
ObjectGuid _creatorGUID;
uint32 _guildId;
CalendarEventType _type;
int32 _dungeonId;
@@ -291,44 +292,44 @@ class CalendarMgr
CalendarEvent* GetEvent(uint64 eventId) const;
CalendarEventStore const& GetEvents() const { return _events; }
CalendarEventStore GetPlayerEvents(uint64 guid);
CalendarEventStore GetPlayerEvents(ObjectGuid guid);
CalendarInvite* GetInvite(uint64 inviteId) const;
CalendarEventInviteStore const& GetInvites() const { return _invites; }
CalendarInviteStore const& GetEventInvites(uint64 eventId);
CalendarInviteStore GetPlayerInvites(uint64 guid);
CalendarInviteStore GetPlayerInvites(ObjectGuid guid);
void FreeEventId(uint64 id);
uint64 GetFreeEventId();
void FreeInviteId(uint64 id);
uint64 GetFreeInviteId();
uint32 GetPlayerNumPending(uint64 guid);
uint32 GetPlayerNumPending(ObjectGuid guid);
void AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType);
void RemoveEvent(uint64 eventId, uint64 remover);
void RemoveEvent(uint64 eventId, ObjectGuid remover);
void UpdateEvent(CalendarEvent* calendarEvent);
void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite);
void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans);
void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover);
void RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid remover);
void UpdateInvite(CalendarInvite* invite);
void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans);
void RemoveAllPlayerEventsAndInvites(uint64 guid);
void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId);
void RemoveAllPlayerEventsAndInvites(ObjectGuid guid);
void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId);
void SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType);
void SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType);
void SendCalendarEventInvite(CalendarInvite const& invite);
void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags);
void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status);
void SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status);
void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime);
void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent);
void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarClearPendingAction(uint64 guid);
void SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param = NULL);
void SendCalendarClearPendingAction(ObjectGuid guid);
void SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param = NULL);
void SendPacketToAllEventRelatives(WorldPacket& packet, CalendarEvent const& calendarEvent);
};
+47 -47
View File
@@ -32,7 +32,7 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 team):
_flags(0),
_channelId(channelId),
_Team(team),
_ownerGUID(0),
_ownerGUID(),
_name(name),
_password("")
{
@@ -80,10 +80,10 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 team):
Tokenizer tokens(db_BannedList, ' ');
for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i)
{
uint64 banned_guid = atol(*i);
ObjectGuid banned_guid(uint64(strtoull(*i, NULL, 10)));
if (banned_guid)
{
TC_LOG_DEBUG("chat.system", "Channel(%s) loaded bannedStore guid:" UI64FMTD "", name.c_str(), banned_guid);
TC_LOG_DEBUG("chat.system", "Channel(%s) loaded bannedStore %s", name.c_str(), banned_guid.ToString().c_str());
bannedStore.insert(banned_guid);
}
}
@@ -110,7 +110,7 @@ void Channel::UpdateChannelInDB() const
std::ostringstream banlist;
BannedContainer::const_iterator iter;
for (iter = bannedStore.begin(); iter != bannedStore.end(); ++iter)
banlist << (*iter) << ' ';
banlist << iter->GetRawValue() << ' ';
std::string banListStr = banlist.str();
@@ -149,7 +149,7 @@ void Channel::CleanOldChannelsInDB()
void Channel::JoinChannel(Player* player, std::string const& pass)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (IsOn(guid))
{
// Do not send error message for built-in channels
@@ -227,7 +227,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
void Channel::LeaveChannel(Player* player, bool send)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
if (send)
@@ -269,7 +269,7 @@ void Channel::LeaveChannel(Player* player, bool send)
// If the channel owner left and there are still playersStore inside, pick a new owner
if (changeowner && _ownership && !playersStore.empty())
{
uint64 newowner = playersStore.begin()->second.player;
ObjectGuid newowner = playersStore.begin()->second.player;
playersStore[newowner].SetModerator(true);
SetOwner(newowner);
}
@@ -278,7 +278,7 @@ void Channel::LeaveChannel(Player* player, bool send)
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban)
{
uint64 good = player->GetGUID();
ObjectGuid good = player->GetGUID();
if (!IsOn(good))
{
@@ -297,7 +297,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
}
Player* bad = sObjectAccessor->FindPlayerByName(badname);
uint64 victim = bad ? bad->GetGUID() : 0;
ObjectGuid victim = bad ? bad->GetGUID() : ObjectGuid::Empty;
if (!victim || !IsOn(victim))
{
WorldPacket data;
@@ -340,7 +340,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
if (changeowner && _ownership && !playersStore.empty())
{
uint64 newowner = good;
ObjectGuid newowner = good;
playersStore[newowner].SetModerator(true);
SetOwner(newowner);
}
@@ -348,7 +348,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
void Channel::UnBan(Player const* player, std::string const& badname)
{
uint64 good = player->GetGUID();
ObjectGuid good = player->GetGUID();
if (!IsOn(good))
{
@@ -367,7 +367,7 @@ void Channel::UnBan(Player const* player, std::string const& badname)
}
Player* bad = sObjectAccessor->FindPlayerByName(badname);
uint64 victim = bad ? bad->GetGUID(): 0;
ObjectGuid victim = bad ? bad->GetGUID() : ObjectGuid::Empty;
if (!victim || !IsBanned(victim))
{
@@ -388,7 +388,7 @@ void Channel::UnBan(Player const* player, std::string const& badname)
void Channel::Password(Player const* player, std::string const& pass)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
ChatHandler chat(player->GetSession());
if (!IsOn(guid))
@@ -418,7 +418,7 @@ void Channel::Password(Player const* player, std::string const& pass)
void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
@@ -440,7 +440,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
return;
Player* newp = sObjectAccessor->FindPlayerByName(p2n);
uint64 victim = newp ? newp->GetGUID() : 0;
ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
if (!victim || !IsOn(victim) ||
(player->GetTeam() != newp->GetTeam() &&
@@ -469,7 +469,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
void Channel::SetOwner(Player const* player, std::string const& newname)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
@@ -488,7 +488,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
}
Player* newp = sObjectAccessor->FindPlayerByName(newname);
uint64 victim = newp ? newp->GetGUID() : 0;
ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
if (!victim || !IsOn(victim) ||
(player->GetTeam() != newp->GetTeam() &&
@@ -505,7 +505,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
SetOwner(victim);
}
void Channel::SendWhoOwner(uint64 guid)
void Channel::SendWhoOwner(ObjectGuid guid)
{
WorldPacket data;
if (IsOn(guid))
@@ -517,7 +517,7 @@ void Channel::SendWhoOwner(uint64 guid)
void Channel::List(Player const* player)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
@@ -565,7 +565,7 @@ void Channel::List(Player const* player)
void Channel::Announce(Player const* player)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
@@ -595,7 +595,7 @@ void Channel::Announce(Player const* player)
UpdateChannelInDB();
}
void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
void Channel::Say(ObjectGuid guid, std::string const& what, uint32 lang)
{
if (what.empty())
return;
@@ -626,12 +626,12 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
else
ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false);
SendToAll(&data, !playersStore[guid].IsModerator() ? guid : ObjectGuid::Empty);
}
void Channel::Invite(Player const* player, std::string const& newname)
{
uint64 guid = player->GetGUID();
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
@@ -676,7 +676,7 @@ void Channel::Invite(Player const* player, std::string const& newname)
return;
}
if (!newp->GetSocial()->HasIgnore(GUID_LOPART(guid)))
if (!newp->GetSocial()->HasIgnore(guid.GetCounter()))
{
WorldPacket data;
MakeInvite(&data, guid);
@@ -689,7 +689,7 @@ void Channel::Invite(Player const* player, std::string const& newname)
SendToOne(&data, guid);
}
void Channel::SetOwner(uint64 guid, bool exclaim)
void Channel::SetOwner(ObjectGuid guid, bool exclaim)
{
if (_ownerGUID)
{
@@ -720,15 +720,15 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
}
}
void Channel::SendToAll(WorldPacket* data, uint64 guid)
void Channel::SendToAll(WorldPacket* data, ObjectGuid guid)
{
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
if (Player* player = ObjectAccessor::FindPlayer(i->first))
if (!guid || !player->GetSocial()->HasIgnore(GUID_LOPART(guid)))
if (!guid || !player->GetSocial()->HasIgnore(guid.GetCounter()))
player->GetSession()->SendPacket(data);
}
void Channel::SendToAllButOne(WorldPacket* data, uint64 who)
void Channel::SendToAllButOne(WorldPacket* data, ObjectGuid who)
{
for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
if (i->first != who)
@@ -736,18 +736,18 @@ void Channel::SendToAllButOne(WorldPacket* data, uint64 who)
player->GetSession()->SendPacket(data);
}
void Channel::SendToOne(WorldPacket* data, uint64 who)
void Channel::SendToOne(WorldPacket* data, ObjectGuid who)
{
if (Player* player = ObjectAccessor::FindPlayer(who))
player->GetSession()->SendPacket(data);
}
void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/)
void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
{
}
void Channel::DeVoice(uint64 /*guid1*/, uint64 /*guid2*/)
void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
{
}
@@ -759,13 +759,13 @@ void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type)
*data << _name;
}
void Channel::MakeJoined(WorldPacket* data, uint64 guid)
void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
*data << uint64(guid);
}
void Channel::MakeLeft(WorldPacket* data, uint64 guid)
void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
*data << uint64(guid);
@@ -801,13 +801,13 @@ void Channel::MakeNotModerator(WorldPacket* data)
MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
}
void Channel::MakePasswordChanged(WorldPacket* data, uint64 guid)
void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
*data << uint64(guid);
}
void Channel::MakeOwnerChanged(WorldPacket* data, uint64 guid)
void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
*data << uint64(guid);
@@ -835,7 +835,7 @@ void Channel::MakeChannelOwner(WorldPacket* data)
*data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name);
}
void Channel::MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags)
void Channel::MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags)
{
MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE);
*data << uint64(guid);
@@ -843,13 +843,13 @@ void Channel::MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags)
*data << uint8(GetPlayerFlags(guid));
}
void Channel::MakeAnnouncementsOn(WorldPacket* data, uint64 guid)
void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
*data << uint64(guid);
}
void Channel::MakeAnnouncementsOff(WorldPacket* data, uint64 guid)
void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
*data << uint64(guid);
@@ -860,7 +860,7 @@ void Channel::MakeMuted(WorldPacket* data)
MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
}
void Channel::MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good)
void Channel::MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{
MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE);
*data << uint64(bad);
@@ -872,14 +872,14 @@ void Channel::MakeBanned(WorldPacket* data)
MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
}
void Channel::MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good)
void Channel::MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{
MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE);
*data << uint64(bad);
*data << uint64(good);
}
void Channel::MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good)
void Channel::MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{
MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE);
*data << uint64(bad);
@@ -892,13 +892,13 @@ void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string &name)
*data << name;
}
void Channel::MakePlayerAlreadyMember(WorldPacket* data, uint64 guid)
void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
*data << uint64(guid);
}
void Channel::MakeInvite(WorldPacket* data, uint64 guid)
void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
*data << uint64(guid);
@@ -951,19 +951,19 @@ void Channel::MakeNotInLfg(WorldPacket* data)
MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
}
void Channel::MakeVoiceOn(WorldPacket* data, uint64 guid)
void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
*data << uint64(guid);
}
void Channel::MakeVoiceOff(WorldPacket* data, uint64 guid)
void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
*data << uint64(guid);
}
void Channel::JoinNotify(uint64 guid)
void Channel::JoinNotify(ObjectGuid guid)
{
WorldPacket data(IsConstant() ? SMSG_USERLIST_ADD : SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
data << uint64(guid);
@@ -978,7 +978,7 @@ void Channel::JoinNotify(uint64 guid)
SendToAll(&data);
}
void Channel::LeaveNotify(uint64 guid)
void Channel::LeaveNotify(ObjectGuid guid)
{
WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
data << uint64(guid);
+35 -35
View File
@@ -122,7 +122,7 @@ class Channel
{
struct PlayerInfo
{
uint64 player;
ObjectGuid player;
uint8 flags;
bool HasFlag(uint8 flag) const { return (flags & flag) != 0; }
@@ -169,21 +169,21 @@ class Channel
void UnBan(Player const* player, std::string const& badname);
void Password(Player const* player, std::string const& pass);
void SetMode(Player const* player, std::string const& p2n, bool mod, bool set);
void SetOwner(uint64 guid, bool exclaim = true);
void SetOwner(ObjectGuid guid, bool exclaim = true);
void SetOwner(Player const* player, std::string const& name);
void SendWhoOwner(uint64 guid);
void SendWhoOwner(ObjectGuid guid);
void SetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, true); }
void UnsetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, false); }
void SetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, true); }
void UnsetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, false); }
void List(Player const* player);
void Announce(Player const* player);
void Say(uint64 guid, std::string const& what, uint32 lang);
void Say(ObjectGuid guid, std::string const& what, uint32 lang);
void Invite(Player const* player, std::string const& newp);
void Voice(uint64 guid1, uint64 guid2);
void DeVoice(uint64 guid1, uint64 guid2);
void JoinNotify(uint64 guid); // invisible notify
void LeaveNotify(uint64 guid); // invisible notify
void Voice(ObjectGuid guid1, ObjectGuid guid2);
void DeVoice(ObjectGuid guid1, ObjectGuid guid2);
void JoinNotify(ObjectGuid guid); // invisible notify
void LeaveNotify(ObjectGuid guid); // invisible notify
void SetOwnership(bool ownership) { _ownership = ownership; };
static void CleanOldChannelsInDB();
@@ -191,29 +191,29 @@ class Channel
// initial packet data (notify type and channel name)
void MakeNotifyPacket(WorldPacket* data, uint8 notify_type);
// type specific packet data
void MakeJoined(WorldPacket* data, uint64 guid); //+ 0x00
void MakeLeft(WorldPacket* data, uint64 guid); //+ 0x01
void MakeJoined(WorldPacket* data, ObjectGuid guid); //+ 0x00
void MakeLeft(WorldPacket* data, ObjectGuid guid); //+ 0x01
void MakeYouJoined(WorldPacket* data); //+ 0x02
void MakeYouLeft(WorldPacket* data); //+ 0x03
void MakeWrongPassword(WorldPacket* data); //? 0x04
void MakeNotMember(WorldPacket* data); //? 0x05
void MakeNotModerator(WorldPacket* data); //? 0x06
void MakePasswordChanged(WorldPacket* data, uint64 guid); //+ 0x07
void MakeOwnerChanged(WorldPacket* data, uint64 guid); //? 0x08
void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09
void MakePasswordChanged(WorldPacket* data, ObjectGuid guid); //+ 0x07
void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid); //? 0x08
void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09
void MakeNotOwner(WorldPacket* data); //? 0x0A
void MakeChannelOwner(WorldPacket* data); //? 0x0B
void MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags); //+ 0x0C
void MakeAnnouncementsOn(WorldPacket* data, uint64 guid); //+ 0x0D
void MakeAnnouncementsOff(WorldPacket* data, uint64 guid); //+ 0x0E
void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags);//+ 0x0C
void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid); //+ 0x0D
void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid); //+ 0x0E
void MakeMuted(WorldPacket* data); //? 0x11
void MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good); //? 0x12
void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x12
void MakeBanned(WorldPacket* data); //? 0x13
void MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x14
void MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good); //? 0x15
void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16
void MakePlayerAlreadyMember(WorldPacket* data, uint64 guid); //+ 0x17
void MakeInvite(WorldPacket* data, uint64 guid); //? 0x18
void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x14
void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x15
void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16
void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid); //+ 0x17
void MakeInvite(WorldPacket* data, ObjectGuid guid); //? 0x18
void MakeInviteWrongFaction(WorldPacket* data); //? 0x19
void MakeWrongFaction(WorldPacket* data); //? 0x1A
void MakeInvalidName(WorldPacket* data); //? 0x1B
@@ -223,26 +223,26 @@ class Channel
void MakeThrottled(WorldPacket* data); //? 0x1F
void MakeNotInArea(WorldPacket* data); //? 0x20
void MakeNotInLfg(WorldPacket* data); //? 0x21
void MakeVoiceOn(WorldPacket* data, uint64 guid); //+ 0x22
void MakeVoiceOff(WorldPacket* data, uint64 guid); //+ 0x23
void MakeVoiceOn(WorldPacket* data, ObjectGuid guid); //+ 0x22
void MakeVoiceOff(WorldPacket* data, ObjectGuid guid); //+ 0x23
void SendToAll(WorldPacket* data, uint64 guid = 0);
void SendToAllButOne(WorldPacket* data, uint64 who);
void SendToOne(WorldPacket* data, uint64 who);
void SendToAll(WorldPacket* data, ObjectGuid guid = ObjectGuid::Empty);
void SendToAllButOne(WorldPacket* data, ObjectGuid who);
void SendToOne(WorldPacket* data, ObjectGuid who);
bool IsOn(uint64 who) const { return playersStore.find(who) != playersStore.end(); }
bool IsBanned(uint64 guid) const { return bannedStore.find(guid) != bannedStore.end(); }
bool IsOn(ObjectGuid who) const { return playersStore.find(who) != playersStore.end(); }
bool IsBanned(ObjectGuid guid) const { return bannedStore.find(guid) != bannedStore.end(); }
void UpdateChannelInDB() const;
void UpdateChannelUseageInDB() const;
uint8 GetPlayerFlags(uint64 guid) const
uint8 GetPlayerFlags(ObjectGuid guid) const
{
PlayerContainer::const_iterator itr = playersStore.find(guid);
return itr != playersStore.end() ? itr->second.flags : 0;
}
void SetModerator(uint64 guid, bool set)
void SetModerator(ObjectGuid guid, bool set)
{
if (playersStore[guid].IsModerator() != set)
{
@@ -255,7 +255,7 @@ class Channel
}
}
void SetMute(uint64 guid, bool set)
void SetMute(ObjectGuid guid, bool set)
{
if (playersStore[guid].IsMuted() != set)
{
@@ -268,8 +268,8 @@ class Channel
}
}
typedef std::map<uint64, PlayerInfo> PlayerContainer;
typedef std::set<uint64> BannedContainer;
typedef std::map<ObjectGuid, PlayerInfo> PlayerContainer;
typedef GuidSet BannedContainer;
bool _announce;
bool _ownership;
@@ -277,7 +277,7 @@ class Channel
uint8 _flags;
uint32 _channelId;
uint32 _Team;
uint64 _ownerGUID;
ObjectGuid _ownerGUID;
std::string _name;
std::string _password;
PlayerContainer playersStore;
+37 -37
View File
@@ -104,7 +104,7 @@ ChatCommand* ChatHandler::getCommandTable()
return commandTableCache;
}
std::string ChatHandler::PGetParseString(int32 entry, ...) const
std::string ChatHandler::PGetParseString(uint32 entry, ...) const
{
const char *format = GetTrinityString(entry);
char str[1024];
@@ -115,7 +115,7 @@ std::string ChatHandler::PGetParseString(int32 entry, ...) const
return std::string(str);
}
const char *ChatHandler::GetTrinityString(int32 entry) const
char const* ChatHandler::GetTrinityString(uint32 entry) const
{
return m_session->GetTrinityString(entry);
}
@@ -125,7 +125,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
return HasPermission(cmd.Permission);
}
bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong)
bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
{
WorldSession* target_session = NULL;
uint32 target_account = 0;
@@ -253,12 +253,12 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str)
free(buf);
}
void ChatHandler::SendSysMessage(int32 entry)
void ChatHandler::SendSysMessage(uint32 entry)
{
SendSysMessage(GetTrinityString(entry));
}
void ChatHandler::PSendSysMessage(int32 entry, ...)
void ChatHandler::PSendSysMessage(uint32 entry, ...)
{
const char *format = GetTrinityString(entry);
va_list ap;
@@ -345,7 +345,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
Player* player = m_session->GetPlayer();
if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity()))
{
uint64 guid = player->GetTarget();
ObjectGuid guid = player->GetTarget();
uint32 areaId = player->GetAreaId();
std::string areaName = "Unknown";
std::string zoneName = "Unknown";
@@ -356,14 +356,14 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
zoneName = zone->area_name;
}
sLog->outCommand(m_session->GetAccountId(), "Command: %s [Player: %s (Guid: %u) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected %s: %s (GUID: %u)]",
fullcmd.c_str(), player->GetName().c_str(), GUID_LOPART(player->GetGUID()),
sLog->outCommand(m_session->GetAccountId(), "Command: %s [Player: %s (%s) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected: %s (%s)]",
fullcmd.c_str(), player->GetName().c_str(), player->GetGUID().ToString().c_str(),
m_session->GetAccountId(), player->GetPositionX(), player->GetPositionY(),
player->GetPositionZ(), player->GetMapId(),
player->GetMap() ? player->GetMap()->GetMapName() : "Unknown",
areaId, areaName.c_str(), zoneName.c_str(), GetLogNameForGuid(guid),
areaId, areaName.c_str(), zoneName.c_str(),
(player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName().c_str() : "",
GUID_LOPART(guid));
guid.ToString().c_str());
}
}
// some commands have custom error messages. Don't send the default one in these cases.
@@ -628,7 +628,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
return ShowHelpForSubCommands(table, "", cmd);
}
size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, uint64 senderGUID, uint64 receiverGUID, std::string const& message, uint8 chatTag,
size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag,
std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/,
uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/,
std::string const& addonPrefix /*= ""*/)
@@ -653,7 +653,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
data << senderName;
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !IS_PLAYER_GUID(receiverGUID) && !IS_PET_GUID(receiverGUID))
if (receiverGUID && !receiverGUID.IsPlayer() && !receiverGUID.IsPet())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
@@ -675,7 +675,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
case CHAT_MSG_BG_SYSTEM_HORDE:
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !IS_PLAYER_GUID(receiverGUID))
if (receiverGUID && !receiverGUID.IsPlayer())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
@@ -730,11 +730,11 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string const& message,
uint32 achievementId /*= 0*/, std::string const& channelName /*= ""*/, LocaleConstant locale /*= DEFAULT_LOCALE*/, std::string const& addonPrefix /*= ""*/)
{
uint64 senderGUID = 0;
ObjectGuid senderGUID;
std::string senderName = "";
uint8 chatTag = 0;
bool gmMessage = false;
uint64 receiverGUID = 0;
ObjectGuid receiverGUID;
std::string receiverName = "";
if (sender)
{
@@ -761,7 +761,7 @@ Player* ChatHandler::getSelectedPlayer()
if (!m_session)
return NULL;
uint64 selected = m_session->GetPlayer()->GetTarget();
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
return m_session->GetPlayer();
@@ -784,9 +784,9 @@ WorldObject* ChatHandler::getSelectedObject()
if (!m_session)
return NULL;
uint64 guid = m_session->GetPlayer()->GetTarget();
ObjectGuid guid = m_session->GetPlayer()->GetTarget();
if (guid == 0)
if (!guid)
return GetNearbyGameObject();
return ObjectAccessor::GetUnit(*m_session->GetPlayer(), guid);
@@ -805,7 +805,7 @@ Player* ChatHandler::getSelectedPlayerOrSelf()
if (!m_session)
return NULL;
uint64 selected = m_session->GetPlayer()->GetTarget();
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
return m_session->GetPlayer();
@@ -950,7 +950,7 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
Player* pl = m_session->GetPlayer();
GameObject* obj = pl->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT));
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid));
if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
{
@@ -1071,7 +1071,7 @@ static char const* const guidKeys[] =
nullptr
};
uint64 ChatHandler::extractGuidFromLink(char* text)
ObjectGuid ChatHandler::extractGuidFromLink(char* text)
{
int type = 0;
@@ -1080,7 +1080,7 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
// |color|Hplayer:name|h[name]|h|r
char* idS = extractKeyFromLink(text, guidKeys, &type);
if (!idS)
return 0;
return ObjectGuid::Empty;
switch (type)
{
@@ -1088,38 +1088,38 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
{
std::string name = idS;
if (!normalizePlayerName(name))
return 0;
return ObjectGuid::Empty;
if (Player* player = sObjectAccessor->FindPlayerByName(name))
return player->GetGUID();
if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(name))
if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(name))
return guid;
return 0;
return ObjectGuid::Empty;
}
case SPELL_LINK_CREATURE:
{
uint32 lowguid = (uint32)atol(idS);
if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
return MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT);
return ObjectGuid(HIGHGUID_UNIT, data->id, lowguid);
else
return 0;
return ObjectGuid::Empty;
}
case SPELL_LINK_GAMEOBJECT:
{
uint32 lowguid = (uint32)atol(idS);
if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
return MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_GAMEOBJECT);
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
else
return 0;
return ObjectGuid::Empty;
}
}
// unknown type?
return 0;
return ObjectGuid::Empty;
}
std::string ChatHandler::extractPlayerNameFromLink(char* text)
@@ -1136,7 +1136,7 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
return name;
}
bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
{
if (args && *args)
{
@@ -1155,7 +1155,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
*player = pl;
// if need guid value from DB (in name case for check player existence)
uint64 guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : 0;
ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : ObjectGuid::Empty;
// if allowed player guid (if no then only online players allowed)
if (player_guid)
@@ -1172,7 +1172,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
*player = pl;
// if allowed player guid (if no then only online players allowed)
if (player_guid)
*player_guid = pl ? pl->GetGUID() : 0;
*player_guid = pl ? pl->GetGUID() : ObjectGuid::Empty;
if (player_name)
*player_name = pl ? pl->GetName() : "";
@@ -1268,7 +1268,7 @@ std::string ChatHandler::GetNameLink(Player* chr) const
return playerLink(chr->GetName());
}
const char *CliHandler::GetTrinityString(int32 entry) const
char const* CliHandler::GetTrinityString(uint32 entry) const
{
return sObjectMgr->GetTrinityStringForDBCLocale(entry);
}
@@ -1295,10 +1295,10 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
return true;
}
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline)
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
{
player = NULL;
guid = 0;
player = NULL;
guid.Clear();
if (cname)
{
+12 -12
View File
@@ -54,7 +54,7 @@ class ChatHandler
virtual ~ChatHandler() { }
// Builds chat packet and returns receiver guid position in the packet to substitute in whisper builders
static size_t BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, uint64 senderGUID, uint64 receiverGUID, std::string const& message, uint8 chatTag,
static size_t BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag,
std::string const& senderName = "", std::string const& receiverName = "",
uint32 achievementId = 0, bool gmMessage = false, std::string const& channelName = "",
std::string const& addonPrefix = "");
@@ -65,13 +65,13 @@ class ChatHandler
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; }
// function with different implementation for chat/console
virtual const char *GetTrinityString(int32 entry) const;
virtual void SendSysMessage(const char *str);
virtual char const* GetTrinityString(uint32 entry) const;
virtual void SendSysMessage(char const* str);
void SendSysMessage(int32 entry);
void PSendSysMessage(const char *format, ...) ATTR_PRINTF(2, 3);
void PSendSysMessage(int32 entry, ...);
std::string PGetParseString(int32 entry, ...) const;
void SendSysMessage(uint32 entry);
void PSendSysMessage(char const* format, ...) ATTR_PRINTF(2, 3);
void PSendSysMessage(uint32 entry, ...);
std::string PGetParseString(uint32 entry, ...) const;
bool ParseCommands(const char* text);
@@ -90,7 +90,7 @@ class ChatHandler
virtual LocaleConstant GetSessionDbcLocale() const;
virtual int GetSessionDbLocaleIndex() const;
bool HasLowerSecurity(Player* target, uint64 guid, bool strong = false);
bool HasLowerSecurity(Player* target, ObjectGuid guid, bool strong = false);
bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false);
void SendGlobalGMSysMessage(const char *str);
@@ -109,12 +109,12 @@ class ChatHandler
char* extractQuotedArg(char* args);
uint32 extractSpellIdFromLink(char* text);
uint64 extractGuidFromLink(char* text);
ObjectGuid extractGuidFromLink(char* text);
GameTele const* extractGameTeleFromLink(char* text);
bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline = false);
bool GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline = false);
std::string extractPlayerNameFromLink(char* text);
// select by arg (name/link) or in-game selection online/offline player or self if a creature is selected
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
bool extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid = NULL, std::string* player_name = NULL);
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
std::string GetNameLink(Player* chr) const;
@@ -148,7 +148,7 @@ class CliHandler : public ChatHandler
explicit CliHandler(void* callbackArg, Print* zprint) : m_callbackArg(callbackArg), m_print(zprint) { }
// overwrite functions
const char *GetTrinityString(int32 entry) const override;
char const* GetTrinityString(uint32 entry) const override;
bool isAvailable(ChatCommand const& cmd) const override;
bool HasPermission(uint32 /*permission*/) const override { return true; }
void SendSysMessage(const char *str) override;
+1 -1
View File
@@ -269,7 +269,7 @@ HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const
if (!victim)
return NULL;
uint64 const guid = victim->GetGUID();
ObjectGuid guid = victim->GetGUID();
for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i)
{
HostileReference* ref = (*i);
+3 -2
View File
@@ -23,6 +23,7 @@
#include "SharedDefines.h"
#include "LinkedReference/Reference.h"
#include "UnitEvents.h"
#include "ObjectGuid.h"
#include <list>
@@ -103,7 +104,7 @@ class HostileReference : public Reference<Unit, ThreatManager>
//=================================================
uint64 getUnitGuid() const { return iUnitGuid; }
ObjectGuid getUnitGuid() const { return iUnitGuid; }
//=================================================
// reference is not needed anymore. realy delete it !
@@ -132,7 +133,7 @@ class HostileReference : public Reference<Unit, ThreatManager>
private:
float iThreat;
float iTempThreatModifier; // used for taunt
uint64 iUnitGuid;
ObjectGuid iUnitGuid;
bool iOnline;
bool iAccessible;
};
+5 -2
View File
@@ -166,12 +166,15 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case INSTANCE_INFO_DATA:
condMeets = instance->GetData(ConditionValue1) == ConditionValue2;
break;
case INSTANCE_INFO_DATA64:
condMeets = instance->GetData64(ConditionValue1) == ConditionValue2;
case INSTANCE_INFO_GUID_DATA:
condMeets = instance->GetGuidData(ConditionValue1) == ObjectGuid(uint64(ConditionValue2));
break;
case INSTANCE_INFO_BOSS_STATE:
condMeets = instance->GetBossState(ConditionValue1) == EncounterState(ConditionValue2);
break;
case INSTANCE_INFO_DATA64:
condMeets = instance->GetData64(ConditionValue1) == ConditionValue2;
break;
}
}
}
+3 -2
View File
@@ -146,8 +146,9 @@ enum RelationType
enum InstanceInfo
{
INSTANCE_INFO_DATA = 0,
INSTANCE_INFO_DATA64,
INSTANCE_INFO_BOSS_STATE
INSTANCE_INFO_GUID_DATA,
INSTANCE_INFO_BOSS_STATE,
INSTANCE_INFO_DATA64
};
enum MaxConditionTargets
+4 -5
View File
@@ -19,6 +19,7 @@
#define _LFG_H
#include "Common.h"
#include "ObjectGuid.h"
namespace lfg
{
@@ -110,11 +111,9 @@ struct LfgLockInfoData
typedef std::set<uint32> LfgDungeonSet;
typedef std::map<uint32, LfgLockInfoData> LfgLockMap;
typedef std::map<uint64, LfgLockMap> LfgLockPartyMap;
typedef std::set<uint64> LfgGuidSet;
typedef std::list<uint64> LfgGuidList;
typedef std::map<uint64, uint8> LfgRolesMap;
typedef std::map<uint64, uint64> LfgGroupsMap;
typedef std::map<ObjectGuid, LfgLockMap> LfgLockPartyMap;
typedef std::map<ObjectGuid, uint8> LfgRolesMap;
typedef std::map<ObjectGuid, ObjectGuid> LfgGroupsMap;
std::string ConcatenateDungeons(LfgDungeonSet const& dungeons);
std::string GetRolesString(uint8 roles);
@@ -22,7 +22,7 @@ namespace lfg
{
LfgGroupData::LfgGroupData(): m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE),
m_Leader(0), m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS)
m_Leader(), m_Dungeon(0), m_KicksLeft(LFG_GROUP_MAX_KICKS)
{ }
LfgGroupData::~LfgGroupData()
@@ -54,14 +54,14 @@ void LfgGroupData::RestoreState()
m_State = m_OldState;
}
void LfgGroupData::AddPlayer(uint64 guid)
void LfgGroupData::AddPlayer(ObjectGuid guid)
{
m_Players.insert(guid);
}
uint8 LfgGroupData::RemovePlayer(uint64 guid)
uint8 LfgGroupData::RemovePlayer(ObjectGuid guid)
{
LfgGuidSet::iterator it = m_Players.find(guid);
GuidSet::iterator it = m_Players.find(guid);
if (it != m_Players.end())
m_Players.erase(it);
return uint8(m_Players.size());
@@ -72,7 +72,7 @@ void LfgGroupData::RemoveAllPlayers()
m_Players.clear();
}
void LfgGroupData::SetLeader(uint64 guid)
void LfgGroupData::SetLeader(ObjectGuid guid)
{
m_Leader = guid;
}
@@ -98,7 +98,7 @@ LfgState LfgGroupData::GetOldState() const
return m_OldState;
}
LfgGuidSet const& LfgGroupData::GetPlayers() const
GuidSet const& LfgGroupData::GetPlayers() const
{
return m_Players;
}
@@ -108,7 +108,7 @@ uint8 LfgGroupData::GetPlayerCount() const
return m_Players.size();
}
uint64 LfgGroupData::GetLeader() const
ObjectGuid LfgGroupData::GetLeader() const
{
return m_Leader;
}
@@ -42,10 +42,10 @@ class LfgGroupData
// General
void SetState(LfgState state);
void RestoreState();
void AddPlayer(uint64 guid);
uint8 RemovePlayer(uint64 guid);
void AddPlayer(ObjectGuid guid);
uint8 RemovePlayer(ObjectGuid guid);
void RemoveAllPlayers();
void SetLeader(uint64 guid);
void SetLeader(ObjectGuid guid);
// Dungeon
void SetDungeon(uint32 dungeon);
@@ -56,9 +56,9 @@ class LfgGroupData
// General
LfgState GetState() const;
LfgState GetOldState() const;
LfgGuidSet const& GetPlayers() const;
GuidSet const& GetPlayers() const;
uint8 GetPlayerCount() const;
uint64 GetLeader() const;
ObjectGuid GetLeader() const;
// Dungeon
uint32 GetDungeon(bool asId = true) const;
@@ -70,8 +70,8 @@ class LfgGroupData
// General
LfgState m_State; ///< State if group in LFG
LfgState m_OldState; ///< Old State
uint64 m_Leader; ///< Leader GUID
LfgGuidSet m_Players; ///< Players in group
ObjectGuid m_Leader; ///< Leader GUID
GuidSet m_Players; ///< Players in group
// Dungeon
uint32 m_Dungeon; ///< Dungeon entry
// Vote Kick
+155 -157
View File
@@ -50,15 +50,15 @@ LFGMgr::~LFGMgr()
delete itr->second;
}
void LFGMgr::_LoadFromDB(Field* fields, uint64 guid)
void LFGMgr::_LoadFromDB(Field* fields, ObjectGuid guid)
{
if (!fields)
return;
if (!IS_GROUP_GUID(guid))
if (!guid.IsGroup())
return;
SetLeader(guid, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
SetLeader(guid, ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()));
uint32 dungeon = fields[17].GetUInt32();
uint8 state = fields[18].GetUInt8();
@@ -79,9 +79,9 @@ void LFGMgr::_LoadFromDB(Field* fields, uint64 guid)
}
}
void LFGMgr::_SaveToDB(uint64 guid, uint32 db_guid)
void LFGMgr::_SaveToDB(ObjectGuid guid, uint32 db_guid)
{
if (!IS_GROUP_GUID(guid))
if (!guid.IsGroup())
return;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
@@ -276,7 +276,7 @@ void LFGMgr::Update(uint32 diff)
for (LfgRolesMap::const_iterator itRoles = roleCheck.roles.begin(); itRoles != roleCheck.roles.end(); ++itRoles)
{
uint64 guid = itRoles->first;
ObjectGuid guid = itRoles->first;
RestoreState(guid, "Remove Obsolete RoleCheck");
SendLfgRoleCheckUpdate(guid, roleCheck);
if (guid == roleCheck.leader)
@@ -305,7 +305,7 @@ void LFGMgr::Update(uint32 diff)
boot.inProgress = false;
for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
{
uint64 pguid = itVotes->first;
ObjectGuid pguid = itVotes->first;
if (pguid != boot.victim)
SendLfgBootProposalUpdate(pguid, boot);
SetState(pguid, LFG_STATE_DUNGEON);
@@ -329,12 +329,12 @@ void LFGMgr::Update(uint32 diff)
uint32 proposalId = itProposal->first;
LfgProposal& proposal = ProposalsStore[proposalId];
uint64 guid = 0;
ObjectGuid guid;
for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
{
guid = itPlayers->first;
SetState(guid, LFG_STATE_PROPOSAL);
if (uint64 gguid = GetGroup(guid))
if (ObjectGuid gguid = GetGroup(guid))
{
SetState(gguid, LFG_STATE_PROPOSAL);
SendLfgUpdateStatus(guid, LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)), true);
@@ -376,10 +376,10 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
return;
Group* grp = player->GetGroup();
uint64 guid = player->GetGUID();
uint64 gguid = grp ? grp->GetGUID() : guid;
ObjectGuid guid = player->GetGUID();
ObjectGuid gguid = grp ? grp->GetGUID() : guid;
LfgJoinResultData joinData;
LfgGuidSet players;
GuidSet players;
uint32 rDungeonId = 0;
bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
@@ -491,7 +491,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
if (joinData.result != LFG_JOIN_OK)
{
TC_LOG_DEBUG("lfg.join", "%u joining with %u members. Result: %u, Dungeons: %s",
GUID_LOPART(guid), grp ? grp->GetMembersCount() : 1, joinData.result, ConcatenateDungeons(dungeons).c_str());
guid.GetCounter(), grp ? grp->GetMembersCount() : 1, joinData.result, ConcatenateDungeons(dungeons).c_str());
if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
joinData.lockmap.clear();
@@ -503,7 +503,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
if (isRaid)
{
TC_LOG_DEBUG("lfg.join", "%u trying to join raid browser and it's disabled.", GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.join", "%u trying to join raid browser and it's disabled.", guid.GetCounter());
return;
}
@@ -531,7 +531,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
{
if (Player* plrg = itr->GetSource())
{
uint64 pguid = plrg->GetGUID();
ObjectGuid pguid = plrg->GetGUID();
plrg->GetSession()->SendLfgUpdateStatus(updateData, true);
SetState(pguid, LFG_STATE_ROLECHECK);
if (!isContinue)
@@ -569,7 +569,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
debugNames.append(player->GetName());
}
TC_LOG_DEBUG("lfg.join", "%u joined (%s), Members: %s. Dungeons (%u): %s", GUID_LOPART(guid),
TC_LOG_DEBUG("lfg.join", "%u joined (%s), Members: %s. Dungeons (%u): %s", guid.GetCounter(),
grp ? "group" : "player", debugNames.c_str(), uint32(dungeons.size()), ConcatenateDungeons(dungeons).c_str());
}
@@ -579,11 +579,11 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
@param[in] guid Player or group guid
*/
void LFGMgr::LeaveLfg(uint64 guid)
void LFGMgr::LeaveLfg(ObjectGuid guid)
{
uint64 gguid = IS_GROUP_GUID(guid) ? guid : GetGroup(guid);
ObjectGuid gguid = guid.IsGroup() ? guid : GetGroup(guid);
TC_LOG_DEBUG("lfg.leave", "%u left (%s)", GUID_LOPART(guid), guid == gguid ? "group" : "player");
TC_LOG_DEBUG("lfg.leave", "%u left (%s)", guid.GetCounter(), guid == gguid ? "group" : "player");
LfgState state = GetState(guid);
switch (state)
@@ -594,8 +594,8 @@ void LFGMgr::LeaveLfg(uint64 guid)
LFGQueue& queue = GetQueue(gguid);
queue.RemoveFromQueue(gguid);
SetState(gguid, LFG_STATE_NONE);
const LfgGuidSet& players = GetPlayers(gguid);
for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
GuidSet const& players = GetPlayers(gguid);
for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
{
SetState(*it, LFG_STATE_NONE);
SendLfgUpdateStatus(*it, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE), true);
@@ -617,7 +617,7 @@ void LFGMgr::LeaveLfg(uint64 guid)
{
// Remove from Proposals
LfgProposalContainer::iterator it = ProposalsStore.begin();
uint64 pguid = gguid == guid ? GetLeader(gguid) : guid;
ObjectGuid pguid = gguid == guid ? GetLeader(gguid) : guid;
while (it != ProposalsStore.end())
{
LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid);
@@ -654,7 +654,7 @@ void LFGMgr::LeaveLfg(uint64 guid)
@param[in] guid Player guid (0 = rolecheck failed)
@param[in] roles Player selected roles
*/
void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* = PLAYER_ROLE_NONE */)
void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid::Empty */, uint8 roles /* = PLAYER_ROLE_NONE */)
{
if (!gguid)
return;
@@ -701,7 +701,7 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
LfgJoinResultData joinData = LfgJoinResultData(joinResult, roleCheck.state);
for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
{
uint64 pguid = it->first;
ObjectGuid pguid = it->first;
if (sendRoleChosen)
SendLfgRoleChosen(pguid, guid, roles);
@@ -746,12 +746,12 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
@param[in] players Set of players to check their dungeon restrictions
@param[out] lockMap Map of players Lock status info of given dungeons (Empty if dungeons is not empty)
*/
void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap)
void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap)
{
lockMap.clear();
for (LfgGuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
for (GuidSet::const_iterator it = players.begin(); it != players.end() && !dungeons.empty(); ++it)
{
uint64 guid = (*it);
ObjectGuid guid = (*it);
LfgLockMap const& cachedLockMap = GetLockedDungeons(guid);
for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && !dungeons.empty(); ++it2)
{
@@ -847,12 +847,12 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true
*/
void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
{
LfgGuidList players;
LfgGuidList playersToTeleport;
GuidList players;
GuidList playersToTeleport;
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
uint64 guid = it->first;
ObjectGuid guid = it->first;
if (guid == proposal.leader)
players.push_front(guid);
else
@@ -866,10 +866,10 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
ASSERT(dungeon);
Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(GUID_LOPART(proposal.group)) : NULL;
for (LfgGuidList::const_iterator it = players.begin(); it != players.end(); ++it)
Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : NULL;
for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it)
{
uint64 pguid = (*it);
ObjectGuid pguid = (*it);
Player* player = ObjectAccessor::FindPlayer(pguid);
if (!player)
continue;
@@ -883,7 +883,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
grp = new Group();
grp->ConvertToLFG();
grp->Create(player);
uint64 gguid = grp->GetGUID();
ObjectGuid gguid = grp->GetGUID();
SetState(gguid, LFG_STATE_PROPOSAL);
sGroupMgr->AddGroup(grp);
}
@@ -899,14 +899,14 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
ASSERT(grp);
grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty));
uint64 gguid = grp->GetGUID();
ObjectGuid gguid = grp->GetGUID();
SetDungeon(gguid, dungeon->Entry());
SetState(gguid, LFG_STATE_DUNGEON);
_SaveToDB(gguid, grp->GetDbStoreId());
// Teleport Player
for (LfgGuidList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
for (GuidList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(*it))
TeleportPlayer(player, false);
@@ -928,7 +928,7 @@ uint32 LFGMgr::AddProposal(LfgProposal& proposal)
@param[in] guid Player guid to update answer
@param[in] accept Player answer
*/
void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
void LFGMgr::UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept)
{
// Check if the proposal exists
LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId);
@@ -945,7 +945,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
LfgProposalPlayer& player = itProposalPlayer->second;
player.accept = LfgAnswer(accept);
TC_LOG_DEBUG("lfg.proposal.update", "Player %u, Proposal %u, Selection: %u", GUID_LOPART(guid), proposalId, accept);
TC_LOG_DEBUG("lfg.proposal.update", "Player %u, Proposal %u, Selection: %u", guid.GetCounter(), proposalId, accept);
if (!accept)
{
RemoveProposal(itProposal, LFG_UPDATETYPE_PROPOSAL_DECLINED);
@@ -974,8 +974,8 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
uint64 pguid = it->first;
uint64 gguid = it->second.group;
ObjectGuid pguid = it->first;
ObjectGuid gguid = it->second.group;
uint32 dungeonId = (*GetSelectedDungeons(pguid).begin());
int32 waitTime = -1;
if (sendUpdate)
@@ -1018,7 +1018,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
}
// Remove players/groups from Queue
for (LfgGuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
queue.RemoveFromQueue(*it);
MakeNewGroup(proposal);
@@ -1044,13 +1044,13 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
it->second.accept = LFG_ANSWER_DENY;
// Mark players/groups to be removed
LfgGuidSet toRemove;
GuidSet toRemove;
for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
if (it->second.accept == LFG_ANSWER_AGREE)
continue;
uint64 guid = it->second.group ? it->second.group : it->first;
ObjectGuid guid = it->second.group ? it->second.group : it->first;
// Player didn't accept or still pending when no secs left
if (it->second.accept == LFG_ANSWER_DENY || type == LFG_UPDATETYPE_PROPOSAL_FAILED)
{
@@ -1062,8 +1062,8 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
// Notify players
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
uint64 guid = it->first;
uint64 gguid = it->second.group ? it->second.group : guid;
ObjectGuid guid = it->first;
ObjectGuid gguid = it->second.group ? it->second.group : guid;
SendLfgUpdateProposal(guid, proposal);
@@ -1073,12 +1073,12 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
if (it->second.accept == LFG_ANSWER_DENY)
{
updateData.updateType = type;
TC_LOG_DEBUG("lfg.proposal.remove", "%u didn't accept. Removing from queue and compatible cache", GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.proposal.remove", "%u didn't accept. Removing from queue and compatible cache", guid.GetCounter());
}
else
{
updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
TC_LOG_DEBUG("lfg.proposal.remove", "%u in same group that someone that didn't accept. Removing from queue and compatible cache", GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.proposal.remove", "%u in same group that someone that didn't accept. Removing from queue and compatible cache", guid.GetCounter());
}
RestoreState(guid, "Proposal Fail (didn't accepted or in group with someone that didn't accept");
@@ -1092,7 +1092,7 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
}
else
{
TC_LOG_DEBUG("lfg.proposal.remove", "Readding %u to queue.", GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.proposal.remove", "Readding %u to queue.", guid.GetCounter());
SetState(guid, LFG_STATE_QUEUED);
if (gguid != guid)
{
@@ -1106,17 +1106,17 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
LFGQueue& queue = GetQueue(proposal.players.begin()->first);
// Remove players/groups from queue
for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
for (GuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
{
uint64 guid = *it;
ObjectGuid guid = *it;
queue.RemoveFromQueue(guid);
proposal.queues.remove(guid);
}
// Readd to queue
for (LfgGuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
for (GuidList::const_iterator it = proposal.queues.begin(); it != proposal.queues.end(); ++it)
{
uint64 guid = *it;
ObjectGuid guid = *it;
queue.AddToQueue(guid);
}
@@ -1131,7 +1131,7 @@ void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdate
@param[in] victim Victim guid
@param[in] reason Kick reason
*/
void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string const& reason)
void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason)
{
SetState(gguid, LFG_STATE_BOOT);
@@ -1141,12 +1141,12 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co
boot.reason = reason;
boot.victim = victim;
LfgGuidSet const& players = GetPlayers(gguid);
GuidSet const& players = GetPlayers(gguid);
// Set votes
for (LfgGuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
for (GuidSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
uint64 guid = (*itr);
ObjectGuid guid = (*itr);
SetState(guid, LFG_STATE_BOOT);
boot.votes[guid] = LFG_ANSWER_PENDING;
}
@@ -1155,7 +1155,7 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co
boot.votes[kicker] = LFG_ANSWER_AGREE; // Kicker auto vote YES
// Notify players
for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
SendLfgBootProposalUpdate(*it, boot);
}
@@ -1165,9 +1165,9 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co
@param[in] guid Player who has answered
@param[in] player answer
*/
void LFGMgr::UpdateBoot(uint64 guid, bool accept)
void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept)
{
uint64 gguid = GetGroup(guid);
ObjectGuid gguid = GetGroup(guid);
if (!gguid)
return;
@@ -1202,7 +1202,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept)
boot.inProgress = false;
for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes)
{
uint64 pguid = itVotes->first;
ObjectGuid pguid = itVotes->first;
if (pguid != boot.victim)
{
SetState(pguid, LFG_STATE_DUNGEON);
@@ -1213,7 +1213,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept)
SetState(gguid, LFG_STATE_DUNGEON);
if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
{
if (Group* group = sGroupMgr->GetGroupByGUID(GUID_LOPART(gguid)))
if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG);
DecreaseKicksLeft(gguid);
}
@@ -1320,30 +1320,30 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*
@param[in] guid Group guid
@param[in] dungeonId Dungeonid
*/
void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId)
void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId)
{
uint32 gDungeonId = GetDungeon(gguid);
if (gDungeonId != dungeonId)
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group %u finished dungeon %u but queued for %u", GUID_LOPART(gguid), dungeonId, gDungeonId);
TC_LOG_DEBUG("lfg.dungeon.finish", "Group %u finished dungeon %u but queued for %u", gguid.GetCounter(), dungeonId, gDungeonId);
return;
}
if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u already rewarded", GUID_LOPART(gguid));
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u already rewarded", gguid.GetCounter());
return;
}
SetState(gguid, LFG_STATE_FINISHED_DUNGEON);
const LfgGuidSet& players = GetPlayers(gguid);
for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
GuidSet const& players = GetPlayers(gguid);
for (GuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
{
uint64 guid = (*it);
ObjectGuid guid = (*it);
if (GetState(guid) == LFG_STATE_FINISHED_DUNGEON)
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u already rewarded", GUID_LOPART(gguid), GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u already rewarded", gguid.GetCounter(), guid.GetCounter());
continue;
}
@@ -1359,14 +1359,14 @@ void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId)
if (!dungeon || (dungeon->type != LFG_TYPE_RANDOM && !dungeon->seasonal))
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u dungeon %u is not random or seasonal", GUID_LOPART(gguid), GUID_LOPART(guid), rDungeonId);
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u dungeon %u is not random or seasonal", gguid.GetCounter(), guid.GetCounter(), rDungeonId);
continue;
}
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player || !player->IsInWorld())
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u not found in world", GUID_LOPART(gguid), GUID_LOPART(guid));
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u not found in world", gguid.GetCounter(), guid.GetCounter());
continue;
}
@@ -1375,7 +1375,7 @@ void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId)
if (player->GetMapId() != mapId)
{
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u is in map %u and should be in %u to get reward", GUID_LOPART(gguid), GUID_LOPART(guid), player->GetMapId(), mapId);
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u is in map %u and should be in %u to get reward", gguid.GetCounter(), guid.GetCounter(), player->GetMapId(), mapId);
continue;
}
@@ -1406,7 +1406,7 @@ void LFGMgr::FinishDungeon(uint64 gguid, const uint32 dungeonId)
}
// Give rewards
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u done dungeon %u, %s previously done.", GUID_LOPART(gguid), GUID_LOPART(guid), GetDungeon(gguid), done? " " : " not");
TC_LOG_DEBUG("lfg.dungeon.finish", "Group: %u, Player: %u done dungeon %u, %s previously done.", gguid.GetCounter(), guid.GetCounter(), GetDungeon(gguid), done? " " : " not");
LfgPlayerRewardData data = LfgPlayerRewardData(dungeon->Entry(), GetDungeon(gguid, false), done, quest);
player->GetSession()->SendLfgPlayerReward(data);
}
@@ -1466,48 +1466,48 @@ LfgType LFGMgr::GetDungeonType(uint32 dungeonId)
return LfgType(dungeon->type);
}
LfgState LFGMgr::GetState(uint64 guid)
LfgState LFGMgr::GetState(ObjectGuid guid)
{
LfgState state;
if (IS_GROUP_GUID(guid))
if (guid.IsGroup())
{
state = GroupsStore[guid].GetState();
TC_LOG_TRACE("lfg.data.group.state.get", "Group: %u, State: %u", GUID_LOPART(guid), state);
TC_LOG_TRACE("lfg.data.group.state.get", "Group: %u, State: %u", guid.GetCounter(), state);
}
else
{
state = PlayersStore[guid].GetState();
TC_LOG_TRACE("lfg.data.player.state.get", "Player: %u, State: %u", GUID_LOPART(guid), state);
TC_LOG_TRACE("lfg.data.player.state.get", "Player: %u, State: %u", guid.GetCounter(), state);
}
return state;
}
LfgState LFGMgr::GetOldState(uint64 guid)
LfgState LFGMgr::GetOldState(ObjectGuid guid)
{
LfgState state;
if (IS_GROUP_GUID(guid))
if (guid.IsGroup())
{
state = GroupsStore[guid].GetOldState();
TC_LOG_TRACE("lfg.data.group.oldstate.get", "Group: %u, Old state: %u", GUID_LOPART(guid), state);
TC_LOG_TRACE("lfg.data.group.oldstate.get", "Group: %u, Old state: %u", guid.GetCounter(), state);
}
else
{
state = PlayersStore[guid].GetOldState();
TC_LOG_TRACE("lfg.data.player.oldstate.get", "Player: %u, Old state: %u", GUID_LOPART(guid), state);
TC_LOG_TRACE("lfg.data.player.oldstate.get", "Player: %u, Old state: %u", guid.GetCounter(), state);
}
return state;
}
uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true */)
uint32 LFGMgr::GetDungeon(ObjectGuid guid, bool asId /*= true */)
{
uint32 dungeon = GroupsStore[guid].GetDungeon(asId);
TC_LOG_TRACE("lfg.data.group.dungeon.get", "Group: %u, asId: %u, Dungeon: %u", GUID_LOPART(guid), asId, dungeon);
TC_LOG_TRACE("lfg.data.group.dungeon.get", "Group: %u, asId: %u, Dungeon: %u", guid.GetCounter(), asId, dungeon);
return dungeon;
}
uint32 LFGMgr::GetDungeonMapId(uint64 guid)
uint32 LFGMgr::GetDungeonMapId(ObjectGuid guid)
{
uint32 dungeonId = GroupsStore[guid].GetDungeon(true);
uint32 mapId = 0;
@@ -1515,38 +1515,38 @@ uint32 LFGMgr::GetDungeonMapId(uint64 guid)
if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
mapId = dungeon->map;
TC_LOG_TRACE("lfg.data.group.dungeon.map", "Group: %u, MapId: %u (DungeonId: %u)", GUID_LOPART(guid), mapId, dungeonId);
TC_LOG_TRACE("lfg.data.group.dungeon.map", "Group: %u, MapId: %u (DungeonId: %u)", guid.GetCounter(), mapId, dungeonId);
return mapId;
}
uint8 LFGMgr::GetRoles(uint64 guid)
uint8 LFGMgr::GetRoles(ObjectGuid guid)
{
uint8 roles = PlayersStore[guid].GetRoles();
TC_LOG_TRACE("lfg.data.player.role.get", "Player: %u, Role: %u", GUID_LOPART(guid), roles);
TC_LOG_TRACE("lfg.data.player.role.get", "Player: %u, Role: %u", guid.GetCounter(), roles);
return roles;
}
const std::string& LFGMgr::GetComment(uint64 guid)
const std::string& LFGMgr::GetComment(ObjectGuid guid)
{
TC_LOG_TRACE("lfg.data.player.comment.get", "Player: %u, Comment: %s", GUID_LOPART(guid), PlayersStore[guid].GetComment().c_str());
TC_LOG_TRACE("lfg.data.player.comment.get", "Player: %u, Comment: %s", guid.GetCounter(), PlayersStore[guid].GetComment().c_str());
return PlayersStore[guid].GetComment();
}
LfgDungeonSet const& LFGMgr::GetSelectedDungeons(uint64 guid)
LfgDungeonSet const& LFGMgr::GetSelectedDungeons(ObjectGuid guid)
{
TC_LOG_TRACE("lfg.data.player.dungeons.selected.get", "Player: %u, Selected Dungeons: %s", GUID_LOPART(guid), ConcatenateDungeons(PlayersStore[guid].GetSelectedDungeons()).c_str());
TC_LOG_TRACE("lfg.data.player.dungeons.selected.get", "Player: %u, Selected Dungeons: %s", guid.GetCounter(), ConcatenateDungeons(PlayersStore[guid].GetSelectedDungeons()).c_str());
return PlayersStore[guid].GetSelectedDungeons();
}
LfgLockMap const LFGMgr::GetLockedDungeons(uint64 guid)
LfgLockMap const LFGMgr::GetLockedDungeons(ObjectGuid guid)
{
TC_LOG_TRACE("lfg.data.player.dungeons.locked.get", "Player: %u, LockedDungeons.", GUID_LOPART(guid));
TC_LOG_TRACE("lfg.data.player.dungeons.locked.get", "Player: %u, LockedDungeons.", guid.GetCounter());
LfgLockMap lock;
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
{
TC_LOG_WARN("lfg.data.player.dungeons.locked.get", "Player: %u not ingame while retrieving his LockedDungeons.", GUID_LOPART(guid));
TC_LOG_WARN("lfg.data.player.dungeons.locked.get", "Player: %u not ingame while retrieving his LockedDungeons.", guid.GetCounter());
return lock;
}
@@ -1609,20 +1609,20 @@ LfgLockMap const LFGMgr::GetLockedDungeons(uint64 guid)
return lock;
}
uint8 LFGMgr::GetKicksLeft(uint64 guid)
uint8 LFGMgr::GetKicksLeft(ObjectGuid guid)
{
uint8 kicks = GroupsStore[guid].GetKicksLeft();
TC_LOG_TRACE("lfg.data.group.kickleft.get", "Group: %u, Kicks left: %u", GUID_LOPART(guid), kicks);
TC_LOG_TRACE("lfg.data.group.kickleft.get", "Group: %u, Kicks left: %u", guid.GetCounter(), kicks);
return kicks;
}
void LFGMgr::RestoreState(uint64 guid, char const* debugMsg)
void LFGMgr::RestoreState(ObjectGuid guid, char const* debugMsg)
{
if (IS_GROUP_GUID(guid))
if (guid.IsGroup())
{
LfgGroupData& data = GroupsStore[guid];
TC_LOG_TRACE("lfg.data.group.state.restore", "Group: %u (%s), State: %s, Old state: %s",
GUID_LOPART(guid), debugMsg, GetStateString(data.GetState()).c_str(),
guid.GetCounter(), debugMsg, GetStateString(data.GetState()).c_str(),
GetStateString(data.GetOldState()).c_str());
data.RestoreState();
@@ -1631,20 +1631,20 @@ void LFGMgr::RestoreState(uint64 guid, char const* debugMsg)
{
LfgPlayerData& data = PlayersStore[guid];
TC_LOG_TRACE("lfg.data.player.state.restore", "Player: %u (%s), State: %s, Old state: %s",
GUID_LOPART(guid), debugMsg, GetStateString(data.GetState()).c_str(),
guid.GetCounter(), debugMsg, GetStateString(data.GetState()).c_str(),
GetStateString(data.GetOldState()).c_str());
data.RestoreState();
}
}
void LFGMgr::SetState(uint64 guid, LfgState state)
void LFGMgr::SetState(ObjectGuid guid, LfgState state)
{
if (IS_GROUP_GUID(guid))
if (guid.IsGroup())
{
LfgGroupData& data = GroupsStore[guid];
TC_LOG_TRACE("lfg.data.group.state.set", "Group: %u, New state: %s, Previous: %s, Old state: %s",
GUID_LOPART(guid), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
guid.GetCounter(), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
GetStateString(data.GetOldState()).c_str());
data.SetState(state);
@@ -1653,64 +1653,64 @@ void LFGMgr::SetState(uint64 guid, LfgState state)
{
LfgPlayerData& data = PlayersStore[guid];
TC_LOG_TRACE("lfg.data.player.state.set", "Player: %u, New state: %s, Previous: %s, OldState: %s",
GUID_LOPART(guid), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
guid.GetCounter(), GetStateString(state).c_str(), GetStateString(data.GetState()).c_str(),
GetStateString(data.GetOldState()).c_str());
data.SetState(state);
}
}
void LFGMgr::SetDungeon(uint64 guid, uint32 dungeon)
void LFGMgr::SetDungeon(ObjectGuid guid, uint32 dungeon)
{
TC_LOG_TRACE("lfg.data.group.dungeon.set", "Group: %u, Dungeon: %u", GUID_LOPART(guid), dungeon);
TC_LOG_TRACE("lfg.data.group.dungeon.set", "Group: %u, Dungeon: %u", guid.GetCounter(), dungeon);
GroupsStore[guid].SetDungeon(dungeon);
}
void LFGMgr::SetRoles(uint64 guid, uint8 roles)
void LFGMgr::SetRoles(ObjectGuid guid, uint8 roles)
{
TC_LOG_TRACE("lfg.data.player.role.set", "Player: %u, Roles: %u", GUID_LOPART(guid), roles);
TC_LOG_TRACE("lfg.data.player.role.set", "Player: %u, Roles: %u", guid.GetCounter(), roles);
PlayersStore[guid].SetRoles(roles);
}
void LFGMgr::SetComment(uint64 guid, std::string const& comment)
void LFGMgr::SetComment(ObjectGuid guid, std::string const& comment)
{
TC_LOG_TRACE("lfg.data.player.comment.set", "Player: %u, Comment: %s", GUID_LOPART(guid), comment.c_str());
TC_LOG_TRACE("lfg.data.player.comment.set", "Player: %u, Comment: %s", guid.GetCounter(), comment.c_str());
PlayersStore[guid].SetComment(comment);
}
void LFGMgr::SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons)
void LFGMgr::SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons)
{
TC_LOG_TRACE("lfg.data.player.dungeon.selected.set", "Player: %u, Dungeons: %s", GUID_LOPART(guid), ConcatenateDungeons(dungeons).c_str());
TC_LOG_TRACE("lfg.data.player.dungeon.selected.set", "Player: %u, Dungeons: %s", guid.GetCounter(), ConcatenateDungeons(dungeons).c_str());
PlayersStore[guid].SetSelectedDungeons(dungeons);
}
void LFGMgr::DecreaseKicksLeft(uint64 guid)
void LFGMgr::DecreaseKicksLeft(ObjectGuid guid)
{
GroupsStore[guid].DecreaseKicksLeft();
TC_LOG_TRACE("lfg.data.group.kicksleft.decrease", "Group: %u, Kicks: %u", GUID_LOPART(guid), GroupsStore[guid].GetKicksLeft());
TC_LOG_TRACE("lfg.data.group.kicksleft.decrease", "Group: %u, Kicks: %u", guid.GetCounter(), GroupsStore[guid].GetKicksLeft());
}
void LFGMgr::RemovePlayerData(uint64 guid)
void LFGMgr::RemovePlayerData(ObjectGuid guid)
{
TC_LOG_TRACE("lfg.data.player.remove", "Player: %u", GUID_LOPART(guid));
TC_LOG_TRACE("lfg.data.player.remove", "Player: %u", guid.GetCounter());
LfgPlayerDataContainer::iterator it = PlayersStore.find(guid);
if (it != PlayersStore.end())
PlayersStore.erase(it);
}
void LFGMgr::RemoveGroupData(uint64 guid)
void LFGMgr::RemoveGroupData(ObjectGuid guid)
{
TC_LOG_TRACE("lfg.data.group.remove", "Group: %u", GUID_LOPART(guid));
TC_LOG_TRACE("lfg.data.group.remove", "Group: %u", guid.GetCounter());
LfgGroupDataContainer::iterator it = GroupsStore.find(guid);
if (it == GroupsStore.end())
return;
LfgState state = GetState(guid);
// If group is being formed after proposal success do nothing more
LfgGuidSet const& players = it->second.GetPlayers();
for (uint64 playerGUID : players)
GuidSet const& players = it->second.GetPlayers();
for (ObjectGuid playerGUID : players)
{
SetGroup(playerGUID, 0);
SetGroup(playerGUID, ObjectGuid::Empty);
if (state != LFG_STATE_PROPOSAL)
{
SetState(playerGUID, LFG_STATE_NONE);
@@ -1720,29 +1720,29 @@ void LFGMgr::RemoveGroupData(uint64 guid)
GroupsStore.erase(it);
}
uint8 LFGMgr::GetTeam(uint64 guid)
uint8 LFGMgr::GetTeam(ObjectGuid guid)
{
uint8 team = PlayersStore[guid].GetTeam();
TC_LOG_TRACE("lfg.data.player.team.get", "Player: %u, Team: %u", GUID_LOPART(guid), team);
TC_LOG_TRACE("lfg.data.player.team.get", "Player: %u, Team: %u", guid.GetCounter(), team);
return team;
}
uint8 LFGMgr::RemovePlayerFromGroup(uint64 gguid, uint64 guid)
uint8 LFGMgr::RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid)
{
return GroupsStore[gguid].RemovePlayer(guid);
}
void LFGMgr::AddPlayerToGroup(uint64 gguid, uint64 guid)
void LFGMgr::AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid)
{
GroupsStore[gguid].AddPlayer(guid);
}
void LFGMgr::SetLeader(uint64 gguid, uint64 leader)
void LFGMgr::SetLeader(ObjectGuid gguid, ObjectGuid leader)
{
GroupsStore[gguid].SetLeader(leader);
}
void LFGMgr::SetTeam(uint64 guid, uint8 team)
void LFGMgr::SetTeam(ObjectGuid guid, uint8 team)
{
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
team = 0;
@@ -1750,93 +1750,91 @@ void LFGMgr::SetTeam(uint64 guid, uint8 team)
PlayersStore[guid].SetTeam(team);
}
uint64 LFGMgr::GetGroup(uint64 guid)
ObjectGuid LFGMgr::GetGroup(ObjectGuid guid)
{
return PlayersStore[guid].GetGroup();
}
void LFGMgr::SetGroup(uint64 guid, uint64 group)
void LFGMgr::SetGroup(ObjectGuid guid, ObjectGuid group)
{
PlayersStore[guid].SetGroup(group);
}
LfgGuidSet const& LFGMgr::GetPlayers(uint64 guid)
GuidSet const& LFGMgr::GetPlayers(ObjectGuid guid)
{
return GroupsStore[guid].GetPlayers();
}
uint8 LFGMgr::GetPlayerCount(uint64 guid)
uint8 LFGMgr::GetPlayerCount(ObjectGuid guid)
{
return GroupsStore[guid].GetPlayerCount();
}
uint64 LFGMgr::GetLeader(uint64 guid)
ObjectGuid LFGMgr::GetLeader(ObjectGuid guid)
{
return GroupsStore[guid].GetLeader();
}
bool LFGMgr::HasIgnore(uint64 guid1, uint64 guid2)
bool LFGMgr::HasIgnore(ObjectGuid guid1, ObjectGuid guid2)
{
Player* plr1 = ObjectAccessor::FindPlayer(guid1);
Player* plr2 = ObjectAccessor::FindPlayer(guid2);
uint32 low1 = GUID_LOPART(guid1);
uint32 low2 = GUID_LOPART(guid2);
return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(low2) || plr2->GetSocial()->HasIgnore(low1));
return plr1 && plr2 && (plr1->GetSocial()->HasIgnore(guid2.GetCounter()) || plr2->GetSocial()->HasIgnore(guid1.GetCounter()));
}
void LFGMgr::SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles)
void LFGMgr::SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgRoleChosen(pguid, roles);
}
void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck)
void LFGMgr::SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const& roleCheck)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
}
void LFGMgr::SendLfgUpdateStatus(uint64 guid, LfgUpdateData const& data, bool party)
void LFGMgr::SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const& data, bool party)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgUpdateStatus(data, party);
}
void LFGMgr::SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data)
void LFGMgr::SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const& data)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgJoinResult(data);
}
void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot)
void LFGMgr::SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const& boot)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgBootProposalUpdate(boot);
}
void LFGMgr::SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal)
void LFGMgr::SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const& proposal)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgUpdateProposal(proposal);
}
void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data)
void LFGMgr::SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data)
{
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->GetSession()->SendLfgQueueStatus(data);
}
bool LFGMgr::IsLfgGroup(uint64 guid)
bool LFGMgr::IsLfgGroup(ObjectGuid guid)
{
return guid && IS_GROUP_GUID(guid) && GroupsStore[guid].IsLfgGroup();
return guid && guid.IsGroup() && GroupsStore[guid].IsLfgGroup();
}
uint8 LFGMgr::GetQueueId(uint64 guid)
uint8 LFGMgr::GetQueueId(ObjectGuid guid)
{
if (IS_GROUP_GUID(guid))
if (guid.IsGroup())
{
LfgGuidSet const& players = GetPlayers(guid);
uint64 pguid = players.empty() ? 0 : (*players.begin());
GuidSet const& players = GetPlayers(guid);
ObjectGuid pguid = players.empty() ? ObjectGuid::Empty : (*players.begin());
if (pguid)
return GetTeam(pguid);
}
@@ -1844,24 +1842,24 @@ uint8 LFGMgr::GetQueueId(uint64 guid)
return GetTeam(guid);
}
LFGQueue& LFGMgr::GetQueue(uint64 guid)
LFGQueue& LFGMgr::GetQueue(ObjectGuid guid)
{
uint8 queueId = GetQueueId(guid);
return QueuesStore[queueId];
}
bool LFGMgr::AllQueued(LfgGuidList const& check)
bool LFGMgr::AllQueued(GuidList const& check)
{
if (check.empty())
return false;
for (LfgGuidList::const_iterator it = check.begin(); it != check.end(); ++it)
for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
if (GetState(*it) != LFG_STATE_QUEUED)
return false;
return true;
}
time_t LFGMgr::GetQueueJoinTime(uint64 guid)
time_t LFGMgr::GetQueueJoinTime(ObjectGuid guid)
{
uint8 queueId = GetQueueId(guid);
LfgQueueContainer::const_iterator itr = QueuesStore.find(queueId);
@@ -1892,7 +1890,7 @@ void LFGMgr::SetOptions(uint32 options)
m_options = options;
}
LfgUpdateData LFGMgr::GetLfgStatus(uint64 guid)
LfgUpdateData LFGMgr::GetLfgStatus(ObjectGuid guid)
{
LfgPlayerData& playerData = PlayersStore[guid];
return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
@@ -1930,7 +1928,7 @@ std::string LFGMgr::DumpQueueInfo(bool full)
return o.str();
}
void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid)
void LFGMgr::SetupGroupMember(ObjectGuid guid, ObjectGuid gguid)
{
LfgDungeonSet dungeons;
dungeons.insert(GetDungeon(gguid));
@@ -1940,7 +1938,7 @@ void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid)
AddPlayerToGroup(gguid, guid);
}
bool LFGMgr::selectedRandomLfgDungeon(uint64 guid)
bool LFGMgr::selectedRandomLfgDungeon(ObjectGuid guid)
{
if (GetState(guid) != LFG_STATE_NONE)
{
@@ -1956,9 +1954,9 @@ bool LFGMgr::selectedRandomLfgDungeon(uint64 guid)
return false;
}
bool LFGMgr::inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty)
bool LFGMgr::inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty)
{
if (!IS_GROUP_GUID(guid))
if (!guid.IsGroup())
guid = GetGroup(guid);
if (uint32 dungeonId = GetDungeon(guid, true))
+70 -70
View File
@@ -138,13 +138,13 @@ typedef std::map<uint8, LFGQueue> LfgQueueContainer;
typedef std::multimap<uint32, LfgReward const*> LfgRewardContainer;
typedef std::pair<LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator> LfgRewardContainerBounds;
typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonContainer;
typedef std::map<uint64, LfgAnswer> LfgAnswerContainer;
typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckContainer;
typedef std::map<ObjectGuid, LfgAnswer> LfgAnswerContainer;
typedef std::map<ObjectGuid, LfgRoleCheck> LfgRoleCheckContainer;
typedef std::map<uint32, LfgProposal> LfgProposalContainer;
typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerContainer;
typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootContainer;
typedef std::map<uint64, LfgGroupData> LfgGroupDataContainer;
typedef std::map<uint64, LfgPlayerData> LfgPlayerDataContainer;
typedef std::map<ObjectGuid, LfgProposalPlayer> LfgProposalPlayerContainer;
typedef std::map<ObjectGuid, LfgPlayerBoot> LfgPlayerBootContainer;
typedef std::map<ObjectGuid, LfgGroupData> LfgGroupDataContainer;
typedef std::map<ObjectGuid, LfgPlayerData> LfgPlayerDataContainer;
typedef std::unordered_map<uint32, LFGDungeonData> LFGDungeonContainer;
// Data needed by SMSG_LFG_JOIN_RESULT
@@ -218,29 +218,29 @@ struct LfgReward
/// Stores player data related to proposal to join
struct LfgProposalPlayer
{
LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING), group(0) { }
LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING), group() { }
uint8 role; ///< Proposed role
LfgAnswer accept; ///< Accept status (-1 not answer | 0 Not agree | 1 agree)
uint64 group; ///< Original group guid. 0 if no original group
ObjectGuid group; ///< Original group guid. 0 if no original group
};
/// Stores group data related to proposal to join
struct LfgProposal
{
LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING),
group(0), leader(0), cancelTime(0), encounters(0), isNew(true)
group(), leader(), cancelTime(0), encounters(0), isNew(true)
{ }
uint32 id; ///< Proposal Id
uint32 dungeonId; ///< Dungeon to join
LfgProposalState state; ///< State of the proposal
uint64 group; ///< Proposal group (0 if new)
uint64 leader; ///< Leader guid.
ObjectGuid group; ///< Proposal group (0 if new)
ObjectGuid leader; ///< Leader guid.
time_t cancelTime; ///< Time when we will cancel this proposal
uint32 encounters; ///< Dungeon Encounters
bool isNew; ///< Determines if it's new group or not
LfgGuidList queues; ///< Queue Ids to remove/readd
LfgGuidList showorder; ///< Show order in update window
GuidList queues; ///< Queue Ids to remove/readd
GuidList showorder; ///< Show order in update window
LfgProposalPlayerContainer players; ///< Players data
};
@@ -252,7 +252,7 @@ struct LfgRoleCheck
LfgRoleCheckState state; ///< State of the rolecheck
LfgDungeonSet dungeons; ///< Dungeons group is applying for (expanded random dungeons)
uint32 rDungeonId; ///< Random Dungeon Id.
uint64 leader; ///< Leader of the group
ObjectGuid leader; ///< Leader of the group
};
/// Stores information of a current vote to kick someone from a group
@@ -261,7 +261,7 @@ struct LfgPlayerBoot
time_t cancelTime; ///< Time left to vote
bool inProgress; ///< Vote in progress
LfgAnswerContainer votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree)
uint64 victim; ///< Player guid to be kicked (can't vote)
ObjectGuid victim; ///< Player guid to be kicked (can't vote)
std::string reason; ///< kick reason
};
@@ -313,7 +313,7 @@ class LFGMgr
// World.cpp
/// Finish the dungeon for the given group. All check are performed using internal lfg data
void FinishDungeon(uint64 gguid, uint32 dungeonId);
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId);
/// Loads rewards for random dungeons
void LoadRewards();
/// Loads dungeons from dbc and adds teleport coords
@@ -321,31 +321,31 @@ class LFGMgr
// Multiple files
/// Check if given guid applied for random dungeon
bool selectedRandomLfgDungeon(uint64 guid);
bool selectedRandomLfgDungeon(ObjectGuid guid);
/// Check if given guid applied for given map and difficulty. Used to know
bool inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty);
bool inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty);
/// Get selected dungeons
LfgDungeonSet const& GetSelectedDungeons(uint64 guid);
LfgDungeonSet const& GetSelectedDungeons(ObjectGuid guid);
/// Get current lfg state
LfgState GetState(uint64 guid);
LfgState GetState(ObjectGuid guid);
/// Get current dungeon
uint32 GetDungeon(uint64 guid, bool asId = true);
uint32 GetDungeon(ObjectGuid guid, bool asId = true);
/// Get the map id of the current dungeon
uint32 GetDungeonMapId(uint64 guid);
uint32 GetDungeonMapId(ObjectGuid guid);
/// Get kicks left in current group
uint8 GetKicksLeft(uint64 gguid);
uint8 GetKicksLeft(ObjectGuid gguid);
/// Load Lfg group info from DB
void _LoadFromDB(Field* fields, uint64 guid);
void _LoadFromDB(Field* fields, ObjectGuid guid);
/// Initializes player data after loading group data from DB
void SetupGroupMember(uint64 guid, uint64 gguid);
void SetupGroupMember(ObjectGuid guid, ObjectGuid gguid);
/// Return Lfg dungeon entry for given dungeon id
uint32 GetLFGDungeonEntry(uint32 id);
// cs_lfg
/// Get current player roles
uint8 GetRoles(uint64 guid);
uint8 GetRoles(ObjectGuid guid);
/// Get current player comment (used for LFR)
std::string const& GetComment(uint64 gguid);
std::string const& GetComment(ObjectGuid gguid);
/// Gets current lfg options
uint32 GetOptions();
/// Sets new lfg options
@@ -359,27 +359,27 @@ class LFGMgr
// LFGScripts
/// Get leader of the group (using internal data)
uint64 GetLeader(uint64 guid);
ObjectGuid GetLeader(ObjectGuid guid);
/// Sets player team
void SetTeam(uint64 guid, uint8 team);
void SetTeam(ObjectGuid guid, uint8 team);
/// Sets player group
void SetGroup(uint64 guid, uint64 group);
void SetGroup(ObjectGuid guid, ObjectGuid group);
/// Gets player group
uint64 GetGroup(uint64 guid);
ObjectGuid GetGroup(ObjectGuid guid);
/// Sets the leader of the group
void SetLeader(uint64 gguid, uint64 leader);
void SetLeader(ObjectGuid gguid, ObjectGuid leader);
/// Removes saved group data
void RemoveGroupData(uint64 guid);
void RemoveGroupData(ObjectGuid guid);
/// Removes a player from a group
uint8 RemovePlayerFromGroup(uint64 gguid, uint64 guid);
uint8 RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid);
/// Adds player to group
void AddPlayerToGroup(uint64 gguid, uint64 guid);
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid);
// LFGHandler
/// Get locked dungeons
LfgLockMap const GetLockedDungeons(uint64 guid);
LfgLockMap const GetLockedDungeons(ObjectGuid guid);
/// Returns current lfg status
LfgUpdateData GetLfgStatus(uint64 guid);
LfgUpdateData GetLfgStatus(ObjectGuid guid);
/// Checks if Seasonal dungeon is active
bool IsSeasonActive(uint32 dungeonId);
/// Gets the random dungeon reward corresponding to given dungeon and player level
@@ -389,55 +389,55 @@ class LFGMgr
/// Teleport a player to/from selected dungeon
void TeleportPlayer(Player* player, bool out, bool fromOpcode = false);
/// Inits new proposal to boot a player
void InitBoot(uint64 gguid, uint64 kguid, uint64 vguid, std::string const& reason);
void InitBoot(ObjectGuid gguid, ObjectGuid kguid, ObjectGuid vguid, std::string const& reason);
/// Updates player boot proposal with new player answer
void UpdateBoot(uint64 guid, bool accept);
void UpdateBoot(ObjectGuid guid, bool accept);
/// Updates proposal to join dungeon with player answer
void UpdateProposal(uint32 proposalId, uint64 guid, bool accept);
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept);
/// Updates the role check with player answer
void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = PLAYER_ROLE_NONE);
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid = ObjectGuid::Empty, uint8 roles = PLAYER_ROLE_NONE);
/// Sets player lfg roles
void SetRoles(uint64 guid, uint8 roles);
void SetRoles(ObjectGuid guid, uint8 roles);
/// Sets player lfr comment
void SetComment(uint64 guid, std::string const& comment);
void SetComment(ObjectGuid guid, std::string const& comment);
/// Join Lfg with selected roles, dungeons and comment
void JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, std::string const& comment);
/// Leaves lfg
void LeaveLfg(uint64 guid);
void LeaveLfg(ObjectGuid guid);
// LfgQueue
/// Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)
LfgState GetOldState(uint64 guid);
LfgState GetOldState(ObjectGuid guid);
/// Check if given group guid is lfg
bool IsLfgGroup(uint64 guid);
bool IsLfgGroup(ObjectGuid guid);
/// Gets the player count of given group
uint8 GetPlayerCount(uint64 guid);
uint8 GetPlayerCount(ObjectGuid guid);
/// Add a new Proposal
uint32 AddProposal(LfgProposal& proposal);
/// Returns queue id
uint8 GetQueueId(uint64 guid);
uint8 GetQueueId(ObjectGuid guid);
/// Checks if all players are queued
bool AllQueued(LfgGuidList const& check);
bool AllQueued(GuidList const& check);
/// Gets queue join time
time_t GetQueueJoinTime(uint64 guid);
time_t GetQueueJoinTime(ObjectGuid guid);
/// Checks if given roles match, modifies given roles map with new roles
static bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
/// Checks if given players are ignoring each other
static bool HasIgnore(uint64 guid1, uint64 guid2);
static bool HasIgnore(ObjectGuid guid1, ObjectGuid guid2);
/// Sends queue status to player
static void SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data);
static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data);
private:
uint8 GetTeam(uint64 guid);
void RestoreState(uint64 guid, char const* debugMsg);
void ClearState(uint64 guid, char const* debugMsg);
void SetDungeon(uint64 guid, uint32 dungeon);
void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons);
void DecreaseKicksLeft(uint64 guid);
void SetState(uint64 guid, LfgState state);
void RemovePlayerData(uint64 guid);
void GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap);
void _SaveToDB(uint64 guid, uint32 db_guid);
uint8 GetTeam(ObjectGuid guid);
void RestoreState(ObjectGuid guid, char const* debugMsg);
void ClearState(ObjectGuid guid, char const* debugMsg);
void SetDungeon(ObjectGuid guid, uint32 dungeon);
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons);
void DecreaseKicksLeft(ObjectGuid guid);
void SetState(ObjectGuid guid, LfgState state);
void RemovePlayerData(ObjectGuid guid);
void GetCompatibleDungeons(LfgDungeonSet& dungeons, GuidSet const& players, LfgLockPartyMap& lockMap);
void _SaveToDB(ObjectGuid guid, uint32 db_guid);
LFGDungeonData const* GetLFGDungeon(uint32 id);
// Proposals
@@ -445,19 +445,19 @@ class LFGMgr
void MakeNewGroup(LfgProposal const& proposal);
// Generic
LFGQueue& GetQueue(uint64 guid);
LFGQueue& GetQueue(ObjectGuid guid);
LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon);
LfgType GetDungeonType(uint32 dungeon);
void SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot);
void SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data);
void SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles);
void SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck);
void SendLfgUpdateStatus(uint64 guid, LfgUpdateData const& data, bool party);
void SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal);
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const& boot);
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const& data);
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles);
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const& roleCheck);
void SendLfgUpdateStatus(ObjectGuid guid, LfgUpdateData const& data, bool party);
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const& proposal);
LfgGuidSet const& GetPlayers(uint64 guid);
GuidSet const& GetPlayers(ObjectGuid guid);
// General variables
uint32 m_QueueTimer; ///< used to check interval of update
@@ -21,7 +21,7 @@ namespace lfg
{
LfgPlayerData::LfgPlayerData(): m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE),
m_Team(0), m_Group(0), m_Roles(0), m_Comment("")
m_Team(0), m_Group(), m_Roles(0), m_Comment("")
{ }
LfgPlayerData::~LfgPlayerData() { }
@@ -34,7 +34,7 @@ void LfgPlayerData::SetState(LfgState state)
case LFG_STATE_FINISHED_DUNGEON:
m_Roles = 0;
m_SelectedDungeons.clear();
m_Comment = "";
m_Comment.clear();
// No break on purpose
case LFG_STATE_DUNGEON:
m_OldState = state;
@@ -59,7 +59,7 @@ void LfgPlayerData::SetTeam(uint8 team)
m_Team = team;
}
void LfgPlayerData::SetGroup(uint64 group)
void LfgPlayerData::SetGroup(ObjectGuid group)
{
m_Group = group;
}
@@ -94,7 +94,7 @@ uint8 LfgPlayerData::GetTeam() const
return m_Team;
}
uint64 LfgPlayerData::GetGroup() const
ObjectGuid LfgPlayerData::GetGroup() const
{
return m_Group;
}
@@ -36,7 +36,7 @@ class LfgPlayerData
void SetState(LfgState state);
void RestoreState();
void SetTeam(uint8 team);
void SetGroup(uint64 group);
void SetGroup(ObjectGuid group);
// Queue
void SetRoles(uint8 roles);
@@ -47,7 +47,7 @@ class LfgPlayerData
LfgState GetState() const;
LfgState GetOldState() const;
uint8 GetTeam() const;
uint64 GetGroup() const;
ObjectGuid GetGroup() const;
// Queue
uint8 GetRoles() const;
@@ -60,7 +60,7 @@ class LfgPlayerData
LfgState m_OldState; ///< Old State - Used to restore state after failed Rolecheck/Proposal
// Player
uint8 m_Team; ///< Player team - determines the queue to join
uint64 m_Group; ///< Original group of player when joined LFG
ObjectGuid m_Group; ///< Original group of player when joined LFG
// Queue
uint8 m_Roles; ///< Roles the player selected when joined LFG
+55 -53
View File
@@ -36,20 +36,20 @@ namespace lfg
@param[in] check list of guids
@returns Concatenated string
*/
std::string ConcatenateGuids(LfgGuidList const& check)
std::string ConcatenateGuids(GuidList const& check)
{
if (check.empty())
return "";
// need the guids in order to avoid duplicates
LfgGuidSet guids(check.begin(), check.end());
GuidSet guids(check.begin(), check.end());
std::ostringstream o;
LfgGuidSet::const_iterator it = guids.begin();
o << (*it);
GuidSet::const_iterator it = guids.begin();
o << it->GetRawValue();
for (++it; it != guids.end(); ++it)
o << '|' << (*it);
o << '|' << it->GetRawValue();
return o.str();
}
@@ -83,26 +83,26 @@ char const* GetCompatibleString(LfgCompatibility compatibles)
}
}
void LFGQueue::AddToQueue(uint64 guid)
void LFGQueue::AddToQueue(ObjectGuid guid)
{
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
if (itQueue == QueueDataStore.end())
{
TC_LOG_ERROR("lfg.queue.add", "Queue data not found for [" UI64FMTD "]", guid);
TC_LOG_ERROR("lfg.queue.add", "Queue data not found for [%s]", guid.ToString().c_str());
return;
}
AddToNewQueue(guid);
}
void LFGQueue::RemoveFromQueue(uint64 guid)
void LFGQueue::RemoveFromQueue(ObjectGuid guid)
{
RemoveFromNewQueue(guid);
RemoveFromCurrentQueue(guid);
RemoveFromCompatibles(guid);
std::ostringstream o;
o << guid;
o << guid.GetRawValue();
std::string sguid = o.str();
LfgQueueDataContainer::iterator itDelete = QueueDataStore.end();
@@ -122,33 +122,33 @@ void LFGQueue::RemoveFromQueue(uint64 guid)
QueueDataStore.erase(itDelete);
}
void LFGQueue::AddToNewQueue(uint64 guid)
void LFGQueue::AddToNewQueue(ObjectGuid guid)
{
newToQueueStore.push_back(guid);
}
void LFGQueue::RemoveFromNewQueue(uint64 guid)
void LFGQueue::RemoveFromNewQueue(ObjectGuid guid)
{
newToQueueStore.remove(guid);
}
void LFGQueue::AddToCurrentQueue(uint64 guid)
void LFGQueue::AddToCurrentQueue(ObjectGuid guid)
{
currentQueueStore.push_back(guid);
}
void LFGQueue::RemoveFromCurrentQueue(uint64 guid)
void LFGQueue::RemoveFromCurrentQueue(ObjectGuid guid)
{
currentQueueStore.remove(guid);
}
void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
void LFGQueue::AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
{
QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap);
AddToQueue(guid);
}
void LFGQueue::RemoveQueueData(uint64 guid)
void LFGQueue::RemoveQueueData(ObjectGuid guid)
{
LfgQueueDataContainer::iterator it = QueueDataStore.find(guid);
if (it != QueueDataStore.end())
@@ -188,13 +188,13 @@ void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
@param[in] guid Guid to remove from compatible cache
*/
void LFGQueue::RemoveFromCompatibles(uint64 guid)
void LFGQueue::RemoveFromCompatibles(ObjectGuid guid)
{
std::stringstream out;
out << guid;
out << guid.GetRawValue();
std::string strGuid = out.str();
TC_LOG_DEBUG("lfg.queue.data.compatibles.remove", "Removing [" UI64FMTD "]", guid);
TC_LOG_DEBUG("lfg.queue.data.compatibles.remove", "Removing %s", guid.ToString().c_str());
for (LfgCompatibleContainer::iterator itNext = CompatibleMapStore.begin(); itNext != CompatibleMapStore.end();)
{
LfgCompatibleContainer::iterator it = itNext++;
@@ -247,16 +247,18 @@ LfgCompatibilityData* LFGQueue::GetCompatibilityData(std::string const& key)
uint8 LFGQueue::FindGroups()
{
uint8 proposals = 0;
LfgGuidList firstNew;
GuidList firstNew;
while (!newToQueueStore.empty())
{
uint64 frontguid = newToQueueStore.front();
TC_LOG_DEBUG("lfg.queue.match.check.new", "Checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(newToQueueStore.size()), uint32(currentQueueStore.size()));
ObjectGuid frontguid = newToQueueStore.front();
TC_LOG_DEBUG("lfg.queue.match.check.new", "Checking [%s] newToQueue(%u), currentQueue(%u)", frontguid.ToString().c_str(),
uint32(newToQueueStore.size()), uint32(currentQueueStore.size()));
firstNew.clear();
firstNew.push_back(frontguid);
RemoveFromNewQueue(frontguid);
LfgGuidList temporalList = currentQueueStore;
GuidList temporalList = currentQueueStore;
LfgCompatibility compatibles = FindNewGroups(firstNew, temporalList);
if (compatibles == LFG_COMPATIBLES_MATCH)
@@ -274,7 +276,7 @@ uint8 LFGQueue::FindGroups()
@param[in] all List of all other guids in main queue to match against
@return LfgCompatibility type of compatibility between groups
*/
LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all)
LfgCompatibility LFGQueue::FindNewGroups(GuidList& check, GuidList& all)
{
std::string strGuids = ConcatenateGuids(check);
LfgCompatibility compatibles = GetCompatibles(strGuids);
@@ -312,7 +314,7 @@ LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all)
@param[in] check List of guids to check compatibilities
@return LfgCompatibility type of compatibility
*/
LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
{
std::string strGuids = ConcatenateGuids(check);
LfgProposal proposal;
@@ -330,7 +332,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
// Check all-but-new compatiblitity
if (check.size() > 2)
{
uint64 frontGuid = check.front();
ObjectGuid frontGuid = check.front();
check.pop_front();
// Check all-but-new compatibilities (New, A, B, C, D) --> check(A, B, C, D)
@@ -347,20 +349,20 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
// Check if more than one LFG group and number of players joining
uint8 numPlayers = 0;
uint8 numLfgGroups = 0;
for (LfgGuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it)
for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it)
{
uint64 guid = (*it);
ObjectGuid guid = *it;
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
if (itQueue == QueueDataStore.end())
{
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guid: [" UI64FMTD "] is not queued but listed as queued!", guid);
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guid: [%s] is not queued but listed as queued!", guid.ToString().c_str());
RemoveFromQueue(guid);
return LFG_COMPATIBILITY_PENDING;
}
// Store group so we don't need to call Mgr to get it later (if it's player group will be 0 otherwise would have joined as group)
for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2)
proposalGroups[it2->first] = IS_GROUP_GUID(itQueue->first) ? itQueue->first : 0;
proposalGroups[it2->first] = itQueue->first.IsGroup() ? itQueue->first : ObjectGuid::Empty;
numPlayers += itQueue->second.roles.size();
@@ -404,16 +406,16 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
// If it's single group no need to check for duplicate players, ignores, bad roles or bad dungeons as it's been checked before joining
if (check.size() > 1)
{
for (LfgGuidList::const_iterator it = check.begin(); it != check.end(); ++it)
for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
{
const LfgRolesMap &roles = QueueDataStore[(*it)].roles;
LfgRolesMap const& roles = QueueDataStore[(*it)].roles;
for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
{
LfgRolesMap::const_iterator itPlayer;
for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer)
{
if (itRoles->first == itPlayer->first)
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guids: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first);
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guids: ERROR! Player multiple times in queue! [%s]", itRoles->first.ToString().c_str());
else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first))
break;
}
@@ -434,22 +436,22 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
{
std::ostringstream o;
for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
o << ", " << it->first << ": " << GetRolesString(it->second);
o << ", " << it->first.GetRawValue() << ": " << GetRolesString(it->second);
TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: (%s) Roles not compatible%s", strGuids.c_str(), o.str().c_str());
SetCompatibles(strGuids, LFG_INCOMPATIBLES_NO_ROLES);
return LFG_INCOMPATIBLES_NO_ROLES;
}
LfgGuidList::iterator itguid = check.begin();
GuidList::iterator itguid = check.begin();
proposalDungeons = QueueDataStore[*itguid].dungeons;
std::ostringstream o;
o << ", " << *itguid << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
for (++itguid; itguid != check.end(); ++itguid)
{
LfgDungeonSet temporal;
LfgDungeonSet &dungeons = QueueDataStore[*itguid].dungeons;
o << ", " << *itguid << ": (" << ConcatenateDungeons(dungeons) << ")";
LfgDungeonSet& dungeons = QueueDataStore[*itguid].dungeons;
o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(dungeons) << ")";
std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
proposalDungeons = temporal;
}
@@ -463,7 +465,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
}
else
{
uint64 gguid = *check.begin();
ObjectGuid gguid = *check.begin();
const LfgQueueData &queue = QueueDataStore[gguid];
proposalDungeons = queue.dungeons;
proposalRoles = queue.roles;
@@ -477,14 +479,14 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS);
data.roles = proposalRoles;
for (LfgGuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
for (GuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
UpdateBestCompatibleInQueue(QueueDataStore.find(*itr), strGuids, data.roles);
SetCompatibilityData(strGuids, data);
return LFG_COMPATIBLES_WITH_LESS_PLAYERS;
}
uint64 gguid = *check.begin();
ObjectGuid gguid = *check.begin();
proposal.queues = check;
proposal.isNew = numLfgGroups != 1 || sLFGMgr->GetOldState(gguid) != LFG_STATE_DUNGEON;
@@ -498,7 +500,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
// Create a new proposal
proposal.cancelTime = time(NULL) + LFG_TIME_PROPOSAL;
proposal.state = LFG_PROPOSAL_INITIATING;
proposal.leader = 0;
proposal.leader.Clear();
proposal.dungeonId = Trinity::Containers::SelectRandomContainerElement(proposalDungeons);
bool leader = false;
@@ -523,9 +525,9 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
}
// Mark proposal members as not queued (but not remove queue data)
for (LfgGuidList::const_iterator itQueue = proposal.queues.begin(); itQueue != proposal.queues.end(); ++itQueue)
for (GuidList::const_iterator itQueue = proposal.queues.begin(); itQueue != proposal.queues.end(); ++itQueue)
{
uint64 guid = (*itQueue);
ObjectGuid guid = (*itQueue);
RemoveFromNewQueue(guid);
RemoveFromCurrentQueue(guid);
}
@@ -581,13 +583,13 @@ void LFGQueue::UpdateQueueTimers(uint8 queueId, time_t currTime)
LfgQueueStatusData queueData(queueId, dungeonId, queueinfo.joinTime, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps);
for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer)
{
uint64 pguid = itPlayer->first;
ObjectGuid pguid = itPlayer->first;
LFGMgr::SendLfgQueueStatus(pguid, queueData);
}
}
}
time_t LFGQueue::GetJoinTime(uint64 guid) const
time_t LFGQueue::GetJoinTime(ObjectGuid guid) const
{
LfgQueueDataContainer::const_iterator itr = QueueDataStore.find(guid);
if (itr != QueueDataStore.end())
@@ -604,11 +606,11 @@ std::string LFGQueue::DumpQueueInfo() const
for (uint8 i = 0; i < 2; ++i)
{
LfgGuidList const& queue = i ? newToQueueStore : currentQueueStore;
for (LfgGuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
GuidList const& queue = i ? newToQueueStore : currentQueueStore;
for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
{
uint64 guid = *it;
if (IS_GROUP_GUID(guid))
ObjectGuid guid = *it;
if (guid.IsGroup())
{
groups++;
playersInGroup += sLFGMgr->GetPlayerCount(guid);
@@ -635,9 +637,9 @@ std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const
void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue)
{
TC_LOG_DEBUG("lfg.queue.compatibles.find", "Guid: " UI64FMTD, itrQueue->first);
TC_LOG_DEBUG("lfg.queue.compatibles.find", "%s", itrQueue->first.ToString().c_str());
std::ostringstream o;
o << itrQueue->first;
o << itrQueue->first.GetRawValue();
std::string sguid = o.str();
for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr)
@@ -660,8 +662,8 @@ void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQu
if (size <= storedSize)
return;
TC_LOG_DEBUG("lfg.queue.compatibles.update", "Changed (%s) to (%s) as best compatible group for " UI64FMTD,
queueData.bestCompatible.c_str(), key.c_str(), itrQueue->first);
TC_LOG_DEBUG("lfg.queue.compatibles.update", "Changed (%s) to (%s) as best compatible group for %s",
queueData.bestCompatible.c_str(), key.c_str(), itrQueue->first.ToString().c_str());
queueData.bestCompatible = key;
queueData.tanks = LFG_TANKS_NEEDED;
+15 -16
View File
@@ -78,7 +78,7 @@ struct LfgWaitTime
typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer;
typedef std::map<std::string, LfgCompatibilityData> LfgCompatibleContainer;
typedef std::map<uint64, LfgQueueData> LfgQueueDataContainer;
typedef std::map<ObjectGuid, LfgQueueData> LfgQueueDataContainer;
/**
Stores all data related to queue
@@ -88,10 +88,10 @@ class LFGQueue
public:
// Add/Remove from queue
void AddToQueue(uint64 guid);
void RemoveFromQueue(uint64 guid);
void AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap);
void RemoveQueueData(uint64 guid);
void AddToQueue(ObjectGuid guid);
void RemoveFromQueue(ObjectGuid guid);
void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap);
void RemoveQueueData(ObjectGuid guid);
// Update Timers (when proposal success)
void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId);
@@ -101,7 +101,7 @@ class LFGQueue
// Update Queue timers
void UpdateQueueTimers(uint8 queueId, time_t currTime);
time_t GetJoinTime(uint64 guid) const;
time_t GetJoinTime(ObjectGuid guid) const;
// Find new group
uint8 FindGroups();
@@ -112,24 +112,23 @@ class LFGQueue
private:
void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles);
LfgRolesMap const& RemoveFromQueueUpdateData(uint64 guid);
void AddToNewQueue(uint64 guid);
void AddToCurrentQueue(uint64 guid);
void RemoveFromNewQueue(uint64 guid);
void RemoveFromCurrentQueue(uint64 guid);
void AddToNewQueue(ObjectGuid guid);
void AddToCurrentQueue(ObjectGuid guid);
void RemoveFromNewQueue(ObjectGuid guid);
void RemoveFromCurrentQueue(ObjectGuid guid);
void SetCompatibles(std::string const& key, LfgCompatibility compatibles);
LfgCompatibility GetCompatibles(std::string const& key);
void RemoveFromCompatibles(uint64 guid);
void RemoveFromCompatibles(ObjectGuid guid);
void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles);
LfgCompatibilityData* GetCompatibilityData(std::string const& key);
void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue);
void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles);
LfgCompatibility FindNewGroups(LfgGuidList& check, LfgGuidList& all);
LfgCompatibility CheckCompatibility(LfgGuidList check);
LfgCompatibility FindNewGroups(GuidList& check, GuidList& all);
LfgCompatibility CheckCompatibility(GuidList check);
// Queue
LfgQueueDataContainer QueueDataStore; ///< Queued groups
@@ -139,8 +138,8 @@ class LFGQueue
LfgWaitTimesContainer waitTimesTankStore; ///< Average wait time to find a group queuing as tank
LfgWaitTimesContainer waitTimesHealerStore; ///< Average wait time to find a group queuing as healer
LfgWaitTimesContainer waitTimesDpsStore; ///< Average wait time to find a group queuing as dps
LfgGuidList currentQueueStore; ///< Ordered list. Used to find groups
LfgGuidList newToQueueStore; ///< New groups to add to queue
GuidList currentQueueStore; ///< Ordered list. Used to find groups
GuidList newToQueueStore; ///< New groups to add to queue
};
} // namespace lfg
+28 -23
View File
@@ -52,16 +52,16 @@ void LFGPlayerScript::OnLogin(Player* player, bool /*loginFirst*/)
return;
// Temporal: Trying to determine when group data and LFG data gets desynched
uint64 guid = player->GetGUID();
uint64 gguid = sLFGMgr->GetGroup(guid);
ObjectGuid guid = player->GetGUID();
ObjectGuid gguid = sLFGMgr->GetGroup(guid);
if (Group const* group = player->GetGroup())
{
uint64 gguid2 = group->GetGUID();
ObjectGuid gguid2 = group->GetGUID();
if (gguid != gguid2)
{
TC_LOG_ERROR("lfg", "%s on group %u but LFG has group %u saved... Fixing.",
player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid));
player->GetSession()->GetPlayerInfo().c_str(), gguid2.GetCounter(), gguid.GetCounter());
sLFGMgr->SetupGroupMember(guid, group->GetGUID());
}
}
@@ -104,24 +104,24 @@ void LFGPlayerScript::OnMapChanged(Player* player)
LFGGroupScript::LFGGroupScript() : GroupScript("LFGGroupScript") { }
void LFGGroupScript::OnAddMember(Group* group, uint64 guid)
void LFGGroupScript::OnAddMember(Group* group, ObjectGuid guid)
{
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 gguid = group->GetGUID();
uint64 leader = group->GetLeaderGUID();
ObjectGuid gguid = group->GetGUID();
ObjectGuid leader = group->GetLeaderGUID();
if (leader == guid)
{
TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "]", gguid, guid, leader);
TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s]", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str());
sLFGMgr->SetLeader(gguid, guid);
}
else
{
LfgState gstate = sLFGMgr->GetState(gguid);
LfgState state = sLFGMgr->GetState(guid);
TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state);
TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s] gstate: %u, state: %u", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str(), gstate, state);
if (state == LFG_STATE_QUEUED)
sLFGMgr->LeaveLfg(guid);
@@ -134,13 +134,14 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid)
sLFGMgr->AddPlayerToGroup(gguid, guid);
}
void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason)
void LFGGroupScript::OnRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason)
{
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 gguid = group->GetGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d Kicker: [" UI64FMTD "] Reason: %s", gguid, guid, method, kicker, (reason ? reason : ""));
ObjectGuid gguid = group->GetGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [%s]: remove [%s] Method: %d Kicker: [%s] Reason: %s",
gguid.ToString().c_str(), guid.ToString().c_str(), method, kicker.ToString().c_str(), (reason ? reason : ""));
bool isLFG = group->isLFGGroup();
@@ -160,13 +161,13 @@ void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod meth
if (state == LFG_STATE_PROPOSAL && method == GROUP_REMOVEMETHOD_DEFAULT)
{
// LfgData: Remove player from group
sLFGMgr->SetGroup(guid, 0);
sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
sLFGMgr->RemovePlayerFromGroup(gguid, guid);
return;
}
sLFGMgr->LeaveLfg(guid);
sLFGMgr->SetGroup(guid, 0);
sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
uint8 players = sLFGMgr->RemovePlayerFromGroup(gguid, guid);
if (Player* player = ObjectAccessor::FindPlayer(guid))
@@ -192,31 +193,35 @@ void LFGGroupScript::OnDisband(Group* group)
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 gguid = group->GetGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnDisband [" UI64FMTD "]", gguid);
ObjectGuid gguid = group->GetGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnDisband [%s]", gguid.ToString().c_str());
sLFGMgr->RemoveGroupData(gguid);
}
void LFGGroupScript::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
void LFGGroupScript::OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid)
{
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 gguid = group->GetGUID();
ObjectGuid gguid = group->GetGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [%s]: old [%s] new [%s]",
gguid.ToString().c_str(), newLeaderGuid.ToString().c_str(), oldLeaderGuid.ToString().c_str());
TC_LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
sLFGMgr->SetLeader(gguid, newLeaderGuid);
}
void LFGGroupScript::OnInviteMember(Group* group, uint64 guid)
void LFGGroupScript::OnInviteMember(Group* group, ObjectGuid guid)
{
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 gguid = group->GetGUID();
uint64 leader = group->GetLeaderGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, leader);
ObjectGuid gguid = group->GetGUID();
ObjectGuid leader = group->GetLeaderGUID();
TC_LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [%s]: invite [%s] leader [%s]",
gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str());
// No gguid == new group being formed
// No leader == after group creation first invite is new leader
// leader and no gguid == first invite after leader is added to new group (this is the real invite)
+4 -4
View File
@@ -46,11 +46,11 @@ class LFGGroupScript : public GroupScript
LFGGroupScript();
// Group Hooks
void OnAddMember(Group* group, uint64 guid) override;
void OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) override;
void OnAddMember(Group* group, ObjectGuid guid) override;
void OnRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason) override;
void OnDisband(Group* group) override;
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) override;
void OnInviteMember(Group* group, uint64 guid) override;
void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) override;
void OnInviteMember(Group* group, ObjectGuid guid) override;
};
} // namespace lfg
+6 -6
View File
@@ -88,7 +88,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetPhaseMask());
SetObjectScale(1);
SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID());
SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID());
_gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
@@ -104,7 +104,7 @@ void Corpse::SaveToDB()
uint16 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
stmt->setUInt32(index++, GetGUIDLow()); // corpseGuid
stmt->setUInt32(index++, GUID_LOPART(GetOwnerGUID())); // guid
stmt->setUInt32(index++, GetOwnerGUID().GetCounter()); // guid
stmt->setFloat (index++, GetPositionX()); // posX
stmt->setFloat (index++, GetPositionY()); // posY
stmt->setFloat (index++, GetPositionZ()); // posZ
@@ -152,7 +152,7 @@ void Corpse::DeleteFromDB(SQLTransaction& trans)
{
// all corpses (not bones)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_CORPSES);
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
}
trans->Append(stmt);
}
@@ -177,7 +177,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[9].GetUInt8());
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[10].GetUInt8());
SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(ownerGuid, 0, HIGHGUID_PLAYER));
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid(HIGHGUID_PLAYER, ownerGuid));
m_time = time_t(fields[11].GetUInt32());
@@ -191,8 +191,8 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.player", "Corpse (guid: %u, owner: %u) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ);
TC_LOG_ERROR("entities.player", "Corpse (%s, owner: %s) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
GetGUID().ToString().c_str(), GetOwnerGUID().ToString().c_str(), posX, posY, posZ);
return false;
}
+1 -1
View File
@@ -64,7 +64,7 @@ class Corpse : public WorldObject, public GridObject<Corpse>
void DeleteBonesFromWorld();
void DeleteFromDB(SQLTransaction& trans);
uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
ObjectGuid GetOwnerGUID() const { return GetGuidValue(CORPSE_FIELD_OWNER); }
time_t const& GetGhostTime() const { return m_time; }
void ResetGhostTime() { m_time = time(NULL); }
+15 -15
View File
@@ -143,7 +143,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(),
m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0),
m_lootRecipient(0), m_lootRecipientGroup(0), _skinner(0), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_lootRecipient(), m_lootRecipientGroup(0), _skinner(), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
@@ -471,17 +471,17 @@ void Creature::Update(uint32 diff)
if (!allowed) // Will be rechecked on next Update call
break;
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
ObjectGuid dbtableHighGuid(HIGHGUID_UNIT, GetEntry(), m_DBTableGuid);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (!linkedRespawntime) // Can respawn
Respawn();
else // the master is dead
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime)+urand(5, MINUTE); // else copy time from master and add a little
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
}
}
@@ -532,7 +532,7 @@ void Creature::Update(uint32 diff)
if (Unit* charmer = ObjectAccessor::GetUnit(*this, LastCharmerGUID))
i_AI->AttackStart(charmer);
LastCharmerGUID = 0;
LastCharmerGUID.Clear();
}
if (!IsInEvadeMode() && IsAIEnabled)
@@ -893,7 +893,7 @@ void Creature::SetLootRecipient(Unit* unit)
if (!unit)
{
m_lootRecipient = 0;
m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
return;
@@ -1224,7 +1224,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
m_DBTableGuid = guid;
if (map->GetInstanceId() == 0)
{
if (map->GetCreature(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guid)))
return false;
}
else
@@ -1474,7 +1474,7 @@ void Creature::setDeathState(DeathState s)
if (sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY) || isWorldBoss())
SaveRespawnTime();
SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetTarget(ObjectGuid::Empty); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
setActive(false);
@@ -1533,8 +1533,8 @@ void Creature::Respawn(bool force)
if (m_DBTableGuid)
GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid);
TC_LOG_DEBUG("entities.unit", "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)",
GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry());
TC_LOG_DEBUG("entities.unit", "Respawning creature %s (%s)",
GetName().c_str(), GetGUID().ToString().c_str());
m_respawnTime = 0;
ResetPickPocketRefillTimer();
loot.clear();
@@ -2572,10 +2572,10 @@ void Creature::SetDisplayId(uint32 modelId)
}
}
void Creature::SetTarget(uint64 guid)
void Creature::SetTarget(ObjectGuid guid)
{
if (!_focusSpell)
SetUInt64Value(UNIT_FIELD_TARGET, guid);
SetGuidValue(UNIT_FIELD_TARGET, guid);
}
void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
@@ -2585,7 +2585,7 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
return;
_focusSpell = focusSpell;
SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID());
SetGuidValue(UNIT_FIELD_TARGET, target->GetGUID());
if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST)
AddUnitState(UNIT_STATE_ROTATING);
@@ -2601,9 +2601,9 @@ void Creature::ReleaseFocus(Spell const* focusSpell)
_focusSpell = NULL;
if (Unit* victim = GetVictim())
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
SetGuidValue(UNIT_FIELD_TARGET, victim->GetGUID());
else
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty);
if (focusSpell->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_DONT_TURN_DURING_CAST)
ClearUnitState(UNIT_STATE_ROTATING);
+10 -10
View File
@@ -552,11 +552,11 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void StartPickPocketRefillTimer();
void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; }
bool CanGeneratePickPocketLoot() const { return _pickpocketLootRestore <= time(NULL); }
void SetSkinner(uint64 guid) { _skinner = guid; }
uint64 GetSkinner() const { return _skinner; } // Returns the player who skinned this creature
void SetSkinner(ObjectGuid guid) { _skinner = guid; }
ObjectGuid GetSkinner() const { return _skinner; } // Returns the player who skinned this creature
Player* GetLootRecipient() const;
Group* GetLootRecipientGroup() const;
bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
bool hasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; }
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
void SetLootRecipient (Unit* unit);
@@ -674,7 +674,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
bool m_isTempWorldObject; //true when possessed
// Handling caster facing during spellcast
void SetTarget(uint64 guid) override;
void SetTarget(ObjectGuid guid) override;
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
void ReleaseFocus(Spell const* focusSpell);
@@ -687,9 +687,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
static float _GetHealthMod(int32 Rank);
uint64 m_lootRecipient;
ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
uint64 _skinner;
ObjectGuid _skinner;
/// Timers
time_t _pickpocketLootRestore;
@@ -746,15 +746,15 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
class AssistDelayEvent : public BasicEvent
{
public:
AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
AssistDelayEvent(ObjectGuid victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time) override;
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
void AddAssistant(ObjectGuid guid) { m_assistants.push_back(guid); }
private:
AssistDelayEvent();
uint64 m_victim;
std::list<uint64> m_assistants;
ObjectGuid m_victim;
GuidList m_assistants;
Unit& m_owner;
};
+13 -13
View File
@@ -28,7 +28,7 @@ GossipMenu::GossipMenu()
{
_menuId = 0;
_locale = DEFAULT_LOCALE;
_senderGUID = 0;
_senderGUID.Clear();
}
GossipMenu::~GossipMenu()
@@ -188,7 +188,7 @@ void PlayerMenu::ClearMenus()
_questMenu.ClearMenu();
}
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID)
void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID)
{
_gossipMenu.SetSenderGUID(objectGUID);
@@ -248,7 +248,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID)
void PlayerMenu::SendCloseGossip()
{
_gossipMenu.SetSenderGUID(0);
_gossipMenu.SetSenderGUID(ObjectGuid::Empty);
WorldPacket data(SMSG_GOSSIP_COMPLETE, 0);
_session->SendPacket(&data);
@@ -323,7 +323,7 @@ void QuestMenu::ClearMenu()
_questMenuItems.clear();
}
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID)
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID)
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100); // guess size
data << uint64(npcGUID);
@@ -368,20 +368,20 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string
data.put<uint8>(count_pos, count);
_session->SendPacket(&data);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC=%s", npcGUID.ToString().c_str());
}
void PlayerMenu::SendQuestGiverStatus(uint32 questStatus, uint64 npcGUID) const
void PlayerMenu::SendQuestGiverStatus(uint32 questStatus, ObjectGuid npcGUID) const
{
WorldPacket data(SMSG_QUESTGIVER_STATUS, 8 + 4);
data << uint64(npcGUID);
data << uint32(questStatus);
_session->SendPacket(&data);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC=%s, status=%u", npcGUID.ToString().c_str(), questStatus);
}
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const
{
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
@@ -441,7 +441,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
}
_session->SendPacket(&data);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPC=%s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
}
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
@@ -615,7 +615,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const
{
std::string questTitle = quest->GetTitle();
std::string questOfferRewardText = quest->GetOfferRewardText();
@@ -676,10 +676,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
quest->BuildExtraQuestInfo(data, _session->GetPlayer());
_session->SendPacket(&data);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPC=%s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
}
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const
{
// We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward
@@ -764,7 +764,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
data << uint32(0x40);
_session->SendPacket(&data);
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPC=%s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
}
void PlayerMenu::AddQuestLevelToTitle(std::string &title, int32 level)
+10 -9
View File
@@ -20,6 +20,7 @@
#define TRINITYCORE_GOSSIP_H
#include "Common.h"
#include "ObjectGuid.h"
#include "QuestDef.h"
#include "NPCHandler.h"
@@ -167,8 +168,8 @@ class GossipMenu
void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
uint32 GetMenuId() const { return _menuId; }
void SetSenderGUID(uint64 guid) { _senderGUID = guid; }
uint64 GetSenderGUID() const { return _senderGUID; }
void SetSenderGUID(ObjectGuid guid) { _senderGUID = guid; }
ObjectGuid GetSenderGUID() const { return _senderGUID; }
void SetLocale(LocaleConstant locale) { _locale = locale; }
LocaleConstant GetLocale() const { return _locale; }
@@ -217,7 +218,7 @@ class GossipMenu
GossipMenuItemContainer _menuItems;
GossipMenuItemDataContainer _menuItemData;
uint32 _menuId;
uint64 _senderGUID;
ObjectGuid _senderGUID;
LocaleConstant _locale;
};
@@ -267,22 +268,22 @@ class PlayerMenu
uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID);
void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID);
void SendCloseGossip();
void SendPointOfInterest(uint32 poiId) const;
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
void SendQuestGiverStatus(uint32 questStatus, uint64 npcGUID) const;
void SendQuestGiverStatus(uint32 questStatus, ObjectGuid npcGUID) const;
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID);
void SendQuestQueryResponse(Quest const* quest) const;
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const;
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const;
static void AddQuestLevelToTitle(std::string &title, int32 level);
@@ -28,7 +28,9 @@ TempSummon::TempSummon(SummonPropertiesEntry const* properties, Unit* owner, boo
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
m_timer(0), m_lifetime(0)
{
m_summonerGUID = owner ? owner->GetGUID() : 0;
if (owner)
m_summonerGUID = owner->GetGUID();
m_unitTypeMask |= UNIT_MASK_SUMMON;
}
@@ -274,7 +276,7 @@ void TempSummon::RemoveFromWorld()
if (slot > 0)
if (Unit* owner = GetSummoner())
if (owner->m_SummonSlot[slot] == GetGUID())
owner->m_SummonSlot[slot] = 0;
owner->m_SummonSlot[slot].Clear();
}
//if (GetOwnerGUID())
@@ -51,7 +51,7 @@ class TempSummon : public Creature
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override { }
Unit* GetSummoner() const;
Creature* GetSummonerCreatureBase() const;
uint64 GetSummonerGUID() const { return m_summonerGUID; }
ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
TempSummonType const& GetSummonType() { return m_type; }
uint32 GetTimer() { return m_timer; }
@@ -60,7 +60,7 @@ class TempSummon : public Creature
TempSummonType m_type;
uint32 m_timer;
uint32 m_lifetime;
uint64 m_summonerGUID;
ObjectGuid m_summonerGUID;
};
class Minion : public TempSummon
@@ -94,7 +94,7 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, SpellInfo
SetEntry(spell->Id);
SetObjectScale(1);
SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());
SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());
SetUInt32Value(DYNAMICOBJECT_BYTES, spell->SpellVisual[0] | (type << 28));
SetUInt32Value(DYNAMICOBJECT_SPELLID, spell->Id);
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
@@ -55,7 +55,7 @@ class DynamicObject : public WorldObject, public GridObject<DynamicObject>, publ
void BindToCaster();
void UnbindFromCaster();
uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); }
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
ObjectGuid GetCasterGUID() const { return GetGuidValue(DYNAMICOBJECT_CASTER); }
float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); }
protected:
@@ -47,19 +47,16 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_respawnTime = 0;
m_respawnDelayTime = 300;
m_lootState = GO_NOT_READY;
m_lootStateUnitGUID = 0;
m_spawnedByDefault = true;
m_usetimes = 0;
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = NULL;
m_ritualOwnerGUID = 0;
m_goData = NULL;
m_DBTableGuid = 0;
m_rotation = 0;
m_lootRecipient = 0;
m_lootRecipientGroup = 0;
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
@@ -78,8 +75,7 @@ GameObject::~GameObject()
bool GameObject::AIM_Initialize()
{
if (m_AI)
delete m_AI;
delete m_AI;
m_AI = FactorySelector::SelectGameObjectAI(this);
@@ -108,7 +104,7 @@ void GameObject::CleanupsBeforeDelete(bool finalCleanup)
void GameObject::RemoveFromOwner()
{
uint64 ownerGUID = GetOwnerGUID();
ObjectGuid ownerGUID = GetOwnerGUID();
if (!ownerGUID)
return;
@@ -119,15 +115,9 @@ void GameObject::RemoveFromOwner()
return;
}
const char * ownerType = "creature";
if (IS_PLAYER_GUID(ownerGUID))
ownerType = "player";
else if (IS_PET_GUID(ownerGUID))
ownerType = "pet";
TC_LOG_FATAL("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (GUID: %u Type: '%s') GO list",
GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType);
SetOwnerGUID(0);
TC_LOG_FATAL("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list",
GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
SetOwnerGUID(ObjectGuid::Empty);
}
void GameObject::AddToWorld()
@@ -384,11 +374,11 @@ void GameObject::Update(uint32 diff)
time_t now = time(NULL);
if (m_respawnTime <= now) // timer expired
{
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT);
ObjectGuid dbtableHighGuid(HIGHGUID_GAMEOBJECT, GetEntry(), m_DBTableGuid);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (linkedRespawntime) // Can't respawn, the master is dead
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
@@ -593,7 +583,7 @@ void GameObject::Update(uint32 diff)
if (spellId)
{
for (std::set<uint64>::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
for (GuidSet::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
// m_unique_users can contain only player GUIDs
if (Player* owner = ObjectAccessor::GetPlayer(*this, *it))
owner->CastSpell(owner, spellId, false);
@@ -990,14 +980,15 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
return false;
// Always seen by owner and friendly units
if (uint64 guid = GetOwnerGUID())
if (ObjectGuid guid = GetOwnerGUID())
{
if (seer->GetGUID() == guid)
return true;
Unit* owner = GetOwner();
if (owner && seer->isType(TYPEMASK_UNIT) && owner->IsFriendlyTo(((Unit*)seer)))
return true;
if (Unit const* unitSeer = seer->ToUnit())
if (owner && owner->IsFriendlyTo(unitSeer))
return true;
}
return false;
@@ -1248,9 +1239,9 @@ void GameObject::Use(Unit* user)
{
if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
for (uint32 i = 0; i < info->chair.slots; ++i)
ChairListSlots[i] = 0; // Last user of current slot set to 0 (none sit here yet)
ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet)
else
ChairListSlots[0] = 0; // error in DB, make one default slot
ChairListSlots[0].Clear(); // error in DB, make one default slot
}
Player* player = user->ToPlayer();
@@ -1283,10 +1274,10 @@ void GameObject::Use(Unit* user)
if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required.
else
itr->second = 0; // This seat is unoccupied.
itr->second.Clear(); // This seat is unoccupied.
}
else
itr->second = 0; // The seat may of had an occupant, but they're offline.
itr->second.Clear(); // The seat may of had an occupant, but they're offline.
}
found_free_slot = true;
@@ -1566,7 +1557,7 @@ void GameObject::Use(Unit* user)
else
{
// reset ritual for this GO
m_ritualOwnerGUID = 0;
m_ritualOwnerGUID.Clear();
m_unique_users.clear();
m_usetimes = 0;
}
@@ -1807,7 +1798,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, bool triggered /*= true
trigger->setFaction(14);
// Set owner guid for target if no owner available - needed by trigger auras
// - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : 0);
trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty);
}
}
@@ -1930,9 +1921,9 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u
if (player)
{
WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8 + 8 + 8 + 4 + 4);
data.appendPackGUID(GetGUID());
data.appendPackGUID(attackerOrHealer->GetGUID());
data.appendPackGUID(player->GetGUID());
data << GetPackGUID();
data << attackerOrHealer->GetPackGUID();
data << player->GetPackGUID();
data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event
// change >= 0 triggers SPELL_BUILDING_DAMAGE event
data << uint32(spellId);
@@ -2048,7 +2039,11 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
void GameObject::SetLootState(LootState state, Unit* unit)
{
m_lootState = state;
m_lootStateUnitGUID = unit ? unit->GetGUID() : 0;
if (unit)
m_lootStateUnitGUID = unit->GetGUID();
else
m_lootStateUnitGUID.Clear();
AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
@@ -2143,7 +2138,7 @@ void GameObject::SetLootRecipient(Unit* unit)
if (!unit)
{
m_lootRecipient = 0;
m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
return;
}
@@ -667,7 +667,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true);
void DeleteFromDB();
void SetOwnerGUID(uint64 owner)
void SetOwnerGUID(ObjectGuid owner)
{
// Owner already found and different than expected owner - remove object from old owner
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
@@ -675,9 +675,9 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
ASSERT(false);
}
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
SetGuidValue(OBJECT_FIELD_CREATED_BY, owner);
}
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
Unit* GetOwner() const;
void SetSpellId(uint32 id)
@@ -767,7 +767,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
Group* GetLootRecipientGroup() const;
void SetLootRecipient(Unit* unit);
bool IsLootAllowedFor(Player const* player) const;
bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; }
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting
@@ -846,17 +846,17 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
LootState m_lootState;
uint64 m_lootStateUnitGUID; // GUID of the unit passed with SetLootState(LootState, Unit*)
ObjectGuid m_lootStateUnitGUID; // GUID of the unit passed with SetLootState(LootState, Unit*)
bool m_spawnedByDefault;
time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
// For traps this: spell casting cooldown, for doors/buttons: reset time.
std::list<uint32> m_SkillupList;
uint64 m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
std::set<uint64> m_unique_users;
ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
GuidSet m_unique_users;
uint32 m_usetimes;
typedef std::map<uint32, uint64> ChairSlotAndUser;
typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
ChairSlotAndUser ChairListSlots;
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
@@ -867,7 +867,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
uint64 m_rotation;
Position m_stationaryPosition;
uint64 m_lootRecipient;
ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
private:
+13 -10
View File
@@ -81,8 +81,11 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
SetEntry(itemid);
SetObjectScale(1.0f);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
if (owner)
{
SetGuidValue(ITEM_FIELD_OWNER, owner->GetGUID());
SetGuidValue(ITEM_FIELD_CONTAINED, owner->GetGUID());
}
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
@@ -94,7 +97,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
// Cleaning 20 slots
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid::Empty);
m_bagslot[i] = NULL;
}
@@ -106,7 +109,7 @@ void Bag::SaveToDB(SQLTransaction& trans)
Item::SaveToDB(trans);
}
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
bool Bag::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
{
if (!Item::LoadFromDB(guid, owner_guid, fields, entry))
return false;
@@ -116,7 +119,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty);
delete m_bagslot[i];
m_bagslot[i] = NULL;
}
@@ -151,7 +154,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/)
m_bagslot[slot]->SetContainer(NULL);
m_bagslot[slot] = NULL;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid::Empty);
}
void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
@@ -161,9 +164,9 @@ void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
if (pItem && pItem->GetGUID() != this->GetGUID())
{
m_bagslot[slot] = pItem;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetOwnerGUID());
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetOwnerGUID());
pItem->SetContainer(this);
pItem->SetSlot(slot);
}
@@ -225,7 +228,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem)
return count;
}
uint8 Bag::GetSlotByItemGUID(uint64 guid) const
uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
{
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] != 0)
@@ -45,7 +45,7 @@ class Bag : public Item
uint32 GetItemCount(uint32 item, Item* eItem = NULL) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const;
uint8 GetSlotByItemGUID(uint64 guid) const;
uint8 GetSlotByItemGUID(ObjectGuid guid) const;
bool IsEmpty() const;
uint32 GetFreeSlots() const;
uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
@@ -54,7 +54,7 @@ class Bag : public Item
// overwrite virtual Item::SaveToDB
void SaveToDB(SQLTransaction& trans) override;
// overwrite virtual Item::LoadFromDB
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) override;
bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override;
// overwrite virtual Item::DeleteFromDB
void DeleteFromDB(SQLTransaction& trans) override;
+23 -18
View File
@@ -267,8 +267,11 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
SetEntry(itemid);
SetObjectScale(1.0f);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
if (owner)
{
SetGuidValue(ITEM_FIELD_OWNER, owner->GetGUID());
SetGuidValue(ITEM_FIELD_CONTAINED, owner->GetGUID());
}
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
if (!itemProto)
@@ -328,9 +331,9 @@ void Item::SaveToDB(SQLTransaction& trans)
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
stmt->setUInt32( index, GetEntry());
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
stmt->setUInt32(++index, GetOwnerGUID().GetCounter());
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
stmt->setUInt32(++index, GetCount());
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
@@ -361,7 +364,7 @@ void Item::SaveToDB(SQLTransaction& trans)
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
stmt->setUInt32(1, guid);
trans->Append(stmt);
}
@@ -400,7 +403,7 @@ void Item::SaveToDB(SQLTransaction& trans)
CharacterDatabase.CommitTransaction(trans);
}
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
{
// 0 1 2 3 4 5 6 7 8 9 10
//result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
@@ -418,12 +421,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
return false;
// set owner (not if item is only loaded for gbank/auction/mail
if (owner_guid != 0)
if (owner_guid)
SetOwnerGUID(owner_guid);
bool need_save = false; // need explicit save data at load fixes
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()));
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32()));
SetCount(fields[2].GetUInt32());
uint32 duration = fields[3].GetUInt32();
@@ -658,7 +661,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
if (forplayer)
{
RemoveFromUpdateQueueOf(forplayer);
forplayer->DeleteRefundReference(GetGUIDLow());
forplayer->DeleteRefundReference(GetGUID());
}
delete this;
return;
@@ -690,7 +693,8 @@ void Item::AddToUpdateQueueOf(Player* player)
if (player->GetGUID() != GetOwnerGUID())
{
TC_LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
TC_LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!",
GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
return;
}
@@ -710,7 +714,8 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
if (player->GetGUID() != GetOwnerGUID())
{
TC_LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
TC_LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!",
GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
return;
}
@@ -862,7 +867,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
return true;
}
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/)
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster /*= ObjectGuid::Empty*/)
{
// Better lost small time at check in comparison lost time at item save to DB.
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
@@ -872,7 +877,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
{
if (uint32 oldEnchant = GetEnchantmentId(slot))
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetEntry(), oldEnchant);
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant);
if (id)
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
@@ -1056,8 +1061,8 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
if (!newItem)
return NULL;
newItem->SetUInt32Value(ITEM_FIELD_CREATOR, GetUInt32Value(ITEM_FIELD_CREATOR));
newItem->SetUInt32Value(ITEM_FIELD_GIFTCREATOR, GetUInt32Value(ITEM_FIELD_GIFTCREATOR));
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS) & ~(ITEM_FLAG_REFUNDABLE | ITEM_FLAG_BOP_TRADEABLE));
newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION));
// player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
@@ -1138,7 +1143,7 @@ void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransa
SetPaidExtendedCost(0);
DeleteRefundDataFromDB(trans);
owner->DeleteRefundReference(GetGUIDLow());
owner->DeleteRefundReference(GetGUID());
}
void Item::UpdatePlayedTime(Player* owner)
+4 -4
View File
@@ -224,8 +224,8 @@ class Item : public Object
ItemTemplate const* GetTemplate() const;
uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
ObjectGuid GetOwnerGUID() const { return GetGuidValue(ITEM_FIELD_OWNER); }
void SetOwnerGUID(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
Player* GetOwner()const;
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, val); }
@@ -235,7 +235,7 @@ class Item : public Object
bool IsBindedNotWith(Player const* player) const;
bool IsBoundByEnchant() const;
virtual void SaveToDB(SQLTransaction& trans);
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
virtual bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry);
static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid);
virtual void DeleteFromDB(SQLTransaction& trans);
static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid);
@@ -296,7 +296,7 @@ class Item : public Object
void SetItemRandomProperties(int32 randomPropId);
void UpdateItemSuffixFactor();
static int32 GenerateItemRandomPropertyId(uint32 item_id);
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0);
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster = ObjectGuid::Empty);
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
void ClearEnchantment(EnchantmentSlot slot);
+48 -48
View File
@@ -53,25 +53,6 @@
#include "Battleground.h"
#include "Chat.h"
uint32 GuidHigh2TypeId(uint32 guid_hi)
{
switch (guid_hi)
{
case HIGHGUID_ITEM: return TYPEID_ITEM;
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently
case HIGHGUID_UNIT: return TYPEID_UNIT;
case HIGHGUID_PET: return TYPEID_UNIT;
case HIGHGUID_PLAYER: return TYPEID_PLAYER;
case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT;
case HIGHGUID_DYNAMICOBJECT:return TYPEID_DYNAMICOBJECT;
case HIGHGUID_CORPSE: return TYPEID_CORPSE;
case HIGHGUID_AREATRIGGER: return TYPEID_AREATRIGGER;
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
}
return NUM_CLIENT_OBJECT_TYPES; // unknown
}
Object::Object() : m_PackGUID(sizeof(uint64)+1)
{
m_objectTypeId = TYPEID_OBJECT;
@@ -84,8 +65,6 @@ Object::Object() : m_PackGUID(sizeof(uint64)+1)
m_inWorld = false;
m_objectUpdated = false;
m_PackGUID.appendPackGUID(0);
}
WorldObject::~WorldObject()
@@ -95,8 +74,8 @@ WorldObject::~WorldObject()
{
if (GetTypeId() == TYPEID_CORPSE)
{
TC_LOG_FATAL("misc", "Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!",
GetGUID(), ((Corpse*)this)->GetType(), GetEntry());
TC_LOG_FATAL("misc", "WorldObject::~WorldObject Corpse Type: %d (%s) deleted but still in map!!",
ToCorpse()->GetType(), GetGUID().ToString().c_str());
ASSERT(false);
}
ResetMap();
@@ -107,7 +86,7 @@ Object::~Object()
{
if (IsInWorld())
{
TC_LOG_FATAL("misc", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry());
TC_LOG_FATAL("misc", "Object::~Object %s deleted but still in world!!", GetGUID().ToString().c_str());
if (isType(TYPEMASK_ITEM))
TC_LOG_FATAL("misc", "Item slot %u", ((Item*)this)->GetSlot());
ASSERT(false);
@@ -116,7 +95,7 @@ Object::~Object()
if (m_objectUpdated)
{
TC_LOG_FATAL("misc", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry());
TC_LOG_FATAL("misc", "Object::~Object %s deleted but still in update list!!", GetGUID().ToString().c_str());
ASSERT(false);
sObjectAccessor->RemoveUpdateObject(this);
}
@@ -139,11 +118,10 @@ void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
{
if (!m_uint32Values) _InitValues();
uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh);
SetUInt64Value(OBJECT_FIELD_GUID, guid);
ObjectGuid guid(guidhigh, entry, guidlow);
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetUInt16Value(OBJECT_FIELD_TYPE, 0, m_objectType);
m_PackGUID.clear();
m_PackGUID.appendPackGUID(GetGUID());
m_PackGUID.Set(guid);
}
std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const
@@ -203,14 +181,14 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
case HIGHGUID_VEHICLE:
{
if (TempSummon const* summon = ToUnit()->ToTempSummon())
if (IS_PLAYER_GUID(summon->GetSummonerGUID()))
if (summon->GetSummonerGUID().IsPlayer())
updateType = UPDATETYPE_CREATE_OBJECT2;
break;
}
case HIGHGUID_GAMEOBJECT:
{
if (IS_PLAYER_GUID(ToGameObject()->GetOwnerGUID()))
if (ToGameObject()->GetOwnerGUID().IsPlayer())
updateType = UPDATETYPE_CREATE_OBJECT2;
break;
}
@@ -248,7 +226,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(500);
buf << uint8(updateType);
buf.append(GetPackGUID());
buf << GetPackGUID();
buf << uint8(m_objectTypeId);
BuildMovementUpdate(&buf, flags);
@@ -272,7 +250,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(500);
buf << uint8(UPDATETYPE_VALUES);
buf.append(GetPackGUID());
buf << GetPackGUID();
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target);
@@ -347,6 +325,12 @@ uint16 Object::GetUInt16Value(uint16 index, uint8 offset) const
return *(((uint16*)&m_uint32Values[index])+offset);
}
ObjectGuid Object::GetGuidValue(uint16 index) const
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
return *((ObjectGuid*)&(m_uint32Values[index]));
}
void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
{
Unit const* self = NULL;
@@ -861,13 +845,12 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
}
}
bool Object::AddUInt64Value(uint16 index, uint64 value)
bool Object::AddGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (value && !*((uint64*)&(m_uint32Values[index])))
if (value && !*((ObjectGuid*)&(m_uint32Values[index])))
{
m_uint32Values[index] = PAIR64_LOPART(value);
m_uint32Values[index + 1] = PAIR64_HIPART(value);
*((ObjectGuid*)&(m_uint32Values[index])) = value;
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
@@ -883,10 +866,10 @@ bool Object::AddUInt64Value(uint16 index, uint64 value)
return false;
}
bool Object::RemoveUInt64Value(uint16 index, uint64 value)
bool Object::RemoveGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (value && *((uint64*)&(m_uint32Values[index])) == value)
if (value && *((ObjectGuid*)&(m_uint32Values[index])) == value)
{
m_uint32Values[index] = 0;
m_uint32Values[index + 1] = 0;
@@ -970,6 +953,23 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
}
}
void Object::SetGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (*((ObjectGuid*)&(m_uint32Values[index])) != value)
{
*((ObjectGuid*)&(m_uint32Values[index])) = value;
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
}
}
void Object::SetStatFloatValue(uint16 index, float value)
{
if (value < 0)
@@ -1246,7 +1246,7 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
void MovementInfo::OutDebug()
{
TC_LOG_INFO("misc", "MOVEMENT INFO");
TC_LOG_INFO("misc", "guid " UI64FMTD, guid);
TC_LOG_INFO("misc", "%s", guid.ToString().c_str());
TC_LOG_INFO("misc", "flags %s (%u)", Movement::MovementFlags_ToString(flags).c_str(), flags);
TC_LOG_INFO("misc", "flags2 %s (%u)", Movement::MovementFlagsExtra_ToString(flags2).c_str(), flags2);
TC_LOG_INFO("misc", "time %u current time %u", time, getMSTime());
@@ -1254,7 +1254,7 @@ void MovementInfo::OutDebug()
if (transport.guid)
{
TC_LOG_INFO("misc", "TRANSPORT:");
TC_LOG_INFO("misc", "guid: " UI64FMTD, transport.guid);
TC_LOG_INFO("misc", "%s", transport.guid.ToString().c_str());
TC_LOG_INFO("misc", "position: `%s`", transport.pos.ToString().c_str());
TC_LOG_INFO("misc", "seat: %i", transport.seat);
TC_LOG_INFO("misc", "time: %u", transport.time);
@@ -2079,7 +2079,7 @@ void WorldObject::SendMessageToSet(WorldPacket* data, Player const* skipped_rcvr
VisitNearbyWorldObject(GetVisibilityRange(), notifier);
}
void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid)
{
WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8);
data << uint64(guid);
@@ -2811,7 +2811,7 @@ struct WorldObjectChangeAccumulator
{
UpdateDataMapType& i_updateDatas;
WorldObject& i_object;
std::set<uint64> plr_list;
GuidSet plr_list;
WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) { }
void Visit(PlayerMapType &m)
{
@@ -2852,13 +2852,13 @@ struct WorldObjectChangeAccumulator
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
source = iter->GetSource();
uint64 guid = source->GetCasterGUID();
ObjectGuid guid = source->GetCasterGUID();
if (IS_PLAYER_GUID(guid))
if (guid.IsPlayer())
{
//Caster may be NULL if DynObj is in removelist
if (Player* caster = ObjectAccessor::FindPlayer(guid))
if (caster->GetUInt64Value(PLAYER_FARSIGHT) == source->GetGUID())
if (caster->GetGuidValue(PLAYER_FARSIGHT) == source->GetGUID())
BuildPacket(caster);
}
}
@@ -2891,9 +2891,9 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
ClearUpdateMask(false);
}
uint64 WorldObject::GetTransGUID() const
ObjectGuid WorldObject::GetTransGUID() const
{
if (GetTransport())
return GetTransport()->GetGUID();
return 0;
return ObjectGuid::Empty;
}
+16 -101
View File
@@ -46,37 +46,6 @@
#define NOMINAL_MELEE_RANGE 5.0f
#define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players
enum TypeMask
{
TYPEMASK_OBJECT = 0x0001,
TYPEMASK_ITEM = 0x0002,
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
TYPEMASK_UNIT = 0x0008, // creature
TYPEMASK_PLAYER = 0x0010,
TYPEMASK_GAMEOBJECT = 0x0020,
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_AREATRIGGER = 0x0100,
TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum TypeID
{
TYPEID_OBJECT = 0,
TYPEID_ITEM = 1,
TYPEID_CONTAINER = 2,
TYPEID_UNIT = 3,
TYPEID_PLAYER = 4,
TYPEID_GAMEOBJECT = 5,
TYPEID_DYNAMICOBJECT = 6,
TYPEID_CORPSE = 7,
TYPEID_AREATRIGGER = 8
};
#define NUM_CLIENT_OBJECT_TYPES 9
uint32 GuidHigh2TypeId(uint32 guid_hi);
enum TempSummonType
{
TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears
@@ -120,62 +89,6 @@ class ZoneScript;
typedef std::unordered_map<Player*, UpdateData> UpdateDataMapType;
//! Structure to ease conversions from single 64 bit integer guid into individual bytes, for packet sending purposes
//! Nuke this out when porting ObjectGuid from MaNGOS, but preserve the per-byte storage
struct ObjectGuid
{
public:
ObjectGuid() { _data.u64 = UI64LIT(0); }
ObjectGuid(uint64 guid) { _data.u64 = guid; }
ObjectGuid(ObjectGuid const& other) { _data.u64 = other._data.u64; }
uint8& operator[](uint32 index)
{
ASSERT(index < sizeof(uint64));
#if TRINITY_ENDIAN == TRINITY_LITTLEENDIAN
return _data.byte[index];
#else
return _data.byte[7 - index];
#endif
}
uint8 const& operator[](uint32 index) const
{
ASSERT(index < sizeof(uint64));
#if TRINITY_ENDIAN == TRINITY_LITTLEENDIAN
return _data.byte[index];
#else
return _data.byte[7 - index];
#endif
}
operator uint64()
{
return _data.u64;
}
ObjectGuid& operator=(uint64 guid)
{
_data.u64 = guid;
return *this;
}
ObjectGuid& operator=(ObjectGuid const& other)
{
_data.u64 = other._data.u64;
return *this;
}
private:
union
{
uint64 u64;
uint8 byte[8];
} _data;
};
class Object
{
public:
@@ -186,11 +99,11 @@ class Object
virtual void AddToWorld();
virtual void RemoveFromWorld();
uint64 GetGUID() const { return GetUInt64Value(0); }
uint32 GetGUIDLow() const { return GUID_LOPART(GetUInt64Value(0)); }
uint32 GetGUIDMid() const { return GUID_ENPART(GetUInt64Value(0)); }
uint32 GetGUIDHigh() const { return GUID_HIPART(GetUInt64Value(0)); }
const ByteBuffer& GetPackGUID() const { return m_PackGUID; }
ObjectGuid GetGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); }
uint32 GetGUIDLow() const { return GetGuidValue(OBJECT_FIELD_GUID).GetCounter(); }
uint32 GetGUIDMid() const { return GetGuidValue(OBJECT_FIELD_GUID).GetEntry(); }
uint32 GetGUIDHigh() const { return GetGuidValue(OBJECT_FIELD_GUID).GetHigh(); }
PackedGuid const& GetPackGUID() const { return m_PackGUID; }
uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); }
@@ -214,6 +127,7 @@ class Object
float GetFloatValue(uint16 index) const;
uint8 GetByteValue(uint16 index, uint8 offset) const;
uint16 GetUInt16Value(uint16 index, uint8 offset) const;
ObjectGuid GetGuidValue(uint16 index) const;
void SetInt32Value(uint16 index, int32 value);
void SetUInt32Value(uint16 index, uint32 value);
@@ -223,11 +137,12 @@ class Object
void SetByteValue(uint16 index, uint8 offset, uint8 value);
void SetUInt16Value(uint16 index, uint8 offset, uint16 value);
void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); }
void SetGuidValue(uint16 index, ObjectGuid value);
void SetStatFloatValue(uint16 index, float value);
void SetStatInt32Value(uint16 index, int32 value);
bool AddUInt64Value(uint16 index, uint64 value);
bool RemoveUInt64Value(uint16 index, uint64 value);
bool AddGuidValue(uint16 index, ObjectGuid value);
bool RemoveGuidValue(uint16 index, ObjectGuid value);
void ApplyModUInt32Value(uint16 index, int32 val, bool apply);
void ApplyModInt32Value(uint16 index, int32 val, bool apply);
@@ -325,7 +240,7 @@ class Object
private:
bool m_inWorld;
ByteBuffer m_PackGUID;
PackedGuid m_PackGUID;
// for output helpfull error messages from asserts
bool PrintIndexError(uint32 index, bool set) const;
@@ -470,7 +385,7 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
struct MovementInfo
{
// common
uint64 guid;
ObjectGuid guid;
uint32 flags;
uint16 flags2;
Position pos;
@@ -481,7 +396,7 @@ struct MovementInfo
{
void Reset()
{
guid = 0;
guid.Clear();
pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
seat = -1;
time = 0;
@@ -489,7 +404,7 @@ struct MovementInfo
time3 = 0;
}
uint64 guid;
ObjectGuid guid;
Position pos;
int8 seat;
uint32 time;
@@ -519,7 +434,7 @@ struct MovementInfo
float splineElevation;
MovementInfo() :
guid(0), flags(0), flags2(0), time(0), pitch(0.0f), splineElevation(0.0f)
flags(0), flags2(0), time(0), pitch(0.0f), splineElevation(0.0f)
{
pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
transport.Reset();
@@ -734,7 +649,7 @@ class WorldObject : public Object, public WorldLocation
void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
void PlayDirectSound(uint32 sound_id, Player* target = NULL);
void SendObjectDeSpawnAnim(uint64 guid);
void SendObjectDeSpawnAnim(ObjectGuid guid);
virtual void SaveRespawnTime() { }
void AddObjectToRemoveList();
@@ -818,7 +733,7 @@ class WorldObject : public Object, public WorldLocation
float GetTransOffsetO() const { return m_movementInfo.transport.pos.GetOrientation(); }
uint32 GetTransTime() const { return m_movementInfo.transport.time; }
int8 GetTransSeat() const { return m_movementInfo.transport.seat; }
virtual uint64 GetTransGUID() const;
virtual ObjectGuid GetTransGUID() const;
void SetTransport(Transport* t) { m_transport = t; }
MovementInfo m_movementInfo;
+1 -204
View File
@@ -20,25 +20,7 @@
#define TRINITY_OBJECTDEFINES_H
#include "Define.h"
enum HighGuid
{
HIGHGUID_ITEM = 0x400, // blizz 4000
HIGHGUID_CONTAINER = 0x400, // blizz 4000
HIGHGUID_PLAYER = 0x000, // blizz 0000
HIGHGUID_GAMEOBJECT = 0xF11, // blizz F110
HIGHGUID_TRANSPORT = 0xF12, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
HIGHGUID_UNIT = 0xF13, // blizz F130
HIGHGUID_PET = 0xF14, // blizz F140
HIGHGUID_VEHICLE = 0xF15, // blizz F550
HIGHGUID_DYNAMICOBJECT = 0xF10, // blizz F100
HIGHGUID_CORPSE = 0xF101, // blizz F100
HIGHGUID_AREATRIGGER = 0xF102, // blizz F100
HIGHGUID_BATTLEGROUND = 0x1F1, // new 4.x
HIGHGUID_MO_TRANSPORT = 0x1FC, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
HIGHGUID_GROUP = 0x1F5,
HIGHGUID_GUILD = 0x1FF // new 4.x
};
#include "ObjectGuid.h"
// used for creating values for respawn for example
inline uint64 MAKE_PAIR64(uint32 l, uint32 h);
@@ -49,37 +31,6 @@ inline uint32 MAKE_PAIR32(uint16 l, uint16 h);
inline uint16 PAIR32_HIPART(uint32 x);
inline uint16 PAIR32_LOPART(uint32 x);
inline bool IS_EMPTY_GUID(uint64 guid);
inline bool IS_CREATURE_GUID(uint64 guid);
inline bool IS_PET_GUID(uint64 guid);
inline bool IS_VEHICLE_GUID(uint64 guid);
inline bool IS_CRE_OR_VEH_GUID(uint64 guid);
inline bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid);
inline bool IS_PLAYER_GUID(uint64 guid);
inline bool IS_GUILD_GUID(uint64 guid);
inline bool IS_UNIT_GUID(uint64 guid);
inline bool IS_ITEM_GUID(uint64 guid);
inline bool IS_GAMEOBJECT_GUID(uint64 guid);
inline bool IS_DYNAMICOBJECT_GUID(uint64 guid);
inline bool IS_CORPSE_GUID(uint64 guid);
inline bool IS_TRANSPORT_GUID(uint64 guid);
inline bool IS_MO_TRANSPORT_GUID(uint64 guid);
inline bool IS_GROUP_GUID(uint64 guid);
inline bool IS_AREATRIGGER_GUID(uint64 guid);
// l - OBJECT_FIELD_GUID
// e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets
// h - OBJECT_FIELD_GUID + 1
inline uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h);
//#define GUID_HIPART(x) (uint32)((uint64(x) >> 52)) & 0x0000FFFF)
inline uint32 GUID_HIPART(uint64 guid);
inline uint32 GUID_ENPART(uint64 x);
inline uint32 GUID_LOPART(uint64 x);
inline bool IsGuidHaveEnPart(uint64 guid);
inline char const* GetLogNameForGuid(uint64 guid);
uint64 MAKE_PAIR64(uint32 l, uint32 h)
{
return uint64(l | (uint64(h) << 32));
@@ -115,158 +66,4 @@ uint16 PAIR32_LOPART(uint32 x)
return (uint16)(x & 0x0000FFFF);
}
bool IS_EMPTY_GUID(uint64 guid)
{
return guid == 0;
}
bool IS_CREATURE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_UNIT;
}
bool IS_PET_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_PET;
}
bool IS_VEHICLE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_VEHICLE;
}
bool IS_CRE_OR_VEH_GUID(uint64 guid)
{
return IS_CREATURE_GUID(guid) || IS_VEHICLE_GUID(guid);
}
bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid)
{
return IS_CRE_OR_VEH_GUID(guid) || IS_PET_GUID(guid);
}
bool IS_PLAYER_GUID(uint64 guid)
{
return guid != 0 && GUID_HIPART(guid) == HIGHGUID_PLAYER;
}
bool IS_GUILD_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_GUILD;
}
bool IS_UNIT_GUID(uint64 guid)
{
return IS_CRE_OR_VEH_OR_PET_GUID(guid) || IS_PLAYER_GUID(guid);
}
bool IS_ITEM_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_ITEM;
}
bool IS_GAMEOBJECT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_GAMEOBJECT;
}
bool IS_DYNAMICOBJECT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_DYNAMICOBJECT;
}
bool IS_CORPSE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_CORPSE;
}
bool IS_TRANSPORT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_TRANSPORT;
}
bool IS_MO_TRANSPORT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_MO_TRANSPORT;
}
bool IS_GROUP_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_GROUP;
}
bool IS_AREATRIGGER_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_AREATRIGGER;
}
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
{
return uint64(uint64(l) | (uint64(e) << 32) | (uint64(h) << ((h == HIGHGUID_CORPSE || h == HIGHGUID_AREATRIGGER) ? 48 : 52)));
}
uint32 GUID_HIPART(uint64 guid)
{
uint32 t = ((uint64(guid) >> 48) & 0x0000FFFF);
return (t == HIGHGUID_CORPSE || t == HIGHGUID_AREATRIGGER) ? t : ((t >> 4) & 0x00000FFF);
}
uint32 GUID_ENPART(uint64 x)
{
return IsGuidHaveEnPart(x)
? ((uint32)((x >> 32) & UI64LIT(0x00000000000FFFFF)))
: 0;
}
uint32 GUID_LOPART(uint64 x)
{
// _GUID_LOPART_3 and _GUID_LOPART_2 were both equal to PAIR64_LOPART
return PAIR64_LOPART(x);
}
bool IsGuidHaveEnPart(uint64 guid)
{
switch (GUID_HIPART(guid))
{
case HIGHGUID_ITEM:
case HIGHGUID_PLAYER:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_CORPSE:
case HIGHGUID_GROUP:
case HIGHGUID_GUILD:
return false;
case HIGHGUID_GAMEOBJECT:
case HIGHGUID_TRANSPORT:
case HIGHGUID_UNIT:
case HIGHGUID_PET:
case HIGHGUID_VEHICLE:
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_AREATRIGGER:
default:
return true;
}
}
char const* GetLogNameForGuid(uint64 guid)
{
switch (GUID_HIPART(guid))
{
case HIGHGUID_ITEM: return "item";
case HIGHGUID_PLAYER: return guid ? "player" : "none";
case HIGHGUID_GAMEOBJECT: return "gameobject";
case HIGHGUID_TRANSPORT: return "transport";
case HIGHGUID_UNIT: return "creature";
case HIGHGUID_PET: return "pet";
case HIGHGUID_VEHICLE: return "vehicle";
case HIGHGUID_DYNAMICOBJECT:return "dynobject";
case HIGHGUID_CORPSE: return "corpse";
case HIGHGUID_MO_TRANSPORT: return "mo_transport";
case HIGHGUID_GROUP: return "group";
case HIGHGUID_GUILD: return "guild";
case HIGHGUID_AREATRIGGER: return "areatrigger";
default:
return "<unknown>";
}
}
#endif
@@ -0,0 +1,111 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 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 "ObjectGuid.h"
#include "World.h"
#include "ObjectMgr.h"
#include <sstream>
#include <iomanip>
ObjectGuid const ObjectGuid::Empty = ObjectGuid();
char const* ObjectGuid::GetTypeName(HighGuid high)
{
switch (high)
{
case HIGHGUID_ITEM: return "Item";
case HIGHGUID_PLAYER: return "Player";
case HIGHGUID_GAMEOBJECT: return "Gameobject";
case HIGHGUID_TRANSPORT: return "Transport";
case HIGHGUID_UNIT: return "Creature";
case HIGHGUID_PET: return "Pet";
case HIGHGUID_VEHICLE: return "Vehicle";
case HIGHGUID_DYNAMICOBJECT: return "DynObject";
case HIGHGUID_CORPSE: return "Corpse";
case HIGHGUID_AREATRIGGER: return "AreaTrigger";
case HIGHGUID_BATTLEGROUND: return "Battleground";
case HIGHGUID_MO_TRANSPORT: return "MoTransport";
case HIGHGUID_INSTANCE: return "InstanceID";
case HIGHGUID_GROUP: return "Group";
case HIGHGUID_GUILD: return "Guild";
default:
return "<unknown>";
}
}
std::string ObjectGuid::ToString() const
{
std::ostringstream str;
str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _data._guid << std::dec;
str << " Type: " << GetTypeName();
if (HasEntry())
str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry() << " ";
str << " Low: " << GetCounter();
return str.str();
}
template<HighGuid high>
uint32 ObjectGuidGenerator<high>::Generate()
{
if (_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1)
{
TC_LOG_ERROR("", "%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high));
World::StopNow(ERROR_EXIT_CODE);
}
return _nextGuid++;
}
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
{
buf << uint64(guid.GetRawValue());
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
{
guid.Set(buf.read<uint64>());
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
{
buf.append(guid._packedGuid);
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
{
buf.readPackGUID(*reinterpret_cast<uint64*>(guid.GuidPtr));
return buf;
}
template uint32 ObjectGuidGenerator<HIGHGUID_ITEM>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_PLAYER>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_GAMEOBJECT>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_TRANSPORT>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_UNIT>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_PET>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_VEHICLE>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_DYNAMICOBJECT>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_CORPSE>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_AREATRIGGER>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_BATTLEGROUND>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_INSTANCE>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_GROUP>::Generate();
template uint32 ObjectGuidGenerator<HIGHGUID_GUILD>::Generate();
@@ -0,0 +1,289 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 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/>.
*/
#ifndef ObjectGuid_h__
#define ObjectGuid_h__
#include "Common.h"
#include "ByteBuffer.h"
#include <functional>
enum TypeID
{
TYPEID_OBJECT = 0,
TYPEID_ITEM = 1,
TYPEID_CONTAINER = 2,
TYPEID_UNIT = 3,
TYPEID_PLAYER = 4,
TYPEID_GAMEOBJECT = 5,
TYPEID_DYNAMICOBJECT = 6,
TYPEID_CORPSE = 7,
TYPEID_AREATRIGGER = 8
};
#define NUM_CLIENT_OBJECT_TYPES 9
enum TypeMask
{
TYPEMASK_OBJECT = 0x0001,
TYPEMASK_ITEM = 0x0002,
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
TYPEMASK_UNIT = 0x0008, // creature
TYPEMASK_PLAYER = 0x0010,
TYPEMASK_GAMEOBJECT = 0x0020,
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_AREATRIGGER = 0x0100,
TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum HighGuid
{
HIGHGUID_ITEM = 0x400, // blizz 4000
HIGHGUID_CONTAINER = 0x400, // blizz 4000
HIGHGUID_PLAYER = 0x000, // blizz 0000
HIGHGUID_GAMEOBJECT = 0xF11, // blizz F110
HIGHGUID_TRANSPORT = 0xF12, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
HIGHGUID_UNIT = 0xF13, // blizz F130
HIGHGUID_PET = 0xF14, // blizz F140
HIGHGUID_VEHICLE = 0xF15, // blizz F550
HIGHGUID_DYNAMICOBJECT = 0xF10, // blizz F100
HIGHGUID_CORPSE = 0xF101, // blizz F100
HIGHGUID_AREATRIGGER = 0xF102,
HIGHGUID_BATTLEGROUND = 0x1F1,
HIGHGUID_MO_TRANSPORT = 0x1FC, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
HIGHGUID_INSTANCE = 0x1F4, // blizz 1F40
HIGHGUID_GROUP = 0x1F5,
HIGHGUID_GUILD = 0x1FF
};
class ObjectGuid;
class PackedGuid;
struct PackedGuidReader
{
explicit PackedGuidReader(ObjectGuid& guid) : GuidPtr(&guid) { }
ObjectGuid* GuidPtr;
};
class ObjectGuid
{
public:
static ObjectGuid const Empty;
ObjectGuid() { _data._guid = UI64LIT(0); }
explicit ObjectGuid(uint64 guid) { _data._guid = guid; }
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) { _data._guid = counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
ObjectGuid(HighGuid hi, uint32 counter) { _data._guid = counter ? uint64(counter) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
operator uint64() const { return _data._guid; }
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
void Set(uint64 guid) { _data._guid = guid; }
void Clear() { _data._guid = 0; }
PackedGuid WriteAsPacked() const;
uint64 GetRawValue() const { return _data._guid; }
HighGuid GetHigh() const
{
uint32 temp = ((uint64(_data._guid) >> 48) & 0x0000FFFF);
return HighGuid((temp == HIGHGUID_CORPSE || temp == HIGHGUID_AREATRIGGER) ? temp : ((temp >> 4) & 0x00000FFF));
}
uint32 GetEntry() const { return HasEntry() ? uint32((_data._guid >> 32) & UI64LIT(0x00000000000FFFFF)) : 0; }
uint32 GetCounter() const
{
return uint32(_data._guid & UI64LIT(0x00000000FFFFFFFF));
}
static uint32 GetMaxCounter(HighGuid /*high*/)
{
return uint32(0xFFFFFFFF);
}
uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
uint8& operator[](uint32 index)
{
ASSERT(index < sizeof(uint64));
return _data._bytes[index];
}
uint8 const& operator[](uint32 index) const
{
ASSERT(index < sizeof(uint64));
return _data._bytes[index];
}
bool IsEmpty() const { return _data._guid == 0; }
bool IsCreature() const { return GetHigh() == HIGHGUID_UNIT; }
bool IsPet() const { return GetHigh() == HIGHGUID_PET; }
bool IsVehicle() const { return GetHigh() == HIGHGUID_VEHICLE; }
bool IsCreatureOrPet() const { return IsCreature() || IsPet(); }
bool IsCreatureOrVehicle() const { return IsCreature() || IsVehicle(); }
bool IsAnyTypeCreature() const { return IsCreature() || IsPet() || IsVehicle(); }
bool IsPlayer() const { return !IsEmpty() && GetHigh() == HIGHGUID_PLAYER; }
bool IsUnit() const { return IsAnyTypeCreature() || IsPlayer(); }
bool IsItem() const { return GetHigh() == HIGHGUID_ITEM; }
bool IsGameObject() const { return GetHigh() == HIGHGUID_GAMEOBJECT; }
bool IsDynamicObject() const { return GetHigh() == HIGHGUID_DYNAMICOBJECT; }
bool IsCorpse() const { return GetHigh() == HIGHGUID_CORPSE; }
bool IsAreaTrigger() const { return GetHigh() == HIGHGUID_AREATRIGGER; }
bool IsBattleground() const { return GetHigh() == HIGHGUID_BATTLEGROUND; }
bool IsTransport() const { return GetHigh() == HIGHGUID_TRANSPORT; }
bool IsMOTransport() const { return GetHigh() == HIGHGUID_MO_TRANSPORT; }
bool IsAnyTypeGameObject() const { return IsGameObject() || IsTransport() || IsMOTransport(); }
bool IsInstance() const { return GetHigh() == HIGHGUID_INSTANCE; }
bool IsGroup() const { return GetHigh() == HIGHGUID_GROUP; }
bool IsGuild() const { return GetHigh() == HIGHGUID_GUILD; }
static TypeID GetTypeId(HighGuid high)
{
switch (high)
{
case HIGHGUID_ITEM: return TYPEID_ITEM;
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER==HIGHGUID_ITEM currently
case HIGHGUID_UNIT: return TYPEID_UNIT;
case HIGHGUID_PET: return TYPEID_UNIT;
case HIGHGUID_PLAYER: return TYPEID_PLAYER;
case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT;
case HIGHGUID_DYNAMICOBJECT: return TYPEID_DYNAMICOBJECT;
case HIGHGUID_CORPSE: return TYPEID_CORPSE;
case HIGHGUID_AREATRIGGER: return TYPEID_AREATRIGGER;
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
case HIGHGUID_VEHICLE: return TYPEID_UNIT;
// unknown
case HIGHGUID_INSTANCE:
case HIGHGUID_BATTLEGROUND:
case HIGHGUID_GROUP:
case HIGHGUID_GUILD:
default: return TYPEID_OBJECT;
}
}
TypeID GetTypeId() const { return GetTypeId(GetHigh()); }
bool operator!() const { return IsEmpty(); }
bool operator== (ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); }
bool operator!= (ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); }
bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
static char const* GetTypeName(HighGuid high);
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
std::string ToString() const;
private:
static bool HasEntry(HighGuid high)
{
switch (high)
{
case HIGHGUID_ITEM:
case HIGHGUID_PLAYER:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_CORPSE:
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_INSTANCE:
case HIGHGUID_GROUP:
return false;
case HIGHGUID_GAMEOBJECT:
case HIGHGUID_TRANSPORT:
case HIGHGUID_UNIT:
case HIGHGUID_PET:
case HIGHGUID_VEHICLE:
default:
return true;
}
}
bool HasEntry() const { return HasEntry(GetHigh()); }
explicit ObjectGuid(uint32 const&) = delete; // no implementation, used to catch wrong type assignment
ObjectGuid(HighGuid, uint32, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
ObjectGuid(HighGuid, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
union
{
uint64 _guid;
uint8 _bytes[sizeof(uint64)];
} _data;
};
// Some Shared defines
typedef std::set<ObjectGuid> GuidSet;
typedef std::list<ObjectGuid> GuidList;
typedef std::deque<ObjectGuid> GuidDeque;
typedef std::vector<ObjectGuid> GuidVector;
// minimum buffer size for packed guid is 9 bytes
#define PACKED_GUID_MIN_BUFFER_SIZE 9
class PackedGuid
{
friend ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
public:
explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(0); }
explicit PackedGuid(uint64 guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid); }
explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
size_t size() const { return _packedGuid.size(); }
private:
ByteBuffer _packedGuid;
};
template<HighGuid high>
class ObjectGuidGenerator
{
public:
explicit ObjectGuidGenerator(uint32 start = 1) : _nextGuid(start) { }
void Set(uint32 val) { _nextGuid = val; }
uint32 Generate();
uint32 GetNextAfterMaxUsed() const { return _nextGuid; }
private:
uint32 _nextGuid;
};
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid);
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid);
inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this); }
namespace std
{
template<>
struct hash<ObjectGuid>
{
public:
size_t operator()(ObjectGuid const& key) const
{
return hash<uint64>()(key.GetRawValue());
}
};
}
#endif // ObjectGuid_h__
Loaded 100 of 597 files, more files were not shown because too many files have changed in this diff. Show more