Store kills/items/secrets in save comment only if visible on HUD

This prevents spoiling levels when the HUD information is disabled.

This change is not retroactive: it has no effect on existing savegames.
You need to save again for this change to have an effect.
This commit is contained in:
Hugo Locurcio 2023-09-21 01:57:21 +02:00 committed by Rachael Alexanderson
parent 5870ec2e7a
commit ffcfec66b3

View file

@ -2275,6 +2275,9 @@ static void PutSaveWads (FSerializer &arc)
}
}
EXTERN_CVAR(Bool, hud_showmonsters)
EXTERN_CVAR(Bool, hud_showitems)
EXTERN_CVAR(Bool, hud_showsecrets)
static void PutSaveComment (FSerializer &arc)
{
int levelTime;
@ -2291,8 +2294,30 @@ static void PutSaveComment (FSerializer &arc)
levelTime = primaryLevel->time / TICRATE;
comment.AppendFormat("%s: %02d:%02d:%02d\n", time, levelTime/3600, (levelTime%3600)/60, levelTime%60);
// Append kills/items/secrets
comment.AppendFormat("K: %d/%d - I: %d/%d - S: %d/%d\n", primaryLevel->killed_monsters, primaryLevel->total_monsters, primaryLevel->found_items, primaryLevel->total_items, primaryLevel->found_secrets, primaryLevel->total_secrets);
// Append kills/items/secrets (only if visible on HUD to avoid spoiling levels)
bool hasStatOnLine = false;
if (hud_showmonsters) {
comment.AppendFormat("K: %d/%d", primaryLevel->killed_monsters, primaryLevel->total_monsters);
hasStatOnLine = true;
}
if (hud_showitems) {
if (hasStatOnLine) {
comment.AppendFormat(" - ");
}
comment.AppendFormat("I: %d/%d", primaryLevel->found_items, primaryLevel->total_items);
hasStatOnLine = true;
}
if (hud_showsecrets) {
if (hasStatOnLine) {
comment.AppendFormat(" - ");
}
comment.AppendFormat("S: %d/%d", primaryLevel->found_secrets, primaryLevel->total_secrets);
hasStatOnLine = true;
}
if (hasStatOnLine) {
comment.AppendFormat("\n");
}
// Append player health and armor
const char* const health = "Health";// GStrings("SAVECOMMENT_HEALTH");