Skip to content

Conversation

@copyrite
Copy link
Contributor

@copyrite copyrite commented Nov 1, 2025

Fixes #1529

@copyrite copyrite marked this pull request as ready for review November 1, 2025 19:15
@copyrite
Copy link
Contributor Author

copyrite commented Nov 1, 2025

Ran a test where I had the following in a for-loop inside XComGameState_HeadquartersXCom.SetUpHeadquarters:

class'XComGameState_RegionLink'.static.CreateAllLinks(StartState);
class'XComGameState_RegionLink'.static.RandomizeLinks(StartState);

//Pick which region the HQ will start in
foreach StartState.IterateByClassType(class'XComGameState_WorldRegion', IterateRegion)
{
	if (default.PossibleStartingRegions.Find(IterateRegion.GetMyTemplateName()) != INDEX_NONE)
	{
		AllStartingRegions.AddItem(IterateRegion);
	}

	// Try to find an optimal starting region
	if(IterateRegion.CanBeStartingRegion(StartState))
	{
		BestStartingRegions.AddItem(IterateRegion);
	}
}
if(BestStartingRegions.Length > 0)
{
	RandomIndex = `SYNC_RAND_STATIC(BestStartingRegions.Length);
	BaseRegion = BestStartingRegions[RandomIndex];
}
else
{
	RandomIndex = `SYNC_RAND_STATIC(AllStartingRegions.Length);
	BaseRegion = AllStartingRegions[RandomIndex];
}
`Log("BaseRegion is" @ string(BaseRegion.m_TemplateName));

Additionally, an event listener that returned true only for Eastern Europe, false for others. Also an event listener that allowed non-continent links, but I'm not sure if that was necessary.

Without the fix, BaseRegion was always Eastern Europe's neighboring region; with the fix, 100% of the time Eastern Europe. I think that's more than enough confirmation that the fix is effective.

@Tedster59 Tedster59 added this to the 1.31.0 milestone Nov 2, 2025
@Tedster59 Tedster59 merged commit 00b038f into X2CommunityCore:master Dec 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XComGameState_WorldRegion.CanBeStartingRegion calls event with wrong region

2 participants