diff urogue/save.c @ 272:1db299e868b8

UltraRogue: add the autosave feature. UltraRogue now automatically saves the game when SIGHUP or SIGTERM is received.
author John "Elwin" Edwards
date Sun, 03 Sep 2017 19:58:22 -0400
parents ac42afd962e4
children
line wrap: on
line diff
--- a/urogue/save.c	Sun Mar 05 20:14:11 2017 -0500
+++ b/urogue/save.c	Sun Sep 03 19:58:22 2017 -0400
@@ -115,6 +115,18 @@
     }
 }
 
+void
+auto_save(int sig)
+{
+    FILE *savef;
+
+    md_ignore_signals();
+    if (file_name[0] && (savef = fopen(file_name, "w"))) {
+        save_file(savef);
+    }
+    exit(0);
+}
+
 int
 restore(char *file)
 {