Root/alex4/patches/030-files-n-paths.patch

1Index: alex4src/src/main.c
2===================================================================
3--- alex4src.orig/src/main.c 2011-06-07 12:24:01.000000000 +0200
4+++ alex4src/src/main.c 2011-06-08 22:27:58.000000000 +0200
5@@ -157,7 +157,7 @@
6     va_list ptr; /* get an arg pointer */
7      FILE *fp;
8     
9- fp = fopen("log.txt", "at");
10+ fp = fopen("/var/log/alex4.log", "at");
11     if (fp) {
12         /* initialize ptr to point to the first argument after the format string */
13         va_start(ptr, format);
14@@ -624,6 +624,12 @@
15     gui_bg_color = 254;
16 }
17 
18+static char *fixpath(const char *name)
19+{
20+ static char buf[128];
21+ return canonicalize_filename(buf, name, sizeof(buf));
22+}
23+
24 // init the game
25 int init_game(const char *map_file) {
26     PACKFILE *pf;
27@@ -637,7 +643,7 @@
28     log2file(" initializing allegro");
29     text_mode(-1);
30     garble_string(init_string, 53);
31- set_config_file("alex4.ini");
32+ set_config_file("/etc/alex4.ini");
33     set_window_close_button(FALSE);
34     
35     // install timers
36@@ -732,7 +738,7 @@
37     // load data
38     log2file(" loading data");
39     packfile_password(init_string);
40- data = load_datafile("data/data.dat");
41+ data = load_datafile("/usr/share/alex4/data.dat");
42     packfile_password(NULL);
43     if (data == NULL) {
44         log2file(" *** failed");
45@@ -742,7 +748,7 @@
46 
47     // load options
48     log2file(" loading options");
49- pf = pack_fopen("alex4.sav", "rp");
50+ pf = pack_fopen(fixpath("~/.alex4.sav"), "rp");
51     if (pf) {
52         load_options(&options, pf);
53         pack_fclose(pf);
54@@ -754,7 +760,7 @@
55 
56     // loading highscores
57     log2file(" loading hiscores");
58- pf = pack_fopen("alex4.hi", "rp");
59+ pf = pack_fopen(fixpath("~/.alex4.hi"), "rp");
60     if (pf) {
61         load_hisc_table(hisc_table, pf);
62         load_hisc_table(hisc_table_space, pf);
63@@ -790,7 +796,7 @@
64         log2file(" loading original maps");
65         packfile_password(init_string);
66         num_levels = -1; // skip end object when counting
67- maps = load_datafile_callback("data/maps.dat", count_maps_callback);
68+ maps = load_datafile_callback("/usr/share/alex4/maps.dat", count_maps_callback);
69         packfile_password(NULL);
70         if (maps == NULL) {
71             log2file(" *** failed");
72@@ -899,9 +905,9 @@
73         if (get_config_int("sound", "use_sound_datafile", 1)) {
74             log2file(" loading sound datafile");
75             packfile_password(init_string);
76- sfx_data = load_datafile("data/sfx_44.dat");
77+ sfx_data = load_datafile("/usr/share/alex4/sfx_44.dat");
78             if (sfx_data == NULL) {
79- sfx_data = load_datafile("data/sfx_22.dat");
80+ sfx_data = load_datafile("/usr/share/alex4/sfx_22.dat");
81                 log2file(" sfx_44.dat not found");
82                 s = 0;
83             }
84@@ -1018,14 +1024,14 @@
85     // only save if everything was inited ok!
86     if (init_ok) {
87         log2file(" saving options");
88- pf = pack_fopen("alex4.sav", "wp");
89+ pf = pack_fopen(fixpath("~/.alex4.sav"), "wp");
90         if (pf) {
91             save_options(&options, pf);
92             pack_fclose(pf);
93         }
94         
95         log2file(" saving highscores");
96- pf = pack_fopen("alex4.hi", "wp");
97+ pf = pack_fopen(fixpath("~/.alex4.hi"), "wp");
98         if (pf) {
99             save_hisc_table(hisc_table, pf);
100             save_hisc_table(hisc_table_space, pf);
101@@ -1372,7 +1378,7 @@
102     if (space) {
103         // get space bg
104         packfile_password(init_string);
105- df = load_datafile_object("data/a45.dat", "BG1");
106+ df = load_datafile_object("/usr/share/alex4/a45.dat", "BG1");
107         packfile_password(NULL);
108         if (df != NULL) {
109             bg = df->dat;
110@@ -3008,7 +3014,7 @@
111     // get working directory
112     get_executable_name(full_path, 1024);
113     replace_filename(working_directory, full_path, "", 1024);
114- chdir(working_directory);
115+ /* chdir(working_directory); */
116 
117 
118     // start logfile
119

Archive Download this file



interactive