Skip to content

Commit

Permalink
fix save game crash?, ref #3397
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed Mar 6, 2016
1 parent e2c7576 commit 6a58af5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
3 changes: 3 additions & 0 deletions addons/interact_menu/XEH_preInit.sqf
Expand Up @@ -4,6 +4,9 @@ ADDON = false;

#include "XEH_PREP.hpp"

GVAR(ActNamespace) = [] call CBA_fnc_createNamespace;
GVAR(ActSelfNamespace) = [] call CBA_fnc_createNamespace;

// Event handlers for all interact menu controls
DFUNC(handleMouseMovement) = {
if (GVAR(cursorKeepCentered)) then {
Expand Down
9 changes: 5 additions & 4 deletions addons/interact_menu/functions/fnc_addActionToClass.sqf
Expand Up @@ -30,10 +30,11 @@ if (_typeNum == 0) then {
[_objectType] call FUNC(compileMenuSelfAction);
};

private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
private _actionTrees = missionNamespace getVariable [_varName, []];
if((count _actionTrees) == 0) then {
missionNamespace setVariable [_varName, _actionTrees];
private _namespace = [GVAR(ActNamespace), GVAR(ActSelfNamespace)] select _typeNum;
private _actionTrees = _namespace getVariable _objectType;
if (isNil "_actionTrees") then {
_actionTrees = [];
_namespace setVariable [_objectType, _actionTrees];
};

if (_parentPath isEqualTo ["ACE_MainActions"]) then {
Expand Down
8 changes: 6 additions & 2 deletions addons/interact_menu/functions/fnc_addMainAction.sqf
Expand Up @@ -18,8 +18,12 @@

params ["_objectType", "_typeNum"];

private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
private _actionTrees = missionNamespace getVariable [_varName, []];
private _namespace = [GVAR(ActNamespace), GVAR(ActSelfNamespace)] select _typeNum;
private _actionTrees = _namespace getVariable _objectType;
if (isNil "_actionTrees") then {
_actionTrees = [];
};

private _parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode);

if (isNil {_parentNode}) then {
Expand Down
6 changes: 3 additions & 3 deletions addons/interact_menu/functions/fnc_compileMenu.sqf
Expand Up @@ -18,10 +18,10 @@ private _objectType = _target;
if (_target isEqualType objNull) then {
_objectType = typeOf _target;
};
private _actionsVarName = format [QGVAR(Act_%1), _objectType];
private _namespace = GVAR(ActNamespace);

// Exit if the action menu is already compiled for this class
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
if !(isNil {_namespace getVariable _objectType}) exitWith {};

private _recurseFnc = {
params ["_actionsCfg", "_parentDistance"];
Expand Down Expand Up @@ -104,7 +104,7 @@ private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions
TRACE_1("Building ACE_Actions",_objectType);
private _actions = [_actionsCfg, 0] call _recurseFnc;

missionNamespace setVariable [_actionsVarName, _actions];
_namespace setVariable [_objectType, _actions];

/*
[
Expand Down
6 changes: 3 additions & 3 deletions addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf
Expand Up @@ -18,10 +18,10 @@ private _objectType = _target;
if (_target isEqualType objNull) then {
_objectType = typeOf _target;
};
private _actionsVarName = format [QGVAR(SelfAct_%1), _objectType];
private _namespace = GVAR(ActSelfNamespace);

// Exit if the action menu is already compiled for this class
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
if !(isNil {_namespace getVariable _objectType}) exitWith {};


private _recurseFnc = {
Expand Down Expand Up @@ -125,4 +125,4 @@ private _actions = [
]
];

missionNamespace setVariable [_actionsVarName, _actions];
_namespace setVariable [_objectType, _actions];
14 changes: 8 additions & 6 deletions addons/interact_menu/functions/fnc_removeActionFromClass.sqf
Expand Up @@ -19,18 +19,20 @@

params ["_objectType", "_typeNum", "_fullPath"];

private ["_res","_varName","_actionTrees", "_parentNode", "_found"];
_res = _fullPath call FUNC(splitPath);
private _res = _fullPath call FUNC(splitPath);
_res params ["_parentPath", "_actionName"];

_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
_actionTrees = missionNamespace getVariable [_varName, []];
private _namespace = [GVAR(ActNamespace), GVAR(ActSelfNamespace)] select _typeNum;
private _actionTrees = _namespace getVariable _objectType;
if (isNil "_actionTrees") then {
_actionTrees = [];
};

_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
private _parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
if (isNil {_parentNode}) exitWith {};

// Iterate through children of the father
_found = false;
private _found = false;
{
if (((_x select 0) select 0) == _actionName) exitWith {
TRACE_2("Deleting Action", _forEachIndex, _x);
Expand Down
9 changes: 5 additions & 4 deletions addons/interact_menu/functions/fnc_renderActionPoints.sqf
Expand Up @@ -54,8 +54,9 @@ private _fnc_renderNearbyActions = {
} count GVAR(objectActionList);

// Iterate through base level class actions and render them if appropiate
private _actionsVarName = format [QGVAR(Act_%1), typeOf _target];
private _classActions = missionNamespace getVariable [_actionsVarName, []];
private _namespace = GVAR(ActNamespace);
private _classActions = _namespace getVariable typeOf _target;

{
private _action = _x;
// Try to render the menu
Expand Down Expand Up @@ -95,8 +96,8 @@ private _fnc_renderSelfActions = {
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];

// Iterate through base level class actions and render them if appropiate
private _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
private _classActions = missionNamespace getVariable [_actionsVarName, []];
private _namespace = GVAR(ActSelfNamespace);
private _classActions = _namespace getVariable typeOf _target;

private _pos = if !(GVAR(useCursorMenu)) then {
//Convert to ASL, add offset and then convert back to AGL (handles waves when over water)
Expand Down

2 comments on commit 6a58af5

@maxhime
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working for me, wiht a message when i reload my save : "Reinitialised : Special Keys Statistics Report"
Question: this new code has an impact on the gameplay/mod ?
Anyway Thanx You, i can save and reload my game now ! ;)

@commy2
Copy link
Contributor Author

@commy2 commy2 commented on 6a58af5 Mar 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can save and reload my game now !

Nice.

Question: this new code has an impact on the gameplay/mod ?

No gameplay changes, just slightly faster lookup times for global variables. Should not be noticable at all though.

Reinitialised : Special Keys Statistics Report

I have no idea. Never heard of that.

Please sign in to comment.