summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-15 09:33:36 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-15 09:33:36 +0000
commita58c6bc75071f2a4f74ab097421c6df14920590c (patch)
tree52aeeeb6983dcf178c31f78c093a9741d451cdec /crawl-ref/source
parent19081dd2e2f1b6bff7596cb66beee90417e640ae (diff)
downloadcrawl-ref-a58c6bc75071f2a4f74ab097421c6df14920590c.tar.gz
crawl-ref-a58c6bc75071f2a4f74ab097421c6df14920590c.zip
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
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/randart.cc2
-rw-r--r--crawl-ref/source/skills2.cc24
2 files changed, 13 insertions, 13 deletions
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