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

delay initPost eventhandler of objects created mid mission #628

Merged
merged 1 commit into from
Apr 8, 2017

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Apr 6, 2017

This "solves" this issue:

["B_MRAP_01_F", "init", {(_this select 0) setVariable ["test1", true, true]}] call CBA_fnc_addClassEventHandler;
_v = "B_MRAP_01_F" createVehicle position player;
_v setVariable ["test2", true, true];
missionNamespace setVariable ["v", _v, true];

On local machine: test1 and test2 are defined
On remote machine: test1 undefined, test2 defined
-> setVariable public doesn't work inside the init eventhandler
We have initPost, which solves this for editor placed objects (init artificially delayed until postInit eventhandler), but it fails for objects created mid mission, which is a pretty nasty inconsistency.
I plan to fix this in the next CBA update by delaying initPost one frame artifically if postInit already happened.

@commy2 commy2 added this to the 3.3 milestone Apr 6, 2017
@Killswitch00 Killswitch00 merged commit dcf6cf5 into master Apr 8, 2017
@commy2 commy2 deleted the delay-initPost-after-postInit branch April 8, 2017 11:27
@PabstMirror
Copy link
Contributor

@commy2 - We got the following error a few times on a normal mission

  Error Reserved variable in expression
File z\ace\addons\interact_menu\functions\fnc_compileMenu.sqf, line 117

Can reproduce with

x3 = "B_Heli_Transport_01_F" createVehicle [0,0,0];
deleteVehicle x3;

ACE throws an error because the object is null (so typeOf = "" and the setVar errors out)
Can easily fix in ace, but I'm wondering if we want a more generic solution in CBA with an isNull check?
Something like:

[{
    if (isNull _this) exitWith {};
    {
        [_this] call _x;
    } forEach (_this getVariable QGVAR(initPost));
}, _this] call CBA_fnc_execNextFrame;

@commy2
Copy link
Contributor Author

commy2 commented Apr 24, 2017

On the one hand, you expect the eventhandler to run when an object is created, on the other, it's not useful at all with objNull.
If this check is added, it should also be added here:
https://github.com/CBATeam/CBA_A3/blob/master/addons/xeh/fnc_postInit_unscheduled.sqf#L36

@commy2
Copy link
Contributor Author

commy2 commented Apr 24, 2017

Nvm, not really needed, as null getVariable reports nil and therefore the forEach is ignored. The isNull check hence isn't needed here either.
I like this for doing only one execNextFrame per object instead of per initPost eventhandler, so it should be done for optimization alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants