Lines 66-71
Link Here
|
66 |
GCTRL_RANKING_EXEC, |
66 |
GCTRL_RANKING_EXEC, |
67 |
GCTRL_RANKING_EXIT, |
67 |
GCTRL_RANKING_EXIT, |
68 |
} |
68 |
} |
|
|
69 |
|
70 |
public static char[] pref_dir() |
71 |
{ |
72 |
char * home = getenv("HOME"); |
73 |
if (home is null) |
74 |
throw new Error("HOME environment variable not defined"); |
75 |
char[] dir = std.string.toString(home) ~ "/.reflectball"; |
76 |
char[] dir2 = std.string.toString(home) ~ "/.reflectball/replay"; |
77 |
try { |
78 |
mkdir(dir); |
79 |
mkdir(dir2); |
80 |
} catch (FileException e) { |
81 |
} |
82 |
return dir; |
83 |
} |
84 |
|
69 |
|
85 |
|
70 |
void TSKgctrl(int id) |
86 |
void TSKgctrl(int id) |
71 |
{ |
87 |
{ |
Lines 78-84
Link Here
|
78 |
replay_data.length = 8; |
94 |
replay_data.length = 8; |
79 |
} |
95 |
} |
80 |
replay_fmax = 0; |
96 |
replay_fmax = 0; |
81 |
fpath = listdir(std.path.curdir ~ "/replay"); |
97 |
fpath = listdir(pref_dir() ~ "/" ~ "replay"); |
82 |
for(int i = 0; i < fpath.length; i++){ |
98 |
for(int i = 0; i < fpath.length; i++){ |
83 |
if(fnmatch(fpath[i], "rlb??????????????.rep")){ |
99 |
if(fnmatch(fpath[i], "rlb??????????????.rep")){ |
84 |
replay_file.length = fcnt + 1; |
100 |
replay_file.length = fcnt + 1; |
Lines 118-124
Link Here
|
118 |
replay_data[i] = replay[i]; |
134 |
replay_data[i] = replay[i]; |
119 |
} |
135 |
} |
120 |
char[] fname; |
136 |
char[] fname; |
121 |
fname = format("./replay/rlb%04d%02d%02d%02d%02d%02d.rep" |
137 |
fname = format(pref_dir() ~ "/" ~ "/replay/rlb%04d%02d%02d%02d%02d%02d.rep" |
122 |
,year |
138 |
,year |
123 |
,month |
139 |
,month |
124 |
,date |
140 |
,date |
Lines 152-159
Link Here
|
152 |
} |
168 |
} |
153 |
|
169 |
|
154 |
void init_highscore(){ |
170 |
void init_highscore(){ |
155 |
if(exists("score.dat")){ |
171 |
if(exists(pref_dir() ~ "/" ~ "score.dat")){ |
156 |
hi_score = cast(int[])read("score.dat"); |
172 |
hi_score = cast(int[])read(pref_dir() ~ "/" ~ "score.dat"); |
157 |
}else{ |
173 |
}else{ |
158 |
hi_score.length = RANKING_MAX * RANKING_RECORD; |
174 |
hi_score.length = RANKING_MAX * RANKING_RECORD; |
159 |
for(int i = 0; i < RANKING_MAX; i++){ |
175 |
for(int i = 0; i < RANKING_MAX; i++){ |
Lines 161-167
Link Here
|
161 |
hi_score[i * RANKING_RECORD + RANKING_BREAK] = 0; |
177 |
hi_score[i * RANKING_RECORD + RANKING_BREAK] = 0; |
162 |
hi_score[i * RANKING_RECORD + RANKING_DESTR] = 0; |
178 |
hi_score[i * RANKING_RECORD + RANKING_DESTR] = 0; |
163 |
} |
179 |
} |
164 |
write("score.dat", cast(void[])hi_score); |
180 |
write(pref_dir() ~ "/" ~ "score.dat", cast(void[])hi_score); |
165 |
} |
181 |
} |
166 |
} |
182 |
} |
167 |
|
183 |
|
Lines 178-184
Link Here
|
178 |
hi_score[i * RANKING_RECORD + RANKING_SCORE] = score; |
194 |
hi_score[i * RANKING_RECORD + RANKING_SCORE] = score; |
179 |
hi_score[i * RANKING_RECORD + RANKING_BREAK] = brk_ship; |
195 |
hi_score[i * RANKING_RECORD + RANKING_BREAK] = brk_ship; |
180 |
hi_score[i * RANKING_RECORD + RANKING_DESTR] = enemy_dst; |
196 |
hi_score[i * RANKING_RECORD + RANKING_DESTR] = enemy_dst; |
181 |
write("score.dat", cast(void[])hi_score); |
197 |
write(pref_dir() ~ "/" ~ "score.dat", cast(void[])hi_score); |
182 |
break; |
198 |
break; |
183 |
} |
199 |
} |
184 |
} |
200 |
} |