A new user interface for you! Read more...

File tumiki-fighters-dotfile.patch of Package tumiki-fighters

# Copyright (C) 2007  Peter De Wachter <pdewacht@gmail.com>
# Distributed under the same license as the game. See debian/copyright.

Index: tf/src/abagames/tf/prefmanager.d
===================================================================
--- tf.orig/src/abagames/tf/prefmanager.d
+++ tf/src/abagames/tf/prefmanager.d
@@ -6,6 +6,8 @@
 module abagames.tf.prefmanager;
 
 private import std.stream;
+private import std.string;
+private import std.c.stdlib;
 private import abagames.util.prefmanager;
 
 /**
@@ -14,7 +16,7 @@ private import abagames.util.prefmanager
 public class PrefManager: abagames.util.prefmanager.PrefManager {
  public:
   static const int VERSION_NUM = 20;
-  static const char[] PREF_FILE = "tf.prf";
+  static const char[] PREF_FILE = ".tumiki-fighters.prf";
   static const int RANKING_NUM = 10;
   static const int DEFAULT_HISCORE = 10000;
   RankingItem[RANKING_NUM] ranking;
@@ -24,6 +26,13 @@ public class PrefManager: abagames.util.
       ri = new RankingItem;
   }
 
+  public static char[] home_dir() {
+    char * home = getenv("HOME");
+    if (home is null)
+      throw new Error("HOME environment variable is not defined");
+    return std.string.toString(home);
+  }
+
   private void init() {
     int sc = DEFAULT_HISCORE * RANKING_NUM;
     foreach (RankingItem ri; ranking) {
@@ -37,13 +46,13 @@ public class PrefManager: abagames.util.
     auto File fd = new File;
     try {
       int ver;
-      fd.open(PREF_FILE);
+      fd.open(home_dir() ~ "/" ~ PREF_FILE);
       fd.read(ver);
       if (ver != VERSION_NUM)
 	throw new Error("Wrong version num");
       foreach (RankingItem ri; ranking)
 	ri.load(fd);
-    } catch (Error e) {
+    } catch (Exception e) {
       init();
     } finally {
       fd.close();
@@ -52,7 +61,7 @@ public class PrefManager: abagames.util.
 
   public void save() {
     auto File fd = new File;
-    fd.create(PREF_FILE);
+    fd.create(home_dir() ~ "/" ~ PREF_FILE);
     fd.write(VERSION_NUM);
     foreach (RankingItem ri; ranking)
       ri.save(fd);