bug in reduce_skill führte zu verrückten skillwerten und asserts.

This commit is contained in:
Enno Rehling 2002-02-16 20:41:50 +00:00
parent d82f1335bf
commit d2d2b75cdc
3 changed files with 9 additions and 6 deletions

View File

@ -2051,6 +2051,7 @@ writegame(char *path, char quiet)
#else #else
for (i=0;i!=u->skill_size;++i) { for (i=0;i!=u->skill_size;++i) {
skill * sv = u->skills+i; skill * sv = u->skills+i;
assert(sv->level>=0 && sv->learning>=0 && sv->learning<=sv->level*2);
if (sv->learning || sv->level) { if (sv->learning || sv->level) {
wi(F, sv->id); wi(F, sv->id);
wi(F, sv->level); wi(F, sv->level);

View File

@ -259,26 +259,28 @@ level(int days)
void void
reduce_skill(skill * sv, int change) reduce_skill(skill * sv, int change)
{ {
int weeks = (sv->level * sv->level - sv->level) / 2 + sv->learning;
if (sv->learning>=change) { if (sv->learning>=change) {
/* just forget a few weeks */ /* just forget a few weeks */
weeks -= change; sv->learning = (unsigned char)(sv->learning-change);
} else { } else {
int weeks;
change -= sv->learning; change -= sv->learning;
while (change>=sv->level && sv->level > 0) { while (change>=sv->level && sv->level > 0) {
change -= sv->level; change -= sv->level;
--sv->level; --sv->level;
} }
if (change && change<sv->level) { if (change && sv->level > 0 && change<sv->level) {
/* this is not an exact science... it would be better to set /* this is not an exact science... it would be better to set
* sv->learning so that the average time to rise was = change. * sv->learning so that the average time to rise was = change.
*/ */
--sv->level;
weeks = (sv->level-change)*2; weeks = (sv->level-change)*2;
} else { } else {
weeks = 0; weeks = 0;
} }
}
sv->learning = (unsigned char)weeks; sv->learning = (unsigned char)weeks;
}
assert(sv->level>=0 && sv->learning>=0 && sv->learning<=sv->level*2);
} }
int int

View File

@ -4559,8 +4559,8 @@
<arg name="target" type="unit"></arg> <arg name="target" type="unit"></arg>
<arg name="report" type="string"></arg> <arg name="report" type="string"></arg>
</type> </type>
<text locale="de">"$unit($spy) gelang es Informationen über $unit(target) herauszubekommen: '$report'."</text> <text locale="de">"$unit($spy) gelang es Informationen über $unit($target) herauszubekommen: '$report'."</text>
<text locale="en">"$unit($spy) managed to gather Information about $unit(target): '$report'."</text> <text locale="en">"$unit($spy) managed to gather information about $unit($target): '$report'."</text>
</message> </message>
<message name="spyfail" section="events"> <message name="spyfail" section="events">