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

Always re-run preInit on mission load/new #685

Merged
merged 2 commits into from
May 20, 2017
Merged

Conversation

PabstMirror
Copy link
Contributor

Should fix #684

Seems like in 1.70, missionnamespace alwayse gets cleared out
(which seems good, just causes some problems)


add3DENEventHandler ["OnMissionNew", _fnc_preInitMissionConfig];
add3DENEventHandler ["OnMissionLoad", _fnc_preInitMissionConfig];
add3DENEventHandler ["OnMissionNew", {[] call CBA_fnc_preInit}];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going from one terrain to another

"OnMissionNew"
XEH: missionNamespace processed [false]
[83008,343.676,0,"XEH: PreInit started. v3.3.1.170504"]
[83008,344.812,0,"XEH: PreInit finished."]
"OnTerrainNew"
XEH: missionNamespace processed [false]
83008,346.107,0,"XEH: PreInit started. v3.3.1.170504"]

both events happen on the same frame, but missionNamespace is wiped between them
OnTerrainNew seems to be last, so if we don't add the event, nothing will be defined

Copy link
Contributor

Choose a reason for hiding this comment

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

OnTerrainNew is still needed as it fires after OnMissionLoad and the missionNamespace get's wiped inbetween them for whatever reason.

@PabstMirror
Copy link
Contributor Author

PabstMirror commented May 17, 2017

  • Major problem is this doesn't work when loading of a mission fails.
    e.g. You load a mission that has requiredAddons you aren't running.
    Mission namespace gets wiped, but no onMissionLoad event.

  • Minor problem, we run preInit more than we have to, worst case seems to be going from one map to loading a mission on another map, preInit runs 3 times:

"OnMissionNew"
XEH: missionNamespace processed [false]
"OnTerrainNew"
XEH: missionNamespace processed [false]
"OnMissionLoad"
XEH: missionNamespace processed [false]

@commy2
Copy link
Contributor

commy2 commented May 17, 2017

To the 2nd point, doesn't really matter imo. preInit is mainly copying over stuff from ui namespace via PREP.

1st one. Why would loading a mission fail?

@PabstMirror
Copy link
Contributor Author

Warning Message: mission.sqm/Mission/Entities/Item2/Entities/Item0.type: Vehicle class CUP_O_TK_Crew no longer exists

image

@commy2
Copy link
Contributor

commy2 commented May 17, 2017

And that opens an empty mission on the same map as selected, right?

@PabstMirror
Copy link
Contributor Author

yea

@commy2
Copy link
Contributor

commy2 commented May 17, 2017

I don't like how convoluted this has become. All 3 events are needed, but they all fire, because BI keeps wiping the namespace.

@PabstMirror
Copy link
Contributor Author

This would catch the mission load failed problem, could possibly replace all other events?

params ["_display"];
private _fnc_watchDog = {
    if (!ISPROCESSED(missionNamespace)) then {
        [] call CBA_fnc_preInit;
    };
};
_display displayAddEventHandler ["MouseMoving", _fnc_watchDog];
_display displayAddEventHandler ["MouseHolding", _fnc_watchDog];

@commy2
Copy link
Contributor

commy2 commented May 17, 2017

Yeah, I like this more.

@PabstMirror
Copy link
Contributor Author

This also fixes the multiple running of preInit

} forEach (missionConfigFile call CBA_fnc_compileEventHandlers);
private _fnc_watchDog = {
if (!ISPROCESSED(missionNamespace)) then {
diag_log text format ["XEH: missionNamespace processed [%1]", ISPROCESSED(missionNamespace)];
Copy link
Contributor

Choose a reason for hiding this comment

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

ISPROCESSED(missionNamespace) is always false, because that is the condition of the if.

@commy2
Copy link
Contributor

commy2 commented May 17, 2017

Works and fixes #684.

@commy2 commy2 added this to the 3.4 milestone May 17, 2017
@Killswitch00 Killswitch00 merged commit 829349b into master May 20, 2017
@Killswitch00 Killswitch00 deleted the rerunPreInit branch May 20, 2017 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CBA settings in editor dont work since 3.3.1
3 participants