Skip to content

Commit

Permalink
Merge pull request #137 from formtapez/MissionEndingFix
Browse files Browse the repository at this point in the history
Fix für Missions-Ende, Wrackräumung und Countdown-Anzeige
  • Loading branch information
formtapez authored Apr 1, 2021
2 parents 3e25a30 + b8b983e commit f7cbc7a
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 138 deletions.
16 changes: 3 additions & 13 deletions addons/OPT/GELDZEIT/fn_frezztime.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,9 @@
*/
#include "macros.hpp"

DFUNC(Player_freeze_time) =
// Spieler in der Freezetime einfrieren
if (GVAR(GAMESTAGE) == GAMESTAGE_FREEZE) then
{
// gib Spieler frei
player enableSimulation true;
};

// friere Spieler, falls freezeTime aktiv
if (!GVAR(Waffenruhestart)) then
{
// freeze Spieler zu Beginn
// Spieler zu Beginn einfrieren
player enableSimulation false;

// warte OPT_PARAM_FREEZE_TIME
//[FUNC(Player_freeze_time), GVAR(FREEZETIME),""] call CLib_fnc_wait;
[FUNC(Player_freeze_time), {(GVAR(FreeztimeEnde))}, "Awesome Delay"] call CLib_fnc_waitUntil;
};
166 changes: 76 additions & 90 deletions addons/OPT/GELDZEIT/fn_serverInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Init Server Zeit und Geldsystem
*
* Author:
* Lord-MDB
* Lord-MDB, form
*
* Arguments:
*
Expand All @@ -30,98 +30,84 @@ private _time = systemTime;
["Logging", "Start", [LOGGING_VERSION, OPT_GELDZEIT_Fraktionauswahl, format ["%1-%2-%3 %4:%5:%6", _time select 0, _time select 1, _time select 2, _time select 3, _time select 4, _time select 5]]] call OPT_LOGGING_fnc_writelog;
["Mission", "Load", [0, 0, 0, missionName]] call OPT_LOGGING_fnc_writelog;

//Init Statussignale
GVAR(Mission_start) = false;
publicVariable QGVAR(Mission_start);

GVAR(FreeztimeEnde) = false;
publicVariable QGVAR(FreeztimeEnde);

GVAR(Waffenruhestart) = false;
publicVariable QGVAR(Waffenruhestart);

GVAR(WaffenruheEnde) = false;
publicVariable QGVAR(WaffenruheEnde);

GVAR(Spielzeitstart) = false;
publicVariable QGVAR(Spielzeitstart);

GVAR(SpielzeitEnde) = false;
publicVariable QGVAR(SpielzeitEnde);

GVAR(Endestart) = false;
publicVariable QGVAR(Endestart);
GVAR(GAMESTAGE) = GAMESTAGE_FREEZE;
publicVariable QGVAR(GAMESTAGE);

GVAR(playerList) = [];

//Waffenruhe
DFUNC(Waffenruhe) =
{
// Logeintrag
GVAR(FreeztimeEnde) = true;
publicVariable QGVAR(FreeztimeEnde);

GVAR(Waffenruhestart) = true;
publicVariable QGVAR(Waffenruhestart);

["Mission", "Truce", [0, 0, 0, missionName]] call OPT_LOGGING_fnc_writelog;

//Nachablauf Waffenruhe Spielzeit auslösen
[FUNC(Spielzeit), GVAR(TRUCETIME),""] call CLib_fnc_wait;
};

//Spielzeit
DFUNC(Spielzeit) =
["missionStarted",
{
// Logeintrag
GVAR(WaffenruheEnde) = true;
publicVariable QGVAR(WaffenruheEnde);

GVAR(Spielzeitstart) = true;
publicVariable QGVAR(Spielzeitstart);

// Missionsstart loggen
["Mission", "Start", [0, 0, 0, missionName]] call OPT_LOGGING_fnc_writelog;

// Nach Ablauf der Waffenruhe die Sektorenmarker von der Karte entfernen
[] call OPT_SECTORCONTROL_fnc_deletesectormarkers;

GVAR(PLAYTIMENETTO) = 0;

GVAR(PLAYTIMENETTO) = (GVAR(PLAYTIME) - GVAR(TRUCETIME) - GVAR(FREEZETIME));

//Nachablauf Spielzeit Ende auslösen
[FUNC(Mission_Ende), GVAR(PLAYTIMENETTO),""] call CLib_fnc_wait;
};

//Mission Ende
DFUNC(Mission_Ende) =
{
GVAR(SpielzeitEnde) = true;
publicVariable QGVAR(SpielzeitEnde);

GVAR(Endestart) = true;
publicVariable QGVAR(Endestart);

[] call FUNC(writePlayerList);

// Endpunktestand loggen
["Mission", "End", [OPT_SECTORCONTROL_nato_points, OPT_SECTORCONTROL_csat_points, OPT_SECTORCONTROL_aaf_points, missionName]] call OPT_LOGGING_fnc_writelog;

[EVENT_SPIELUHR_ENDBILDSCHIRM,[]] call CFUNC(globalEvent);
};

["missionStarted", {
// SERVER ONLY
// nicht time! time ist 0, da time Zeit von Missionsbeginn mitteilt. serverTime hingegen wird
// immer synchronisiert und beinhaltet Zeit seit Serverstart

GVAR(startTime) = serverTime;
publicVariable QGVAR(startTime); // gibt allen Clients die Startzeit des Servers bekannt

GVAR(Mission_start) = true;
publicVariable QGVAR(Mission_start);

// Nach Ablauf der Freeztime die Waffenruhe auslösen
[FUNC(Waffenruhe), GVAR(FREEZETIME),""] call CLib_fnc_wait;
publicVariable QGVAR(startTime);

GVAR(Timestamp_Waffenruhestart) = GVAR(startTime) + GVAR(FREEZETIME);
GVAR(Timestamp_Spielzeitstart) = GVAR(startTime) + GVAR(FREEZETIME) + GVAR(TRUCETIME);
GVAR(Timestamp_Spielzeitende) = GVAR(startTime) + GVAR(PLAYTIME); // Freeze- & Trucetime zählt zur Spielzeit dazu!

// Aktuellen Spielabschnitt setzen
[{
switch (GVAR(GAMESTAGE)) do
{
case GAMESTAGE_FREEZE:
{
// Nach Ablauf der Freezetime die Waffenruhe auslösen
if (serverTime > GVAR(Timestamp_Waffenruhestart)) then
{
GVAR(GAMESTAGE) = GAMESTAGE_TRUCE;
publicVariable QGVAR(GAMESTAGE);

// Gefreezte Spieler auftauen
{player enableSimulation true;} remoteExec ["call", -2];

// Logeintrag
["Mission", "Truce", [0, 0, 0, missionName]] call OPT_LOGGING_fnc_writelog;
};
};

case GAMESTAGE_TRUCE:
{
// Nach Ablauf der Waffenruhe die Spielzeit auslösen
if (serverTime > GVAR(Timestamp_Spielzeitstart)) then
{
GVAR(GAMESTAGE) = GAMESTAGE_WAR;
publicVariable QGVAR(GAMESTAGE);

// Missionsstart loggen
["Mission", "Start", [0, 0, 0, missionName]] call OPT_LOGGING_fnc_writelog;

// Nach Ablauf der Waffenruhe die Sektorenmarker von der Karte entfernen
[] call OPT_SECTORCONTROL_fnc_deletesectormarkers;
};
};

case GAMESTAGE_WAR:
{
// Nach Ablauf der Spielzeit das Ende auslösen
if (serverTime > GVAR(Timestamp_Spielzeitende)) then
{
GVAR(GAMESTAGE) = GAMESTAGE_END;
publicVariable QGVAR(GAMESTAGE);

// Spielerliste loggen
[] call FUNC(writePlayerList);

// Endpunktestand loggen
["Mission", "End", [OPT_SECTORCONTROL_nato_points, OPT_SECTORCONTROL_csat_points, OPT_SECTORCONTROL_aaf_points, missionName]] call OPT_LOGGING_fnc_writelog;

[EVENT_SPIELUHR_ENDBILDSCHIRM,[]] call CFUNC(globalEvent);
};
};

case GAMESTAGE_END:
{
// do nothing and watch people disconnecting...
};

default
{
GVAR(GAMESTAGE) = GAMESTAGE_FREEZE;
publicVariable QGVAR(GAMESTAGE);
};
};
}, 1, _this] call CFUNC(addPerFrameHandler);
}] call CFUNC(addEventhandler);
49 changes: 27 additions & 22 deletions addons/OPT/HUD/fn_updatehud.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Author: James
* Author: James, form
* script for updating HUD information each forEachMember
*
* Arguments:
Expand All @@ -16,9 +16,19 @@

disableSerialization;

// avoid CBA_fnc_formatElapsedTime because it shows "60" seconds from time to time...
TimeToString =
{
params ["_seconds"];
private _hours = floor (_seconds / 3600);
_seconds = _seconds - (_hours * 3600);
private _minutes = floor (_seconds / 60);
_seconds = _seconds - (_minutes * 60);
format ["%1:%2:%3", _hours, [_minutes, 2] call CBA_fnc_formatNumber, [floor _seconds , 2] call CBA_fnc_formatNumber];
};

//Anzeigen Steuerung im Dialog
[{

private _currentCutDisplay = uiNamespace getVariable "opt_hud_anzeige";
//--------------------- update players ------------------------------------------
private _control = _currentCutDisplay displayCtrl 5101;
Expand All @@ -43,7 +53,7 @@ disableSerialization;

default
{
ERROR_LOG("Updatehud: Fehlerhafte Datenübergabe - Keine Fraktionauswahl erkannt");
ERROR_LOG("Updatehud: Fehlerhafte Datenübergabe - Keine Fraktionauswahl erkannt");
};
};

Expand Down Expand Up @@ -81,7 +91,7 @@ disableSerialization;

default
{
ERROR_LOG("Updatehud: Fehlerhafte Datenübergabe - Keine Fraktionauswahl erkannt");
ERROR_LOG("UpdateHUD: Fehlerhafte Datenübergabe - Keine Fraktionauswahl erkannt");
};
};

Expand All @@ -93,35 +103,37 @@ disableSerialization;
//--------------------- update clock ---------------------------------------
_control = _currentCutDisplay displayCtrl 5105;

private "_timeStr";
private _timeElapsed = (serverTime - OPT_GELDZEIT_startTime);
private _playTime = OPT_GELDZEIT_PLAYTIME - _timeElapsed;
private _truceTime = (OPT_GELDZEIT_TRUCETIME + OPT_GELDZEIT_FREEZETIME) - _timeElapsed;
private _timeStr = "";
private _timeElapsed = serverTime - OPT_GELDZEIT_startTime;

if (OPT_GELDZEIT_Spielzeitstart) then
if (OPT_GELDZEIT_GAMESTAGE >= GAMESTAGE_WAR) then
{
// Mission gestartet - Zeige verbleibende Spielzeit
_timeLeft = [_playTime] call CBA_fnc_formatElapsedTime;
private _playTime = OPT_GELDZEIT_PLAYTIME - _timeElapsed;

if (_playTime > 0) then
{
_timeStr = format [MLOC(TIME_LEFT), _timeLeft];
_timeStr = format [MLOC(TIME_LEFT), [_playTime] call TimeToString];
_control ctrlSetTextColor [0.7, 0.7, 0.7, 1];
}
else
{
_timeStr = MLOC(TIME_END);
_control ctrlSetTextColor [1, 0, 0, 0.9];
};

// Färbe Uhr in den letzten 5 Minuten rot
if (_playTime < 300) then
{
_control ctrlSetTextColor [0.9, 0.2, 0.2, 1];
};
}
else
{
// Mission noch nicht gestartet - Zeige verbleibende Zeit der Waffenruhe
_timeLeft = [_truceTime] call CBA_fnc_formatElapsedTime;

private _truceTime = OPT_GELDZEIT_TRUCETIME + OPT_GELDZEIT_FREEZETIME - _timeElapsed;
if (_truceTime > 0) then
{
_timeStr = format [MLOC(TIME_CEASEFIRE), _timeLeft];
_timeStr = format [MLOC(TIME_CEASEFIRE), [_truceTime] call TimeToString];
_control ctrlSetTextColor [0.6, 0.1, 0, 1];
}
else
Expand All @@ -133,12 +145,5 @@ disableSerialization;

// Anzeige updaten
_control ctrlSetText _timeStr;

// Färbe Uhr in den letzten 5 Minuten rot
if (_playTime < 300) then
{
_control ctrlSetTextColor [0.9, 0.2, 0.2, 1];
};

_control ctrlShow true;
}, 1, _this] call CFUNC(addPerFrameHandler);
2 changes: 1 addition & 1 deletion addons/OPT/SECTORCONTROL/fn_Punkte.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GVAR(points_logtime) = 0;
GVAR(Punktecount) = [
{
// Logge und übertrage Punktestand, solange Spiel noch läuft
if ((OPT_GELDZEIT_Spielzeitstart) and (OPT_GELDZEIT_PLAYTIME - (serverTime - OPT_GELDZEIT_startTime) > 0)) then
if ((OPT_GELDZEIT_GAMESTAGE == GAMESTAGE_WAR) and (OPT_GELDZEIT_PLAYTIME - (serverTime - OPT_GELDZEIT_startTime) > 0)) then
{
// Falls es einen Dominator gibt -> Erhöhe Punkte +1, ansonsten spätestens alls 60 Sekunden einen Logeintrag
switch (GVAR(dominator)) do
Expand Down
4 changes: 2 additions & 2 deletions addons/OPT/SECTORCONTROL/fn_addflagmenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#include "macros.hpp"

if (OPT_GELDZEIT_Spielzeitstart) exitWith{};
if (OPT_GELDZEIT_GAMESTAGE >= GAMESTAGE_WAR) exitWith{};

GVAR(officer) =
[
Expand All @@ -39,7 +39,7 @@ if (typeOf player in GVAR(officer)) then
true,
true,
"",
"!OPT_GELDZEIT_Spielzeitstart"
"(OPT_GELDZEIT_GAMESTAGE <= 1)"
];

// inform player
Expand Down
2 changes: 1 addition & 1 deletion addons/OPT/SECTORCONTROL/fn_captureflagcondition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (_flag isEqualTo objNull or _unit isEqualTo objNull) exitWith{false};
// in Restspielzeit gezogen werden
// nur von der anderen Seite
vehicle _unit == _unit and
OPT_GELDZEIT_Spielzeitstart and
OPT_GELDZEIT_GAMESTAGE == GAMESTAGE_WAR and
(_flag distance player) <= GVAR(flagDistanceToPlayer) and
OPT_GELDZEIT_PLAYTIME - (serverTime - OPT_GELDZEIT_startTime) > 0 and
(side _unit != _flag getVariable ['owner', sideUnknown])
6 changes: 3 additions & 3 deletions addons/OPT/SECTORCONTROL/fn_serverInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ DFUNC(startflagsetup) =
[sideUnknown, objNull] call FUNC(setFlagOwner);
};

["missionStarted", {

["missionStarted",
{
// Finale Fahnenmasten und Markierungen setzen
[] call FUNC(setupflagpoles);
[FUNC(startflagsetup), {OPT_GELDZEIT_Spielzeitstart}, "Awesome Delay"] call CLib_fnc_waitUntil;
[FUNC(startflagsetup), {(OPT_GELDZEIT_GAMESTAGE == GAMESTAGE_WAR)}, "Awesome Delay"] call CLib_fnc_waitUntil;
}] call CFUNC(addEventhandler);

// Sektorenmarker auf die Karte zeichnen sobald die Mission durchgeladen ist
Expand Down
2 changes: 1 addition & 1 deletion addons/OPT/SECTORCONTROL/fn_setupflag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Flaggen-Seite loggen
true, // showWindow
true, // hideOnUse
"", // shortcut
"(vehicle player == player and OPT_GELDZEIT_Spielzeitstart and ((OPT_GELDZEIT_PLAYTIME - (serverTime - OPT_GELDZEIT_startTime)) > 0) and (playerside != _target getVariable 'owner'))",
"(vehicle player == player and (OPT_GELDZEIT_GAMESTAGE == 2) and ((OPT_GELDZEIT_PLAYTIME - (serverTime - OPT_GELDZEIT_startTime)) > 0) and (playerside != _target getVariable 'owner'))",
GVAR(flagDistanceToPlayer) // radius
]
] remoteExecCall ["addAction", -2, true];
Expand Down
Loading

0 comments on commit f7cbc7a

Please sign in to comment.