Skip to content

Commit

Permalink
Merge pull request #85 from gruppe-adler/optimize
Browse files Browse the repository at this point in the history
mostly not what the branch name says
  • Loading branch information
Fusselwurm authored Jul 28, 2020
2 parents 7768d60 + 8fda953 commit df94655
Show file tree
Hide file tree
Showing 145 changed files with 1,265 additions and 915 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ backpackProbability | 0.5 | Probability that a civilian will wea
backpacks | [] | All classnames of backpacks that civilians may wear.
civClasses | ["C_Man_1"] | Unit classes to use for spawning civilians
clothes | [] | All classnames of clothes that civilians may wear.
debugCivState | 0 | Toggles civ behavior debugging mode (0/1).
debugFps | 0 | Toggles fps monitoring mode (0/1).
enabled | false | if grad_civs is enabled (false,true)
exitOn | "" | Condition upon which grad-civs loops will stop.
faces | [] | All classnames of faces that civilians may have.
goggles | [] | All classnames of goggles that civilians may wear.
headgear | [] | All classnames of headgear that civilians may wear.
Expand Down Expand Up @@ -184,17 +182,6 @@ Parameter | Explanation
----------|-------------------------------------------------------------
vehicles | Array - All classnames of vehicles that civilians may drive.

### grad_civs_legacy_fnc_setDebugMode
Sets debug mode. Overwrites value from CBA settings. Execute local.

#### Syntax
`[debugCivState] call grad_civs_legacy_fnc_setDebugMode`

Parameter | Explanation
--------------|--------------------------
debugCivState | Bool - Debug mode on/off.


### grad_civs_common_fnc_addExclusionZone and grad_civs_common_fnc_addPopulationZone

Prevent civilians from entering areas.
Expand Down
8 changes: 3 additions & 5 deletions addons/cars/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "script_component.hpp"

if (!(EGVAR(main,enabled))) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};
if (!(EGVAR(main,enabled))) exitWith {};

if (isServer || !hasInterface) then {
["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
if (isServer || CBA_isHeadlessClient) then {
["business", ["bus_rally"], FUNC(sm_business)] call EFUNC(common,augmentStateMachine);
};
10 changes: 7 additions & 3 deletions addons/cars/functions/fnc_loadAnimals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ if (isNull _vehicle) exitWith {

if ((random 1) >= _chance) exitWith {};

if (isNil "grad_animalTransport_fnc_findSuitableSpaces") exitWith {
WARNING("grad_animalTransport_fnc_findSuitableSpaces does not exist, not spawning animals");
if (isNil "grad_animalTransport_fnc_getSupportedAnimalConfigs") exitWith {
WARNING("grad_animalTransport does not exist, not spawning animals");
grad_animalTransport_fnc_getSupportedAnimalConfigs = {[]}; // yes this is evil.
};


private _animalConfig = selectRandom ([] call grad_animalTransport_fnc_getSupportedAnimalConfigs);
private _supportedAnimalConfigs = [] call grad_animalTransport_fnc_getSupportedAnimalConfigs;
if (_supportedAnimalConfigs isEqualTo []) exitWith {};

private _animalConfig = selectRandom _supportedAnimalConfigs;
private _animalClassName = configName _animalConfig;

private _spaces = [_vehicle, _animalClassName] call grad_animalTransport_fnc_findSuitableSpaces;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "..\script_component.hpp"

(([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") || (_this call EFUNC(legacy,sm_activities_helper_surrenderCondition))
(([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") || (_this call EFUNC(interact,sm_activities_helper_surrenderCondition))
17 changes: 9 additions & 8 deletions addons/cars/functions/fnc_spawnVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ clearWeaponCargoGlobal _veh;
clearItemCargoGlobal _veh;
clearMagazineCargoGlobal _veh;

_veh addEventHandler ["FiredNear",
{
params ["_vec", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];

private _units = crew _vec;

["fired_near", _units, _units] call CBA_fnc_targetEvent;
}];
_veh addEventHandler [
"FiredNear",
{
params ["_vec", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];
{
[QEGVAR(legacy,firedNear), [_x], _x] call CBA_fnc_targetEvent;
} forEach (crew _vec);
}
];

private _animalChance = GVAR(animalTransportChance);
[_veh, _animalChance] call FUNC(loadAnimals);
Expand Down
2 changes: 1 addition & 1 deletion addons/cars/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef DEBUG_ENABLED_MAIN
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_MAIN
#ifdef DEBUG_SETTINGS_MAIN
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
#endif

Expand Down
2 changes: 1 addition & 1 deletion addons/cba_statemachine/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef DEBUG_ENABLED_MAIN
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_MAIN
#ifdef DEBUG_SETTINGS_MAIN
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
#endif

Expand Down
4 changes: 2 additions & 2 deletions addons/common/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CfgVehicles
class GVAR(PopulationZone): Module_F
{
scope = 2; // visible in editor
displayName = "population zone";
displayName = "Population Zone";
icon = QPATHTOF(ui\icon_module_population_zone_ca.paa);
category = QEGVAR(main,modules);
function = QFUNC(module_populationZone);
Expand All @@ -32,7 +32,7 @@ class CfgVehicles
class GVAR(ExclusionZone): Module_F
{
scope = 2; // visible in editor
displayName = "exclusion zone";
displayName = "Exclusion Zone";
icon = QPATHTOF(ui\icon_module_exclusion_zone_ca.paa);
category = QEGVAR(main,modules);
function = QFUNC(module_exclusionZone);
Expand Down
4 changes: 3 additions & 1 deletion addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ PREP(augmentStateMachine);
PREP(civGetState);
PREP(clearExclusionZones);
PREP(clearPopulationZones);
PREP(config_getCivClasses);
PREP(dismissCiv);
PREP(dismissGroup);
PREP(config_getCivClasses);
PREP(formatNowPlusSeconds);
PREP(getExclusionZones);
PREP(getPopulationZones);
PREP(initConfig);
PREP(isInPopulatedZone);
PREP(module_exclusionZone);
PREP(module_populationZone);
PREP(nowPlusSeconds);
PREP(parseCsv);
PREP(registerCivTaskType);
4 changes: 1 addition & 3 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "script_component.hpp"

if (!(EGVAR(main,enabled))) exitWith {
INFO("GRAD civs is disabled. Good bye!");
};
if (!(EGVAR(main,enabled))) exitWith {};

[
QGVAR(do_dismiss_civ),
Expand Down
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_dismissCiv.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ _civ enableAI "MOVE";
} forEach allVariables _civ;

// trigger event last
["grad_civs_civ_removed", [_civ]] call CBA_fnc_globalEvent;
[QGVAR(civ_removed), [_civ]] call CBA_fnc_globalEvent;

INFO_1("dismissed civ %1", _civ);
2 changes: 1 addition & 1 deletion addons/common/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifdef DEBUG_ENABLED_MAIN
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_MAIN
#ifdef DEBUG_SETTINGS_MAIN
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
#endif

Expand Down
1 change: 1 addition & 0 deletions addons/diagnostics/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\grad_civs\addons\diagnostics
14 changes: 14 additions & 0 deletions addons/diagnostics/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Extended_PostInit_EventHandlers
{
class ADDON
{
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_PreInit_EventHandlers
{
class ADDON
{
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
9 changes: 9 additions & 0 deletions addons/diagnostics/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREP(initConfig);
PREP(showFps);
PREP(showHonkAtArea);
PREP(showInfoLine);
PREP(showOnMap_drawCivs);
PREP(showOnMap);
PREP(showPinkArrows);
PREP(showPointingHints);
PREP(updateInfoLine);
47 changes: 47 additions & 0 deletions addons/diagnostics/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "script_component.hpp"

if (!(EGVAR(main,enabled))) exitWith {};

if (hasInterface) then {
call FUNC(showHonkAtArea);
call FUNC(showOnMap);
call FUNC(showPinkArrows);
call FUNC(showPointingHints);
call FUNC(showInfoLine);
call FUNC(showFps);
};

if (isServer || CBA_isHeadlessClient) then {
GVAR(debugLoopHandle) = [{
params ["_args", "_handle"];
if (hasInterface && (!isGameFocused || isGamePaused)) exitWith {};
if (call EGVAR(legacy,EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler};
if (GVAR(showInfoLine)) then {
{ _x call FUNC(updateInfoLine); } forEach EGVAR(legacy,localCivs);
};
}, 1, []] call CBA_fnc_addPerFrameHandler;

[
{
if (GVAR(showFps)) then {
[QGVAR(fps), [clientOwner, diag_fps, count EGVAR(legacy,localCivs)]] call CBA_fnc_globalEvent;
};
},
2,
[]
] call CBA_fnc_addPerFrameHandler;
};

if (isServer) then {
[
QEGVAR(common,civ_added),
{
params [["_civ", objNull, [objNull]]];
_civ setVariable [QGVAR(localAt), owner _civ, true];
_civ addEventHandler ["Local", {
params ["_civ", ""];
_civ setVariable [QGVAR(localAt), owner _civ, true];
}];
}
] call CBA_fnc_addEventHandler;
};
12 changes: 12 additions & 0 deletions addons/diagnostics/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;


[] call FUNC(initConfig);
15 changes: 15 additions & 0 deletions addons/diagnostics/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = QUOTE(COMPONENT);
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"grad_civs_main", "grad_civs_legacy"};
author = "AUTHOR";
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
60 changes: 60 additions & 0 deletions addons/diagnostics/functions/fnc_initConfig.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "..\script_component.hpp"

INFO("initConfig running...");

private _settingsGroup = ["GRAD Civs", "a) diagnostics"];

[
QGVAR(showFps),
"CHECKBOX",
"Show server & HC fps",
_settingsGroup,
false,
true,
{},
false
] call CBA_fnc_addSetting;

[
QGVAR(showOnMap),
"CHECKBOX",
"Show civs on map",
_settingsGroup,
false,
true,
FUNC(showOnMap),
false
] call CBA_fnc_addSetting;

[
QGVAR(showInfoLine),
"CHECKBOX",
"Show info line",
_settingsGroup,
false,
true,
FUNC(showInfoLine),
false
] call CBA_fnc_addSetting;

[
QGVAR(showPinkArrows),
"CHECKBOX",
"Create 3D arrows over civ heads",
_settingsGroup,
false,
true,
FUNC(showPinkArrows),
false
] call CBA_fnc_addSetting;

[
QGVAR(showMisc),
"CHECKBOX",
"Miscellaneous stuff",
_settingsGroup,
false,
true,
FUNC(showHonkAtArea),
false
] call CBA_fnc_addSetting;
33 changes: 33 additions & 0 deletions addons/diagnostics/functions/fnc_showFps.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "..\script_component.hpp"

ISNILS(GVAR(lastFps), call CBA_fnc_hashCreate);
ISNILS(GVAR(fpsHandler), -1);
ISNILS(GVAR(fpsPfh), -1);

GVAR(fpsHandler) = [
QGVAR(fps),
{
if (!GVAR(showFps)) exitWith {};
params [
["_clientId", -1, [0]],
["_fps", -1, [0]],
["_civCount", 0, [0]]
];

[GVAR(lastFps), _clientId, [_fps, _civCount]] call CBA_fnc_hashSet;
}
] call CBA_fnc_addEventHandler;

GVAR(fpsPfh) = [
{
if (!GVAR(showFps)) exitWith {};

private _text = "FPS ";
[GVAR(lastFps), {
_text = format ["%1 | %2: %3 (%4)", _text, _key, _value#0, _value#1]
}] call CBA_fnc_hashEachPair;
systemChat _text;
},
2,
[]
] call CBA_fnc_addPerFrameHandler;
28 changes: 28 additions & 0 deletions addons/diagnostics/functions/fnc_showHonkAtArea.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "..\script_component.hpp"

GVAR(honkHandler) = [QEGVAR(interact,honking_at_poly), {
if (!GVAR(showMisc)) exitWith {};
[
{
params [
["_args", [], [[]]],
["_handle", 0, [0]]
];
_args params [
["_endTime", 0, [0]],
["_poly", [], [[]]]
];
if (CBA_missionTime >= _endTime) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
};

{ // show the honked_at "danger zone" in front of the vehicle
private _from = _poly select _forEachIndex;
private _to = _poly select ((_forEachIndex + 1) mod (count _poly));
drawLine3D [_from, _to, [1, 0.3, 0.5, 1]];
} forEach _poly;
},
0,
[CBA_missionTime + 3, _this]
] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;
Loading

0 comments on commit df94655

Please sign in to comment.