Skip to content

Commit

Permalink
Merge pull request #74 from gruppe-adler/fix-mp
Browse files Browse the repository at this point in the history
Fix mp
  • Loading branch information
Fusselwurm authored Jul 3, 2020
2 parents 095ae7c + c1b4e00 commit d16d261
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 93 deletions.
4 changes: 3 additions & 1 deletion addons/cars/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};

["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
if (isServer || !hasInterface) then {
["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
};
6 changes: 3 additions & 3 deletions addons/legacy/functions/fnc_doCustomActivity.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ INFO_2("civ %1: starts custom activity %2", _civ, _id);
// I am however afraid of broadcasting code (where I have no idea how large it is) everytime a civ does something special.
// Also, when civ changes owner it starts a new life anyway, so there's that /shrug
// If in doubt, that's the place where a lot of things (anim, AI props) should be reset anyway. (TODO)
_civ setVariable [QGVAR(customActivity_id), _id];
_civ setVariable [QGVAR(customActivity_id), _id, true]; // needs to be global, serves as indicator for player interactions
_civ setVariable [QGVAR(customActivity_doEnd), _doEnd];
_civ setVariable [QGVAR(customActivity_parameters), _moreParameters];

Expand All @@ -68,10 +68,10 @@ private _endCode = {
INFO_2("civ %1: ending custom activity %2", _civ, _id);
private _doEnd = _civ getVariable [QGVAR(customActivity_doEnd), {}];
private _moreParameters = _civ getVariable [QGVAR(customActivity_parameters), []];
([_civ] + _moreParameters) call _doEnd;
([_civ] + _moreParameters) call _doEnd;
_this call _doEnd;

_civ setVariable [QGVAR(customActivity_id), nil];
_civ setVariable [QGVAR(customActivity_id), nil, true];
_civ setVariable [QGVAR(customActivity_doEnd), nil];
_civ setVariable [QGVAR(customActivity_parameters), nil];
[_target, ""] call FUNC(setCurrentlyThinking);
Expand Down
6 changes: 5 additions & 1 deletion addons/legacy/functions/fnc_interact_backUpAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
private _veh = vehicle _target;
private _reverseTargetPos = (getPos _veh) vectorAdd ((vectorDir _veh) vectorMultiply -50);

[_target, _reverseTargetPos] call FUNC(customActivity_reverse);
[
QGVAR(told_to_reverse),
[_target, _reverseTargetPos],
_target
] call CBA_fnc_targetEvent;
6 changes: 5 additions & 1 deletion addons/legacy/functions/fnc_interact_carryOnAction.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include "..\script_component.hpp"

_target call FUNC(endCustomActivity);
[
QGVAR(told_to_carry_on),
[_target],
_target
] call CBA_fnc_targetEvent;
15 changes: 15 additions & 0 deletions addons/legacy/functions/fnc_sm_activities.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ private _panic = [] call FUNC(sm_panic);
[_target, _reverseTargetPos] call FUNC(customActivity_reverse);
}] call CBA_fnc_addEventHandler;

[QGVAR(told_to_reverse), {
params [
["_target", objNull, [objNull]],
["_reverseTargetPos", [0, 0, 0], [[]]]
];
[_target, _reverseTargetPos] call FUNC(customActivity_reverse);
}] call CBA_fnc_addEventHandler;

[QGVAR(told_to_carry_on), {
params [
["_target", objNull, [objNull]]
];
_target call FUNC(endCustomActivity);
}] call CBA_fnc_addEventHandler;


// STATES
assert(_activities isEqualType locationNull);
Expand Down
44 changes: 23 additions & 21 deletions addons/mimikry/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ if (isServer) then {
if (hasInterface) then {
ISNILS(GVAR(INFOCHANNEL), 0);
[] call FUNC(addEventHandlers);
};

GVAR(PLAYERSIDE) = sideUnknown;
[
{
if (!isGameFocused || isGamePaused) exitWith {};
if !(alive player) exitWith {};
if (GVAR(PLAYERSIDE) == side player) exitWith {};
if ((["HEALTHY", "INJURED"] find (lifeState player)) == -1) exitWith {};

if (side player == civilian) then {
GVAR(INFOCHANNEL) radioChannelAdd [player];
["you are CIVILIAN now"] call FUNC(showCivHint);
} else { if (GVAR(PLAYERSIDE) == civilian) then {
["you are NO LONGER CIVILIAN"] call FUNC(showCivHint);
GVAR(INFOCHANNEL) radioChannelRemove [player];
}};
GVAR(PLAYERSIDE) = side player;
},
5,
[]
] call CBA_fnc_addPerFrameHandler;

GVAR(PLAYERSIDE) = sideUnknown;
[
{
if (!isGameFocused || isGamePaused) exitWith {};
if !(alive player) exitWith {};
if (GVAR(PLAYERSIDE) == side player) exitWith {};
if ((["HEALTHY", "INJURED"] find (lifeState player)) == -1) exitWith {};

if (side player == civilian) then {
GVAR(INFOCHANNEL) radioChannelAdd [player];
["you are CIVILIAN now"] call FUNC(showCivHint);
} else { if (GVAR(PLAYERSIDE) == civilian) then {
["you are NO LONGER CIVILIAN"] call FUNC(showCivHint);
GVAR(INFOCHANNEL) radioChannelRemove [player];
}};
GVAR(PLAYERSIDE) = side player;
},
5,
[]
] call CBA_fnc_addPerFrameHandler;

};
32 changes: 17 additions & 15 deletions addons/patrol/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};

[
QEGVAR(legacy,spawnAllowed),
{
ISNILS(GVAR(maxCivsOnFoot), [QGVAR(maxCivsOnFoot)] call CBA_settings_fnc_get);
if ((count (["patrol"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then {
[ALL_HUMAN_PLAYERS] call FUNC(addFootsy);
};
}
] call CBA_fnc_addEventHandler;
if (isServer || !hasInterface) then {
[
QEGVAR(legacy,spawnAllowed),
{
ISNILS(GVAR(maxCivsOnFoot), [QGVAR(maxCivsOnFoot)] call CBA_settings_fnc_get);
if ((count (["patrol"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then {
[ALL_HUMAN_PLAYERS] call FUNC(addFootsy);
};
}
] call CBA_fnc_addEventHandler;

private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesOnFoot)] call CBA_settings_fnc_get);
[
"patrol",
_spawnDistances#1 * 1.5
] call EFUNC(common,registerCivTaskType);
private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesOnFoot)] call CBA_settings_fnc_get);
[
"patrol",
_spawnDistances#1 * 1.5
] call EFUNC(common,registerCivTaskType);

["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
};
42 changes: 17 additions & 25 deletions addons/residents/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,22 @@ if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};

[
QEGVAR(legacy,spawnAllowed),
{
ISNILS(GVAR(maxCivsResidents), [QGVAR(maxCivsResidents)] call CBA_settings_fnc_get);
if ((count (["reside"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsResidents)) then {
[ALL_HUMAN_PLAYERS] call FUNC(addResident);
};
}
] call CBA_fnc_addEventHandler;
if (isServer || !hasInterface) then {
[
QEGVAR(legacy,spawnAllowed),
{
ISNILS(GVAR(maxCivsResidents), [QGVAR(maxCivsResidents)] call CBA_settings_fnc_get);
if ((count (["reside"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsResidents)) then {
[ALL_HUMAN_PLAYERS] call FUNC(addResident);
};
}
] call CBA_fnc_addEventHandler;

private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesResidents)] call CBA_settings_fnc_get);
[
"reside",
_spawnDistances#1 * 1.2
] call EFUNC(common,registerCivTaskType);
private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesResidents)] call CBA_settings_fnc_get);
[
"reside",
_spawnDistances#1 * 1.2
] call EFUNC(common,registerCivTaskType);

[
{"business" in (allVariables EGVAR(common,stateMachines))},
{
[EGVAR(common,stateMachines) getVariable "business"] call FUNC(sm_business);
},
[],
300,
{
ERROR("'business' state machine did not get initialized - cannot add to it");
}
] call CBA_fnc_waitUntilAndExecute;
["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
};
24 changes: 13 additions & 11 deletions addons/transit/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};

[
QEGVAR(legacy,spawnAllowed),
{
_maxVehiclesInTransit = [QGVAR(maxVehiclesInTransit)] call CBA_settings_fnc_get;
if ((count (["transit"] call EFUNC(cars,getGlobalVehicles))) < _maxVehiclesInTransit) then {
[] call FUNC(spawnSomething);
};
}
] call CBA_fnc_addEventHandler;
if (isServer || !hasInterface) then {
[
QEGVAR(legacy,spawnAllowed),
{
_maxVehiclesInTransit = [QGVAR(maxVehiclesInTransit)] call CBA_settings_fnc_get;
if ((count (["transit"] call EFUNC(cars,getGlobalVehicles))) < _maxVehiclesInTransit) then {
[] call FUNC(spawnSomething);
};
}
] call CBA_fnc_addEventHandler;

["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
["lifecycle", ["lfc_life", "lfc_despawn"], FUNC(sm_lifecycle)] call EFUNC(common,augmentStateMachine);
["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
["lifecycle", ["lfc_life", "lfc_despawn"], FUNC(sm_lifecycle)] call EFUNC(common,augmentStateMachine);
};
32 changes: 17 additions & 15 deletions addons/voyage/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};

[
QEGVAR(legacy,spawnAllowed),
{
private _maxCivsInVehicles = [QGVAR(maxCivsInVehicles)] call CBA_settings_fnc_get;
if ((count (["voyage"] call EFUNC(legacy,getGlobalCivs))) < _maxCivsInVehicles) then {
[ALL_HUMAN_PLAYERS] call FUNC(addCarCrew);
};
}
] call CBA_fnc_addEventHandler;
if (isServer || !hasInterface) then {
[
QEGVAR(legacy,spawnAllowed),
{
private _maxCivsInVehicles = [QGVAR(maxCivsInVehicles)] call CBA_settings_fnc_get;
if ((count (["voyage"] call EFUNC(legacy,getGlobalCivs))) < _maxCivsInVehicles) then {
[ALL_HUMAN_PLAYERS] call FUNC(addCarCrew);
};
}
] call CBA_fnc_addEventHandler;

private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesInVehicles)] call CBA_settings_fnc_get);
[
"voyage",
_spawnDistances#1 * 1.5
] call EFUNC(common,registerCivTaskType);
private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesInVehicles)] call CBA_settings_fnc_get);
[
"voyage",
_spawnDistances#1 * 1.5
] call EFUNC(common,registerCivTaskType);

["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
["business", ["bus_mountUp"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
};

[] call FUNC(setupZeusModules);

0 comments on commit d16d261

Please sign in to comment.