Address Gitlib issu #57: Resume can't open save file...
[open-adventure.git] / saveresume.c
index eab902ab8036aa68a960c7d8d4ea23095c8cdc69..15d14c1472dbbdc09b784581ee30f9e3c9fd1d80 100644 (file)
 #include "advent.h"
 #include "dungeon.h"
 
-#define VRSION 28      /* bump on save format change */
+/*
+ * Bump on save format change.
+ *
+ * Note: Verify that the tests run clean before bumping this, then rebuild the check
+ * files afterwards.  Otherwise you will get a spurious failure due to the old version
+ * having been generated into a check file.
+ */
+#define VRSION 29
 
 /*
  * If you change the first three members, the resume function may not properly
@@ -101,6 +108,9 @@ int resume(void)
 
     while (fp == NULL) {
         char* name = readline("\nFile name: ");
+       // Autocomplete can leave the input with an extra traoling space.
+       if (name != NULL && strlen(name) > 0 && name[strlen(name) - 1] == ' ')
+           name[strlen(name) - 1] = '\0';
         if (name == NULL)
             return GO_TOP;
         fp = fopen(name, READ_MODE);