From d35f58a46d5c47271a6084b9a16eef8fb2b4d0db Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 21 Dec 2022 22:05:48 +0100 Subject: [PATCH] Core/WorldStates: Migrate pvp season worldstates to new system --- sql/updates/world/4.3.4/2022_12_21_03_world.sql | 7 +++++++ src/server/game/Entities/Player/Player.cpp | 4 ---- src/server/game/Miscellaneous/SharedDefines.h | 3 +++ src/server/game/Server/Packets/WorldStatePackets.h | 2 +- src/server/game/World/World.cpp | 9 +++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 sql/updates/world/4.3.4/2022_12_21_03_world.sql diff --git a/sql/updates/world/4.3.4/2022_12_21_03_world.sql b/sql/updates/world/4.3.4/2022_12_21_03_world.sql new file mode 100644 index 0000000000..136c8958bb --- /dev/null +++ b/sql/updates/world/4.3.4/2022_12_21_03_world.sql @@ -0,0 +1,7 @@ +UPDATE `world_state` SET `Comment`='Battlegrounds - Horde bases' WHERE `ID`=1778; +UPDATE `world_state` SET `Comment`='Battlegrounds - Alliance bases' WHERE `ID`=1779; + +DELETE FROM `world_state` WHERE `ID` IN (3191,3901); +INSERT INTO `world_state` (`ID`,`DefaultValue`,`MapIDs`,`AreaIDs`,`ScriptName`,`Comment`) VALUES +(3191,0,NULL,NULL,'','PvpSeason - Current season ID'), +(3901,0,NULL,NULL,'','PvpSeason - Previous season ID'); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a671b8b869..d2e696a610 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -8774,10 +8774,6 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) packet.Worldstates.emplace_back(2260, 0); // 5 packet.Worldstates.emplace_back(2259, 0); // 6 - packet.Worldstates.emplace_back(3191, int32(sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS) ? sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) : 0)); // 7 Current Season - Arena season in progress - // 0 - End of season - packet.Worldstates.emplace_back(3901, int32(sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))); // 8 PreviousSeason - SendDirectMessage(packet.Write()); } diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 28de75ee34..ee6f1885db 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -4359,6 +4359,9 @@ enum AreaId : uint32 enum WorldState : uint32 { + WS_CURRENT_PVP_SEASON_ID = 3191, + WS_PREVIOUS_PVP_SEASON_ID = 3901, + WS_BATTLEFIELD_WG_VEHICLE_H = 3490, WS_BATTLEFIELD_WG_MAX_VEHICLE_H = 3491, WS_BATTLEFIELD_WG_VEHICLE_A = 3680, diff --git a/src/server/game/Server/Packets/WorldStatePackets.h b/src/server/game/Server/Packets/WorldStatePackets.h index 570e89abf8..ada0c982a2 100644 --- a/src/server/game/Server/Packets/WorldStatePackets.h +++ b/src/server/game/Server/Packets/WorldStatePackets.h @@ -33,7 +33,7 @@ namespace WorldPackets int32 Value; }; - class InitWorldStates final : public ServerPacket + class TC_GAME_API InitWorldStates final : public ServerPacket { public: InitWorldStates(); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 6132369257..25e4c23102 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1281,6 +1281,12 @@ void World::LoadConfigSettings(bool reload) m_float_configs[CONFIG_ARENA_LOSE_RATING_MODIFIER] = sConfigMgr->GetFloatDefault("Arena.ArenaLoseRatingModifier", 24.0f); m_float_configs[CONFIG_ARENA_MATCHMAKER_RATING_MODIFIER] = sConfigMgr->GetFloatDefault("Arena.ArenaMatchmakerRatingModifier", 24.0f); + if (reload) + { + sWorldStateMgr->SetValue(WS_CURRENT_PVP_SEASON_ID, getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS) ? getIntConfig(CONFIG_ARENA_SEASON_ID) : 0, false, nullptr); + sWorldStateMgr->SetValue(WS_PREVIOUS_PVP_SEASON_ID, getIntConfig(CONFIG_ARENA_SEASON_ID) - getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS), false, nullptr); + } + m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfigMgr->GetBoolDefault("OffhandCheckAtSpellUnlearn", true); m_int_configs[CONFIG_CREATURE_PICKPOCKET_REFILL] = sConfigMgr->GetIntDefault("Creature.PickPocketRefillDelay", 10 * MINUTE); @@ -2129,6 +2135,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading World States..."); // must be loaded before battleground, outdoor PvP and conditions LoadWorldStates(); + sWorldStateMgr->SetValue(WS_CURRENT_PVP_SEASON_ID, getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS) ? getIntConfig(CONFIG_ARENA_SEASON_ID) : 0, false, nullptr); + sWorldStateMgr->SetValue(WS_PREVIOUS_PVP_SEASON_ID, getIntConfig(CONFIG_ARENA_SEASON_ID) - getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS), false, nullptr); + TC_LOG_INFO("server.loading", "Loading World State templates..."); sWorldStateMgr->LoadFromDB();