From 56c2bd018d9b32ac7abf855f70aefd8c3189673f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 3 Feb 2023 14:36:55 +0100 Subject: [PATCH] Add more information in saved game comments Save games now store kills/items/secrets and player health/armor in the comment string, which is displayed in the save/load game menu. This change is not retroactive: old savegames will not display this information until they are overwritten. --- src/g_game.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index f68fca225..f686a573b 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2289,7 +2289,25 @@ static void PutSaveComment (FSerializer &arc) // Append elapsed time const char *const time = GStrings("SAVECOMMENT_TIME"); levelTime = primaryLevel->time / TICRATE; - comment.AppendFormat("%s: %02d:%02d:%02d", time, levelTime/3600, (levelTime%3600)/60, levelTime%60); + 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 player health and armor + const char *const health = GStrings("SAVECOMMENT_HEALTH"); + const char *const armor = GStrings("SAVECOMMENT_ARMOR"); + int armorAmount = 0; + auto basicArmorItem = primaryLevel->Players[consoleplayer]->mo->FindInventory(NAME_BasicArmor); + if (basicArmorItem) { + armorAmount += basicArmorItem->IntVar(NAME_Amount); + } + auto hexenArmorItem = primaryLevel->Players[consoleplayer]->mo->FindInventory(NAME_HexenArmor); + if (hexenArmorItem) { + double *Slots = (double*)hexenArmorItem->ScriptVar(NAME_Slots, nullptr); + armorAmount += Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4]; + } + comment.AppendFormat("%s: %d - %s: %d", health, primaryLevel->Players[consoleplayer]->mo->health, armor, armorAmount); // Write out the comment arc.AddString("Comment", comment);