Skip to content

Commit

Permalink
Leaving BG through portal always sent you to exit before patch 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Oct 30, 2023
1 parent f85877f commit a9e2d97
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 49 deletions.
26 changes: 26 additions & 0 deletions sql/migrations/20231030173812_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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`='20231030173812');
IF v=0 THEN
INSERT INTO `migrations` VALUES ('20231030173812');
-- Add your query below.


-- Horde battleground exit triggers.
UPDATE `areatrigger_teleport` SET `required_condition`=2 WHERE `id` IN (2606, 3949, 3669);
-- Alliance battleground exit triggers.
UPDATE `areatrigger_teleport` SET `required_condition`=3 WHERE `id` IN (2608, 3948, 3671);

-- Remove texts that exist elsewhere.
DELETE FROM `mangos_string` WHERE `entry` IN (752, 753);


-- End of migration.
END IF;
END??
delimiter ;
CALL add_migration();
DROP PROCEDURE IF EXISTS add_migration;
2 changes: 1 addition & 1 deletion src/game/Battlegrounds/BattleGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class BattleGround

/* Triggers handle */
// must be implemented in BG subclass
virtual void HandleAreaTrigger(Player* /*source*/, uint32 /*trigger*/) {}
virtual bool HandleAreaTrigger(Player* /*source*/, uint32 /*trigger*/) { return false; }
// must be implemented in BG subclass if need AND call base class generic code
virtual void HandleKillPlayer(Player* pVictim, Player* pKiller);
virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/) { };
Expand Down
21 changes: 12 additions & 9 deletions src/game/Battlegrounds/BattleGroundAB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,24 @@ void BattleGroundAB::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/)

}

void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
{
switch (trigger)
{
case 3948: // Arathi Basin Alliance Exit.
if (source->GetTeam() != ALLIANCE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE);
else
if (source->GetTeam() == ALLIANCE)
{
source->LeaveBattleground();
break;
return true;
}
return false;
case 3949: // Arathi Basin Horde Exit.
if (source->GetTeam() != HORDE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE);
else
if (source->GetTeam() == HORDE)
{
source->LeaveBattleground();
break;
return true;
}
return false;
case 3866: // Stables
case 3869: // Gold Mine
case 3867: // Farm
Expand All @@ -210,6 +212,7 @@ void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
//source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
break;
}
return false;
}

/* type: 0-neutral, 1-contested, 3-occupied
Expand Down
2 changes: 1 addition & 1 deletion src/game/Battlegrounds/BattleGroundAB.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class BattleGroundAB : public BattleGround
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
void RemovePlayer(Player* player, ObjectGuid guid);
void HandleAreaTrigger(Player* source, uint32 trigger);
bool HandleAreaTrigger(Player* source, uint32 trigger);
virtual bool SetupBattleGround();
virtual void Reset();
void EndBattleGround(Team winner);
Expand Down
37 changes: 23 additions & 14 deletions src/game/Battlegrounds/BattleGroundAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,37 +1003,46 @@ void BattleGroundAV::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/)
{
}

void BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
{
// this is wrong way to implement these things. On official it done by gameobject spell cast.
switch (trigger)
{
case 95:
case 2608:
if (source->GetTeam() != ALLIANCE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE);
else
case 2608: // Alterac Valley - Alliance Exit
// World of Warcraft Client Patch 1.7.0 (2005-09-13)
// - Characters that use the Battlemaster to enter a Battleground will
// now port back to that Battlemaster when they leave the Battleground
// for any reason.
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1
if (source->GetTeam() == ALLIANCE)
{
source->LeaveBattleground();
break;
case 2606:
if (source->GetTeam() != HORDE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE);
else
return true;
}
#endif
return false;
case 2606: // Alterac Valley - Horde Exit
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1
if (source->GetTeam() == HORDE)
{
source->LeaveBattleground();
break;
return true;
}
#endif
return false;
case 3326:
case 3327:
case 3328:
case 3329:
case 3330:
case 3331:
//source->Unmount();
break;
return true;
default:
sLog.Out(LOG_BASIC, LOG_LVL_DEBUG, "BattleGroundAV: WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
break;
}
return false;
}

void BattleGroundAV::UpdatePlayerScore(Player* source, uint32 type, uint32 value)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Battlegrounds/BattleGroundAV.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class BattleGroundAV : public BattleGround
void FillInitialWorldStates(WorldPacket& data, uint32& count) override;

void RemovePlayer(Player* plr, ObjectGuid guid) override;
void HandleAreaTrigger(Player* source, uint32 trigger) override;
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
void Reset() override;

void ResetTamedEvent(uint32 teamIdx);
Expand Down
44 changes: 26 additions & 18 deletions src/game/Battlegrounds/BattleGroundWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,11 @@ void BattleGroundWS::UpdateTeamScore(Team team)
UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, GetTeamScore(team));
}

void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
bool BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
{
// this is wrong way to implement these things. On official it done by gameobject spell cast.
if (GetStatus() != STATUS_IN_PROGRESS)
return;
return false;

//uint32 SpellId = 0;
//uint64 buff_guid = 0;
switch (trigger)
{
case 3686: // Alliance elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update().
Expand All @@ -538,29 +535,39 @@ void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
case 3708: // Horde elixir of regeneration spawn
case 3707: // Alliance elixir of berserk spawn
case 3709: // Horde elixir of berserk spawn
break;
return true;
case AREATRIGGER_ALLIANCE_FLAG_SPAWN: // Alliance Flag spawn
if (m_flagState[BG_TEAM_HORDE] && !m_flagState[BG_TEAM_ALLIANCE])
if (GetHordeFlagPickerGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
break;
return true;
case AREATRIGGER_HORDE_FLAG_SPAWN: // Horde Flag spawn
if (m_flagState[BG_TEAM_ALLIANCE] && !m_flagState[BG_TEAM_HORDE])
if (GetAllianceFlagPickerGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
break;
case 3669: // horde portal
if (source->GetTeam() != HORDE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE);
else
return true;
case 3669: // Warsong Gulch - Horde Exit
// World of Warcraft Client Patch 1.7.0 (2005-09-13)
// - Characters that use the Battlemaster to enter a Battleground will
// now port back to that Battlemaster when they leave the Battleground
// for any reason.
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1
if (source->GetTeam() == HORDE)
{
source->LeaveBattleground();
break;
case 3671: // alliance portal
if (source->GetTeam() != ALLIANCE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE);
else
return true;
}
#endif
return false;
case 3671: // Warsong Gulch - Alliance Exit
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_6_1
if (source->GetTeam() == ALLIANCE)
{
source->LeaveBattleground();
break;
return true;
}
#endif
return false;
/*case 3649: // unk1
case 3688: // unk2
case 4628: // unk3
Expand All @@ -571,6 +578,7 @@ void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
break;
}
return false;
}

bool BattleGroundWS::SetupBattleGround()
Expand Down
2 changes: 1 addition & 1 deletion src/game/Battlegrounds/BattleGroundWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class BattleGroundWS : public BattleGround
virtual void EventPlayerCapturedFlag(Player* source);

void RemovePlayer(Player* player, ObjectGuid guid);
void HandleAreaTrigger(Player* source, uint32 trigger);
bool HandleAreaTrigger(Player* source, uint32 trigger);
void HandleKillPlayer(Player* pVictim, Player* pKiller);
bool SetupBattleGround();
virtual void Reset();
Expand Down
4 changes: 2 additions & 2 deletions src/game/Handlers/MiscHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
if (pPlayer->InBattleGround())
{
if (BattleGround* bg = pPlayer->GetBattleGround())
bg->HandleAreaTrigger(pPlayer, triggerId);
return;
if (bg->HandleAreaTrigger(pPlayer, triggerId))
return;
}
if (ZoneScript* pZoneScript = pPlayer->GetZoneScript())
{
Expand Down
4 changes: 2 additions & 2 deletions src/game/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ enum MangosStrings
// = 749, not used
LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING = 750, // "Not enough players. This game will close in %u mins."
LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS = 751, // "Not enough players. This game will close in %u seconds."
LANG_BATTLEGROUND_ONLY_ALLIANCE_USE = 752, // "Only The Alliance can use that portal"
LANG_BATTLEGROUND_ONLY_HORDE_USE = 753, // "Only The Horde can use that portal"
// = 752, not used
// = 753, not used
// = 754, not used
// = 755, not used
// = 756, not used
Expand Down

0 comments on commit a9e2d97

Please sign in to comment.