kellerkompanie / kellerkompanie-mods

This project contains modifications for the Arma 3 game, custom tailored towards the needs of the Kellerkompanie community (https://kellerkompanie.com/). Not all parts are self-written. Where indicated the content does not belong to us, but rather to the original authors. The rest may be used by anyone in any way.
MIT License
4 stars 1 forks source link

Medic Settings on Loadout spawn wrong #74

Closed Schwaggot closed 5 years ago

Schwaggot commented 5 years ago

Somehow the wrong settings are applied on loadout and Mission briefing generation.

Schwaggot commented 5 years ago

Official answer by commy2

They are synchronized. But the global variables are set one frame after postInit. "ace_medical_enableAdvancedWounds" call CBA_settings_fnc_get You could use this instead.

This is function get: https://github.com/CBATeam/CBA_A3/blob/master/addons/settings/fnc_get.sqf

This is where the settings are "refreshed" one frame after postInit: https://github.com/CBATeam/CBA_A3/blob/master/addons/settings/XEH_postInit.sqf#L3-L18 (Event refreshAllSettings which is just refreshSetting over all settings.)

This is where the settings are applied to mission namespace variables (event refreshSetting): https://github.com/CBATeam/CBA_A3/blob/master/addons/settings/XEH_preInit.sqf#L46-L63

Note how it uses function get and then sets the global.This operates on the theory that all variables (incl. mission settings) are synchronized (one frame after) postInit. get should also report the correct thing at postInit. This one frame delay is to catch settings defined themselves in postInit in scripts that due to loading order may be executed before cba_settings postInit.

The mission namespace variables have always been secondary to me. refreshSetting is called when you create the setting (init function, addSetting function), but since the server namespace is not synronized in preInit, because of how multiplayer works, they have their client/local value. new messages All variables sent at preInit from the server are guaranteed to have arrived at postInit (due to the implementation in initFunctions.sqf). This is why I refresh all settings at postInit.

Schwaggot commented 5 years ago

Current solution does not work in all cases, yesterday several people had the problem again.