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 | |
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')
-rw-r--r-- | crawl-ref/source/command.cc | 103 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 10 |
2 files changed, 58 insertions, 55 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(); } diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 1c92ab90c1..737b54ee9e 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -349,7 +349,7 @@ melee_attack::melee_attack(actor *attk, actor *defn, weapon(NULL), damage_brand(SPWPN_NORMAL), wpn_skill(SK_UNARMED_COMBAT), hands(HANDS_ONE), spwld(SPWLD_NONE), hand_half_bonus(false), - art_props(0), attack_verb(), verb_degree(), + art_props(0), attack_verb("bug"), verb_degree(), no_damage_message(), special_damage_message(), unarmed_attack(), shield(NULL), defender_shield(NULL), heavy_armour_penalty(0), can_do_unarmed(false), @@ -807,7 +807,7 @@ bool melee_attack::player_attack() bleed_onto_floor(where.x, where.y, defender->id(), blood, true); } - if (damage_done > 0 || !defender_visible) + if (damage_done > 0 || !defender_visible && !shield_blocked) player_announce_hit(); else if (!shield_blocked && damage_done <= 0) { @@ -3827,7 +3827,7 @@ void melee_attack::mons_perform_attack_rounds() { if (attack_shield_blocked(true)) { - shield_blocked = true; + shield_blocked = true; perceived_attack = true; this_round_hit = did_hit = true; } @@ -3864,6 +3864,10 @@ void melee_attack::mons_perform_attack_rounds() if (damage_done > 0) { +#ifdef DEBUG_DIAGNOSTICS + if (shield_blocked) + mpr("ERROR: Non-zero damage after shield block!"); +#endif mons_announce_hit(attk); check_defender_train_armour(); |