URL:
  <http://gna.org/bugs/?16433>

                 Summary: Improper rounding in end-game calculations and
elsewhere
                 Project: Battle for Wesnoth
            Submitted by: srk9
            Submitted on: Saturday 08/14/2010 at 14:41
                Category: Bug
                Severity: 2 - Minor
                Priority: 5 - Normal
              Item Group:  None of the others
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.8.4
        Operating System: Gentoo Linux

    _______________________________________________________

Details:

I was playing the Northern Winter scenario from the Heir to the Throne
campaign and I ended with 1604 gold prior to the bonus gold calculation.
After the bonus gold calculation, I had 481 gold. This should have been 482
gold.

The source code uses truncation rather than rounding. Since I expect that
rounding should be used, it should be implemented by using div100rounded() in
src/util.hpp. Unfortunately, div100rounded() has a bug that causes any number
of the form 100x + 50, where x is an integer, to be rounded down when it
should be rounded up.

I have attached a patch which fixes both issues. The patch can be applied on
a Unix system via "patch -p1 < /path/to/wesnoth_improper_rounding_fix.patch"
when the present working directory is the tree's root.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Saturday 08/14/2010 at 14:41  Name: wesnoth_improper_rounding_fix.patch
 Size: 1kB   By: srk9
This patch fixes the rounding issues
<http://gna.org/bugs/download.php?file_id=9836>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?16433>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to