Add EvaluateOnAbort scenario flag for Tower of Despair

In Tower of Despair, the scenario saves per-room progress in the
player files. Players win individual rooms, but never the whole
scenario. Consequently, they currently have to give up to make sure
they don't lose their progress. This is not intuitive at all. With the
new flag enabled, players will be saved even if the scenario is aborted.
master
Lukas Werling 2018-02-18 21:46:56 +01:00
parent fa3e8c2a50
commit 4a3c9f2fc2
5 changed files with 24 additions and 5 deletions

View File

@ -122,9 +122,14 @@
</row>
<row>
<col>FoWEnabled</col>
<col>Integer</col>
<col>Bool</col>
<col>0 or 1. If 0, FoW is disabled, and the whole landscape is visible. Default 1.</col>
</row>
<row>
<col>EvaluateOnAbort</col>
<col>Bool</col>
<col>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.</col>
</row>
</table>
</text>
<text>

View File

@ -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);

View File

@ -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;

View File

@ -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()

View File

@ -126,6 +126,8 @@ public:
C4SRealism Realism;
bool EvaluateOnAbort;
public:
bool IsMelee();
void Default();