changeset 263:08057be02f47

UltraRogue: make scorefile location configurable.
author John "Elwin" Edwards
date Wed, 15 Feb 2017 20:38:12 -0500
parents c7c6c5a7d840
children 778938a5c21d
files urogue/main.c urogue/rogue.h urogue/state.c
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/urogue/main.c	Tue Feb 14 20:42:33 2017 -0500
+++ b/urogue/main.c	Wed Feb 15 20:38:12 2017 -0500
@@ -27,6 +27,7 @@
 #include "rogue.h"
 
 #define SAVEDIR "."
+#define SCOREFILE "/var/local/games/roguelike/urogue.scr"
 
 FILE *fd_score = NULL;
 
@@ -94,13 +95,21 @@
 
     /* Get default score file */
 
+#ifdef SCOREFILE
+    strncpy(score_file, SCOREFILE, 2*LINELEN);
+    score_file[2*LINELEN - 1] = '\0';
+#else
     strcpy(score_file, "urogue.scr");
+#endif
 
     fd_score = fopen(score_file, "r+");
 
     if (fd_score == NULL)
         fd_score = fopen(score_file, "a+");
 
+    if (!use_savedir)
+        md_normaluser();
+
     if ((env = getenv("OPTIONS")) != NULL)
         parse_opts(env);
 
--- a/urogue/rogue.h	Tue Feb 14 20:42:33 2017 -0500
+++ b/urogue/rogue.h	Wed Feb 15 20:38:12 2017 -0500
@@ -1811,6 +1811,7 @@
 void md_srandom(long seed);
 int md_readchar(WINDOW *win);
 int md_getuid(void);
+void md_normaluser(void);
 
 #define NOOP(x) (x += 0)
 #define CCHAR(x) ( (char) (x & A_CHARTEXT) )
--- a/urogue/state.c	Tue Feb 14 20:42:33 2017 -0500
+++ b/urogue/state.c	Wed Feb 15 20:38:12 2017 -0500
@@ -1436,7 +1436,8 @@
     // The file_name stored in the file no longer replaces its actual name.
     ur_free(str);
     str = ur_read_string(savef);
-    strcpy(score_file,str);
+    if (!use_savedir)
+        strcpy(score_file,str);
     ur_free(str);
 
     DUMPSTRING