Skip to content

Commit

Permalink
Merge pull request #123 from IrLED/UPSMON_cycle
Browse files Browse the repository at this point in the history
Optimization of thread mass producers
  • Loading branch information
IrLED committed Nov 21, 2017
2 parents 1fd1a8e + ef7c68e commit 7197cd7
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 74 deletions.
1 change: 1 addition & 0 deletions AntistasiOfficial.Altis/CREATE/VEHdespawner.sqf
@@ -1,3 +1,4 @@
scriptName "VEHdespawner";
params ["_vehicle"];
private ["_isListed","_vehiclePos","_city","_data","_unit"];

Expand Down
1 change: 1 addition & 0 deletions AntistasiOfficial.Altis/CREATE/genRoadPatrol.sqf
@@ -1,4 +1,5 @@
#include "script_component.hpp"
scriptName "genRoadPatrol";
private ["_allVehicles","_allGroups","_allSoldiers","_base","_spawnData","_spawnPosition","_direction","_vehicleArray","_vehicleType","_arrayBases","_arrayTargets","_distance","_vehicleData","_vehicle","_groupVehicle","_beach","_group","_target","_targetPosition","_wp_v_1","_object","_knowledge"];

_allVehicles = [];
Expand Down
38 changes: 26 additions & 12 deletions AntistasiOfficial.Altis/REINF/postmortem.sqf
@@ -1,12 +1,26 @@
_muerto = _this select 0;
sleep cleantime;
deleteVehicle _muerto;
_grupo = group _muerto;
if (!isNull _grupo) then
{
if ({alive _x} count units _grupo == 0) then {deleteGroup _grupo};
}
else
{
if (_muerto in staticsToSave) then {staticsToSave = staticsToSave - [_muerto]; publicVariable "staticsToSave";};
};

if(isNil "postmortem_array") then {
postmortem_array = [];
[] spawn {
scriptName "postmortem_cycle";
while {true} do {
if (postmortem_array isEqualTo []) then {
sleep 60;
}else{
(postmortem_array deleteAt 0) params ["_what","_when"];
_when = _when - diag_tickTime;
if ( _when > 1 ) then {sleep _when;};
deleteVehicle _what;
private _group = group _what;
if (!isNull _group) then {
if ({alive _x} count units _group == 0) then {deleteGroup _group};
}else{
if (_what in staticsToSave) then {staticsToSave = staticsToSave - [_what]; publicVariable "staticsToSave";};
};
};
};
};
};

params ["_dead",["_cleanTOut",cleantime]];
postmortem_array pushBack [_dead, diag_tickTime + _cleanTOut];
Expand Up @@ -10,8 +10,7 @@ Returns:
****************************************************************/
private ["_grpid","_leader","_pos","_rankshort","_lastname","_wppos","_markercolor","_grptype","_drawicon","_text","_trackername","_destname"];


scriptName "UPSMON_TRACK";
While {true} do
{
{
Expand Down
Expand Up @@ -9,16 +9,27 @@ Parameter(s):
Returns:
****************************************************************/
if (isNil "UPS_forCh_arr") then {
UPS_forCh_arr = [];
[] spawn {
scriptName "UPSMON_formationChanger";
while {true} do {
if (UPS_forCh_arr isEqualTo []) then {
sleep 10;
}else{
(UPS_forCh_arr deleteAt 0) params ["_what","_when"];
_when = _when - diag_tickTime;
if ( _when > 1 ) then {sleep _when;};
if (!IsNull _what) then
{
_what setvariable ["UPSMON_haschangedformation",false];
};
};
};
};
};

private ["_grp","_supstatus","_attackpos","_dist","_terrainscan","_haslos","_time"];

_grp = _this select 0;
_supstatus = _this select 1;
_attackpos = _this select 2;
_dist = _this select 3;
_terrainscan = _this select 4;
_haslos = _this select 5;
_typeofgrp = _this select 6;
params ["_grp","_supstatus","_attackpos","_dist","_terrainscan","_haslos","_typeofgrp"];

If (!(_grp getvariable ["UPSMON_haschangedformation",false])) then
{
Expand Down Expand Up @@ -157,15 +168,4 @@ If (!(_grp getvariable ["UPSMON_haschangedformation",false])) then
};
};

[_grp] spawn
{
private ["_grp"];

_grp = _this select 0;

sleep 20;
If (!IsNull _grp) then
{
_grp setvariable ["UPSMON_haschangedformation",false];
};
};
UPS_forCh_arr pushBack [_grp, diag_tickTime + 20];
7 changes: 4 additions & 3 deletions AntistasiOfficial.Altis/Scripts/UPSMON/UPSMON_MAINLOOP.sqf
Expand Up @@ -80,13 +80,14 @@ UPSMON_MAINLOOP_postCycle = {};
UPSMON_MAINLOOP_preItem = {};
UPSMON_MAINLOOP_postItem = {};
#endif
scriptname "UPSMON_MAINLOOP";
UPSMON_MAINLOOP_cycle = 10;

while {true} do
{
#ifdef PROFILE_UPSMON
call UPSMON_MAINLOOP_preCycle;
#endif
_cycle = ((random 1) + 10);
{
#ifdef PROFILE_UPSMON
call UPSMON_MAINLOOP_preItem;
Expand Down Expand Up @@ -1056,5 +1057,5 @@ while {true} do
#ifdef PROFILE_UPSMON
call UPSMON_MAINLOOP_postCycle;
#endif
sleep _cycle;
};
sleep UPSMON_MAINLOOP_cycle;
};
65 changes: 30 additions & 35 deletions AntistasiOfficial.Altis/Scripts/UPSMON/UPSMON_MAINLOOPCiv.sqf
@@ -1,11 +1,11 @@
private ["_cycle","_grp","_members","_grpmission","_grpstatus","_grpid","_Ucthis","_lastcurrpos","_lastpos","_lastattackpos","_areamarker","_npc","_driver","_buildingdist","_deadbodiesnear","_stuck","_makenewtarget","_targetpos","_attackpos","_dist","_target","_wptype","_traveldist","_targetdist","_speedmode","_behaviour","_combatmode","_currPos","_grpcomposition","_typeofgrp","_capacityofgrp","_assignedvehicle","_supstatus","_TargetSearch"];

scriptname "UPSMON_MAINLOOPCiv";
UPSMON_MAINLOOPCiv_cycle = 15;
while {true} do
{
_cycle = ((random 1) + 10);
{
If (!IsNull _x) then
{
If (!IsNull _x) then{
_grp = _x;

_members = (_grp getvariable "UPSMON_Origin") select 4;
Expand All @@ -22,8 +22,7 @@ while {true} do

_areamarker = _Ucthis select 1;

if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith
{
if (({alive _x && !(captive _x)} count units _grp) == 0 || _grp getvariable ["UPSMON_Removegroup",false]) exitwith{
[_grp,_UCthis] call UPSMON_RESPAWN;
};

Expand Down Expand Up @@ -56,8 +55,7 @@ while {true} do
// current position
_currPos = getposATL _npc;

If (count(waypoints _grp) != 0) then
{
If (count(waypoints _grp) != 0) then{
_wppos = waypointPosition [_grp,count(waypoints _grp)-1];
_targetpos = _wppos;
_wptype = waypointType [_grp,count(waypoints _grp)-1];
Expand All @@ -71,29 +69,28 @@ while {true} do

_supstatus = [_grp] call UPSMON_supstatestatus;
_nowp = [_grp,_target,_supstatus] call UPSMON_NOWP;

If (_grp getvariable ["UPSMON_GrpHostility",0] > 0) then
{
_TargetSearch = [_grp,_areamarker] call UPSMON_TargetAcquisitionCiv;
_target = _TargetSearch select 0;
_dist = _TargetSearch select 1;
_attackpos = _TargetSearch select 2;

If (_grp getvariable ["UPSMON_Grpmission",""] != "HARASS") then
{
If (!Isnull _target) then
{
_grp setvariable ["UPSMON_Grpmission","HARASS"]
};
}
else
{
If (Isnull _target) then
{
[_grp] call UPSMON_BackToNormal;
};
};
};
if (_grp getvariable ["UPSMON_GrpHostility",0] > 0) then
{
_TargetSearch = [_grp,_areamarker] call UPSMON_TargetAcquisitionCiv;
_target = _TargetSearch select 0;
_dist = _TargetSearch select 1;
_attackpos = _TargetSearch select 2;

If (_grp getvariable ["UPSMON_Grpmission",""] != "HARASS") then
{
If (!Isnull _target) then
{
_grp setvariable ["UPSMON_Grpmission","HARASS"]
};
}
else
{
If (Isnull _target) then
{
[_grp] call UPSMON_BackToNormal;
};
};
};

//If in safe mode if find dead bodies change behaviour
{
Expand Down Expand Up @@ -287,12 +284,10 @@ while {true} do
_grp setvariable ["UPSMON_Lastinfos",[_currpos,_targetpos]];
_grp setvariable ["UPSMON_Lastattackpos",_attackpos];
_grp setvariable ["UPSMON_LastGrpmission",_grp getvariable ["UPSMON_Grpmission",""]];

sleep 0.1;

};

} foreach UPSMON_Civs;
If (ObjNull in UPSMON_NPCs) then {UPSMON_NPCs = UPSMON_NPCs - [ObjNull]};
sleep _cycle;
};
if (ObjNull in UPSMON_NPCs) then {UPSMON_NPCs = UPSMON_NPCs - [ObjNull]};
sleep UPSMON_MAINLOOPCiv_cycle;
};
2 changes: 1 addition & 1 deletion AntistasiOfficial.Altis/initVar.sqf
Expand Up @@ -245,4 +245,4 @@ publicVariable "static_playerSide";

if (isMultiplayer) then {[[petros,"hint","Variables Init Completed"],"commsMP"] call BIS_fnc_MP;};

diag_log "InitVar.sqf: end";
diag_log "InitVar.sqf: end";

0 comments on commit 7197cd7

Please sign in to comment.