File tree 7 files changed +34
-5
lines changed
7 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -1095,7 +1095,7 @@ int main(int argc,char **argv)
1095
1095
printf ("Started WinSock version %X.%02X\n" , wd .wVersion /0x100 , wd .wVersion & 0xFF );
1096
1096
#endif
1097
1097
1098
-
1098
+ chdir_to_data_files ();
1099
1099
ERROR ("Initialization...\n" );
1100
1100
1101
1101
last_obj = & objects ;
Original file line number Diff line number Diff line change @@ -2223,7 +2223,7 @@ int main(int argc,char **argv)
2223
2223
printf ("Started WinSock version %X.%02X\n" , wd .wVersion /0x100 , wd .wVersion & 0xFF );
2224
2224
#endif
2225
2225
2226
-
2226
+ chdir_to_data_files ();
2227
2227
#ifdef XWINDOW
2228
2228
x_display_name = 0 ;
2229
2229
x_font_name = 0 ;
Original file line number Diff line number Diff line change @@ -34,9 +34,7 @@ AC_STRUCT_TM
34
34
dnl Checks for library functions.
35
35
AC_PROG_GCC_TRADITIONAL
36
36
AC_TYPE_SIGNAL
37
- AC_CHECK_FUNCS(gettimeofday select strtol strtoul getopt)
38
-
39
- AC_CHECK_FUNCS(psignal)
37
+ AC_CHECK_FUNCS(gettimeofday select strtol strtoul getopt psignal access)
40
38
41
39
AC_CHECK_FUNC(random, cf_result=yes, cf_result=no)
42
40
if test "$cf_result" = no; then
Original file line number Diff line number Diff line change 6
6
#include "config.h"
7
7
#endif
8
8
9
+ #ifdef HAVE_ACCESS
10
+ # ifdef HAVE_UNISTD_H
11
+ # include <unistd.h>
12
+ # endif
13
+ #endif
14
+
9
15
#include "data.h"
10
16
#include "cfg.h"
11
17
#include "hash.h"
@@ -623,3 +629,25 @@ char* md5_level(int level_num)
623
629
mem_free (result );
624
630
return q ;
625
631
}
632
+
633
+ /* returns 1 if the file is readable */
634
+ static int r_access (const char * filename )
635
+ {
636
+ #ifdef HAVE_ACCESS
637
+ return !access (filename , R_OK );
638
+ #else
639
+ FILE * f = fopen (filename , "r" );
640
+ if (f ) {
641
+ fclose (f );
642
+ return 1 ;
643
+ }
644
+ return 0 ;
645
+ #endif
646
+ }
647
+
648
+ /* changes the current dir to where the data files can be found */
649
+ void chdir_to_data_files (void )
650
+ {
651
+ if (!r_access (DATA_PATH BANNER_FILE ))
652
+ chdir (BASE_DIR );
653
+ }
Original file line number Diff line number Diff line change @@ -252,4 +252,5 @@ void update_position(
252
252
extern void _skip_ws (char * * txt );
253
253
extern int _convert_type (unsigned char c );
254
254
extern char * load_level (int );
255
+ extern void chdir_to_data_files (void );
255
256
#endif
Original file line number Diff line number Diff line change @@ -361,6 +361,7 @@ int main(int argc, char**argv)
361
361
unsigned long_long last_time ;
362
362
char * LEVEL ;
363
363
364
+ chdir_to_data_files ();
364
365
set_sigint ();
365
366
366
367
while (1 )
Original file line number Diff line number Diff line change @@ -3081,6 +3081,7 @@ int main(int argc, char **argv)
3081
3081
}
3082
3082
consoleApp = 1 ;
3083
3083
#endif
3084
+ chdir_to_data_files ();
3084
3085
parse_command_line (argc ,argv );
3085
3086
3086
3087
a = server ();
You can’t perform that action at this time.
0 commit comments