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

Allow mods to gracefully prevent geoscape tick #425

Closed
Xymanek opened this issue Feb 19, 2019 · 2 comments
Closed

Allow mods to gracefully prevent geoscape tick #425

Xymanek opened this issue Feb 19, 2019 · 2 comments
Labels
needs-docs Needs documentation

Comments

@Xymanek
Copy link
Member

Xymanek commented Feb 19, 2019

XGGeoscape:

event Tick( float fDeltaT )
{
	fGameTime = fDeltaT * m_fTimeScale;

	// ....
	
	// IF( PAUSED )
	if (fGameTime == 0)
	{
		UpdateUIVisualsOnly();
		return;
	}

Adding an event before if (fGameTime == 0) will allow mods to prevent the game tick. Eg. opening a screen upon entering geoscape, but only when the game is ready to tick (no other interactions are going on)

Xymanek added a commit to Xymanek/X2WOTCCommunityHighlander that referenced this issue Feb 19, 2019
@robojumper robojumper added the needs-docs Needs documentation label Jan 18, 2020
@Iridar
Copy link
Contributor

Iridar commented Jan 9, 2021

Purely out of curiosity, what are the go-to use cases for this?

Also, isn't ticking done a lot? Triggering an event for every tick is not deemed excessive?

@Xymanek
Copy link
Member Author

Xymanek commented Feb 12, 2021

CI has 2 uses for this:

  1. Opening the covert actions screen (which needs to be on top of the geospace) from the event queue in the avenger
  2. Preventing time from progressing when the game is in a "must launch infiltration" state

In both cases, nothing must happen between opening the geoscape and the screen opening on top of it. Geoscape is actually a bit of a painful opening and at least one tick will happen even if you try to instantly open another screen on top (which normally pauses the time).

Also, isn't ticking done a lot? Triggering an event for every tick is not deemed excessive?

Robojumper has done testing and triggering events with 0 listeners is extremely cheap. So subscribing to this with a listener template is indeed a bad idea, but CI doesn't do that, it uses "temporary" listener registrations only.

In hindsight, the only bad aspect is the GC thrashing with a new tuple every frame. I don't expect unreal's GC to break apart due to this (especially since the reachability path is very simple - it's either directly in a root or not reachable at all), but it could've been easily avoided using either a singleton tuple or the delegates approach. Alas, it is too late now due to BC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-docs Needs documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants