server/addons/db/functions/fnc_saveGameState.sqf
Jacob Schmidt 257a62acc0 fix: Rename companyGenerals to companyShareholders
This commit renames the `companyGenerals` variable to `companyShareholders` to better reflect its intended purpose and usage within the codebase. The change affects the following files:

-   `addons/main/config.cpp`: Renames the `companyGenerals` config entry to `companyShareholders`.
-   `addons/init/functions/fnc_handleServerState.sqf`: Updates the variable name used when saving company state.
-   `addons/db/functions/fnc_loadGameState.sqf`: Updates the variable name used when loading company state.
-   `addons/db/functions/fnc_saveGameState.sqf`: Updates the variable name used when saving company state.
-   `addons/init/functions/fnc_handleServerStateLoad.sqf`: Updates the variable name used when loading company state from the server.

This change ensures consistency and clarity in the codebase, making it easier to understand and maintain. The `companyGarageUnlocks` variable was also removed from the save/load functions as it was not being used.
2025-04-05 14:24:46 -05:00

70 lines
2.4 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: forge_server_db_fnc_saveGameState
* Author: J. Schmidt
*
* Description:
* Collects and saves the current game state to mission or profile namespace
*
* Arguments:
* 0: _nameSpace - Namespace to save to (mission, profile) <STRING> (default: mission)
*
* Return Value:
* Success <BOOL>
*/
params [["_nameSpace", "mission", [""]]];
if (isNil "companyFunds") then { companyFunds = 0 };
if (isNil "companyRating") then { companyRating = 0 };
if (isNil "companyShareholders") then { companyShareholders = [] };
if (isNil "companyGarageUnlocks") then { companyGarageUnlocks = [] };
private _companyState = createHashMapFromArray [
["key", "CompanyState"],
["funds", companyFunds],
["rating", companyRating],
["operations", companyShareholders]
];
if (_nameSpace == "mission") then {
["companyStore", "CompanyState", _companyState] call FUNC(saveToMission);
} else {
["companyStore", "CompanyState", _companyState] call FUNC(saveToProfile);
};
{
if (alive _x) then {
private _playerState = createHashMapFromArray [
["key", getPlayerUID _x],
["armory_unlocks", GETVAR(_x,FORGE_Armory_Unlocks,_default_armory_unlocks)],
["garage_unlocks", GETVAR(_x,FORGE_Garage_Unlocks,_default_garage_unlocks)],
["locker", GETVAR(_x,FORGE_Locker,[])],
["garage", GETVAR(_x,FORGE_Garage,[])],
["cash", GETVAR(_x,FORGE_Cash,0)],
["bank", GETVAR(_x,FORGE_Bank,0)],
["number", GETVAR(_x,FORGE_Phone_Number,"unknown")],
["email", GETVAR(_x,FORGE_Email,"unknown@spearnet.mil")],
["paygrade", GETVAR(_x,FORGE_Paygrade,"E1")],
["reputation", rating _x],
["loadout", getUnitLoadout _x],
["holster", GETVAR(_x,FORGE_Holster_Weapon,true)],
["position", getPosASLVisual _x],
["direction", getDirVisual _x]
];
if (isNull objectParent _x) then {
_playerState set ["currentWeapon", currentMuzzle _x];
_playerState set ["stance", stance _x];
};
if (_nameSpace == "mission") then {
["playerStore", getPlayerUID _x, _playerState] call FUNC(saveToMission);
} else {
["playerStore", getPlayerUID _x, _playerState] call FUNC(saveToProfile);
};
};
} forEach playableUnits;
true