Skip to content

Commit 8f219f9

Browse files
authored
Merge pull request #1406 from Kexanone/naked-unit-fix
Add naked unit bug workaround
2 parents 0e310f7 + bcebe93 commit 8f219f9

5 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Extended_PreInit_EventHandlers {
2+
class ADDON {
3+
init = QUOTE(call COMPILE_FILE(XEH_preInit));
4+
};
5+
};

addons/network/XEH_preInit.sqf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "script_component.hpp"
2+
3+
ADDON = false;
4+
5+
#include "initSettings.sqf"
6+
7+
// Restore loadouts lost by the naked unit bug
8+
[QGVAR(validateLoadout), {
9+
params ["_unit", "_loadout"];
10+
11+
if (GVAR(loadoutValidation) > 0 && {getUnitLoadout _unit isNotEqualTo _loadout}) then {
12+
_unit setUnitLoadout _loadout;
13+
};
14+
}] call CBA_fnc_addEventHandler;
15+
16+
["CAManBase", "Local", {
17+
params ["_unit", "_local"];
18+
if !(_local) then {
19+
// Broadcast loadout to new owner if unit was once local on this machine
20+
if (GVAR(loadoutValidation) > 0 && {_unit getVariable [QGVAR(wasLocal), false]}) then {
21+
if (GVAR(loadoutValidation) == 1 && {!(_unit in playableUnits)}) exitWith {};
22+
private _loadout = getUnitLoadout _unit;
23+
[QGVAR(validateLoadout), [_unit, _loadout], _unit] call CBA_fnc_targetEvent;
24+
};
25+
};
26+
_unit setVariable [QGVAR(wasLocal), _local];
27+
}] call CBA_fnc_addClassEventHandler;
28+
29+
["CAManBase", "Init", {
30+
params ["_unit"];
31+
if (local _unit) then {
32+
_unit setVariable [QGVAR(wasLocal), true];
33+
};
34+
}] call CBA_fnc_addClassEventHandler;
35+
36+
ADDON = true;

addons/network/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ class CfgPatches {
1414
};
1515
};
1616

17+
#include "CfgEventHandlers.hpp"
1718
#include "CfgFunctions.hpp"

addons/network/initSettings.sqf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
QGVAR(loadoutValidation),
3+
"LIST",
4+
[LLSTRING(LoadoutValidation), LLSTRING(LoadoutValidationTooltip)],
5+
LSTRING(Component),
6+
[
7+
[0, 1, 2],
8+
[
9+
[LLSTRING(NeverValidate), LLSTRING(NeverValidateTooltip)],
10+
[LLSTRING(ValidatePlayableOnly), LLSTRING(ValidatePlayableOnlyTooltip)],
11+
[LLSTRING(ValidateAll), LLSTRING(ValidateAllTooltip)]
12+
],
13+
0 // Disabled by default
14+
],
15+
1 // Forced on all machines by default
16+
] call CBA_fnc_addSetting;

addons/network/stringtable.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,45 @@
1515
<Italian>Community Base Addons - Rete</Italian>
1616
<Czech>Community Base Addons - Síť</Czech>
1717
</Key>
18+
<Key ID="STR_CBA_Network_LoadoutValidation">
19+
<English>Loadout validation</English>
20+
<German>Überprüfung von Ausrüstungen</German>
21+
<French>Validation des équipements</French>
22+
</Key>
23+
<Key ID="STR_CBA_Network_LoadoutValidationTooltip">
24+
<English>Validate loadout of units. Fixes an issue where units appear naked after changing locality.</English>
25+
<German>Überprüfe die Ausrüstung von Einheiten. Korrigiert den Fehler, bei dem Einheiten nackt sind nach einer Änderung deren Lokalität.</German>
26+
<French>Valider l'équipement des unités. Correction pour l'erreur suivante: Les unités sont nues après changer la localité</French>
27+
</Key>
28+
<Key ID="STR_CBA_Network_NeverValidate">
29+
<English>Never</English>
30+
<German>Niemals</German>
31+
<French>Jamais</French>
32+
</Key>
33+
<Key ID="STR_CBA_Network_NeverValidateTooltip">
34+
<English>Never validate loadouts</English>
35+
<German>Überprüfe niemals Ausrüstungen</German>
36+
<French>Ne valider jamais des équipements</French>
37+
</Key>
38+
<Key ID="STR_CBA_Network_ValidatePlayableOnly">
39+
<English>Playable units only</English>
40+
<German>Nur spielbare Einheiten</German>
41+
<French>Seulement les unités jouables</French>
42+
</Key>
43+
<Key ID="STR_CBA_Network_ValidatePlayableOnlyTooltip">
44+
<English>Validate only loadout of playable units</English>
45+
<German>Überprüfe nur die Ausrüstung von spielbaren Einheiten</German>
46+
<French>Valider seulement l'équipements des unités jouables</French>
47+
</Key>
48+
<Key ID="STR_CBA_Network_ValidateAll">
49+
<English>All units</English>
50+
<German>Alle Einheiten</German>
51+
<French>Toutes les unités</French>
52+
</Key>
53+
<Key ID="STR_CBA_Network_ValidateAllTooltip">
54+
<English>Validate loadout of all units</English>
55+
<German>Überprüfe die Ausrüstungen von allen Einheiten</German>
56+
<French>Valider l'équipement de toutes les unités</French>
57+
</Key>
1858
</Package>
1959
</Project>

0 commit comments

Comments
 (0)