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

Convert Apollo to use unitLoadout #272

Merged
merged 4 commits into from
Feb 17, 2017
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
1 change: 0 additions & 1 deletion addons/apollo/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ PREP(moduleInit);
PREP(playerLoadClient);
PREP(playerSaveClient);
PREP(playerSingletonSave);
PREP(startPlayerLoadClient);
PREP(vehicleLoad);
PREP(vehicleSaveServer);
PREP(vehicleSingletonLoad);
Expand Down
7 changes: 3 additions & 4 deletions addons/apollo/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@ if (!hasInterface) exitWith {};
// Load player after Respawn EH
[QGVAR(reinitializePlayer), {
params ["_player", "_registeredDeath"];
TRACE_1("Registered Death",_this);
TRACE_1("Reinitialization",_this);

// Load player
if (_registeredDeath == "done") then {
// Prevent saving during reinitialization
_player setVariable [QGVAR(lastSavedTime), CBA_missionTime];
// Reinitialize client
[_player, "respawned"] call FUNC(startPlayerLoadClient);
[_player, "respawned"] call FUNC(playerLoadClient);
} else {
ERROR("Connection terminated - Death failed to register!");
[localize LSTRING(RespawnReinitialization)] call FUNC(endMissionError);
};
}] call CBA_fnc_addEventHandler;

// Load player
[player, "loaded"] call FUNC(startPlayerLoadClient);
[player, "loaded"] call FUNC(playerLoadClient);
}] call CBA_fnc_addEventHandler;
10 changes: 7 additions & 3 deletions addons/apollo/functions/fnc_playerLoadClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Arguments:
* 0: Player <OBJECT>
* 1: Load type ("loaded" or "respawned") <STRING>
* 1: Load Type ("loaded" or "respawned") <STRING>
*
* Return Value:
* None
Expand All @@ -14,22 +14,26 @@
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

params ["_player", "_loadType"];

_player allowDamage false;

TRACE_1("Loading Client",_player);
private _success = false;

// Don't load when UID is "_SP_PLAYER_" (singleplayer/editor)
if (getPlayerUID _player == "_SP_PLAYER_") exitWith {false};

private _loadData = "ApolloClient" callExtension format ["%1%2/%3", "loadPlayer", getPlayerUID _player, GVAR(isDebug)];

if (_loadData == "loaded") then {
private _updateInfo = true;
while {_updateInfo} do {
private _loadData = "ApolloClient" callExtension "get";
//TRACE_1("Load Data",_loadData);
//TRACE_1("Load Data",_loadData);

if (_loadData == "error") then {
// Bad things happened, stop executing
Expand Down Expand Up @@ -64,6 +68,6 @@ if (_success) then {

INFO_1("Client %1 successfully.",_loadType);
} else {
ERROR_2("Player not successfully loaded (Name: %1 - UID: %2)!",profileName,getPlayerUID _player);
ERROR_2("Player load failed (Name: %1 - UID: %2)!",profileName,getPlayerUID _player);
["Your connection has been terminated - Error during Chronos loading!"] call FUNC(endMissionError);
};
96 changes: 20 additions & 76 deletions addons/apollo/functions/fnc_playerSingletonSave.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* Arguments:
* 0: Player <OBJECT>
* 1: Player UID <STRING>
* 2: Validate/Save <STRING>
* 2: Type ("save" or "validate") <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "36182159512951925", "save"] call tac_apollo_fnc_playerSingletonSave
* [player, "36182159512951925", "save", "loaded"] call tac_apollo_fnc_playerSingletonSave
*
* Public: No
*/
Expand All @@ -23,91 +23,36 @@ params ["_player", "_uid", "_type"];
private _name = name _player;
private _playerPos = getPosASL _player;
private _playerDir = getDir _player;
private _playerHeadgear = headgear _player;
private _playerGoggles = goggles _player;

// Uniform
private _uniform = uniform _player;
private _uniformCargo = [];
private _uniformMagazines = [];
private _uniformWeapons = [];
// Loadout
private _loadout = getUnitLoadout _player;

if (_uniform != "") then {
private _uniformContainer = uniformContainer _player;
_uniformCargo append (itemCargo _uniformContainer);
_uniformMagazines append (getMagazineCargo _uniformContainer);
_uniformWeapons append (weaponsItems _uniformContainer);
// Remove "ItemRadioAcreFlagged"
if ((_loadout select 9) select 2 == "ItemRadioAcreFlagged") then {
(_loadout select 9) set [2, ""];
};

// Vest
private _vest = vest _player;
private _vestCargo = [];
private _vestMagazines = [];
private _vestWeapons = [];

if (_vest != "") then {
private _vestContainer = vestContainer _player;
_vestCargo append (itemCargo _vestContainer);
_vestMagazines append (getMagazineCargo _vestContainer);
_vestWeapons append (weaponsItems _vestContainer);
};

// Backpack
private _backpack = backpack _player;
private _backpackCargo = [];
private _backpackMagazines = [];
private _backpackWeapons = [];

if (_backpack != "") then {
private _backpackContainer = backpackContainer _player;
_backpackCargo append (itemCargo _backpackContainer);
_backpackMagazines append (getMagazineCargo _backpackContainer);
_backpackWeapons append (weaponsItems _backpackContainer);
// Set ACRE base classes
private _replaceRadioAcre = {
if ([_this select 0] call acre_api_fnc_isRadio) then {
_this set [0, [_this select 0] call acre_api_fnc_getBaseRadio];
};
};

// Inventory
private _inventory = assignedItems _player;

// Weapons
private _primaryWeapon = primaryWeapon _player;
private _secondaryWeapon = secondaryWeapon _player;
private _handgunWeapon = handgunWeapon _player;

private _weapons = [];
_weapons pushBack _primaryWeapon;
_weapons pushBack _secondaryWeapon;
_weapons pushBack _handgunWeapon;

// Primary Weapon Attachments
private _primaryWepAttachments = [];
if (_primaryWeapon != "" ) then {
_primaryWepAttachments append (primaryWeaponItems _player);
if !((_loadout select 3) isEqualTo []) then {
{_x call _replaceRadioAcre} forEach ((_loadout select 3) select 1); // Uniform items
};

// Secondary Weapon Attachments
private _secondaryWepAttachments = [];
if (_secondaryWeapon != "" ) then {
_secondaryWepAttachments append (secondaryWeaponItems _player);
if !((_loadout select 4) isEqualTo []) then {
{_x call _replaceRadioAcre} forEach ((_loadout select 4) select 1); // Vest items
};

// Handgun Attachments
private _handgunAttachments = [];
if (_handgunWeapon != "" ) then {
_handgunAttachments append (handgunItems _player);
if !((_loadout select 5) isEqualTo []) then {
{_x call _replaceRadioAcre} forEach ((_loadout select 5) select 1); // Backpack items
};

// Weapon Magazines
private _weaponMagazines = [];
_weaponMagazines pushBack (primaryWeaponMagazine _player);
_weaponMagazines pushBack (secondaryWeaponMagazine _player);
_weaponMagazines pushBack (handgunMagazine _player);

// Other
private _inVehicle = (vehicle _player) != _player;
private _alive = alive _player;
private _selectedWeapon = currentWeapon _player;
private _currentStance = animationState _player;
private _fatigue = getFatigue _player;

// Variables
private _playerVariables = [];
Expand All @@ -117,13 +62,12 @@ private _playerVariables = [];
};
} forEach (allVariables _playerObject);*/

private _serverReply = ["storeInfantry", _type, _uid, _name, _playerPos, _playerDir, _playerHeadgear, _playerGoggles, _uniform, _uniformCargo, _uniformMagazines, _vest, _vestCargo, _vestMagazines, _backpack, _backpackCargo, _backpackMagazines, _inventory, _weapons, _primaryWepAttachments, _secondaryWepAttachments, _handgunAttachments , _weaponMagazines, _inVehicle, _alive, _selectedWeapon, _currentStance, _fatigue, _uniformWeapons, _vestWeapons, _backpackWeapons, _playerVariables] call FUNC(invokeJavaMethod);
private _serverReply = ["storeInfantry", _type, _uid, _name, _playerPos, _playerDir, _loadout, _inVehicle, _alive, _selectedWeapon, _currentStance, _playerVariables] call FUNC(invokeJavaMethod);

TRACE_2("Singleton Save",_type,_serverReply);

if (_type == "validate" && {_serverReply == "success"}) then {
if (_type == "validate" && {_serverReply == "success"}) exitWith {
// No simulation toggling due to possible lag breaking correct position and direction setting
_player hideObjectGlobal false;
["infantryLoaded", _uid] call FUNC(invokeJavaMethod);
};

Expand Down
27 changes: 0 additions & 27 deletions addons/apollo/functions/fnc_startPlayerLoadClient.sqf

This file was deleted.