Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new override event for starting region eligibility hook #1304

Conversation

Tedster59
Copy link
Contributor

Fixes issue #1303 using option #1 of an override event to allow mods to override the behavior of this function.

@Tedster59 Tedster59 force-pushed the 1303-improved-geoscape-creation branch from e5e5a02 to 9a3d6ab Compare February 25, 2024 01:17
/// NewGameState: none
/// ```
//
// **NOTE** This function is public so that it can be called from `XComGameState_WorldRegion`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still make it final.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Tedster59 Tedster59 force-pushed the 1303-improved-geoscape-creation branch from 54b90dd to fdb2876 Compare February 25, 2024 01:28
@Tedster59 Tedster59 force-pushed the 1303-improved-geoscape-creation branch 2 times, most recently from b3d556e to cbb869a Compare February 25, 2024 01:32
@@ -228,10 +228,13 @@ static function RandomizeLinks(XComGameState StartState)
}

//---------------------------------------------------------------------------------------
static function bool IsEligibleStartRegion(XComGameState StartState, XComGameState_WorldRegion RegionState)
static final function bool IsEligibleStartRegion(XComGameState StartState, XComGameState_WorldRegion RegionState)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't clear enough. You can't change the function definition of a function that already exists, especially one that's not a private Highlander API. I meant making the TriggerOverrideEligibleStartingRegion() final.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


// Start Issue #1303
/// HL-Docs: feature:OverrideEligibleStartingRegion; issue:1303; tags:strategy
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a third /? Or just remove the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Fix review comments

Fix doc errors

Implement new override event for starting region eligibility hook

Fixes issue X2CommunityCore#1303

Mark function final
Copy link
Contributor

Pull request modifies event listener templates

Difference (click to expand)
diff --git a/target/CHL_Event_Compiletest.uc b/target/CHL_Event_Compiletest.uc
index 119ff6b..03d8f1b 100644
--- a/target/CHL_Event_Compiletest.uc
+++ b/target/CHL_Event_Compiletest.uc
@@ -506,6 +506,24 @@ static function EventListenerReturn OnOverrideDisableReinforcementsFlare(Object
 	return ELR_NoInterrupt;
 }
 
+static function EventListenerReturn OnOverrideEligibleStartingRegion(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
+{
+	local XComGameState_WorldRegion PotentialStartRegion;
+	local XComLWTuple Tuple;
+	local bool ValidStartRegion;
+
+	PotentialStartRegion = XComGameState_WorldRegion(EventSource);
+	Tuple = XComLWTuple(EventData);
+
+	ValidStartRegion = Tuple.Data[0].b;
+
+	// Your code here
+
+	Tuple.Data[0].b = ValidStartRegion;
+
+	return ELR_NoInterrupt;
+}
+
 static function EventListenerReturn OnOverrideEncounterZoneAnchorPoint(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
 {
 	local XComGameState_AIGroup AIGroup;
What? (click to expand)

The Highlander documentation tool generates event listener examples from event specifications.
This comment contains the modifications that would be made to the copy-pasteable event listeners in documentation, for PR authors and reviewers to inspect for correctness, and will automatically be kept up-to-date whenever this PR is updated.

// public API. Backwards compatibility is not guaranteed.

static final function bool TriggerOverrideEligibleStartingRegion(
XComGameState StartState,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason you have StartState as a function argument but don't use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the cargo cult

Fix review comments

Fix doc errors

Implement new override event for starting region eligibility hook

Fixes issue X2CommunityCore#1303

Mark function final
@Iridar Iridar modified the milestones: 1.27.1, 1.28.0 Feb 25, 2024
@Iridar Iridar added the ready-for-merge the pull request was reviewed and is ready to be merged. label Feb 25, 2024
@Tedster59
Copy link
Contributor Author

Closing this and re-opening with a different branch in #1309 to fix github commit issues

@Tedster59 Tedster59 closed this Feb 27, 2024
@Iridar Iridar removed this from the 1.28.0 milestone Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge the pull request was reviewed and is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants