Skip to content

Commit

Permalink
Update base game classes to use new helper function
Browse files Browse the repository at this point in the history
Fixes #1417

This function was created by @Xymanek and used in Covert Infiltration after extensive investigation to ensure that it properly handles when things aren't in progress.
  • Loading branch information
Tedster59 authored and Iridar committed Dec 2, 2024
1 parent 8c6c96e commit 12e1fb5
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,20 +345,23 @@ static event UpdateDLC()
local XComGameStateHistory History;
local XComGameState NewGameState;
local XComGameState_AlienRulerManager RulerMgr;
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bUpdated;

if (class'X2Helpers_DLC_Day60'.static.IsXPackIntegrationEnabled())
{
History = `XCOMHISTORY;
StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
RulerMgr = XComGameState_AlienRulerManager(History.GetSingleGameStateObjectForClass(class'XComGameState_AlienRulerManager'));

NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Update Alien Hunters DLC");
RulerMgr = XComGameState_AlienRulerManager(NewGameState.ModifyStateObject(class'XComGameState_AlienRulerManager', RulerMgr.ObjectID));

// Don't trigger updates while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
bUpdated = RulerMgr.ActivateRulerLocations(); // Check for any new rulers getting activated, and set their timers
bUpdated = bUpdated || RulerMgr.UpdateRulerLocations();
Expand Down
18 changes: 17 additions & 1 deletion X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,20 @@ static final function array<SoldierClassAbilityType> RebuildSoldierClassAbilityT

return AbilityTypes;
}
// End Issue #815
// End Issue #815

/// HL-Docs: ref:Bugfixes; issue:1417
/// This helper function uses a more robust check to ensure the geoscape is ready for alerts.
/// This replaces functions that only check for the presence of a UIAlert screen, which can
/// result in popups in places such as Squad Select or the Black Market screen if the campaign date lines up with flight time.
static function bool GeoscapeReadyForUpdate()
{
local UIStrategyMap StrategyMap;

StrategyMap = `HQPRES.StrategyMap2D;

return
StrategyMap != none &&
StrategyMap.m_eUIState != eSMS_Flight &&
StrategyMap.Movie.Pres.ScreenStack.GetCurrentScreen() == StrategyMap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1881,12 +1881,14 @@ function bool IsFavored()
// THIS FUNCTION SHOULD RETURN TRUE IN ALL THE SAME CASES AS Update
function bool ShouldUpdate()
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;

StrategyMap = `HQPRES.StrategyMap2D;
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bMetXCom && !bSeenLocationReveal)
{
Expand All @@ -1901,14 +1903,17 @@ function bool ShouldUpdate()
// IF ADDING NEW CASES WHERE bModified = true, UPDATE FUNCTION ShouldUpdate ABOVE
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bModified;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bModified = false;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bMetXCom && !bSeenLocationReveal)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ function bool CanAffordIntelCost()
function bool Update(XComGameState NewGameState)
{
local XComGameState_HeadquartersAlien AlienHQ;
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bUpdated;
local int HoursToAdd;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bUpdated = false;

// Do not modify doom while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (class'X2StrategyGameRulesetDataStructures'.static.LessThan(DoomProjectIntervalEndTime, `STRATEGYRULES.GameTime))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,12 +606,14 @@ function CleanUpForSaleItems(XComGameState NewGameState)
// THIS FUNCTION SHOULD RETURN TRUE IN ALL THE SAME CASES AS Update
function bool ShouldUpdate( )
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;

StrategyMap = `HQPRES.StrategyMap2D;
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass( class'UIAlert' ))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
// Check if making contact is complete
if (bNeedsScan && IsScanComplete( ))
Expand All @@ -627,14 +629,17 @@ function bool ShouldUpdate( )
// IF ADDING NEW CASES WHERE bModified = true, UPDATE FUNCTION ShouldUpdate ABOVE
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bModified;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bModified = false;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
// Check if making contact is complete
if (bNeedsScan && IsScanComplete())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1544,13 +1544,17 @@ function bool DidRiskOccur(name RiskName)
function bool ShouldUpdate()
{
local XComGameState_HeadquartersXCom XComHQ;
local UIStrategyMap StrategyMap;

// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;

XComHQ = class'UIUtilities_Strategy'.static.GetXComHQ();
StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (!bCompleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ static function SetUpHavens(XComGameState StartState)
// THIS FUNCTION SHOULD RETURN TRUE IN ALL THE SAME CASES AS Update
function bool ShouldUpdate( )
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;

StrategyMap = `HQPRES.StrategyMap2D;
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass( class'UIAlert' ))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (IsScanComplete( ))
{
Expand All @@ -80,17 +82,20 @@ function bool Update(XComGameState NewGameState)
{
local XComGameState_HeadquartersXCom XComHQ;
local XComGameState_HeadquartersResistance ResHQ;
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bUpdated;
local int IntelRewardAmt;

XComHQ = class'UIUtilities_Strategy'.static.GetXComHQ();
ResHQ = class'UIUtilities_Strategy'.static.GetResistanceHQ();
StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bUpdated = false;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (IsScanComplete())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,17 @@ function name SelectNextSoldierClass()
// returns true if an internal value has changed (lots of time checks)
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bUpdated;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bUpdated = false;

// Don't trigger end of month while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (!bInactive)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ static function SetupCalendar(XComGameState StartState)
//---------------------------------------------------------------------------------------
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local int idx;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not spawn any new missions while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
// Check for mission events
for (idx = 0; idx < CurrentMissionMonth.Length; idx++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,12 +1384,14 @@ function string GetResistanceModeLabel()
// THIS FUNCTION SHOULD RETURN TRUE IN ALL THE SAME CASES AS Update
function bool ShouldUpdate()
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;

StrategyMap = `HQPRES.StrategyMap2D;
//StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bMetXCom && !bSeenFactionHQReveal)
{
Expand All @@ -1404,14 +1406,17 @@ function bool ShouldUpdate()
// IF ADDING NEW CASES WHERE bModified = true, UPDATE FUNCTION ShouldUpdate ABOVE
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bModified;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bModified = false;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bMetXCom && !bSeenFactionHQReveal)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ function XComGameState_MissionSiteAvengerDefense CreateAvengerDefenseMission(Sta
//---------------------------------------------------------------------------------------
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bModified;

bModified = false;
Expand All @@ -473,8 +474,9 @@ function bool Update(XComGameState NewGameState)
}

// Do not trigger interception while the Avenger or Skyranger are flying, or if another popup is already being presented
StrategyMap = `HQPRES.StrategyMap2D;
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
//StrategyMap = `HQPRES.StrategyMap2D;
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
// If we have hit our interception time, become visible, transport to be close to XComHQ, and start the attack
if (class'X2StrategyGameRulesetDataStructures'.static.LessThan(InterceptionTime, GetCurrentTime()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,13 @@ function BuildHavenETA(out int MinDays, out int MaxDays)
// THIS FUNCTION SHOULD RETURN TRUE IN ALL THE SAME CASES AS Update
function bool ShouldUpdate( )
{
local UIStrategyMap StrategyMap;
StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
// local UIStrategyMap StrategyMap;
// StrategyMap = `HQPRES.StrategyMap2D;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass( class'UIAlert' ))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bUpdateShortestPathsToMissions)
{
Expand Down Expand Up @@ -503,14 +505,17 @@ function bool ShouldUpdate( )
// IF ADDING NEW CASES WHERE bModified = true, UPDATE FUNCTION ShouldUpdate ABOVE
function bool Update(XComGameState NewGameState)
{
local UIStrategyMap StrategyMap;
// Issue #1417: no longer used
//local UIStrategyMap StrategyMap;
local bool bModified;

StrategyMap = `HQPRES.StrategyMap2D;
// Issue #1417: no longer used
//StrategyMap = `HQPRES.StrategyMap2D;
bModified = false;

// Do not trigger anything while the Avenger or Skyranger are flying, or if another popup is already being presented
if (StrategyMap != none && StrategyMap.m_eUIState != eSMS_Flight && !`HQPRES.ScreenStack.IsCurrentClass(class'UIAlert'))
// Issue #1417: Use a more robust check to determine if the game should trigger the update.
if (class'CHHelpers'.static.GeoscapeReadyForUpdate())
{
if (bUpdateShortestPathsToMissions)
{
Expand Down

0 comments on commit 12e1fb5

Please sign in to comment.