diff --git a/sql/updates/world/4.3.4/2022_12_29_02_world.sql b/sql/updates/world/4.3.4/2022_12_29_02_world.sql new file mode 100644 index 0000000000..b5c733b17c --- /dev/null +++ b/sql/updates/world/4.3.4/2022_12_29_02_world.sql @@ -0,0 +1,4 @@ +DELETE FROM `world_state` WHERE `ID` IN (4485,4486); +INSERT INTO `world_state` (`ID`, `DefaultValue`, `MapIDs`, `ScriptName`, `Comment`) VALUES +(4485, 0, '-1', '', 'Instances - Generic - Team In Instance - Alliance'), +(4486, 0, '-1', '', 'Instances - Generic - Team In Instance - Horde'); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b7dfa9d9c9..ebe68d0348 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2585,7 +2585,7 @@ template TC_GAME_API void Map::RemoveFromMap(AreaTrigger*, bool); InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, TeamId InstanceTeam) : Map(id, expiry, InstanceId, SpawnMode), m_resetAfterUnload(false), m_unloadWhenEmpty(false), - i_data(nullptr), i_script_id(0), i_script_team(InstanceTeam) + i_data(nullptr), i_script_id(0) { //lets initialize visibility distance for dungeons InstanceMap::InitVisibilityDistance(); @@ -2593,6 +2593,9 @@ InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 Spaw // the timer is started by default, and stopped when the first player joins // this make sure it gets unloaded if for some reason no player joins m_unloadTimer = std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); + + sWorldStateMgr->SetValue(WS_TEAM_IN_INSTANCE_ALLIANCE, InstanceTeam == TEAM_ALLIANCE, false, this); + sWorldStateMgr->SetValue(WS_TEAM_IN_INSTANCE_HORDE, InstanceTeam == TEAM_HORDE, false, this); } InstanceMap::~InstanceMap() @@ -3048,6 +3051,15 @@ uint32 InstanceMap::GetMaxResetDelay() const return mapDiff ? mapDiff->resetTime : 0; } +TeamId InstanceMap::GetTeamIdInInstance() const +{ + if (sWorldStateMgr->GetValue(WS_TEAM_IN_INSTANCE_ALLIANCE, this)) + return TEAM_ALLIANCE; + if (sWorldStateMgr->GetValue(WS_TEAM_IN_INSTANCE_HORDE, this)) + return TEAM_HORDE; + return TEAM_NEUTRAL; +} + /* ******* Battleground Instance Maps ******* */ BattlegroundMap::BattlegroundMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 spawnMode) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 382ab5fc29..f39652b422 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -785,8 +785,8 @@ class TC_GAME_API InstanceMap : public Map bool HasPermBoundPlayers() const; uint32 GetMaxPlayers() const; uint32 GetMaxResetDelay() const; - TeamId GetTeamIdInInstance() const { return i_script_team; } - Team GetTeamInInstance() const { return i_script_team == TEAM_ALLIANCE ? ALLIANCE : HORDE; } + TeamId GetTeamIdInInstance() const; + Team GetTeamInInstance() const { return GetTeamIdInInstance() == TEAM_ALLIANCE ? ALLIANCE : HORDE; } virtual void InitVisibilityDistance() override; private: @@ -794,7 +794,6 @@ class TC_GAME_API InstanceMap : public Map bool m_unloadWhenEmpty; InstanceScript* i_data; uint32 i_script_id; - TeamId i_script_team; }; class TC_GAME_API BattlegroundMap : public Map diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 174206c1c2..098d8d1be4 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -4362,6 +4362,9 @@ enum WorldState : uint32 WS_CURRENT_PVP_SEASON_ID = 3191, WS_PREVIOUS_PVP_SEASON_ID = 3901, + WS_TEAM_IN_INSTANCE_ALLIANCE = 4485, + WS_TEAM_IN_INSTANCE_HORDE = 4486, + WS_BATTLEFIELD_WG_VEHICLE_H = 3490, WS_BATTLEFIELD_WG_MAX_VEHICLE_H = 3491, WS_BATTLEFIELD_WG_VEHICLE_A = 3680,