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

Add naked unit bug workaround #1406

Merged
merged 21 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Kexanone marked this conversation as resolved.
Show resolved Hide resolved

["CAManBase", "Local", {
Kexanone marked this conversation as resolved.
Show resolved Hide resolved
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;
};
Kexanone marked this conversation as resolved.
Show resolved Hide resolved
};
_unit setVariable [QGVAR(wasLocal), _local];
}] call CBA_fnc_addClassEventHandler;

["CAManBase", "Init", {
params ["_unit"];
if (local _unit) then {
_unit setVariable [QGVAR(wasLocal), true];
};
commy2 marked this conversation as resolved.
Show resolved Hide resolved
}] 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>