Skip to content

Commit

Permalink
Merge pull request #1406 from Kexanone/naked-unit-fix
Browse files Browse the repository at this point in the history
Add naked unit bug workaround
  • Loading branch information
PabstMirror committed Mar 3, 2021
2 parents 0e310f7 + bcebe93 commit 8f219f9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/network/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
36 changes: 36 additions & 0 deletions addons/network/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "script_component.hpp"

ADDON = false;

#include "initSettings.sqf"

// Restore loadouts lost by the naked unit bug
[QGVAR(validateLoadout), {
params ["_unit", "_loadout"];

if (GVAR(loadoutValidation) > 0 && {getUnitLoadout _unit isNotEqualTo _loadout}) then {
_unit setUnitLoadout _loadout;
};
}] call CBA_fnc_addEventHandler;

["CAManBase", "Local", {
params ["_unit", "_local"];
if !(_local) then {
// Broadcast loadout to new owner if unit was once local on this machine
if (GVAR(loadoutValidation) > 0 && {_unit getVariable [QGVAR(wasLocal), false]}) then {
if (GVAR(loadoutValidation) == 1 && {!(_unit in playableUnits)}) exitWith {};
private _loadout = getUnitLoadout _unit;
[QGVAR(validateLoadout), [_unit, _loadout], _unit] call CBA_fnc_targetEvent;
};
};
_unit setVariable [QGVAR(wasLocal), _local];
}] call CBA_fnc_addClassEventHandler;

["CAManBase", "Init", {
params ["_unit"];
if (local _unit) then {
_unit setVariable [QGVAR(wasLocal), true];
};
}] call CBA_fnc_addClassEventHandler;

ADDON = true;
1 change: 1 addition & 0 deletions addons/network/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class CfgPatches {
};
};

#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"
16 changes: 16 additions & 0 deletions addons/network/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
QGVAR(loadoutValidation),
"LIST",
[LLSTRING(LoadoutValidation), LLSTRING(LoadoutValidationTooltip)],
LSTRING(Component),
[
[0, 1, 2],
[
[LLSTRING(NeverValidate), LLSTRING(NeverValidateTooltip)],
[LLSTRING(ValidatePlayableOnly), LLSTRING(ValidatePlayableOnlyTooltip)],
[LLSTRING(ValidateAll), LLSTRING(ValidateAllTooltip)]
],
0 // Disabled by default
],
1 // Forced on all machines by default
] call CBA_fnc_addSetting;
40 changes: 40 additions & 0 deletions addons/network/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,45 @@
<Italian>Community Base Addons - Rete</Italian>
<Czech>Community Base Addons - Síť</Czech>
</Key>
<Key ID="STR_CBA_Network_LoadoutValidation">
<English>Loadout validation</English>
<German>Überprüfung von Ausrüstungen</German>
<French>Validation des équipements</French>
</Key>
<Key ID="STR_CBA_Network_LoadoutValidationTooltip">
<English>Validate loadout of units. Fixes an issue where units appear naked after changing locality.</English>
<German>Überprüfe die Ausrüstung von Einheiten. Korrigiert den Fehler, bei dem Einheiten nackt sind nach einer Änderung deren Lokalität.</German>
<French>Valider l'équipement des unités. Correction pour l'erreur suivante: Les unités sont nues après changer la localité</French>
</Key>
<Key ID="STR_CBA_Network_NeverValidate">
<English>Never</English>
<German>Niemals</German>
<French>Jamais</French>
</Key>
<Key ID="STR_CBA_Network_NeverValidateTooltip">
<English>Never validate loadouts</English>
<German>Überprüfe niemals Ausrüstungen</German>
<French>Ne valider jamais des équipements</French>
</Key>
<Key ID="STR_CBA_Network_ValidatePlayableOnly">
<English>Playable units only</English>
<German>Nur spielbare Einheiten</German>
<French>Seulement les unités jouables</French>
</Key>
<Key ID="STR_CBA_Network_ValidatePlayableOnlyTooltip">
<English>Validate only loadout of playable units</English>
<German>Überprüfe nur die Ausrüstung von spielbaren Einheiten</German>
<French>Valider seulement l'équipements des unités jouables</French>
</Key>
<Key ID="STR_CBA_Network_ValidateAll">
<English>All units</English>
<German>Alle Einheiten</German>
<French>Toutes les unités</French>
</Key>
<Key ID="STR_CBA_Network_ValidateAllTooltip">
<English>Validate loadout of all units</English>
<German>Überprüfe die Ausrüstungen von allen Einheiten</German>
<French>Valider l'équipement de toutes les unités</French>
</Key>
</Package>
</Project>

0 comments on commit 8f219f9

Please sign in to comment.