--- include/savegame.h.orig 2004-12-13 23:29:55.346394024 -0500 +++ include/savegame.h 2004-12-13 23:30:11.844885872 -0500 @@ -20,7 +20,7 @@ #define SAVEGAME_VERSION "2.1" -#define SAVE_DIR "Savegames" +#define SAVE_DIR ".smclone/Savegames" struct Savegame { --- savegame.cpp.orig 2004-12-13 23:23:21.299298288 -0500 +++ savegame.cpp 2004-12-13 23:28:37.816180408 -0500 @@ -37,8 +37,8 @@ Loaded_Save_info.OverWorld = 0; Loaded_Save_info.Itembox_item = 0; - char Full_Save_Name[40]; - sprintf( Full_Save_Name,"%s/%d.sav", SAVE_DIR, Save_file ); + char Full_Save_Name[255]; + snprintf( Full_Save_Name, 254, "%s/%s/%d.sav", getenv("HOME"), SAVE_DIR, Save_file ); ifstream ifs( Full_Save_Name, ios::in ); @@ -67,8 +67,11 @@ +#include int Savegame_Save( unsigned int Save_file, Savegame Save_info ) { - char Full_Save_Name[45]; - sprintf( Full_Save_Name, "%s/%d.sav", SAVE_DIR, Save_file ); + char Full_Save_Name[255]; + snprintf( Full_Save_Name, 254, "%s/%s", getenv("HOME"), SAVE_DIR ); + mkdir(Full_Save_Name, 0770); + snprintf( Full_Save_Name, 254, "%s/%s/%d.sav", getenv("HOME"), SAVE_DIR, Save_file ); ifstream ifs( Full_Save_Name, ios::in ); @@ -163,11 +163,11 @@ const char *Savegame_GetDescription( unsigned int Save_file, bool Only_Description ) { std :: string Full_Save_Name; - char buffer[10]; + char buffer[255]; Full_Save_Name = SAVE_DIR "/.sav"; - sprintf( buffer, "%d", Save_file ); + snprintf( buffer, 254, "%s/%d", getenv("HOME"), Save_file ); Full_Save_Name.insert( strlen( SAVE_DIR ) + 1, buffer ); @@ -226,11 +226,11 @@ bool Savegame_valid( unsigned int Save_file ) { std :: string Full_Save_Name; - char buffer[10]; + char buffer[255]; Full_Save_Name = SAVE_DIR "/.sav"; - sprintf( buffer, "%d", Save_file ); + snprintf( buffer, 254, "%s/%d", getenv("HOME"), Save_file ); Full_Save_Name.insert( strlen( SAVE_DIR ) + 1, buffer ); ifstream ifs( Full_Save_Name.c_str(), ios::in ); --- main.cpp.orig 2004-12-13 23:29:48.623416072 -0500 +++ main.cpp 2004-12-13 23:31:16.989982312 -0500 @@ -554,14 +554,17 @@ +#include void MakeScreenshot( void ) { - char filename[20]; + char filename[255]; int i = 0; while( i < 1000 ) { i++; - sprintf( filename, "Screenshots/%03d.bmp" , i ); + snprintf( filename, 254, "%s/.smclone/Screenshots" , getenv("HOME")); + mkdir(filename, 0770); + snprintf( filename, 254, "%s/.smclone/Screenshots/%03d.bmp" , getenv("HOME"), i ); FILE *fp = fopen( filename, "r" ); if( !fp ) --- preferences.cpp.orig 2004-12-13 23:31:36.006091424 -0500 +++ preferences.cpp 2004-12-13 23:33:28.611972728 -0500 @@ -27,6 +27,15 @@ { // } +#include +char *get_PREF_NAME( void ) +{ + static char ret[255]; + snprintf(ret, 254, "%s/.smclone", getenv("HOME")); + mkdir(ret, 0770); + snprintf(ret, 254, "%s/.smclone/%s", getenv("HOME"), PREF_NAME); + return ret; +} bool cPreferences :: Load( void ) { @@ -38,11 +44,11 @@ return 0; } - ifstream ifs( PREF_NAME, ios::in ); + ifstream ifs( get_PREF_NAME(), ios::in ); if( !ifs ) { - cout << "Could not open preferences file : " << PREF_NAME << endl; + cout << "Could not open preferences file : " << get_PREF_NAME() << endl; return 0; } @@ -67,7 +73,7 @@ { Update(); - ofstream ofs( PREF_NAME, ios::out ); + ofstream ofs( get_PREF_NAME(), ios::out ); char row[250]; @@ -150,7 +156,7 @@ bool cPreferences :: Prefs_available( void ) { - FILE *fp = fopen( PREF_NAME, "r" ); + FILE *fp = fopen( get_PREF_NAME(), "r" ); if ( !fp ) {