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

Events during campaign setup are "lost" regarding listener templates #869

Closed
Xymanek opened this issue May 22, 2020 · 1 comment · Fixed by #928
Closed

Events during campaign setup are "lost" regarding listener templates #869

Xymanek opened this issue May 22, 2020 · 1 comment · Fixed by #928

Comments

@Xymanek
Copy link
Member

Xymanek commented May 22, 2020

When a campaign is first launched, the initial set of state creation is done in the shell map. Shell has no listener templates (see #297) and as such, mods cannot react to the events (hooks) triggered during that phase. Below are the events that get triggered when using just CHL (based on CI's latest development version, 3c3bdd5):

UnitRandomizedStats
OverrideClipSize
OverrideRandomizeAppearance
OverrideHasHeavyWeapon
OverrideItemMinEquipped
OverrideHasGrenadePocket
NewCrewNotification
UnitRankUp
OverrideAddChosenTacticalTagsToMission
OverrideScienceScore
OverrideCurrentDoom
SquaddieItemStateApplied

Source behind generating this list: 5fc965c
Full output + parser: https://gist.github.com/Xymanek/b8ac7021900d17ba417d2f7759151525
Note that the list above potentially does not include all events triggered, in case some events are triggered in response to other events (I had to practically disable all listeners to investigate)

An easy solution would be to register strategy listener templates before starting the process, since these are mostly strategy events. Downside is that the listeners might not expect to be called in not-ready-campaign state and might not expect to be called while a start state is opened.

An opt-in solution would be adding RegisterInStrategySetup to CHEventListenerTemplate; obviously that would require mod authors to manually mark their listeners, so some bugs resulting from the above behaviour might remain.

cc @Musashi1584 @pledbrook since I know some of these events are yours

@Musashi1584
Copy link
Contributor

i support the RegisterInStrategySetup solution since its the probably the most bc friendly way and would be consistent with the current implementation of register in strategy and register in tactical.
afaik the current limitation did not had any negative consequences on the events i created and used (at least i haven't actively encountered any bugs caused by this). Anyhow i think this is something that can be relevant for certain events and it should be addressed in any solution space of #297

@Musashi1584 Musashi1584 modified the milestone: 1.22.0 Jun 1, 2020
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jan 7, 2021
This change adds an extra `RegisterInCampaignStart` boolean to CHL event
listener templates (on top of the existing `RegisterInTactical` and
`RegisterInStrategy` ones). Listeners registered for campaign start will
now receive events that are fired during campaign initialization, which
strategy listeners don't receive.

Resolves X2CommunityCore#869.
pledbrook added a commit to long-war-2/X2WOTCCommunityHighlander that referenced this issue Jan 7, 2021
This change adds an extra `RegisterInCampaignStart` boolean to CHL event
listener templates (on top of the existing `RegisterInTactical` and
`RegisterInStrategy` ones). Listeners registered for campaign start will
now receive events that are fired during campaign initialization, which
strategy listeners don't receive.

Resolves X2CommunityCore#869.
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 a pull request may close this issue.

2 participants