Interaction Menu - fix a crash when loading savegames (#7115)

* fix a crash when loading savegames

* fix a variable name

* optimize

* Put CAManBase actions into seperate bucket

* Apply suggestions from code review

Co-Authored-By: commy2 <commy-2@gmx.de>

* Fast exit for All

* CaManBase

* can't skip mans
This commit is contained in:
commy2 2019-08-02 03:52:20 +02:00 committed by PabstMirror
parent 66f62bb1a2
commit 0fd442451f
5 changed files with 53 additions and 16 deletions

View File

@ -74,4 +74,38 @@ GVAR(lastTimeSearchedActions) = -1000;
// Init zeus menu
[] call FUNC(compileMenuZeus);
// Handle addActionToClass with Inheritance flag set (CAManBase actions are seperated for speed)
GVAR(inheritedActionsAll) = [];
GVAR(inheritedClassesAll) = [];
GVAR(inheritedActionsMan) = [];
GVAR(inheritedClassesMan) = [];
["All", "InitPost", {
BEGIN_COUNTER(InitPost);
params ["_object"];
private _type = typeOf _object;
if (GVAR(inheritedClassesAll) pushBackUnique _type == -1) exitWith { END_COUNTER(InitPost); };
{
_x params ["_objectType", "_typeNum", "_parentPath", "_action"];
if (_object isKindOf _objectType) then {
[_type, _typeNum, _parentPath, _action] call FUNC(addActionToClass);
};
} forEach GVAR(inheritedActionsAll);
END_COUNTER(InitPost);
}] call CBA_fnc_addClassEventHandler;
["CAManBase", "InitPost", {
BEGIN_COUNTER(InitPost);
params ["_object"];
private _type = typeOf _object;
if (GVAR(inheritedClassesMan) pushBackUnique _type == -1) exitWith { END_COUNTER(InitPost); };
{
_x params ["_typeNum", "_parentPath", "_action"];
[_type, _typeNum, _parentPath, _action] call FUNC(addActionToClass);
} forEach GVAR(inheritedActionsMan);
END_COUNTER(InitPost);
}] call CBA_fnc_addClassEventHandler;
ADDON = true;

View File

@ -25,21 +25,24 @@ if (!params [["_objectType", "", [""]], ["_typeNum", 0, [0]], ["_parentPath", []
ERROR("Bad Params");
[]
};
TRACE_4("params",_objectType,_typeNum,_parentPath,_action);
TRACE_4("addActionToClass",_objectType,_typeNum,_parentPath,_action);
if (param [4, false, [false]]) exitwith {
if (isNil QGVAR(inheritedActions)) then {GVAR(inheritedActions) = [];};
private _index = GVAR(inheritedActions) pushBack [[], _typeNum, _parentPath, _action];
private _initEH = compile format ['
params ["_object"];
private _typeOf = typeOf _object;
(GVAR(inheritedActions) select %1) params ["_addedClasses", "_typeNum", "_parentPath", "_action"];
if (_typeOf in _addedClasses) exitWith {};
_addedClasses pushBack _typeOf;
[_typeOf, _typeNum, _parentPath, _action] call FUNC(addActionToClass);
', _index];
TRACE_2("Added inheritable action",_objectType,_index);
[_objectType, "init", _initEH, true, [], true] call CBA_fnc_addClassEventHandler;
BEGIN_COUNTER(addAction);
if (_objectType == "CAManBase") then {
GVAR(inheritedActionsMan) pushBack [_typeNum, _parentPath, _action];
{
[_x, _typeNum, _parentPath, _action] call FUNC(addActionToClass);
} forEach GVAR(inheritedClassesMan);
} else {
GVAR(inheritedActionsAll) pushBack [_objectType, _typeNum, _parentPath, _action];
{
if (_x isKindOf _objectType) then {
[_x, _typeNum, _parentPath, _action] call FUNC(addActionToClass);
};
} forEach GVAR(inheritedClassesAll);
};
END_COUNTER(addAction);
// Return the full path
(_parentPath + [_action select 0])

View File

@ -122,7 +122,7 @@ private _actions = [_actionsCfg, 0] call _recurseFnc;
// ace_interaction_fnc_addPassengerAction expects ACE_MainActions to be first
// Other mods can change the order that configs are added, so we should verify this now and resort if needed
if (_objectType isKindOf "CaManBase") then {
if (_objectType isKindOf "CAManBase") then {
if ((((_actions select 0) select 0) select 0) != "ACE_MainActions") then {
INFO_1("ACE_MainActions not first for man [%1]",_objectType);
private _mainActions = [];

View File

@ -31,7 +31,7 @@ _vehicle setVariable [QGVAR(targetObject), _targetObject, true];
private _laserMethod = QFUNC(findLaserSource);
private _vehicleSourceSelection = "";
if (_vehicle isKindOf "CaManBase") then {
if (_vehicle isKindOf "CAManBase") then {
_vehicleSourceSelection = "pilot";
} else {
{ // Go through turrets on vehicle and find the laser

View File

@ -5,7 +5,7 @@
#include "\z\ace\addons\medical\script_component.hpp"
// UAV-AI should get filtered by scope check
private _mans = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'scope')) == 2} && {configName _x isKindOf 'CaManBase'}", true];
private _mans = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(getNumber (_x >> 'scope')) == 2} && {configName _x isKindOf 'CAManBase'}", true];
INFO_1("Checking mans for medical hitpoints [%1 mans]",count _mans);
private _testPass = true;