diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-24 20:53:55 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-24 20:53:55 +0000 |
commit | b50a2fe4fc4789277f4d78fbb95b227039f50fc4 (patch) | |
tree | ec85542a063430a7a0ff1b3500ecabf13dafb5a7 /crawl-ref/source/ouch.cc | |
parent | 8ff8b514bd6f983e092b1ddddda6f29b5dd5197b (diff) | |
download | crawl-ref-b50a2fe4fc4789277f4d78fbb95b227039f50fc4.tar.gz crawl-ref-b50a2fe4fc4789277f4d78fbb95b227039f50fc4.zip |
More cleanups of file handling.
Removed the useless "anticheat check."
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@108 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/ouch.cc')
-rw-r--r-- | crawl-ref/source/ouch.cc | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 4375ad025e..7161aee1da 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -935,7 +935,6 @@ void ouch( int dam, int death_source, char death_type, const char *aux ) void end_game( struct scorefile_entry &se ) { int i; - char del_file[300]; // massive overkill! bool dead = true; if (se.death_type == KILLED_BY_LEAVING || @@ -963,44 +962,24 @@ void end_game( struct scorefile_entry &se ) unlink(info); // create base file name - snprintf( info, INFO_SIZE, -#ifdef SAVE_DIR_PATH - SAVE_DIR_PATH -#endif -#ifdef MULTIUSER - "%s%d", -#else - "%s", -#endif - you.your_name -#ifdef MULTIUSER - , (int) getuid() -#endif - ); + std::string basename = get_savedir_filename( you.your_name, "", "" ); - // this is to catch the game package if it still exists. + const char* suffixes[] = { +#ifdef CLUA_BINDINGS + ".lua", +#endif #ifdef PACKAGE_SUFFIX - strcpy(del_file, info); - strcat(del_file, "." PACKAGE_SUFFIX); - unlink(del_file); + PACKAGE_SUFFIX , #endif + ".st", ".kil", ".tc", ".nts", ".sav" + }; - // last, but not least, delete player .sav file - strcpy(del_file, info); - - std::string basefile = del_file; - - strcat(del_file, ".sav"); - unlink(del_file); + const int num_suffixes = sizeof(suffixes) / sizeof(const char*); - // Delete record of stashes, kills, travel cache and lua save. - unlink( (basefile + ".st").c_str() ); - unlink( (basefile + ".kil").c_str() ); - unlink( (basefile + ".tc").c_str() ); - unlink( (basefile + ".nts").c_str() ); -#ifdef CLUA_BINDINGS - unlink( (basefile + ".lua").c_str() ); -#endif + for ( int i = 0; i < num_suffixes; ++i ) { + std::string tmpname = basename + suffixes[i]; + unlink( tmpname.c_str() ); + } // death message if (dead) |