Core/WorldStates: Migrate battleground HolidayWorldState to new system

Port From (https://github.com/TrinityCore/TrinityCore/commit/020166649dd5afb94dddbfcc990d4bb51e231ab1)
This commit is contained in:
hondacrx
2022-07-13 17:35:10 -04:00
parent 9421aeee98
commit 6825419b88
5 changed files with 39 additions and 46 deletions
-14
View File
@@ -717,20 +717,6 @@ namespace Game.Entities
return true; return true;
} }
void SendBGWeekendWorldStates()
{
foreach (var bl in CliDB.BattlemasterListStorage.Values)
{
if (bl.HolidayWorldState != 0)
{
if (Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bl.Id))
SendUpdateWorldState(bl.HolidayWorldState, 1);
else
SendUpdateWorldState(bl.HolidayWorldState, 0);
}
}
}
public void SendPvpRewards() public void SendPvpRewards()
{ {
//WorldPacket packet(SMSG_REQUEST_PVP_REWARDS_RESPONSE, 24); //WorldPacket packet(SMSG_REQUEST_PVP_REWARDS_RESPONSE, 24);
-1
View File
@@ -2932,7 +2932,6 @@ namespace Game.Entities
packet.AddState(3901, previousArenaSeason); packet.AddState(3901, previousArenaSeason);
SendPacket(packet); SendPacket(packet);
SendBGWeekendWorldStates();
} }
public long GetBarberShopCost(List<ChrCustomizationChoice> newCustomizations) public long GetBarberShopCost(List<ChrCustomizationChoice> newCustomizations)
+4 -9
View File
@@ -1477,15 +1477,10 @@ namespace Game
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id); BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id);
if (bgTypeId != BattlegroundTypeId.None) if (bgTypeId != BattlegroundTypeId.None)
{ {
BattlemasterListRecord bl = CliDB.BattlemasterListStorage.LookupByKey(bgTypeId); var bl = CliDB.BattlemasterListStorage.LookupByKey(Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id));
if (bl != null && bl.HolidayWorldState != 0) if (bl != null)
{ if (bl.HolidayWorldState != 0)
UpdateWorldState worldstate = new(); Global.WorldStateMgr.SetValue(bl.HolidayWorldState, Activate ? 1 : 0, false, null);
worldstate.VariableID = bl.HolidayWorldState;
worldstate.Value = Activate ? 1 : 0;
//worldstate.Hidden = false;
Global.WorldMgr.SendGlobalMessage(worldstate);
}
} }
} }
} }
+2 -2
View File
@@ -154,7 +154,7 @@ namespace Game
if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty()) if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty())
return _realmWorldStateValues.LookupByKey(worldStateId); return _realmWorldStateValues.LookupByKey(worldStateId);
if (!worldStateTemplate.MapIds.Contains(map.GetId())) if (map == null || !worldStateTemplate.MapIds.Contains(map.GetId()))
return 0; return 0;
return map.GetWorldStateValue(worldStateId); return map.GetWorldStateValue(worldStateId);
@@ -197,7 +197,7 @@ namespace Game
return; return;
} }
if (!worldStateTemplate.MapIds.Contains(map.GetId())) if (map == null || !worldStateTemplate.MapIds.Contains(map.GetId()))
return; return;
map.SetWorldStateValue(worldStateId, value, hidden); map.SetWorldStateValue(worldStateId, value, hidden);
@@ -0,0 +1,13 @@
DELETE FROM `world_state` WHERE `ID` IN (1941,1942,1943,2851,3695,4273,5360,5361,6306,6436,7671);
INSERT INTO `world_state` (`ID`,`DefaultValue`,`MapIDs`,`AreaIDs`,`ScriptName`,`Comment`) VALUES
(1941,0,NULL,NULL,'','Battleground Call to Arms - Alterac Valley'),
(1942,0,NULL,NULL,'','Battleground Call to Arms - Warsong Gulch'),
(1943,0,NULL,NULL,'','Battleground Call to Arms - Arathi Basin'),
(2851,0,NULL,NULL,'','Battleground Call to Arms - Eye of the Storm'),
(3695,0,NULL,NULL,'','Battleground Call to Arms - Strand of the Ancients'),
(4273,0,NULL,NULL,'','Battleground Call to Arms - Isle of Conquest'),
(5360,0,NULL,NULL,'','Battleground Call to Arms - The Battle for Gilneas'),
(5361,0,NULL,NULL,'','Battleground Call to Arms - Twin Peaks'),
(6306,0,NULL,NULL,'','Battleground Call to Arms - Temple of Kotmogu'),
(6436,0,NULL,NULL,'','Battleground Call to Arms - Silvershard Mines'),
(7671,0,NULL,NULL,'','Battleground Call to Arms - Deepwind Gorge (Legacy)');