Build 169

Fixed: Vehicles were being deleted at missions too quickly after crew were killed.
This commit is contained in:
Chris Cardozo 2018-12-04 05:45:15 -05:00
parent 6560123a60
commit a34071bf86
16 changed files with 68 additions and 312 deletions

View File

@ -24,6 +24,10 @@ while {true} do
uiSleep 1;
if (diag_tickTime > _timer1sec) then
{
[] call blck_fnc_vehicleMonitor;
#ifdef GRGserver
[] call blck_fnc_broadcastServerFPS;
#endif
_timer1sec = diag_tickTime + 1;
};
if (diag_tickTime > _timer5sec) then

View File

@ -16,4 +16,4 @@ _group = _this select 0;
_unit = _x;
_tempEH = _unit addEventHandler ["Reloaded", {_this call blck_EH_unitWeaponReloaded;}];
}forEach (units _group);
//diag_log format["blckHC:: group %1 transferred to HC %1",_group,_client];
//diag_log format["blckHC:: group %1 transferred to HC %1",_group,clientOwner];

View File

@ -1,6 +0,0 @@
diag_log format["_fnc_HC_XferVehicle:: _this = %1",_this];
private["_veh","_tempEH","_localEH"];
_veh = _this select 0;
_tempEH = ["HandleDamage",_veh addMPEventHandler["HandleDamage",{ [_this] call compile preprocessFileLineNumbers blck_EH_AIVehicle_HandleDamage}]];
_localEH = [_tempEH];
_veh setVariable["localEH",_tempEH,true];

View File

@ -1,19 +0,0 @@
/*
Killed handler for _units
By Ghostrider-GRG-
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
//#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private _clientId = clientOwner;
private _groupsOwned = {groupOwner _x isEqualTo _clientId)} count allGroups;
//diag_log format["_fnc_HC_groupsAssigned:: %1 groups running on client %2",_groupsOwned,_clientId];
_groupsOwned
//[_clientId,_groupsOwned] remoteExec ["blck_fnc_updateClientGroupCounts",2];

View File

@ -1,15 +0,0 @@
/*
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
params["_vehicle"];
[_vehicle] remoteExec ["blck_fnc_monitorVehicleStatus",2];

View File

@ -1,108 +0,0 @@
/*
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
//diag_log format["_fnc_vehicleMonitor: starting function at diag_tickTime = %1",diag_tickTime];
#ifdef blck_debugMode
//diag_log format["_fnc_vehicleMonitor:: blck_debugMode defined"];
#endif
private ["_vehList","_veh","_isEmplaced","_ownerIsPlayer","_allCrewDead","_deleteNow","_missionCompleted","_evaluate","_cleanupTimer"];
_vehList = +blck_HC_monitoredVehicles;
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 and blck_HC_monitoredVehicles %3",diag_tickTime,_vehList,blck_HC_monitoredVehicles];};
#endif
//diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 and blck_HC_monitoredVehicles %3",diag_tickTime,_vehList,blck_HC_monitoredVehicles];
//blck_fnc_releaseVehicleToPlayers
{
/*
Determine state of vehicle
_isEmplaced
_ownerIsPlayer
_allCrewDead
_deleteNow
*/
//diag_log format["_fnc_vehicleMonitor: evaluating vehicle %1",_x];
_veh = _x; // (purely for clarity at this point, _x could be used just as well)
_isEmplaced = _veh getVariable["GRG_vehType","none"] isEqualTo "emplaced";
_ownerIsPlayer = if (owner _veh > 2 && !(owner _veh in blck_connectedHCs)) then {true} else {false};
{
//diag_log format["_fnc_vehicleMonitor: vehicle %1 crew %2 alive = %3",_veh,_x, alive _x];
}forEach (crew _veh);
_allCrewDead = if (({alive _x} count (crew _veh)) == 0) then {true} else {false};
//diag_log format["_fnc_vehicleMonitor: _allCrewDead = %1",_allCrewDead];
_deletenow = false;
if ( (_veh getVariable["blck_DeleteAt",0] > 0) && (diag_tickTime > (_veh getVariable "blck_DeleteAt"))) then {_deleteNow = true};
_missionCompleted = if (_veh getVariable["missionCompleted",0] != 0) then {true} else {false};
_evaluate = true;
if (_ownerIsPlayer) then
{
// disable further monitoring and mark to never be deleted.
_evaluate = false;
_veh setVariable["blck_DeleteAt",0];
blck_HC_monitoredVehicles = blck_HC_monitoredVehicles - [_veh];
//diag_log format["_fnc_vehicleMonitor: vehicle %1 now owned by player %2",_veh, owner _veh];
};
if (_allCrewDead && _evaluate) then
{
if (_isEmplaced) then
{
if (blck_killEmptyStaticWeapons) then
{
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: case of destroyed where vehicle = %1",_veh];};
#endif
_veh setDamage 1;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
}else {
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
} else {
if (blck_killEmptyAIVehicles) then
{
_veh setDamage 0.7;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
} else {
//diag_log format["_fnc_vehicleMonitor:: case of RELEASE where vehicle = %1 and Vehicle is typeOf %2",_veh, typeOf _veh];
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
};
};
if (_missionCompleted && !(_allCrewDead)) then
{
//diag_log format["_fnc_vehicleMonitor:: case of mission vehicle with AI alive at mission end: schedule destruction with _veh = %1 and typeOf _veh = %2",_veh, typeOf _veh];
_cleanupTimer = _veh getVariable["blck_DeleteAt",0]; // The time delete to deleting any alive AI units
if (_cleanupTimer == 0) then {_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer]};
_evaluate = false;
};
if (_evaluate) then
{
[_veh] call blck_fnc_reloadVehicleAmmo;
};
if (_deleteNow) then
{
[_veh] call blck_fnc_destroyVehicleAndCrew;
_evaluate = false;
};
}forEach _vehList;

View File

@ -1,25 +0,0 @@
/*
Killed handler for _units
By Ghostrider-GRG-
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
//#include "\q\addons\custom_server\Configs\blck_defines.hpp";
diag_log "_fnc_HC_monitor.sqf <RUNNING>";
_blckGroups = 0;
_otherGroups = 0;
_totalGroups = 0;
_timerOneSec =0;
_timerSixtySec = 0;
_timer3min = 0;
while {true} do
{
uiSleep 1;
};

View File

@ -1,61 +0,0 @@
/*
Killed handler for _units
By Ghostrider-GRG-
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
//#include "\q\addons\custom_server\Configs\blck_defines.hpp";
params["_name","_owner"];
//diag_log format["_fnc_onPlayerDisconnected triggered with _name = %1 and _owner = %2",_name,_owner];
private["_HCownerids","_groupLocalEH","_vehicleLocalEH"];
// Remove the name of the HC from the list of active, connected HCs
if (toLower(_name) isEqualTo "headlessclient") then
{
//diag_log "_fnc_onPlayerDisconnected: a headless client disconnected, time to deal with the damage";
_entities = entities "Headlessclient_F";
_blck_connectedHCs = +blck_connectedHCs;
_HCownerids = [];
{
if !(_x in _entities) then
{
// If the HC is not in the list of connected SC then delete it from the list maintained separately by blckeagls.
blck_connectedHCs = blck_connectedHCs - [_x];
} else {
// Grab the owner ids for currently connected HCs.
_HCownerids pushBack (owner _x);
};
}forEach _blck_connectedHCs;
// Check whether there are any groups assigned to an owner that is not connected and deal with it
{
if !(_x getVariable["owner",0] in _HCownerids) then
{
//diag_log format["_fnc_onPlayerDisconnected:: reseting eventHandlers for group %1",_x];
// do any cleanup; at present this is simply removing locally added event handlers
_groupLocalEH = _x getVariable["localEH",[]];
private _group = _x;
{
_group removeEventHandler (_x getVariable["localEH","Reloaded"]);
}forEach _groupLocalEH;
_x setVariable["localEH",nil,true];
};
}forEach allGroups;
{
if !(_x getVariable["owner",0] in _HCownerids) then
{
//diag_log format["_fnc_onPlayerDisconnected:: reseting eventHandlers for vehicle %1",_x];
// do any cleanup; at present this is simply removing locally added event handlers
_vehicleLocalEH = _x getVariable["localEH",[]];
{
_x removeEventHandler _x;
}forEach _vehicleLocalEH;
_x setVariable["localEH",nil,true];
};
}forEach blck_monitoredVehicles;
};

View File

@ -20,7 +20,7 @@ blck_fnc_countGroupsAssigned = {
};
private["_numTransfered","_clientId","_allGroups","_groupsOwned","_idHC","_id","_swap","_rc"];
//_numTransfered = 0;
_numTransfered = 0;
_idHC = -2;
blck_connectedHCs = entities "HeadlessClient_F";
//diag_log format["_fnc_passToHCs:: blck_connectedHCs = %1 | count _HCs = %2 | server FPS = %3",blck_connectedHCs,count blck_connectedHCs,diag_fps];
@ -36,7 +36,7 @@ if !(blck_connectedHCs isEqualTo []) then
if (_sgor) then
{
[_x] remoteExec["blck_fnc_HC_XferGroup",_idHC];
//_numTransfered = _numTransfered + 1;
_numTransfered = _numTransfered + 1;
};
};
};

View File

@ -1,9 +1,7 @@
/*
for ghostridergaming
By Ghostrider [GRG]
Fill a crate with items
--------------------------
License
--------------------------

View File

@ -8,12 +8,6 @@
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private _crate = _this select 0;
#ifdef blck_debugMode
diag_log format["_fnc_loadMisionLootcrate: _this = %1",_this];
diag_log format["_fnc_loadMisionLootcrate: difficulty = %1", _crate getVariable "difficulty"];
diag_log format["_fnc_loadMisionLootcrate: lootCounts = %1", _crate getVariable "lootCounts"];
diag_log format["_fnc_loadMisionLootcrate: lootArray = %1",_crate getVariable "lootArray"];
#endif
[_crate,(_crate getVariable "lootArray"),(_crate getVariable "lootCounts")] call blck_fnc_fillBoxes;
[_crate, _crate getVariable "difficulty"] call blck_fnc_addMoneyToObject;
_crate setVariable["lootLoaded",true];

View File

@ -24,10 +24,6 @@ for "_i" from 1 to (count blck_liveMissionAI) do {
};
[_x] call blck_fnc_deleteAI;
} forEach _unitsarr;
uiSleep 0.1;
#ifdef blck_debugMode
if (blck_debugLevel > 1) then {diag_log format["_fnc_mainTread:: blck_liveMissionAI updated to %1",blck_liveMissionAI];};
#endif
}
else {
blck_liveMissionAI pushback _units;

View File

@ -16,7 +16,7 @@ private ["_obj"];
if !(_characterBuildingConfigs isEqualTo []) then
{
_obj = createVehicle[(_characterBuildingConfigs select 0),_center vectorAdd (_characterBuildingConfigs select 1),[],0,"CAN_COLLIDE"];
//diag_log format["_fnc_placeCharacterInBuilding: _obj = %1",_obj];
diag_log format["_fnc_placeCharacterInBuilding: _obj = %1",_obj];
_obj setDir (_characterBuildingConfigs select 2);
_obj allowDamage true;
_obj enableDynamicSimulation true;

View File

@ -1,8 +1,7 @@
/*
Killed handler for _units
By Ghostrider-GRG-
And Ignatz-HeMan
--------------------------
License
--------------------------
@ -10,12 +9,10 @@
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
// Needs optimization for headless clients
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
params["_veh"];
blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
//diag_log format["_fnc_releaseVehicleToPlayersl: _veh = %1 | isLocal _veh = %3 | (owner _veh) = %2",_veh,(owner _veh),Local _veh];
if (local _veh) then {
_veh lock false;
}
@ -27,12 +24,11 @@
[[_veh,false],["lock",_veh]] remoteExecCall ["remoteExecCall", 2]; // If run on HC, move to the server. Server will remoteexec on local machine
};
};
//diag_log format["_fnc_releaseVehicleToPlayers: _veh=%1 | owner = %2 | lock = %3",_veh,owner _veh, locked _veh];
{
_veh removealleventhandlers _x;
} forEach ["GetIn","GetOut","fired","hit","hitpart","reloaded","dammaged","HandleDamage"];
{
_veh removeAllMPEventHandlers _x;
} forEach ["MPHit","MPKilled"];
_veh setVariable["blck_DeleteAt",nil];
if ((damage _veh) > 0.6) then {_veh setDamage 0.6};
if ((damage _veh) > 0.6) then {_veh setDamage 0.6}; // So they don't blow up when a player tries to get in.

View File

@ -11,64 +11,61 @@
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private ["_vehList"];
_vehList = +blck_monitoredVehicles;
//diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 ",diag_tickTime,_vehList,blck_monitoredVehicles];
//diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 ",diag_tickTime,blck_monitoredVehicles];
private _serverIDs = ([2] + (entities "HeadlessClient_F"));
for "_i" from 1 to (count blck_monitoredVehicles) do
{
private["_veh","_isEmplaced","_allCrewDead","_evaluate","_deleteAtTime"];
_veh = _x; // (purely for clarity at this point, _x could be used just as well)
_isEmplaced = _veh getVariable["GRG_vehType","none"] isEqualTo "emplaced";
_allCrewDead = {alive _x} count (crew _veh) == 0;
_evaluate = 0;
_deleteAtTime = _veh getVariable ["blck_deleteAtTime",diag_tickTime + 1];
if (diag_tickTime > _deleteAtTime) then
if (_i > (count blck_monitoredVehicles)) exitWith {};
private _veh = blck_monitoredVehicles deleteAt 0;
if !(_veh isEqualTo objNull) then
{
_evaluate = 3;
} else {
if (_allCrewDead) then
// if the owner is a player do not add back for further monitoring
if ((owner _veh) in (_serverIDs)) then
{
_evaluate = if (_isEmplaced) then {1} else {2};
};
};
//diag_log format["_fnc_vehicleMonitor: vehicle = %1 | owner = %2 | crew = %3 | _evaluate = %4",_veh, owner _veh, {alive _x} count (crew _veh), _evaluate];
switch (_evaluate) do
{
case 0:{[_veh] call blck_fnc_reloadVehicleAmmo;};
case 1:{
if (blck_killEmptyStaticWeapons) then
//diag_log format["_fnc_vehicleMonitor: vehicle %1 to be deleted at %2",_veh,(_veh getVariable ["blck_deleteAtTime",0])];
if ((_veh getVariable ["blck_deleteAtTime",0]) > 0) then
{
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: case of destroyed where vehicle = %1",_veh];};
_veh setDamage 1;
_veh setVariable["blck_deleteAtTime",diag_tickTime + 60];
}else {
//diag_log format["_fnc_vehicleMonitor: calling _fnc_releaseVehicleToPlayers for vehicle %1",_veh];
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
};
case 2:{
if (blck_killEmptyAIVehicles) then
{
//if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: case of destroyed where vehicle = %1",_veh];};
_veh setDamage 0.7;
_veh setFuel 0;
_veh setVariable["blck_deleteAtTime",diag_tickTime + 60];
if (diag_tickTime > ( _veh getVariable ["blck_deleteAtTime",0])) then
{
//diag_log format["_fnc_vehicleMonitor: deleting vehicle and crew for %1",_veh];
[_veh] call blck_fnc_destroyVehicleAndCrew;
} else {
blck_monitoredVehicles pushBack _veh;
};
} else {
//diag_log format["_fnc_vehicleMonitor: calling _fnc_releaseVehicleToPlayers for vehicle %1",_veh];
[_veh] call blck_fnc_releaseVehicleToPlayers;
if ({alive _veh} count (crew _veh) == 0) then
{
if (_veh getVariable["GRG_vehType","none"] isEqualTo "emplaced") then
{
if (blck_killEmptyStaticWeapons) then
{
//diag_log format["_fnc_vehicleMonitor: disabling static %1 and setting its delete time",_veh];
_veh setDamage 1;
_veh setVariable["blck_deleteAtTime",diag_tickTime + 60,true];
}else {
//diag_log format["_fnc_vehicleMonitor: releasing static %1 to players and setting a default delete timer",_veh];
[_veh] call blck_fnc_releaseVehicleToPlayers;
_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer,true];
};
} else {
if (blck_killEmptyAIVehicles) then
{
//diag_log format["_fnc_vehicleMonitor: disabling vehicle %1 and setting a delete time",_veh];
_veh setDamage 0.7;
_veh setFuel 0;
_veh setVariable["blck_deleteAtTime",diag_tickTime + 60];
} else {
//diag_log format["-------->_fnc_vehicleMonitor: releasing vehicle %1 to players and setting a default delete timer",_veh];
_veh setVariable["blck_deleteAtTime",diag_tickTime + blck_vehicleDeleteTimer,true];
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
};
};
blck_monitoredVehicles pushBack _veh;
};
} else {
//diag_log format["_fnc_vehicleMonitor: owner of vehicle %1 is a player, discontinuing further monitoring",_veh];
};
case 3:{
//diag_log format["_fnc_releaseVehicleToPlayers: destroying vehicle and crew for vehicle %1 at time %2",_veh,diag_tickTime];
[_veh] call blck_fnc_destroyVehicleAndCrew;
};
};
}forEach _vehList;
};

View File

@ -163,6 +163,11 @@ private _functions = [
missionnamespace setvariable [_name,compileFinal preprocessFileLineNumbers _path];
} foreach _functions;
#ifdef GRGserver
blck_fnc_broadcastServerFPS = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Functions\GMS_fnc_broadcastServerFPS.sqf";
diag_log "blck_functions loaded using GRGserver settings ---- >>>> ";
#endif
onPlayerDisconnected {[_name,_owner] call blck_fnc_onPlayerDisconnected;};