You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Heal character to max
2. Equip Girdle of the Dwarves so that CON bonus changes (i.e. from 14-18
to 15-19)
What is the expected output? What do you see instead?
HP current remains equal to max, with the increased value.
Instead, HP becomes the difference between old and new max.
What version of the product are you using? On what operating system?
1.0.20 on Win XP
Please provide any additional information below.
References are from SVN dated 11 Sep 2009.
Notes marked with //S:
ovr024.cs, line 1087:
if (player.hit_point_max > map_hp)
{
player.hit_point_current = (byte)(player.hit_point_max
- map_hp);
}
if (player.hit_point_max < map_hp)
{
if (player.hit_point_current > map_hp -
player.hit_point_max)
{
player.hit_point_current = (byte)(map_hp -
player.hit_point_max);
}
else
{
player.hit_point_current = 0;
}
}
//S: the minimum fix would be using "+=" and "-=" instead of "=":
player.hit_point_current += (byte)(player.hit_point_max
- map_hp);
//...
player.hit_point_current -= (byte)(map_hp -
player.hit_point_max);
//S: however, the whole story is much simpler than this and can be cleaned
up as:
//S: some caution is needed here... this must be a
//S: signed comparison!
if (player.hit_point_current >
map_hp – player.hit_point_max)
{
player.hit_point_current +=
(byte)(player.hit_point_max – map_hp);
}
else
{
player.hit_point_current = 0;
}
Original issue reported on code.google.com by surrano on 16 Sep 2009 at 6:54
The text was updated successfully, but these errors were encountered:
Ended up with the following solution because of the signs... maybe the original
looks
better, having fewer type casts :)
int maxdelta = (int) map_hp - player.hit_point_max;
System.Console.WriteLine("HPChange: " + map_hp + "-" +
player.hit_point_max + "=" + maxdelta +
" current=" + player.hit_point_current);
if ((int)player.hit_point_current > maxdelta)
{
player.hit_point_current = (byte)((int)player.hit_point_current -
maxdelta);
}
else
{
player.hit_point_current = 0;
}
Original comment by surrano on 18 Sep 2009 at 7:40
Original issue reported on code.google.com by
surrano
on 16 Sep 2009 at 6:54The text was updated successfully, but these errors were encountered: