1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
diff -ru formido-1.0.orig/src/blend.cpp formido-1.0/src/blend.cpp
--- formido-1.0.orig/src/blend.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/blend.cpp 2004-01-30 02:22:04.000000000 -0800
@@ -218,7 +218,7 @@
// 8-bit tables
else {
// First, try to load tables from 'data/alpha8.tab'
- FILE *fin = fopen("data/alpha8.tab", "rb");
+ FILE *fin = fopen("./alpha8.tab", "rb");
if(fin) {
// Load the tables
fread(a_table8, sizeof(a_table8), 1, fin);
@@ -251,7 +251,7 @@
}
// Save the table to disk
- FILE *fout = fopen("data/alpha8.tab", "wb");
+ FILE *fout = fopen("./alpha8.tab", "wb");
if(fout) {
fwrite(a_table8, sizeof(a_table8), 1, fout);
fclose(fout);
diff -ru formido-1.0.orig/src/config.cpp formido-1.0/src/config.cpp
--- formido-1.0.orig/src/config.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/config.cpp 2004-01-30 00:26:31.000000000 -0800
@@ -30,8 +30,10 @@
void load_config(char *file, CONFIG *conf) {
FILE *f = fopen(file, "rt");
- if(!f)
- error_msg("Unable to load config file: %s!", file);
+ if(!f) {
+ if (!(f = fopen(CONFIG(file), "rt")))
+ error_msg("Unable to load config file: %s!", file);
+ }
fscanf(f, "video_mode_color_depth = %d\n", &(conf->vid_color_depth));
fscanf(f, "video_mode_fullscreen = %d\n", &(conf->fullscreen));
diff -ru formido-1.0.orig/src/game.cpp formido-1.0/src/game.cpp
--- formido-1.0.orig/src/game.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/game.cpp 2004-01-30 00:31:12.000000000 -0800
@@ -173,15 +173,15 @@
char file[100] = "";
int num = 0;
- sprintf(file, "shot%03d.bmp", num);
+ sprintf(file, "./shot%03d.bmp", num);
game_paused = true;
// Check if exists
- FILE *f = fopen(CONFIG(file), "r");
+ FILE *f = fopen(file, "r");
if(!f) {
// Doesn't exist, save it.
- SDL_SaveBMP(screen, CONFIG(file));
+ SDL_SaveBMP(screen, file);
}
else {
fclose(f);
@@ -189,14 +189,14 @@
// Exists, choose another name
while(num < 1000) {
num++;
- sprintf(file, "shot%03d.bmp", num);
+ sprintf(file, "./shot%03d.bmp", num);
// Check if exists
- f = fopen(CONFIG(file), "r");
+ f = fopen(file, "r");
if(!f) {
// Doesn't exist, save it.
- SDL_SaveBMP(screen, CONFIG(file));
+ SDL_SaveBMP(screen, file);
break;
}
else
diff -ru formido-1.0.orig/src/init.cpp formido-1.0/src/init.cpp
--- formido-1.0.orig/src/init.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/init.cpp 2004-01-30 00:23:08.000000000 -0800
@@ -80,8 +80,7 @@
void init_sdl() {
// Load the config
- //load_config("formido.cfg", &config);
- load_config(CONFIG("formido.cfg"), &config);
+ load_config("formido.cfg", &config);
// Initialize SDL with video and audio support
if(config.sound) {
diff -ru formido-1.0.orig/src/main.cpp formido-1.0/src/main.cpp
--- formido-1.0.orig/src/main.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/main.cpp 2004-01-30 00:29:09.000000000 -0800
@@ -23,6 +23,9 @@
*/
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
@@ -272,6 +275,15 @@
// The good old main()
int main(int argc, char *argv[]) {
+ if (!getenv("HOME")) {
+ error_msg("Environment variable HOME not set. Exiting.");
+ }
+ chdir(getenv("HOME"));
+ /* Don't check the return here because it may already exist. */
+ mkdir(".formido", 0744);
+ if (chdir(".formido") != 0) {
+ error_msg("Failed to change directories to ~/.formido");
+ }
// Initialize SDL
init_sdl();
@@ -359,8 +371,7 @@
// Save the config
- //save_config("formido.cfg", &config);
- save_config(CONFIG("formido.cfg"), &config);
+ save_config("./formido.cfg", &config);
return 0;
}
diff -ru formido-1.0.orig/src/menu.cpp formido-1.0/src/menu.cpp
--- formido-1.0.orig/src/menu.cpp 2003-11-07 10:59:01.000000000 -0800
+++ formido-1.0/src/menu.cpp 2004-01-30 00:23:22.000000000 -0800
@@ -262,7 +262,7 @@
menu_id = MENU_ID_MAIN;
menu_item = MENU_GAME_SETTINGS;
// Load back the initial settings from config
- load_config(CONFIG("formido.cfg"), &config);
+ load_config("formido.cfg", &config);
Mix_VolumeMusic(config.music_vol);
}
else if(menu_id == MENU_ID_HALL_OF_FAME) {
@@ -305,7 +305,7 @@
menu_item = MENU_GAME_SETTINGS;
menu_id = MENU_ID_MAIN;
// Save config
- save_config(CONFIG("formido.cfg"), &config);
+ save_config("./formido.cfg", &config);
break;
// Keys
|