Core/WorldStates: Allow setting "hidden" field of SMSG_UPDATE_WORLD_STATE
Port From (https://github.com/TrinityCore/TrinityCore/commit/de26cafbbe1b355b69ec871f4fee0704a3ef29a5)
This commit is contained in:
@@ -601,7 +601,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public void DoUpdateWorldState(uint worldStateId, int value)
|
public void DoUpdateWorldState(uint worldStateId, int value)
|
||||||
{
|
{
|
||||||
Global.WorldStateMgr.SetValue(worldStateId, value, instance);
|
Global.WorldStateMgr.SetValue(worldStateId, value, false, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send Notify to all players in instance
|
// Send Notify to all players in instance
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public Dictionary<int, int> GetWorldStateValues() { return _worldStateValues; }
|
public Dictionary<int, int> GetWorldStateValues() { return _worldStateValues; }
|
||||||
|
|
||||||
public void SetWorldStateValue(int worldStateId, int value)
|
public void SetWorldStateValue(int worldStateId, int value, bool hidden)
|
||||||
{
|
{
|
||||||
int oldValue = _worldStateValues.LookupByKey(worldStateId);
|
int oldValue = _worldStateValues.LookupByKey(worldStateId);
|
||||||
_worldStateValues[worldStateId] = value;
|
_worldStateValues[worldStateId] = value;
|
||||||
@@ -597,6 +597,7 @@ namespace Game.Maps
|
|||||||
UpdateWorldState updateWorldState = new();
|
UpdateWorldState updateWorldState = new();
|
||||||
updateWorldState.VariableID = (uint)worldStateId;
|
updateWorldState.VariableID = (uint)worldStateId;
|
||||||
updateWorldState.Value = value;
|
updateWorldState.Value = value;
|
||||||
|
updateWorldState.Hidden = hidden;
|
||||||
updateWorldState.Write();
|
updateWorldState.Write();
|
||||||
|
|
||||||
foreach (var player in GetPlayers())
|
foreach (var player in GetPlayers())
|
||||||
|
|||||||
@@ -896,8 +896,8 @@ namespace Game
|
|||||||
LoadWorldStates();
|
LoadWorldStates();
|
||||||
|
|
||||||
// TODO: this is temporary until custom world states are purged from old world state saved values
|
// TODO: this is temporary until custom world states are purged from old world state saved values
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, (int)GetWorldState(WorldStates.WarModeHordeBuffValue), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, (int)GetWorldState(WorldStates.WarModeHordeBuffValue), false, null);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, (int)GetWorldState(WorldStates.WarModeAllianceBuffValue), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, (int)GetWorldState(WorldStates.WarModeAllianceBuffValue), false, null);
|
||||||
|
|
||||||
Global.ObjectMgr.LoadPhases();
|
Global.ObjectMgr.LoadPhases();
|
||||||
|
|
||||||
@@ -1258,8 +1258,8 @@ namespace Game
|
|||||||
|
|
||||||
public void SetForcedWarModeFactionBalanceState(int team, int reward = 0)
|
public void SetForcedWarModeFactionBalanceState(int team, int reward = 0)
|
||||||
{
|
{
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (team == TeamId.Alliance ? reward : 0), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (team == TeamId.Alliance ? reward : 0), false, null);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (team == TeamId.Horde ? reward : 0), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (team == TeamId.Horde ? reward : 0), false, null);
|
||||||
|
|
||||||
// save to db
|
// save to db
|
||||||
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
||||||
@@ -2533,8 +2533,8 @@ namespace Game
|
|||||||
outnumberedFactionReward = 5;
|
outnumberedFactionReward = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (dominantFaction == TeamId.Alliance ? outnumberedFactionReward : 0), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeHordeBuffValue, 10 + (dominantFaction == TeamId.Alliance ? outnumberedFactionReward : 0), false, null);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (dominantFaction == TeamId.Horde ? outnumberedFactionReward : 0), null);
|
Global.WorldStateMgr.SetValue(WorldStates.WarModeAllianceBuffValue, 10 + (dominantFaction == TeamId.Horde ? outnumberedFactionReward : 0), false, null);
|
||||||
|
|
||||||
// save to db
|
// save to db
|
||||||
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
SetWorldState(WorldStates.WarModeHordeBuffValue, Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, null));
|
||||||
|
|||||||
@@ -160,17 +160,17 @@ namespace Game
|
|||||||
return map.GetWorldStateValue(worldStateId);
|
return map.GetWorldStateValue(worldStateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue(WorldStates worldStateId, int value, Map map)
|
public void SetValue(WorldStates worldStateId, int value, bool hidden, Map map)
|
||||||
{
|
{
|
||||||
SetValue((int)worldStateId, value, map);
|
SetValue((int)worldStateId, value, hidden, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue(uint worldStateId, int value, Map map)
|
public void SetValue(uint worldStateId, int value, bool hidden, Map map)
|
||||||
{
|
{
|
||||||
SetValue((int)worldStateId, value, map);
|
SetValue((int)worldStateId, value, hidden, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue(int worldStateId, int value, Map map)
|
public void SetValue(int worldStateId, int value, bool hidden, Map map)
|
||||||
{
|
{
|
||||||
WorldStateTemplate worldStateTemplate = GetWorldStateTemplate(worldStateId);
|
WorldStateTemplate worldStateTemplate = GetWorldStateTemplate(worldStateId);
|
||||||
if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty())
|
if (worldStateTemplate == null || worldStateTemplate.MapIds.Empty())
|
||||||
@@ -185,6 +185,7 @@ namespace Game
|
|||||||
UpdateWorldState updateWorldState = new();
|
UpdateWorldState updateWorldState = new();
|
||||||
updateWorldState.VariableID = (uint)worldStateId;
|
updateWorldState.VariableID = (uint)worldStateId;
|
||||||
updateWorldState.Value = value;
|
updateWorldState.Value = value;
|
||||||
|
updateWorldState.Hidden = hidden;
|
||||||
Global.WorldMgr.SendGlobalMessage(updateWorldState);
|
Global.WorldMgr.SendGlobalMessage(updateWorldState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ namespace Game
|
|||||||
if (!worldStateTemplate.MapIds.Contains(map.GetId()))
|
if (!worldStateTemplate.MapIds.Contains(map.GetId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
map.SetWorldStateValue(worldStateId, value);
|
map.SetWorldStateValue(worldStateId, value, hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<int, int> GetInitialWorldStatesForMap(Map map)
|
public Dictionary<int, int> GetInitialWorldStatesForMap(Map map)
|
||||||
|
|||||||
@@ -82,14 +82,14 @@ namespace Game.BattleFields
|
|||||||
|
|
||||||
void loadSavedWorldState(WorldStates id)
|
void loadSavedWorldState(WorldStates id)
|
||||||
{
|
{
|
||||||
Global.WorldStateMgr.SetValue(id, (int)Global.WorldMgr.GetWorldState(id), m_Map);
|
Global.WorldStateMgr.SetValue(id, (int)Global.WorldMgr.GetWorldState(id), false, m_Map);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSavedWorldState(WorldStates.BattlefieldWgShowTimeNextBattle);
|
loadSavedWorldState(WorldStates.BattlefieldWgShowTimeNextBattle);
|
||||||
loadSavedWorldState(WorldStates.BattlefieldWgDefender);
|
loadSavedWorldState(WorldStates.BattlefieldWgDefender);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgAttacker, (int)GetAttackerTeam(), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgAttacker, (int)GetAttackerTeam(), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), m_Map);
|
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[1], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), m_Map);
|
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[1], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), false, m_Map);
|
||||||
loadSavedWorldState(WorldStates.BattlefieldWgAttackedA);
|
loadSavedWorldState(WorldStates.BattlefieldWgAttackedA);
|
||||||
loadSavedWorldState(WorldStates.BattlefieldWgDefendedA);
|
loadSavedWorldState(WorldStates.BattlefieldWgDefendedA);
|
||||||
loadSavedWorldState(WorldStates.BattlefieldWgAttackedH);
|
loadSavedWorldState(WorldStates.BattlefieldWgAttackedH);
|
||||||
@@ -210,11 +210,11 @@ namespace Game.BattleFields
|
|||||||
else
|
else
|
||||||
Log.outError(LogFilter.Battlefield, "WG: Failed to spawn titan relic.");
|
Log.outError(LogFilter.Battlefield, "WG: Failed to spawn titan relic.");
|
||||||
|
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgAttacker, (int)GetAttackerTeam(), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgAttacker, (int)GetAttackerTeam(), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgDefender, (int)GetDefenderTeam(), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgDefender, (int)GetDefenderTeam(), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeNextBattle, 0, m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeNextBattle, 0, false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeBattleEnd, 1, m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeBattleEnd, 1, false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), m_Map);
|
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), false, m_Map);
|
||||||
|
|
||||||
// Update tower visibility and update faction
|
// Update tower visibility and update faction
|
||||||
foreach (var guid in CanonList)
|
foreach (var guid in CanonList)
|
||||||
@@ -316,12 +316,12 @@ namespace Game.BattleFields
|
|||||||
else
|
else
|
||||||
worldStateId = GetDefenderTeam() == TeamId.Horde ? WorldStates.BattlefieldWgAttackedH : WorldStates.BattlefieldWgAttackedA;
|
worldStateId = GetDefenderTeam() == TeamId.Horde ? WorldStates.BattlefieldWgAttackedH : WorldStates.BattlefieldWgAttackedA;
|
||||||
|
|
||||||
Global.WorldStateMgr.SetValue(worldStateId, Global.WorldStateMgr.GetValue((int)worldStateId, m_Map) + 1, m_Map);
|
Global.WorldStateMgr.SetValue(worldStateId, Global.WorldStateMgr.GetValue((int)worldStateId, m_Map) + 1, false, m_Map);
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeNextBattle, 1, m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeNextBattle, 1, false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeBattleEnd, 0, m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgShowTimeBattleEnd, 0, false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[1], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), m_Map);
|
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[1], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), false, m_Map);
|
||||||
|
|
||||||
// Remove turret
|
// Remove turret
|
||||||
foreach (var guid in CanonList)
|
foreach (var guid in CanonList)
|
||||||
@@ -841,7 +841,7 @@ namespace Game.BattleFields
|
|||||||
else
|
else
|
||||||
m_Timer -= 600000;
|
m_Timer -= 600000;
|
||||||
|
|
||||||
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), m_Map);
|
Global.WorldStateMgr.SetValue(WGConst.ClockWorldState[0], (int)(GameTime.GetGameTime() + m_Timer / Time.InMilliseconds), false, m_Map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Keep tower
|
else // Keep tower
|
||||||
@@ -903,10 +903,10 @@ namespace Game.BattleFields
|
|||||||
// Update vehicle count WorldState to player
|
// Update vehicle count WorldState to player
|
||||||
void UpdateVehicleCountWG()
|
void UpdateVehicleCountWG()
|
||||||
{
|
{
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgVehicleH, (int)GetData(WGData.VehicleH), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgVehicleH, (int)GetData(WGData.VehicleH), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgMaxVehicleH, (int)GetData(WGData.MaxVehicleH), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgMaxVehicleH, (int)GetData(WGData.MaxVehicleH), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgVehicleA, (int)GetData(WGData.VehicleA), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgVehicleA, (int)GetData(WGData.VehicleA), false, m_Map);
|
||||||
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgMaxVehicleA, (int)GetData(WGData.MaxVehicleA), m_Map);
|
Global.WorldStateMgr.SetValue(WorldStates.BattlefieldWgMaxVehicleA, (int)GetData(WGData.MaxVehicleA), false, m_Map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTenacity()
|
void UpdateTenacity()
|
||||||
@@ -1080,7 +1080,7 @@ namespace Game.BattleFields
|
|||||||
|
|
||||||
// Update worldstate
|
// Update worldstate
|
||||||
_state = WGGameObjectState.AllianceIntact - ((int)_teamControl * 3);
|
_state = WGGameObjectState.AllianceIntact - ((int)_teamControl * 3);
|
||||||
Global.WorldStateMgr.SetValue(_worldState, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_worldState, (int)_state, false, _wg.GetMap());
|
||||||
}
|
}
|
||||||
UpdateCreatureAndGo();
|
UpdateCreatureAndGo();
|
||||||
build.SetFaction(WGConst.WintergraspFaction[_teamControl]);
|
build.SetFaction(WGConst.WintergraspFaction[_teamControl]);
|
||||||
@@ -1106,7 +1106,7 @@ namespace Game.BattleFields
|
|||||||
{
|
{
|
||||||
// Update worldstate
|
// Update worldstate
|
||||||
_state = WGGameObjectState.AllianceDamage - ((int)_teamControl * 3);
|
_state = WGGameObjectState.AllianceDamage - ((int)_teamControl * 3);
|
||||||
Global.WorldStateMgr.SetValue(_worldState, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_worldState, (int)_state, false, _wg.GetMap());
|
||||||
|
|
||||||
// Send warning message
|
// Send warning message
|
||||||
if (_staticTowerInfo != null) // tower damage + name
|
if (_staticTowerInfo != null) // tower damage + name
|
||||||
@@ -1137,7 +1137,7 @@ namespace Game.BattleFields
|
|||||||
{
|
{
|
||||||
// Update worldstate
|
// Update worldstate
|
||||||
_state = WGGameObjectState.AllianceDestroy - ((int)_teamControl * 3);
|
_state = WGGameObjectState.AllianceDestroy - ((int)_teamControl * 3);
|
||||||
Global.WorldStateMgr.SetValue(_worldState, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_worldState, (int)_state, false, _wg.GetMap());
|
||||||
|
|
||||||
// Warn players
|
// Warn players
|
||||||
if (_staticTowerInfo != null)
|
if (_staticTowerInfo != null)
|
||||||
@@ -1194,7 +1194,7 @@ namespace Game.BattleFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
_state = (WGGameObjectState)Global.WorldMgr.GetWorldState(_worldState);
|
_state = (WGGameObjectState)Global.WorldMgr.GetWorldState(_worldState);
|
||||||
Global.WorldStateMgr.SetValue(_worldState, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_worldState, (int)_state, false, _wg.GetMap());
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
case WGGameObjectState.NeutralIntact:
|
case WGGameObjectState.NeutralIntact:
|
||||||
@@ -1505,7 +1505,7 @@ namespace Game.BattleFields
|
|||||||
{
|
{
|
||||||
// Updating worldstate
|
// Updating worldstate
|
||||||
_state = WGGameObjectState.AllianceIntact;
|
_state = WGGameObjectState.AllianceIntact;
|
||||||
Global.WorldStateMgr.SetValue(_staticInfo.WorldStateId, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_staticInfo.WorldStateId, (int)_state, false, _wg.GetMap());
|
||||||
|
|
||||||
// Warning message
|
// Warning message
|
||||||
if (!init)
|
if (!init)
|
||||||
@@ -1525,7 +1525,7 @@ namespace Game.BattleFields
|
|||||||
{
|
{
|
||||||
// Update worldstate
|
// Update worldstate
|
||||||
_state = WGGameObjectState.HordeIntact;
|
_state = WGGameObjectState.HordeIntact;
|
||||||
Global.WorldStateMgr.SetValue(_staticInfo.WorldStateId, (int)_state, _wg.GetMap());
|
Global.WorldStateMgr.SetValue(_staticInfo.WorldStateId, (int)_state, false, _wg.GetMap());
|
||||||
|
|
||||||
// Warning message
|
// Warning message
|
||||||
if (!init)
|
if (!init)
|
||||||
|
|||||||
Reference in New Issue
Block a user