From a58c6bc75071f2a4f74ab097421c6df14920590c Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 15 Jun 2008 09:33:36 +0000 Subject: Cleaned up skill percentage calculation. Should fix 1929156. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5842 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/randart.cc | 2 +- crawl-ref/source/skills2.cc | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index 34a7895c57..ad70985692 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -1353,7 +1353,7 @@ std::string randart_name(const item_def &item, bool appearance) result += item_base_name(item) + " "; int tries = 100; - std::string name = ""; + std::string name; do { name = getRandNameString(lookup); diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index e7bd806a54..ff56b9babf 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -1786,26 +1786,26 @@ static void _display_skill_table(bool show_aptitudes) if (you.skills[x] < 27) { - const int needed = skill_exp_needed(you.skills[x] + 1); - const int prev_needed = skill_exp_needed(you.skills[x]); - int spec_abil = species_skills(x, you.species); + const int spec_abil = species_skills(x, you.species); if (!show_aptitudes) { - int percent_done = ((you.skill_points[x] - - (prev_needed * spec_abil) / 100) * 100) / - (((needed - prev_needed) * spec_abil) / 100); + const int needed = + (skill_exp_needed(you.skills[x] + 1) * spec_abil) / 100; + const int prev_needed = + (skill_exp_needed(you.skills[x] ) * spec_abil) / 100; - // But wouldn't that put us way into the next level? - // Shouldn't it be 0 then, or maybe the difference? - if (percent_done >= 100) + const int amt_done = you.skill_points[x] - prev_needed; + int percent_done = (amt_done*100) / (needed - prev_needed); + + if (percent_done >= 100) // paranoia (1) percent_done = 99; - if (percent_done <= 0) - percent_done = 1; // This'll just be turned to 0 anyway. + if (percent_done < 0) // paranoia (2) + percent_done = 0; textcolor(CYAN); - // Round down by 5 digits. + // Round down to multiple of 5. cprintf( " (%2d%%)", (percent_done / 5) * 5 ); } else -- cgit v1.2.3-54-g00ecf