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

Armory - Fix player DB connection check and move initialization of module #103

Merged
merged 2 commits into from
Sep 26, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/armory/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "script_component.hpp"

GVAR(initialized) = false;
[QGVAR(updateArsenal), FUNC(updateArsenal)] call CBA_fnc_addEventHandler;

TRACE_2("", isDedicated, GVAR(allowPlayerDBConnection));

if (isDedicated || GVAR(allowPlayerDBConnection)) then {
if (isDedicated || (isServer && GVAR(allowPlayerDBConnection))) then {

private _dbConnected = ["armory", "armory.ini"] call DB_CONNECT;
if (isNil "_dbConnected" || !(_dbConnected select 0)) exitWith {
Expand Down Expand Up @@ -34,6 +33,7 @@ if (isDedicated || GVAR(allowPlayerDBConnection)) then {
};
}] call CBA_fnc_addEventhandler;

LOG("Armory initialized");
GVAR(initialized) = true;
publicVariable QGVAR(initialized);
};
Expand Down
1 change: 1 addition & 0 deletions addons/armory/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

GVAR(initialized) = false;
#include "initSettings.hpp"

ADDON = true;
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_createEquipment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (_editors isEqualType "") then {
};

CHECK(!GVAR(initialized) || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo ""));
CHECK(!isDedicated && !GVAR(allowPlayerDBConnection));
CHECK(!isDedicated && !(isServer && GVAR(allowPlayerDBConnection)));

[GVAR(sessionID), "insertEquipment", _equipmentName, _editors] call DB_SET;

Expand Down
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_initEquipment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ params [["_equipmentName", "", [""]]];
TRACE_1("", _equipmentName);

CHECKRET(!GVAR(initialized) || _equipmentName isEqualTo "",false);
CHECKRET(!isDedicated && !GVAR(allowPlayerDBConnection),false);
CHECKRET(!isDedicated && !(isServer && GVAR(allowPlayerDBConnection)),false);
CHECKRET(_equipmentName in GVAR(equipmentInitialized),true);

private _equipmentInfo = [GVAR(sessionID), "getEquipmentInfo", _equipmentName] call DB_GET;
Expand Down
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_updateArsenal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TRACE_3("", _equipmentName, _status, _argsSuccessfullyParsed);

CHECK(!GVAR(initialized) || !_params);

if (isDedicated || GVAR(allowPlayerDBConnection)) then {
if (isDedicated || (isServer && GVAR(allowPlayerDBConnection))) then {
private _equipmentArray = GVAR(equipment) getVariable [_equipmentName, []];
private _equipmentID = _equipmentArray param [2, 0];

Expand Down
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_updateBackpack.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
private _params = params [["_equipmentName", "", [""]], ["_name", "", [""]], ["_oldName", "", [""]]];

CHECK(!GVAR(initialized) || !_params);
CHECK(!isDedicated && !GVAR(allowPlayerDBConnection));
CHECK(!isDedicated && !(isServer && GVAR(allowPlayerDBConnection)));

(GVAR(equipment) getVariable [_equipmentName, []]) params ["", "_backpackNamespace", "", "_equipmentID"];
_backpackNamespace getVariable [_name, []] params ["", "_idc", "_class", "_items"];
Expand Down
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_updateEditors.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private _checkEditors = false;
} count _editors;

CHECK(!GVAR(initialized) || !_params || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo "") || _checkEditors);
CHECK(!isDedicated && !GVAR(allowPlayerDBConnection));
CHECK(!isDedicated && !(isServer && GVAR(allowPlayerDBConnection)));

private _equipmentArray = GVAR(equipment) getVariable [_equipmentName, []];
private _equipmentID = _equipmentArray param [3, 0];
Expand Down
2 changes: 1 addition & 1 deletion addons/armory/functions/fnc_updateLoadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_name", "", [""]], ["_oldName", "", [""]]];

CHECK(!GVAR(initialized) || !_argsSuccessfullyParsed);
CHECK(!isDedicated && !GVAR(allowPlayerDBConnection));
CHECK(!isDedicated && !(isServer && GVAR(allowPlayerDBConnection)));

(GVAR(equipment) getVariable [_equipmentName, []]) params ["_loadoutNamespace", "", "", "_equipmentID"];
_loadoutNamespace getVariable [_name, []] params ["", "_idc", "_loadout", "_ace_medic", "_ace_engineer"];
Expand Down