shithub: choc

Download patch

ref: 0b50fbde6a49250d4372a3255b1e1fd451326abe
parent: 0fe9bbcffeb7f7fdb032642127cca54b7d965227
author: Mike Swanson <mikeonthecomputer@gmail.com>
date: Wed Feb 14 15:58:27 EST 2018

Print a more useful error about which savegame failed to load

Amends the prior commit, also fixes the formatting for the I_Error()
function call to represent the preferred format outlined in HACKING.

Hexen now has two locations that can fail out with an error.  One in
CopySaveSlot that should fail when a hex?.hxs file does not exist, as
specified via the -loadgame parameter.  A second in the SV_OpenRead
function that should probably never get triggered after the first; it
would mean the hex6.hxs file wasn't created or somehow deleted in the
middle of the function.  (Chocolate Hexen race condition exploits,
anyone?)

--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -1553,7 +1553,7 @@
 
     if (save_stream == NULL)
     {
-        I_Error ("Could not load savegame");
+        I_Error("Could not load savegame %s", savename);
     }
 
     savegame_error = false;
--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -69,7 +69,7 @@
 
     if (SaveGameFP == NULL)
     {
-        I_Error ("Could not load savegame");
+        I_Error("Could not load savegame %s", filename);
     }
 }
 
--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -3238,6 +3238,10 @@
                    "%shex%d.hxs", SavePath, destSlot);
         CopyFile(sourceName, destName);
     }
+    else
+    {
+        I_Error("Could not load savegame %s", sourceName);
+    }
 }
 
 //==========================================================================
@@ -3344,9 +3348,10 @@
 {
     SavingFP = fopen(fileName, "rb");
 
+    // Should never happen, only if hex6.hxs cannot ever be created.
     if (SavingFP == NULL)
     {
-        I_Error ("Could not load savegame");
+        I_Error("Could not load savegame %s", fileName);
     }
 }