diff --git a/docs/sdk/scenario/scenario.xml b/docs/sdk/scenario/scenario.xml
index 755b7cde1..58708dd91 100644
--- a/docs/sdk/scenario/scenario.xml
+++ b/docs/sdk/scenario/scenario.xml
@@ -122,9 +122,14 @@
FoWEnabled
- Integer
+ Bool
0 or 1. If 0, FoW is disabled, and the whole landscape is visible. Default 1.
+
+ EvaluateOnAbort
+ Bool
+ If enabled, the game will be evaluated even when aborted by the player. This is intended for scenarios like Tower of Despair that save progress in players. Default false.
+
diff --git a/src/game/C4Game.cpp b/src/game/C4Game.cpp
index 50c468c09..acb8433f4 100644
--- a/src/game/C4Game.cpp
+++ b/src/game/C4Game.cpp
@@ -1458,6 +1458,7 @@ void C4Game::Default()
HaltCount=0;
fReferenceDefinitionOverride=false;
Evaluated=false;
+ EvaluateOnAbort=false;
TimeGo=false;
Time=0;
StartTime=0;
@@ -2264,6 +2265,8 @@ bool C4Game::InitGame(C4Group &hGroup, InitMode init_mode, bool fLoadSky, C4Valu
{
RoundResults.Init();
}
+ // Per-scenario flag, ignored in sections.
+ EvaluateOnAbort = C4S.Game.EvaluateOnAbort;
}
// Denumerate game data pointers
@@ -3677,6 +3680,12 @@ void C4Game::Abort(bool fApproved)
return;
}
}
+ if (EvaluateOnAbort)
+ {
+ // Scenario forces evaluation. This is intended for scenarios that
+ // always save progress in the players, such as Tower of Despair.
+ Evaluate();
+ }
// hard-abort: eval league and quit
// manually evaluate league
Players.RemoveLocal(true, true);
diff --git a/src/game/C4Game.h b/src/game/C4Game.h
index 50e953c4d..c41cc4225 100644
--- a/src/game/C4Game.h
+++ b/src/game/C4Game.h
@@ -112,6 +112,7 @@ public:
int32_t HaltCount;
bool InitialPlayersJoined; // true after the InitializeFinal callback has been made
bool GameOver;
+ bool EvaluateOnAbort; // set in Scenario.txt, copied here because of sections
bool Evaluated;
bool GameOverDlgShown;
bool fScriptCreatedObjects;
diff --git a/src/landscape/C4Scenario.cpp b/src/landscape/C4Scenario.cpp
index e5f256702..e6c342fbf 100644
--- a/src/landscape/C4Scenario.cpp
+++ b/src/landscape/C4Scenario.cpp
@@ -217,6 +217,7 @@ void C4SGame::Default()
Goals.Clear();
Rules.Clear();
FoWEnabled = true;
+ EvaluateOnAbort = false;
}
void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection)
@@ -228,10 +229,11 @@ void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection)
pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapePushPull), "LandscapePushPull", false));
pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapeInsertThrust), "LandscapeInsertThrust",true));
- pComp->Value(mkNamingAdapt(mkParAdapt(Mode, StdCompiler::RCT_IdtfAllowEmpty), "Mode", StdCopyStrBuf()));
- pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
- pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList()));
- pComp->Value(mkNamingAdapt(FoWEnabled, "FoWEnabled", true));
+ pComp->Value(mkNamingAdapt(mkParAdapt(Mode, StdCompiler::RCT_IdtfAllowEmpty), "Mode", StdCopyStrBuf()));
+ pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
+ pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList()));
+ pComp->Value(mkNamingAdapt(FoWEnabled, "FoWEnabled", true));
+ pComp->Value(mkNamingAdapt(EvaluateOnAbort, "EvaluateOnAbort", false));
}
void C4SPlrStart::Default()
diff --git a/src/landscape/C4Scenario.h b/src/landscape/C4Scenario.h
index 9a4ab4866..d3aaf6e89 100644
--- a/src/landscape/C4Scenario.h
+++ b/src/landscape/C4Scenario.h
@@ -126,6 +126,8 @@ public:
C4SRealism Realism;
+ bool EvaluateOnAbort;
+
public:
bool IsMelee();
void Default();