ariel- committed 2016-01-11 01:50:45 -03:00
1 parent 694c89d76d
commit b3ea9fbbe5
163 files changed
+2448 -2328

No files matched your search

+3 -8
View File
@@ -1417,7 +1417,6 @@ DROP TABLE IF EXISTS `corpse`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `corpse` (
`corpseGuid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
`guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Character Global Unique Identifier',
`posX` float NOT NULL DEFAULT '0',
`posY` float NOT NULL DEFAULT '0',
@@ -1433,10 +1432,9 @@ CREATE TABLE `corpse` (
`time` int(10) unsigned NOT NULL DEFAULT '0',
`corpseType` tinyint(3) unsigned NOT NULL DEFAULT '0',
`instanceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Instance Identifier',
PRIMARY KEY (`corpseGuid`),
PRIMARY KEY (`guid`),
KEY `idx_type` (`corpseType`),
KEY `idx_instance` (`instanceId`),
KEY `idx_player` (`guid`),
KEY `idx_time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Death System';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -1458,12 +1456,9 @@ DROP TABLE IF EXISTS `corpse_phases`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `corpse_phases` (
`Guid` int(10) unsigned NOT NULL,
`OwnerGuid` int(10) unsigned NOT NULL DEFAULT '0',
`PhaseId` int(10) unsigned NOT NULL,
`OwnerGuid` int(10) unsigned NOT NULL,
`Time` int(10) unsigned NOT NULL DEFAULT '0',
`CorpseType` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`Guid`,`PhaseId`)
PRIMARY KEY (`OwnerGuid`,`PhaseId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Grid Loading System';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -0,0 +1,18 @@
-- Keep only the highest guid PvE or PvP (not bones) corpse per player guid
DELETE c FROM `corpse` c LEFT JOIN
(
SELECT MAX(`guid`) AS id
FROM `corpse`
WHERE `corpseType` IN (1,2)
GROUP BY `guid`
) corpsetemp
ON c.`guid` = corpsetemp.`id`
WHERE corpsetemp.`id` IS NULL;
ALTER TABLE `corpse_phases`
DROP PRIMARY KEY,
DROP `Guid`,
DROP `CorpseType`,
DROP `Time`,
CHANGE `OwnerGuid` `OwnerGuid` int(10) unsigned NOT NULL DEFAULT '0' FIRST,
ADD PRIMARY KEY (`OwnerGuid`, `PhaseId`);
@@ -0,0 +1,3 @@
UPDATE `trinity_string`
SET `content_default` = 'Object GUID is: %s'
WHERE `entry`=201;
@@ -333,16 +333,13 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_PLAYER_HOMEBIND, "DELETE FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC);
// Corpse
PrepareStatement(CHAR_SEL_CORPSES, "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, corpseGuid, guid FROM corpse WHERE corpseType <> 0", CONNECTION_SYNCH);
PrepareStatement(CHAR_INS_CORPSE, "INSERT INTO corpse (corpseGuid, guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CORPSE, "DELETE FROM corpse WHERE corpseGuid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PLAYER_CORPSES, "DELETE FROM corpse WHERE guid = ? AND corpseType <> 0", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_OLD_CORPSES, "DELETE FROM corpse WHERE corpseType = 0 OR time < (UNIX_TIMESTAMP(NOW()) - ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CORPSE_PHASES, "SELECT Guid, PhaseId FROM corpse_phases", CONNECTION_SYNCH);
PrepareStatement(CHAR_DEL_CORPSE_PHASES, "DELETE FROM corpse_phases WHERE Guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PLAYER_CORPSES_PHASES, "DELETE FROM corpse_phases WHERE OwnerGuid = ? AND CorpseType <> 0", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_OLD_CORPSE_PHASES, "DELETE FROM corpse_phases WHERE CorpseType = 0 OR Time < (UNIX_TIMESTAMP(NOW()) - ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_CORPSE_PHASES, "INSERT INTO corpse_phases (Guid, PhaseId, OwnerGuid, Time, CorpseType) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CORPSES, "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_INS_CORPSE, "INSERT INTO corpse (guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CORPSE, "DELETE FROM corpse WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CORPSES_FROM_MAP, "DELETE cp, c FROM corpse_phases cp INNER JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CORPSE_PHASES, "SELECT cp.OwnerGuid, cp.PhaseId FROM corpse_phases cp LEFT JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_INS_CORPSE_PHASES, "INSERT INTO corpse_phases (OwnerGuid, PhaseId) VALUES (?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CORPSE_PHASES, "DELETE FROM corpse_phases WHERE OwnerGuid = ?", CONNECTION_ASYNC);
// Creature respawn
PrepareStatement(CHAR_SEL_CREATURE_RESPAWNS, "SELECT guid, respawnTime FROM creature_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH);
@@ -296,13 +296,10 @@ enum CharacterDatabaseStatements
CHAR_SEL_CORPSES,
CHAR_INS_CORPSE,
CHAR_DEL_CORPSE,
CHAR_DEL_PLAYER_CORPSES,
CHAR_DEL_OLD_CORPSES,
CHAR_DEL_CORPSES_FROM_MAP,
CHAR_SEL_CORPSE_PHASES,
CHAR_DEL_CORPSE_PHASES,
CHAR_DEL_PLAYER_CORPSES_PHASES,
CHAR_DEL_OLD_CORPSE_PHASES,
CHAR_INS_CORPSE_PHASES,
CHAR_DEL_CORPSE_PHASES,
CHAR_SEL_CREATURE_RESPAWNS,
CHAR_REP_CREATURE_RESPAWN,
+5 -5
View File
@@ -55,7 +55,7 @@ void PetAI::_stopAttack()
{
if (!me->IsAlive())
{
TC_LOG_DEBUG("misc", "Creature stoped attacking cuz his dead [guid=%u]", me->GetGUIDLow());
TC_LOG_DEBUG("misc", "Creature stoped attacking cuz his dead [guid=%u]", me->GetGUID().GetCounter());
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveIdle();
me->CombatStop();
@@ -97,7 +97,7 @@ void PetAI::UpdateAI(uint32 diff)
if (_needToStop())
{
TC_LOG_DEBUG("misc", "Pet AI stopped attacking [guid=%u]", me->GetGUIDLow());
TC_LOG_DEBUG("misc", "Pet AI stopped attacking [guid=%u]", me->GetGUID().GetCounter());
_stopAttack();
return;
}
@@ -439,7 +439,7 @@ void PetAI::HandleReturnMovement()
ClearCharmInfoFlags();
me->GetCharmInfo()->SetIsReturning(true);
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MovePoint(me->GetGUIDLow(), x, y, z);
me->GetMotionMaster()->MovePoint(me->GetGUID().GetCounter(), x, y, z);
}
}
else // COMMAND_FOLLOW
@@ -492,7 +492,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data)
{
// Pet is returning to where stay was clicked. data should be
// pet's GUIDLow since we set that as the waypoint ID
if (data == me->GetGUIDLow() && me->GetCharmInfo()->IsReturning())
if (data == me->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning())
{
ClearCharmInfoFlags();
me->GetCharmInfo()->SetIsAtStay(true);
@@ -505,7 +505,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data)
{
// If data is owner's GUIDLow then we've reached follow point,
// otherwise we're probably chasing a creature
if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUIDLow() && me->GetCharmInfo()->IsReturning())
if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning())
{
ClearCharmInfoFlags();
me->GetCharmInfo()->SetIsFollowing(true);
+2 -2
View File
@@ -94,7 +94,7 @@ namespace FactorySelector
// select NullCreatureAI if not another cases
ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key();
TC_LOG_DEBUG("scripts", "Creature %s (Entry: %u GUID: %u DB GUID: %u) is using AI type: %s.", creature->GetName().c_str(), creature->GetEntry(), creature->GetGUIDLow(), creature->GetDBTableGUIDLow(), ainame.c_str());
TC_LOG_DEBUG("scripts", "Creature %s (Entry: %u GUID: %u DB GUID: %u) is using AI type: %s.", creature->GetName().c_str(), creature->GetEntry(), creature->GetGUID().GetCounter(), creature->GetSpawnId(), ainame.c_str());
return (ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature));
}
@@ -141,7 +141,7 @@ namespace FactorySelector
std::string ainame = (ai_factory == NULL || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key();
TC_LOG_DEBUG("scripts", "GameObject %u used AI is %s.", go->GetGUIDLow(), ainame.c_str());
TC_LOG_DEBUG("scripts", "GameObject %u used AI is %s.", go->GetGUID().GetCounter(), ainame.c_str());
return (ai_factory == NULL ? new NullGameObjectAI(go) : ai_factory->Create(go));
}
@@ -168,7 +168,7 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* source, uint32 soundId)
if (!sSoundEntriesStore.LookupEntry(soundId))
{
TC_LOG_ERROR("scripts", "Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", soundId, source->GetTypeId(), source->GetGUIDLow());
TC_LOG_ERROR("scripts", "Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", soundId, source->GetTypeId(), source->GetGUID().GetCounter());
return;
}
+84 -77
View File
@@ -39,9 +39,9 @@
SmartScript::SmartScript()
{
go = NULL;
me = NULL;
trigger = NULL;
go = nullptr;
me = nullptr;
trigger = nullptr;
mEventPhase = 0;
mPathId = 0;
mTargetStorage = new ObjectListMap();
@@ -114,7 +114,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
mLastInvoker = unit->GetGUID();
if (Unit* tempInvoker = GetLastInvoker())
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName().c_str(), tempInvoker->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName().c_str(), tempInvoker->GetGUID().GetCounter());
switch (e.GetActionType())
{
@@ -122,8 +122,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
ObjectList* targets = GetTargets(e, unit);
Creature* talker = me;
Player* targetPlayer = NULL;
Unit* talkTarget = NULL;
Player* targetPlayer = nullptr;
Unit* talkTarget = nullptr;
if (targets)
{
@@ -162,7 +162,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
mUseTextTimer = true;
sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), talkTarget);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textGuid: %u",
talker->GetName().c_str(), talker->GetGUIDLow(), talkTarget ? talkTarget->GetGUIDLow() : 0);
talker->GetName().c_str(), talker->GetGUID().GetCounter(), talkTarget ? talkTarget->GetGUID().GetCounter() : 0);
break;
}
case SMART_ACTION_SIMPLE_TALK:
@@ -180,7 +180,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, (*itr)->ToPlayer());
}
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (GuidLow: %u), textGroupId: %u",
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID));
(*itr)->GetName().c_str(), (*itr)->GetGUID().GetCounter(), uint8(e.action.talk.textGroupID));
}
delete targets;
@@ -198,7 +198,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (GuidLow: %u), emote: %u",
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.emote.emote);
(*itr)->GetName().c_str(), (*itr)->GetGUID().GetCounter(), e.action.emote.emote);
}
}
@@ -217,7 +217,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? (*itr)->ToPlayer() : nullptr);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u",
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.onlySelf);
(*itr)->GetName().c_str(), (*itr)->GetGUID().GetCounter(), e.action.sound.sound, e.action.sound.onlySelf);
}
}
@@ -238,7 +238,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToCreature()->setFaction(e.action.faction.factionID);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, GuidLow %u set faction to %u",
(*itr)->GetEntry(), (*itr)->GetGUIDLow(), e.action.faction.factionID);
(*itr)->GetEntry(), (*itr)->GetGUID().GetCounter(), e.action.faction.factionID);
}
else
{
@@ -248,7 +248,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToCreature()->setFaction(ci->faction);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry %u, GuidLow %u set faction to %u",
(*itr)->GetEntry(), (*itr)->GetGUIDLow(), ci->faction);
(*itr)->GetEntry(), (*itr)->GetGUID().GetCounter(), ci->faction);
}
}
}
@@ -280,7 +280,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
uint32 displayId = ObjectMgr::ChooseDisplayId(ci);
(*itr)->ToCreature()->SetDisplayId(displayId);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u set displayid to %u",
(*itr)->GetEntry(), (*itr)->GetGUIDLow(), displayId);
(*itr)->GetEntry(), (*itr)->GetGUID().GetCounter(), displayId);
}
}
//if no param1, then use value from param2 (modelId)
@@ -288,14 +288,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u set displayid to %u",
(*itr)->GetEntry(), (*itr)->GetGUIDLow(), e.action.morphOrMount.model);
(*itr)->GetEntry(), (*itr)->GetGUID().GetCounter(), e.action.morphOrMount.model);
}
}
else
{
(*itr)->ToCreature()->DeMorph();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u demorphs.",
(*itr)->GetEntry(), (*itr)->GetGUIDLow());
(*itr)->GetEntry(), (*itr)->GetGUID().GetCounter());
}
}
@@ -314,7 +314,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToPlayer()->FailQuest(e.action.quest.quest);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow %u fails quest %u",
(*itr)->GetGUIDLow(), e.action.quest.quest);
(*itr)->GetGUID().GetCounter(), e.action.quest.quest);
}
}
@@ -333,9 +333,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest))
{
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, NULL);
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u",
(*itr)->GetGUIDLow(), e.action.quest.quest);
(*itr)->GetGUID().GetCounter(), e.action.quest.quest);
}
}
}
@@ -397,7 +397,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
uint32 emote = temp[urand(0, count - 1)];
(*itr)->ToUnit()->HandleEmoteCommand(emote);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow %u handle random emote %u",
(*itr)->GetGUIDLow(), emote);
(*itr)->GetGUID().GetCounter(), emote);
}
}
@@ -416,7 +416,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
me->getThreatManager().modifyThreatPercent(target, e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature guidLow %u modify threat for unit %u, value %i",
me->GetGUIDLow(), target->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
me->GetGUID().GetCounter(), target->GetGUID().GetCounter(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
}
}
break;
@@ -436,7 +436,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
me->getThreatManager().modifyThreatPercent((*itr)->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow %u modify threat for unit %u, value %i",
me->GetGUIDLow(), (*itr)->GetGUIDLow(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
me->GetGUID().GetCounter(), (*itr)->GetGUID().GetCounter(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
}
}
@@ -463,7 +463,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
(*itr)->ToPlayer()->GroupEventHappens(e.action.quest.quest, me);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow %u credited quest %u",
(*itr)->GetGUIDLow(), e.action.quest.quest);
(*itr)->GetGUID().GetCounter(), e.action.quest.quest);
}
}
@@ -512,7 +512,7 @@ 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",
(me ? me->GetGUID() : go->GetGUID()).GetTypeName(), me ? me->GetGUIDLow() : go->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
(me ? me->GetGUID() : go->GetGUID()).GetTypeName(), me ? me->GetGUID().GetCounter() : go->GetGUID().GetCounter(), e.action.cast.spell, (*itr)->GetGUID().GetCounter(), 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 (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str());
@@ -543,7 +543,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
tempLastInvoker->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) != 0);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker %u casts spell %u on target %u with castflags %u",
tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
tempLastInvoker->GetGUID().GetCounter(), e.action.cast.spell, (*itr)->GetGUID().GetCounter(), 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 (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str());
@@ -564,7 +564,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToUnit()->AddAura(e.action.cast.spell, (*itr)->ToUnit());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura %u to unit %u",
e.action.cast.spell, (*itr)->GetGUIDLow());
e.action.cast.spell, (*itr)->GetGUID().GetCounter());
}
}
@@ -585,7 +585,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
(*itr)->ToGameObject()->SetLootState(GO_READY);
(*itr)->ToGameObject()->UseDoorOrButton(0, false, unit);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject %u (entry: %u) activated",
(*itr)->GetGUIDLow(), (*itr)->GetEntry());
(*itr)->GetGUID().GetCounter(), (*itr)->GetEntry());
}
}
@@ -604,7 +604,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToGameObject()->ResetDoorOrButton();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject %u (entry: %u) reset",
(*itr)->GetGUIDLow(), (*itr)->GetEntry());
(*itr)->GetGUID().GetCounter(), (*itr)->GetEntry());
}
}
@@ -623,7 +623,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit %u set emotestate to %u",
(*itr)->GetGUIDLow(), e.action.emote.emote);
(*itr)->GetGUID().GetCounter(), e.action.emote.emote);
}
}
@@ -644,13 +644,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS",
(*itr)->GetGUIDLow(), e.action.unitFlag.flag);
(*itr)->GetGUID().GetCounter(), e.action.unitFlag.flag);
}
else
{
(*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS_2",
(*itr)->GetGUIDLow(), e.action.unitFlag.flag);
(*itr)->GetGUID().GetCounter(), e.action.unitFlag.flag);
}
}
}
@@ -672,13 +672,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS",
(*itr)->GetGUIDLow(), e.action.unitFlag.flag);
(*itr)->GetGUID().GetCounter(), e.action.unitFlag.flag);
}
else
{
(*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS_2",
(*itr)->GetGUIDLow(), e.action.unitFlag.flag);
(*itr)->GetGUID().GetCounter(), e.action.unitFlag.flag);
}
}
}
@@ -693,7 +693,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ENSURE_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack != 0);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: %u bool on = %u",
me->GetGUIDLow(), e.action.autoAttack.attack);
me->GetGUID().GetCounter(), e.action.autoAttack.attack);
break;
}
case SMART_ACTION_ALLOW_COMBAT_MOVEMENT:
@@ -704,7 +704,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
bool move = e.action.combatMove.move != 0;
ENSURE_AI(SmartAI, me->AI())->SetCombatMove(move);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature %u bool on = %u",
me->GetGUIDLow(), e.action.combatMove.move);
me->GetGUID().GetCounter(), e.action.combatMove.move);
break;
}
case SMART_ACTION_SET_EVENT_PHASE:
@@ -714,7 +714,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
SetPhase(e.action.setEventPhase.phase);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature %u set event phase %u",
GetBaseObject()->GetGUIDLow(), e.action.setEventPhase.phase);
GetBaseObject()->GetGUID().GetCounter(), e.action.setEventPhase.phase);
break;
}
case SMART_ACTION_INC_EVENT_PHASE:
@@ -725,7 +725,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
IncPhase(e.action.incEventPhase.inc);
DecPhase(e.action.incEventPhase.dec);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature %u inc event phase by %u, "
"decrease by %u", GetBaseObject()->GetGUIDLow(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
"decrease by %u", GetBaseObject()->GetGUID().GetCounter(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
break;
}
case SMART_ACTION_EVADE:
@@ -734,7 +734,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
me->AI()->EnterEvadeMode();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature %u EnterEvadeMode", me->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature %u EnterEvadeMode", me->GetGUID().GetCounter());
break;
}
case SMART_ACTION_FLEE_FOR_ASSIST:
@@ -748,7 +748,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
Trinity::BroadcastTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, BROADCAST_TEXT_FLEE_FOR_ASSIST);
sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
}
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUID().GetCounter());
break;
}
case SMART_ACTION_CALL_GROUPEVENTHAPPENS:
@@ -760,7 +760,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
unit->ToPlayer()->GroupEventHappens(e.action.quest.quest, GetBaseObject());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %u, group credit for quest %u",
unit->GetGUIDLow(), e.action.quest.quest);
unit->GetGUID().GetCounter(), e.action.quest.quest);
}
// Special handling for vehicles
@@ -804,7 +804,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
(*itr)->ToUnit()->RemoveAllAuras();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit %u, spell %u",
(*itr)->GetGUIDLow(), e.action.removeAura.spell);
(*itr)->GetGUID().GetCounter(), e.action.removeAura.spell);
}
delete targets;
@@ -828,7 +828,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
ENSURE_AI(SmartAI, me->AI())->SetFollow((*itr)->ToUnit(), (float)e.action.follow.dist, (float)e.action.follow.angle, e.action.follow.credit, e.action.follow.entry, e.action.follow.creditType);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature %u following target %u",
me->GetGUIDLow(), (*itr)->GetGUIDLow());
me->GetGUID().GetCounter(), (*itr)->GetGUID().GetCounter());
break;
}
}
@@ -865,7 +865,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
uint32 phase = temp[urand(0, count - 1)];
SetPhase(phase);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature %u sets event phase to %u",
GetBaseObject()->GetGUIDLow(), phase);
GetBaseObject()->GetGUID().GetCounter(), phase);
break;
}
case SMART_ACTION_RANDOM_PHASE_RANGE:
@@ -876,7 +876,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
uint32 phase = urand(e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax);
SetPhase(phase);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature %u sets event phase to %u",
GetBaseObject()->GetGUIDLow(), phase);
GetBaseObject()->GetGUID().GetCounter(), phase);
break;
}
case SMART_ACTION_CALL_KILLEDMONSTER:
@@ -890,7 +890,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u",
player->GetGUIDLow(), e.action.killedMonster.creature);
player->GetGUID().GetCounter(), e.action.killedMonster.creature);
}
}
else // Specific target type
@@ -905,7 +905,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
(*itr)->ToPlayer()->KilledMonsterCredit(e.action.killedMonster.creature);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u",
(*itr)->GetGUIDLow(), e.action.killedMonster.creature);
(*itr)->GetGUID().GetCounter(), e.action.killedMonster.creature);
}
else if (IsUnit(*itr)) // Special handling for vehicles
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
@@ -985,7 +985,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (me && !me->isDead())
{
me->Kill(me);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature %u", me->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature %u", me->GetGUID().GetCounter());
}
break;
}
@@ -994,7 +994,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (me)
{
me->SetInCombatWithZone();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature %u", me->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature %u", me->GetGUID().GetCounter());
}
break;
}
@@ -1008,7 +1008,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
Trinity::BroadcastTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, BROADCAST_TEXT_CALL_FOR_HELP);
sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
}
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature %u", me->GetGUIDLow());
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature %u", me->GetGUID().GetCounter());
}
break;
}
@@ -1018,7 +1018,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
me->SetSheath(SheathState(e.action.setSheath.sheath));
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature %u, State: %u",
me->GetGUIDLow(), e.action.setSheath.sheath);
me->GetGUID().GetCounter(), e.action.setSheath.sheath);
}
break;
}
@@ -1461,7 +1461,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
WorldObject* target = NULL;
WorldObject* target = nullptr;
if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID ||
e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE ||
@@ -1595,7 +1595,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
}
case SMART_ACTION_TRIGGER_TIMED_EVENT:
ProcessEventsFor((SMART_EVENT)SMART_EVENT_TIMED_EVENT_TRIGGERED, NULL, e.action.timeEvent.id);
ProcessEventsFor((SMART_EVENT)SMART_EVENT_TIMED_EVENT_TRIGGERED, nullptr, e.action.timeEvent.id);
break;
case SMART_ACTION_REMOVE_TIMED_EVENT:
mRemIDs.push_back(e.action.timeEvent.id);
@@ -1614,7 +1614,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
meOrigGUID = me->GetGUID();
if (!goOrigGUID && go)
goOrigGUID = go->GetGUID();
go = NULL;
go = nullptr;
me = (*itr)->ToCreature();
break;
}
@@ -1625,7 +1625,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!goOrigGUID && go)
goOrigGUID = go->GetGUID();
go = (*itr)->ToGameObject();
me = NULL;
me = nullptr;
break;
}
}
@@ -2259,7 +2259,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
waypoints[4] = e.action.closestWaypointFromList.wp5;
waypoints[5] = e.action.closestWaypointFromList.wp6;
float distanceToClosest = std::numeric_limits<float>::max();
WayPoint* closestWp = NULL;
WayPoint* closestWp = nullptr;
ObjectList* targets = GetTargets(e, unit);
if (targets)
@@ -2442,9 +2442,9 @@ SmartScriptHolder SmartScript::CreateEvent(SMART_EVENT e, uint32 event_flags, ui
return script;
}
ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*= NULL*/)
ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*= nullptr*/)
{
Unit* scriptTrigger = NULL;
Unit* scriptTrigger = nullptr;
if (invoker)
scriptTrigger = invoker;
else if (Unit* tempLastInvoker = GetLastInvoker())
@@ -2499,7 +2499,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
{
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
if (Player* member = groupRef->GetSource())
l->push_back(member);
}
@@ -2714,7 +2714,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
if (l->empty())
{
delete l;
l = NULL;
l = nullptr;
}
return l;
@@ -3126,7 +3126,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{
if (e.event.gameEvent.gameEventId != var0)
return;
ProcessAction(e, NULL, var0);
ProcessAction(e, nullptr, var0);
break;
}
case SMART_EVENT_GO_STATE_CHANGED:
@@ -3140,7 +3140,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{
if (e.event.eventInform.eventId != var0)
return;
ProcessAction(e, NULL, var0);
ProcessAction(e, nullptr, var0);
break;
}
case SMART_EVENT_ACTION_DONE:
@@ -3155,7 +3155,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me || !me->IsInCombat())
return;
ObjectList* _targets = NULL;
ObjectList* _targets = nullptr;
switch (e.GetTargetType())
{
@@ -3175,7 +3175,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!_targets)
return;
Unit* target = NULL;
Unit* target = nullptr;
for (ObjectList::const_iterator itr = _targets->begin(); itr != _targets->end(); ++itr)
{
@@ -3204,7 +3204,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me)
return;
WorldObject* creature = NULL;
WorldObject* creature = nullptr;
if (e.event.distance.guid != 0)
{
@@ -3235,7 +3235,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me)
return;
WorldObject* gameobject = NULL;
WorldObject* gameobject = nullptr;
if (e.event.distance.guid != 0)
{
@@ -3308,7 +3308,7 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsInCombat()))
return;
if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat())) //can be used with me=NULL (go script)
if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat())) //can be used with me=nullptr (go script)
return;
if (e.timer < diff)
@@ -3435,7 +3435,7 @@ void SmartScript::OnUpdate(uint32 const diff)
mTalkerEntry = 0;
mTextTimer = 0;
mUseTextTimer = false;
ProcessEventsFor(SMART_EVENT_TEXT_OVER, NULL, textID, entry);
ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
} else mTextTimer -= diff;
}
}
@@ -3481,22 +3481,22 @@ void SmartScript::GetScript()
SmartAIEventList e;
if (me)
{
e = sSmartScriptMgr->GetScript(-((int32)me->GetDBTableGUIDLow()), mScriptType);
e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
if (e.empty())
e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
FillScript(e, me, NULL);
FillScript(e, me, nullptr);
}
else if (go)
{
e = sSmartScriptMgr->GetScript(-((int32)go->GetDBTableGUIDLow()), mScriptType);
e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
if (e.empty())
e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
FillScript(e, go, NULL);
FillScript(e, go, nullptr);
}
else if (trigger)
{
e = sSmartScriptMgr->GetScript((int32)trigger->id, mScriptType);
FillScript(e, NULL, trigger);
FillScript(e, nullptr, trigger);
}
}
@@ -3528,7 +3528,7 @@ void SmartScript::OnInitialize(WorldObject* obj, AreaTriggerEntry const* at)
}
else
{
TC_LOG_ERROR("misc", "SmartScript::OnInitialize: !WARNING! Initialized objects are NULL.");
TC_LOG_ERROR("misc", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
return;
}
@@ -3584,13 +3584,13 @@ uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid)
Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
{
if (!me)
return NULL;
return nullptr;
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Unit* unit = NULL;
Unit* unit = nullptr;
Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff);
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check);
@@ -3638,9 +3638,9 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
{
if (!me)
return NULL;
return nullptr;
Unit* unit = NULL;
Unit* unit = nullptr;
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
Trinity::UnitLastSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, unit, u_check);
me->VisitNearbyObject(range, searcher);
@@ -3678,5 +3678,12 @@ void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
Unit* SmartScript::GetLastInvoker()
{
return ObjectAccessor::FindUnit(mLastInvoker);
WorldObject* lookupRoot = me;
if (!lookupRoot)
lookupRoot = go;
if (lookupRoot)
return ObjectAccessor::GetUnit(*lookupRoot, mLastInvoker);
return ObjectAccessor::FindPlayer(mLastInvoker);
}
+38 -42
View File
@@ -34,19 +34,19 @@ class SmartScript
SmartScript();
~SmartScript();
void OnInitialize(WorldObject* obj, AreaTriggerEntry const* at = NULL);
void OnInitialize(WorldObject* obj, AreaTriggerEntry const* at = nullptr);
void GetScript();
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at);
void ProcessEventsFor(SMART_EVENT e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
void ProcessEvent(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
bool CheckTimer(SmartScriptHolder const& e) const;
void RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max);
void UpdateTimer(SmartScriptHolder& e, uint32 const diff);
void InitTimer(SmartScriptHolder& e);
void ProcessAction(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = NULL);
void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = nullptr);
ObjectList* GetWorldObjectsInDist(float dist);
void InstallTemplate(SmartScriptHolder const& e);
SmartScriptHolder CreateEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0);
@@ -55,7 +55,7 @@ class SmartScript
uint32 GetPathId() const { return mPathId; }
WorldObject* GetBaseObject()
{
WorldObject* obj = NULL;
WorldObject* obj = nullptr;
if (me)
obj = me;
else if (go)
@@ -108,7 +108,7 @@ class SmartScript
(*mTargetStorage)[id] = new ObjectGuidList(targets, GetBaseObject());
}
bool IsSmart(Creature* c = NULL)
bool IsSmart(Creature* c = nullptr)
{
bool smart = true;
if (c && c->GetAIName() != "SmartAI")
@@ -118,12 +118,12 @@ class SmartScript
smart = false;
if (!smart)
TC_LOG_ERROR("sql.sql", "SmartScript: Action target Creature (GUID: %u Entry: %u) is not using SmartAI, action called by Creature (GUID: %u Entry: %u) skipped to prevent crash.", c ? c->GetDBTableGUIDLow() : 0, c ? c->GetEntry() : 0, me ? me->GetDBTableGUIDLow() : 0, me ? me->GetEntry() : 0);
TC_LOG_ERROR("sql.sql", "SmartScript: Action target Creature (GUID: %u Entry: %u) is not using SmartAI, action called by Creature (GUID: %u Entry: %u) skipped to prevent crash.", c ? c->GetSpawnId() : 0, c ? c->GetEntry() : 0, me ? me->GetSpawnId() : 0, me ? me->GetEntry() : 0);
return smart;
}
bool IsSmartGO(GameObject* g = NULL)
bool IsSmartGO(GameObject* g = nullptr)
{
bool smart = true;
if (g && g->GetAIName() != "SmartGameObjectAI")
@@ -132,7 +132,7 @@ class SmartScript
if (!go || go->GetAIName() != "SmartGameObjectAI")
smart = false;
if (!smart)
TC_LOG_ERROR("sql.sql", "SmartScript: Action target GameObject (GUID: %u Entry: %u) is not using SmartGameObjectAI, action called by GameObject (GUID: %u Entry: %u) skipped to prevent crash.", g ? g->GetDBTableGUIDLow() : 0, g ? g->GetEntry() : 0, go ? go->GetDBTableGUIDLow() : 0, go ? go->GetEntry() : 0);
TC_LOG_ERROR("sql.sql", "SmartScript: Action target GameObject (GUID: %u Entry: %u) is not using SmartGameObjectAI, action called by GameObject (GUID: %u Entry: %u) skipped to prevent crash.", g ? g->GetSpawnId() : 0, g ? g->GetEntry() : 0, go ? go->GetSpawnId() : 0, go ? go->GetEntry() : 0);
return smart;
}
@@ -177,33 +177,21 @@ class SmartScript
GameObject* FindGameObjectNear(WorldObject* searchObject, uint32 guid) const
{
GameObject* gameObject = NULL;
auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
if (bounds.first != bounds.second)
return bounds.first->second;
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
return gameObject;
return nullptr;
}
Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const
{
Creature* creature = NULL;
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
if (bounds.first == bounds.second)
return nullptr;
Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid);
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check);
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
return creature;
auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair) -> bool { return pair.second->IsAlive(); });
return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
}
ObjectListMap* mTargetStorage;
@@ -211,20 +199,28 @@ class SmartScript
void OnReset();
void ResetBaseObject()
{
if (meOrigGUID)
WorldObject* lookupRoot = me;
if (!lookupRoot)
lookupRoot = go;
if (lookupRoot)
{
if (Creature* m = HashMapHolder<Creature>::Find(meOrigGUID))
if (!meOrigGUID.IsEmpty())
{
me = m;
go = NULL;
if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID))
{
me = m;
go = nullptr;
}
}
}
if (goOrigGUID)
{
if (GameObject* o = HashMapHolder<GameObject>::Find(goOrigGUID))
if (!goOrigGUID.IsEmpty())
{
me = NULL;
go = o;
if (GameObject* o = ObjectAccessor::GetGameObject(*lookupRoot, goOrigGUID))
{
me = nullptr;
go = o;
}
}
}
goOrigGUID.Clear();
+1 -1
View File
@@ -81,7 +81,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
{
do
{
ObjectGuid guid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
ObjectGuid guid(HighGuid::Player, (*result)[0].GetUInt32());
// Kick if player is online
if (Player* p = ObjectAccessor::FindConnectedPlayer(guid))
@@ -736,7 +736,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(ObjectGuid(HIGHGUID_PLAYER, uint32(atol(guids[i]))));
ca.guids.insert(ObjectGuid(HighGuid::Player, uint32(atol(guids[i]))));
ca.changed = false;
@@ -774,7 +774,7 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
CriteriaProgress& progress = m_criteriaProgress[id];
progress.counter = counter;
progress.date = date;
progress.CompletedGUID = ObjectGuid(HIGHGUID_PLAYER, guid);
progress.CompletedGUID = ObjectGuid(HighGuid::Player, guid);
progress.changed = false;
} while (criteriaResult->NextRow());
}
@@ -1927,7 +1927,7 @@ void AchievementMgr<Player>::CompletedAchievement(AchievementEntry const* achiev
SendAchievementEarned(achievement);
TC_LOG_INFO("achievement", "AchievementMgr::CompletedAchievement(%u). Player: %s (%u)",
achievement->ID, GetOwner()->GetName().c_str(), GetOwner()->GetGUIDLow());
achievement->ID, GetOwner()->GetName().c_str(), GetOwner()->GetGUID().GetCounter());
CompletedAchievementData& ca = m_completedAchievements[achievement->ID];
ca.date = time(NULL);
@@ -115,7 +115,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
return;
uint32 bidderAccId = 0;
ObjectGuid bidderGuid(HIGHGUID_PLAYER, auction->bidder);
ObjectGuid bidderGuid(HighGuid::Player, auction->bidder);
Player* bidder = ObjectAccessor::FindConnectedPlayer(bidderGuid);
// data for gm.log
std::string bidderName;
@@ -138,7 +138,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
if (logGmTrade)
{
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
ObjectGuid ownerGuid = ObjectGuid(HighGuid::Player, auction->owner);
std::string ownerName;
if (!sObjectMgr->GetPlayerNameByGUID(ownerGuid, ownerName))
ownerName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
@@ -156,7 +156,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
// owner in `data` will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
stmt->setUInt32(0, auction->bidder);
stmt->setUInt32(1, pItem->GetGUIDLow());
stmt->setUInt32(1, pItem->GetGUID().GetCounter());
trans->Append(stmt);
if (bidder)
@@ -179,7 +179,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTransaction& trans)
{
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
ObjectGuid owner_guid(HighGuid::Player, auction->owner);
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist (online or offline)
@@ -191,7 +191,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)
{
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
ObjectGuid owner_guid(HighGuid::Player, auction->owner);
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
@@ -222,7 +222,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
if (!pItem)
return;
ObjectGuid owner_guid(HIGHGUID_PLAYER, auction->owner);
ObjectGuid owner_guid(HighGuid::Player, auction->owner);
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
@@ -245,7 +245,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)
{
ObjectGuid oldBidder_guid(HIGHGUID_PLAYER, auction->bidder);
ObjectGuid oldBidder_guid(HighGuid::Player, auction->bidder);
Player* oldBidder = ObjectAccessor::FindConnectedPlayer(oldBidder_guid);
uint32 oldBidder_accId = 0;
@@ -267,7 +267,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)
{
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
ObjectGuid bidder_guid = ObjectGuid(HighGuid::Player, auction->bidder);
Player* bidder = ObjectAccessor::FindConnectedPlayer(bidder_guid);
uint32 bidder_accId = 0;
@@ -382,8 +382,8 @@ void AuctionHouseMgr::LoadAuctions()
void AuctionHouseMgr::AddAItem(Item* it)
{
ASSERT(it);
ASSERT(mAitems.find(it->GetGUIDLow()) == mAitems.end());
mAitems[it->GetGUIDLow()] = it;
ASSERT(mAitems.find(it->GetGUID().GetCounter()) == mAitems.end());
mAitems[it->GetGUID().GetCounter()] = it;
}
bool AuctionHouseMgr::RemoveAItem(uint32 id, bool deleteItem)
@@ -623,7 +623,7 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player,
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
{
AuctionEntry* Aentry = itr->second;
if (Aentry && Aentry->bidder == player->GetGUIDLow())
if (Aentry && Aentry->bidder == player->GetGUID().GetCounter())
{
if (itr->second->BuildAuctionInfo(data))
++count;
@@ -638,7 +638,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player,
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
{
AuctionEntry* Aentry = itr->second;
if (Aentry && Aentry->owner == player->GetGUIDLow())
if (Aentry && Aentry->owner == player->GetGUID().GetCounter())
{
if (Aentry->BuildAuctionInfo(data))
++count;
@@ -866,7 +866,7 @@ std::string AuctionEntry::BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint3
{
std::ostringstream strm;
strm.width(16);
strm << std::right << std::hex << ObjectGuid(HIGHGUID_PLAYER, lowGuid).GetRawValue(); // 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();
@@ -993,7 +993,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config)
AuctionEntry* auctionEntry = new AuctionEntry();
auctionEntry->Id = sObjectMgr->GenerateAuctionID();
auctionEntry->owner = 0;
auctionEntry->itemGUIDLow = item->GetGUIDLow();
auctionEntry->itemGUIDLow = item->GetGUID().GetCounter();
auctionEntry->itemEntry = item->GetEntry();
auctionEntry->startbid = bidPrice;
auctionEntry->buyout = buyoutPrice;
+16 -16
View File
@@ -769,7 +769,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
}
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
delete creature;
@@ -801,7 +801,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
// Create gameobject
GameObject* go = new GameObject;
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry);
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry);
@@ -834,7 +834,7 @@ GameObject* Battlefield::GetGameObject(ObjectGuid guid)
// ******************* CapturePoint **********************
// *******************************************************
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID()
BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointSpawnId()
{
m_team = TEAM_NEUTRAL;
m_value = 0;
@@ -849,9 +849,9 @@ BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_
bool BfCapturePoint::HandlePlayerEnter(Player* player)
{
if (m_capturePointGUID)
if (m_capturePointSpawnId)
{
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
{
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)));
@@ -864,8 +864,8 @@ bool BfCapturePoint::HandlePlayerEnter(Player* player)
GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
{
if (m_capturePointGUID)
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
if (m_capturePointSpawnId)
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID());
@@ -879,10 +879,10 @@ GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player)
void BfCapturePoint::SendChangePhase()
{
if (!m_capturePointGUID)
if (!m_capturePointSpawnId)
return;
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
{
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
@@ -899,7 +899,7 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
TC_LOG_DEBUG("bg.battlefield", "Creating capture point %u", capturePoint->GetEntry());
m_capturePointGUID = ObjectGuid(HIGHGUID_GAMEOBJECT, capturePoint->GetEntry(), capturePoint->GetGUIDLow());
m_capturePointSpawnId = ObjectGuid(HighGuid::GameObject, capturePoint->GetEntry(), capturePoint->GetGUID().GetCounter());
// check info existence
GameObjectTemplate const* goinfo = capturePoint->GetGOInfo();
@@ -931,20 +931,20 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint)
GameObject* BfCapturePoint::GetCapturePointGo()
{
return m_Bf->GetGameObject(m_capturePointGUID);
return m_Bf->GetGameObject(m_capturePointSpawnId);
}
bool BfCapturePoint::DelCapturePoint()
{
if (m_capturePointGUID)
if (m_capturePointSpawnId)
{
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
{
capturePoint->SetRespawnTime(0); // not save respawn time
capturePoint->Delete();
capturePoint = NULL;
}
m_capturePointGUID.Clear();
m_capturePointSpawnId.Clear();
}
return true;
@@ -952,10 +952,10 @@ bool BfCapturePoint::DelCapturePoint()
bool BfCapturePoint::Update(uint32 diff)
{
if (!m_capturePointGUID)
if (!m_capturePointSpawnId)
return false;
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID))
if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointSpawnId))
{
float radius = capturePoint->GetGOInfo()->capturePoint.radius;
+1 -1
View File
@@ -133,7 +133,7 @@ class BfCapturePoint
uint32 m_capturePointEntry;
// Gameobject related to that capture point
ObjectGuid m_capturePointGUID;
ObjectGuid m_capturePointSpawnId;
};
class BfGraveyard
@@ -80,7 +80,7 @@ void BattlefieldMgr::HandlePlayerEnterZone(Player* player, uint32 zoneId)
return;
bf->HandlePlayerEnterZone(player, zoneId);
TC_LOG_DEBUG("bg.battlefield", "Player %u entered battlefield id %u", player->GetGUIDLow(), bf->GetTypeId());
TC_LOG_DEBUG("bg.battlefield", "Player %u entered battlefield id %u", player->GetGUID().GetCounter(), bf->GetTypeId());
}
void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId)
@@ -94,7 +94,7 @@ void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId)
return;
itr->second->HandlePlayerLeaveZone(player, zoneId);
TC_LOG_DEBUG("bg.battlefield", "Player %u left battlefield id %u", player->GetGUIDLow(), itr->second->GetTypeId());
TC_LOG_DEBUG("bg.battlefield", "Player %u left battlefield id %u", player->GetGUID().GetCounter(), itr->second->GetTypeId());
}
Battlefield* BattlefieldMgr::GetBattlefieldToZoneId(uint32 zoneId)
+2 -2
View File
@@ -42,7 +42,7 @@ Arena::Arena()
void Arena::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new ArenaScore(player->GetGUID(), player->GetBGTeam());
if (player->GetBGTeam() == ALLIANCE) // gold
{
@@ -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::FindConnectedPlayer(ObjectGuid(HIGHGUID_PLAYER, score.first)))
if (Player* player = ObjectAccessor::FindConnectedPlayer(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),
+6 -6
View File
@@ -193,7 +193,7 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult result)
TeamId = fields[0].GetUInt32();
TeamName = fields[1].GetString();
CaptainGuid = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
CaptainGuid = ObjectGuid(HighGuid::Player, fields[2].GetUInt32());
Type = fields[3].GetUInt8();
BackgroundColor = fields[4].GetUInt32();
EmblemStyle = fields[5].GetUInt8();
@@ -232,7 +232,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
break;
ArenaTeamMember newMember;
newMember.Guid = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32());
newMember.Guid = ObjectGuid(HighGuid::Player, fields[1].GetUInt32());
newMember.WeekGames = fields[2].GetUInt16();
newMember.WeekWins = fields[3].GetUInt16();
newMember.SeasonGames = fields[4].GetUInt16();
@@ -305,8 +305,8 @@ void ArenaTeam::SetCaptain(ObjectGuid guid)
if (oldCaptain)
{
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u, Name: %s] [Type: %u].",
oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(),
newCaptain->GetGUIDLow(), GetId(), GetName().c_str(), GetType());
oldCaptain->GetName().c_str(), oldCaptain->GetGUID().GetCounter(), newCaptain->GetName().c_str(),
newCaptain->GetGUID().GetCounter(), GetId(), GetName().c_str(), GetType());
}
}
}
@@ -327,7 +327,7 @@ void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb)
// delete all info regarding this team
for (uint32 i = 0; i < ARENA_TEAM_END; ++i)
player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0);
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] left arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId(), GetName().c_str());
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] left arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUID().GetCounter(), GetType(), GetId(), GetName().c_str());
}
// Only used for single member deletion, for arena team disband we use a single query for more efficiency
@@ -347,7 +347,7 @@ void ArenaTeam::Disband(WorldSession* session)
{
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());
TC_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUID().GetCounter(), GetType(), GetId(), GetName().c_str());
}
// Remove all members from arena team
@@ -820,10 +820,10 @@ void Battleground::EndBattleground(uint32 winner)
if (isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_PLAYER);
BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUIDLow());
BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID().GetCounter());
stmt->setUInt32(0, battlegroundId);
stmt->setUInt32(1, player->GetGUIDLow());
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->setUInt32(2, score->second->GetKillingBlows());
stmt->setUInt32(3, score->second->GetDeaths());
stmt->setUInt32(4, score->second->GetHonorableKills());
@@ -1343,7 +1343,7 @@ void Battleground::BuildPvPLogDataPacket(WorldPacket& data)
bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
{
BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUIDLow());
BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUID().GetCounter());
if (itr == PlayerScores.end()) // player not found...
return false;
@@ -1418,7 +1418,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
// So we must create it specific for this instance
GameObject* go = new GameObject;
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, GetBgMap(),
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(),
PHASEMASK_NORMAL, x, y, z, o, rotation0, rotation1, rotation2, rotation3, 100, goState))
{
TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
@@ -1428,7 +1428,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
}
/*
uint32 guid = go->GetGUIDLow();
uint32 guid = go->GetGUID().GetCounter();
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
// iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
@@ -1561,8 +1561,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y,
}
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, x, y, z, o))
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
{
TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
@@ -650,7 +650,7 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
bg->SetRandomTypeID(bgTypeId);
bg->SetRated(isRated);
bg->SetRandom(isRandom);
bg->SetGuid(ObjectGuid(HIGHGUID_BATTLEGROUND, uint32(bgTypeId)));
bg->SetGuid(ObjectGuid(HighGuid::BattleGround, uint32(bgTypeId)));
// Set up correct min/max player counts for scoreboards
if (bg->isArena())
@@ -753,7 +753,7 @@ bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate)
bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
bg->SetScriptId(bgTemplate->ScriptId);
bg->SetGuid(ObjectGuid(HIGHGUID_BATTLEGROUND, uint32(bgTemplate->Id)));
bg->SetGuid(ObjectGuid(HighGuid::BattleGround, uint32(bgTemplate->Id)));
AddBattleground(bg);
@@ -477,7 +477,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
TC_LOG_DEBUG("bg.battleground", "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u",
player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
player->GetName().c_str(), player->GetGUID().GetCounter(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, player, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, player->GetBattlegroundQueueJoinTime(bgTypeId), ginfo->ArenaType);
@@ -1042,7 +1042,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(m_BgQueueTypeId);
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
{
TC_LOG_DEBUG("bg.battleground", "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUIDLow(), m_BgInstanceGUID);
TC_LOG_DEBUG("bg.battleground", "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUID().GetCounter(), m_BgInstanceGUID);
player->RemoveBattlegroundQueueId(m_BgQueueTypeId);
bgQueue.RemovePlayer(m_PlayerGuid, true);
@@ -222,7 +222,7 @@ void BattlegroundAB::StartingEventOpenDoors()
void BattlegroundAB::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundABScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundABScore(player->GetGUID(), player->GetBGTeam());
}
void BattlegroundAB::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/)
@@ -302,7 +302,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
if (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid <= AV_NPC_A_GRAVEDEFENSE3)
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
{
CreatureData &data = sObjectMgr->NewOrExistCreatureData(creature->GetDBTableGUIDLow());
CreatureData &data = sObjectMgr->NewOrExistCreatureData(creature->GetSpawnId());
data.spawndist = 5;
}
//else spawndist will be 15, so creatures move maximum=10
@@ -435,7 +435,7 @@ void BattlegroundAV::StartingEventOpenDoors()
void BattlegroundAV::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundAVScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundAVScore(player->GetGUID(), player->GetBGTeam());
}
void BattlegroundAV::EndBattleground(uint32 winner)
@@ -161,7 +161,7 @@ void BattlegroundEY::CheckSomeoneJoinedPoint()
GameObject* obj = NULL;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
obj = GetBgMap()->GetGameObject(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if (obj)
{
uint8 j = 0;
@@ -201,7 +201,7 @@ void BattlegroundEY::CheckSomeoneLeftPoint()
GameObject* obj = NULL;
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
{
obj = HashMapHolder<GameObject>::Find(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
obj = GetBgMap()->GetGameObject(BgObjects[BG_EY_OBJECT_TOWER_CAP_FEL_REAVER + i]);
if (obj)
{
uint8 j = 0;
@@ -362,7 +362,7 @@ void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
void BattlegroundEY::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundEYScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundEYScore(player->GetGUID(), player->GetBGTeam());
m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID());
}
@@ -588,7 +588,7 @@ void BattlegroundEY::RespawnFlagAfterDrop()
{
RespawnFlag(true);
GameObject* obj = HashMapHolder<GameObject>::Find(GetDroppedFlagGUID());
GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGUID());
if (obj)
obj->Delete();
else
@@ -245,7 +245,7 @@ void BattlegroundIC::StartingEventOpenDoors()
void BattlegroundIC::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundICScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundICScore(player->GetGUID(), player->GetBGTeam());
if (nodePoint[NODE_TYPE_QUARRY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H))
player->CastSpell(player, SPELL_QUARRY, true);
@@ -476,7 +476,7 @@ void BattlegroundSA::FillInitialWorldStates(WorldPacket& data)
void BattlegroundSA::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundSAScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundSAScore(player->GetGUID(), player->GetBGTeam());
SendTransportInit(player);
@@ -227,7 +227,7 @@ void BattlegroundWS::StartingEventOpenDoors()
void BattlegroundWS::AddPlayer(Player* player)
{
Battleground::AddPlayer(player);
PlayerScores[player->GetGUIDLow()] = new BattlegroundWGScore(player->GetGUID(), player->GetBGTeam());
PlayerScores[player->GetGUID().GetCounter()] = new BattlegroundWGScore(player->GetGUID(), player->GetBGTeam());
}
void BattlegroundWS::RespawnFlag(uint32 Team, bool captured)
+3 -3
View File
@@ -58,7 +58,7 @@ void CalendarMgr::LoadFromDB()
Field* fields = result->Fetch();
uint64 eventId = fields[0].GetUInt64();
ObjectGuid creatorGUID = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32());
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();
ObjectGuid invitee = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
ObjectGuid senderGUID = ObjectGuid(HIGHGUID_PLAYER, fields[3].GetUInt32());
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());
+62 -69
View File
@@ -40,7 +40,7 @@ static size_t getCommandTableSize(const ChatCommand* commands)
if (!commands)
return 0;
size_t count = 0;
while (commands[count].Name != NULL)
while (commands[count].Name != nullptr)
count++;
return count;
}
@@ -59,7 +59,7 @@ ChatCommand* ChatHandler::getCommandTable()
// cache for commands, needed because some commands are loaded dynamically through ScriptMgr
// cache is never freed and will show as a memory leak in diagnostic tools
// can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements
static ChatCommand* commandTableCache = NULL;
static ChatCommand* commandTableCache = nullptr;
if (LoadCommandTable())
{
@@ -113,7 +113,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
{
WorldSession* target_session = NULL;
WorldSession* target_session = nullptr;
uint32 target_account = 0;
if (target)
@@ -148,7 +148,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
else if (target_account)
target_sec = AccountMgr::GetSecurity(target_account, realmHandle.Index);
else
return true; // caller must report error for (target == NULL && target_account == 0)
return true; // caller must report error for (target == nullptr && target_account == 0)
AccountTypes target_ac_sec = AccountTypes(target_sec);
if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
@@ -216,7 +216,7 @@ void ChatHandler::SendSysMessage(const char *str, bool escapeCharacters)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
m_session->SendPacket(&data);
}
@@ -234,7 +234,7 @@ void ChatHandler::SendGlobalSysMessage(const char *str)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalMessage(&data);
}
@@ -252,7 +252,7 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalGMMessage(&data);
}
@@ -277,7 +277,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
while (*text == ' ') ++text;
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
if (!hasStringAbbr(table[i].Name, cmd.c_str()))
continue;
@@ -285,7 +285,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
bool match = false;
if (strlen(table[i].Name) > cmd.length())
{
for (uint32 j = 0; table[j].Name != NULL; ++j)
for (uint32 j = 0; table[j].Name != nullptr; ++j)
{
if (!hasStringAbbr(table[j].Name, cmd.c_str()))
continue;
@@ -301,7 +301,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
continue;
// select subcommand from child commands list
if (table[i].ChildCommands != NULL)
if (table[i].ChildCommands != nullptr)
{
if (!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd))
{
@@ -378,14 +378,14 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text,
while (*text == ' ') ++text;
for (uint32 i = 0; table[i].Name != NULL; i++)
for (uint32 i = 0; table[i].Name != nullptr; i++)
{
// for data fill use full explicit command names
if (table[i].Name != cmd)
continue;
// select subcommand from child commands list (including "")
if (table[i].ChildCommands != NULL)
if (table[i].ChildCommands != nullptr)
{
if (SetDataForCommandInTable(table[i].ChildCommands, text, permission, help, fullcommand))
return true;
@@ -521,7 +521,7 @@ Valid examples:
bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd)
{
std::string list;
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -560,7 +560,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
{
if (*cmd)
{
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -570,7 +570,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
continue;
// have subcommand
char const* subcmd = (*cmd) ? strtok(NULL, " ") : "";
char const* subcmd = (*cmd) ? strtok(nullptr, " ") : "";
if (table[i].ChildCommands && subcmd && *subcmd)
{
@@ -590,7 +590,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
}
else
{
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -744,7 +744,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
Player* ChatHandler::getSelectedPlayer()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
@@ -756,7 +756,7 @@ Player* ChatHandler::getSelectedPlayer()
Unit* ChatHandler::getSelectedUnit()
{
if (!m_session)
return NULL;
return nullptr;
if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
return selected;
@@ -767,7 +767,7 @@ Unit* ChatHandler::getSelectedUnit()
WorldObject* ChatHandler::getSelectedObject()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid guid = m_session->GetPlayer()->GetTarget();
@@ -780,7 +780,7 @@ WorldObject* ChatHandler::getSelectedObject()
Creature* ChatHandler::getSelectedCreature()
{
if (!m_session)
return NULL;
return nullptr;
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(), m_session->GetPlayer()->GetTarget());
}
@@ -788,7 +788,7 @@ Creature* ChatHandler::getSelectedCreature()
Player* ChatHandler::getSelectedPlayerOrSelf()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
@@ -807,14 +807,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
{
// skip empty
if (!text)
return NULL;
return nullptr;
// skip spaces
while (*text == ' '||*text == '\t'||*text == '\b')
++text;
if (!*text)
return NULL;
return nullptr;
// return non link case
if (text[0] != '|')
@@ -826,28 +826,28 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
char* check = strtok(text, "|"); // skip color
if (!check)
return NULL; // end of data
return nullptr; // end of data
char* cLinkType = strtok(NULL, ":"); // linktype
char* cLinkType = strtok(nullptr, ":"); // linktype
if (!cLinkType)
return NULL; // end of data
return nullptr; // end of data
if (strcmp(cLinkType, linkType) != 0)
{
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after retturn from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
SendSysMessage(LANG_WRONG_LINK_TYPE);
return NULL;
return nullptr;
}
char* cKeys = strtok(NULL, "|"); // extract keys and values
char* cKeysTail = strtok(NULL, "");
char* cKeys = strtok(nullptr, "|"); // extract keys and values
char* cKeysTail = strtok(nullptr, "");
char* cKey = strtok(cKeys, ":|"); // extract key
if (something1)
*something1 = strtok(NULL, ":|"); // extract something
*something1 = strtok(nullptr, ":|"); // extract something
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
return cKey;
}
@@ -855,14 +855,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
{
// skip empty
if (!text)
return NULL;
return nullptr;
// skip spaces
while (*text == ' '||*text == '\t'||*text == '\b')
++text;
if (!*text)
return NULL;
return nullptr;
// return non link case
if (text[0] != '|')
@@ -880,48 +880,48 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
{
char* check = strtok(text, "|"); // skip color
if (!check)
return NULL; // end of data
return nullptr; // end of data
tail = strtok(NULL, ""); // tail
tail = strtok(nullptr, ""); // tail
}
else
tail = text+1; // skip first |
char* cLinkType = strtok(tail, ":"); // linktype
if (!cLinkType)
return NULL; // end of data
return nullptr; // end of data
for (int i = 0; linkTypes[i]; ++i)
{
if (strcmp(cLinkType, linkTypes[i]) == 0)
{
char* cKeys = strtok(NULL, "|"); // extract keys and values
char* cKeysTail = strtok(NULL, "");
char* cKeys = strtok(nullptr, "|"); // extract keys and values
char* cKeysTail = strtok(nullptr, "");
char* cKey = strtok(cKeys, ":|"); // extract key
if (something1)
*something1 = strtok(NULL, ":|"); // extract something
*something1 = strtok(nullptr, ":|"); // extract something
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
if (found_idx)
*found_idx = i;
return cKey;
}
}
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
SendSysMessage(LANG_WRONG_LINK_TYPE);
return NULL;
return nullptr;
}
GameObject* ChatHandler::GetNearbyGameObject()
{
if (!m_session)
return NULL;
return nullptr;
Player* pl = m_session->GetPlayer();
GameObject* obj = NULL;
GameObject* obj = nullptr;
Trinity::NearestGameObjectCheck check(*pl);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
@@ -931,23 +931,16 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry)
{
if (!m_session)
return NULL;
return nullptr;
Player* pl = m_session->GetPlayer();
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid));
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HighGuid::GameObject, entry, lowguid));
if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
{
// search near player then
CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
Cell cell(p);
Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
auto bounds = pl->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
if (bounds.first != bounds.second)
obj = bounds.first->second;
}
return obj;
@@ -980,7 +973,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
// number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r
// number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r
int type = 0;
char* param1_str = NULL;
char* param1_str = nullptr;
char* idS = extractKeyFromLink(text, spellKeys, &type, &param1_str);
if (!idS)
return 0;
@@ -1028,7 +1021,7 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
char* cId = extractKeyFromLink(text, "Htele");
if (!cId)
return NULL;
return nullptr;
// id case (explicit or from shift link)
if (cId[0] >= '0' || cId[0] >= '9')
@@ -1085,7 +1078,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
uint32 lowguid = atoul(idS);
if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
return ObjectGuid(HIGHGUID_UNIT, data->id, lowguid);
return ObjectGuid(HighGuid::Unit, data->id, lowguid);
else
return ObjectGuid::Empty;
}
@@ -1094,7 +1087,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
uint32 lowguid = atoul(idS);
if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
return ObjectGuid(HighGuid::GameObject, data->id, lowguid);
else
return ObjectGuid::Empty;
}
@@ -1118,7 +1111,7 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
return name;
}
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/)
{
if (args && *args)
{
@@ -1174,12 +1167,12 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
{
char* p1 = strtok(args, " ");
char* p2 = strtok(NULL, " ");
char* p2 = strtok(nullptr, " ");
if (!p2)
{
p2 = p1;
p1 = NULL;
p1 = nullptr;
}
if (arg1)
@@ -1192,7 +1185,7 @@ void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
char* ChatHandler::extractQuotedArg(char* args)
{
if (!*args)
return NULL;
return nullptr;
if (*args == '"')
return strtok(args+1, "\"");
@@ -1205,9 +1198,9 @@ char* ChatHandler::extractQuotedArg(char* args)
continue;
}
// return NULL if we reached the end of the string
// return nullptr if we reached the end of the string
if (!*args)
return NULL;
return nullptr;
// since we skipped all spaces, we expect another token now
if (*args == '"')
@@ -1225,7 +1218,7 @@ char* ChatHandler::extractQuotedArg(char* args)
return strtok(args + 1, "\"");
}
else
return NULL;
return nullptr;
}
}
@@ -1279,7 +1272,7 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
{
player = NULL;
player = nullptr;
guid.Clear();
if (cname)
+2 -2
View File
@@ -301,10 +301,10 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
switch (object->GetTypeId())
{
case TYPEID_UNIT:
condMeets &= object->ToCreature()->GetDBTableGUIDLow() == ConditionValue3;
condMeets &= object->ToCreature()->GetSpawnId() == ConditionValue3;
break;
case TYPEID_GAMEOBJECT:
condMeets &= object->ToGameObject()->GetDBTableGUIDLow() == ConditionValue3;
condMeets &= object->ToGameObject()->GetSpawnId() == ConditionValue3;
break;
default:
break;
+1 -1
View File
@@ -58,7 +58,7 @@ void LFGMgr::_LoadFromDB(Field* fields, ObjectGuid guid)
if (!guid.IsGroup())
return;
SetLeader(guid, ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()));
SetLeader(guid, ObjectGuid(HighGuid::Player, fields[0].GetUInt32()));
uint32 dungeon = fields[17].GetUInt32();
uint8 state = fields[18].GetUInt8();
@@ -89,7 +89,7 @@ void LFGPlayerScript::OnMapChanged(Player* player)
player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f);
TC_LOG_ERROR("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%u) is in LFG dungeon map but does not have a valid group! "
"Teleporting to homebind.", player->GetName().c_str(), player->GetGUIDLow());
"Teleporting to homebind.", player->GetName().c_str(), player->GetGUID().GetCounter());
return;
}
@@ -40,7 +40,7 @@ void AreaTrigger::AddToWorld()
///- Register the AreaTrigger for guid lookup and for caster
if (!IsInWorld())
{
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<AreaTrigger>(GetGUID(), this);
WorldObject::AddToWorld();
}
}
@@ -51,7 +51,7 @@ void AreaTrigger::RemoveFromWorld()
if (IsInWorld())
{
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<AreaTrigger>(GetGUID());
}
}
@@ -65,7 +65,7 @@ bool AreaTrigger::CreateAreaTrigger(uint32 guidlow, uint32 triggerEntry, Unit* c
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_AREATRIGGER, caster->GetPhaseMask());
WorldObject::_Create(guidlow, HighGuid::AreaTrigger, caster->GetPhaseMask());
SetEntry(triggerEntry);
SetDuration(spell->GetDuration());
+18 -41
View File
@@ -44,7 +44,7 @@ void Corpse::AddToWorld()
{
///- Register the corpse for guid lookup
if (!IsInWorld())
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Corpse>(GetGUID(), this);
Object::AddToWorld();
}
@@ -53,15 +53,15 @@ void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if (IsInWorld())
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<Corpse>(GetGUID());
Object::RemoveFromWorld();
WorldObject::RemoveFromWorld();
}
bool Corpse::Create(uint32 guidlow, Map* map)
{
SetMap(map);
Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
Object::_Create(guidlow, 0, HighGuid::Corpse);
return true;
}
@@ -82,9 +82,9 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
//in other way we will get a crash in Corpse::SaveToDB()
SetMap(owner->GetMap());
WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetPhaseMask());
WorldObject::_Create(guidlow, HighGuid::Corpse, owner->GetPhaseMask());
SetObjectScale(1);
SetObjectScale(1.0f);
SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID());
_gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
@@ -102,7 +102,6 @@ void Corpse::SaveToDB()
uint16 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
stmt->setUInt32(index++, GetGUIDLow()); // corpseGuid
stmt->setUInt32(index++, GetOwnerGUID().GetCounter()); // guid
stmt->setFloat (index++, GetPositionX()); // posX
stmt->setFloat (index++, GetPositionY()); // posY
@@ -124,11 +123,8 @@ void Corpse::SaveToDB()
{
index = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE_PHASES);
stmt->setUInt32(index++, GetGUIDLow()); // Guid (corpse's)
stmt->setUInt32(index++, phaseId); // PhaseId
stmt->setUInt32(index++, GetOwnerGUID().GetCounter()); // OwnerGuid
stmt->setUInt32(index++, uint32(m_time)); // Time
stmt->setUInt8(index++, GetType()); // CorpseType
stmt->setUInt32(index++, phaseId); // PhaseId
trans->Append(stmt);
}
@@ -142,7 +138,7 @@ void Corpse::DeleteBonesFromWorld()
if (!corpse)
{
TC_LOG_ERROR("entities.player", "Bones %u not found in world.", GetGUIDLow());
TC_LOG_ERROR("entities.player", "Bones %u not found in world.", GetGUID().GetCounter());
return;
}
@@ -151,46 +147,27 @@ void Corpse::DeleteBonesFromWorld()
void Corpse::DeleteFromDB(SQLTransaction& trans)
{
PreparedStatement* stmt = NULL;
if (GetType() == CORPSE_BONES)
{
// Only specific bones
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE_PHASES);
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
}
else
{
// all corpses (not bones)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_CORPSES);
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_CORPSES_PHASES);
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
trans->Append(stmt);
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE_PHASES);
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
trans->Append(stmt);
}
bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, corpseGuid, guid FROM corpse WHERE corpseType <> 0
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse
uint32 ownerGuid = fields[15].GetUInt32();
float posX = fields[0].GetFloat();
float posY = fields[1].GetFloat();
float posZ = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 mapId = fields[4].GetUInt16();
Object::_Create(guid, 0, HIGHGUID_CORPSE);
Object::_Create(guid, 0, HighGuid::Corpse);
SetObjectScale(1.0f);
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
@@ -199,7 +176,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());
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid(HIGHGUID_PLAYER, ownerGuid));
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(fields[14].GetUInt32()));
m_time = time_t(fields[11].GetUInt32());
+52 -51
View File
@@ -139,7 +139,7 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(),
m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(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_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(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),
m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(NULL), m_creatureData(NULL), m_waypointID(0), m_path_id(0), m_formation(NULL)
{
@@ -176,7 +176,11 @@ void Creature::AddToWorld()
{
if (GetZoneScript())
GetZoneScript()->OnCreatureCreate(this);
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Creature>(GetGUID(), this);
if (m_spawnId)
GetMap()->GetCreatureBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
Unit::AddToWorld();
SearchFormation();
AIM_Initialize();
@@ -191,10 +195,14 @@ void Creature::RemoveFromWorld()
{
if (GetZoneScript())
GetZoneScript()->OnCreatureRemove(this);
if (m_formation)
sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
Unit::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
if (m_spawnId)
Trinity::Containers::MultimapErasePair(GetMap()->GetCreatureBySpawnIdStore(), m_spawnId, this);
GetMap()->GetObjectsStore().Remove<Creature>(GetGUID());
}
}
@@ -213,7 +221,7 @@ void Creature::SearchFormation()
if (IsSummon())
return;
uint32 lowguid = GetDBTableGUIDLow();
uint32 lowguid = GetSpawnId();
if (!lowguid)
return;
@@ -448,11 +456,11 @@ void Creature::Update(uint32 diff)
{
case JUST_RESPAWNED:
// Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUIDLow(), GetEntry());
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUID().GetCounter(), GetEntry());
break;
case JUST_DIED:
// Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUID().GetCounter(), GetEntry());
break;
case DEAD:
{
@@ -463,7 +471,7 @@ void Creature::Update(uint32 diff)
if (!allowed) // Will be rechecked on next Update call
break;
ObjectGuid dbtableHighGuid(HIGHGUID_UNIT, GetEntry(), m_DBTableGuid);
ObjectGuid dbtableHighGuid(HighGuid::Unit, GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (!linkedRespawntime) // Can respawn
Respawn();
@@ -922,7 +930,7 @@ void Creature::SaveToDB()
{
// this should only be used when the creature has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise
CreatureData const* data = sObjectMgr->GetCreatureData(m_DBTableGuid);
CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId);
if (!data)
{
TC_LOG_ERROR("entities.unit", "Creature::SaveToDB failed, cannot get creature data!");
@@ -936,9 +944,10 @@ void Creature::SaveToDB()
void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{
// update in loaded data
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_DBTableGuid);
if (!m_spawnId)
m_spawnId = sObjectMgr->GenerateCreatureSpawnId();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_spawnId);
uint32 displayId = GetNativeDisplayId();
uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
@@ -1005,13 +1014,13 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
SQLTransaction trans = WorldDatabase.BeginTransaction();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
uint8 index = 0;
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
@@ -1186,7 +1195,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const*
SetOriginalEntry(entry);
Object::_Create(guidlow, entry, (vehId || cinfo->VehicleId) ? HIGHGUID_VEHICLE : HIGHGUID_UNIT);
Object::_Create(guidlow, entry, (vehId || cinfo->VehicleId) ? HighGuid::Vehicle : HighGuid::Unit);
if (!UpdateEntry(entry, data))
return false;
@@ -1208,26 +1217,18 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const*
return true;
}
bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
bool Creature::LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap)
{
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
CreatureData const* data = sObjectMgr->GetCreatureData(spawnId);
if (!data)
{
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) not found in table `creature`, can't load. ", guid);
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) not found in table `creature`, can't load. ", spawnId);
return false;
}
m_DBTableGuid = guid;
if (map->GetInstanceId() == 0)
{
if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guid)))
return false;
}
else
guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT);
if (!Create(guid, map, data->phaseMask, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
m_spawnId = spawnId;
if (!Create(map->GenerateLowGuid<HighGuid::Unit>(), map, data->phaseMask, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
return false;
//We should set first home position, because then AI calls home movement
@@ -1238,7 +1239,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
m_respawnDelay = data->spawntimesecs;
m_deathState = ALIVE;
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_DBTableGuid);
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId);
if (m_respawnTime) // respawn on Update
{
m_deathState = DEAD;
@@ -1333,31 +1334,31 @@ bool Creature::hasInvolvedQuest(uint32 quest_id) const
void Creature::DeleteFromDB()
{
if (!m_DBTableGuid)
if (!m_spawnId)
{
TC_LOG_ERROR("entities.unit", "Trying to delete not saved creature! LowGUID: %u, Entry: %u", GetGUIDLow(), GetEntry());
TC_LOG_ERROR("entities.unit", "Trying to delete not saved creature! LowGUID: %u, Entry: %u", GetGUID().GetCounter(), GetEntry());
return;
}
GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid);
sObjectMgr->DeleteCreatureData(m_DBTableGuid);
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
sObjectMgr->DeleteCreatureData(m_spawnId);
SQLTransaction trans = WorldDatabase.BeginTransaction();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
@@ -1552,8 +1553,8 @@ void Creature::Respawn(bool force)
if (getDeathState() == DEAD)
{
if (m_DBTableGuid)
GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid);
if (m_spawnId)
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
TC_LOG_DEBUG("entities.unit", "Respawning creature %s (%s)",
GetName().c_str(), GetGUID().ToString().c_str());
@@ -1586,9 +1587,9 @@ void Creature::Respawn(bool force)
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
}
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<Creature>(GetSpawnId()) : 0;
if (poolid)
sPoolMgr->UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<Creature>(poolid, GetSpawnId());
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
@@ -1809,7 +1810,7 @@ Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
if (dist > MAX_VISIBILITY_DISTANCE)
{
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) SelectNearestTargetInAttackDistance called with dist > MAX_VISIBILITY_DISTANCE. Distance set to ATTACK_DISTANCE.", GetGUIDLow(), GetEntry());
TC_LOG_ERROR("entities.unit", "Creature (GUID: %u Entry: %u) SelectNearestTargetInAttackDistance called with dist > MAX_VISIBILITY_DISTANCE. Distance set to ATTACK_DISTANCE.", GetGUID().GetCounter(), GetEntry());
dist = ATTACK_DISTANCE;
}
@@ -1992,10 +1993,10 @@ bool Creature::_IsTargetAcceptable(const Unit* target) const
void Creature::SaveRespawnTime()
{
if (IsSummon() || !m_DBTableGuid || (m_creatureData && !m_creatureData->dbData))
if (IsSummon() || !m_spawnId || (m_creatureData && !m_creatureData->dbData))
return;
GetMap()->SaveCreatureRespawnTime(m_DBTableGuid, m_respawnTime);
GetMap()->SaveCreatureRespawnTime(m_spawnId, m_respawnTime);
}
// this should not be called by petAI or
@@ -2027,9 +2028,9 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool /*force*/) const
CreatureAddon const* Creature::GetCreatureAddon() const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_DBTableGuid))
if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_spawnId))
return addon;
}
@@ -2098,7 +2099,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr);
if (!AdditionalSpellInfo)
{
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUID().GetCounter(), GetEntry(), *itr);
continue;
}
@@ -2106,13 +2107,13 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (HasAura(*itr))
{
if (!reload)
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetDBTableGUIDLow(), GetEntry(), *itr);
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetSpawnId(), GetEntry(), *itr);
continue;
}
AddAura(*itr, this);
TC_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
TC_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUID().GetCounter(), GetEntry());
}
}
@@ -2187,9 +2188,9 @@ time_t Creature::GetRespawnTimeEx() const
void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (CreatureData const* data = sObjectMgr->GetCreatureData(GetDBTableGUIDLow()))
if (CreatureData const* data = sObjectMgr->GetCreatureData(GetSpawnId()))
{
x = data->posX;
y = data->posY;
@@ -2553,7 +2554,7 @@ void Creature::SetTextRepeatId(uint8 textGroup, uint8 id)
if (std::find(repeats.begin(), repeats.end(), id) == repeats.end())
repeats.push_back(id);
else
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), GetName().c_str(), GetGUIDLow(), GetEntry(), uint32(id));
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), GetName().c_str(), GetGUID().GetCounter(), GetEntry(), uint32(id));
}
CreatureTextRepeatIds Creature::GetTextRepeatGroup(uint8 textGroup)
+4 -4
View File
@@ -443,7 +443,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void SelectLevel();
void LoadEquipment(int8 id = 1, bool force = false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
uint32 GetSpawnId() const { return m_spawnId; }
void Update(uint32 time) override; // overwrited Unit::Update
void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr, float* dist =nullptr) const;
@@ -535,8 +535,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void setDeathState(DeathState s) override; // override virtual Unit::setDeathState
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); }
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true);
bool LoadFromDB(uint32 spawnId, Map* map) { return LoadCreatureFromDB(spawnId, map, false); }
bool LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap = true);
void SaveToDB();
// overriden in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
@@ -700,7 +700,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void RegenerateHealth();
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
uint32 m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid
uint8 m_equipmentId;
int8 m_originalEquipmentId; // can be -1
@@ -41,7 +41,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member)
//Add member to an existing group
if (itr != map->CreatureGroupHolder.end())
{
TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUIDLow(), member->GetInstanceId());
TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUID().GetCounter(), member->GetInstanceId());
itr->second->AddMember(member);
}
//Create new group
@@ -56,7 +56,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member)
void FormationMgr::RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
{
TC_LOG_DEBUG("entities.unit", "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
TC_LOG_DEBUG("entities.unit", "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetSpawnId());
group->RemoveMember(member);
if (group->isEmpty())
@@ -142,16 +142,16 @@ void FormationMgr::LoadCreatureFormations()
void CreatureGroup::AddMember(Creature* member)
{
TC_LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());
TC_LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUID().GetCounter());
//Check if it is a leader
if (member->GetDBTableGUIDLow() == m_groupID)
if (member->GetSpawnId() == m_groupID)
{
TC_LOG_DEBUG("entities.unit", "Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow());
TC_LOG_DEBUG("entities.unit", "Unit GUID: %u is formation leader. Adding group.", member->GetGUID().GetCounter());
m_leader = member;
}
m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetSpawnId())->second;
member->SetFormation(this);
}
@@ -166,7 +166,7 @@ void CreatureGroup::RemoveMember(Creature* member)
void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
{
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetSpawnId()]->groupAI;
if (!groupAI)
return;
@@ -205,7 +205,7 @@ void CreatureGroup::FormationReset(bool dismiss)
itr->first->GetMotionMaster()->Initialize();
else
itr->first->GetMotionMaster()->MoveIdle();
TC_LOG_DEBUG("entities.unit", "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUIDLow());
TC_LOG_DEBUG("entities.unit", "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUID().GetCounter());
}
}
m_Formed = !dismiss;
@@ -51,7 +51,7 @@ void DynamicObject::AddToWorld()
///- Register the dynamicObject for guid lookup and for caster
if (!IsInWorld())
{
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<DynamicObject>(GetGUID(), this);
WorldObject::AddToWorld();
BindToCaster();
}
@@ -74,7 +74,7 @@ void DynamicObject::RemoveFromWorld()
UnbindFromCaster();
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<DynamicObject>(GetGUID());
}
}
@@ -88,7 +88,7 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, SpellInfo
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
WorldObject::_Create(guidlow, HighGuid::DynamicObject, caster->GetPhaseMask());
SetEntry(spell->Id);
SetObjectScale(1);
@@ -52,7 +52,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_goInfo = NULL;
m_goData = NULL;
m_DBTableGuid = 0;
m_spawnId = 0;
m_rotation = 0;
m_lootRecipientGroup = 0;
@@ -117,7 +117,7 @@ void GameObject::RemoveFromOwner()
// This happens when a mage portal is despawned after the caster changes map (for example using the portal)
TC_LOG_DEBUG("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());
GetGUID().GetCounter(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
SetOwnerGUID(ObjectGuid::Empty);
}
@@ -129,7 +129,9 @@ void GameObject::AddToWorld()
if (m_zoneScript)
m_zoneScript->OnGameObjectCreate(this);
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<GameObject>(GetGUID(), this);
if (m_spawnId)
GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport());
@@ -159,7 +161,10 @@ void GameObject::RemoveFromWorld()
if (GetMap()->ContainsGameObjectModel(*m_model))
GetMap()->RemoveGameObjectModel(*m_model);
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
if (m_spawnId)
Trinity::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
GetMap()->GetObjectsStore().Remove<GameObject>(GetGUID());
}
}
@@ -200,7 +205,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 /*phase
if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT)
m_updateFlag |= UPDATEFLAG_TRANSPORT;
Object::_Create(guidlow, goinfo->entry, HIGHGUID_GAMEOBJECT);
Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject);
m_goInfo = goinfo;
@@ -291,7 +296,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 /*phase
break;
}
if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(guidlow))
if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId()))
{
if (addon->InvisibilityValue)
{
@@ -420,7 +425,7 @@ void GameObject::Update(uint32 diff)
time_t now = time(NULL);
if (m_respawnTime <= now) // timer expired
{
ObjectGuid dbtableHighGuid(HIGHGUID_GAMEOBJECT, GetEntry(), m_DBTableGuid);
ObjectGuid dbtableHighGuid(HighGuid::GameObject, GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (linkedRespawntime) // Can't respawn, the master is dead
{
@@ -476,9 +481,9 @@ void GameObject::Update(uint32 diff)
}
// Respawn timer
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
if (poolid)
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
else
GetMap()->AddToMap(this);
}
@@ -716,9 +721,9 @@ void GameObject::Delete()
SetGoState(GO_STATE_READY);
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
if (poolid)
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
else
AddObjectToRemoveList();
}
@@ -767,7 +772,7 @@ void GameObject::SaveToDB()
{
// this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise
GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid);
GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId);
if (!data)
{
TC_LOG_ERROR("misc", "GameObject::SaveToDB failed, cannot get gameobject data!");
@@ -784,10 +789,10 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
if (!goI)
return;
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
if (!m_spawnId)
m_spawnId = GetGUID().GetCounter();
// update in loaded data (changing data only in this place)
GameObjectData& data = sObjectMgr->NewGOData(m_DBTableGuid);
GameObjectData& data = sObjectMgr->NewGOData(m_spawnId);
// data->guid = guid must not be updated at save
data.id = GetEntry();
@@ -813,11 +818,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
uint8 index = 0;
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
@@ -865,8 +870,9 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
GOState go_state = data->go_state;
uint32 artKit = data->artKit;
m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
m_spawnId = guid;
if (map->GetInstanceId() != 0)
guid = map->GenerateLowGuid<HighGuid::GameObject>();
if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
return false;
@@ -894,13 +900,13 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
else
{
m_respawnDelayTime = data->spawntimesecs;
m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid);
m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId);
// ready to respawn
if (m_respawnTime && m_respawnTime <= time(NULL))
{
m_respawnTime = 0;
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
}
}
}
@@ -921,18 +927,18 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
void GameObject::DeleteFromDB()
{
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
sObjectMgr->DeleteGOData(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
sObjectMgr->DeleteGOData(m_spawnId);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
WorldDatabase.Execute(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
WorldDatabase.Execute(stmt);
}
@@ -1000,7 +1006,7 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime()
{
if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
GetMap()->SaveGORespawnTime(m_spawnId, m_respawnTime);
}
bool GameObject::IsNeverVisible() const
@@ -1057,7 +1063,7 @@ void GameObject::Respawn()
if (m_spawnedByDefault && m_respawnTime > 0)
{
m_respawnTime = time(NULL);
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
}
}
@@ -1182,7 +1188,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
void GameObject::SetGoArtKit(uint8 kit)
{
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid));
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_spawnId));
if (data)
data->artKit = kit;
}
@@ -1375,7 +1381,7 @@ void GameObject::Use(Unit* user)
if (info->goober.eventId)
{
TC_LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
TC_LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetSpawnId());
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
EventInform(info->goober.eventId, user);
}
@@ -1781,7 +1787,7 @@ void GameObject::Use(Unit* user)
default:
if (GetGoType() >= MAX_GAMEOBJECT_TYPE)
TC_LOG_ERROR("misc", "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)",
user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType());
user->GetTypeId(), user->GetGUID().GetCounter(), user->GetName().c_str(), GetGUID().GetCounter(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType());
break;
}
@@ -2367,9 +2373,9 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow()))
if (GameObjectData const* data = sObjectMgr->GetGOData(GetSpawnId()))
{
x = data->posX;
y = data->posY;
@@ -676,7 +676,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
bool IsDynTransport() const;
bool IsDestructibleBuilding() const;
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
uint32 GetSpawnId() const { return m_spawnId; }
void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
@@ -884,7 +884,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
ChairSlotAndUser ChairListSlots;
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
uint32 m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid
GameObjectTemplate const* m_goInfo;
GameObjectData const* m_goData;
GameObjectValue m_goValue;
@@ -76,7 +76,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
return false;
Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
Object::_Create(guidlow, 0, HighGuid::Container);
SetEntry(itemid);
SetObjectScale(1.0f);
+31 -19
View File
@@ -262,7 +262,7 @@ Item::Item()
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
{
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
Object::_Create(guidlow, 0, HighGuid::Item);
SetEntry(itemid);
SetObjectScale(1.0f);
@@ -322,7 +322,7 @@ void Item::SaveToDB(SQLTransaction& trans)
if (!isInTransaction)
trans = CharacterDatabase.BeginTransaction();
uint32 guid = GetGUIDLow();
uint32 guid = GetGUID().GetCounter();
switch (uState)
{
case ITEM_NEW:
@@ -410,7 +410,7 @@ bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
Object::_Create(guid, 0, HIGHGUID_ITEM);
Object::_Create(guid, 0, HighGuid::Item);
// Set entry, MUST be before proto check
SetEntry(entry);
@@ -425,8 +425,8 @@ bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32
SetOwnerGUID(owner_guid);
bool need_save = false; // need explicit save data at load fixes
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()));
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32()));
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();
@@ -494,7 +494,7 @@ void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromDB(SQLTransaction& trans)
{
DeleteFromDB(trans, GetGUIDLow());
DeleteFromDB(trans, GetGUID().GetCounter());
// Delete the items if this is a container
if (!loot.isLooted())
@@ -511,7 +511,7 @@ void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromInventoryDB(SQLTransaction& trans)
{
DeleteFromInventoryDB(trans, GetGUIDLow());
DeleteFromInventoryDB(trans, GetGUID().GetCounter());
}
ItemTemplate const* Item::GetTemplate() const
@@ -1042,7 +1042,7 @@ Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player)
ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
Item* item = NewItemOrBag(proto);
if (item->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), itemEntry, player))
if (item->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), itemEntry, player))
{
item->SetCount(count);
return item;
@@ -1082,7 +1082,7 @@ bool Item::IsBindedNotWith(Player const* player) const
return false;
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
if (allowedGUIDs.find(player->GetGUIDLow()) != allowedGUIDs.end())
if (allowedGUIDs.find(player->GetGUID().GetCounter()) != allowedGUIDs.end())
return false;
// BOA item case
@@ -1099,16 +1099,28 @@ void Item::BuildUpdate(UpdateDataMapType& data_map)
ClearUpdateMask(false);
}
void Item::AddToObjectUpdate()
{
if (Player* owner = GetOwner())
owner->GetMap()->AddUpdateObject(this);
}
void Item::RemoveFromObjectUpdate()
{
if (Player* owner = GetOwner())
owner->GetMap()->RemoveUpdateObject(this);
}
void Item::SaveRefundDataToDB()
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
stmt->setUInt32(1, GetRefundRecipient());
stmt->setUInt32(2, GetPaidMoney());
stmt->setUInt16(3, uint16(GetPaidExtendedCost()));
@@ -1122,7 +1134,7 @@ void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
if (trans)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
(*trans)->Append(stmt);
}
@@ -1201,7 +1213,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
allowedGUIDs.clear();
SetState(ITEM_CHANGED, currentOwner);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -1522,7 +1534,7 @@ void Item::ItemContainerSaveLootToDB()
if (loot.isLooted()) // no money and no loot
return;
uint32 container_id = GetGUIDLow();
uint32 container_id = GetGUID().GetCounter();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
loot.containerID = container_id; // Save this for when a LootItem is removed
@@ -1590,7 +1602,7 @@ bool Item::ItemContainerLoadLootFromDB()
// Default. If there are no records for this item then it will be rolled for in Player::SendLoot()
m_lootGenerated = false;
uint32 container_id = GetGUIDLow();
uint32 container_id = GetGUID().GetCounter();
// Save this for later use
loot.containerID = container_id;
@@ -1644,7 +1656,7 @@ bool Item::ItemContainerLoadLootFromDB()
// If container item is in a bag, add that player as an allowed looter
if (GetBagSlot())
loot_item.allowedGUIDs.insert(GetOwner()->GetGUIDLow());
loot_item.allowedGUIDs.insert(GetOwner()->GetGUID().GetCounter());
// Finally add the LootItem to the container
loot.items.push_back(loot_item);
@@ -1666,7 +1678,7 @@ bool Item::ItemContainerLoadLootFromDB()
void Item::ItemContainerDeleteLootItemsFromDB()
{
// Deletes items associated with an openable item from the DB
uint32 containerId = GetGUIDLow();
uint32 containerId = GetGUID().GetCounter();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS);
stmt->setUInt32(0, containerId);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
@@ -1677,7 +1689,7 @@ void Item::ItemContainerDeleteLootItemsFromDB()
void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID)
{
// Deletes a single item associated with an openable item from the DB
uint32 containerId = GetGUIDLow();
uint32 containerId = GetGUID().GetCounter();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM);
stmt->setUInt32(0, containerId);
stmt->setUInt32(1, itemID);
@@ -1689,7 +1701,7 @@ void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID)
void Item::ItemContainerDeleteLootMoneyFromDB()
{
// Deletes the money loot associated with an openable item from the DB
uint32 containerId = GetGUIDLow();
uint32 containerId = GetGUID().GetCounter();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY);
stmt->setUInt32(0, containerId);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
+2
View File
@@ -357,6 +357,8 @@ class Item : public Object
bool CheckSoulboundTradeExpire();
void BuildUpdate(UpdateDataMapType&) override;
void AddToObjectUpdate() override;
void RemoveFromObjectUpdate() override;
uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
+55 -88
View File
@@ -90,14 +90,12 @@ Object::~Object()
if (isType(TYPEMASK_ITEM))
TC_LOG_FATAL("misc", "Item slot %u", ((Item*)this)->GetSlot());
ASSERT(false);
RemoveFromWorld();
}
if (m_objectUpdated)
{
TC_LOG_FATAL("misc", "Object::~Object %s deleted but still in update list!!", GetGUID().ToString().c_str());
ASSERT(false);
sObjectAccessor->RemoveUpdateObject(this);
}
delete [] m_uint32Values;
@@ -142,7 +140,8 @@ void Object::AddToWorld()
m_inWorld = true;
// synchronize values mirror with values array (changes will send in updatecreate opcode any way
ClearUpdateMask(true);
ASSERT(!m_objectUpdated);
ClearUpdateMask(false);
}
void Object::RemoveFromWorld()
@@ -168,17 +167,17 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
if (target == this) // building packet for yourself
flags |= UPDATEFLAG_SELF;
switch (GetGUIDHigh())
switch (GetGUID().GetHigh())
{
case HIGHGUID_PLAYER:
case HIGHGUID_PET:
case HIGHGUID_CORPSE:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_AREATRIGGER:
case HighGuid::Player:
case HighGuid::Pet:
case HighGuid::Corpse:
case HighGuid::DynamicObject:
case HighGuid::AreaTrigger:
updateType = UPDATETYPE_CREATE_OBJECT2;
break;
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
case HighGuid::Unit:
case HighGuid::Vehicle:
{
if (TempSummon const* summon = ToUnit()->ToTempSummon())
if (summon->GetSummonerGUID().IsPlayer())
@@ -186,7 +185,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
break;
}
case HIGHGUID_GAMEOBJECT:
case HighGuid::GameObject:
{
if (ToGameObject()->GetOwnerGUID().IsPlayer())
updateType = UPDATETYPE_CREATE_OBJECT2;
@@ -692,6 +691,15 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
data->append(fieldBuffer);
}
void Object::AddToObjectUpdateIfNeeded()
{
if (m_inWorld && !m_objectUpdated)
{
AddToObjectUpdate();
m_objectUpdated = true;
}
}
void Object::ClearUpdateMask(bool remove)
{
_changesMask.Clear();
@@ -699,7 +707,7 @@ void Object::ClearUpdateMask(bool remove)
if (m_objectUpdated)
{
if (remove)
sObjectAccessor->RemoveUpdateObject(this);
RemoveFromObjectUpdate();
m_objectUpdated = false;
}
}
@@ -800,11 +808,7 @@ void Object::SetInt32Value(uint16 index, int32 value)
m_int32Values[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -817,11 +821,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
m_uint32Values[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -843,11 +843,7 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -860,11 +856,7 @@ bool Object::AddGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -882,11 +874,7 @@ bool Object::RemoveGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -903,11 +891,7 @@ void Object::SetFloatValue(uint16 index, float value)
m_floatValues[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -927,11 +911,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
m_uint32Values[index] |= uint32(uint32(value) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -951,11 +931,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
m_uint32Values[index] |= uint32(uint32(value) << (offset * 16));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -968,11 +944,7 @@ void Object::SetGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1042,11 +1014,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
m_uint32Values[index] = newval;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1063,11 +1031,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
m_uint32Values[index] = newval;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1107,11 +1071,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1130,11 +1090,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1349,7 +1305,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
float sizefactor = GetObjectSize() + obj->GetObjectSize();
float maxdist = dist2compare + sizefactor;
if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == GetTransport()->GetGUIDLow())
if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetGUID().GetCounter() == GetTransport()->GetGUID().GetCounter())
{
float dtx = m_movementInfo.transport.pos.m_positionX - obj->m_movementInfo.transport.pos.m_positionX;
float dty = m_movementInfo.transport.pos.m_positionY - obj->m_movementInfo.transport.pos.m_positionY;
@@ -1931,11 +1887,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
void Object::ForceValuesUpdateAtIndex(uint32 i)
{
_changesMask.SetBit(i);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
void WorldObject::SendMessageToSet(WorldPacket* data, bool self)
@@ -2006,7 +1958,7 @@ void WorldObject::AddObjectToRemoveList()
Map* map = FindMap();
if (!map)
{
TC_LOG_ERROR("misc", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
TC_LOG_ERROR("misc", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUID().GetCounter(), GetMapId());
return;
}
@@ -2083,7 +2035,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
break;
}
if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
{
delete summon;
return NULL;
@@ -2140,6 +2092,11 @@ void WorldObject::SetZoneScript()
}
}
void WorldObject::ClearZoneScript()
{
m_zoneScript = nullptr;
}
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const
{
if (Map* map = FindMap())
@@ -2180,7 +2137,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
Map* map = GetMap();
GameObject* go = new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, GetPhaseMask(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
{
delete go;
return NULL;
@@ -2466,7 +2423,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
if (!Trinity::IsValidMapCoord(destx, desty, pos.m_positionZ))
{
TC_LOG_FATAL("misc", "WorldObject::MovePosition: Object (TypeId: %u Entry: %u GUID: %u) has invalid coordinates X: %f and Y: %f were passed!",
GetTypeId(), GetEntry(), GetGUIDLow(), destx, desty);
GetTypeId(), GetEntry(), GetGUID().GetCounter(), destx, desty);
return;
}
@@ -2889,6 +2846,16 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
ClearUpdateMask(false);
}
void WorldObject::AddToObjectUpdate()
{
GetMap()->AddUpdateObject(this);
}
void WorldObject::RemoveFromObjectUpdate()
{
GetMap()->RemoveUpdateObject(this);
}
ObjectGuid WorldObject::GetTransGUID() const
{
if (GetTransport())
+8 -3
View File
@@ -103,9 +103,6 @@ class Object
virtual void RemoveFromWorld();
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); }
@@ -222,6 +219,10 @@ class Object
uint16 m_objectType;
virtual void AddToObjectUpdate() = 0;
virtual void RemoveFromObjectUpdate() = 0;
void AddToObjectUpdateIfNeeded();
TypeID m_objectTypeId;
uint16 m_updateFlag;
@@ -569,6 +570,7 @@ class WorldObject : public Object, public WorldLocation
Map const* GetBaseMap() const;
void SetZoneScript();
void ClearZoneScript();
ZoneScript* GetZoneScript() const { return m_zoneScript; }
TempSummon* SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
@@ -589,6 +591,9 @@ class WorldObject : public Object, public WorldLocation
virtual void UpdateObjectVisibility(bool forced = true);
void BuildUpdate(UpdateDataMapType&) override;
void AddToObjectUpdate() override;
void RemoveFromObjectUpdate() override;
//relocation and visibility system functions
void AddToNotify(uint16 f) { m_notifyflags |= f;}
bool isNeedNotify(uint16 f) const { return (m_notifyflags & f) != 0; }
+27 -37
View File
@@ -28,21 +28,21 @@ 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";
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>";
}
@@ -60,15 +60,14 @@ std::string ObjectGuid::ToString() const
return str.str();
}
template<HighGuid high>
uint32 ObjectGuidGenerator<high>::Generate()
ObjectGuid ObjectGuid::Global(HighGuid type, LowType counter)
{
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++;
return ObjectGuid(type, counter);
}
ObjectGuid ObjectGuid::MapSpecific(HighGuid type, uint32 entry, LowType counter)
{
return ObjectGuid(type, entry, counter);
}
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
@@ -95,17 +94,8 @@ ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
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();
void ObjectGuidGeneratorBase::HandleCounterOverflow(HighGuid high)
{
TC_LOG_ERROR("misc", "%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high));
World::StopNow(ERROR_EXIT_CODE);
}
+137 -72
View File
@@ -22,6 +22,7 @@
#include "Common.h"
#include "ByteBuffer.h"
#include <type_traits>
#include <functional>
#include <unordered_set>
@@ -54,26 +55,67 @@ enum TypeMask
TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum HighGuid
enum class 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
Item = 0x400, // blizz 4000
Container = 0x400, // blizz 4000
Player = 0x000, // blizz 0000
GameObject = 0xF11, // blizz F110
Transport = 0xF12, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
Unit = 0xF13, // blizz F130
Pet = 0xF14, // blizz F140
Vehicle = 0xF15, // blizz F550
DynamicObject = 0xF10, // blizz F100
Corpse = 0xF101, // blizz F100
AreaTrigger = 0xF102,
BattleGround = 0x1F1,
Mo_Transport = 0x1FC, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
Instance = 0x1F4, // blizz 1F40
Group = 0x1F5,
Guild = 0x1FF
};
template<HighGuid guid>
struct ObjectGuidTraits
{
static bool const Global = false;
static bool const MapSpecific = false;
};
#define GUID_TRAIT_GLOBAL(highguid) \
template<> struct ObjectGuidTraits<highguid> \
{ \
static bool const Global = true; \
static bool const MapSpecific = false; \
}
#define GUID_TRAIT_MAP_SPECIFIC(highguid) \
template<> struct ObjectGuidTraits<highguid> \
{ \
static bool const Global = false; \
static bool const MapSpecific = true; \
}
GUID_TRAIT_GLOBAL(HighGuid::Mo_Transport);
GUID_TRAIT_GLOBAL(HighGuid::Group);
GUID_TRAIT_GLOBAL(HighGuid::Instance);
GUID_TRAIT_GLOBAL(HighGuid::BattleGround);
GUID_TRAIT_GLOBAL(HighGuid::Player);
GUID_TRAIT_GLOBAL(HighGuid::Item);
GUID_TRAIT_GLOBAL(HighGuid::Transport);
GUID_TRAIT_GLOBAL(HighGuid::Guild);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Unit);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Vehicle);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Pet);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::GameObject);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::DynamicObject);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Corpse);
GUID_TRAIT_MAP_SPECIFIC(HighGuid::AreaTrigger);
#undef GUID_TRAIT_GLOBAL
#undef GUID_TRAIT_REALM_SPECIFIC
#undef GUID_TRAIT_MAP_SPECIFIC
class ObjectGuid;
class PackedGuid;
@@ -90,10 +132,16 @@ class ObjectGuid
typedef uint32 LowType;
template<HighGuid type>
static typename std::enable_if<ObjectGuidTraits<type>::Global, ObjectGuid>::type Create(LowType counter) { return Global(type, counter); }
template<HighGuid type>
static typename std::enable_if<ObjectGuidTraits<type>::MapSpecific, ObjectGuid>::type Create(uint32 entry, LowType counter) { return MapSpecific(type, entry, counter); }
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) << 32) | (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; }
ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) { _data._guid = counter ? uint64(counter) | (uint64(entry) << 32) | (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; }
ObjectGuid(ObjectGuid const& r) : _data(r._data) { }
ObjectGuid(ObjectGuid&& r) : _data(r._data) { }
@@ -111,8 +159,8 @@ class ObjectGuid
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));
HighGuid temp = static_cast<HighGuid>((uint64(_data._guid) >> 48) & 0x0000FFFF);
return HighGuid((temp == HighGuid::Corpse || temp == HighGuid::AreaTrigger) ? temp : HighGuid(((uint32)temp >> 4) & 0x00000FFF));
}
uint32 GetEntry() const { return HasEntry() ? uint32((_data._guid >> 32) & UI64LIT(0x00000000000FFFFF)) : 0; }
uint32 GetCounter() const
@@ -140,48 +188,48 @@ class ObjectGuid
}
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 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 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 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; }
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;
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;
case HighGuid::Instance:
case HighGuid::BattleGround:
case HighGuid::Group:
case HighGuid::Guild:
default: return TYPEID_OBJECT;
}
}
@@ -201,19 +249,19 @@ class ObjectGuid
{
switch (high)
{
case HIGHGUID_ITEM:
case HIGHGUID_PLAYER:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_CORPSE:
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_INSTANCE:
case HIGHGUID_GROUP:
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:
case HighGuid::GameObject:
case HighGuid::Transport:
case HighGuid::Unit:
case HighGuid::Pet:
case HighGuid::Vehicle:
default:
return true;
}
@@ -221,6 +269,9 @@ class ObjectGuid
bool HasEntry() const { return HasEntry(GetHigh()); }
static ObjectGuid Global(HighGuid type, LowType counter);
static ObjectGuid MapSpecific(HighGuid type, uint32 entry, LowType counter);
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
@@ -260,18 +311,32 @@ class PackedGuid
ByteBuffer _packedGuid;
};
template<HighGuid high>
class ObjectGuidGenerator
class ObjectGuidGeneratorBase
{
public:
explicit ObjectGuidGenerator(uint32 start = 1) : _nextGuid(start) { }
ObjectGuidGeneratorBase(ObjectGuid::LowType start = 1) : _nextGuid(start) { }
void Set(uint32 val) { _nextGuid = val; }
uint32 Generate();
uint32 GetNextAfterMaxUsed() const { return _nextGuid; }
virtual void Set(ObjectGuid::LowType val) { _nextGuid = val; }
virtual ObjectGuid::LowType Generate() = 0;
ObjectGuid::LowType GetNextAfterMaxUsed() const { return _nextGuid; }
private:
uint32 _nextGuid;
protected:
static void HandleCounterOverflow(HighGuid high);
ObjectGuid::LowType _nextGuid;
};
template<HighGuid high>
class ObjectGuidGenerator : public ObjectGuidGeneratorBase
{
public:
explicit ObjectGuidGenerator(ObjectGuid::LowType start = 1) : ObjectGuidGeneratorBase(start) { }
ObjectGuid::LowType Generate() override
{
if (_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1)
HandleCounterOverflow(high);
return _nextGuid++;
}
};
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
+15 -15
View File
@@ -67,7 +67,7 @@ void Pet::AddToWorld()
if (!IsInWorld())
{
///- Register the pet for guid lookup
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Pet>(GetGUID(), this);
Unit::AddToWorld();
AIM_Initialize();
}
@@ -91,7 +91,7 @@ void Pet::RemoveFromWorld()
{
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<Pet>(GetGUID());
}
}
@@ -99,7 +99,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
{
m_loading = true;
uint32 ownerid = owner->GetGUIDLow();
uint32 ownerid = owner->GetGUID().GetCounter();
PreparedStatement* stmt;
PreparedQueryResult result;
@@ -175,7 +175,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
}
Map* map = owner->GetMap();
uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET);
uint32 guid = map->GenerateLowGuid<HighGuid::Pet>();
if (!Create(guid, map, petEntry, petId))
return false;
@@ -194,7 +194,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY());
return false;
}
@@ -249,7 +249,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY());
return false;
}
@@ -334,7 +334,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
CleanupActionBar(); // remove unknown spells from action bar after load
TC_LOG_DEBUG("entities.pet", "New Pet has guid %u", GetGUIDLow());
TC_LOG_DEBUG("entities.pet", "New Pet has guid %u", GetGUID().GetCounter());
owner->PetSpellInitialize();
@@ -346,7 +346,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
if (getPetType() == HUNTER_PET)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_DECLINED_NAME);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt32(1, GetCharmInfo()->GetPetNumber());
result = CharacterDatabase.Query(stmt);
@@ -733,7 +733,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY());
return false;
}
@@ -770,7 +770,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner)
bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map)
{
TC_LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed");
uint32 guid=sObjectMgr->GenerateLowGuid(HIGHGUID_PET);
uint32 guid = map->GenerateLowGuid<HighGuid::Pet>();
uint32 petId = sObjectMgr->GeneratePetNumber();
if (!Create(guid, map, cinfo->Entry, petId))
return false;
@@ -1146,7 +1146,7 @@ void Pet::_SaveSpells(SQLTransaction& trans)
void Pet::_LoadAuras(uint32 timediff)
{
TC_LOG_DEBUG("entities.pet", "Loading auras for pet %u", GetGUIDLow());
TC_LOG_DEBUG("entities.pet", "Loading auras for pet %u", GetGUID().GetCounter());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_AURA);
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
@@ -1642,7 +1642,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* onlinePet /*= NULL*/)
uint32 exceptPetNumber = onlinePet ? onlinePet->GetCharmInfo()->GetPetNumber() : 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt32(1, exceptPetNumber);
PreparedQueryResult resultPets = CharacterDatabase.Query(stmt);
@@ -1651,7 +1651,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* onlinePet /*= NULL*/)
return;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_LIST);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt32(1, exceptPetNumber);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -1804,9 +1804,9 @@ bool Pet::Create(uint32 guidlow, Map* map, uint32 Entry, uint32 petId)
ASSERT(map);
SetMap(map);
Object::_Create(guidlow, petId, HIGHGUID_PET);
Object::_Create(guidlow, petId, HighGuid::Pet);
m_DBTableGuid = guidlow;
m_spawnId = guidlow;
m_originalEntry = Entry;
if (!InitEntry(Entry))
File diff suppressed because it is too large. Load diff
@@ -206,7 +206,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri
friendInfo.Level = 0;
friendInfo.Class = 0;
Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friendGUID));
Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, friendGUID));
if (!target)
return;
@@ -291,10 +291,10 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
AccountTypes gmSecLevel = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
{
PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUIDLow());
PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUID().GetCounter());
if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
{
Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, 0, itr->first));
Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, 0, itr->first));
if (!target)
continue;
@@ -54,7 +54,7 @@ bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, floa
return false;
}
Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT);
Object::_Create(guidlow, 0, HighGuid::Mo_Transport);
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
@@ -309,7 +309,7 @@ Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data)
if (!creature->IsPositionValid())
{
TC_LOG_ERROR("entities.transport", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
TC_LOG_ERROR("entities.transport", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)",creature->GetGUID().GetCounter(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
delete creature;
return NULL;
}
@@ -359,7 +359,7 @@ GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data
if (!go->IsPositionValid())
{
TC_LOG_ERROR("entities.transport", "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUIDLow(), go->GetEntry(), go->GetPositionX(), go->GetPositionY());
TC_LOG_ERROR("entities.transport", "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUID().GetCounter(), go->GetEntry(), go->GetPositionX(), go->GetPositionY());
delete go;
return NULL;
}
@@ -458,7 +458,7 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
pos.GetPosition(x, y, z, o);
CalculatePassengerPosition(x, y, z, &o);
if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, 0, entry, x, y, z, o, nullptr, vehId))
if (!summon->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, 0, entry, x, y, z, o, nullptr, vehId))
{
delete summon;
return NULL;
+15 -15
View File
@@ -825,7 +825,7 @@ void Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo
{
if (!spellInfo)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
return;
}
@@ -853,7 +853,7 @@ void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
return;
}
@@ -903,7 +903,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit*
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
return;
}
SpellCastTargets targets;
@@ -917,7 +917,7 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
return;
}
SpellCastTargets targets;
@@ -931,7 +931,7 @@ void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castI
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
return;
}
SpellCastTargets targets;
@@ -1878,10 +1878,10 @@ void Unit::AttackerStateUpdate (Unit* victim, WeaponAttackType attType, bool ext
if (GetTypeId() == TYPEID_PLAYER)
TC_LOG_DEBUG("entities.unit", "AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
GetGUID().GetCounter(), victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
else
TC_LOG_DEBUG("entities.unit", "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
GetGUID().GetCounter(), victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
}
}
@@ -2150,9 +2150,9 @@ void Unit::SendMeleeAttackStop(Unit* victim)
TC_LOG_DEBUG("entities.unit", "WORLD: Sent SMSG_ATTACKSTOP");
if (victim)
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().GetCounter(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUID().GetCounter());
else
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow());
TC_LOG_DEBUG("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().GetCounter());
}
bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType /*attackType*/)
@@ -3956,7 +3956,7 @@ void Unit::DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime)
// update for out of range group members (on 1 slot use)
aura->SetNeedClientUpdateForTargets();
TC_LOG_DEBUG("spells", "Aura %u partially interrupted on unit %u, new duration: %u ms", aura->GetId(), GetGUIDLow(), aura->GetDuration());
TC_LOG_DEBUG("spells", "Aura %u partially interrupted on unit %u, new duration: %u ms", aura->GetId(), GetGUID().GetCounter(), aura->GetDuration());
}
}
}
@@ -14231,11 +14231,11 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
ASSERT(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
ASSERT((type == CHARM_TYPE_VEHICLE) == IsVehicle());
TC_LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (GUID %u), charmed %u (GUID %u), type %u.", charmer->GetEntry(), charmer->GetGUIDLow(), GetEntry(), GetGUIDLow(), uint32(type));
TC_LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (GUID %u), charmed %u (GUID %u), type %u.", charmer->GetEntry(), charmer->GetGUID().GetCounter(), GetEntry(), GetGUID().GetCounter(), uint32(type));
if (this == charmer)
{
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Unit %u (GUID %u) is trying to charm itself!", GetEntry(), GetGUIDLow());
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Unit %u (GUID %u) is trying to charm itself!", GetEntry(), GetGUID().GetCounter());
return false;
}
@@ -14244,14 +14244,14 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetTransport())
{
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), GetGUIDLow());
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), GetGUID().GetCounter());
return false;
}
// Already charmed
if (GetCharmerGUID())
{
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) has already been charmed but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUIDLow(), charmer->GetEntry(), charmer->GetGUIDLow());
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) has already been charmed but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUID().GetCounter(), charmer->GetEntry(), charmer->GetGUID().GetCounter());
return false;
}
@@ -14278,7 +14278,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
// StopCastingCharm may remove a possessed pet?
if (!IsInWorld())
{
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) is not in world but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUIDLow(), charmer->GetEntry(), charmer->GetGUIDLow());
TC_LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) is not in world but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUID().GetCounter(), charmer->GetEntry(), charmer->GetGUID().GetCounter());
return false;
}
+13 -13
View File
@@ -115,12 +115,12 @@ void Vehicle::Uninstall()
if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
{
TC_LOG_ERROR("entities.vehicle", "Vehicle GuidLow: %u, Entry: %u attempts to uninstall, but already has STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry());
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().GetCounter(), _me->GetEntry());
return;
}
_status = STATUS_UNINSTALLING;
TC_LOG_DEBUG("entities.vehicle", "Vehicle::Uninstall Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow());
TC_LOG_DEBUG("entities.vehicle", "Vehicle::Uninstall Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUID().GetCounter());
RemoveAllPassengers();
if (GetBase()->GetTypeId() == TYPEID_UNIT)
@@ -143,7 +143,7 @@ void Vehicle::Reset(bool evading /*= false*/)
if (GetBase()->GetTypeId() != TYPEID_UNIT)
return;
TC_LOG_DEBUG("entities.vehicle", "Vehicle::Reset (Entry: %u, GuidLow: %u, DBGuid: %u)", GetCreatureEntry(), _me->GetGUIDLow(), _me->ToCreature()->GetDBTableGUIDLow());
TC_LOG_DEBUG("entities.vehicle", "Vehicle::Reset (Entry: %u, GuidLow: %u, DBGuid: %u)", GetCreatureEntry(), _me->GetGUID().GetCounter(), _me->ToCreature()->GetSpawnId());
ApplyAllImmunities();
InstallAllAccessories(evading);
@@ -221,7 +221,7 @@ void Vehicle::ApplyAllImmunities()
void Vehicle::RemoveAllPassengers()
{
TC_LOG_DEBUG("entities.vehicle", "Vehicle::RemoveAllPassengers. Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow());
TC_LOG_DEBUG("entities.vehicle", "Vehicle::RemoveAllPassengers. Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUID().GetCounter());
/// Setting to_Abort to true will cause @VehicleJoinEvent::Abort to be executed on next @Unit::UpdateEvents call
/// This will properly "reset" the pending join process for the passenger.
@@ -358,13 +358,13 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
if (_status == STATUS_UNINSTALLING)
{
TC_LOG_ERROR("entities.vehicle", "Vehicle (GuidLow: %u, DB GUID: %u, Entry: %u) attempts to install accessory (Entry: %u) on seat %d with STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(),
(_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : _me->GetGUIDLow()), GetCreatureEntry(), entry, (int32)seatId);
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().GetCounter(),
(_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetSpawnId() : _me->GetGUID().GetCounter()), GetCreatureEntry(), entry, (int32)seatId);
return;
}
TC_LOG_DEBUG("entities.vehicle", "Vehicle (GuidLow: %u, DB Guid: %u, Entry %u): installing accessory (Entry: %u) on seat: %d",
_me->GetGUIDLow(), (_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : _me->GetGUIDLow()), GetCreatureEntry(),
_me->GetGUID().GetCounter(), (_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetSpawnId() : _me->GetGUID().GetCounter()), GetCreatureEntry(),
entry, (int32)seatId);
TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime);
@@ -399,13 +399,13 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
if (_status == STATUS_UNINSTALLING)
{
TC_LOG_ERROR("entities.vehicle", "Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %d",
unit->GetGUIDLow(), unit->GetEntry(), _me->GetGUIDLow(), _me->GetEntry(), (int32)seatId);
unit->GetGUID().GetCounter(), unit->GetEntry(), _me->GetGUID().GetCounter(), _me->GetEntry(), (int32)seatId);
return false;
}
TC_LOG_DEBUG("entities.vehicle", "Unit %s scheduling enter vehicle (entry: %u, vehicleId: %u, guid: %u (dbguid: %u) on seat %d",
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(),
(_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : 0), (int32)seatId);
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().GetCounter(),
(_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetSpawnId() : 0), (int32)seatId);
// The seat selection code may kick other passengers off the vehicle.
// While the validity of the following may be arguable, it is possible that when such a passenger
@@ -474,7 +474,7 @@ Vehicle* Vehicle::RemovePassenger(Unit* unit)
ASSERT(seat != Seats.end());
TC_LOG_DEBUG("entities.vehicle", "Unit %s exit vehicle entry %u id %u dbguid %u seat %d",
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first);
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().GetCounter(), (int32)seat->first);
if (seat->second.SeatInfo->CanEnterOrExit() && ++UsableSeatNum)
_me->SetFlag(UNIT_NPC_FLAGS, (_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
@@ -847,7 +847,7 @@ void VehicleJoinEvent::Abort(uint64)
if (Target)
{
TC_LOG_DEBUG("entities.vehicle", "Passenger GuidLow: %u, Entry: %u, board on vehicle GuidLow: %u, Entry: %u SeatId: %d cancelled",
Passenger->GetGUIDLow(), Passenger->GetEntry(), Target->GetBase()->GetGUIDLow(), Target->GetBase()->GetEntry(), (int32)Seat->first);
Passenger->GetGUID().GetCounter(), Passenger->GetEntry(), Target->GetBase()->GetGUID().GetCounter(), Target->GetBase()->GetEntry(), (int32)Seat->first);
/// @SPELL_AURA_CONTROL_VEHICLE auras can be applied even when the passenger is not (yet) on the vehicle.
/// When this code is triggered it means that something went wrong in @Vehicle::AddPassenger, and we should remove
@@ -856,7 +856,7 @@ void VehicleJoinEvent::Abort(uint64)
}
else
TC_LOG_DEBUG("entities.vehicle", "Passenger GuidLow: %u, Entry: %u, board on uninstalled vehicle SeatId: %d cancelled",
Passenger->GetGUIDLow(), Passenger->GetEntry(), (int32)Seat->first);
Passenger->GetGUID().GetCounter(), Passenger->GetEntry(), (int32)Seat->first);
if (Passenger->IsInWorld() && Passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY))
Passenger->ToCreature()->DespawnOrUnsummon();
+104 -69
View File
@@ -477,7 +477,7 @@ void GameEventMgr::LoadFromDB()
ModelEquip newModelEquipSet;
newModelEquipSet.modelid = fields[3].GetUInt32();
newModelEquipSet.equipment_id = fields[4].GetUInt8();
newModelEquipSet.equipement_id_prev = 0;
newModelEquipSet.equipment_id_prev = 0;
newModelEquipSet.modelid_prev = 0;
if (newModelEquipSet.equipment_id > 0)
@@ -918,7 +918,7 @@ void GameEventMgr::LoadFromDB()
uint32 GameEventMgr::GetNPCFlag(Creature* cr)
{
uint32 mask = 0;
uint32 guid = cr->GetDBTableGUIDLow();
uint32 guid = cr->GetSpawnId();
for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
{
@@ -1116,25 +1116,35 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id)
void GameEventMgr::UpdateEventNPCFlags(uint16 event_id)
{
std::unordered_map<uint32, std::unordered_set<ObjectGuid::LowType>> creaturesByMap;
// go through the creatures whose npcflags are changed in the event
for (NPCFlagList::iterator itr = mGameEventNPCFlags[event_id].begin(); itr != mGameEventNPCFlags[event_id].end(); ++itr)
{
// get the creature data from the low guid to get the entry, to be able to find out the whole guid
if (CreatureData const* data = sObjectMgr->GetCreatureData(itr->first))
creaturesByMap[data->mapid].insert(itr->first);
for (auto const& p : creaturesByMap)
{
sMapMgr->DoForAllMapsWithMapId(p.first, [this, &p](Map* map)
{
Creature* cr = HashMapHolder<Creature>::Find(ObjectGuid(HIGHGUID_UNIT, data->id, itr->first));
// if we found the creature, modify its npcflag
if (cr)
for (auto& spawnId : p.second)
{
uint32 npcflag = GetNPCFlag(cr);
if (const CreatureTemplate* ci = cr->GetCreatureTemplate())
npcflag |= ci->npcflag;
cr->SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
// reset gossip options, since the flag change might have added / removed some
//cr->ResetGossipOptions();
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId);
for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr)
{
Creature* creature = itr->second;
uint32 npcflag = GetNPCFlag(creature);
if (CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate())
npcflag |= creatureTemplate->npcflag;
creature->SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
// reset gossip options, since the flag change might have added / removed some
//cr->ResetGossipOptions();
}
}
// if we didn't find it, then the npcflag will be updated when the creature is loaded
}
});
}
}
@@ -1253,8 +1263,16 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{
sObjectMgr->RemoveCreatureFromGrid(*itr, data);
if (Creature* creature = ObjectAccessor::GetObjectInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, *itr), (Creature*)NULL))
creature->AddObjectToRemoveList();
sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map)
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(*itr);
for (auto it = creatureBounds.first; it != creatureBounds.second; )
{
Creature* creature = it->second;
++it;
creature->AddObjectToRemoveList();
}
});
}
}
@@ -1275,8 +1293,16 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{
sObjectMgr->RemoveGameobjectFromGrid(*itr, data);
if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, *itr), (GameObject*)NULL))
pGameobject->AddObjectToRemoveList();
sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map)
{
auto gameObjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(*itr);
for (auto it = gameObjectBounds.first; it != gameObjectBounds.second; )
{
GameObject* go = it->second;
++it;
go->AddObjectToRemoveList();
}
});
}
}
if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
@@ -1301,60 +1327,50 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
continue;
// Update if spawned
Creature* creature = ObjectAccessor::GetObjectInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, itr->first), (Creature*)NULL);
if (creature)
sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr, activate](Map* map)
{
if (activate)
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(itr->first);
for (auto it = creatureBounds.first; it != creatureBounds.second; ++it)
{
itr->second.equipement_id_prev = creature->GetCurrentEquipmentId();
itr->second.modelid_prev = creature->GetDisplayId();
creature->LoadEquipment(itr->second.equipment_id, true);
if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
Creature* creature = it->second;
if (activate)
{
creature->SetDisplayId(itr->second.modelid);
creature->SetNativeDisplayId(itr->second.modelid);
itr->second.equipment_id_prev = creature->GetCurrentEquipmentId();
itr->second.modelid_prev = creature->GetDisplayId();
creature->LoadEquipment(itr->second.equipment_id, true);
if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
{
creature->SetDisplayId(itr->second.modelid);
creature->SetNativeDisplayId(itr->second.modelid);
}
}
else
{
creature->LoadEquipment(itr->second.equipment_id_prev, true);
if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
{
creature->SetDisplayId(itr->second.modelid_prev);
creature->SetNativeDisplayId(itr->second.modelid_prev);
}
}
}
else
{
creature->LoadEquipment(itr->second.equipement_id_prev, true);
if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
{
creature->SetDisplayId(itr->second.modelid_prev);
creature->SetNativeDisplayId(itr->second.modelid_prev);
}
}
}
else // If not spawned
{
CreatureData const* data2 = sObjectMgr->GetCreatureData(itr->first);
if (data2 && activate)
{
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(data2->id);
uint32 displayID = ObjectMgr::ChooseDisplayId(cinfo, data2);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
});
if (data2->equipmentId == 0)
itr->second.equipement_id_prev = 0; ///@todo: verify this line
else if (data2->equipmentId != -1)
itr->second.equipement_id_prev = data->equipmentId;
itr->second.modelid_prev = displayID;
}
}
// now last step: put in data
// just to have write access to it
CreatureData& data2 = sObjectMgr->NewOrExistCreatureData(itr->first);
if (activate)
{
itr->second.modelid_prev = data2.displayid;
itr->second.equipment_id_prev = data2.equipmentId;
data2.displayid = itr->second.modelid;
data2.equipmentId = itr->second.equipment_id;
}
else
{
data2.displayid = itr->second.modelid_prev;
data2.equipmentId = itr->second.equipement_id_prev;
data2.equipmentId = itr->second.equipment_id_prev;
}
}
}
@@ -1595,24 +1611,43 @@ void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id)
}
}
class GameEventAIHookWorker
{
public:
GameEventAIHookWorker(uint16 eventId, bool activate) : _eventId(eventId), _activate(activate) { }
void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
{
for (auto const& p : creatureMap)
if (p.second->IsInWorld() && p.second->IsAIEnabled)
p.second->AI()->sOnGameEvent(_activate, _eventId);
}
void Visit(std::unordered_map<ObjectGuid, GameObject*>& gameObjectMap)
{
for (auto const& p : gameObjectMap)
if (p.second->IsInWorld())
p.second->AI()->OnGameEvent(_activate, _eventId);
}
template<class T>
void Visit(std::unordered_map<ObjectGuid, T*>&) { }
private:
uint16 _eventId;
bool _activate;
};
void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate)
{
//! Iterate over every supported source type (creature and gameobject)
//! Not entirely sure how this will affect units in non-loaded grids.
sMapMgr->DoForAllMaps([event_id, activate](Map* map)
{
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Creature>::GetLock());
HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures();
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld())
iter->second->AI()->sOnGameEvent(activate, event_id);
}
{
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<GameObject>::GetLock());
HashMapHolder<GameObject>::MapType const& m = ObjectAccessor::GetGameObjects();
for (HashMapHolder<GameObject>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld())
iter->second->AI()->OnGameEvent(activate, event_id);
}
GameEventAIHookWorker worker(event_id, activate);
TypeContainerVisitor<GameEventAIHookWorker, MapStoredObjectTypesContainer> visitor(worker);
visitor.Visit(map->GetObjectsStore());
});
}
uint16 GameEventMgr::GetEventIdForQuest(Quest const* quest) const
+2 -2
View File
@@ -76,7 +76,7 @@ struct ModelEquip
uint32 modelid;
uint32 modelid_prev;
uint8 equipment_id;
uint8 equipement_id_prev;
uint8 equipment_id_prev;
};
struct NPCVendorEntry
@@ -161,7 +161,7 @@ class GameEventMgr
typedef std::list<NPCVendorEntry> NPCVendorList;
typedef std::vector<NPCVendorList> GameEventNPCVendorMap;
typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap;
typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair;
typedef std::pair<ObjectGuid::LowType /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair;
typedef std::list<GuidNPCFlagPair> NPCFlagList;
typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
typedef std::vector<uint32> GameEventBitmask;
+76 -141
View File
@@ -28,6 +28,7 @@
#include "ObjectMgr.h"
#include "Pet.h"
#include "Player.h"
#include "Transport.h"
#include "World.h"
#include <boost/thread/shared_mutex.hpp>
@@ -37,152 +38,128 @@ ObjectAccessor::ObjectAccessor() { }
ObjectAccessor::~ObjectAccessor() { }
template<class T> T* ObjectAccessor::GetObjectInWorld(uint32 mapid, float x, float y, ObjectGuid guid, T* /*fake*/)
{
T* obj = HashMapHolder<T>::Find(guid);
if (!obj || obj->GetMapId() != mapid)
return NULL;
CellCoord p = Trinity::ComputeCellCoord(x, y);
if (!p.IsCoordValid())
{
TC_LOG_ERROR("misc", "ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord);
return NULL;
}
CellCoord q = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if (!q.IsCoordValid())
{
TC_LOG_ERROR("misc", "ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord);
return NULL;
}
int32 dx = int32(p.x_coord) - int32(q.x_coord);
int32 dy = int32(p.y_coord) - int32(q.y_coord);
if (dx > -2 && dx < 2 && dy > -2 && dy < 2)
return obj;
else
return NULL;
}
Player* ObjectAccessor::GetObjectInWorld(ObjectGuid guid, Player* /*typeSpecifier*/)
{
Player* player = HashMapHolder<Player>::Find(guid);
return player && player->IsInWorld() ? player : NULL;
}
WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, ObjectGuid guid)
WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, ObjectGuid const& guid)
{
switch (guid.GetHigh())
{
case HIGHGUID_PLAYER: return GetPlayer(p, guid);
case HIGHGUID_TRANSPORT:
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_GAMEOBJECT: return GetGameObject(p, guid);
case HIGHGUID_VEHICLE:
case HIGHGUID_UNIT: return GetCreature(p, guid);
case HIGHGUID_PET: return GetPet(p, guid);
case HIGHGUID_DYNAMICOBJECT: return GetDynamicObject(p, guid);
case HIGHGUID_AREATRIGGER: return GetAreaTrigger(p, guid);
case HIGHGUID_CORPSE: return GetCorpse(p, guid);
default: return NULL;
case HighGuid::Player: return GetPlayer(p, guid);
case HighGuid::Transport:
case HighGuid::Mo_Transport:
case HighGuid::GameObject: return GetGameObject(p, guid);
case HighGuid::Vehicle:
case HighGuid::Unit: return GetCreature(p, guid);
case HighGuid::Pet: return GetPet(p, guid);
case HighGuid::DynamicObject: return GetDynamicObject(p, guid);
case HighGuid::AreaTrigger: return GetAreaTrigger(p, guid);
case HighGuid::Corpse: return GetCorpse(p, guid);
default: return nullptr;
}
}
Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const& p, ObjectGuid guid, uint32 typemask)
Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const& p, ObjectGuid const& guid, uint32 typemask)
{
switch (guid.GetHigh())
{
case HIGHGUID_ITEM:
case HighGuid::Item:
if (typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER)
return ((Player const&)p).GetItemByGuid(guid);
break;
case HIGHGUID_PLAYER:
case HighGuid::Player:
if (typemask & TYPEMASK_PLAYER)
return GetPlayer(p, guid);
break;
case HIGHGUID_TRANSPORT:
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_GAMEOBJECT:
case HighGuid::Transport:
case HighGuid::Mo_Transport:
case HighGuid::GameObject:
if (typemask & TYPEMASK_GAMEOBJECT)
return GetGameObject(p, guid);
break;
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
case HighGuid::Unit:
case HighGuid::Vehicle:
if (typemask & TYPEMASK_UNIT)
return GetCreature(p, guid);
break;
case HIGHGUID_PET:
case HighGuid::Pet:
if (typemask & TYPEMASK_UNIT)
return GetPet(p, guid);
break;
case HIGHGUID_DYNAMICOBJECT:
case HighGuid::DynamicObject:
if (typemask & TYPEMASK_DYNAMICOBJECT)
return GetDynamicObject(p, guid);
break;
case HIGHGUID_AREATRIGGER:
case HighGuid::AreaTrigger:
if (typemask & TYPEMASK_AREATRIGGER)
return GetAreaTrigger(p, guid);
case HIGHGUID_CORPSE:
case HighGuid::Corpse:
break;
default:
break;
}
return NULL;
return nullptr;
}
Corpse* ObjectAccessor::GetCorpse(WorldObject const& u, ObjectGuid guid)
Corpse* ObjectAccessor::GetCorpse(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (Corpse*)NULL);
return u.GetMap()->GetCorpse(guid);
}
GameObject* ObjectAccessor::GetGameObject(WorldObject const& u, ObjectGuid guid)
GameObject* ObjectAccessor::GetGameObject(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (GameObject*)NULL);
return u.GetMap()->GetGameObject(guid);
}
Transport* ObjectAccessor::GetTransport(WorldObject const& u, ObjectGuid guid)
Transport* ObjectAccessor::GetTransport(WorldObject const& u, ObjectGuid const& guid)
{
if (!guid.IsMOTransport())
return NULL;
GameObject* go = GetGameObject(u, guid);
return go ? go->ToTransport() : NULL;
return u.GetMap()->GetTransport(guid);
}
DynamicObject* ObjectAccessor::GetDynamicObject(WorldObject const& u, ObjectGuid guid)
DynamicObject* ObjectAccessor::GetDynamicObject(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (DynamicObject*)NULL);
return u.GetMap()->GetDynamicObject(guid);
}
AreaTrigger* ObjectAccessor::GetAreaTrigger(WorldObject const& u, ObjectGuid guid)
AreaTrigger* ObjectAccessor::GetAreaTrigger(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (AreaTrigger*)NULL);
return u.GetMap()->GetAreaTrigger(guid);
}
Unit* ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid)
Unit* ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (Unit*)NULL);
if (guid.IsPlayer())
return GetPlayer(u, guid);
if (guid.IsPet())
return GetPet(u, guid);
return GetCreature(u, guid);
}
Creature* ObjectAccessor::GetCreature(WorldObject const& u, ObjectGuid guid)
Creature* ObjectAccessor::GetCreature(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (Creature*)NULL);
return u.GetMap()->GetCreature(guid);
}
Pet* ObjectAccessor::GetPet(WorldObject const& u, ObjectGuid guid)
Pet* ObjectAccessor::GetPet(WorldObject const& u, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (Pet*)NULL);
return u.GetMap()->GetPet(guid);
}
Player* ObjectAccessor::GetPlayer(WorldObject const& u, ObjectGuid guid)
Player* ObjectAccessor::GetPlayer(Map const* m, ObjectGuid const& guid)
{
return GetObjectInMap(guid, u.GetMap(), (Player*)NULL);
if (Player* player = HashMapHolder<Player>::Find(guid))
if (player->IsInWorld() && player->GetMap() == m)
return player;
return nullptr;
}
Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, ObjectGuid guid)
Player* ObjectAccessor::GetPlayer(WorldObject const& u, ObjectGuid const& guid)
{
return GetPlayer(u.GetMap(), guid);
}
Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, ObjectGuid const& guid)
{
if (guid.IsPet())
return GetPet(u, guid);
@@ -190,29 +167,20 @@ Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, Object
if (guid.IsCreatureOrVehicle())
return GetCreature(u, guid);
return NULL;
return nullptr;
}
Pet* ObjectAccessor::FindPet(ObjectGuid guid)
Player* ObjectAccessor::FindPlayer(ObjectGuid const& guid)
{
return GetObjectInWorld(guid, (Pet*)NULL);
Player* player = HashMapHolder<Player>::Find(guid);
return player && player->IsInWorld() ? player : nullptr;
}
Player* ObjectAccessor::FindPlayer(ObjectGuid guid)
{
return GetObjectInWorld(guid, (Player*)NULL);
}
Player* ObjectAccessor::FindConnectedPlayer(ObjectGuid guid)
Player* ObjectAccessor::FindConnectedPlayer(ObjectGuid const& guid)
{
return HashMapHolder<Player>::Find(guid);
}
Unit* ObjectAccessor::FindUnit(ObjectGuid guid)
{
return GetObjectInWorld(guid, (Unit*)NULL);
}
Player* ObjectAccessor::FindPlayerByName(std::string const& name)
{
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
@@ -230,7 +198,7 @@ Player* ObjectAccessor::FindPlayerByName(std::string const& name)
return iter->second;
}
return NULL;
return nullptr;
}
Player* ObjectAccessor::FindConnectedPlayerByName(std::string const& name)
@@ -248,7 +216,7 @@ Player* ObjectAccessor::FindConnectedPlayerByName(std::string const& name)
return iter->second;
}
return NULL;
return nullptr;
}
void ObjectAccessor::SaveAllPlayers()
@@ -260,13 +228,13 @@ void ObjectAccessor::SaveAllPlayers()
itr->second->SaveToDB();
}
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid const& guid)
{
boost::shared_lock<boost::shared_mutex> lock(_corpseLock);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end())
return NULL;
return nullptr;
ASSERT(iter->second->GetType() != CORPSE_BONES);
@@ -352,14 +320,14 @@ void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid,
}
}
Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia /*=false*/)
Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid const& player_guid, bool insignia /*=false*/)
{
Corpse* corpse = GetCorpseForPlayerGUID(player_guid);
if (!corpse)
{
//in fact this function is called from several places
//even when player doesn't have a corpse, not an error
return NULL;
return nullptr;
}
TC_LOG_DEBUG("misc", "Deleting Corpse and spawned bones.");
@@ -375,7 +343,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insi
corpse->DeleteFromDB(trans);
CharacterDatabase.CommitTransaction(trans);
Corpse* bones = NULL;
Corpse* bones = nullptr;
// create the bones only if the map and the grid is loaded at the corpse's location
// ignore bones creating option in case insignia
@@ -385,7 +353,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insi
{
// Create bones, don't change Corpse
bones = new Corpse;
bones->Create(corpse->GetGUIDLow(), map);
bones->Create(corpse->GetGUID().GetCounter(), map);
for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
@@ -397,6 +365,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insi
bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
bones->SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Empty);
bones->SetGuidValue(OBJECT_FIELD_DATA, corpse->GetGuidValue(OBJECT_FIELD_DATA));
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
@@ -418,7 +387,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insi
void ObjectAccessor::RemoveOldCorpses()
{
time_t now = time(NULL);
time_t now = time(nullptr);
Player2CorpsesMapType::iterator next;
for (Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next)
{
@@ -432,27 +401,6 @@ void ObjectAccessor::RemoveOldCorpses()
}
}
void ObjectAccessor::Update(uint32 /*diff*/)
{
UpdateDataMapType update_players;
while (!i_objects.empty())
{
Object* obj = *i_objects.begin();
ASSERT(obj && obj->IsInWorld());
i_objects.erase(i_objects.begin());
obj->BuildUpdate(update_players);
}
WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
{
iter->second.BuildPacket(&packet);
iter->first->GetSession()->SendPacket(&packet);
packet.clear(); // clean the string
}
}
void ObjectAccessor::UnloadAll()
{
for (Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr)
@@ -463,22 +411,9 @@ void ObjectAccessor::UnloadAll()
}
/// Define the static members of HashMapHolder
template <class T> typename HashMapHolder<T>::MapType HashMapHolder<T>::_objectMap;
template <class T> boost::shared_mutex HashMapHolder<T>::_lock;
/// Global definitions for the hashmap storage
template class HashMapHolder<Player>;
template class HashMapHolder<Pet>;
template class HashMapHolder<GameObject>;
template class HashMapHolder<DynamicObject>;
template class HashMapHolder<Creature>;
template class HashMapHolder<Corpse>;
template Player* ObjectAccessor::GetObjectInWorld<Player>(uint32 mapid, float x, float y, ObjectGuid guid, Player* /*fake*/);
template Pet* ObjectAccessor::GetObjectInWorld<Pet>(uint32 mapid, float x, float y, ObjectGuid guid, Pet* /*fake*/);
template Creature* ObjectAccessor::GetObjectInWorld<Creature>(uint32 mapid, float x, float y, ObjectGuid guid, Creature* /*fake*/);
template Corpse* ObjectAccessor::GetObjectInWorld<Corpse>(uint32 mapid, float x, float y, ObjectGuid guid, Corpse* /*fake*/);
template GameObject* ObjectAccessor::GetObjectInWorld<GameObject>(uint32 mapid, float x, float y, ObjectGuid guid, GameObject* /*fake*/);
template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, ObjectGuid guid, DynamicObject* /*fake*/);
template class HashMapHolder<Transport>;
+20 -98
View File
@@ -30,7 +30,6 @@
#include "UpdateData.h"
#include "Object.h"
class Creature;
class Corpse;
class Unit;
@@ -46,6 +45,9 @@ template <class T>
class HashMapHolder
{
public:
static_assert(std::is_same<Player, T>::value
|| std::is_same<Transport, T>::value,
"Only Player and Transport can be registered in global HashMapHolder");
typedef std::unordered_map<ObjectGuid, T*> MapType;
@@ -100,78 +102,28 @@ class ObjectAccessor
return &instance;
}
template<class T> static T* GetObjectInOrOutOfWorld(ObjectGuid guid, T* /*typeSpecifier*/)
{
return HashMapHolder<T>::Find(guid);
}
static Unit* GetObjectInOrOutOfWorld(ObjectGuid guid, Unit* /*typeSpecifier*/)
{
if (guid.IsPlayer())
return (Unit*)GetObjectInOrOutOfWorld(guid, (Player*)NULL);
if (guid.IsPet())
return (Unit*)GetObjectInOrOutOfWorld(guid, (Pet*)NULL);
return (Unit*)GetObjectInOrOutOfWorld(guid, (Creature*)NULL);
}
// returns object if is in world
template<class T> static T* GetObjectInWorld(ObjectGuid guid, T* /*typeSpecifier*/)
{
return HashMapHolder<T>::Find(guid);
}
// Player may be not in world while in ObjectAccessor
static Player* GetObjectInWorld(ObjectGuid guid, Player* /*typeSpecifier*/);
static Unit* GetObjectInWorld(ObjectGuid guid, Unit* /*typeSpecifier*/)
{
if (guid.IsPlayer())
return (Unit*)GetObjectInWorld(guid, (Player*)NULL);
if (guid.IsPet())
return (Unit*)GetObjectInWorld(guid, (Pet*)NULL);
return (Unit*)GetObjectInWorld(guid, (Creature*)NULL);
}
// returns object if is in map
template<class T> static T* GetObjectInMap(ObjectGuid guid, Map* map, T* /*typeSpecifier*/)
{
ASSERT(map);
if (T * obj = GetObjectInWorld(guid, (T*)NULL))
if (obj->GetMap() == map)
return obj;
return NULL;
}
template<class T> static T* GetObjectInWorld(uint32 mapid, float x, float y, ObjectGuid guid, T* /*fake*/);
// these functions return objects only if in map of specified object
static WorldObject* GetWorldObject(WorldObject const&, ObjectGuid);
static Object* GetObjectByTypeMask(WorldObject const&, ObjectGuid, uint32 typemask);
static Corpse* GetCorpse(WorldObject const& u, ObjectGuid guid);
static GameObject* GetGameObject(WorldObject const& u, ObjectGuid guid);
static Transport* GetTransport(WorldObject const& u, ObjectGuid guid);
static DynamicObject* GetDynamicObject(WorldObject const& u, ObjectGuid guid);
static AreaTrigger* GetAreaTrigger(WorldObject const& u, ObjectGuid guid);
static Unit* GetUnit(WorldObject const&, ObjectGuid guid);
static Creature* GetCreature(WorldObject const& u, ObjectGuid guid);
static Pet* GetPet(WorldObject const&, ObjectGuid guid);
static Player* GetPlayer(WorldObject const&, ObjectGuid guid);
static Creature* GetCreatureOrPetOrVehicle(WorldObject const&, ObjectGuid);
static WorldObject* GetWorldObject(WorldObject const&, ObjectGuid const&);
static Object* GetObjectByTypeMask(WorldObject const&, ObjectGuid const&, uint32 typemask);
static Corpse* GetCorpse(WorldObject const& u, ObjectGuid const& guid);
static GameObject* GetGameObject(WorldObject const& u, ObjectGuid const& guid);
static Transport* GetTransport(WorldObject const& u, ObjectGuid const& guid);
static DynamicObject* GetDynamicObject(WorldObject const& u, ObjectGuid const& guid);
static AreaTrigger* GetAreaTrigger(WorldObject const& u, ObjectGuid const& guid);
static Unit* GetUnit(WorldObject const&, ObjectGuid const& guid);
static Creature* GetCreature(WorldObject const& u, ObjectGuid const& guid);
static Pet* GetPet(WorldObject const&, ObjectGuid const& guid);
static Player* GetPlayer(Map const* m, ObjectGuid const& guid);
static Player* GetPlayer(WorldObject const&, ObjectGuid const& guid);
static Creature* GetCreatureOrPetOrVehicle(WorldObject const&, ObjectGuid const&);
// these functions return objects if found in whole world
// ACCESS LIKE THAT IS NOT THREAD SAFE
static Pet* FindPet(ObjectGuid);
static Player* FindPlayer(ObjectGuid);
static Creature* FindCreature(ObjectGuid);
static Unit* FindUnit(ObjectGuid);
static Player* FindPlayer(ObjectGuid const&);
static Player* FindPlayerByName(std::string const& name);
// this returns Player even if he is not in world, for example teleporting
static Player* FindConnectedPlayer(ObjectGuid);
static Player* FindConnectedPlayer(ObjectGuid const&);
static Player* FindConnectedPlayerByName(std::string const& name);
// when using this, you must use the hashmapholder's lock
@@ -180,18 +132,6 @@ class ObjectAccessor
return HashMapHolder<Player>::GetContainer();
}
// when using this, you must use the hashmapholder's lock
static HashMapHolder<Creature>::MapType const& GetCreatures()
{
return HashMapHolder<Creature>::GetContainer();
}
// when using this, you must use the hashmapholder's lock
static HashMapHolder<GameObject>::MapType const& GetGameObjects()
{
return HashMapHolder<GameObject>::GetContainer();
}
template<class T> static void AddObject(T* object)
{
HashMapHolder<T>::Insert(object);
@@ -205,42 +145,24 @@ class ObjectAccessor
static void SaveAllPlayers();
//non-static functions
void AddUpdateObject(Object* obj)
{
std::lock_guard<std::mutex> lock(_objectLock);
i_objects.insert(obj);
}
void RemoveUpdateObject(Object* obj)
{
std::lock_guard<std::mutex> lock(_objectLock);
i_objects.erase(obj);
}
//Thread safe
Corpse* GetCorpseForPlayerGUID(ObjectGuid guid);
Corpse* GetCorpseForPlayerGUID(ObjectGuid const& guid);
void RemoveCorpse(Corpse* corpse);
void AddCorpse(Corpse* corpse);
void AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map);
Corpse* ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia = false);
Corpse* ConvertCorpseForPlayer(ObjectGuid const& player_guid, bool insignia = false);
//Thread unsafe
void Update(uint32 diff);
void RemoveOldCorpses();
void UnloadAll();
private:
static void _buildChangeObjectForPlayer(WorldObject*, UpdateDataMapType&);
static void _buildPacket(Player*, Object*, UpdateDataMapType&);
void _update();
typedef std::unordered_map<ObjectGuid, Corpse*> Player2CorpsesMapType;
typedef std::unordered_map<Player*, UpdateData>::value_type UpdateDataValueType;
std::set<Object*> i_objects;
Player2CorpsesMapType i_player2corpse;
std::mutex _objectLock;
boost::shared_mutex _corpseLock;
};
+74 -222
View File
@@ -228,16 +228,6 @@ ObjectMgr::ObjectMgr():
_mailId(1),
_hiPetNumber(1),
_voidItemId(1),
_hiCharGuid(1),
_hiCreatureGuid(1),
_hiPetGuid(1),
_hiVehicleGuid(1),
_hiItemGuid(1),
_hiGoGuid(1),
_hiDoGuid(1),
_hiCorpseGuid(1),
_hiAreaTriggerGuid(1),
_hiMoTransGuid(1),
DBCLocaleIndex(LOCALE_enUS)
{
for (uint8 i = 0; i < MAX_CLASSES; ++i)
@@ -1423,8 +1413,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
guid = ObjectGuid(HIGHGUID_UNIT, slave->id, guidLow);
linkedGuid = ObjectGuid(HIGHGUID_UNIT, master->id, linkedGuidLow);
guid = ObjectGuid(HighGuid::Unit, slave->id, guidLow);
linkedGuid = ObjectGuid(HighGuid::Unit, master->id, linkedGuidLow);
break;
}
case CREATURE_TO_GO:
@@ -1460,8 +1450,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
guid = ObjectGuid(HIGHGUID_UNIT, slave->id, guidLow);
linkedGuid = ObjectGuid(HIGHGUID_GAMEOBJECT, master->id, linkedGuidLow);
guid = ObjectGuid(HighGuid::Unit, slave->id, guidLow);
linkedGuid = ObjectGuid(HighGuid::GameObject, master->id, linkedGuidLow);
break;
}
case GO_TO_GO:
@@ -1497,8 +1487,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
guid = ObjectGuid(HIGHGUID_GAMEOBJECT, slave->id, guidLow);
linkedGuid = ObjectGuid(HIGHGUID_GAMEOBJECT, master->id, linkedGuidLow);
guid = ObjectGuid(HighGuid::GameObject, slave->id, guidLow);
linkedGuid = ObjectGuid(HighGuid::GameObject, master->id, linkedGuidLow);
break;
}
case GO_TO_CREATURE:
@@ -1534,8 +1524,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
guid = ObjectGuid(HIGHGUID_GAMEOBJECT, slave->id, guidLow);
linkedGuid = ObjectGuid(HIGHGUID_UNIT, master->id, linkedGuidLow);
guid = ObjectGuid(HighGuid::GameObject, slave->id, guidLow);
linkedGuid = ObjectGuid(HighGuid::Unit, master->id, linkedGuidLow);
break;
}
}
@@ -1555,7 +1545,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
CreatureData const* master = GetCreatureData(guidLow);
ASSERT(master);
ObjectGuid guid(HIGHGUID_UNIT, master->id, guidLow);
ObjectGuid guid(HighGuid::Unit, master->id, guidLow);
if (!linkedGuidLow) // we're removing the linking
{
@@ -1586,7 +1576,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
return false;
}
ObjectGuid linkedGuid(HIGHGUID_UNIT, slave->id, linkedGuidLow);
ObjectGuid linkedGuid(HighGuid::Unit, slave->id, linkedGuidLow);
_linkedRespawnStore[guid] = linkedGuid;
PreparedStatement *stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CREATURE_LINKED_RESPAWN);
@@ -1899,7 +1889,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
if (!map)
return 0;
uint32 guid = GenerateLowGuid(HIGHGUID_GAMEOBJECT);
uint32 guid = GenerateGameObjectSpawnId();
GameObjectData& data = NewGOData(guid);
data.id = entry;
data.mapid = mapId;
@@ -1939,39 +1929,6 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
return guid;
}
bool ObjectMgr::MoveCreatureData(uint32 guid, uint32 mapId, const Position& pos)
{
CreatureData& data = NewOrExistCreatureData(guid);
if (!data.id)
return false;
RemoveCreatureFromGrid(guid, &data);
if (data.posX == pos.GetPositionX() && data.posY == pos.GetPositionY() && data.posZ == pos.GetPositionZ())
return true;
data.posX = pos.GetPositionX();
data.posY = pos.GetPositionY();
data.posZ = pos.GetPositionZ();
data.orientation = pos.GetOrientation();
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
if (Map* map = sMapMgr->CreateBaseMap(mapId))
{
// We use spawn coords to spawn
if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY))
{
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map))
{
TC_LOG_ERROR("misc", "MoveCreatureData: Cannot add creature guid %u to map", guid);
delete creature;
return false;
}
}
}
return true;
}
uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/)
{
CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
@@ -1980,8 +1937,11 @@ uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y,
uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats
CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class);
Map* map = sMapMgr->CreateBaseMap(mapId);
if (!map)
return 0;
uint32 guid = GenerateLowGuid(HIGHGUID_UNIT);
uint32 guid = GenerateCreatureSpawnId();
CreatureData& data = NewOrExistCreatureData(guid);
data.id = entry;
data.mapid = mapId;
@@ -2006,19 +1966,15 @@ uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y,
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
if (Map* map = sMapMgr->CreateBaseMap(mapId))
// We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
{
// We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map))
{
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(guid, map))
{
TC_LOG_ERROR("misc", "AddCreature: Cannot add creature entry %u to map", entry);
delete creature;
return 0;
}
TC_LOG_ERROR("misc", "AddCreature: Cannot add creature entry %u to map", entry);
delete creature;
return 0;
}
}
@@ -2231,7 +2187,7 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const
{
ObjectGuid guid(HIGHGUID_PLAYER, lowguid);
ObjectGuid guid(HighGuid::Player, lowguid);
return ObjectAccessor::FindPlayer(guid);
}
@@ -2245,7 +2201,7 @@ ObjectGuid ObjectMgr::GetPlayerGUIDByName(std::string const& name) const
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
return ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
return ObjectGuid(HighGuid::Player, (*result)[0].GetUInt32());
return ObjectGuid::Empty;
}
@@ -5729,7 +5685,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
Player* player = NULL;
if (serverUp)
player = ObjectAccessor::FindConnectedPlayer(ObjectGuid(HIGHGUID_PLAYER, m->receiver));
player = ObjectAccessor::FindConnectedPlayer(ObjectGuid(HighGuid::Player, m->receiver));
if (player && player->m_mailsLoaded)
{ // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail
@@ -6523,61 +6479,58 @@ void ObjectMgr::SetHighestGuids()
{
QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters");
if (result)
_hiCharGuid = (*result)[0].GetUInt32()+1;
result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
if (result)
_hiCreatureGuid = (*result)[0].GetUInt32()+1;
GetGuidSequenceGenerator<HighGuid::Player>().Set((*result)[0].GetUInt32() + 1);
result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance");
if (result)
_hiItemGuid = (*result)[0].GetUInt32()+1;
GetGuidSequenceGenerator<HighGuid::Item>().Set((*result)[0].GetUInt32() + 1);
// Cleanup other tables from nonexistent guids ( >= _hiItemGuid)
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", _hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", _hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", _hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", _hiItemGuid); // One-time query
result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
if (result)
_hiGoGuid = (*result)[0].GetUInt32()+1;
uint32 hiItemGuid = GetGuidSequenceGenerator<HighGuid::Item>().GetNextAfterMaxUsed();
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", hiItemGuid); // One-time query
result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
if (result)
_hiMoTransGuid = (*result)[0].GetUInt32()+1;
GetGuidSequenceGenerator<HighGuid::Mo_Transport>().Set((*result)[0].GetUInt32() + 1);
result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
if (result)
_auctionId = (*result)[0].GetUInt32()+1;
_auctionId = (*result)[0].GetUInt32() + 1;
result = CharacterDatabase.Query("SELECT MAX(id) FROM mail");
if (result)
_mailId = (*result)[0].GetUInt32()+1;
result = CharacterDatabase.Query("SELECT MAX(corpseGuid) FROM corpse");
if (result)
_hiCorpseGuid = (*result)[0].GetUInt32()+1;
_mailId = (*result)[0].GetUInt32() + 1;
result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
if (result)
sArenaTeamMgr->SetNextArenaTeamId((*result)[0].GetUInt32()+1);
sArenaTeamMgr->SetNextArenaTeamId((*result)[0].GetUInt32() + 1);
result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
if (result)
_equipmentSetGuid = (*result)[0].GetUInt64()+1;
_equipmentSetGuid = (*result)[0].GetUInt64() + 1;
result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
if (result)
sGuildMgr->SetNextGuildId((*result)[0].GetUInt32()+1);
sGuildMgr->SetNextGuildId((*result)[0].GetUInt32() + 1);
result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
if (result)
sGroupMgr->SetGroupDbStoreSize((*result)[0].GetUInt32()+1);
sGroupMgr->SetGroupDbStoreSize((*result)[0].GetUInt32() + 1);
result = CharacterDatabase.Query("SELECT MAX(itemId) from character_void_storage");
if (result)
_voidItemId = (*result)[0].GetUInt64()+1;
_voidItemId = (*result)[0].GetUInt64() + 1;
result = WorldDatabase.Query("SELECT MAX(guid) FROM creature");
if (result)
_creatureSpawnId = (*result)[0].GetUInt32() + 1;
result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject");
if (result)
_gameObjectSpawnId = (*result)[0].GetUInt32() + 1;
}
uint32 ObjectMgr::GenerateAuctionID()
@@ -6610,64 +6563,34 @@ uint32 ObjectMgr::GenerateMailID()
return _mailId++;
}
uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
uint32 ObjectMgr::GeneratePetNumber()
{
switch (guidhigh)
return ++_hiPetNumber;
}
uint64 ObjectMgr::GenerateVoidStorageItemId()
{
return ++_voidItemId;
}
uint32 ObjectMgr::GenerateCreatureSpawnId()
{
if (_creatureSpawnId >= 0xFFFFFF)
{
case HIGHGUID_ITEM:
{
ASSERT(_hiItemGuid < 0xFFFFFFFE && "Item guid overflow!");
return _hiItemGuid++;
}
case HIGHGUID_UNIT:
{
ASSERT(_hiCreatureGuid < 0x00FFFFFE && "Creature guid overflow!");
return _hiCreatureGuid++;
}
case HIGHGUID_PET:
{
ASSERT(_hiPetGuid < 0x00FFFFFE && "Pet guid overflow!");
return _hiPetGuid++;
}
case HIGHGUID_VEHICLE:
{
ASSERT(_hiVehicleGuid < 0x00FFFFFF && "Vehicle guid overflow!");
return _hiVehicleGuid++;
}
case HIGHGUID_PLAYER:
{
ASSERT(_hiCharGuid < 0xFFFFFFFE && "Player guid overflow!");
return _hiCharGuid++;
}
case HIGHGUID_GAMEOBJECT:
{
ASSERT(_hiGoGuid < 0x00FFFFFE && "Gameobject guid overflow!");
return _hiGoGuid++;
}
case HIGHGUID_CORPSE:
{
ASSERT(_hiCorpseGuid < 0xFFFFFFFE && "Corpse guid overflow!");
return _hiCorpseGuid++;
}
case HIGHGUID_AREATRIGGER:
{
ASSERT(_hiAreaTriggerGuid < 0xFFFFFFFE && "AreaTrigger guid overflow!");
return _hiAreaTriggerGuid++;
}
case HIGHGUID_DYNAMICOBJECT:
{
ASSERT(_hiDoGuid < 0xFFFFFFFE && "DynamicObject guid overflow!");
return _hiDoGuid++;
}
case HIGHGUID_MO_TRANSPORT:
{
ASSERT(_hiMoTransGuid < 0xFFFFFFFE && "MO Transport guid overflow!");
return _hiMoTransGuid++;
}
default:
ASSERT(false && "ObjectMgr::GenerateLowGuid - Unknown HIGHGUID type");
return 0;
TC_LOG_ERROR("misc", "Creature spawn id overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return _creatureSpawnId++;
}
uint32 ObjectMgr::GenerateGameObjectSpawnId()
{
if (_gameObjectSpawnId >= 0xFFFFFF)
{
TC_LOG_ERROR("misc", "GameObject spawn id overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return _gameObjectSpawnId++;
}
void ObjectMgr::LoadGameObjectLocales()
@@ -7054,77 +6977,6 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
return *(list0.begin()+urand(0, list0.size()-1)) + *(list1.begin()+urand(0, list1.size()-1));
}
uint32 ObjectMgr::GeneratePetNumber()
{
return ++_hiPetNumber;
}
uint64 ObjectMgr::GenerateVoidStorageItemId()
{
return ++_voidItemId;
}
void ObjectMgr::LoadCorpses()
{
uint32 oldMSTime = getMSTime();
std::unordered_map<uint32, std::list<uint32>> phases;
// 0 1
// SELECT Guid, PhaseId FROM corpse_phases
PreparedQueryResult phaseResult = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSE_PHASES));
if (phaseResult)
{
do
{
Field* fields = phaseResult->Fetch();
uint32 guid = fields[0].GetUInt32();
uint32 phaseId = fields[1].GetUInt32();
phases[guid].push_back(phaseId);
} while (phaseResult->NextRow());
}
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, corpseGuid, guid FROM corpse WHERE corpseType <> 0
PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES));
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 corpses. DB table `corpse` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 guid = fields[14].GetUInt32();
CorpseType type = CorpseType(fields[12].GetUInt8());
if (type >= MAX_CORPSE_TYPE)
{
TC_LOG_ERROR("misc", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type);
continue;
}
Corpse* corpse = new Corpse(type);
if (!corpse->LoadCorpseFromDB(guid, fields))
{
delete corpse;
continue;
}
for (auto phaseId : phases[guid])
corpse->SetInPhase(phaseId, false, true);
sObjectAccessor->AddCorpse(corpse);
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u corpses in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadReputationRewardRate()
{
uint32 oldMSTime = getMSTime();
@@ -9545,7 +9397,7 @@ VehicleAccessoryList const* ObjectMgr::GetVehicleAccessoryList(Vehicle* veh) con
if (Creature* cre = veh->GetBase()->ToCreature())
{
// Give preference to GUID-based accessories
VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetDBTableGUIDLow());
VehicleAccessoryContainer::const_iterator itr = _vehicleAccessoryStore.find(cre->GetSpawnId());
if (itr != _vehicleAccessoryStore.end())
return &itr->second;
}
+25 -15
View File
@@ -36,13 +36,14 @@
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include "VehicleDefines.h"
#include "ConditionMgr.h"
#include "DB2Stores.h"
#include <string>
#include <tuple>
#include <map>
#include <limits>
#include "ConditionMgr.h"
#include <functional>
#include "DB2Stores.h"
#include <memory>
class Item;
struct AccessRequirement;
@@ -1028,7 +1029,6 @@ class ObjectMgr
void LoadExplorationBaseXP();
void LoadPetNames();
void LoadPetNumber();
void LoadCorpses();
void LoadFishingBaseSkillLevel();
void LoadReputationRewardRate();
@@ -1069,12 +1069,21 @@ class ObjectMgr
CreatureBaseStats const* GetCreatureBaseStats(uint8 level, uint8 unitClass);
void SetHighestGuids();
uint32 GenerateLowGuid(HighGuid guidhigh);
template<HighGuid type>
inline ObjectGuidGeneratorBase& GetGenerator()
{
static_assert(ObjectGuidTraits<type>::Global, "Only global guid can be generated in ObjectMgr context");
return GetGuidSequenceGenerator<type>();
}
uint32 GenerateAuctionID();
uint64 GenerateEquipmentSetGuid();
uint32 GenerateMailID();
uint32 GeneratePetNumber();
uint64 GenerateVoidStorageItemId();
uint32 GenerateCreatureSpawnId();
uint32 GenerateGameObjectSpawnId();
typedef std::multimap<int32, uint32> ExclusiveQuestGroups;
typedef std::pair<ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator> ExclusiveQuestGroupsBounds;
@@ -1224,7 +1233,6 @@ class ObjectMgr
void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
uint32 AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
uint32 AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
bool MoveCreatureData(uint32 guid, uint32 map, const Position& pos);
// reserved names
void LoadReservedPlayersNames();
@@ -1389,19 +1397,21 @@ class ObjectMgr
uint32 _mailId;
uint32 _hiPetNumber;
uint64 _voidItemId;
uint32 _creatureSpawnId;
uint32 _gameObjectSpawnId;
// first free low guid for selected guid type
uint32 _hiCharGuid;
uint32 _hiCreatureGuid;
uint32 _hiPetGuid;
uint32 _hiVehicleGuid;
uint32 _hiItemGuid;
uint32 _hiGoGuid;
uint32 _hiDoGuid;
uint32 _hiCorpseGuid;
uint32 _hiAreaTriggerGuid;
uint32 _hiMoTransGuid;
template<HighGuid high>
inline ObjectGuidGeneratorBase& GetGuidSequenceGenerator()
{
auto itr = _guidGenerators.find(high);
if (itr == _guidGenerators.end())
itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
return *itr->second;
}
std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators;
QuestMap _questTemplates;
typedef std::unordered_map<uint32, GossipText> GossipTextContainer;
+2
View File
@@ -59,6 +59,7 @@ class AreaTrigger;
// Creature used instead pet to simplify *::Visit templates (not required duplicate code for Creature->Pet case)
typedef TYPELIST_4(Player, Creature/*pets*/, Corpse/*resurrectable*/, DynamicObject/*farsight target*/) AllWorldObjectTypes;
typedef TYPELIST_5(GameObject, Creature/*except pets*/, DynamicObject, Corpse/*Bones*/, AreaTrigger) AllGridObjectTypes;
typedef TYPELIST_6(Creature, GameObject, DynamicObject, Pet, Corpse, AreaTrigger) AllMapStoredObjectTypes;
typedef GridRefManager<Corpse> CorpseMapType;
typedef GridRefManager<Creature> CreatureMapType;
@@ -83,6 +84,7 @@ typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTyp
typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer;
typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer;
typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer;
template<uint32 LIMIT>
struct CoordPair
@@ -735,18 +735,6 @@ namespace Trinity
NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&);
};
class GameObjectWithDbGUIDCheck
{
public:
GameObjectWithDbGUIDCheck(WorldObject const& /*obj*/, uint32 db_guid) : i_db_guid(db_guid) { }
bool operator()(GameObject const* go) const
{
return go->GetDBTableGUIDLow() == i_db_guid;
}
private:
uint32 i_db_guid;
};
// Unit checks
class MostHPMissingInRange
@@ -848,18 +836,6 @@ namespace Trinity
float i_range;
};
class CreatureWithDbGUIDCheck
{
public:
CreatureWithDbGUIDCheck(WorldObject const* /*obj*/, uint32 lowguid) : i_lowguid(lowguid) { }
bool operator()(Creature* u)
{
return u->GetDBTableGUIDLow() == i_lowguid;
}
private:
uint32 i_lowguid;
};
class AnyFriendlyUnitInObjectRangeCheck
{
public:
+1 -1
View File
@@ -140,7 +140,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord &cell, CorpseMapTyp
if (itr->second != map->GetInstanceId())
continue;
ObjectGuid player_guid(HIGHGUID_PLAYER, itr->first);
ObjectGuid player_guid(HighGuid::Player, itr->first);
Corpse* obj = sObjectAccessor->GetCorpseForPlayerGUID(player_guid);
if (!obj)
+11 -11
View File
@@ -93,7 +93,7 @@ bool Group::Create(Player* leader)
ObjectGuid leaderGuid = leader->GetGUID();
uint32 lowguid = sGroupMgr->GenerateGroupId();
m_guid = ObjectGuid(HIGHGUID_GROUP, lowguid);
m_guid = ObjectGuid(HighGuid::Group, lowguid);
m_leaderGuid = leaderGuid;
m_leaderName = leader->GetName();
leader->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GROUP_LEADER);
@@ -162,15 +162,15 @@ bool Group::Create(Player* leader)
void Group::LoadGroupFromDB(Field* fields)
{
m_dbStoreId = fields[16].GetUInt32();
m_guid = ObjectGuid(HIGHGUID_GROUP, sGroupMgr->GenerateGroupId());
m_leaderGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
m_guid = ObjectGuid(HighGuid::Group, sGroupMgr->GenerateGroupId());
m_leaderGuid = ObjectGuid(HighGuid::Player, fields[0].GetUInt32());
// group leader not exist
if (!sObjectMgr->GetPlayerNameByGUID(m_leaderGuid, m_leaderName))
return;
m_lootMethod = LootMethod(fields[1].GetUInt8());
m_looterGuid = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
m_looterGuid = ObjectGuid(HighGuid::Player, fields[2].GetUInt32());
m_lootThreshold = ItemQualities(fields[3].GetUInt8());
for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
@@ -192,7 +192,7 @@ void Group::LoadGroupFromDB(Field* fields)
else
m_raidDifficulty = Difficulty(r_diff);
m_masterLooterGuid = ObjectGuid(HIGHGUID_PLAYER, fields[15].GetUInt32());
m_masterLooterGuid = ObjectGuid(HighGuid::Player, fields[15].GetUInt32());
if (m_groupType & GROUPTYPE_LFG)
sLFGMgr->_LoadFromDB(fields, GetGUID());
@@ -201,7 +201,7 @@ void Group::LoadGroupFromDB(Field* fields)
void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles)
{
MemberSlot member;
member.guid = ObjectGuid(HIGHGUID_PLAYER, guidLow);
member.guid = ObjectGuid(HighGuid::Player, guidLow);
// skip non-existed member
if (!sObjectMgr->GetPlayerNameByGUID(member.guid, member.name))
@@ -690,7 +690,7 @@ void Group::ChangeLeader(ObjectGuid newLeaderGuid)
// Update the group leader
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_LEADER);
stmt->setUInt32(0, newLeader->GetGUIDLow());
stmt->setUInt32(0, newLeader->GetGUID().GetCounter());
stmt->setUInt32(1, m_dbStoreId);
trans->Append(stmt);
@@ -958,7 +958,7 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
//roll for over-threshold item if it's one-player loot
if (item->Quality >= uint32(m_lootThreshold))
{
ObjectGuid newitemGUID = ObjectGuid(HIGHGUID_ITEM, sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM));
ObjectGuid newitemGUID = ObjectGuid(HighGuid::Item, sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
Roll* r = new Roll(newitemGUID, *i);
//a vector is filled with only near party members
@@ -1042,7 +1042,7 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
continue;
}
ObjectGuid newitemGUID = ObjectGuid(HIGHGUID_ITEM, sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM));
ObjectGuid newitemGUID = ObjectGuid(HighGuid::Item, sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
Roll* r = new Roll(newitemGUID, *i);
//a vector is filled with only near party members
@@ -1103,7 +1103,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
//roll for over-threshold item if it's one-player loot
if (item->Quality >= uint32(m_lootThreshold))
{
ObjectGuid newitemGUID = ObjectGuid(HIGHGUID_ITEM, sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM));
ObjectGuid newitemGUID = ObjectGuid(HighGuid::Item, sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
Roll* r = new Roll(newitemGUID, *i);
for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
@@ -1178,7 +1178,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
continue;
item = sObjectMgr->GetItemTemplate(i->itemid);
ObjectGuid newitemGUID = ObjectGuid(HIGHGUID_ITEM, sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM));
ObjectGuid newitemGUID = ObjectGuid(HighGuid::Item, sObjectMgr->GetGenerator<HighGuid::Item>().Generate());
Roll* r = new Roll(newitemGUID, *i);
for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
+23 -23
View File
@@ -199,8 +199,8 @@ void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const
void Guild::EventLogEntry::WritePacket(WorldPacket& data, ByteBuffer& content) const
{
ObjectGuid guid1 = ObjectGuid(HIGHGUID_PLAYER, m_playerGuid1);
ObjectGuid guid2 = ObjectGuid(HIGHGUID_PLAYER, m_playerGuid2);
ObjectGuid guid1 = ObjectGuid(HighGuid::Player, m_playerGuid1);
ObjectGuid guid2 = ObjectGuid(HighGuid::Player, m_playerGuid2);
data.WriteBit(guid1[2]);
data.WriteBit(guid1[4]);
@@ -276,7 +276,7 @@ void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const
void Guild::BankEventLogEntry::WritePacket(WorldPacket& data, ByteBuffer& content) const
{
ObjectGuid logGuid = ObjectGuid(HIGHGUID_PLAYER, m_playerGuid);
ObjectGuid logGuid = ObjectGuid(HighGuid::Player, m_playerGuid);
bool hasItem = m_eventType == GUILD_BANK_LOG_DEPOSIT_ITEM || m_eventType == GUILD_BANK_LOG_WITHDRAW_ITEM ||
m_eventType == GUILD_BANK_LOG_MOVE_ITEM || m_eventType == GUILD_BANK_LOG_MOVE_ITEM2;
@@ -598,7 +598,7 @@ bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item)
stmt->setUInt32(0, m_guildId);
stmt->setUInt8 (1, m_tabId);
stmt->setUInt8 (2, slotId);
stmt->setUInt32(3, item->GetGUIDLow());
stmt->setUInt32(3, item->GetGUID().GetCounter());
CharacterDatabase.ExecuteOrAppend(trans, stmt);
item->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty);
@@ -928,7 +928,7 @@ void Guild::PlayerMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData
{
ASSERT(pFrom);
// Bank -> Char
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUID().GetCounter(),
pFrom->GetItem()->GetEntry(), count);
}
@@ -1013,11 +1013,11 @@ void Guild::BankMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData*
ASSERT(pFrom->GetItem());
if (pFrom->IsBank())
// Bank -> Bank
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUID().GetCounter(),
pFrom->GetItem()->GetEntry(), count, m_container);
else
// Char -> Bank
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUID().GetCounter(),
pFrom->GetItem()->GetEntry(), count);
}
@@ -1028,7 +1028,7 @@ void Guild::BankMoveItemData::LogAction(MoveItemData* pFrom) const
{
sLog->outCommand(m_pPlayer->GetSession()->GetAccountId(),
"GM %s (Guid: %u) (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank named: %s (Guild ID: %u)",
m_pPlayer->GetName().c_str(), m_pPlayer->GetGUIDLow(), m_pPlayer->GetSession()->GetAccountId(),
m_pPlayer->GetName().c_str(), m_pPlayer->GetGUID().GetCounter(), m_pPlayer->GetSession()->GetAccountId(),
pFrom->GetItem()->GetTemplate()->Name1.c_str(), pFrom->GetItem()->GetEntry(), pFrom->GetItem()->GetCount(),
m_pGuild->GetName().c_str(), m_pGuild->GetId());
}
@@ -1769,7 +1769,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
Player* player = session->GetPlayer();
// Do not show invitations from ignored players
if (pInvitee->GetSocial()->HasIgnore(player->GetGUIDLow()))
if (pInvitee->GetSocial()->HasIgnore(player->GetGUID().GetCounter()))
return;
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeam() != player->GetTeam())
@@ -1803,7 +1803,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
TC_LOG_DEBUG("guild", "Player %s invited %s to join his Guild", player->GetName().c_str(), name.c_str());
pInvitee->SetGuildIdInvited(m_id);
_LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUIDLow(), pInvitee->GetGUIDLow());
_LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUID().GetCounter(), pInvitee->GetGUID().GetCounter());
WorldPacket data(SMSG_GUILD_INVITE, 100);
data << uint32(GetLevel());
@@ -1815,7 +1815,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
ObjectGuid oldGuildGuid;
if (uint32 oldId = pInvitee->GetGuildId())
oldGuildGuid = ObjectGuid(HIGHGUID_GUILD, oldId);
oldGuildGuid = ObjectGuid(HighGuid::Guild, oldId);
ObjectGuid newGuildGuid = GetGUID();
@@ -1905,7 +1905,7 @@ void Guild::HandleLeaveMember(WorldSession* session)
{
DeleteMember(player->GetGUID(), false, false);
_LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUIDLow());
_LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUID().GetCounter());
_BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str());
SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name);
@@ -1941,7 +1941,7 @@ void Guild::HandleRemoveMember(WorldSession* session, ObjectGuid guid)
{
// After call to DeleteMember pointer to member becomes invalid
DeleteMember(guid, false, true);
_LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), guid.GetCounter());
_LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUID().GetCounter(), guid.GetCounter());
_BroadcastEvent(GE_REMOVED, ObjectGuid::Empty, name.c_str(), player->GetName().c_str());
SendCommandResult(session, GUILD_COMMAND_REMOVE, ERR_GUILD_COMMAND_SUCCESS, name);
}
@@ -1997,7 +1997,7 @@ void Guild::HandleUpdateMemberRank(WorldSession* session, ObjectGuid guid, bool
uint32 newRankId = member->GetRankId() + (demote ? 1 : -1);
member->ChangeRank(newRankId);
_LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUIDLow(), member->GetGUID().GetCounter(), newRankId);
_LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID().GetCounter(), member->GetGUID().GetCounter(), newRankId);
_BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str());
}
}
@@ -2081,7 +2081,7 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint64 amount, bool
player->SaveGoldToDB(trans);
}
_LogBankEvent(trans, cashFlow ? GUILD_BANK_LOG_CASH_FLOW_DEPOSIT : GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUIDLow(), amount);
_LogBankEvent(trans, cashFlow ? GUILD_BANK_LOG_CASH_FLOW_DEPOSIT : GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUID().GetCounter(), amount);
CharacterDatabase.CommitTransaction(trans);
std::string aux = ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true);
@@ -2131,7 +2131,7 @@ bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint64 amount, bool
_ModifyBankMoney(trans, amount, false);
// Log guild bank event
_LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUIDLow(), amount);
_LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUID().GetCounter(), amount);
CharacterDatabase.CommitTransaction(trans);
std::string aux = ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true);
@@ -2390,7 +2390,7 @@ bool Guild::LoadFromDB(Field* fields)
{
m_id = fields[0].GetUInt32();
m_name = fields[1].GetString();
m_leaderGuid = ObjectGuid(HIGHGUID_PLAYER, fields[2].GetUInt32());
m_leaderGuid = ObjectGuid(HighGuid::Player, fields[2].GetUInt32());
m_emblemInfo.LoadFromDB(fields);
m_info = fields[8].GetString();
m_motd = fields[9].GetString();
@@ -2424,7 +2424,7 @@ void Guild::LoadRankFromDB(Field* fields)
bool Guild::LoadMemberFromDB(Field* fields)
{
uint32 lowguid = fields[1].GetUInt32();
Member *member = new Member(m_id, ObjectGuid(HIGHGUID_PLAYER, lowguid), fields[2].GetUInt8());
Member *member = new Member(m_id, ObjectGuid(HighGuid::Player, lowguid), fields[2].GetUInt8());
if (!member->LoadFromDB(fields))
{
_DeleteMemberFromDB(lowguid);
@@ -2510,7 +2510,7 @@ void Guild::LoadGuildNewsLogFromDB(Field* fields)
fields[1].GetUInt32(), // guid
fields[6].GetUInt32(), // timestamp //64 bits?
GuildNews(fields[2].GetUInt8()), // type
ObjectGuid(HIGHGUID_PLAYER, fields[3].GetUInt32()), // player guid
ObjectGuid(HighGuid::Player, fields[3].GetUInt32()), // player guid
fields[4].GetUInt32(), // Flags
fields[5].GetUInt32())); // value
}
@@ -2618,7 +2618,7 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin
for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
if (Player* player = itr->second->FindConnectedPlayer())
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()))
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID().GetCounter()))
player->GetSession()->SendPacket(&data);
}
}
@@ -2632,7 +2632,7 @@ void Guild::BroadcastAddonToGuild(WorldSession* session, bool officerOnly, std::
for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
if (Player* player = itr->second->FindPlayer())
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()) &&
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID().GetCounter()) &&
player->GetSession()->IsAddonRegistered(prefix))
player->GetSession()->SendPacket(&data);
}
@@ -3197,7 +3197,7 @@ void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAm
if (pItemSrc->GetCount() == 0)
{
TC_LOG_FATAL("guild", "Guild::SwapItems: Player %s(GUIDLow: %u) tried to move item %u from tab %u slot %u to tab %u slot %u, but item %u has a stack of zero!",
player->GetName(), player->GetGUIDLow(), pItemSrc->GetEntry(), tabId, slotId, destTabId, destSlotId, pItemSrc->GetEntry());
player->GetName(), player->GetGUID().GetCounter(), pItemSrc->GetEntry(), tabId, slotId, destTabId, destSlotId, pItemSrc->GetEntry());
//return; // Commented out for now, uncomment when it's verified that this causes a crash!!
}
// */
@@ -3609,7 +3609,7 @@ void Guild::GiveXP(uint32 xp, Player* source)
void Guild::SendGuildXP(WorldSession* session /* = NULL */) const
{
//Member const* member = GetMember(session->GetGuidLow());
//Member const* member = GetMember(session->GetGUID().GetCounter());
WorldPacket data(SMSG_GUILD_XP, 40);
data << uint64(/*member ? member->GetTotalActivity() :*/ 0);
+1 -1
View File
@@ -777,7 +777,7 @@ public:
// Getters
uint32 GetId() const { return m_id; }
ObjectGuid GetGUID() const { return ObjectGuid(HIGHGUID_GUILD, m_id); }
ObjectGuid GetGUID() const { return ObjectGuid(HighGuid::Guild, m_id); }
ObjectGuid GetLeaderGUID() const { return m_leaderGuid; }
std::string const& GetName() const { return m_name; }
std::string const& GetMOTD() const { return m_motd; }
+1 -1
View File
@@ -102,7 +102,7 @@ void GuildFinderMgr::LoadMembershipRequests()
std::string comment = fields[5].GetString();
uint32 submitTime = fields[6].GetUInt32();
MembershipRequest request(ObjectGuid(HIGHGUID_PLAYER, playerId), guildId, availability, classRoles, interests, comment, time_t(submitTime));
MembershipRequest request(ObjectGuid(HighGuid::Player, playerId), guildId, availability, classRoles, interests, comment, time_t(submitTime));
_membershipRequests[guildId].push_back(request);
@@ -179,7 +179,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recvData)
}
// OK result but don't send invite
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID().GetCounter()))
return;
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam())
@@ -174,7 +174,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
if (bid > MAX_MONEY_AMOUNT || buyout > MAX_MONEY_AMOUNT)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (GUID %u) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (GUID %u) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUID().GetCounter());
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
@@ -226,7 +226,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
if (itemEntry == 0)
itemEntry = item->GetTemplate()->ItemId;
if (sAuctionMgr->GetAItem(item->GetGUIDLow()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
if (sAuctionMgr->GetAItem(item->GetGUID().GetCounter()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
item->GetCount() < count[i] || itemEntry != item->GetTemplate()->ItemId)
{
@@ -286,7 +286,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
AH->houseId = AUCTIONHOUSE_NEUTRAL;
else
{
CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(creature->GetDBTableGUIDLow());
CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(creature->GetSpawnId());
if (!auctioneerData)
{
TC_LOG_ERROR("misc", "Data for auctioneer not found (%s)", auctioneer.ToString().c_str());
@@ -314,10 +314,10 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
}
AH->Id = sObjectMgr->GenerateAuctionID();
AH->itemGUIDLow = item->GetGUIDLow();
AH->itemGUIDLow = item->GetGUID().GetCounter();
AH->itemEntry = item->GetEntry();
AH->itemCount = item->GetCount();
AH->owner = _player->GetGUIDLow();
AH->owner = _player->GetGUID().GetCounter();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;
@@ -328,7 +328,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
AH->auctionHouseEntry = auctionHouseEntry;
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
_player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
_player->GetName().c_str(), _player->GetGUID().GetCounter(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUID().GetCounter(), item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(item);
auctionHouse->AddAuction(AH);
sAuctionMgr->PendingAuctionAdd(_player, AH);
@@ -365,10 +365,10 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
}
AH->Id = sObjectMgr->GenerateAuctionID();
AH->itemGUIDLow = newItem->GetGUIDLow();
AH->itemGUIDLow = newItem->GetGUID().GetCounter();
AH->itemEntry = newItem->GetEntry();
AH->itemCount = newItem->GetCount();
AH->owner = _player->GetGUIDLow();
AH->owner = _player->GetGUID().GetCounter();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;
@@ -379,7 +379,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
AH->auctionHouseEntry = auctionHouseEntry;
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
_player->GetName().c_str(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUIDLow(), newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
_player->GetName().c_str(), _player->GetGUID().GetCounter(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUID().GetCounter(), newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(newItem);
auctionHouse->AddAuction(AH);
sAuctionMgr->PendingAuctionAdd(_player, AH);
@@ -455,7 +455,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
Player* player = GetPlayer();
if (!auction || auction->owner == player->GetGUIDLow())
if (!auction || auction->owner == player->GetGUID().GetCounter())
{
//you cannot bid your own auction:
SendAuctionCommandResult(NULL, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
@@ -463,7 +463,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
}
// impossible have online own another character (use this for speedup check in case online owner)
ObjectGuid ownerGuid(HIGHGUID_PLAYER, auction->owner);
ObjectGuid ownerGuid(HighGuid::Player, auction->owner);
Player* auction_owner = ObjectAccessor::FindPlayer(ownerGuid);
if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(ownerGuid) == player->GetSession()->GetAccountId())
{
@@ -498,7 +498,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
{
if (auction->bidder > 0)
{
if (auction->bidder == player->GetGUIDLow())
if (auction->bidder == player->GetGUID().GetCounter())
player->ModifyMoney(-int64(price - auction->bid));
else
{
@@ -510,7 +510,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
else
player->ModifyMoney(-int64(price));
auction->bidder = player->GetGUIDLow();
auction->bidder = player->GetGUID().GetCounter();
auction->bid = price;
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
@@ -525,7 +525,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
else
{
//buyout:
if (player->GetGUIDLow() == auction->bidder)
if (player->GetGUID().GetCounter() == auction->bidder)
player->ModifyMoney(-int64(auction->buyout - auction->bid));
else
{
@@ -533,7 +533,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
if (auction->bidder) //buyout for bidded auction ..
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);
}
auction->bidder = player->GetGUIDLow();
auction->bidder = player->GetGUID().GetCounter();
auction->bid = auction->buyout;
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
@@ -580,7 +580,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData)
Player* player = GetPlayer();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (auction && auction->owner == player->GetGUIDLow())
if (auction && auction->owner == player->GetGUID().GetCounter())
{
Item* pItem = sAuctionMgr->GetAItem(auction->itemGUIDLow);
if (pItem)
@@ -610,7 +610,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData)
{
SendAuctionCommandResult(NULL, AUCTION_CANCEL, ERR_AUCTION_DATABASE_ERROR);
//this code isn't possible ... maybe there should be assert
TC_LOG_ERROR("network", "CHEATER: %u tried to cancel auction (id: %u) of another player or auction is NULL", player->GetGUIDLow(), auctionId);
TC_LOG_ERROR("network", "CHEATER: %u tried to cancel auction (id: %u) of another player or auction is NULL", player->GetGUID().GetCounter(), auctionId);
return;
}
@@ -104,7 +104,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
TC_LOG_ERROR("network", "Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUIDLow());
TC_LOG_ERROR("network", "Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUID().GetCounter());
return;
}
@@ -212,7 +212,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",
bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str());
bgQueueTypeId, bgTypeId, _player->GetGUID().GetCounter(), _player->GetName().c_str());
}
else
{
@@ -262,7 +262,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, ginfo->ArenaType);
member->GetSession()->SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",
bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str());
bgQueueTypeId, bgTypeId, member->GetGUID().GetCounter(), member->GetName().c_str());
}
TC_LOG_DEBUG("bg.battleground", "Battleground: group end");
}
@@ -390,7 +390,7 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recvData)
BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
if (!bl)
{
TC_LOG_DEBUG("bg.battleground", "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("bg.battleground", "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName().c_str(), _player->GetGUID().GetCounter());
return;
}
@@ -509,13 +509,13 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
sBattlegroundMgr->BuildStatusFailedPacket(&data2, bg, _player, 0, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->GetSession()->SendPacket(&data2);
action = 0;
TC_LOG_DEBUG("bg.battleground", "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("bg.battleground", "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUID().GetCounter());
}
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
TC_LOG_DEBUG("network", "Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
_player->GetName().c_str(), _player->GetGUID().GetCounter(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
@@ -565,7 +565,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player, team);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
}
else // leave queue
{
@@ -589,7 +589,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
if (!ginfo.ArenaType)
sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetTypeID(), bgQueueTypeId);
}
}
@@ -772,7 +772,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, arenatype);
member->GetSession()->SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUID().GetCounter(), member->GetName().c_str());
}
sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
+1 -1
View File
@@ -451,7 +451,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
{
Field* fields = result->Fetch();
inviteeGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
inviteeGuid = ObjectGuid(HighGuid::Player, fields[0].GetUInt32());
inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
}
@@ -240,7 +240,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)
do
{
ObjectGuid guid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
ObjectGuid guid(HighGuid::Player, (*result)[0].GetUInt32());
TC_LOG_INFO("network", "Loading char guid %s from account %u.", guid.ToString().c_str(), GetAccountId());
@@ -628,7 +628,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
Player newChar(this);
newChar.GetMotionMaster()->Initialize();
if (!newChar.Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PLAYER), createInfo))
if (!newChar.Create(sObjectMgr->GetGenerator<HighGuid::Player>().Generate(), createInfo))
{
// Player not create (race/class/etc problem?)
newChar.CleanupsBeforeDelete();
@@ -665,7 +665,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
SendCharCreate(CHAR_CREATE_SUCCESS);
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().GetCounter());
sScriptMgr->OnPlayerCreate(&newChar);
sWorld->AddCharacterNameData(newChar.GetGUID(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
@@ -913,7 +913,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
TC_LOG_DEBUG("network", "WORLD: Sent server info");
}
//QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, rank FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUIDLow());
//QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, rank FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUID().GetCounter());
if (PreparedQueryResult resultGuild = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GUILD))
{
Field* fields = resultGuild->Fetch();
@@ -984,7 +984,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
else
{
// remove wrong guild data
TC_LOG_ERROR("misc", "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId());
TC_LOG_ERROR("misc", "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUID().GetCounter(), pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
@@ -992,7 +992,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
pCurrChar->SendInitialPacketsAfterAddToMap();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ONLINE);
stmt->setUInt32(0, pCurrChar->GetGUIDLow());
stmt->setUInt32(0, pCurrChar->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_ONLINE);
@@ -1010,7 +1010,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
}
// friend status
sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);
sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUID().GetCounter(), true);
// Place character in world (and load zone) before some object loading
pCurrChar->LoadCorpse();
@@ -1080,7 +1080,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
std::string IP_str = GetRemoteAddress();
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d",
GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel());
GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUID().GetCounter(), pCurrChar->getLevel());
if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
+2 -2
View File
@@ -164,7 +164,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
break;
default:
TC_LOG_ERROR("network", "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
recvData.rfinish();
return;
@@ -283,7 +283,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && !ChatHandler(this).isValidChatMessage(msg.c_str()))
{
TC_LOG_ERROR("network", "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(),
GetPlayer()->GetGUIDLow(), msg.c_str());
GetPlayer()->GetGUID().GetCounter(), msg.c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
+1 -1
View File
@@ -75,7 +75,7 @@ void WorldSession::HandleSetSheathedOpcode(WorldPacket& recvData)
uint32 sheathed;
recvData >> sheathed;
//TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed);
//TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUID().GetCounter(), sheathed);
if (sheathed >= MAX_SHEATH_STATE)
{
+2 -2
View File
@@ -40,8 +40,8 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
return;
//TC_LOG_DEBUG("network", "WORLD: Received CMSG_DUEL_ACCEPTED");
TC_LOG_DEBUG("network", "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str());
TC_LOG_DEBUG("network", "Player 1 is: %u (%s)", player->GetGUID().GetCounter(), player->GetName().c_str());
TC_LOG_DEBUG("network", "Player 2 is: %u (%s)", plTarget->GetGUID().GetCounter(), plTarget->GetName().c_str());
time_t now = time(NULL);
player->duel->startTimer = now;
+4 -4
View File
@@ -139,7 +139,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
return;
}
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID().GetCounter()))
{
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S);
return;
@@ -344,7 +344,7 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recvData)
if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
{
TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
return;
}
@@ -411,7 +411,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
if (guid == GetPlayer()->GetGUID())
{
TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
return;
}
@@ -456,7 +456,7 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData)
if (GetPlayer()->GetName() == membername)
{
TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
return;
}
@@ -26,7 +26,7 @@ void WorldSession::HandleGuildFinderAddRecruit(WorldPacket& recvPacket)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_ADD_RECRUIT");
if (sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUIDLow()).size() == 10)
if (sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUID().GetCounter()).size() == 10)
return;
uint32 classRoles = 0;
@@ -94,7 +94,7 @@ void WorldSession::HandleGuildFinderBrowse(WorldPacket& recvPacket)
Player* player = GetPlayer();
LFGuildPlayer settings(player->GetGUIDLow(), classRoles, availability, guildInterests, ANY_FINDER_LEVEL);
LFGuildPlayer settings(player->GetGUID().GetCounter(), classRoles, availability, guildInterests, ANY_FINDER_LEVEL);
LFGuildStore guildList = sGuildFinderMgr->GetGuildsMatchingSetting(settings, player->GetTeamId());
uint32 guildCount = guildList.size();
@@ -150,7 +150,7 @@ void WorldSession::HandleGuildFinderBrowse(WorldPacket& recvPacket)
bufferData.WriteByteSeq(guildGUID[7]);
bufferData << uint8(sGuildFinderMgr->HasRequest(player->GetGUIDLow(), guild->GetGUID())); // Request pending
bufferData << uint8(sGuildFinderMgr->HasRequest(player->GetGUID().GetCounter(), guild->GetGUID())); // Request pending
bufferData.WriteByteSeq(guildGUID[2]);
bufferData.WriteByteSeq(guildGUID[0]);
@@ -208,7 +208,7 @@ void WorldSession::HandleGuildFinderGetApplications(WorldPacket& /*recvPacket*/)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_GET_APPLICATIONS"); // Empty opcode
std::list<MembershipRequest> applicatedGuilds = sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUIDLow());
std::list<MembershipRequest> applicatedGuilds = sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUID().GetCounter());
uint32 applicationsCount = applicatedGuilds.size();
WorldPacket data(SMSG_LF_GUILD_MEMBERSHIP_LIST_UPDATED, 7 + 54 * applicationsCount);
data.WriteBits(applicationsCount, 20);
@@ -260,7 +260,7 @@ void WorldSession::HandleGuildFinderGetApplications(WorldPacket& /*recvPacket*/)
data.FlushBits();
data.append(bufferData);
}
data << uint32(10 - sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUIDLow())); // Applications count left
data << uint32(10 - sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUID().GetCounter())); // Applications count left
GetPlayer()->SendDirectMessage(&data);
}
@@ -397,7 +397,7 @@ void WorldSession::HandleGuildFinderRemoveRecruit(WorldPacket& recvPacket)
if (!guildGuid.IsGuild())
return;
sGuildFinderMgr->RemoveMembershipRequest(GetPlayer()->GetGUIDLow(), guildGuid.GetCounter());
sGuildFinderMgr->RemoveMembershipRequest(GetPlayer()->GetGUID().GetCounter(), guildGuid.GetCounter());
}
// Sent any time a guild master sets an option in the interface and when listing / unlisting his guild
+12 -12
View File
@@ -1029,7 +1029,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GIFT);
stmt->setUInt32(0, item->GetOwnerGUID().GetCounter());
stmt->setUInt32(1, item->GetGUIDLow());
stmt->setUInt32(1, item->GetGUID().GetCounter());
stmt->setUInt32(2, item->GetEntry());
stmt->setUInt32(3, item->GetUInt32Value(ITEM_FIELD_FLAGS));
trans->Append(stmt);
@@ -1369,7 +1369,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
if (count >= EQUIPMENT_SLOT_END)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) sent a wrong count (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), count);
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) sent a wrong count (%u) when transmogrifying items.", player->GetGUID().GetCounter(), player->GetName().c_str(), count);
recvData.rfinish();
return;
}
@@ -1444,7 +1444,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
// slot of the transmogrified item
if (slots[i] >= EQUIPMENT_SLOT_END)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify %s with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), itemGuids[i].ToString().c_str(), slots[i]);
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify %s with a wrong slot (%u) when transmogrifying items.", player->GetGUID().GetCounter(), player->GetName().c_str(), itemGuids[i].ToString().c_str(), slots[i]);
return;
}
@@ -1452,7 +1452,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i]);
if (!itemTransmogrified)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName().c_str(), slots[i]);
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUID().GetCounter(), player->GetName().c_str(), slots[i]);
return;
}
@@ -1464,7 +1464,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(newEntries[i]);
if (!proto)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify to an invalid item (entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), newEntries[i]);
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify to an invalid item (entry: %u).", player->GetGUID().GetCounter(), player->GetName().c_str(), newEntries[i]);
return;
}
@@ -1472,21 +1472,21 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
itemTransmogrifier = player->GetItemByGuid(itemGuids[i]);
if (!itemTransmogrifier)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (%s).", player->GetGUIDLow(), player->GetName().c_str(), itemGuids[i].ToString().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (%s).", player->GetGUID().GetCounter(), player->GetName().c_str(), itemGuids[i].ToString().c_str());
return;
}
// entry of transmogrifier and from packet
if (itemTransmogrifier->GetEntry() != newEntries[i])
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid entry (entry: %u) for %s.", player->GetGUIDLow(), player->GetName().c_str(), newEntries[i], itemGuids[i].ToString().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid entry (entry: %u) for %s.", player->GetGUID().GetCounter(), player->GetName().c_str(), newEntries[i], itemGuids[i].ToString().c_str());
return;
}
// validity of the transmogrification items
if (!Item::CanTransmogrifyItemWithItem(itemTransmogrified, itemTransmogrifier))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry());
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUID().GetCounter(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry());
return;
}
@@ -1583,7 +1583,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData)
if (!item)
{
TC_LOG_DEBUG("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUID().GetCounter(), player->GetName().c_str());
SendReforgeResult(false);
return;
}
@@ -1592,7 +1592,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData)
{
if (!item->GetEnchantmentId(REFORGE_ENCHANTMENT_SLOT))
{
TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to remove reforge from non-reforged item (Entry: %u)", player->GetGUIDLow(), player->GetName().c_str(), item->GetEntry());
TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to remove reforge from non-reforged item (Entry: %u)", player->GetGUID().GetCounter(), player->GetName().c_str(), item->GetEntry());
SendReforgeResult(false);
return;
}
@@ -1607,7 +1607,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData)
if (item->GetEnchantmentId(REFORGE_ENCHANTMENT_SLOT))
{
TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an already reforged item (Entry: %u)", player->GetGUIDLow(), player->GetName().c_str(), item->GetEntry());
TC_LOG_ERROR("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an already reforged item (Entry: %u)", player->GetGUID().GetCounter(), player->GetName().c_str(), item->GetEntry());
SendReforgeResult(false);
return;
}
@@ -1615,7 +1615,7 @@ void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData)
ItemReforgeEntry const* stats = sItemReforgeStore.LookupEntry(reforgeEntry);
if (!stats)
{
TC_LOG_DEBUG("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUIDLow(), player->GetName().c_str(), reforgeEntry);
TC_LOG_DEBUG("network", "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUID().GetCounter(), player->GetName().c_str(), reforgeEntry);
SendReforgeResult(false);
return;
}
+5 -5
View File
@@ -111,7 +111,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
switch (guid.GetHigh())
{
case HIGHGUID_GAMEOBJECT:
case HighGuid::GameObject:
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
@@ -121,7 +121,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
case HighGuid::Corpse: // remove insignia ONLY in BG
{
Corpse* bones = ObjectAccessor::GetCorpse(*player, guid);
@@ -133,7 +133,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
break;
}
case HIGHGUID_ITEM:
case HighGuid::Item:
{
if (Item* item = player->GetItemByGuid(guid))
{
@@ -142,8 +142,8 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
}
break;
}
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
case HighGuid::Unit:
case HighGuid::Vehicle:
{
Creature* creature = player->GetMap()->GetCreature(guid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
+11 -11
View File
@@ -160,7 +160,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
{
TC_LOG_INFO("network", "Player %u is sending mail to %s (GUID: not existed!) with subject %s "
"and body %s includes %u items, " UI64FMTD " copper and " UI64FMTD " COD copper with unk1 = %u, unk2 = %u",
player->GetGUIDLow(), receiverName.c_str(), subject.c_str(), body.c_str(),
player->GetGUID().GetCounter(), receiverName.c_str(), subject.c_str(), body.c_str(),
items_count, money, COD, stationery, package);
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return;
@@ -168,7 +168,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
TC_LOG_INFO("network", "Player %u is sending mail to %s (%s) with subject %s and body %s "
"includes %u items, " UI64FMTD " copper and " UI64FMTD " COD copper with unk1 = %u, unk2 = %u",
player->GetGUIDLow(), receiverName.c_str(), receiverGuid.ToString().c_str(), subject.c_str(),
player->GetGUID().GetCounter(), receiverName.c_str(), receiverGuid.ToString().c_str(), subject.c_str(),
body.c_str(), items_count, money, COD, stationery, package);
if (player->GetGUID() == receiverGuid)
@@ -349,7 +349,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (log)
{
sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail item: %s (Entry: %u Count: %u) "
"to: %s (%s) (Account: %u)", GetPlayerName().c_str(), GetGuidLow(), GetAccountId(),
"to: %s (%s) (Account: %u)", GetPlayerName().c_str(), GetGUIDLow(), GetAccountId(),
item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount(),
receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
@@ -371,7 +371,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (log && money > 0)
{
sLog->outCommand(GetAccountId(), "GM %s (GUID: %u) (Account: %u) mail money: " UI64FMTD " to: %s (%s) (Account: %u)",
GetPlayerName().c_str(), GetGuidLow(), GetAccountId(), money, receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
GetPlayerName().c_str(), GetGUIDLow(), GetAccountId(), money, receiverName.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
}
}
@@ -553,7 +553,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
{
ObjectGuid sender_guid(HIGHGUID_PLAYER, m->sender);
ObjectGuid sender_guid(HighGuid::Player, m->sender);
Player* receiver = ObjectAccessor::FindConnectedPlayer(sender_guid);
uint32 sender_accId = 0;
@@ -593,7 +593,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
player->m_mailsUpdated = true;
player->RemoveMItem(it->GetGUIDLow());
player->RemoveMItem(it->GetGUID().GetCounter());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
it->SetState(ITEM_UNCHANGED); // need to set this state, otherwise item cannot be removed later, if neccessary
@@ -707,7 +707,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData)
switch ((*itr)->messageType)
{
case MAIL_NORMAL: // sender guid
data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender);
data << ObjectGuid(HighGuid::Player, (*itr)->sender);
break;
case MAIL_CREATURE:
case MAIL_GAMEOBJECT:
@@ -734,7 +734,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData)
// item index (0-6?)
data << uint8(i);
// item guid low?
data << uint32((item ? item->GetGUIDLow() : 0));
data << uint32((item ? item->GetGUID().GetCounter() : 0));
// entry
data << uint32((item ? item->GetEntry() : 0));
for (uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j)
@@ -794,7 +794,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData)
}
Item* bodyItem = new Item; // This is not bag and then can be used new Item.
if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, player))
if (!bodyItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), MAIL_BODY_ITEM_TEMPLATE, player))
{
delete bodyItem;
return;
@@ -816,7 +816,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData)
bodyItem->SetText(m->body);
if (m->messageType == MAIL_NORMAL)
bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HIGHGUID_PLAYER, m->sender));
bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid(HighGuid::Player, m->sender));
bodyItem->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_MAIL_TEXT_MASK);
@@ -871,7 +871,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket& /*recvData*/)
if (sentSenders.count(m->sender))
continue;
data << uint64(m->messageType == MAIL_NORMAL ? ObjectGuid(HIGHGUID_PLAYER, m->sender) : ObjectGuid::Empty); // player guid
data << uint64(m->messageType == MAIL_NORMAL ? ObjectGuid(HighGuid::Player, m->sender) : ObjectGuid::Empty); // player guid
data << uint32(m->messageType != MAIL_NORMAL ? m->sender : 0); // non-player entries
data << uint32(m->messageType);
data << uint32(m->stationery);
+17 -17
View File
@@ -67,7 +67,7 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData)
if (GetPlayer()->getDeathState() == JUST_DIED)
{
TC_LOG_DEBUG("network", "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
GetPlayer()->KillPlayer();
}
@@ -595,7 +595,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std
{
Field* fields = result->Fetch();
friendGuid = ObjectGuid(HIGHGUID_PLAYER, 0, fields[0].GetUInt32());
friendGuid = ObjectGuid(HighGuid::Player, 0, fields[0].GetUInt32());
team = Player::TeamForRace(fields[1].GetUInt8());
friendAccountId = fields[2].GetUInt32();
@@ -680,7 +680,7 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(PreparedQueryResult result)
if (result)
{
IgnoreGuid = ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
IgnoreGuid = ObjectGuid(HighGuid::Player, (*result)[0].GetUInt32());
if (IgnoreGuid)
{
@@ -844,7 +844,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
if (player->IsInFlight())
{
TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u",
player->GetName().c_str(), player->GetGUIDLow(), triggerId);
player->GetName().c_str(), player->GetGUID().GetCounter(), triggerId);
return;
}
@@ -852,14 +852,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
if (!atEntry)
{
TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u",
player->GetName().c_str(), player->GetGUIDLow(), triggerId);
player->GetName().c_str(), player->GetGUID().GetCounter(), triggerId);
return;
}
if (!player->IsInAreaTriggerRadius(atEntry))
{
TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far, ignore Area Trigger ID: %u",
player->GetName().c_str(), player->GetGUIDLow(), triggerId);
player->GetName().c_str(), player->GetGUID().GetCounter(), triggerId);
return;
}
@@ -1286,7 +1286,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recvData)
if (GetPlayer()->IsInFlight())
{
TC_LOG_DEBUG("network", "Player '%s' (GUID: %u) in flight, ignore worldport command.",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
return;
}
@@ -1431,7 +1431,7 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recvData)
if (apply)
{
TC_LOG_DEBUG("network", "Added FarSight %s to player %u", _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("network", "Added FarSight %s to player %u", _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str(), _player->GetGUID().GetCounter());
if (WorldObject* target = _player->GetViewpoint())
_player->SetSeer(target);
else
@@ -1439,7 +1439,7 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recvData)
}
else
{
TC_LOG_DEBUG("network", "Player %u set vision to self", _player->GetGUIDLow());
TC_LOG_DEBUG("network", "Player %u set vision to self", _player->GetGUID().GetCounter());
_player->SetSeer(_player);
}
@@ -1508,7 +1508,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData)
if (mode >= MAX_DUNGEON_DIFFICULTY)
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode);
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUID().GetCounter(), mode);
return;
}
@@ -1520,7 +1520,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData)
if (map && map->IsDungeon())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!",
_player->GetName().c_str(), _player->GetGUIDLow());
_player->GetName().c_str(), _player->GetGUID().GetCounter());
return;
}
@@ -1541,7 +1541,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData)
if (groupGuy->GetMap()->IsNonRaidDungeon())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!",
_player->GetGUIDLow(), groupGuy->GetName().c_str(), groupGuy->GetGUIDLow());
_player->GetGUID().GetCounter(), groupGuy->GetName().c_str(), groupGuy->GetGUID().GetCounter());
return;
}
}
@@ -1567,7 +1567,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData)
if (mode >= MAX_RAID_DIFFICULTY)
{
TC_LOG_ERROR("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode);
TC_LOG_ERROR("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUID().GetCounter(), mode);
return;
}
@@ -1575,7 +1575,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData)
Map* map = _player->FindMap();
if (map && map->IsDungeon())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow());
TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUID().GetCounter());
return;
}
@@ -1598,7 +1598,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData)
if (groupGuy->GetMap()->IsRaid())
{
TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow());
TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUID().GetCounter());
return;
}
}
@@ -1835,7 +1835,7 @@ void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket)
if (!_player->HasPendingBind())
{
TC_LOG_INFO("network", "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!",
_player->GetName().c_str(), _player->GetGUIDLow());
_player->GetName().c_str(), _player->GetGUID().GetCounter());
return;
}
@@ -1989,7 +1989,7 @@ void WorldSession::HandleObjectUpdateFailedOpcode(WorldPacket& recvPacket)
recvPacket.ReadByteSeq(guid[5]);
WorldObject* obj = ObjectAccessor::GetWorldObject(*GetPlayer(), guid);
TC_LOG_ERROR("network", "Object update failed for object " UI64FMTD " (%s) for player %s (%u)", uint64(guid), obj ? obj->GetName().c_str() : "object-not-found", GetPlayerName().c_str(), GetGuidLow());
TC_LOG_ERROR("network", "Object update failed for object " UI64FMTD " (%s) for player %s (%u)", uint64(guid), obj ? obj->GetName().c_str() : "object-not-found", GetPlayerName().c_str(), GetGUIDLow());
// If create object failed for current player then client will be stuck on loading screen
if (_player->GetGUID() == guid)
+2 -2
View File
@@ -80,7 +80,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// while the player is in transit, for example the map may get full
if (!newMap || !newMap->CanEnter(GetPlayer()))
{
TC_LOG_ERROR("network", "Map %d (%s) could not be created for player %d (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str());
TC_LOG_ERROR("network", "Map %d (%s) could not be created for player %d (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", GetPlayer()->GetGUID().GetCounter(), GetPlayer()->GetName().c_str());
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
@@ -97,7 +97,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
{
TC_LOG_ERROR("network", "WORLD: failed to teleport player %s (%d) to map %d (%s) because of unknown reason!",
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown");
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown");
GetPlayer()->ResetMap();
GetPlayer()->SetMap(oldMap);
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
+4 -4
View File
@@ -517,7 +517,7 @@ void WorldSession::SendStablePet(ObjectGuid guid)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS_DETAIL);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT);
@@ -621,7 +621,7 @@ void WorldSession::HandleStablePet(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOTS);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(2, PET_SAVE_LAST_STABLE_SLOT);
@@ -681,7 +681,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_ENTRY);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt32(1, petnumber);
stmt->setUInt8(2, PET_SAVE_FIRST_STABLE_SLOT);
stmt->setUInt8(3, PET_SAVE_LAST_STABLE_SLOT);
@@ -810,7 +810,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOT_BY_ID);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt32(1, petId);
_stableSwapCallback.SetParam(petId);
+7 -7
View File
@@ -46,7 +46,7 @@ void WorldSession::HandleDismissCritter(WorldPacket& recvData)
if (!pet)
{
TC_LOG_DEBUG("network", "Vanitypet (%s) does not exist - player '%s' (guid: %u / account: %u) attempted to dismiss it (possibly lagged out)",
guid.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), GetAccountId());
guid.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter(), GetAccountId());
return;
}
@@ -151,7 +151,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
if (!charmInfo)
{
TC_LOG_DEBUG("network", "WorldSession::HandlePetAction(petGuid: %s, tagGuid: %s, spellId: %u, flag: %u): object (GUID: %u Entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!",
guid1.ToString().c_str(), guid2.ToString().c_str(), spellid, flag, pet->GetGUIDLow(), pet->GetEntry(), pet->GetTypeId());
guid1.ToString().c_str(), guid2.ToString().c_str(), spellid, flag, pet->GetGUID().GetCounter(), pet->GetEntry(), pet->GetTypeId());
return;
}
@@ -499,7 +499,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
TC_LOG_ERROR("network", "WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
TC_LOG_ERROR("network", "WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().GetCounter(), pet->GetTypeId());
return;
}
@@ -610,7 +610,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
recvData >> name;
recvData >> isdeclined;
Pet* pet = ObjectAccessor::FindPet(petguid);
Pet* pet = ObjectAccessor::GetPet(*_player, petguid);
// check it!
if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
!pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ||
@@ -663,7 +663,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
for (uint8 i = 0; i < 5; i++)
stmt->setString(i + 1, declinedname.name[i]);
@@ -673,7 +673,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_NAME);
stmt->setString(0, name);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(1, _player->GetGUID().GetCounter());
stmt->setUInt32(2, pet->GetCharmInfo()->GetPetNumber());
trans->Append(stmt);
@@ -738,7 +738,7 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().GetCounter(), pet->GetTypeId());
return;
}
+19 -19
View File
@@ -191,7 +191,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
if (!charter)
return;
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow());
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUID().GetCounter());
// ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
// ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
charter->SetState(ITEM_CHANGED, _player);
@@ -201,7 +201,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
// we checked above, if this player is in an arenateam, so this must be
// datacorruption
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_BY_OWNER);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, type);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -217,7 +217,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
}
// delete petitions with the same guid as this one
ssInvalidPetitionGUIDs << '\'' << charter->GetGUIDLow() << '\'';
ssInvalidPetitionGUIDs << '\'' << charter->GetGUID().GetCounter() << '\'';
TC_LOG_DEBUG("network", "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
CharacterDatabase.EscapeString(name);
@@ -226,8 +226,8 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(1, charter->GetGUIDLow());
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt32(1, charter->GetGUID().GetCounter());
stmt->setString(2, name);
stmt->setUInt8(3, uint8(type));
trans->Append(stmt);
@@ -253,7 +253,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
if (!result)
{
TC_LOG_DEBUG("entities.player.items", "Petition %s is not found for player %u %s", petitionguid.ToString().c_str(), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str());
TC_LOG_DEBUG("entities.player.items", "Petition %s is not found for player %u %s", petitionguid.ToString().c_str(), GetPlayer()->GetGUID().GetCounter(), GetPlayer()->GetName().c_str());
return;
}
Field* fields = result->Fetch();
@@ -286,7 +286,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
Field* fields2 = result->Fetch();
uint32 lowGuid = fields2[0].GetUInt32();
data << ObjectGuid(HIGHGUID_PLAYER, 0, lowGuid); // Player GUID
data << ObjectGuid(HighGuid::Player, 0, lowGuid); // Player GUID
data << uint32(0); // there 0 ...
result->NextRow();
@@ -322,7 +322,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
if (result)
{
Field* fields = result->Fetch();
ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
ownerguid = ObjectGuid(HighGuid::Player, fields[0].GetUInt32());
name = fields[1].GetString();
type = fields[2].GetUInt8();
}
@@ -461,16 +461,16 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData)
if (!result)
{
TC_LOG_ERROR("network", "Petition %s is not found for player %u %s", petitionGuid.ToString().c_str(), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str());
TC_LOG_ERROR("network", "Petition %s is not found for player %u %s", petitionGuid.ToString().c_str(), GetPlayer()->GetGUID().GetCounter(), GetPlayer()->GetName().c_str());
return;
}
fields = result->Fetch();
ObjectGuid ownerGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
ObjectGuid ownerGuid(HighGuid::Player, fields[0].GetUInt32());
uint64 signs = fields[1].GetUInt64();
uint8 type = fields[2].GetUInt8();
uint32 playerGuid = _player->GetGUIDLow();
uint32 playerGuid = _player->GetGUID().GetCounter();
if (ownerGuid == _player->GetGUID())
return;
@@ -581,7 +581,7 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recvData)
ObjectGuid petitionguid;
recvData >> petitionguid; // petition guid
TC_LOG_DEBUG("network", "Petition %s declined by %u", petitionguid.ToString().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("network", "Petition %s declined by %u", petitionguid.ToString().c_str(), _player->GetGUID().GetCounter());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_OWNER_BY_GUID);
@@ -593,7 +593,7 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recvData)
return;
Field* fields = result->Fetch();
ObjectGuid ownerguid(HIGHGUID_PLAYER, 0, fields[0].GetUInt32());
ObjectGuid ownerguid(HighGuid::Player, 0, fields[0].GetUInt32());
Player* owner = ObjectAccessor::FindConnectedPlayer(ownerguid);
if (owner) // petition owner online
@@ -704,7 +704,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
for (uint8 i = 1; i <= signs; ++i)
{
Field* fields2 = result->Fetch();
data << uint64(ObjectGuid(HIGHGUID_PLAYER, fields2[0].GetUInt32())); // Player GUID
data << uint64(ObjectGuid(HighGuid::Player, fields2[0].GetUInt32())); // Player GUID
data << uint32(0); // there 0 ...
result->NextRow();
@@ -728,7 +728,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
if (!item)
return;
TC_LOG_DEBUG("network", "Petition %s turned in by %u", petitionGuid.ToString().c_str(), _player->GetGUIDLow());
TC_LOG_DEBUG("network", "Petition %s turned in by %u", petitionGuid.ToString().c_str(), _player->GetGUID().GetCounter());
// Get petition data from db
uint32 ownerguidlo;
@@ -748,12 +748,12 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
}
else
{
TC_LOG_ERROR("network", "Player %s (guid: %u) tried to turn in petition (%s) that is not present in the database", _player->GetName().c_str(), _player->GetGUIDLow(), petitionGuid.ToString().c_str());
TC_LOG_ERROR("network", "Player %s (guid: %u) tried to turn in petition (%s) that is not present in the database", _player->GetName().c_str(), _player->GetGUID().GetCounter(), petitionGuid.ToString().c_str());
return;
}
// Only the petition owner can turn in the petition
if (_player->GetGUIDLow() != ownerguidlo)
if (_player->GetGUID().GetCounter() != ownerguidlo)
return;
// Petition type (guild/arena) specific checks
@@ -849,7 +849,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
for (uint8 i = 0; i < signatures; ++i)
{
Field* fields = result->Fetch();
guild->AddMember(ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()));
guild->AddMember(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()));
result->NextRow();
}
}
@@ -876,7 +876,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
for (uint8 i = 0; i < signatures; ++i)
{
Field* fields = result->Fetch();
ObjectGuid memberGUID(HIGHGUID_PLAYER, fields[0].GetUInt32());
ObjectGuid memberGUID(HighGuid::Player, fields[0].GetUInt32());
TC_LOG_DEBUG("network", "PetitionsHandler: Adding arena team (guid: %u) member %s", arenaTeam->GetId(), memberGUID.ToString().c_str());
arenaTeam->AddMember(memberGUID);
result->NextRow();
+7 -7
View File
@@ -48,14 +48,14 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData)
{
case TYPEID_UNIT:
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u", questGiver->GetGUIDLow());
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u", questGiver->GetGUID().GetCounter());
if (!questGiver->ToCreature()->IsHostileTo(_player)) // do not show quest status to enemies
questStatus = _player->GetQuestDialogStatus(questGiver);
break;
}
case TYPEID_GAMEOBJECT:
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u", questGiver->GetGUIDLow());
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u", questGiver->GetGUID().GetCounter());
questStatus = _player->GetQuestDialogStatus(questGiver);
break;
}
@@ -257,7 +257,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData)
if (reward >= QUEST_REWARD_CHOICES_COUNT)
{
TC_LOG_ERROR("network", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUIDLow(), reward);
TC_LOG_ERROR("network", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().GetCounter(), reward);
return;
}
@@ -284,7 +284,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData)
(_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete()))
{
TC_LOG_ERROR("network", "Error in QUEST_STATUS_COMPLETE: player %s (guid %u) tried to complete quest %u, but is not allowed to do so (possible packet-hacking or high latency)",
_player->GetName().c_str(), _player->GetGUIDLow(), questId);
_player->GetName().c_str(), _player->GetGUID().GetCounter(), questId);
return;
}
@@ -427,14 +427,14 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData)
_player->RemoveActiveQuest(questId);
_player->RemoveTimedAchievement(ACHIEVEMENT_TIMED_TYPE_QUEST, questId);
TC_LOG_INFO("network", "Player %u abandoned quest %u", _player->GetGUIDLow(), questId);
TC_LOG_INFO("network", "Player %u abandoned quest %u", _player->GetGUID().GetCounter(), questId);
if (sWorld->getBoolConfig(CONFIG_QUEST_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
// prepare Quest Tracker datas
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME);
stmt->setUInt32(0, questId);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(1, _player->GetGUID().GetCounter());
// add to Quest Tracker
CharacterDatabase.Execute(stmt);
@@ -523,7 +523,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData)
if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE)
{
TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [guid: %u] tried to complete quest [entry: %u] without being in possession of the quest!",
_player->GetName().c_str(), _player->GetGUIDLow(), questId);
_player->GetName().c_str(), _player->GetGUID().GetCounter(), questId);
return;
}
@@ -27,7 +27,7 @@ void WorldSession::HandleGrantLevel(WorldPacket& recvData)
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
Player* target = ObjectAccessor::GetObjectInWorld(guid, _player);
Player* target = ObjectAccessor::GetPlayer(*_player, guid);
// check cheating
uint8 levels = _player->GetGrantableLevels();
@@ -70,7 +70,7 @@ void WorldSession::HandleAcceptGrantLevel(WorldPacket& recvData)
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
Player* other = ObjectAccessor::GetObjectInWorld(guid, _player);
Player* other = ObjectAccessor::GetPlayer(*_player, guid);
if (!(other && other->GetSession()))
return;
+6 -6
View File
@@ -219,7 +219,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
{
pUser->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, NULL);
TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
pUser->GetName().c_str(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId);
pUser->GetName().c_str(), pUser->GetGUID().GetCounter(), item->GetGUID().GetCounter(), proto->ItemId);
return;
}
@@ -232,7 +232,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
if (!lockInfo)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
TC_LOG_ERROR("network", "WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", item->GetGUIDLow(), lockId);
TC_LOG_ERROR("network", "WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", item->GetGUID().GetCounter(), lockId);
return;
}
@@ -248,7 +248,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUID().GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -265,14 +265,14 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
}
else
{
TC_LOG_ERROR("network", "Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUIDLow());
TC_LOG_ERROR("network", "Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUID().GetCounter());
pUser->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
return;
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -625,7 +625,7 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
recvData.read_skip<uint32>(); // DisplayId ?
// Get unit for which data is needed by client
Unit* unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)NULL);
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
if (!unit)
return;
+2 -2
View File
@@ -217,7 +217,7 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recvData)
recvData >> comment;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SURVEY);
stmt->setUInt32(0, GetPlayer()->GetGUIDLow());
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
stmt->setUInt32(1, nextSurveyID);
stmt->setUInt32(2, mainSurvey);
stmt->setString(3, comment);
@@ -240,7 +240,7 @@ void WorldSession::HandleReportLag(WorldPacket& recvData)
recvData >> z;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LAG_REPORT);
stmt->setUInt32(0, GetPlayer()->GetGUIDLow());
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
stmt->setUInt8 (1, lagType);
stmt->setUInt16(2, mapId);
stmt->setFloat (3, x);
+11 -11
View File
@@ -85,12 +85,12 @@ void WorldSession::SendTradeStatus(TradeStatusInfo const& info)
void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/)
{
TC_LOG_DEBUG("network", "WORLD: Ignore Trade %u", _player->GetGUIDLow());
TC_LOG_DEBUG("network", "WORLD: Ignore Trade %u", _player->GetGUID().GetCounter());
}
void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/)
{
TC_LOG_DEBUG("network", "WORLD: Busy Trade %u", _player->GetGUIDLow());
TC_LOG_DEBUG("network", "WORLD: Busy Trade %u", _player->GetGUID().GetCounter());
}
void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
@@ -223,7 +223,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
if (myItems[i])
{
// logging
TC_LOG_DEBUG("network", "partner storing: %u", myItems[i]->GetGUIDLow());
TC_LOG_DEBUG("network", "partner storing: %u", myItems[i]->GetGUID().GetCounter());
if (HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
{
sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
@@ -241,7 +241,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
if (hisItems[i])
{
// logging
TC_LOG_DEBUG("network", "player storing: %u", hisItems[i]->GetGUIDLow());
TC_LOG_DEBUG("network", "player storing: %u", hisItems[i]->GetGUID().GetCounter());
if (HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
{
sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
@@ -264,21 +264,21 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
if (myItems[i])
{
if (!traderCanTrade)
TC_LOG_ERROR("network", "trader can't store item: %u", myItems[i]->GetGUIDLow());
TC_LOG_ERROR("network", "trader can't store item: %u", myItems[i]->GetGUID().GetCounter());
if (_player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, myItems[i], false) == EQUIP_ERR_OK)
_player->MoveItemToInventory(playerDst, myItems[i], true, true);
else
TC_LOG_ERROR("network", "player can't take item back: %u", myItems[i]->GetGUIDLow());
TC_LOG_ERROR("network", "player can't take item back: %u", myItems[i]->GetGUID().GetCounter());
}
// return the already removed items to the original owner
if (hisItems[i])
{
if (!playerCanTrade)
TC_LOG_ERROR("network", "player can't store item: %u", hisItems[i]->GetGUIDLow());
TC_LOG_ERROR("network", "player can't store item: %u", hisItems[i]->GetGUID().GetCounter());
if (trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, hisItems[i], false) == EQUIP_ERR_OK)
trader->MoveItemToInventory(traderDst, hisItems[i], true, true);
else
TC_LOG_ERROR("network", "trader can't take item back: %u", hisItems[i]->GetGUIDLow());
TC_LOG_ERROR("network", "trader can't take item back: %u", hisItems[i]->GetGUID().GetCounter());
}
}
}
@@ -296,7 +296,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item* *m
{
if (Item* item = myTrade->GetItem(TradeSlots(i)))
{
TC_LOG_DEBUG("network", "player trade item %u bag: %u slot: %u", item->GetGUIDLow(), item->GetBagSlot(), item->GetSlot());
TC_LOG_DEBUG("network", "player trade item %u bag: %u slot: %u", item->GetGUID().GetCounter(), item->GetBagSlot(), item->GetSlot());
//Can return NULL
myItems[i] = item;
myItems[i]->SetInTrade();
@@ -304,7 +304,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item* *m
if (Item* item = hisTrade->GetItem(TradeSlots(i)))
{
TC_LOG_DEBUG("network", "partner trade item %u bag: %u slot: %u", item->GetGUIDLow(), item->GetBagSlot(), item->GetSlot());
TC_LOG_DEBUG("network", "partner trade item %u bag: %u slot: %u", item->GetGUID().GetCounter(), item->GetBagSlot(), item->GetSlot());
hisItems[i] = item;
hisItems[i]->SetInTrade();
}
@@ -767,7 +767,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUID().GetCounter()))
{
info.Status = TRADE_STATUS_IGNORE_YOU;
SendTradeStatus(info);
+3 -3
View File
@@ -59,7 +59,7 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData)
{
recvData.rfinish(); // prevent warnings spam
TC_LOG_ERROR("network", "HandleChangeSeatsOnControlledVehicle, Opcode: %u, Player %u tried to switch seats but current seatflags %u don't permit that.",
recvData.GetOpcode(), GetPlayer()->GetGUIDLow(), seat->m_flags);
recvData.GetOpcode(), GetPlayer()->GetGUID().GetCounter(), seat->m_flags);
return;
}
@@ -188,7 +188,7 @@ void WorldSession::HandleEjectPassenger(WorldPacket& data)
if (seat->IsEjectable())
unit->ExitVehicle();
else
TC_LOG_ERROR("network", "Player %u attempted to eject %s from non-ejectable seat.", GetPlayer()->GetGUIDLow(), guid.ToString().c_str());
TC_LOG_ERROR("network", "Player %u attempted to eject %s from non-ejectable seat.", GetPlayer()->GetGUID().GetCounter(), guid.ToString().c_str());
}
else
TC_LOG_ERROR("network", "HandleEjectPassenger: %s tried to eject invalid %s ", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str());
@@ -206,7 +206,7 @@ void WorldSession::HandleRequestVehicleExit(WorldPacket& /*recvData*/)
GetPlayer()->ExitVehicle();
else
TC_LOG_ERROR("network", "Player %u tried to exit vehicle, but seatflags %u (ID: %u) don't permit that.",
GetPlayer()->GetGUIDLow(), seat->m_ID, seat->m_flags);
GetPlayer()->GetGUID().GetCounter(), seat->m_ID, seat->m_flags);
}
}
}
+10 -10
View File
@@ -68,7 +68,7 @@ void WorldSession::HandleVoidStorageUnlock(WorldPacket& recvData)
if (player->IsVoidStorageUnlocked())
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player (GUID: %u, name: %s) tried to unlock void storage a 2nd time.", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player (GUID: %u, name: %s) tried to unlock void storage a 2nd time.", player->GetGUID().GetCounter(), player->GetName().c_str());
return;
}
@@ -109,7 +109,7 @@ void WorldSession::HandleVoidStorageQuery(WorldPacket& recvData)
if (!player->IsVoidStorageUnlocked())
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUID().GetCounter(), player->GetName().c_str());
return;
}
@@ -200,7 +200,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
if (countDeposit > 9)
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit more than 9 items (%u).", player->GetGUIDLow(), player->GetName().c_str(), countDeposit);
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit more than 9 items (%u).", player->GetGUID().GetCounter(), player->GetName().c_str(), countDeposit);
return;
}
@@ -228,7 +228,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
if (countWithdraw > 9)
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to withdraw more than 9 items (%u).", player->GetGUIDLow(), player->GetName().c_str(), countWithdraw);
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to withdraw more than 9 items (%u).", player->GetGUID().GetCounter(), player->GetName().c_str(), countWithdraw);
return;
}
@@ -290,7 +290,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
if (!player->IsVoidStorageUnlocked())
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUID().GetCounter(), player->GetName().c_str());
return;
}
@@ -331,7 +331,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
Item* item = player->GetItemByGuid(*itr);
if (!item)
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit an invalid item (item guid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr));
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) wants to deposit an invalid item (item guid: " UI64FMTD ").", player->GetGUID().GetCounter(), player->GetName().c_str(), uint64(*itr));
continue;
}
@@ -356,7 +356,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
VoidStorageItem* itemVS = player->GetVoidStorageItem(*itr, slot);
if (!itemVS)
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) tried to withdraw an invalid item (id: " UI64FMTD ")", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr));
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) tried to withdraw an invalid item (id: " UI64FMTD ")", player->GetGUID().GetCounter(), player->GetName().c_str(), uint64(*itr));
continue;
}
@@ -365,7 +365,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
if (msg != EQUIP_ERR_OK)
{
SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_INVENTORY_FULL);
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) couldn't withdraw item id " UI64FMTD " because inventory was full.", player->GetGUIDLow(), player->GetName().c_str(), uint64(*itr));
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (GUID: %u, name: %s) couldn't withdraw item id " UI64FMTD " because inventory was full.", player->GetGUID().GetCounter(), player->GetName().c_str(), uint64(*itr));
return;
}
@@ -527,14 +527,14 @@ void WorldSession::HandleVoidSwapItem(WorldPacket& recvData)
if (!player->IsVoidStorageUnlocked())
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUIDLow(), player->GetName().c_str());
TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) queried void storage without unlocking it.", player->GetGUID().GetCounter(), player->GetName().c_str());
return;
}
uint8 oldSlot;
if (!player->GetVoidStorageItem(itemId, oldSlot))
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) requested swapping an invalid item (slot: %u, itemid: " UI64FMTD ").", player->GetGUIDLow(), player->GetName().c_str(), newSlot, uint64(itemId));
TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (GUID: %u, name: %s) requested swapping an invalid item (slot: %u, itemid: " UI64FMTD ").", player->GetGUID().GetCounter(), player->GetName().c_str(), newSlot, uint64(itemId));
return;
}
@@ -551,7 +551,10 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
if (iMap)
{
iMap->DeleteRespawnTimes();
iMap->DeleteCorpseData();
}
else
Map::DeleteRespawnTimesInDB(mapid, instanceId);
+2 -2
View File
@@ -177,11 +177,11 @@ class InstanceScript : public ZoneScript
inline Creature* GetCreature(uint32 type)
{
return ObjectAccessor::GetObjectInMap<Creature>(GetObjectGuid(type), instance, nullptr);
return instance->GetCreature(GetObjectGuid(type));
}
inline GameObject* GetGameObject(uint32 type)
{
return ObjectAccessor::GetObjectInMap<GameObject>(GetObjectGuid(type), instance, nullptr);
return instance->GetGameObject(GetObjectGuid(type));
}
// Called when a player successfully enters the instance.
+16 -16
View File
@@ -404,7 +404,7 @@ bool LootItem::AllowedForPlayer(Player const* player) const
void LootItem::AddAllowedLooter(const Player* player)
{
allowedGUIDs.insert(player->GetGUIDLow());
allowedGUIDs.insert(player->GetGUID().GetCounter());
}
//
@@ -486,7 +486,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
{
uint32 plguid = player->GetGUIDLow();
uint32 plguid = player->GetGUID().GetCounter();
QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid);
if (qmapitr == PlayerQuestItems.end())
@@ -541,7 +541,7 @@ QuestItemList* Loot::FillFFALoot(Player* player)
return NULL;
}
PlayerFFAItems[player->GetGUIDLow()] = ql;
PlayerFFAItems[player->GetGUID().GetCounter()] = ql;
return ql;
}
@@ -579,7 +579,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
return NULL;
}
PlayerQuestItems[player->GetGUIDLow()] = ql;
PlayerQuestItems[player->GetGUID().GetCounter()] = ql;
return ql;
}
@@ -611,7 +611,7 @@ QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player, bool pres
return NULL;
}
PlayerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql;
PlayerNonQuestNonFFAConditionalItems[player->GetGUID().GetCounter()] = ql;
return ql;
}
@@ -662,7 +662,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
++i_next;
if (Player* player = ObjectAccessor::FindPlayer(*i))
{
QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUID().GetCounter());
if (pq != PlayerQuestItems.end() && pq->second)
{
// find where/if the player has the given item in it's vector
@@ -729,7 +729,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
if (lootSlot >= items.size())
{
uint32 questSlot = lootSlot - items.size();
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
if (itr != PlayerQuestItems.end() && questSlot < itr->second->size())
{
QuestItem* qitem2 = &itr->second->at(questSlot);
@@ -745,7 +745,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
is_looted = item->is_looted;
if (item->freeforall)
{
QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUID().GetCounter());
if (itr != PlayerFFAItems.end())
{
for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
@@ -761,7 +761,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
}
else if (!item->conditions.empty())
{
QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
if (itr != PlayerNonQuestNonFFAConditionalItems.end())
{
for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
@@ -787,7 +787,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
uint32 Loot::GetMaxSlotInLootFor(Player* player) const
{
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
return items.size() + (itr != PlayerQuestItems.end() ? itr->second->size() : 0);
}
@@ -795,7 +795,7 @@ uint32 Loot::GetMaxSlotInLootFor(Player* player) const
bool Loot::hasItemFor(Player* player) const
{
QuestItemMap const& lootPlayerQuestItems = GetPlayerQuestItems();
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUID().GetCounter());
if (q_itr != lootPlayerQuestItems.end())
{
QuestItemList* q_list = q_itr->second;
@@ -808,7 +808,7 @@ bool Loot::hasItemFor(Player* player) const
}
QuestItemMap const& lootPlayerFFAItems = GetPlayerFFAItems();
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUID().GetCounter());
if (ffa_itr != lootPlayerFFAItems.end())
{
QuestItemList* ffa_list = ffa_itr->second;
@@ -821,7 +821,7 @@ bool Loot::hasItemFor(Player* player) const
}
QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = GetPlayerNonQuestNonFFAConditionalItems();
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow());
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{
QuestItemList* conditional_list = nn_itr->second;
@@ -973,7 +973,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
LootSlotType slotType = lv.permission == OWNER_PERMISSION ? LOOT_SLOT_TYPE_OWNER : LOOT_SLOT_TYPE_ALLOW_LOOT;
QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow());
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID().GetCounter());
if (q_itr != lootPlayerQuestItems.end())
{
QuestItemList* q_list = q_itr->second;
@@ -1014,7 +1014,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
}
QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow());
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID().GetCounter());
if (ffa_itr != lootPlayerFFAItems.end())
{
QuestItemList* ffa_list = ffa_itr->second;
@@ -1032,7 +1032,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
}
QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow());
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID().GetCounter());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{
QuestItemList* conditional_list = nn_itr->second;
+10 -10
View File
@@ -45,7 +45,7 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery
break;*/
case TYPEID_PLAYER:
m_messageType = MAIL_NORMAL;
m_senderId = sender->GetGUIDLow();
m_senderId = sender->GetGUID().GetCounter();
break;
default:
m_messageType = MAIL_NORMAL;
@@ -67,19 +67,19 @@ MailSender::MailSender(Player* sender)
{
m_messageType = MAIL_NORMAL;
m_stationery = sender->IsGameMaster() ? MAIL_STATIONERY_GM : MAIL_STATIONERY_DEFAULT;
m_senderId = sender->GetGUIDLow();
m_senderId = sender->GetGUID().GetCounter();
}
MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUIDLow()) { }
MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUID().GetCounter()) { }
MailReceiver::MailReceiver(Player* receiver, uint32 receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid)
{
ASSERT(!receiver || receiver->GetGUIDLow() == receiver_lowguid);
ASSERT(!receiver || receiver->GetGUID().GetCounter() == receiver_lowguid);
}
MailDraft& MailDraft::AddItem(Item* item)
{
m_items[item->GetGUIDLow()] = item; return *this;
m_items[item->GetGUID().GetCounter()] = item; return *this;
}
void MailDraft::prepareItems(Player* receiver, SQLTransaction& trans)
@@ -117,7 +117,7 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/
if (inDB)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUID().GetCounter());
trans->Append(stmt);
}
@@ -129,7 +129,7 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/
void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans)
{
ObjectGuid receiverGuid(HIGHGUID_PLAYER, receiver_guid);
ObjectGuid receiverGuid(HighGuid::Player, receiver_guid);
Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid);
uint32 rc_account = 0;
@@ -158,7 +158,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32
// owner in data will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
stmt->setUInt32(0, receiver_guid);
stmt->setUInt32(1, item->GetGUIDLow());
stmt->setUInt32(1, item->GetGUID().GetCounter());
trans->Append(stmt);
}
}
@@ -226,7 +226,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver,
Item* pItem = mailItemIter->second;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM);
stmt->setUInt32(0, mailId);
stmt->setUInt32(1, pItem->GetGUIDLow());
stmt->setUInt32(1, pItem->GetGUID().GetCounter());
stmt->setUInt32(2, receiver.GetPlayerGUIDLow());
trans->Append(stmt);
}
@@ -249,7 +249,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver,
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
m->AddItem(item->GetGUIDLow(), item->GetEntry());
m->AddItem(item->GetGUID().GetCounter(), item->GetEntry());
}
m->messageType = sender.GetMailMessageType();
+157 -51
View File
@@ -401,7 +401,7 @@ template<>
void Map::DeleteFromWorld(Player* player)
{
sObjectAccessor->RemoveObject(player);
sObjectAccessor->RemoveUpdateObject(player); /// @todo I do not know why we need this, it should be removed in ~Object anyway
RemoveUpdateObject(player); /// @todo I do not know why we need this, it should be removed in ~Object anyway
delete player;
}
@@ -487,7 +487,7 @@ bool Map::AddPlayerToMap(Player* player)
CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
if (!cellCoord.IsCoordValid())
{
TC_LOG_ERROR("maps", "Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
TC_LOG_ERROR("maps", "Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUID().GetCounter(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
return false;
}
@@ -707,6 +707,8 @@ void Map::Update(const uint32 t_diff)
obj->Update(t_diff);
}
SendObjectUpdates();
///- Process necessary scripts
if (!m_scriptSchedule.empty())
{
@@ -943,7 +945,7 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->GetGUIDLow(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->GetGUID().GetCounter(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
AddCreatureToMoveList(creature, x, y, z, ang);
// in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList
@@ -975,7 +977,7 @@ void Map::GameObjectRelocation(GameObject* go, float x, float y, float z, float
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
AddGameObjectToMoveList(go, x, y, z, orientation);
// in diffcell/diffgrid case notifiers called at finishing move go in Map::MoveAllGameObjectsInMoveList
@@ -1008,7 +1010,7 @@ void Map::DynamicObjectRelocation(DynamicObject* dynObj, float x, float y, float
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", dynObj->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", dynObj->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
AddDynamicObjectToMoveList(dynObj, x, y, z, orientation);
// in diffcell/diffgrid case notifiers called at finishing move dynObj in Map::MoveAllGameObjectsInMoveList
@@ -1119,7 +1121,7 @@ void Map::MoveAllCreaturesInMoveList()
{
// ... or unload (if respawn grid also not loaded)
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) cannot be move to unloaded respawn grid.", c->GetGUIDLow(), c->GetEntry());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) cannot be move to unloaded respawn grid.", c->GetGUID().GetCounter(), c->GetEntry());
#endif
//AddObjectToRemoveList(Pet*) should only be called in Pet::Remove
//This may happen when a player just logs in and a pet moves to a nearby unloaded cell
@@ -1173,7 +1175,7 @@ void Map::MoveAllGameObjectsInMoveList()
{
// ... or unload (if respawn grid also not loaded)
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) cannot be move to unloaded respawn grid.", go->GetGUIDLow(), go->GetEntry());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) cannot be move to unloaded respawn grid.", go->GetGUID().GetCounter(), go->GetEntry());
#endif
AddObjectToRemoveList(go);
}
@@ -1212,7 +1214,7 @@ void Map::MoveAllDynamicObjectsInMoveList()
else
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) cannot be moved to unloaded grid.", dynObj->GetGUIDLow());
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) cannot be moved to unloaded grid.", dynObj->GetGUID().GetCounter());
#endif
}
}
@@ -1230,7 +1232,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
if (old_cell.DiffCell(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
#endif
c->RemoveFromGrid();
@@ -1239,7 +1241,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
else
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
#endif
}
@@ -1252,7 +1254,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
EnsureGridLoadedForActiveObject(new_cell, c);
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
c->RemoveFromGrid();
@@ -1265,7 +1267,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
c->RemoveFromGrid();
@@ -1277,7 +1279,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
// fail to move: normal creature attempt move to unloaded grid
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
return false;
}
@@ -1291,7 +1293,7 @@ bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
if (old_cell.DiffCell(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1300,7 +1302,7 @@ bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
else
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
#endif
}
@@ -1313,7 +1315,7 @@ bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
EnsureGridLoadedForActiveObject(new_cell, go);
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Active GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Active GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1326,7 +1328,7 @@ bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1338,7 +1340,7 @@ bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
// fail to move: normal GameObject attempt move to unloaded grid
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
return false;
}
@@ -1352,7 +1354,7 @@ bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
if (old_cell.DiffCell(new_cell))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1361,7 +1363,7 @@ bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
else
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
#endif
}
@@ -1374,7 +1376,7 @@ bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
EnsureGridLoadedForActiveObject(new_cell, go);
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Active DynamicObject (GUID: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "Active DynamicObject (GUID: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1387,7 +1389,7 @@ bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
go->RemoveFromGrid();
@@ -1399,7 +1401,7 @@ bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
// fail to move: normal GameObject attempt move to unloaded grid
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
TC_LOG_DEBUG("maps", "DynamicObject (GUID: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
return false;
}
@@ -1418,7 +1420,7 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
c->GetMotionMaster()->Clear();
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
TC_LOG_DEBUG("maps", "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", c->GetGUID().GetCounter(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
#endif
// teleport it to respawn point (like normal respawn if player see)
@@ -1445,7 +1447,7 @@ bool Map::GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly)
return true;
#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", go->GetGUIDLow(), go->GetEntry(), go->GetCurrentCell().GridX(), go->GetCurrentCell().GridY(), go->GetCurrentCell().CellX(), go->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
TC_LOG_DEBUG("maps", "GameObject (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", go->GetGUID().GetCounter(), go->GetEntry(), go->GetCurrentCell().GridX(), go->GetCurrentCell().GridY(), go->GetCurrentCell().CellX(), go->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
#endif
// teleport it to respawn point (like normal respawn if player see)
@@ -2481,7 +2483,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const
if (xy_cell != cur_cell)
{
TC_LOG_DEBUG("maps", "Creature (GUID: %u) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
c->GetGUIDLow(),
c->GetGUID().GetCounter(),
c->GetPositionX(), c->GetPositionY(), (moved ? "final" : "original"),
cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());
@@ -2520,7 +2522,7 @@ void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpa
void Map::SendInitSelf(Player* player)
{
TC_LOG_DEBUG("maps", "Creating player data for himself %u", player->GetGUIDLow());
TC_LOG_DEBUG("maps", "Creating player data for himself %u", player->GetGUID().GetCounter());
UpdateData data(player->GetMapId());
@@ -2600,6 +2602,27 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y)
i_grids[x][y] = grid;
}
void Map::SendObjectUpdates()
{
UpdateDataMapType update_players;
while (!_updateObjects.empty())
{
Object* obj = *_updateObjects.begin();
ASSERT(obj->IsInWorld());
_updateObjects.erase(_updateObjects.begin());
obj->BuildUpdate(update_players);
}
WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); )
{
iter->second.BuildPacket(&packet);
iter->first->SendDirectMessage(&packet);
packet.clear(); // clean the string
}
}
void Map::DelayedUpdate(const uint32 t_diff)
{
for (_transportsUpdateIter = _transports.begin(); _transportsUpdateIter != _transports.end();)
@@ -2637,7 +2660,7 @@ void Map::AddObjectToRemoveList(WorldObject* obj)
obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
i_objectsToRemove.insert(obj);
//TC_LOG_DEBUG("maps", "Object (GUID: %u TypeId: %u) added to removing list.", obj->GetGUIDLow(), obj->GetTypeId());
//TC_LOG_DEBUG("maps", "Object (GUID: %u TypeId: %u) added to removing list.", obj->GetGUID().GetCounter(), obj->GetTypeId());
}
void Map::AddObjectToSwitchList(WorldObject* obj, bool on)
@@ -2694,7 +2717,7 @@ void Map::RemoveAllObjectsInRemoveList()
{
Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
if (!corpse)
TC_LOG_ERROR("maps", "Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow());
TC_LOG_ERROR("maps", "Tried to delete corpse/bones %u that is not in map.", obj->GetGUID().GetCounter());
else
RemoveFromMap(corpse, true);
break;
@@ -2795,7 +2818,7 @@ void Map::AddToActive(Creature* c)
AddToActiveHelper(c);
// also not allow unloading spawn grid to prevent creating creature clone at load
if (!c->IsPet() && c->GetDBTableGUIDLow())
if (!c->IsPet() && c->GetSpawnId())
{
float x, y, z;
c->GetRespawnPosition(x, y, z);
@@ -2806,7 +2829,7 @@ void Map::AddToActive(Creature* c)
{
GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
TC_LOG_ERROR("maps", "Active creature (GUID: %u Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
c->GetGUID().GetCounter(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}
}
}
@@ -2826,7 +2849,7 @@ void Map::RemoveFromActive(Creature* c)
RemoveFromActiveHelper(c);
// also allow unloading spawn grid
if (!c->IsPet() && c->GetDBTableGUIDLow())
if (!c->IsPet() && c->GetSpawnId())
{
float x, y, z;
c->GetRespawnPosition(x, y, z);
@@ -2837,7 +2860,7 @@ void Map::RemoveFromActive(Creature* c)
{
GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
TC_LOG_ERROR("maps", "Active creature (GUID: %u Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
c->GetGUID().GetCounter(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}
}
}
@@ -2895,7 +2918,7 @@ bool InstanceMap::CanEnter(Player* player)
{
if (player->GetMapRef().getTarget() == this)
{
TC_LOG_ERROR("maps", "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode());
TC_LOG_ERROR("maps", "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUID().GetCounter(), GetId(), GetInstanceId(), GetSpawnMode());
ASSERT(false);
return false;
}
@@ -2990,7 +3013,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
// cannot enter other instances if bound permanently
if (playerBind->save != mapSave)
{
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is permanently bound to instance %s %d, %d, %d, %d, %d, %d but he is being put into instance %s %d, %d, %d, %d, %d, %d", player->GetName().c_str(), player->GetGUIDLow(), GetMapName(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), GetMapName(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset());
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is permanently bound to instance %s %d, %d, %d, %d, %d, %d but he is being put into instance %s %d, %d, %d, %d, %d, %d", player->GetName().c_str(), player->GetGUID().GetCounter(), GetMapName(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), GetMapName(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset());
return false;
}
}
@@ -3002,7 +3025,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
InstanceGroupBind* groupBind = group->GetBoundInstance(this);
if (playerBind && playerBind->save != mapSave)
{
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is being put into instance %s %d, %d, %d, %d, %d, %d but he is in group %s and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), GetMapName(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), group->GetLeaderGUID().ToString().c_str(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset());
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is being put into instance %s %d, %d, %d, %d, %d, %d but he is in group %s and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName().c_str(), player->GetGUID().GetCounter(), GetMapName(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), group->GetLeaderGUID().ToString().c_str(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset());
if (groupBind)
TC_LOG_ERROR("maps", "InstanceMap::Add: the group is bound to the instance %s %d, %d, %d, %d, %d, %d", GetMapName(), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset());
//ASSERT(false);
@@ -3016,7 +3039,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
// cannot jump to a different instance without resetting it
if (groupBind->save != mapSave)
{
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %s which is bound to instance %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), group->GetLeaderGUID().ToString().c_str(), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty());
TC_LOG_ERROR("maps", "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %s which is bound to instance %d, %d, %d!", player->GetName().c_str(), player->GetGUID().GetCounter(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), group->GetLeaderGUID().ToString().c_str(), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty());
TC_LOG_ERROR("maps", "MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount());
if (groupBind->save)
TC_LOG_ERROR("maps", "GroupBind save players: %d, group count: %d", groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount());
@@ -3176,7 +3199,7 @@ void InstanceMap::PermBindAllPlayers(Player* source)
InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
if (!save)
{
TC_LOG_ERROR("maps", "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName().c_str(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId());
TC_LOG_ERROR("maps", "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUID().GetCounter(), source->GetName().c_str(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId());
return;
}
@@ -3209,7 +3232,10 @@ void InstanceMap::UnloadAll()
ASSERT(!HavePlayers());
if (m_resetAfterUnload == true)
{
DeleteRespawnTimes();
DeleteCorpseData();
}
Map::UnloadAll();
}
@@ -3285,7 +3311,7 @@ bool BattlegroundMap::CanEnter(Player* player)
{
if (player->GetMapRef().getTarget() == this)
{
TC_LOG_ERROR("maps", "BGMap::CanEnter - player %u is already in map!", player->GetGUIDLow());
TC_LOG_ERROR("maps", "BGMap::CanEnter - player %u is already in map!", player->GetGUID().GetCounter());
ASSERT(false);
return false;
}
@@ -3331,17 +3357,37 @@ void BattlegroundMap::RemoveAllPlayers()
player->TeleportTo(player->GetBattlegroundEntryPoint());
}
Creature* Map::GetCreature(ObjectGuid guid)
AreaTrigger* Map::GetAreaTrigger(ObjectGuid const& guid)
{
return ObjectAccessor::GetObjectInMap(guid, this, (Creature*)NULL);
return _objectsStore.Find<AreaTrigger>(guid);
}
GameObject* Map::GetGameObject(ObjectGuid guid)
Corpse* Map::GetCorpse(ObjectGuid const& guid)
{
return ObjectAccessor::GetObjectInMap(guid, this, (GameObject*)NULL);
return _objectsStore.Find<Corpse>(guid);
}
Transport* Map::GetTransport(ObjectGuid guid)
Creature* Map::GetCreature(ObjectGuid const& guid)
{
return _objectsStore.Find<Creature>(guid);
}
DynamicObject* Map::GetDynamicObject(ObjectGuid const& guid)
{
return _objectsStore.Find<DynamicObject>(guid);
}
GameObject* Map::GetGameObject(ObjectGuid const& guid)
{
return _objectsStore.Find<GameObject>(guid);
}
Pet* Map::GetPet(ObjectGuid const& guid)
{
return _objectsStore.Find<Pet>(guid);
}
Transport* Map::GetTransport(ObjectGuid const& guid)
{
if (!guid.IsMOTransport())
return NULL;
@@ -3350,11 +3396,6 @@ Transport* Map::GetTransport(ObjectGuid guid)
return go ? go->ToTransport() : NULL;
}
DynamicObject* Map::GetDynamicObject(ObjectGuid guid)
{
return ObjectAccessor::GetObjectInMap(guid, this, (DynamicObject*)NULL);
}
void Map::UpdateIteratorBack(Player* player)
{
if (m_mapRefIter == player->GetMapRef())
@@ -3480,9 +3521,9 @@ time_t Map::GetLinkedRespawnTime(ObjectGuid guid) const
ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
switch (linkedGuid.GetHigh())
{
case HIGHGUID_UNIT:
case HighGuid::Unit:
return GetCreatureRespawnTime(linkedGuid.GetCounter());
case HIGHGUID_GAMEOBJECT:
case HighGuid::GameObject:
return GetGORespawnTime(linkedGuid.GetCounter());
default:
break;
@@ -3491,6 +3532,71 @@ time_t Map::GetLinkedRespawnTime(ObjectGuid guid) const
return time_t(0);
}
void Map::LoadCorpseData()
{
std::unordered_map<uint32, std::unordered_set<uint32>> phases;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSE_PHASES);
stmt->setUInt32(0, GetId());
// 0, 1
// SELECT Guid, PhaseId FROM corpse_phases
PreparedQueryResult phaseResult = CharacterDatabase.Query(stmt);
if (phaseResult)
{
do
{
Field* fields = phaseResult->Fetch();
uint32 guid = fields[0].GetUInt32();
uint32 phaseId = fields[1].GetUInt32();
phases[guid].insert(phaseId);
} while (phaseResult->NextRow());
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES);
stmt->setUInt32(0, GetId());
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ?
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
return;
uint32 count = 0;
do
{
Field* fields = result->Fetch();
CorpseType type = CorpseType(fields[12].GetUInt8());
ObjectGuid::LowType guid = fields[14].GetUInt32();
if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
{
TC_LOG_ERROR("misc", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type);
continue;
}
Corpse* corpse = new Corpse(type);
if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
{
delete corpse;
continue;
}
for (auto phaseId : phases[guid])
corpse->SetInPhase(phaseId, false, true);
sObjectAccessor->AddCorpse(corpse);
++count;
} while (result->NextRow());
}
void Map::DeleteCorpseData()
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSES_FROM_MAP);
stmt->setUInt32(0, GetId());
CharacterDatabase.Execute(stmt);
}
void Map::SendZoneDynamicInfo(Player* player)
{
uint32 zoneId = GetZoneId(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
+54 -4
View File
@@ -34,6 +34,7 @@
#include <bitset>
#include <list>
#include <memory>
class Unit;
class WorldPacket;
@@ -443,10 +444,21 @@ class Map : public GridRefManager<NGridType>
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0);
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = NULL);
Creature* GetCreature(ObjectGuid guid);
GameObject* GetGameObject(ObjectGuid guid);
Transport* GetTransport(ObjectGuid guid);
DynamicObject* GetDynamicObject(ObjectGuid guid);
AreaTrigger* GetAreaTrigger(ObjectGuid const& guid);
Corpse* GetCorpse(ObjectGuid const& guid);
Creature* GetCreature(ObjectGuid const& guid);
DynamicObject* GetDynamicObject(ObjectGuid const& guid);
GameObject* GetGameObject(ObjectGuid const& guid);
Pet* GetPet(ObjectGuid const& guid);
Transport* GetTransport(ObjectGuid const& guid);
MapStoredObjectTypesContainer& GetObjectsStore() { return _objectsStore; }
typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> CreatureBySpawnIdContainer;
CreatureBySpawnIdContainer& GetCreatureBySpawnIdStore() { return _creatureBySpawnIdStore; }
typedef std::unordered_multimap<ObjectGuid::LowType, GameObject*> GameObjectBySpawnIdContainer;
GameObjectBySpawnIdContainer& GetGameObjectBySpawnIdStore() { return _gameObjectBySpawnIdStore; }
MapInstanced* ToMapInstanced() { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); return NULL; }
MapInstanced const* ToMapInstanced() const { if (Instanceable()) return reinterpret_cast<MapInstanced const*>(this); return NULL; }
@@ -495,6 +507,8 @@ class Map : public GridRefManager<NGridType>
void RemoveGORespawnTime(uint32 dbGuid);
void LoadRespawnTimes();
void DeleteRespawnTimes();
void LoadCorpseData();
void DeleteCorpseData();
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId);
@@ -509,6 +523,23 @@ class Map : public GridRefManager<NGridType>
void UpdateAreaDependentAuras();
template<HighGuid high>
inline ObjectGuid::LowType GenerateLowGuid()
{
static_assert(ObjectGuidTraits<high>::MapSpecific, "Only map specific guid can be generated in Map context");
return GetGuidSequenceGenerator<high>().Generate();
}
void AddUpdateObject(Object* obj)
{
_updateObjects.insert(obj);
}
void RemoveUpdateObject(Object* obj)
{
_updateObjects.erase(obj);
}
private:
void LoadMapAndVMap(int gx, int gy);
void LoadVMap(int gx, int gy);
@@ -563,6 +594,8 @@ class Map : public GridRefManager<NGridType>
void UpdateActiveCells(const float &x, const float &y, const uint32 t_diff);
void SendObjectUpdates();
protected:
void SetUnloadReferenceLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
@@ -655,6 +688,23 @@ class Map : public GridRefManager<NGridType>
ZoneDynamicInfoMap _zoneDynamicInfo;
uint32 _defaultLight;
template<HighGuid high>
inline ObjectGuidGeneratorBase& GetGuidSequenceGenerator()
{
auto itr = _guidGenerators.find(high);
if (itr == _guidGenerators.end())
itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
return *itr->second;
}
std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators;
MapStoredObjectTypesContainer _objectsStore;
CreatureBySpawnIdContainer _creatureBySpawnIdStore;
GameObjectBySpawnIdContainer _gameObjectBySpawnIdStore;
std::unordered_set<Object*> _updateObjects;
};
enum InstanceResetMethod
+1 -2
View File
@@ -79,6 +79,7 @@ Map* MapManager::CreateBaseMap(uint32 id)
{
map = new Map(id, i_gridCleanUpDelay, 0, REGULAR_DIFFICULTY);
map->LoadRespawnTimes();
map->LoadCorpseData();
}
i_maps[id] = map;
@@ -250,8 +251,6 @@ void MapManager::Update(uint32 diff)
for (iter = i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->DelayedUpdate(uint32(i_timer.GetCurrent()));
sObjectAccessor->Update(uint32(i_timer.GetCurrent()));
i_timer.SetCurrent(0);
}
+47
View File
@@ -21,6 +21,7 @@
#include "Object.h"
#include "Map.h"
#include "MapInstanced.h"
#include "GridStates.h"
#include "MapUpdater.h"
@@ -125,6 +126,12 @@ class MapManager
MapUpdater * GetMapUpdater() { return &m_updater; }
template<typename Worker>
void DoForAllMaps(Worker&& worker);
template<typename Worker>
void DoForAllMapsWithMapId(uint32 mapId, Worker&& worker);
private:
typedef std::unordered_map<uint32, Map*> MapMapType;
typedef std::vector<bool> InstanceIds;
@@ -150,5 +157,45 @@ class MapManager
uint32 _nextInstanceId;
MapUpdater m_updater;
};
template<typename Worker>
inline void MapManager::DoForAllMaps(Worker&& worker)
{
std::lock_guard<std::mutex> lock(_mapsLock);
for (auto& mapPair : i_maps)
{
Map* map = mapPair.second;
if (MapInstanced* mapInstanced = map->ToMapInstanced())
{
MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps();
for (auto& instancePair : instances)
worker(instancePair.second);
}
else
worker(map);
}
}
template<typename Worker>
inline void MapManager::DoForAllMapsWithMapId(uint32 mapId, Worker&& worker)
{
std::lock_guard<std::mutex> lock(_mapsLock);
auto itr = i_maps.find(mapId);
if (itr != i_maps.end())
{
Map* map = itr->second;
if (MapInstanced* mapInstanced = map->ToMapInstanced())
{
MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps();
for (auto& instancePair : instances)
worker(instancePair.second);
}
else
worker(map);
}
}
#define sMapMgr MapManager::instance()
#endif
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff. Show more