File tree Expand file tree Collapse file tree 7 files changed +34
-5
lines changed Expand file tree Collapse file tree 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)
10951095	printf ("Started WinSock version %X.%02X\n" , wd .wVersion /0x100 , wd .wVersion & 0xFF );
10961096#endif 
10971097
1098- 
1098+ 	 chdir_to_data_files (); 
10991099	ERROR ("Initialization...\n" );
11001100
11011101	last_obj = & objects ;
Original file line number Diff line number Diff line change @@ -2223,7 +2223,7 @@ int main(int argc,char **argv)
22232223	printf ("Started WinSock version %X.%02X\n" , wd .wVersion /0x100 , wd .wVersion & 0xFF );
22242224#endif 
22252225
2226- 
2226+ 	 chdir_to_data_files (); 
22272227#ifdef  XWINDOW 
22282228	x_display_name = 0 ;
22292229	x_font_name = 0 ;
Original file line number Diff line number Diff line change @@ -34,9 +34,7 @@ AC_STRUCT_TM
3434dnl Checks for library functions.
3535AC_PROG_GCC_TRADITIONAL
3636AC_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)
4038
4139AC_CHECK_FUNC(random, cf_result=yes, cf_result=no)
4240if test "$cf_result" = no; then
Original file line number Diff line number Diff line change 66#include  "config.h" 
77#endif 
88
9+ #ifdef  HAVE_ACCESS 
10+ # ifdef  HAVE_UNISTD_H 
11+ #  include  <unistd.h> 
12+ # endif 
13+ #endif 
14+ 
915#include  "data.h" 
1016#include  "cfg.h" 
1117#include  "hash.h" 
@@ -623,3 +629,25 @@ char* md5_level(int level_num)
623629	mem_free (result );
624630	return  q ;
625631}
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(
252252extern  void  _skip_ws (char * * txt );
253253extern  int  _convert_type (unsigned char   c );
254254extern  char  *  load_level (int );
255+ extern  void  chdir_to_data_files (void );
255256#endif 
Original file line number Diff line number Diff line change @@ -361,6 +361,7 @@ int main(int argc, char**argv)
361361	unsigned long_long   last_time ;
362362	char  * LEVEL ;
363363
364+ 	chdir_to_data_files ();
364365	set_sigint ();
365366
366367	while (1 )
Original file line number Diff line number Diff line change @@ -3081,6 +3081,7 @@ int main(int argc, char **argv)
30813081	}
30823082	consoleApp = 1 ;
30833083#endif 
3084+ 	chdir_to_data_files ();
30843085	parse_command_line (argc ,argv );
30853086
30863087	a = server ();
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments