diff options
Diffstat (limited to 'src/server/game')
25 files changed, 683 insertions, 652 deletions
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index dc7d7caaf19..0352a87351a 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -3189,7 +3189,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() if (!result) { - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 completed achievements. DB table `character_achievement` is empty."); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 realm first completed achievements. DB table `character_achievement` is empty."); return; } @@ -3215,7 +3215,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime)); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu realm first completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime)); } void AchievementGlobalMgr::LoadRewards() diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 968e1eea7f1..b0ad965f310 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -465,10 +465,9 @@ WorldPacket Battlefield::BuildWarningAnnPacket(std::string const& msg) void Battlefield::SendWarningToAllInZone(uint32 entry) { - if (Unit* unit = sObjectAccessor->FindUnit(StalkerGuid)) - if (Creature* stalker = unit->ToCreature()) - // FIXME: replaced CHAT_TYPE_END with CHAT_MSG_BG_SYSTEM_NEUTRAL to fix compile, it's a guessed change :/ - sCreatureTextMgr->SendChat(stalker, (uint8) entry, 0, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE); + if (Creature* stalker = GetCreature(StalkerGuid)) + // FIXME: replaced CHAT_TYPE_END with CHAT_MSG_BG_SYSTEM_NEUTRAL to fix compile, it's a guessed change :/ + sCreatureTextMgr->SendChat(stalker, (uint8) entry, 0, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_ADDON, TEXT_RANGE_ZONE); } /*void Battlefield::SendWarningToAllInWar(int32 entry,...) @@ -488,9 +487,8 @@ void Battlefield::SendWarningToAllInZone(uint32 entry) void Battlefield::SendWarningToPlayer(Player* player, uint32 entry) { if (player) - if (Unit* unit = sObjectAccessor->FindUnit(StalkerGuid)) - if (Creature* stalker = unit->ToCreature()) - sCreatureTextMgr->SendChat(stalker, (uint8)entry, player->GetGUID()); + if (Creature* stalker = GetCreature(StalkerGuid)) + sCreatureTextMgr->SendChat(stalker, (uint8)entry, player->GetGUID()); } void Battlefield::SendUpdateWorldState(uint32 field, uint32 value) @@ -743,7 +741,7 @@ void BfGraveyard::Resurrect() // Check if the player is in world and on the good graveyard if (player->IsInWorld()) - if (Unit* spirit = sObjectAccessor->FindUnit(m_SpiritGuide[m_ControlTeam])) + if (Creature* spirit = m_Bf->GetCreature(m_SpiritGuide[m_ControlTeam])) spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true); // Resurect player @@ -793,6 +791,18 @@ void BfGraveyard::RelocateDeadPlayers() } } +bool BfGraveyard::HasNpc(uint64 guid) +{ + if (!m_SpiritGuide[0] || !m_SpiritGuide[1]) + return false; + + if (!m_Bf->GetCreature(m_SpiritGuide[0]) || + !m_Bf->GetCreature(m_SpiritGuide[1])) + return false; + + return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid); +} + // ******************************************************* // *************** End Spirit Guide system *************** // ******************************************************* @@ -866,11 +876,25 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z return go; } +Creature* Battlefield::GetCreature(uint64 GUID) +{ + if (!m_Map) + return NULL; + return m_Map->GetCreature(GUID); +} + +GameObject* Battlefield::GetGameObject(uint64 GUID) +{ + if (!m_Map) + return NULL; + return m_Map->GetGameObject(GUID); +} + // ******************************************************* // ******************* CapturePoint ********************** // ******************************************************* -BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePoint(NULL) +BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_capturePointGUID(0) { m_team = TEAM_NEUTRAL; m_value = 0; @@ -885,19 +909,24 @@ BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_ bool BfCapturePoint::HandlePlayerEnter(Player* player) { - if (m_capturePoint) + if (m_capturePointGUID) { - player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1); - player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f))); - player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); + if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) + { + player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1); + player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f))); + player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); + } } + return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second; } GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player) { - if (m_capturePoint) - player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0); + if (m_capturePointGUID) + if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) + player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 0); GuidSet::iterator current = m_activePlayers[player->GetTeamId()].find(player->GetGUID()); @@ -910,15 +939,18 @@ GuidSet::iterator BfCapturePoint::HandlePlayerLeave(Player* player) void BfCapturePoint::SendChangePhase() { - if (!m_capturePoint) + if (!m_capturePointGUID) return; - - // send this too, sometimes the slider disappears, dunno why :( - SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1); - // send these updates to only the ones in this objective - SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); - // send this too, sometimes it resets :S - SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); + + if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) + { + // send this too, sometimes the slider disappears, dunno why :( + SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1); + // send these updates to only the ones in this objective + SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); + // send this too, sometimes it resets :S + SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); + } } bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) @@ -927,7 +959,7 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Creating capture point %u", capturePoint->GetEntry()); - m_capturePoint = capturePoint; + m_capturePointGUID = MAKE_NEW_GUID(capturePoint->GetGUIDLow(), capturePoint->GetEntry(), HIGHGUID_GAMEOBJECT); // check info existence GameObjectTemplate const* goinfo = capturePoint->GetGOInfo(); @@ -957,13 +989,22 @@ bool BfCapturePoint::SetCapturePointData(GameObject* capturePoint) return true; } +GameObject* BfCapturePoint::GetCapturePointGo() +{ + return m_Bf->GetGameObject(m_capturePointGUID); +} + bool BfCapturePoint::DelCapturePoint() { - if (m_capturePoint) + if (m_capturePointGUID) { - m_capturePoint->SetRespawnTime(0); // not save respawn time - m_capturePoint->Delete(); - m_capturePoint = NULL; + if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) + { + capturePoint->SetRespawnTime(0); // not save respawn time + capturePoint->Delete(); + capturePoint = NULL; + } + m_capturePointGUID = 0; } return true; @@ -971,37 +1012,40 @@ bool BfCapturePoint::DelCapturePoint() bool BfCapturePoint::Update(uint32 diff) { - if (!m_capturePoint) + if (!m_capturePointGUID) return false; - float radius = m_capturePoint->GetGOInfo()->capturePoint.radius; - - for (uint8 team = 0; team < 2; ++team) + if (GameObject* capturePoint = m_Bf->GetGameObject(m_capturePointGUID)) { - for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) + float radius = capturePoint->GetGOInfo()->capturePoint.radius; + + for (uint8 team = 0; team < 2; ++team) { - if (Player* player = sObjectAccessor->FindPlayer(*itr)) + for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { - if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) - itr = HandlePlayerLeave(player); + if (Player* player = sObjectAccessor->FindPlayer(*itr)) + { + if (!capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) + itr = HandlePlayerLeave(player); + else + ++itr; + } else ++itr; } - else - ++itr; } - } - - std::list<Player*> players; - Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); - Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker); - m_capturePoint->VisitNearbyWorldObject(radius, searcher); - - for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) - if ((*itr)->IsOutdoorPvPActive()) - if (m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second) - HandlePlayerEnter(*itr); + std::list<Player*> players; + Trinity::AnyPlayerInObjectRangeCheck checker(capturePoint, radius); + Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker); + capturePoint->VisitNearbyWorldObject(radius, searcher); + + for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) + if ((*itr)->IsOutdoorPvPActive()) + if (m_activePlayers[(*itr)->GetTeamId()].insert((*itr)->GetGUID()).second) + HandlePlayerEnter(*itr); + } + // get the difference of numbers float fact_diff = ((float) m_activePlayers[0].size() - (float) m_activePlayers[1].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL; if (G3D::fuzzyEq(fact_diff, 0.0f)) diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index bcadc877eea..f17a7666d67 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -104,8 +104,9 @@ class BfCapturePoint virtual void SendChangePhase(); bool SetCapturePointData(GameObject* capturePoint); - GameObject* GetCapturePointGo() { return m_capturePoint; } - + GameObject* GetCapturePointGo(); + uint32 GetCapturePointEntry(){ return m_capturePointEntry; } + TeamId GetTeamId() { return m_team; } protected: bool DelCapturePoint(); @@ -138,7 +139,7 @@ class BfCapturePoint uint32 m_capturePointEntry; // Gameobject related to that capture point - GameObject* m_capturePoint; + uint64 m_capturePointGUID; }; class BfGraveyard @@ -172,17 +173,7 @@ class BfGraveyard void RelocateDeadPlayers(); // Check if this graveyard has a spirit guide - bool HasNpc(uint64 guid) - { - if (!m_SpiritGuide[0] || !m_SpiritGuide[1]) - return false; - - if (!sObjectAccessor->FindUnit(m_SpiritGuide[0]) || - !sObjectAccessor->FindUnit(m_SpiritGuide[1])) - return false; - - return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid); - } + bool HasNpc(uint64 guid); // Check if a player is in this graveyard's ressurect queue bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); } @@ -301,6 +292,9 @@ class Battlefield : public ZoneScript Creature* SpawnCreature(uint32 entry, Position pos, TeamId team); GameObject* SpawnGameObject(uint32 entry, float x, float y, float z, float o); + Creature* GetCreature(uint64 GUID); + GameObject* GetGameObject(uint64 GUID); + // Script-methods /// Called on start @@ -381,6 +375,7 @@ class Battlefield : public ZoneScript uint32 m_BattleId; // BattleID (for packet) uint32 m_ZoneId; // ZoneID of Wintergrasp = 4197 uint32 m_MapId; // MapId where is Battlefield + Map* m_Map; uint32 m_MaxPlayer; // Maximum number of player that participated to Battlefield uint32 m_MinPlayer; // Minimum number of player for Battlefield start uint32 m_MinLevel; // Required level to participate at Battlefield @@ -416,7 +411,7 @@ class Battlefield : public ZoneScript void BroadcastPacketToWar(WorldPacket& data) const; // CapturePoint system - void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointGo()->GetEntry()] = cp; } + void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointEntry()] = cp; } BfCapturePoint* GetCapturePoint(uint32 lowguid) const { diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 0865df03d34..63f95e159af 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -22,6 +22,7 @@ #include "BattlefieldWG.h" #include "AchievementMgr.h" +#include "MapManager.h" #include "ObjectMgr.h" #include "Opcodes.h" #include "Player.h" @@ -55,6 +56,7 @@ bool BattlefieldWG::SetupBattlefield() m_BattleId = BATTLEFIELD_BATTLEID_WG; m_ZoneId = BATTLEFIELD_WG_ZONEID; m_MapId = BATTLEFIELD_WG_MAPID; + m_Map = sMapMgr->FindMap(m_MapId, 0); m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX); m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE); @@ -142,9 +144,8 @@ bool BattlefieldWG::SetupBattlefield() // Hide NPCs from the Attacker's team in the keep for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); // Spawn Horde NPCs outside the keep for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++) @@ -158,9 +159,8 @@ bool BattlefieldWG::SetupBattlefield() // Hide units outside the keep that are defenders for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); // Spawn turrets and hide them per default for (uint8 i = 0; i < WG_MAX_TURRET; i++) @@ -177,20 +177,24 @@ bool BattlefieldWG::SetupBattlefield() // Spawn all gameobjects for (uint8 i = 0; i < WG_MAX_OBJ; i++) { - GameObject* go = SpawnGameObject(WGGameObjectBuilding[i].entry, WGGameObjectBuilding[i].x, WGGameObjectBuilding[i].y, WGGameObjectBuilding[i].z, WGGameObjectBuilding[i].o); - BfWGGameObjectBuilding* b = new BfWGGameObjectBuilding(this); - b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].nameId); - if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE) - go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); - BuildingsInZone.insert(b); + if (GameObject* go = SpawnGameObject(WGGameObjectBuilding[i].entry, WGGameObjectBuilding[i].x, WGGameObjectBuilding[i].y, WGGameObjectBuilding[i].z, WGGameObjectBuilding[i].o)) + { + BfWGGameObjectBuilding* b = new BfWGGameObjectBuilding(this); + b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].nameId); + if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE) + go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); + BuildingsInZone.insert(b); + } } // Spawning portal defender for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++) { - GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o); - DefenderPortalList.insert(go); - go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]); + if (GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o)) + { + DefenderPortalList.insert(go->GetGUID()); + go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]); + } } UpdateCounterVehicle(true); @@ -216,13 +220,13 @@ bool BattlefieldWG::Update(uint32 diff) void BattlefieldWG::OnBattleStart() { // Spawn titan relic - m_titansRelic = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0); - if (m_titansRelic) + if (GameObject* relic = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0)) { // Update faction of relic, only attacker can click on - m_titansRelic->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetAttackerTeam()]); + relic->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetAttackerTeam()]); // Set in use (not allow to click on before last door is broken) - m_titansRelic->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + relic->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + m_titansRelicGUID = relic->GetGUID(); } else sLog->outError(LOG_FILTER_BATTLEFIELD, "WG: Failed to spawn titan relic."); @@ -231,13 +235,10 @@ void BattlefieldWG::OnBattleStart() // Update tower visibility and update faction for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) { - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) + if (Creature* creature = GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - ShowNpc(creature, true); - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); - } + ShowNpc(creature, true); + creature->setFaction(WintergraspFaction[GetDefenderTeam()]); } } @@ -307,21 +308,19 @@ void BattlefieldWG::UpdateCounterVehicle(bool init) void BattlefieldWG::OnBattleEnd(bool endByTimer) { // Remove relic - if (m_titansRelic) - m_titansRelic->RemoveFromWorld(); - m_titansRelic = NULL; + if (m_titansRelicGUID) + if (GameObject* relic = GetGameObject(m_titansRelicGUID)) + relic->RemoveFromWorld(); + m_titansRelicGUID = 0; // Remove turret for (GuidSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr) { - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) + if (Creature* creature = GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) - { - if (!endByTimer) - creature->setFaction(WintergraspFaction[GetDefenderTeam()]); - HideNpc(creature); - } + if (!endByTimer) + creature->setFaction(WintergraspFaction[GetDefenderTeam()]); + HideNpc(creature); } } @@ -329,25 +328,21 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) { // Change all npc in keep for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); for (GuidSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - ShowNpc(creature, true); + if (Creature* creature = GetCreature(*itr)) + ShowNpc(creature, true); // Change all npc out of keep for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - HideNpc(creature); + if (Creature* creature = GetCreature(*itr)) + HideNpc(creature); for (GuidSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - ShowNpc(creature, true); + if (Creature* creature = GetCreature(*itr)) + ShowNpc(creature, true); } // Update all graveyard, control is to defender when no wartime @@ -355,15 +350,18 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) if (BfGraveyard* graveyard = GetGraveyardById(i)) graveyard->GiveControlTo(GetDefenderTeam()); - for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY); + for (GuidSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr) + if (GameObject* object = GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_IMMEDIATELY); - for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_ONE_DAY); + for (GuidSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr) + if (GameObject* object = GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_ONE_DAY); // Update portal defender faction - for (GameObjectSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr) - (*itr)->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]); + for (GuidSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr) + if (GameObject* portal = GetGameObject(*itr)) + portal->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]); // Saving data for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) @@ -398,10 +396,9 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer) m_PlayersInWar[team].clear(); for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - if (creature->IsVehicle()) - creature->GetVehicleKit()->Dismiss(); + if (Creature* creature = GetCreature(*itr)) + if (creature->IsVehicle()) + creature->GetVehicleKit()->Dismiss(); m_vehicles[team].clear(); } @@ -650,18 +647,15 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim) for (GuidSet::const_iterator itr = KeepCreature[GetOtherTeam(killerTeam)].begin(); itr != KeepCreature[GetOtherTeam(killerTeam)].end(); ++itr) { - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) + if (Creature* creature = GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) + if (victim->GetEntry() == creature->GetEntry() && !again) { - if (victim->GetEntry() == creature->GetEntry() && !again) - { - again = true; - for (GuidSet::const_iterator iter = m_PlayersInWar[killerTeam].begin(); iter != m_PlayersInWar[killerTeam].end(); ++iter) - if (Player* player = sObjectAccessor->FindPlayer(*iter)) - if (player->GetDistance2d(killer) < 40.0f) - PromotePlayer(player); - } + again = true; + for (GuidSet::const_iterator iter = m_PlayersInWar[killerTeam].begin(); iter != m_PlayersInWar[killerTeam].end(); ++iter) + if (Player* player = sObjectAccessor->FindPlayer(*iter)) + if (player->GetDistance2d(killer) < 40.0f) + PromotePlayer(player); } } } @@ -938,22 +932,25 @@ void BattlefieldWG::ProcessEvent(WorldObject *obj, uint32 eventId) { if (CanInteractWithRelic()) EndBattle(false); - else - GetRelic()->SetRespawnTime(RESPAWN_IMMEDIATELY); + else if (GameObject* relic = GetRelic()) + relic->SetRespawnTime(RESPAWN_IMMEDIATELY); } // if destroy or damage event, search the wall/tower and update worldstate/send warning message for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr) { - if (go->GetEntry() == (*itr)->m_Build->GetEntry()) + if (GameObject* build = GetGameObject((*itr)->m_BuildGUID)) { - if ((*itr)->m_Build->GetGOInfo()->building.damagedEvent == eventId) - (*itr)->Damaged(); + if (go->GetEntry() == build->GetEntry()) + { + if (build->GetGOInfo()->building.damagedEvent == eventId) + (*itr)->Damaged(); - if ((*itr)->m_Build->GetGOInfo()->building.destroyedEvent == eventId) - (*itr)->Destroyed(); + if (build->GetGOInfo()->building.destroyedEvent == eventId) + (*itr)->Destroyed(); - break; + break; + } } } } @@ -1009,9 +1006,8 @@ void BattlefieldWG::UpdateTenacity() player->RemoveAurasDueToSpell(SPELL_TENACITY); for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE); + if (Creature* creature = GetCreature(*itr)) + creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE); } // Apply new buff @@ -1037,9 +1033,8 @@ void BattlefieldWG::UpdateTenacity() player->SetAuraStack(SPELL_TENACITY, player, newStack); for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack); + if (Creature* creature = GetCreature(*itr)) + creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack); if (buff_honor != 0) { @@ -1047,9 +1042,8 @@ void BattlefieldWG::UpdateTenacity() if (Player* player = sObjectAccessor->FindPlayer(*itr)) player->CastSpell(player, buff_honor, true); for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - creature->CastSpell(creature, buff_honor, true); + if (Creature* creature = GetCreature(*itr)) + creature->CastSpell(creature, buff_honor, true); } } } diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index bd616167e8b..73ec858e965 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -383,10 +383,10 @@ class BattlefieldWG : public Battlefield bool SetupBattlefield(); /// Return pointer to relic object - GameObject* GetRelic() { return m_titansRelic; } + GameObject* GetRelic() { return GetGameObject(m_titansRelicGUID); } /// Define relic object - void SetRelic(GameObject* relic) { m_titansRelic = relic; } + void SetRelic(uint64 relicGUID) { m_titansRelicGUID = relicGUID; } /// Check if players can interact with the relic (Only if the last door has been broken) bool CanInteractWithRelic() { return m_isRelicInteractible; } @@ -420,8 +420,8 @@ class BattlefieldWG : public Battlefield Workshop WorkshopsList; - GameObjectSet DefenderPortalList; - GameObjectSet m_KeepGameObject[2]; + GuidSet DefenderPortalList; + GuidSet m_KeepGameObject[2]; GameObjectBuilding BuildingsInZone; GuidSet m_vehicles[2]; @@ -432,7 +432,7 @@ class BattlefieldWG : public Battlefield uint32 m_tenacityStack; uint32 m_saveTimer; - GameObject* m_titansRelic; + uint64 m_titansRelicGUID; }; uint32 const VehNumWorldState[] = { 3680, 3490 }; @@ -1065,7 +1065,7 @@ struct BfWGGameObjectBuilding { m_WG = WG; m_Team = 0; - m_Build = NULL; + m_BuildGUID = 0; m_Type = 0; m_WorldState = 0; m_State = 0; @@ -1079,7 +1079,7 @@ struct BfWGGameObjectBuilding BattlefieldWG* m_WG; // Linked gameobject - GameObject* m_Build; + uint64 m_BuildGUID; // eWGGameObjectBuildingType uint32 m_Type; @@ -1094,7 +1094,7 @@ struct BfWGGameObjectBuilding uint32 m_NameId; // GameObject associations - GameObjectSet m_GameObjectList[2]; + GuidSet m_GameObjectList[2]; // Creature associations GuidSet m_CreatureBottomList[2]; @@ -1120,20 +1120,23 @@ struct BfWGGameObjectBuilding break; } - // Rebuild gameobject - if (m_Build->IsDestructibleBuilding()) + if (GameObject* build = m_WG->GetGameObject(m_BuildGUID)) { - m_Build->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true); - if (m_Build->GetEntry() == GO_WINTERGRASP_VAULT_GATE) - if (GameObject* go = m_Build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 10.0f)) - go->EnableCollision(true); - - // Update worldstate - m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT - (m_Team * 3); - m_WG->SendUpdateWorldState(m_WorldState, m_State); + // Rebuild gameobject + if (build->IsDestructibleBuilding()) + { + build->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true); + if (build->GetEntry() == GO_WINTERGRASP_VAULT_GATE) + if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 50.0f)) + go->EnableCollision(true); + + // Update worldstate + m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT - (m_Team * 3); + m_WG->SendUpdateWorldState(m_WorldState, m_State); + } + UpdateCreatureAndGo(); + build->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_Team]); } - UpdateCreatureAndGo(); - m_Build->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_Team]); } // Called when associated gameobject is damaged @@ -1148,14 +1151,12 @@ struct BfWGGameObjectBuilding m_WG->SendWarningToAllInZone(m_NameId); for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); if (m_Type == BATTLEFIELD_WG_OBJECTTYPE_KEEP_TOWER) m_WG->UpdateDamagedTowerCount(m_WG->GetDefenderTeam()); @@ -1182,8 +1183,9 @@ struct BfWGGameObjectBuilding m_WG->UpdatedDestroyedTowerCount(TeamId(m_Team)); break; case BATTLEFIELD_WG_OBJECTTYPE_DOOR_LAST: - if (GameObject* go = m_Build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 10.0f)) - go->EnableCollision(false); + if (GameObject* build = m_WG->GetGameObject(m_BuildGUID)) + if (GameObject* go = build->FindNearestGameObject(GO_WINTERGRASP_KEEP_COLLISION_WALL, 10.0f)) + go->EnableCollision(false); m_WG->SetRelicInteractible(true); if (m_WG->GetRelic()) m_WG->GetRelic()->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); @@ -1197,8 +1199,11 @@ struct BfWGGameObjectBuilding void Init(GameObject* go, uint32 type, uint32 worldstate, uint32 nameid) { + if (!go) + return; + // GameObject associated to object - m_Build = go; + m_BuildGUID = go->GetGUID(); // Type of building (WALL/TOWER/DOOR) m_Type = type; @@ -1226,23 +1231,20 @@ struct BfWGGameObjectBuilding } m_State = sWorld->getWorldState(m_WorldState); - if (m_Build) + switch (m_State) { - switch (m_State) - { - case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT: - case BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT: - m_Build->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true); - break; - case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY: - case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DESTROY: - m_Build->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); - break; - case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE: - case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DAMAGE: - m_Build->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); - break; - } + case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT: + case BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT: + go->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, NULL, true); + break; + case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY: + case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DESTROY: + go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); + break; + case BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE: + case BATTLEFIELD_WG_OBJECTSTATE_HORDE_DAMAGE: + go->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); + break; } int32 towerid = -1; @@ -1278,9 +1280,9 @@ struct BfWGGameObjectBuilding { WintergraspObjectPositionData gobData = AttackTowers[towerid - 4].GameObject[i]; if (GameObject* go = m_WG->SpawnGameObject(gobData.entryHorde, gobData.x, gobData.y, gobData.z, gobData.o)) - m_GameObjectList[TEAM_HORDE].insert(go); + m_GameObjectList[TEAM_HORDE].insert(go->GetGUID()); if (GameObject* go = m_WG->SpawnGameObject(gobData.entryAlliance, gobData.x, gobData.y, gobData.z, gobData.o)) - m_GameObjectList[TEAM_ALLIANCE].insert(go); + m_GameObjectList[TEAM_ALLIANCE].insert(go->GetGUID()); } // Spawn associate npc bottom @@ -1364,64 +1366,59 @@ struct BfWGGameObjectBuilding void UpdateCreatureAndGo() { for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureTopList[m_WG->GetDefenderTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); for (GuidSet::const_iterator itr = m_CreatureTopList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureTopList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, true); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, true); for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetDefenderTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetDefenderTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); for (GuidSet::const_iterator itr = m_CreatureBottomList[m_WG->GetAttackerTeam()].begin(); itr != m_CreatureBottomList[m_WG->GetAttackerTeam()].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, true); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, true); - for (GameObjectSet::const_iterator itr = m_GameObjectList[m_WG->GetDefenderTeam()].begin(); itr != m_GameObjectList[m_WG->GetDefenderTeam()].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_ONE_DAY); + for (GuidSet::const_iterator itr = m_GameObjectList[m_WG->GetDefenderTeam()].begin(); itr != m_GameObjectList[m_WG->GetDefenderTeam()].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_ONE_DAY); - for (GameObjectSet::const_iterator itr = m_GameObjectList[m_WG->GetAttackerTeam()].begin(); itr != m_GameObjectList[m_WG->GetAttackerTeam()].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY); + for (GuidSet::const_iterator itr = m_GameObjectList[m_WG->GetAttackerTeam()].begin(); itr != m_GameObjectList[m_WG->GetAttackerTeam()].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_IMMEDIATELY); } void UpdateTurretAttack(bool disable) { for (GuidSet::const_iterator itr = m_TowerCannonBottomList.begin(); itr != m_TowerCannonBottomList.end(); ++itr) { - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) + if (Creature* creature = m_WG->GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) + if (GameObject* build = m_WG->GetGameObject(m_BuildGUID)) { - if (m_Build) - { - if (disable) - m_WG->HideNpc(creature); - else - m_WG->ShowNpc(creature, true); + if (disable) + m_WG->HideNpc(creature); + else + m_WG->ShowNpc(creature, true); - switch (m_Build->GetEntry()) + switch (build->GetEntry()) + { + case GO_WINTERGRASP_FORTRESS_TOWER_1: + case GO_WINTERGRASP_FORTRESS_TOWER_2: + case GO_WINTERGRASP_FORTRESS_TOWER_3: + case GO_WINTERGRASP_FORTRESS_TOWER_4: + { + creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]); + break; + } + case GO_WINTERGRASP_SHADOWSIGHT_TOWER: + case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: + case GO_WINTERGRASP_FLAMEWATCH_TOWER: { - case GO_WINTERGRASP_FORTRESS_TOWER_1: - case GO_WINTERGRASP_FORTRESS_TOWER_2: - case GO_WINTERGRASP_FORTRESS_TOWER_3: - case GO_WINTERGRASP_FORTRESS_TOWER_4: - { - creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]); - break; - } - case GO_WINTERGRASP_SHADOWSIGHT_TOWER: - case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: - case GO_WINTERGRASP_FLAMEWATCH_TOWER: - { - creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]); - break; - } + creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]); + break; } } } @@ -1430,34 +1427,31 @@ struct BfWGGameObjectBuilding for (GuidSet::const_iterator itr = m_TurretTopList.begin(); itr != m_TurretTopList.end(); ++itr) { - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) + if (Creature* creature = m_WG->GetCreature(*itr)) { - if (Creature* creature = unit->ToCreature()) + if (GameObject* build = m_WG->GetGameObject(m_BuildGUID)) { - if (m_Build) - { - if (disable) - m_WG->HideNpc(creature); - else - m_WG->ShowNpc(creature, true); + if (disable) + m_WG->HideNpc(creature); + else + m_WG->ShowNpc(creature, true); - switch (m_Build->GetEntry()) + switch (build->GetEntry()) + { + case GO_WINTERGRASP_FORTRESS_TOWER_1: + case GO_WINTERGRASP_FORTRESS_TOWER_2: + case GO_WINTERGRASP_FORTRESS_TOWER_3: + case GO_WINTERGRASP_FORTRESS_TOWER_4: { - case GO_WINTERGRASP_FORTRESS_TOWER_1: - case GO_WINTERGRASP_FORTRESS_TOWER_2: - case GO_WINTERGRASP_FORTRESS_TOWER_3: - case GO_WINTERGRASP_FORTRESS_TOWER_4: - { - creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]); - break; - } - case GO_WINTERGRASP_SHADOWSIGHT_TOWER: - case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: - case GO_WINTERGRASP_FLAMEWATCH_TOWER: - { - creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]); - break; - } + creature->setFaction(WintergraspFaction[m_WG->GetDefenderTeam()]); + break; + } + case GO_WINTERGRASP_SHADOWSIGHT_TOWER: + case GO_WINTERGRASP_WINTER_S_EDGE_TOWER: + case GO_WINTERGRASP_FLAMEWATCH_TOWER: + { + creature->setFaction(WintergraspFaction[m_WG->GetAttackerTeam()]); + break; } } } @@ -1544,19 +1538,19 @@ struct WGWorkshop struct WintergraspWorkshopData { BattlefieldWG* m_WG; // Pointer to wintergrasp - GameObject* m_Build; + uint64 m_BuildGUID; uint32 m_Type; uint32 m_State; // For worldstate uint32 m_WorldState; uint32 m_TeamControl; // Team witch control the workshop GuidSet m_CreatureOnPoint[2]; // Contain all Creature associate to this point - GameObjectSet m_GameObjectOnPoint[2]; // Contain all Gameobject associate to this point + GuidSet m_GameObjectOnPoint[2]; // Contain all Gameobject associate to this point uint32 m_NameId; // Id of trinity_string witch contain name of this node, using for alert message WintergraspWorkshopData(BattlefieldWG* WG) { m_WG = WG; - m_Build = NULL; + m_BuildGUID = 0; m_Type = 0; m_State = 0; m_WorldState = 0; @@ -1578,9 +1572,9 @@ struct WintergraspWorkshopData void AddGameObject(WintergraspObjectPositionData obj) { if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryHorde, obj.x, obj.y, obj.z, obj.o)) - m_GameObjectOnPoint[TEAM_HORDE].insert(gameobject); + m_GameObjectOnPoint[TEAM_HORDE].insert(gameobject->GetGUID()); if (GameObject* gameobject = m_WG->SpawnGameObject(obj.entryAlliance, obj.x, obj.y, obj.z, obj.o)) - m_GameObjectOnPoint[TEAM_ALLIANCE].insert(gameobject); + m_GameObjectOnPoint[TEAM_ALLIANCE].insert(gameobject->GetGUID()); } // Init method, setup variable @@ -1607,23 +1601,23 @@ struct WintergraspWorkshopData { // Show Alliance creature for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_ALLIANCE].begin(); itr != m_CreatureOnPoint[TEAM_ALLIANCE].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, creature->GetEntry() != 30499); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, creature->GetEntry() != 30499); // Hide Horde creature for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_HORDE].begin(); itr != m_CreatureOnPoint[TEAM_HORDE].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); // Show Alliance gameobject - for (GameObjectSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY); + for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_IMMEDIATELY); // Hide Horde gameobject - for (GameObjectSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_ONE_DAY); + for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_ONE_DAY); // Updating worldstate @@ -1646,23 +1640,23 @@ struct WintergraspWorkshopData { // Show Horde creature for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_HORDE].begin(); itr != m_CreatureOnPoint[TEAM_HORDE].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->ShowNpc(creature, creature->GetEntry() != 30400); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->ShowNpc(creature, creature->GetEntry() != 30400); // Hide Alliance creature for (GuidSet::const_iterator itr = m_CreatureOnPoint[TEAM_ALLIANCE].begin(); itr != m_CreatureOnPoint[TEAM_ALLIANCE].end(); ++itr) - if (Unit* unit = sObjectAccessor->FindUnit(*itr)) - if (Creature* creature = unit->ToCreature()) - m_WG->HideNpc(creature); + if (Creature* creature = m_WG->GetCreature(*itr)) + m_WG->HideNpc(creature); // Hide Alliance gameobject - for (GameObjectSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_ONE_DAY); + for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_ALLIANCE].begin(); itr != m_GameObjectOnPoint[TEAM_ALLIANCE].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_ONE_DAY); // Show Horde gameobject - for (GameObjectSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr) - (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY); + for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TEAM_HORDE].begin(); itr != m_GameObjectOnPoint[TEAM_HORDE].end(); ++itr) + if (GameObject* object = m_WG->GetGameObject(*itr)) + object->SetRespawnTime(RESPAWN_IMMEDIATELY); // Update worlstate m_State = BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 881d0e3296b..16220d17170 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1322,6 +1322,9 @@ void Battleground::EventPlayerLoggedIn(Player* player) void Battleground::EventPlayerLoggedOut(Player* player) { uint64 guid = player->GetGUID(); + if (!IsPlayerInBattleground(guid)) // Check if this player really is in battleground (might be a GM who teleported inside) + return; + // player is correct pointer, it is checked in WorldSession::LogoutPlayer() m_OfflineQueue.push_back(player->GetGUID()); m_Players[guid].OfflineRemoveTime = sWorld->GetGameTime() + MAX_OFFLINE_TIME; @@ -1332,8 +1335,8 @@ void Battleground::EventPlayerLoggedOut(Player* player) // 1 player is logging out, if it is the last, then end arena! if (isArena()) - if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam()))) - EndBattleground(GetOtherTeam(player->GetTeam())); + if (GetAlivePlayersCountByTeam(player->GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetBGTeam()))) + EndBattleground(GetOtherTeam(player->GetBGTeam())); } } diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index f5edafec655..79c4f1accab 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -1013,8 +1013,8 @@ void BattlegroundMgr::CreateInitialBattlegrounds() data.MaxPlayersPerTeam = fields[2].GetUInt16(); data.LevelMin = fields[3].GetUInt8(); data.LevelMax = fields[4].GetUInt8(); - uint8 spawn = fields[9].GetUInt8(); - data.StartMaxDist = float(spawn * spawn); + float dist = fields[9].GetFloat(); + data.StartMaxDist = dist * dist; data.scriptId = sObjectMgr->GetScriptId(fields[11].GetCString()); data.BattlegroundName = bl->name; diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 7bada252da6..8ce7d7d2139 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -297,7 +297,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b SendToOne(&data, good); return; } - + Player* bad = sObjectAccessor->FindPlayerByName(badname); uint64 victim = bad ? bad->GetGUID() : 0; if (!victim || !IsOn(victim)) @@ -403,7 +403,7 @@ void Channel::Password(Player const* player, std::string const& pass) SendToOne(&data, guid); return; } - + if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity())) { WorldPacket data; @@ -479,7 +479,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname) uint64 guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); - if (!IsOn(guid) || (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); @@ -487,9 +487,17 @@ void Channel::SetOwner(Player const* player, std::string const& newname) return; } + if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID) + { + WorldPacket data; + MakeNotOwner(&data); + SendToOne(&data, guid); + return; + } + Player* newp = sObjectAccessor->FindPlayerByName(newname); uint64 victim = newp ? newp->GetGUID() : 0; - + if (!victim || !IsOn(victim) || (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) { @@ -600,8 +608,6 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; - Player* player = ObjectAccessor::FindPlayer(guid); - if (!IsOn(guid)) { WorldPacket data; @@ -609,7 +615,7 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) SendToOne(&data, guid); return; } - + if (playersStore[guid].IsMuted()) { WorldPacket data; @@ -621,12 +627,13 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) WorldPacket data(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + _name.size() + 8 + 4 + what.size() + 1); data << uint8(CHAT_MSG_CHANNEL); data << uint32(lang); - data << guid; + data << uint64(guid); data << uint32(0); data << _name; - data << guid; - data << what.size() + 1; + data << uint64(guid); + data << uint32(what.size() + 1); data << what; + Player* player = ObjectAccessor::FindPlayer(guid); data << uint8(player ? player->GetChatTag() : 0); SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false); diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index b903f15c9a8..2ec7ed199ba 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -43,7 +43,7 @@ ChannelMgr* ChannelMgr::forTeam(uint32 team) return NULL; } -Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) +Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channelId) { std::wstring wname; Utf8toWStr(name, wname); @@ -53,7 +53,7 @@ Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) if (i == channels.end()) { - Channel* nchan = new Channel(name, channel_id, team); + Channel* nchan = new Channel(name, channelId, team); channels[wname] = nchan; return nchan; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 3b825a7b8f0..544e3087614 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -739,12 +739,11 @@ void ConditionMgr::LoadConditions(bool isReload) } QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, " - " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorTextId, ScriptName FROM conditions"); + " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions"); if (!result) { - sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 conditions. DB table `conditions` is empty!"); - + sLog->outError(LOG_FILTER_SQL, ">> Loaded 0 conditions. DB table `conditions` is empty!"); return; } @@ -755,19 +754,20 @@ void ConditionMgr::LoadConditions(bool isReload) Field* fields = result->Fetch(); Condition* cond = new Condition(); - int32 iSourceTypeOrReferenceId = fields[0].GetInt32(); + int32 iSourceTypeOrReferenceId = fields[0].GetInt32(); cond->SourceGroup = fields[1].GetUInt32(); cond->SourceEntry = fields[2].GetInt32(); cond->SourceId = fields[3].GetInt32(); cond->ElseGroup = fields[4].GetUInt32(); - int32 iConditionTypeOrReference = fields[5].GetInt32(); + int32 iConditionTypeOrReference = fields[5].GetInt32(); cond->ConditionTarget = fields[6].GetUInt8(); cond->ConditionValue1 = fields[7].GetUInt32(); cond->ConditionValue2 = fields[8].GetUInt32(); cond->ConditionValue3 = fields[9].GetUInt32(); cond->NegativeCondition = fields[10].GetUInt8(); - cond->ErrorTextId = fields[11].GetUInt32(); - cond->ScriptId = sObjectMgr->GetScriptId(fields[12].GetCString()); + cond->ErrorType = fields[11].GetUInt32(); + cond->ErrorTextId = fields[12].GetUInt32(); + cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetCString()); if (iConditionTypeOrReference >= 0) cond->ConditionType = ConditionTypes(iConditionTypeOrReference); @@ -844,6 +844,18 @@ void ConditionMgr::LoadConditions(bool isReload) continue; } + if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL) + { + sLog->outError(LOG_FILTER_SQL, "Condition type %u entry %i can't have ErrorType (%u), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType); + cond->ErrorType = 0; + } + + if (cond->ErrorTextId && !cond->ErrorType) + { + sLog->outError(LOG_FILTER_SQL, "Condition type %u entry %i has any ErrorType, ErrorTextId (%u) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId); + cond->ErrorTextId = 0; + } + if (cond->SourceGroup) { bool valid = false; @@ -1444,7 +1456,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) if (cond->ConditionTarget >= cond->GetMaxAvailableConditionTargets()) { - sLog->outError(LOG_FILTER_SQL, "SourceType %u, SourceEntry %u in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry); + sLog->outError(LOG_FILTER_SQL, "SourceType %u, SourceEntry %u, SourceGroup %u in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry, cond->SourceGroup); return false; } diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index f8f40972337..99f200b4228 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -181,6 +181,7 @@ struct Condition uint32 ConditionValue1; uint32 ConditionValue2; uint32 ConditionValue3; + uint32 ErrorType; uint32 ErrorTextId; uint32 ReferenceId; uint32 ScriptId; @@ -199,6 +200,7 @@ struct Condition ConditionValue2 = 0; ConditionValue3 = 0; ReferenceId = 0; + ErrorType = 0; ErrorTextId = 0; ScriptId = 0; NegativeCondition = false; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 37f723f5c1f..458b4ea7706 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -953,30 +953,6 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const && player->getClass() == GetCreatureTemplate()->trainer_class; } -void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 /*MovementFlags*/, uint8 /*type*/) -{ - /* uint32 timeElap = getMSTime(); - if ((timeElap - m_startMove) < m_moveTime) - { - oX = (dX - oX) * ((timeElap - m_startMove) / m_moveTime); - oY = (dY - oY) * ((timeElap - m_startMove) / m_moveTime); - } - else - { - oX = dX; - oY = dY; - } - - dX = x; - dY = y; - m_orientation = atan2((oY - dY), (oX - dX)); - - m_startMove = getMSTime(); - m_moveTime = time;*/ - float speed = GetDistance(x, y, z) / ((float)time * 0.001f); - MonsterMoveWithSpeed(x, y, z, speed); -} - Player* Creature::GetLootRecipient() const { if (!m_lootRecipient) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 4a410f4a41d..4651adb7006 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -520,7 +520,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature bool AIM_Initialize(CreatureAI* ai = NULL); void Motion_Initialize(); - void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); CreatureAI* AI() const { return (CreatureAI*)i_AI; } bool SetWalk(bool enable); diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 6be78ec2fb5..eec50095a91 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1026,7 +1026,7 @@ Item* Item::CloneItem(uint32 count, Player const* player) const newItem->SetUInt32Value(ITEM_FIELD_CREATOR, GetUInt32Value(ITEM_FIELD_CREATOR)); newItem->SetUInt32Value(ITEM_FIELD_GIFTCREATOR, GetUInt32Value(ITEM_FIELD_GIFTCREATOR)); - newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS)); + newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS) & ~(ITEM_FLAG_REFUNDABLE | ITEM_FLAG_BOP_TRADEABLE)); newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION)); // player CAN be NULL in which case we must not update random properties because that accesses player's item update queue if (player) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5de54a9d974..ebf25ddb575 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12369,10 +12369,10 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool // if this original item then it need create record in inventory // in case trade we already have item in other player inventory pLastItem->SetState(in_characterInventoryDB ? ITEM_CHANGED : ITEM_NEW, this); - } - if (pLastItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE)) - AddTradeableItem(pLastItem); + if (pLastItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE)) + AddTradeableItem(pLastItem); + } } void Player::DestroyItem(uint8 bag, uint8 slot, bool update) @@ -17885,8 +17885,14 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F AllowedLooterSet looters; for (Tokenizer::const_iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr) looters.insert(atol(*itr)); - item->SetSoulboundTradeable(looters); - AddTradeableItem(item); + + if (looters.size() > 1 && item->GetTemplate()->GetMaxStackSize() == 1 && item->IsSoulBound()) + { + item->SetSoulboundTradeable(looters); + AddTradeableItem(item); + } + else + item->ClearSoulboundTradeable(this); } else { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 66bc030623c..43bbf8eb02a 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15907,316 +15907,319 @@ uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float c return CalculatePct(damage, percent); } -uint32 Unit::GetModelForForm(ShapeshiftForm form) +uint32 Unit::GetModelForForm(ShapeshiftForm form) const { - switch (form) + if (GetTypeId() == TYPEID_PLAYER) { - case FORM_CAT: - // Based on Hair color - if (getRace() == RACE_NIGHTELF) - { - uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); - switch (hairColor) - { - case 7: // Violet - case 8: - return 29405; - case 3: // Light Blue - return 29406; - case 0: // Green - case 1: // Light Green - case 2: // Dark Green - return 29407; - case 4: // White - return 29408; - default: // original - Dark Blue - return 892; - } - } - else if (getRace() == RACE_TROLL) - { - uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); - switch (hairColor) - { - case 0: // Red - case 1: - return 33668; - case 2: // Yellow - case 3: - return 33667; - case 4: // Blue - case 5: - case 6: - return 33666; - case 7: // Purple - case 10: - return 33665; - default: // original - white - return 33669; - } - } - else if (getRace() == RACE_WORGEN) - { - // Based on Skin color - uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); - // Male - if (getGender() == GENDER_MALE) - { - switch (skinColor) - { - case 1: // Brown - return 33662; - case 2: // Black - case 7: - return 33661; - case 4: // yellow - return 33664; - case 3: // White - case 5: - return 33663; - default: // original - Gray - return 33660; - } - } - // Female - else + switch (form) + { + case FORM_CAT: + // Based on Hair color + if (getRace() == RACE_NIGHTELF) { - switch (skinColor) + uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); + switch (hairColor) { - case 5: // Brown - case 6: - return 33662; - case 7: // Black + case 7: // Violet case 8: - return 33661; - case 3: // yellow - case 4: - return 33664; - case 2: // White - return 33663; - default: // original - Gray - return 33660; + return 29405; + case 3: // Light Blue + return 29406; + case 0: // Green + case 1: // Light Green + case 2: // Dark Green + return 29407; + case 4: // White + return 29408; + default: // original - Dark Blue + return 892; } } - } - // Based on Skin color - else if (getRace() == RACE_TAUREN) - { - uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); - // Male - if (getGender() == GENDER_MALE) + else if (getRace() == RACE_TROLL) { - switch (skinColor) + uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); + switch (hairColor) { - case 12: // White - case 13: - case 14: - case 18: // Completly White - return 29409; - case 9: // Light Brown - case 10: - case 11: - return 29410; - case 6: // Brown - case 7: - case 8: - return 29411; - case 0: // Dark + case 0: // Red case 1: - case 2: - case 3: // Dark Grey - case 4: + return 33668; + case 2: // Yellow + case 3: + return 33667; + case 4: // Blue case 5: - return 29412; - default: // original - Grey - return 8571; + case 6: + return 33666; + case 7: // Purple + case 10: + return 33665; + default: // original - white + return 33669; } } - // Female - else + else if (getRace() == RACE_WORGEN) { - switch (skinColor) + // Based on Skin color + uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); + // Male + if (getGender() == GENDER_MALE) { - case 10: // White - return 29409; - case 6: // Light Brown - case 7: - return 29410; - case 4: // Brown - case 5: - return 29411; - case 0: // Dark - case 1: - case 2: - case 3: - return 29412; - default: // original - Grey - return 8571; + switch (skinColor) + { + case 1: // Brown + return 33662; + case 2: // Black + case 7: + return 33661; + case 4: // yellow + return 33664; + case 3: // White + case 5: + return 33663; + default: // original - Gray + return 33660; + } + } + // Female + else + { + switch (skinColor) + { + case 5: // Brown + case 6: + return 33662; + case 7: // Black + case 8: + return 33661; + case 3: // yellow + case 4: + return 33664; + case 2: // White + return 33663; + default: // original - Gray + return 33660; + } } } - } - else if (Player::TeamForRace(getRace()) == ALLIANCE) - return 892; - else - return 8571; - case FORM_BEAR: - // Based on Hair color - if (getRace() == RACE_NIGHTELF) - { - uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); - switch (hairColor) - { - case 0: // Green - case 1: // Light Green - case 2: // Dark Green - return 29413; // 29415? - case 6: // Dark Blue - return 29414; - case 4: // White - return 29416; - case 3: // Light Blue - return 29417; - default: // original - Violet - return 2281; - } - } - else if (getRace() == RACE_TROLL) - { - uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); - switch (hairColor) - { - case 0: // Red - case 1: - return 33657; - case 2: // Yellow - case 3: - return 33659; - case 7: // Purple - case 10: - return 33656; - case 8: // White - case 9: - case 11: - case 12: - return 33658; - default: // original - Blue - return 33655; - } - } - else if (getRace() == RACE_WORGEN) - { // Based on Skin color - uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); - // Male - if (getGender() == GENDER_MALE) + else if (getRace() == RACE_TAUREN) { - switch (skinColor) + uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); + // Male + if (getGender() == GENDER_MALE) { - case 1: // Brown - return 33652; - case 2: // Black - case 7: - return 33651; - case 4: // Yellow - return 33653; - case 3: // White - case 5: - return 33654; - default: // original - Gray - return 33650; + switch (skinColor) + { + case 12: // White + case 13: + case 14: + case 18: // Completly White + return 29409; + case 9: // Light Brown + case 10: + case 11: + return 29410; + case 6: // Brown + case 7: + case 8: + return 29411; + case 0: // Dark + case 1: + case 2: + case 3: // Dark Grey + case 4: + case 5: + return 29412; + default: // original - Grey + return 8571; + } + } + // Female + else + { + switch (skinColor) + { + case 10: // White + return 29409; + case 6: // Light Brown + case 7: + return 29410; + case 4: // Brown + case 5: + return 29411; + case 0: // Dark + case 1: + case 2: + case 3: + return 29412; + default: // original - Grey + return 8571; + } } } - // Female + else if (Player::TeamForRace(getRace()) == ALLIANCE) + return 892; else + return 8571; + case FORM_BEAR: + // Based on Hair color + if (getRace() == RACE_NIGHTELF) { - switch (skinColor) + uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); + switch (hairColor) { - case 5: // Brown - case 6: - return 33652; - case 7: // Black - case 8: - return 33651; - case 3: // yellow - case 4: - return 33654; - case 2: // White - return 33653; - default: // original - Gray - return 33650; + case 0: // Green + case 1: // Light Green + case 2: // Dark Green + return 29413; // 29415? + case 6: // Dark Blue + return 29414; + case 4: // White + return 29416; + case 3: // Light Blue + return 29417; + default: // original - Violet + return 2281; } } - } - // Based on Skin color - else if (getRace() == RACE_TAUREN) - { - uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); - // Male - if (getGender() == GENDER_MALE) + else if (getRace() == RACE_TROLL) { - switch (skinColor) + uint8 hairColor = GetByteValue(PLAYER_BYTES, 3); + switch (hairColor) { - case 0: // Dark (Black) + case 0: // Red case 1: - case 2: - return 29418; - case 3: // White - case 4: - case 5: - case 12: - case 13: - case 14: - return 29419; - case 9: // Light Brown/Grey + return 33657; + case 2: // Yellow + case 3: + return 33659; + case 7: // Purple case 10: + return 33656; + case 8: // White + case 9: case 11: - case 15: - case 16: - case 17: - return 29420; - case 18: // Completly White - return 29421; - default: // original - Brown - return 2289; + case 12: + return 33658; + default: // original - Blue + return 33655; } } - // Female - else + else if (getRace() == RACE_WORGEN) { - switch (skinColor) + // Based on Skin color + uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); + // Male + if (getGender() == GENDER_MALE) { - case 0: // Dark (Black) - case 1: - return 29418; - case 2: // White - case 3: - return 29419; - case 6: // Light Brown/Grey - case 7: - case 8: - case 9: - return 29420; - case 10: // Completly White - return 29421; - default: // original - Brown - return 2289; + switch (skinColor) + { + case 1: // Brown + return 33652; + case 2: // Black + case 7: + return 33651; + case 4: // Yellow + return 33653; + case 3: // White + case 5: + return 33654; + default: // original - Gray + return 33650; + } + } + // Female + else + { + switch (skinColor) + { + case 5: // Brown + case 6: + return 33652; + case 7: // Black + case 8: + return 33651; + case 3: // yellow + case 4: + return 33654; + case 2: // White + return 33653; + default: // original - Gray + return 33650; + } } } - } - else if (Player::TeamForRace(getRace()) == ALLIANCE) - return 2281; - else - return 2289; - case FORM_FLIGHT: - if (Player::TeamForRace(getRace()) == ALLIANCE) - return 20857; - return 20872; - case FORM_FLIGHT_EPIC: - if (Player::TeamForRace(getRace()) == ALLIANCE) - return 21243; - return 21244; - default: - break; + // Based on Skin color + else if (getRace() == RACE_TAUREN) + { + uint8 skinColor = GetByteValue(PLAYER_BYTES, 0); + // Male + if (getGender() == GENDER_MALE) + { + switch (skinColor) + { + case 0: // Dark (Black) + case 1: + case 2: + return 29418; + case 3: // White + case 4: + case 5: + case 12: + case 13: + case 14: + return 29419; + case 9: // Light Brown/Grey + case 10: + case 11: + case 15: + case 16: + case 17: + return 29420; + case 18: // Completly White + return 29421; + default: // original - Brown + return 2289; + } + } + // Female + else + { + switch (skinColor) + { + case 0: // Dark (Black) + case 1: + return 29418; + case 2: // White + case 3: + return 29419; + case 6: // Light Brown/Grey + case 7: + case 8: + case 9: + return 29420; + case 10: // Completly White + return 29421; + default: // original - Brown + return 2289; + } + } + } + else if (Player::TeamForRace(getRace()) == ALLIANCE) + return 2281; + else + return 2289; + case FORM_FLIGHT: + if (Player::TeamForRace(getRace()) == ALLIANCE) + return 20857; + return 20872; + case FORM_FLIGHT_EPIC: + if (Player::TeamForRace(getRace()) == ALLIANCE) + return 21243; + return 21244; + default: + break; + } } uint32 modelid = 0; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 4dfe5ec1a00..11f78275f24 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2134,7 +2134,7 @@ class Unit : public WorldObject void AddPetAura(PetAura const* petSpell); void RemovePetAura(PetAura const* petSpell); - uint32 GetModelForForm(ShapeshiftForm form); + uint32 GetModelForForm(ShapeshiftForm form) const; uint32 GetModelForTotem(PlayerTotemType totemType); void SetReducedThreatPercent(uint32 pct, uint64 guid) diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index d221a8ac80d..e85a888e01c 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -52,15 +52,8 @@ void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlag recvPacket >> hasMovementData; if (hasMovementData) { - recvPacket.rfinish(); - // movement packet for caster of the spell - /*recvPacket.read_skip<uint32>(); // MSG_MOVE_STOP - hardcoded in client - uint64 guid; - recvPacket.readPackGUID(guid); - - MovementInfo movementInfo; - movementInfo.guid = guid; - ReadMovementInfo(recvPacket, &movementInfo);*/ + recvPacket.SetOpcode(Opcodes(recvPacket.read<uint32>())); + HandleMovementOpcodes(recvPacket); } } else if (castFlags & 0x8) // Archaeology diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 8a7a1cec33a..6576b470a7f 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -86,8 +86,7 @@ enum TrinityStrings LANG_CONNECTED_PLAYERS = 60, LANG_ACCOUNT_ADDON = 61, LANG_IMPROPER_VALUE = 62, - LANG_CANT_DO_NOW = 63, - // Room for more level 0 64-99 not used + // Room for more level 0 63-99 not used // level 1 chat LANG_GLOBAL_NOTIFY = 100, diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 6c2315ddc69..38da442ca5b 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -90,7 +90,6 @@ void AddSC_npc_innkeeper(); void AddSC_npcs_special(); void AddSC_npc_taxi(); void AddSC_achievement_scripts(); -void AddSC_event_scripts(); //eastern kingdoms void AddSC_alterac_valley(); //Alterac Valley @@ -595,6 +594,9 @@ void AddSC_shattrath_city(); void AddSC_terokkar_forest(); void AddSC_zangarmarsh(); +// Events +void AddSC_event_childrens_week(); + // battlegrounds // outdoor pvp @@ -706,7 +708,6 @@ void AddWorldScripts() AddSC_npc_taxi(); AddSC_achievement_scripts(); AddSC_chat_log(); - AddSC_event_scripts(); #endif } @@ -1230,6 +1231,13 @@ void AddNorthrendScripts() #endif } +void AddEventScripts() +{ +#ifdef SCRIPTS + AddSC_event_childrens_week(); +#endif +} + void AddOutdoorPvPScripts() { #ifdef SCRIPTS diff --git a/src/server/game/Scripting/ScriptLoader.h b/src/server/game/Scripting/ScriptLoader.h index 0db6917a0d4..04ab3215551 100644 --- a/src/server/game/Scripting/ScriptLoader.h +++ b/src/server/game/Scripting/ScriptLoader.h @@ -27,6 +27,7 @@ void AddEasternKingdomsScripts(); void AddKalimdorScripts(); void AddOutlandScripts(); void AddNorthrendScripts(); +void AddEventScripts(); void AddBattlegroundScripts(); void AddOutdoorPvPScripts(); void AddCustomScripts(); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 72e1a472c06..27e5e2d8d2b 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -283,7 +283,10 @@ void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, /// Logging helper for unexpected opcodes void WorldSession::LogUnprocessedTail(WorldPacket* packet) { - sLog->outError(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", + if (!sLog->ShouldLog(LOG_FILTER_OPCODES, LOG_LEVEL_TRACE) || packet->rpos() >= packet->wpos()) + return; + + sLog->outTrace(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); packet->print_storage(); } @@ -344,8 +347,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) { sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle->Handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; @@ -358,8 +360,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) // not expected _player or must checked in packet hanlder sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle->Handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } break; case STATUS_TRANSFER: @@ -371,8 +372,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) { sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle->Handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } break; case STATUS_AUTHED: @@ -390,8 +390,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle->Handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); break; case STATUS_NEVER: sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 73f19ba3f3c..435f65cb5d8 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -173,7 +173,8 @@ int WorldSocket::SendPacket(WorldPacket const& pct) pkt = &buff; } - sLog->outInfo(LOG_FILTER_OPCODES, "S->C: %s", GetOpcodeNameForLogging(pkt->GetOpcode()).c_str()); + if (m_Session) + sLog->outTrace(LOG_FILTER_OPCODES, "S->C: %s %s", m_Session->GetPlayerInfo().c_str(), GetOpcodeNameForLogging(pkt->GetOpcode()).c_str()); sScriptMgr->OnPacketSend(this, *pkt); @@ -678,7 +679,8 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) sPacketLog->LogPacket(*new_pct, CLIENT_TO_SERVER); std::string opcodeName = GetOpcodeNameForLogging(opcode); - sLog->outInfo(LOG_FILTER_OPCODES, "C->S: %s", opcodeName.c_str()); + if (m_Session) + sLog->outTrace(LOG_FILTER_OPCODES, "C->S: %s %s", m_Session->GetPlayerInfo().c_str(), opcodeName.c_str()); try { @@ -696,7 +698,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct)); return HandleAuthSession(*new_pct); case CMSG_KEEP_ALIVE: - sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", GetOpcodeNameForLogging(opcode).c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", opcodeName.c_str()); sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct)); return 0; case CMSG_LOG_DISCONNECT: diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4c22328cd26..b38d5f085b6 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4884,17 +4884,12 @@ SpellCastResult Spell::CheckCast(bool strict) ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id); if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions)) { - // send error msg to player if condition failed and text message available - // TODO: using WorldSession::SendNotification is not blizzlike - if (Player* playerCaster = m_caster->ToPlayer()) + // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others) + if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType) { - // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others) - if (playerCaster->GetSession() && condInfo.mLastFailedCondition - && condInfo.mLastFailedCondition->ErrorTextId) - { - playerCaster->GetSession()->SendNotification(condInfo.mLastFailedCondition->ErrorTextId); - return SPELL_FAILED_DONT_REPORT; - } + if (condInfo.mLastFailedCondition->ErrorType == SPELL_FAILED_CUSTOM_ERROR) + m_customError = SpellCustomErrors(condInfo.mLastFailedCondition->ErrorTextId); + return SpellCastResult(condInfo.mLastFailedCondition->ErrorType); } if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget) return SPELL_FAILED_CASTER_AURASTATE; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 11368e990f5..94cd924681e 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -5123,12 +5123,11 @@ void Spell::EffectDurabilityDamage(SpellEffIndex effIndex) int32 slot = m_spellInfo->Effects[effIndex].MiscValue; - // FIXME: some spells effects have value -1/-2 - // Possibly its mean -1 all player equipped items and -2 all items + // -1 means all player equipped items and -2 all items if (slot < 0) { unitTarget->ToPlayer()->DurabilityPointsLossAll(damage, (slot < -1)); - ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, -1, -1); // -1 -1 pair triggers SPELL_DURABILITY_DAMAGE_ALL event + ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, -1, -1); return; } |
