-- cgit v1.2.3-54-g00ecf From 91bc3928fb0c255f3ebdc3275740bb3442ecab96 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 27 Nov 2006 13:41:55 +0000 Subject: Fixed hiscores segfaults (reprise for 0.1.4). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.1.4@501 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/hiscores.cc | 33 +++++++++++++++------------------ crawl-ref/source/hiscores.h | 4 ++-- crawl-ref/source/ouch.cc | 9 +++------ 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index bb15621d36..1e5fafe507 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -214,25 +214,26 @@ void hiscores_print_list( int display_count, int format ) else cprintf("%s", info); + std::string entry; // format the entry if (format == SCORE_TERSE) { - hiscores_format_single( info, hs_list[i] ); + entry = hiscores_format_single( hs_list[i] ); // truncate if we want short format - info[75] = 0; + if (entry.length() > 75) + entry = entry.substr(0, 75); } else { - hiscores_format_single_long( info, hs_list[i], + entry = hiscores_format_single_long( hs_list[i], (format == SCORE_VERBOSE) ); } - // print entry - strcat(info, EOL); + entry += EOL; if(use_printf) - printf("%s", info); + printf("%s", entry.c_str()); else - cprintf("%s", info); + cprintf("%s", entry.c_str()); if (i == newest_entry && !use_printf) textcolor(LIGHTGREY); @@ -254,11 +255,9 @@ static const char *const range_type_verb( const char *const aux ) return ("blasted"); // spells, wands } -void hiscores_format_single(char *buf, const scorefile_entry &se) +std::string hiscores_format_single(const scorefile_entry &se) { - std::string line = se.hiscore_line(scorefile_entry::DDV_ONELINE); - strncpy(buf, line.c_str(), INFO_SIZE); - buf[INFO_SIZE - 1] = 0; + return se.hiscore_line(scorefile_entry::DDV_ONELINE); } static bool hiscore_same_day( time_t t1, time_t t2 ) @@ -289,16 +288,14 @@ static std::string hiscore_newline_string() return (EOL " "); } -void hiscores_format_single_long( char *buf, const scorefile_entry &se, - bool verbose ) +std::string hiscores_format_single_long( const scorefile_entry &se, + bool verbose ) { - std::string line = - se.hiscore_line( + return se.hiscore_line( verbose? scorefile_entry::DDV_VERBOSE : scorefile_entry::DDV_NORMAL ); - strncpy(buf, line.c_str(), HIGHSCORE_SIZE); - buf[HIGHSCORE_SIZE - 1] = 0; + } // -------------------------------------------------------------------------- @@ -1510,7 +1507,7 @@ scorefile_entry::character_description(death_desc_verbosity verbosity) const bool verbose = verbosity == DDV_VERBOSE; char scratch[INFO_SIZE]; - char buf[INFO_SIZE]; + char buf[HIGHSCORE_SIZE]; std::string desc; // Please excuse the following bit of mess in the name of flavour ;) diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h index 93b22e660d..f8d7841fe7 100644 --- a/crawl-ref/source/hiscores.h +++ b/crawl-ref/source/hiscores.h @@ -28,8 +28,8 @@ void hiscores_print_list( int display_count = -1, int format = SCORE_TERSE ); /* *********************************************************************** * called from: ouch hiscores * *********************************************************************** */ -void hiscores_format_single( char *buffer, const scorefile_entry &se ); -void hiscores_format_single_long( char *buffer, const scorefile_entry &se, +std::string hiscores_format_single( const scorefile_entry &se ); +std::string hiscores_format_single_long( const scorefile_entry &se, bool verbose = false ); #endif // HISCORES_H diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 4cc78e65d8..f73f3c20da 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -891,15 +891,12 @@ void end_game( struct scorefile_entry &se ) cprintf( "Goodbye, %s.", you.your_name ); cprintf( EOL EOL " " ); // Space padding where # would go in list format - char scorebuff[ HIGHSCORE_SIZE ]; - hiscores_format_single_long( scorebuff, se, true ); - // truncate - scorebuff[ HIGHSCORE_SIZE - 1 ] = 0; + std::string hiscore = hiscores_format_single_long( se, true ); - const int lines = count_occurrences(scorebuff, EOL) + 1; + const int lines = count_occurrences(hiscore, EOL) + 1; - cprintf( scorebuff ); + cprintf( "%s", hiscore.c_str() ); cprintf( EOL "Best Crawlers -" EOL ); -- cgit v1.2.3-54-g00ecf From f5e094c8c6d4f5947d48510633a74cc3b65bf98b Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 27 Nov 2006 14:47:56 +0000 Subject: Fixed char_set being ignored. Fixed g++ warnings in libunix.cc. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.1.4@506 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 2 ++ crawl-ref/source/initfile.cc | 3 --- crawl-ref/source/libunix.cc | 17 ----------------- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index ef7bf4b03b..6be9c94139 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2687,6 +2687,7 @@ static bool initialise(void) seed_rng(); init_overmap(); // in overmap.cc (duh?) clear_ids(); // in itemname.cc + init_char_table(Options.char_set); init_feature_table(); init_properties(); @@ -2803,6 +2804,7 @@ static bool initialise(void) you.your_name[kNameLen - 1] = 0; // In case Lua changed the character set. + init_char_table(Options.char_set); init_feature_table(); #endif viewwindow(1, false); // This just puts the view up for the first turn. diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 6a2a1f7dc5..6b3559c7a3 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -523,7 +523,6 @@ void game_options::reset_options() #else char_set = CSET_IBM; #endif - init_char_table(char_set); // set it to the .crawlrc default autopickups = ((1L << 15) | // gold @@ -1169,8 +1168,6 @@ void game_options::read_option_line(const std::string &str, bool runscript) valid = false; } } - if (valid) - init_char_table(char_set); } else if (key == "default_autopickup") { diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index 99605bea5f..7b4884cb04 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -95,55 +95,38 @@ static short translate_colour( short col ) { case BLACK: return COLOR_BLACK; - break; case BLUE: return COLOR_BLUE; - break; case GREEN: return COLOR_GREEN; - break; case CYAN: return COLOR_CYAN; - break; case RED: return COLOR_RED; - break; case MAGENTA: return COLOR_MAGENTA; - break; case BROWN: return COLOR_YELLOW; - break; case LIGHTGREY: return COLOR_WHITE; - break; case DARKGREY: return COLOR_BLACK + COLFLAG_CURSES_BRIGHTEN; - break; case LIGHTBLUE: return COLOR_BLUE + COLFLAG_CURSES_BRIGHTEN; - break; case LIGHTGREEN: return COLOR_GREEN + COLFLAG_CURSES_BRIGHTEN; - break; case LIGHTCYAN: return COLOR_CYAN + COLFLAG_CURSES_BRIGHTEN; - break; case LIGHTRED: return COLOR_RED + COLFLAG_CURSES_BRIGHTEN; - break; case LIGHTMAGENTA: return COLOR_MAGENTA + COLFLAG_CURSES_BRIGHTEN; - break; case YELLOW: return COLOR_YELLOW + COLFLAG_CURSES_BRIGHTEN; - break; case WHITE: return COLOR_WHITE + COLFLAG_CURSES_BRIGHTEN; - break; default: return COLOR_GREEN; - break; //mainly for debugging } } -- cgit v1.2.3-54-g00ecf From 29faa0a6eb7d70224246e9613a5b9cec4f94dcb5 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 27 Nov 2006 16:00:59 +0000 Subject: [1603062] Fixed save_dir not working when LOAD_PACKAGE_CMD is defined (sartak). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.1.4@509 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/AppHdr.h | 9 +++------ crawl-ref/source/files.cc | 43 ++++++++++++++++++++++++++----------------- crawl-ref/source/files.h | 1 + crawl-ref/source/newgame.cc | 7 +++++-- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 602d351444..198b1819fa 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -318,17 +318,14 @@ // to a command to compress and bundle the save game files into a // single unit... the two %s will be replaced with the players // save file name. Define LOAD_UNPACKAGE_CMD to undo this process - // the %s is the same as above. + // the %s is the same as above. The second %s in LOAD_UNPACKAGE_CMD + // is for the output directory. // // PACKAGE_SUFFIX is used when the package file name is needed // // Comment these lines out if you want to leave the save files uncompressed. #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s.zip %s.*" -#ifdef SAVE_DIR_PATH - #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d" SAVE_DIR_PATH -#else - #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip" -#endif + #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d %s" #ifdef SAVE_PACKAGE_CMD // This is used to unpack specific files from the archive. diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 25fc3a39a7..f9c3332186 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -468,14 +468,17 @@ std::vector find_saved_characters() 0, filename.length() - strlen(PACKAGE_SUFFIX)); - std::string zipname = get_savedir_path(basename); + const std::string zipname = get_savedir_path(basename); // This is the filename we actually read ourselves. filename = basename + ".sav"; + const std::string dir = get_savedir(); + char cmd_buff[1024]; snprintf( cmd_buff, sizeof(cmd_buff), UNPACK_SPECIFIC_FILE_CMD, zipname.c_str(), + dir.c_str(), filename.c_str() ); if (system(cmd_buff) != 0) @@ -498,6 +501,12 @@ std::vector find_saved_characters() return (chars); } +std::string get_savedir() +{ + const std::string &dir = Options.save_dir; + return (dir.empty()? "." : dir); +} + std::string get_savedir_filename(const char *prefix, const char *suffix, const char *extension, bool suppress_uid) { @@ -515,8 +524,8 @@ std::string get_savedir_filename(const char *prefix, const char *suffix, result += suffix; if ( *extension ) { - result += '.'; - result += extension; + result += '.'; + result += extension; } #ifdef DOS @@ -1177,7 +1186,7 @@ void save_game(bool leave_game) if (stashf) { stashes.save(stashf); fclose(stashf); - DO_CHMOD_PRIVATE(stashFile.c_str()); + DO_CHMOD_PRIVATE(stashFile.c_str()); } #endif @@ -1195,7 +1204,7 @@ void save_game(bool leave_game) if (killf) { you.kills.save(killf); fclose(killf); - DO_CHMOD_PRIVATE(killFile.c_str()); + DO_CHMOD_PRIVATE(killFile.c_str()); } /* travel cache */ @@ -1204,25 +1213,25 @@ void save_game(bool leave_game) if (travelf) { travel_cache.save(travelf); fclose(travelf); - DO_CHMOD_PRIVATE(travelCacheFile.c_str()); + DO_CHMOD_PRIVATE(travelCacheFile.c_str()); } /* notes */ std::string notesFile = get_savedir_filename(you.your_name, "", "nts"); FILE *notesf = fopen(notesFile.c_str(), "wb"); if (notesf) { - save_notes(notesf); + save_notes(notesf); fclose(notesf); - DO_CHMOD_PRIVATE(notesFile.c_str()); + DO_CHMOD_PRIVATE(notesFile.c_str()); } std::string charFile = get_savedir_filename(you.your_name, "", "sav"); FILE *charf = fopen(charFile.c_str(), "wb"); if (!charf) { - snprintf(info, INFO_SIZE, "Unable to open \"%s\" for writing!\n", + snprintf(info, INFO_SIZE, "Unable to open \"%s\" for writing!\n", charFile.c_str()); - perror(info); - end(-1); + perror(info); + end(-1); } // 0.0 initial genesis of saved format @@ -1369,8 +1378,8 @@ void restore_game(void) FILE *charf = fopen(charFile.c_str(), "rb"); if (!charf ) { - snprintf(info, INFO_SIZE, "Unable to open %s for reading!\n", - charFile.c_str() ); + snprintf(info, INFO_SIZE, "Unable to open %s for reading!\n", + charFile.c_str() ); perror(info); end(-1); } @@ -1390,7 +1399,7 @@ void restore_game(void) if (!feof(charf)) { snprintf( info, INFO_SIZE, "\nIncomplete read of \"%s\" - aborting.\n", - charFile.c_str()); + charFile.c_str()); perror(info); end(-1); } @@ -1428,8 +1437,8 @@ void restore_game(void) std::string notesFile = get_savedir_filename(you.your_name, "", "nts"); FILE *notesf = fopen(notesFile.c_str(), "rb"); if (notesf) { - load_notes(notesf); - fclose(notesf); + load_notes(notesf); + fclose(notesf); } } @@ -1845,7 +1854,7 @@ unsigned char translate_spell(unsigned char spel) case SPELL_SUMMON_HORRIBLE_THINGS: return (MS_LEVEL_SUMMON); /* approximate */ case SPELL_SHADOW_CREATURES: - return (MS_LEVEL_SUMMON); /* approximate */ + return (MS_LEVEL_SUMMON); /* approximate */ case SPELL_ANIMATE_DEAD: return (MS_ANIMATE_DEAD); case SPELL_PAIN: diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h index b7fd81a5fd..3bbd358a1e 100644 --- a/crawl-ref/source/files.h +++ b/crawl-ref/source/files.h @@ -37,6 +37,7 @@ bool travel_load_map( char branch, int absdepth ); std::vector find_saved_characters(); +std::string get_savedir(); std::string get_savedir_filename(const char *pre, const char *suf, const char *ext, bool suppress_uid = false); diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index c4ffc8cbd1..5a1c97671c 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -294,12 +294,15 @@ static bool check_saved_game(void) // Create command char cmd_buff[1024]; + const std::string directory = get_savedir(); + snprintf( cmd_buff, sizeof(cmd_buff), LOAD_UNPACKAGE_CMD, - basename.c_str() ); + basename.c_str(), directory.c_str() ); if (system( cmd_buff ) != 0) { - cprintf( EOL "Warning: Zip command (LOAD_UNPACKAGE_CMD) returned non-zero value!" EOL ); + cprintf( EOL "Warning: Zip command (LOAD_UNPACKAGE_CMD) " + "returned non-zero value!" EOL ); } // Remove save game package -- cgit v1.2.3-54-g00ecf From dfeea2c359b14029741cdcc191d82dc596c18a1c Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 27 Nov 2006 16:02:59 +0000 Subject: Updated CREDITS for 0.1.4. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.1.4@510 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/CREDITS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crawl-ref/CREDITS b/crawl-ref/CREDITS index 85ee808cf5..a2ed015618 100644 --- a/crawl-ref/CREDITS +++ b/crawl-ref/CREDITS @@ -17,6 +17,7 @@ contributed to Dungeon Crawl Stone Soup: Peter Borgmann Matthew Cline +Mike Drinen Elethiomel Ben Goetter R. Dan Henry @@ -28,4 +29,5 @@ Pedro Lemuel Pitkin Johanna Ploog David Rose +sartak Johan Strandell -- cgit v1.2.3-54-g00ecf From 93731f302aac0d4e41fd606028a391c207307e0f Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 27 Nov 2006 16:04:41 +0000 Subject: Set version to 0.1.4 for release. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.1.4@511 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crawl-ref/source/version.h b/crawl-ref/source/version.h index ce898d6603..45db6fe5b9 100644 --- a/crawl-ref/source/version.h +++ b/crawl-ref/source/version.h @@ -41,7 +41,7 @@ /* *********************************************************************** * called from: chardump - command - newgame * *********************************************************************** */ -#define VERSION "0.2-svn (crawl-ref)" +#define VERSION "0.1.4 (crawl-ref)" // last updated 20feb2001 {GDL} /* *********************************************************************** -- cgit v1.2.3-54-g00ecf