diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-15 14:29:27 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-15 14:29:27 +0000 |
commit | c4fe8d851bbeceb9c768dc72f53378360f5938f2 (patch) | |
tree | 9986742b5cbfdefcc806ce8f88bb6816578b941c /crawl-ref/source/command.cc | |
parent | 94ecb28d87ead9a3d77f2bbecc59eb8cc978d95c (diff) | |
download | crawl-ref-c4fe8d851bbeceb9c768dc72f53378360f5938f2.tar.gz crawl-ref-c4fe8d851bbeceb9c768dc72f53378360f5938f2.zip |
Fix 1994279: Crash when checking ?v (version information).
Fix 1994352: Buggy message after an invisible monster blocks an attack.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5847 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/command.cc')
-rw-r--r-- | crawl-ref/source/command.cc | 103 |
1 files changed, 51 insertions, 52 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index dfb78e084a..2a597731ed 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -129,64 +129,63 @@ static void _add_file_to_scroller(FILE* fp, formatted_scroller& m, static std::string _get_version_changes(void) { - std::string result = ""; + // Attempts to print "Highlights" of the latest version. + FILE* fp = fopen(datafile_path("changes.stone_soup", false).c_str(), "r"); + if (!fp) + return ""; + std::string result = ""; + std::string help; + char buf[200]; bool start = false; - // Attempts to print "Highlights" of the latest version. - FILE* fp = fopen(datafile_path("changes.stone_soup", true).c_str(), "r"); - if (fp) + bool skip_lines = true; + while (fgets(buf, sizeof buf, fp)) { - char buf[200]; - std::string help; - bool skip_lines = true; - while (fgets(buf, sizeof buf, fp)) + // Remove trailing spaces. + for (int i = strlen(buf) - 1; i >= 0; i++) { - // Remove trailing spaces. - for (int i = strlen(buf) - 1; i >= 0; i++) - { - if (isspace( buf[i] )) - buf[i] = 0; - else - break; - } - help = buf; - // Give up if you encountered the second set of underliners - // and still haven't found Highlights. - if (help.find("---") != std::string::npos) - { - if (skip_lines) - { - skip_lines = false; - continue; - } - else if (!start) - break; - } - - if (help.find("Highlights") != std::string::npos) + if (isspace( buf[i] )) + buf[i] = 0; + else + break; + } + help = buf; + // Give up if you encountered the second set of underliners + // and still haven't found Highlights. + if (help.find("---") != std::string::npos) + { + if (skip_lines) { - // Highlight the Highlights, so to speak. - std::string text = "<w>"; - text += buf; - text += "</w>"; - text += EOL; - result += text; - // And start printing from now on. - start = true; + skip_lines = false; + continue; } else if (!start) - continue; - else if (buf[0] == 0) - { - // Stop reading and copying text with the first empty line - // following the Highlights section. break; - } - else - { - result += buf; - result += EOL; - } + } + + if (help.find("Highlights") != std::string::npos) + { + // Highlight the Highlights, so to speak. + std::string text = "<w>"; + text += buf; + text += "</w>"; + text += EOL; + result += text; + // And start printing from now on. + start = true; + } + else if (!start) + continue; + else if (buf[0] == 0) + { + // Stop reading and copying text with the first empty line + // following the Highlights section. + break; + } + else + { + result += buf; + result += EOL; } } fclose(fp); @@ -230,7 +229,7 @@ static void _print_version(void) cmd_version.add_text(_get_version_changes()); // Read in information about changes in comparison to the latest version. - FILE* fp = fopen(datafile_path("034_changes.txt", true).c_str(), "r"); + FILE* fp = fopen(datafile_path("034_changes.txt", false).c_str(), "r"); if (fp) { char buf[200]; @@ -257,8 +256,8 @@ static void _print_version(void) else cmd_version.add_text(buf); } + fclose(fp); } - fclose(fp); cmd_version.show(); } |