summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/skills.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 04:33:02 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 04:33:02 +0000
commitefa16086d78dc42f1f6d48e2a5a2d26adcedb04d (patch)
tree1346ff9092f83b3a7ba98fde4db2f13673071599 /crawl-ref/source/skills.cc
parent196478b990026d562ba1aeeeec5b4402bb477e50 (diff)
downloadcrawl-ref-efa16086d78dc42f1f6d48e2a5a2d26adcedb04d.tar.gz
crawl-ref-efa16086d78dc42f1f6d48e2a5a2d26adcedb04d.zip
Fix [2004924], using sorear's suggested method: Avoid doing fractional
arithmetic in _exercise2() by pre-multiplying the factors by 10, which allows crosstraining to work properly when the experience pool isn't full. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6322 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/skills.cc')
-rw-r--r--crawl-ref/source/skills.cc38
1 files changed, 14 insertions, 24 deletions
diff --git a/crawl-ref/source/skills.cc b/crawl-ref/source/skills.cc
index b518962de5..a48357f573 100644
--- a/crawl-ref/source/skills.cc
+++ b/crawl-ref/source/skills.cc
@@ -178,7 +178,7 @@ int exercise(int exsk, int deg)
static int _exercise2(int exsk)
{
- int deg = 1;
+ int deg = 10;
int bonus = 0;
char old_best_skill = best_skill(SK_FIGHTING, (NUM_SKILLS - 1), 99);
@@ -190,7 +190,7 @@ static int _exercise2(int exsk)
&& (you.skills[SK_SHORT_BLADES] > you.skills[exsk]
|| you.skills[SK_LONG_BLADES] > you.skills[exsk]))
{
- bonus += random2(3);
+ bonus += random2(30);
}
// Axes and Polearms.
@@ -198,7 +198,7 @@ static int _exercise2(int exsk)
&& (you.skills[SK_AXES] > you.skills[exsk]
|| you.skills[SK_POLEARMS] > you.skills[exsk]))
{
- bonus += random2(3);
+ bonus += random2(30);
}
// Polearms and Staves.
@@ -206,7 +206,7 @@ static int _exercise2(int exsk)
&& (you.skills[SK_POLEARMS] > you.skills[exsk]
|| you.skills[SK_STAVES] > you.skills[exsk]))
{
- bonus += random2(3);
+ bonus += random2(30);
}
// Axes and Maces.
@@ -214,7 +214,7 @@ static int _exercise2(int exsk)
&& (you.skills[SK_AXES] > you.skills[exsk]
|| you.skills[SK_MACES_FLAILS] > you.skills[exsk]))
{
- bonus += random2(3);
+ bonus += random2(30);
}
// Slings and Throwing.
@@ -222,7 +222,7 @@ static int _exercise2(int exsk)
&& (you.skills[SK_SLINGS] > you.skills[exsk]
|| you.skills[SK_THROWING] > you.skills[exsk]))
{
- bonus += random2(3);
+ bonus += random2(30);
}
}
@@ -291,7 +291,6 @@ static int _exercise2(int exsk)
return (0);
}
- int fraction = 0;
int spending_limit = MIN(MAX_SPENDING_LIMIT, you.exp_available);
// Handle fractional learning.
@@ -305,26 +304,17 @@ static int _exercise2(int exsk)
if (exsk != SK_DARTS && exsk != SK_BOWS && exsk != SK_CROSSBOWS
|| skill_change > you.exp_available)
{
- fraction = (spending_limit * 10) / skill_change;
- skill_change = (skill_change * fraction) / 10;
+ int fraction = (spending_limit * 10) / skill_change;
- deg = (deg * fraction) / 10;
+ deg *= fraction;
if (deg == 0)
- bonus = (bonus * fraction) / 10;
+ bonus *= fraction;
}
else
- {
- if ((skill_change / 2) > MAX_SPENDING_LIMIT)
- {
- deg = 0;
- fraction = 5;
- }
- else
- deg = 1;
-
- skill_change = spending_limit;
- }
+ deg = ((skill_change / 2) > MAX_SPENDING_LIMIT) ? 5 : 10;
+
+ skill_change = spending_limit;
}
skill_change -= random2(5);
@@ -333,11 +323,11 @@ static int _exercise2(int exsk)
{
// No free lunch. This is a problem now that we don't have
// overspending.
- skill_change = (fraction > 0 || deg > 0 || bonus > 0) ? 1 : 0;
+ skill_change = (deg > 0 || bonus > 0) ? 1 : 0;
}
// We can safely return at any stage before this.
- int skill_inc = (deg + bonus) * 10 + fraction;
+ int skill_inc = deg + bonus;
// Starting to learn skills is easier if the appropriate stat is
// high.