diff --git a/sql/migrations/20191207183415_world.sql b/sql/migrations/20191207183415_world.sql new file mode 100644 index 000000000..5ba810771 --- /dev/null +++ b/sql/migrations/20191207183415_world.sql @@ -0,0 +1,72 @@ +DROP PROCEDURE IF EXISTS add_migration; +delimiter ?? +CREATE PROCEDURE `add_migration`() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20191207183415'); +IF v=0 THEN +INSERT INTO `migrations` VALUES ('20191207183415'); +-- Add your query below. + + +ALTER TABLE `areatrigger_teleport` + CHANGE COLUMN `name` `name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `patch`, + ADD COLUMN `message` VARCHAR(128) NOT NULL DEFAULT '' AFTER `name`; + +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 20 to enter.' WHERE `id`=45; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 10 to enter.' WHERE `id`=78; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 15 to enter.' WHERE `id`=101; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 10 to enter.' WHERE `id`=145; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 10 to enter.' WHERE `id`=228; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 15 to enter.' WHERE `id`=244; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 10 to enter.', `required_level`=10 WHERE `id`=257; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 30 to enter.' WHERE `id`=286; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 15 to enter.' WHERE `id`=324; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 25 to enter.' WHERE `id`=442; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 35 to enter.' WHERE `id`=446; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 15 to enter.' WHERE `id`=523; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 20 to enter.' WHERE `id`=610; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 20 to enter.' WHERE `id`=612; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 20 to enter.' WHERE `id`=614; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 30 to enter.' WHERE `id`=902; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 35 to enter.' WHERE `id`=924; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 40 to enter.' WHERE `id`=1466; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=1468; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=2214; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=2216; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=2217; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 8 to enter.' WHERE `id`=2230; +UPDATE `areatrigger_teleport` SET `message`='You must be a Stone Guard or higher rank in order to enter the Hall of Legends.' WHERE `id`=2527; +UPDATE `areatrigger_teleport` SET `message`='You must be a Knight or higher rank in order to enter the Champions\' Hall.' WHERE `id`=2532; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=2567; +UPDATE `areatrigger_teleport` SET `message`='Only the Horde may use this portal.' WHERE `id`=2606; +UPDATE `areatrigger_teleport` SET `message`='Only the Alliance may use this portal.' WHERE `id`=2608; +UPDATE `areatrigger_teleport` SET `message`='You must be part of a Raid group, at least level 50 and have the Drakefire Amulet in your inventory to enter.' WHERE `id`=2848; +UPDATE `areatrigger_teleport` SET `message`='You must be part of a Raid group and at least level 50 to enter.' WHERE `id`=2886; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 30 to enter.' WHERE `id`=3133; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 30 to enter.' WHERE `id`=3134; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3183; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3184; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3185; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3186; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3187; +UPDATE `areatrigger_teleport` SET `message`='You must be at least level 45 to enter.' WHERE `id`=3189; +UPDATE `areatrigger_teleport` SET `message`='You must be attuned and in a raid group to enter.' WHERE `id`=3528; +UPDATE `areatrigger_teleport` SET `message`='Only the Horde may use this portal.' WHERE `id`=3669; +UPDATE `areatrigger_teleport` SET `message`='Only the Alliance may use this portal.' WHERE `id`=3671; +UPDATE `areatrigger_teleport` SET `message`='You must be part of a raid group and at least 50th level to enter.', `required_level`=50 WHERE `id`=3726; +UPDATE `areatrigger_teleport` SET `message`='You must be part of a Raid group and at least level 50 to enter.' WHERE `id`=3928; +UPDATE `areatrigger_teleport` SET `message`='Only the Alliance may use this portal.' WHERE `id`=3948; +UPDATE `areatrigger_teleport` SET `message`='Only the Horde may use this portal.' WHERE `id`=3949; +UPDATE `areatrigger_teleport` SET `message`='You cannot enter here unless the gates of Ahn\'Qiraj have been opened, you are level 50+, and in a raid group.' WHERE `id`=4008; +UPDATE `areatrigger_teleport` SET `message`='You cannot enter here unless the gates of Ahn\'Qiraj have been opened, you are level 50+, and in a raid group.' WHERE `id`=4010; +UPDATE `areatrigger_teleport` SET `message`='You must be level 51+, in a Raid group, and be attuned to Naxxramas to enter.' WHERE `id`=4055; +UPDATE `areatrigger_teleport` SET `required_level`=0 WHERE `id`=2890; + + +-- End of migration. +END IF; +END?? +delimiter ; +CALL add_migration(); +DROP PROCEDURE IF EXISTS add_migration; diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index cb03c7c4e..d9dd49c2d 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -3330,10 +3330,10 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return false; } - mapid = at->target_mapId; - x = at->target_X; - y = at->target_Y; - z = at->target_Z; + mapid = at->destination.mapId; + x = at->destination.x; + y = at->destination.y; + z = at->destination.z; return true; } } diff --git a/src/game/Commands/MiscCommands.cpp b/src/game/Commands/MiscCommands.cpp index e76eb30a2..8d68959fa 100644 --- a/src/game/Commands/MiscCommands.cpp +++ b/src/game/Commands/MiscCommands.cpp @@ -1379,18 +1379,18 @@ void ChatHandler::ShowTriggerTargetListHelper(uint32 id, AreaTriggerTeleport con char dist_buf[50]; if (!subpart) { - float dist = m_session->GetPlayer()->GetDistance2d(at->target_X, at->target_Y); + float dist = m_session->GetPlayer()->GetDistance2d(at->destination); snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist); } else dist_buf[0] = '\0'; PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CHAT, - subpart ? " -> " : "", id, id, at->target_mapId, at->target_X, at->target_Y, at->target_Z, dist_buf); + subpart ? " -> " : "", id, id, at->destination.mapId, at->destination.x, at->destination.y, at->destination.z, dist_buf); } else PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CONSOLE, - subpart ? " -> " : "", id, at->target_mapId, at->target_X, at->target_Y, at->target_Z); + subpart ? " -> " : "", id, at->destination.mapId, at->destination.x, at->destination.y, at->destination.z); } void ChatHandler::ShowTriggerListHelper(AreaTriggerEntry const * atEntry) @@ -1584,11 +1584,11 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) if (!at) continue; - if (at->target_mapId != m_session->GetPlayer()->GetMapId()) + if (at->destination.mapId != m_session->GetPlayer()->GetMapId()) continue; - float dx = at->target_X - pl->GetPositionX(); - float dy = at->target_Y - pl->GetPositionY(); + float dx = at->destination.x - pl->GetPositionX(); + float dy = at->destination.y - pl->GetPositionY(); if (dx * dx + dy * dy > dist2) continue; diff --git a/src/game/Commands/TeleportCommands.cpp b/src/game/Commands/TeleportCommands.cpp index 25bba23cf..337b2d5c6 100644 --- a/src/game/Commands/TeleportCommands.cpp +++ b/src/game/Commands/TeleportCommands.cpp @@ -318,7 +318,7 @@ bool ChatHandler::HandleGoTriggerCommand(char* args) return false; } - return HandleGoHelper(pPlayer, at->target_mapId, at->target_X, at->target_Y, &at->target_Z); + return HandleGoHelper(pPlayer, at->destination.mapId, at->destination.x, at->destination.y, &at->destination.z); } else return HandleGoHelper(pPlayer, atEntry->mapid, atEntry->x, atEntry->y, &atEntry->z); diff --git a/src/game/Handlers/BattleGroundHandler.cpp b/src/game/Handlers/BattleGroundHandler.cpp index 8f434eaa4..57afc83e0 100644 --- a/src/game/Handlers/BattleGroundHandler.cpp +++ b/src/game/Handlers/BattleGroundHandler.cpp @@ -129,7 +129,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) if (queuedAtBGPortal) { auto const& bgQueuePos = _player->GetBattleGroundEntryPoint(); - if (_player->GetMapId() != bgQueuePos.mapid || !_player->IsWithinDist3d(bgQueuePos.coord_x, bgQueuePos.coord_y, bgQueuePos.coord_z, 50.0f)) + if (_player->GetMapId() != bgQueuePos.mapId || !_player->IsWithinDist3d(bgQueuePos, 50.0f)) { ProcessAnticheatAction("PassiveAnticheat", "Attempt to queue for BG through out of range portal", CHEAT_ACTION_LOG | CHEAT_ACTION_REPORT_GMS); return; diff --git a/src/game/Handlers/CharacterHandler.cpp b/src/game/Handlers/CharacterHandler.cpp index 2be1d11df..72b5cbe18 100644 --- a/src/game/Handlers/CharacterHandler.cpp +++ b/src/game/Handlers/CharacterHandler.cpp @@ -619,9 +619,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) // normal delayed teleport protection not applied (and this correct) for this case (Player object just created) AreaTriggerTeleport const* at = sObjectMgr.GetGoBackTrigger(pCurrChar->GetMapId()); if (at) - pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation()); + pCurrChar->TeleportTo(at->destination, pCurrChar->GetOrientation()); else if (pCurrChar->GetMapId() == 533) - pCurrChar->TeleportTo(0, 3120.16f, -3724.93f, 137.66f, 5.83567f); // Naxxramas has no exit trigger + pCurrChar->TeleportTo(0, 3362.15f, -3379.35f, 144.782f, 6.28319f); // Naxxramas has no exit trigger else pCurrChar->TeleportToHomebind(); diff --git a/src/game/Handlers/MiscHandler.cpp b/src/game/Handlers/MiscHandler.cpp index a4a9f8efb..a5b6c71d7 100644 --- a/src/game/Handlers/MiscHandler.cpp +++ b/src/game/Handlers/MiscHandler.cpp @@ -41,6 +41,7 @@ #include "ObjectAccessor.h" #include "Object.h" #include "BattleGround.h" +#include "BattleGroundMgr.h" #include "Pet.h" #include "SocialMgr.h" #include "Spell.h" @@ -798,21 +799,21 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) return; } - BattlegroundEntranceTrigger const* bget = sObjectMgr.GetBattlegroundEntranceTrigger(Trigger_ID); - if (bget) + if (BattlegroundEntranceTrigger const* bget = sObjectMgr.GetBattlegroundEntranceTrigger(Trigger_ID)) { - if (pl->GetTeam() == bget->team) + BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bget->bgTypeId); + if (!bg) + return; + + if ((pl->GetLevel() < bg->GetMinLevel() || pl->GetLevel() > bg->GetMaxLevel()) || + (pl->GetTeam() == bget->team)) { - if (pl->GetBGAccessByLevel(bget->bgTypeId)) - { - pl->SetBattleGroundEntryPoint(bget->exit_mapId, bget->exit_X, bget->exit_Y, bget->exit_Z, bget->exit_Orientation); - SendBattlegGroundList(pl->GetObjectGuid(), bget->bgTypeId); - } - else - SendAreaTriggerMessage("You do not meet this Battleground's level requirements."); + SendAreaTriggerMessage("You must be in the %s and at least %u%s level to enter.", pl->GetTeam() == ALLIANCE ? "Alliance" : "Horde", bg->GetMinLevel(), bg->GetMinLevel() % 2 ? "st" : "th"); + return; } - else - SendAreaTriggerMessage("Only %s members can enter the Battleground here.", pl->GetTeam() == ALLIANCE ? "Horde" : "Alliance"); + + pl->SetBattleGroundEntryPoint(bget->exit_mapId, bget->exit_X, bget->exit_Y, bget->exit_Z, bget->exit_Orientation); + SendBattlegGroundList(pl->GetObjectGuid(), bget->bgTypeId); return; } @@ -833,7 +834,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (!at) return; - MapEntry const* targetMapEntry = sMapStorage.LookupEntry(at->target_mapId); + MapEntry const* targetMapEntry = sMapStorage.LookupEntry(at->destination.mapId); if (!targetMapEntry) return; @@ -906,7 +907,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) } // need find areatrigger to inner dungeon for landing point - if (at->target_mapId != corpseMapId) + if (at->destination.mapId != corpseMapId) if (AreaTriggerTeleport const* corpseAt = sObjectMgr.GetMapEntranceTrigger(corpseMapId)) at = corpseAt; // now we can resurrect player, and then check teleport requirements @@ -934,7 +935,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) { if (!GetPlayer()->GetQuestRewardStatus(9121) && !GetPlayer()->GetQuestRewardStatus(9122) && !GetPlayer()->GetQuestRewardStatus(9123)) { - SendAreaTriggerMessage("You must complete The Dread Citadel to enter Naxxramas"); + SendAreaTriggerMessage(at->message.c_str()); return; } } @@ -946,22 +947,28 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if (missingLevel || missingItem || missingQuest || missingRank || missingTeam) { - if (missingItem) - SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, ObjectMgr::GetItemPrototype(missingItem)->Name1); - else if (missingQuest) - SendAreaTriggerMessage("You must complete %s to enter", sObjectMgr.GetQuestTemplate(missingQuest)->GetTitle().c_str()); - else if (missingLevel) - SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED), missingLevel); - else if (missingRank) - SendAreaTriggerMessage("You must be a %s or higher rank in order to enter the %s.", pl->GetTeam() == HORDE ? HordePvPRankNames[at->required_pvp_rank] : AlliancePvPRankNames[at->required_pvp_rank], targetMapEntry->name); - else if (missingTeam) - SendAreaTriggerMessage("Only %s may enter here", at->required_team == HORDE ? "Horde" : "Alliance"); - + if (at->message.empty()) + { + if (missingItem) + SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, ObjectMgr::GetItemPrototype(missingItem)->Name1); + else if (missingQuest) + SendAreaTriggerMessage("You must complete %s to enter", sObjectMgr.GetQuestTemplate(missingQuest)->GetTitle().c_str()); + else if (missingLevel) + SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED), missingLevel); + else if (missingRank) + SendAreaTriggerMessage("You must be a %s or higher rank in order to enter the %s.", pl->GetTeam() == HORDE ? HordePvPRankNames[at->required_pvp_rank] : AlliancePvPRankNames[at->required_pvp_rank], targetMapEntry->name); + else if (missingTeam) + SendAreaTriggerMessage("Only %s may enter here", at->required_team == HORDE ? "Horde" : "Alliance"); + } + else + { + SendAreaTriggerMessage(at->message.c_str()); + } return; } } - GetPlayer()->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation); + GetPlayer()->TeleportTo(at->destination); } void WorldSession::HandleUpdateAccountData(WorldPacket & recv_data) diff --git a/src/game/Handlers/MovementHandler.cpp b/src/game/Handlers/MovementHandler.cpp index c69e08544..4bc37c6fe 100644 --- a/src/game/Handlers/MovementHandler.cpp +++ b/src/game/Handlers/MovementHandler.cpp @@ -61,11 +61,11 @@ void WorldSession::HandleMoveWorldportAckOpcode() WorldLocation &loc = GetPlayer()->GetTeleportDest(); // possible errors in the coordinate validity check (only cheating case possible) - if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation)) + if (!MapManager::IsValidMapCoord(loc)) { sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location " "(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + GetPlayer()->GetGuidStr().c_str(), loc.mapId, loc.x, loc.y, loc.z); // stop teleportation else we would try this again and again in LogoutPlayer... GetPlayer()->SetSemaphoreTeleportFar(false); // and teleport the player to a valid place @@ -74,7 +74,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() } // get the destination map entry, not the current one, this will fix homebind and reset greeting - MapEntry const* mEntry = sMapStorage.LookupEntry(loc.mapid); + MapEntry const* mEntry = sMapStorage.LookupEntry(loc.mapId); Map* map = nullptr; @@ -82,13 +82,13 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (mEntry->IsBattleGround()) { if (GetPlayer()->GetBattleGroundId()) - map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId()); + map = sMapMgr.FindMap(loc.mapId, GetPlayer()->GetBattleGroundId()); if (!map) { DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance " " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + GetPlayer()->GetGuidStr().c_str(), loc.mapId, loc.x, loc.y, loc.z); GetPlayer()->SetSemaphoreTeleportFar(false); @@ -110,16 +110,16 @@ void WorldSession::HandleMoveWorldportAckOpcode() // relocate the player to the teleport destination if (!map) { - if (loc.mapid <= 1) - GetPlayer()->SetLocationInstanceId(sMapMgr.GetContinentInstanceId(loc.mapid, loc.coord_x, loc.coord_y)); - map = sMapMgr.CreateMap(loc.mapid, GetPlayer()); + if (loc.mapId <= 1) + GetPlayer()->SetLocationInstanceId(sMapMgr.GetContinentInstanceId(loc.mapId, loc.x, loc.y)); + map = sMapMgr.CreateMap(loc.mapId, GetPlayer()); } GetPlayer()->SetMap(map); if (Transport* t = GetPlayer()->GetTransport()) // Transport position may have changed while loading t->UpdatePassengerPosition(GetPlayer()); else - GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation); + GetPlayer()->Relocate(loc.x, loc.y, loc.z, loc.o); GetPlayer()->SendInitialPacketsBeforeAddToMap(); // the CanEnter checks are done in TeleporTo but conditions may change @@ -132,7 +132,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map " " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", - GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); + GetPlayer()->GetGuidStr().c_str(), loc.mapId, loc.x, loc.y, loc.z); // Teleport to previous place, if cannot be ported back TP to homebind place if (!GetPlayer()->TeleportTo(old_loc)) @@ -250,7 +250,7 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recvData) pPlayerMover->SetSemaphoreTeleportNear(false); WorldLocation const& dest = pPlayerMover->GetTeleportDest(); - pPlayerMover->TeleportPositionRelocation(dest.coord_x, dest.coord_y, dest.coord_z, dest.orientation); + pPlayerMover->TeleportPositionRelocation(dest); // resummon pet, if the destination is in another continent instance, let Player::SwitchInstance do it // because the client will request the name for the old pet guid and receive no answer @@ -260,7 +260,7 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recvData) if (sWorld.getConfig(CONFIG_BOOL_CONTINENTS_INSTANCIATE) && pPlayerMover->GetMap()->IsContinent()) { bool transition = false; - if (sMapMgr.GetContinentInstanceId(pPlayerMover->GetMap()->GetId(), dest.coord_x, dest.coord_y, &transition) == pPlayerMover->GetInstanceId()) + if (sMapMgr.GetContinentInstanceId(pPlayerMover->GetMap()->GetId(), dest.x, dest.y, &transition) == pPlayerMover->GetInstanceId()) pPlayerMover->ResummonPetTemporaryUnSummonedIfAny(); } else diff --git a/src/game/HardcodedEvents.cpp b/src/game/HardcodedEvents.cpp index 62e5e5aa8..ed95d0e13 100644 --- a/src/game/HardcodedEvents.cpp +++ b/src/game/HardcodedEvents.cpp @@ -565,8 +565,8 @@ void SilithusWarEffortBattle::Enable() KalimdorMap = Maps[KalimdorID]; - float CenterX = EventPos.coord_x; - float CenterY = EventPos.coord_y; + float CenterX = EventPos.x; + float CenterY = EventPos.y; const float Radius = 45.0f; @@ -598,7 +598,7 @@ void SilithusWarEffortBattle::Enable() RaceClassCombo RaceClass = AvaliableCombos[ComboID]; - BattlePlayerAI* PlayerAi = new BattlePlayerAI(nullptr, RaceClass.Race, RaceClass.Class, EventPos.mapid, 14, FinalX, FinalY, FinalZ, FinalO); + BattlePlayerAI* PlayerAi = new BattlePlayerAI(nullptr, RaceClass.Race, RaceClass.Class, EventPos.mapId, 14, FinalX, FinalY, FinalZ, FinalO); if (sPlayerBotMgr.addBot(PlayerAi)) { BotEventInfo EventInfo(PlayerAi); diff --git a/src/game/MapNodes/Handlers/SessionTransfert.cpp b/src/game/MapNodes/Handlers/SessionTransfert.cpp index ae0bb791a..6b702da98 100644 --- a/src/game/MapNodes/Handlers/SessionTransfert.cpp +++ b/src/game/MapNodes/Handlers/SessionTransfert.cpp @@ -141,11 +141,11 @@ void NodeSession::HandleLoadPlayerSerialized(WorldPacket& pkt) sObjectAccessor.AddObject(player); WorldPacket data(SMSG_NEW_WORLD, 20); - data << uint32(player->GetTeleportDest().mapid); - data << float(player->GetTeleportDest().coord_x); - data << float(player->GetTeleportDest().coord_y); - data << float(player->GetTeleportDest().coord_z); - data << float(player->GetTeleportDest().orientation); + data << uint32(player->GetTeleportDest().mapId); + data << float(player->GetTeleportDest().x); + data << float(player->GetTeleportDest().y); + data << float(player->GetTeleportDest().z); + data << float(player->GetTeleportDest().o); wsess->SendPacket(&data); } diff --git a/src/game/MapNodes/Serializers/PlayerSerializer.h b/src/game/MapNodes/Serializers/PlayerSerializer.h index ea89664ee..cd4f3cc10 100644 --- a/src/game/MapNodes/Serializers/PlayerSerializer.h +++ b/src/game/MapNodes/Serializers/PlayerSerializer.h @@ -43,13 +43,13 @@ inline ByteBuffer& operator>>(ByteBuffer& buf, Position& p) inline ByteBuffer& operator<<(ByteBuffer& buf, WorldLocation const& p) { - buf << p.coord_x << p.coord_y << p.coord_z << p.orientation << p.mapid; + buf << p.x << p.y << p.z << p.o << p.mapId; return buf; } inline ByteBuffer& operator>>(ByteBuffer& buf, WorldLocation& p) { - buf >> p.coord_x >> p.coord_y >> p.coord_z >> p.orientation >> p.mapid; + buf >> p.x >> p.y >> p.z >> p.o >> p.mapId; return buf; } diff --git a/src/game/Maps/MapManager.h b/src/game/Maps/MapManager.h index 43fc93779..ffe8731a1 100644 --- a/src/game/Maps/MapManager.h +++ b/src/game/Maps/MapManager.h @@ -143,7 +143,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton(at.target_mapId); + MapEntry const* mapEntry = sMapStorage.LookupEntry(at.destination.mapId); if (!mapEntry) { - sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent target map (ID: %u) for Area trigger (ID:%u).", at.target_mapId, Trigger_ID); + sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent target map (ID: %u) for Area trigger (ID:%u).", at.destination.mapId, Trigger_ID); continue; } - if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0) + if (!at.destination.x && !at.destination.y && !at.destination.z) { sLog.outErrorDb("Table `areatrigger_teleport` has area trigger (ID:%u) without target coordinates.", Trigger_ID); continue; @@ -6803,7 +6804,7 @@ AreaTriggerTeleport const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const for (AreaTriggerTeleportMap::const_iterator itr = m_AreaTriggerTeleportMap.begin(); itr != m_AreaTriggerTeleportMap.end(); ++itr) { - if (itr->second.target_mapId == uint32(mapEntry->ghostEntranceMap)) + if (itr->second.destination.mapId == uint32(mapEntry->ghostEntranceMap)) { AreaTriggerEntry const* atEntry = GetAreaTrigger(itr->first); if (atEntry && atEntry->mapid == map_id) @@ -6820,7 +6821,7 @@ AreaTriggerTeleport const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const { for (AreaTriggerTeleportMap::const_iterator itr = m_AreaTriggerTeleportMap.begin(); itr != m_AreaTriggerTeleportMap.end(); ++itr) { - if (itr->second.target_mapId == Map) + if (itr->second.destination.mapId == Map) { AreaTriggerEntry const* atEntry = GetAreaTrigger(itr->first); if (atEntry) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 3615381cc..b9a1a9c31 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -64,18 +64,15 @@ typedef std::unordered_map GameTeleMap; struct AreaTriggerTeleport { - uint8 requiredLevel; - uint32 requiredItem; - uint32 requiredItem2; - uint32 requiredQuest; - int required_event; - uint8 required_pvp_rank; - uint16 required_team; - uint32 target_mapId; - float target_X; - float target_Y; - float target_Z; - float target_Orientation; + std::string message; + uint8 requiredLevel = 0; + uint32 requiredItem = 0; + uint32 requiredItem2 = 0; + uint32 requiredQuest = 0; + int required_event = 0; + uint8 required_pvp_rank = 0; + uint16 required_team = 0; + WorldLocation destination; }; struct BattlegroundEntranceTrigger diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index 184ec3d42..33045cfba 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -111,15 +111,15 @@ struct Position struct WorldLocation { - uint32 mapid = 0; - float coord_x = 0.0f; - float coord_y = 0.0f; - float coord_z = 0.0f; - float orientation = 0.0f; + uint32 mapId = 0; + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; + float o = 0.0f; explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0) - : mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {} + : mapId(_mapid), x(_x), y(_y), z(_z), o(_o) {} WorldLocation(WorldLocation const &loc) - : mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {} + : mapId(loc.mapId), x(loc.x), y(loc.y), z(loc.z), o(loc.o) {} }; @@ -753,8 +753,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object float GetPositionZ() const { return m_position.z; } virtual void GetSafePosition(float &x, float &y, float &z, Transport* onTransport = nullptr) const { GetPosition(x, y, z, onTransport); } void GetPosition(float &x, float &y, float &z, Transport* onTransport = nullptr) const; - void GetPosition(WorldLocation &loc) const - { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } + void GetPosition(WorldLocation &loc) const { loc.mapId = m_mapId; GetPosition(loc.x, loc.y, loc.z); loc.o = GetOrientation(); } float GetOrientation() const { return m_position.o; } void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const; @@ -807,12 +806,16 @@ class MANGOS_DLL_SPEC WorldObject : public Object float GetDistance3dToCenter(WorldObject const* target) const; float GetDistance(WorldObject const* obj) const; float GetDistance(float x, float y, float z) const; + float GetDistance(WorldLocation const& position) const { return GetDistance(position.x, position.y, position.z); } float GetDistance2d(WorldObject const* obj) const; float GetDistance2d(float x, float y) const; + float GetDistance2d(WorldLocation const& position) const { return GetDistance2d(position.x, position.y); } float GetDistanceZ(WorldObject const* obj) const; float GetDistanceSqr(float x, float y, float z) const; bool IsInMap(WorldObject const* obj) const; + bool IsWithinDist3d(WorldLocation const& position, float dist2compare) const { return IsWithinDist3d(position.x, position.y, position.z, dist2compare); } bool IsWithinDist3d(float x, float y, float z, float dist2compare) const; + bool IsWithinDist2d(WorldLocation const& position, float dist2compare) const { return IsWithinDist2d(position.x, position.y, dist2compare); } bool IsWithinDist2d(float x, float y, float dist2compare) const; bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const; diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 5c11dbce7..6a239fb25 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -1911,10 +1911,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati const auto wps = [this](){ WorldPacket data; BuildTeleportAckMsg(data, - m_teleport_dest.coord_x, - m_teleport_dest.coord_y, - m_teleport_dest.coord_z, - m_teleport_dest.orientation); + m_teleport_dest.x, + m_teleport_dest.y, + m_teleport_dest.z, + m_teleport_dest.o); SendMovementMessageToSet(std::move(data), true); }; if (recover) @@ -2070,10 +2070,10 @@ bool Player::ExecuteTeleportFar(ScheduledTeleportData *data) } else { - data << m_teleport_dest.coord_x; - data << m_teleport_dest.coord_y; - data << m_teleport_dest.coord_z; - data << m_teleport_dest.orientation; + data << m_teleport_dest.x; + data << m_teleport_dest.y; + data << m_teleport_dest.z; + data << m_teleport_dest.o; } GetSession()->SendPacket(&data); SendMovementMessageToSet(std::move(data), true); @@ -2100,7 +2100,7 @@ void Player::RestorePendingTeleport() bool Player::TeleportToBGEntryPoint() { - if (m_bgData.joinPos.coord_x == 0.0f && m_bgData.joinPos.coord_y == 0.0f && m_bgData.joinPos.coord_z == 0.0f) + if (m_bgData.joinPos.x == 0.0f && m_bgData.joinPos.y == 0.0f && m_bgData.joinPos.z == 0.0f) m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f); return TeleportTo(m_bgData.joinPos); @@ -14562,8 +14562,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder) // player can have current coordinates in to BG map, fix this { const WorldLocation& _loc = GetBattleGroundEntryPoint(); - SetLocationMapId(_loc.mapid); - Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation); + SetLocationMapId(_loc.mapId); + Relocate(_loc.x, _loc.y, _loc.z, _loc.o); // We are not in BG anymore SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); @@ -14626,8 +14626,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder) AreaTriggerTeleport const* at = sObjectMgr.GetGoBackTrigger(GetMapId()); if (at) { - Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); - SetLocationMapId(at->target_mapId); + Relocate(at->destination.x, at->destination.y, at->destination.z, at->destination.o); + SetLocationMapId(at->destination.mapId); } else if (GetMapId() == 533) // Naxxramas { @@ -16013,11 +16013,11 @@ void Player::SaveToDB(bool online, bool force) } else { - uberInsert.addUInt32(GetTeleportDest().mapid); - uberInsert.addFloat(finiteAlways(GetTeleportDest().coord_x)); - uberInsert.addFloat(finiteAlways(GetTeleportDest().coord_y)); - uberInsert.addFloat(finiteAlways(GetTeleportDest().coord_z)); - uberInsert.addFloat(MapManager::NormalizeOrientation(finiteAlways(GetTeleportDest().orientation))); + uberInsert.addUInt32(GetTeleportDest().mapId); + uberInsert.addFloat(finiteAlways(GetTeleportDest().x)); + uberInsert.addFloat(finiteAlways(GetTeleportDest().y)); + uberInsert.addFloat(finiteAlways(GetTeleportDest().z)); + uberInsert.addFloat(MapManager::NormalizeOrientation(finiteAlways(GetTeleportDest().o))); } std::ostringstream ss; @@ -20203,11 +20203,11 @@ void Player::_SaveBGData() stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(m_bgData.bgInstanceID); stmt.addUInt32(uint32(m_bgData.bgTeam)); - stmt.addFloat(m_bgData.joinPos.coord_x); - stmt.addFloat(m_bgData.joinPos.coord_y); - stmt.addFloat(m_bgData.joinPos.coord_z); - stmt.addFloat(m_bgData.joinPos.orientation); - stmt.addUInt32(m_bgData.joinPos.mapid); + stmt.addFloat(m_bgData.joinPos.x); + stmt.addFloat(m_bgData.joinPos.y); + stmt.addFloat(m_bgData.joinPos.z); + stmt.addFloat(m_bgData.joinPos.o); + stmt.addUInt32(m_bgData.joinPos.mapId); stmt.Execute(); } @@ -20278,11 +20278,11 @@ bool Player::HasMovementFlag(MovementFlags f) const void Player::SetHomebindToLocation(WorldLocation const& loc, uint32 area_id) { - m_homebindMapId = loc.mapid; + m_homebindMapId = loc.mapId; m_homebindAreaId = area_id; - m_homebindX = loc.coord_x; - m_homebindY = loc.coord_y; - m_homebindZ = loc.coord_z; + m_homebindX = loc.x; + m_homebindY = loc.y; + m_homebindZ = loc.z; // update sql homebind CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index 5efed3eb6..011f770ee 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -1749,7 +1749,7 @@ class MANGOS_DLL_SPEC Player final: public Unit bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0, std::function recover = std::function()); bool TeleportTo(WorldLocation const &loc, uint32 options = 0, std::function recover = std::function()) { - return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation, options, recover); + return TeleportTo(loc.mapId, loc.x, loc.y, loc.z, loc.o, options, recover); } // _NOT_ thread-safe. Must be executed by the map manager after map updates, since we diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 99b01068f..0c9eac19e 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -1430,11 +1430,19 @@ class MANGOS_DLL_SPEC Unit : public WorldObject MotionMaster* GetMotionMaster() { return &i_motionMaster; } MotionMaster const* GetMotionMaster() const { return &i_motionMaster; } void RestoreMovement(); + + template + void NearTeleportTo(T const& pos, uint32 teleportOptions = TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET) { NearTeleportTo(pos.x, pos.y, pos.z, pos.o, teleportOptions); } void NearTeleportTo(float x, float y, float z, float orientation, uint32 teleportOptions = TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); + template + void NearLandTo(T const& pos) { NearLandTo(pos.x, pos.y, pos.z, pos.o); } void NearLandTo(float x, float y, float z, float orientation); + template + void TeleportPositionRelocation(T const& pos) { TeleportPositionRelocation(pos.x, pos.y, pos.z, pos.o); } void TeleportPositionRelocation(float x, float y, float z, float o); - void MonsterMoveWithSpeed(float x, float y, float z, float o, float speed, uint32 options); + void MonsterMove(float x, float y, float z); + void MonsterMoveWithSpeed(float x, float y, float z, float o, float speed, uint32 options); bool IsStopped() const { return !(HasUnitState(UNIT_STAT_MOVING)); } void StopMoving(bool force = false); void DisableSpline(); diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index 52897c3ca..d9c0ad169 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -6650,17 +6650,17 @@ void Spell::EffectBind(SpellEffectIndex eff_idx) // binding WorldPacket data(SMSG_BINDPOINTUPDATE, (4 + 4 + 4 + 4 + 4)); - data << float(loc.coord_x); - data << float(loc.coord_y); - data << float(loc.coord_z); - data << uint32(loc.mapid); + data << float(loc.x); + data << float(loc.y); + data << float(loc.z); + data << uint32(loc.mapId); data << uint32(area_id); player->SendDirectMessage(&data); - DEBUG_LOG("New Home Position X is %f", loc.coord_x); - DEBUG_LOG("New Home Position Y is %f", loc.coord_y); - DEBUG_LOG("New Home Position Z is %f", loc.coord_z); - DEBUG_LOG("New Home MapId is %u", loc.mapid); + DEBUG_LOG("New Home Position X is %f", loc.x); + DEBUG_LOG("New Home Position Y is %f", loc.y); + DEBUG_LOG("New Home Position Z is %f", loc.z); + DEBUG_LOG("New Home MapId is %u", loc.mapId); DEBUG_LOG("New Home AreaId is %u", area_id); // zone update diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 48eebac9f..0d393ade2 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -733,7 +733,7 @@ void WorldSession::LogoutPlayer(bool Save) { AreaTriggerTeleport const* at = sObjectMgr.GetGoBackTrigger(map->GetId()); if (at) - removedFromMap = _player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, _player->GetOrientation()); + removedFromMap = _player->TeleportTo(at->destination); else removedFromMap = _player->TeleportToHomebind(); @@ -1325,11 +1325,11 @@ void WorldSession::LoginPlayerToNode(NodeSession* session) SendPacket(&data); // Set position on Node - GetPlayer()->GetTeleportDest().mapid = GetPlayer()->GetMapId(); - GetPlayer()->GetTeleportDest().coord_x = GetPlayer()->GetPositionX(); - GetPlayer()->GetTeleportDest().coord_y = GetPlayer()->GetPositionY(); - GetPlayer()->GetTeleportDest().coord_z = GetPlayer()->GetPositionZ(); - GetPlayer()->GetTeleportDest().orientation = GetPlayer()->GetOrientation(); + GetPlayer()->GetTeleportDest().mapId = GetPlayer()->GetMapId(); + GetPlayer()->GetTeleportDest().x = GetPlayer()->GetPositionX(); + GetPlayer()->GetTeleportDest().y = GetPlayer()->GetPositionY(); + GetPlayer()->GetTeleportDest().z = GetPlayer()->GetPositionZ(); + GetPlayer()->GetTeleportDest().o = GetPlayer()->GetOrientation(); GetPlayer()->SetSemaphoreTeleportFar(true); m_nodeSession = session; diff --git a/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/boss_nefarian.cpp b/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/boss_nefarian.cpp index 4e60d8743..3ceda8e5c 100644 --- a/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/boss_nefarian.cpp +++ b/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/boss_nefarian.cpp @@ -237,10 +237,10 @@ struct boss_nefarianAI : ScriptedAI double dsin = sin(dang); double dcos = cos(dang); m_creature->GetPosition(loc); - loc.coord_x += 5.0f * dcos; - loc.coord_y += 5.0f * dsin; - loc.coord_z += 0.5f; - loc.orientation = dang - M_PI_F; + loc.x += 5.0f * dcos; + loc.y += 5.0f * dsin; + loc.z += 0.5f; + loc.o = dang - M_PI_F; pPlayer->TeleportTo(loc); pPlayer->AddAura(SPELL_ROGUE); // OK break; diff --git a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp index 36f528b41..8337f44f1 100644 --- a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp +++ b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp @@ -124,7 +124,7 @@ struct mob_rottingMaggotAI : public ScriptedAI if (!m_creature->HasAura(SPELL_RETCHING_PLAGUE)) m_creature->CastSpell(m_creature, SPELL_RETCHING_PLAGUE, true); } - if (m_creature->GetDistance(aggroPossition.coord_x, aggroPossition.coord_y, aggroPossition.coord_z) > 40.0f) + if (m_creature->GetDistance(aggroPossition) > 40.0f) { EnterEvadeMode(); }