Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move radio tower repair to server side, fix bugs #684

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions A3-Antistasi/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class A3A
class prestige {};
class radioCheck {};
class rebuildAssets {};
class rebuildRadioTower {};
class relocateHQObjects {};
class repairRuinedBuilding {};
class resourceCheckSkipTime {};
Expand Down
25 changes: 1 addition & 24 deletions A3-Antistasi/functions/Base/fn_rebuildAssets.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,6 @@ if (isNull _antennaDead) then
else
{
hint "Radio Tower rebuilt";
antennasDead = antennasDead - [_antennaDead]; publicVariable "antennasDead";
[_antennaDead] call A3A_fnc_repairRuinedBuilding;
antennas pushBack _antennaDead; publicVariable "antennas";

{if ([antennas,_x] call BIS_fnc_nearestPosition == _antennaDead) then {[_x,true] spawn A3A_fnc_blackout}} forEach citiesX;
_mrkFinal = createMarker [format ["Ant%1", mapGridPosition _antennaDead], getPos _antennaDead];
_mrkFinal setMarkerShape "ICON";
_mrkFinal setMarkerType "loc_Transmitter";
_mrkFinal setMarkerColor "ColorBlack";
_mrkFinal setMarkerText "Radio Tower";
mrkAntennas pushBack _mrkFinal;
publicVariable "mrkAntennas";
_antennaDead addEventHandler ["Killed",
{
_antenna = _this select 0;
_antenna removeAllEventHandlers "Killed";
{if ([antennas,_x] call BIS_fnc_nearestPosition == _antenna) then {[_x,false] spawn A3A_fnc_blackout}} forEach citiesX;
_mrk = [mrkAntennas, _antenna] call BIS_fnc_nearestPosition;
antennas = antennas - [_antenna]; antennasDead = antennasDead + [_antenna]; deleteMarker _mrk;
["TaskSucceeded",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",teamPlayer];
["TaskFailed",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",Occupants];
publicVariable "antennas"; publicVariable "antennasDead";
}
];
[_antennaDead] remoteExec ["A3A_fnc_rebuildRadioTower", 2];
};
[0,-5000] remoteExec ["A3A_fnc_resourcesFIA",2];
38 changes: 38 additions & 0 deletions A3-Antistasi/functions/Base/fn_rebuildRadioTower.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Repairs a radio tower.
// Parameter should be present in antennasDead array
private _file = "fn_rebuildRadioTower";
if (!isServer) exitWith { [1, "Server-only function miscalled", _file] call A3A_fnc_log };

params ["_antenna"];

if !(_antenna in antennasDead) exitWith { [1, "Attempted to rebuild invalid radio tower", _file] call A3A_fnc_log };
[2, format["Repairing Antenna %1", str _antenna], _file] call A3A_fnc_log;

antennasDead = antennasDead - [_antenna]; publicVariable "antennasDead";
[_antenna] call A3A_fnc_repairRuinedBuilding;
antennas pushBack _antenna; publicVariable "antennas";

{if ([antennas,_x] call BIS_fnc_nearestPosition == _antenna) then {[_x,true] spawn A3A_fnc_blackout}} forEach citiesX;

private _mrkFinal = createMarker [format ["Ant%1", mapGridPosition _antenna], getPos _antenna];
_mrkFinal setMarkerShape "ICON";
_mrkFinal setMarkerType "loc_Transmitter";
_mrkFinal setMarkerColor "ColorBlack";
_mrkFinal setMarkerText "Radio Tower";
mrkAntennas pushBack _mrkFinal;
publicVariable "mrkAntennas";

_antenna addEventHandler ["Killed",
{
params ["_antenna"];
_antenna removeAllEventHandlers "Killed";
{if ([antennas,_x] call BIS_fnc_nearestPosition == _antenna) then {[_x,false] spawn A3A_fnc_blackout}} forEach citiesX;
_mrk = [mrkAntennas, _antenna] call BIS_fnc_nearestPosition;
mrkAntennas = mrkAntennas - [_mrk]; deleteMarker _mrk;
antennas = antennas - [_antenna]; antennasDead = antennasDead + [_antenna];
publicVariable "antennas"; publicVariable "antennasDead"; publicVariable "mrkAntennas";
["TaskSucceeded",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",teamPlayer];
["TaskFailed",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",Occupants];
}
];

2 changes: 2 additions & 0 deletions A3-Antistasi/functions/Base/fn_repairRuinedBuilding.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//Repairs a destroyed building.
//Parameter can either be the ruin of a building, or the building itself buried underneath the ruins.

if (!isServer) exitWith { [1, "Server-only function miscalled", "fn_repairRuinedBuilding"] call A3A_fnc_log };

params ["_target"];

private _buildingToRepair = objNull;
Expand Down
25 changes: 1 addition & 24 deletions A3-Antistasi/functions/Missions/fn_REP_Antenna.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,7 @@ if (dateToNumber date > _dateLimitNum) then
[-600] remoteExec ["A3A_fnc_timingCA",2];
[-10,theBoss] call A3A_fnc_playerScoreAdd;
};
antennasDead = antennasDead - [_antennaDead]; publicVariable "antennasDead";
diag_log format ["%1: [Antistasi] | DEBUG | Repairing Antenna %2.",servertime, typeOf _antennaDead];
[_antennaDead] call A3A_fnc_repairRuinedBuilding;
antennas pushBack _antennaDead; publicVariable "antennas";
{if ([antennas,_x] call BIS_fnc_nearestPosition == _antennaDead) then {[_x,true] spawn A3A_fnc_blackout}} forEach citiesX;
_mrkFinal = createMarker [format ["Ant%1", mapGridPosition _antennaDead], getPos _antennaDead];
_mrkFinal setMarkerShape "ICON";
_mrkFinal setMarkerType "loc_Transmitter";
_mrkFinal setMarkerColor "ColorBlack";
_mrkFinal setMarkerText "Radio Tower";
mrkAntennas pushBack _mrkFinal;
publicVariable "mrkAntennas";
_antennaDead addEventHandler ["Killed",
{
_antenna = _this select 0;
_antenna removeAllEventHandlers "Killed";
{if ([antennas,_x] call BIS_fnc_nearestPosition == _antenna) then {[_x,false] spawn A3A_fnc_blackout}} forEach citiesX;
_mrk = [mrkAntennas, _antenna] call BIS_fnc_nearestPosition;
antennas = antennas - [_antenna]; antennasDead = antennasDead + [_antenna]; deleteMarker _mrk;
["TaskSucceeded",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",teamPlayer];
["TaskFailed",["", "Radio Tower Destroyed"]] remoteExec ["BIS_fnc_showNotification",Occupants];
publicVariable "antennas"; publicVariable "antennasDead";
}
];
[_antennaDead] remoteExec ["A3A_fnc_rebuildRadioTower", 2];
};

_nul = [30,"REP"] spawn A3A_fnc_deleteTask;
Expand Down
5 changes: 4 additions & 1 deletion A3-Antistasi/functions/init/fn_initServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ addMissionEventHandler ["BuildingChanged", {
_oldBuilding setVariable ["ruins", _newBuilding];
_newBuilding setVariable ["building", _oldBuilding];

destroyedBuildings pushBack (getPosATL _oldBuilding);
// Antenna dead/alive status is handled separately
if !(_oldBuilding in antennas || _oldBuilding in antennasDead) then {
destroyedBuildings pushBack (getPosATL _oldBuilding);
};
};
}];

Expand Down