On Thu, Apr 13, 2006 at 06:49:51PM -0700, William Balcerski wrote:
> I looked into this issue further, and found out some things regarding
> floats and decimals that I should have known about before I posted.
> Namely, that floats do not precisely store numbers like .1 or .2.  So I
> don't see any way around the fact that bombing does not grant .2
> kills per army bombed exactly everytime.

No, but pretty darned close to .2. It sounds like all you have is a
rounding issue. 0.1999999 is 0.2, not 0.1.

> I also looked into how the client and server interact with regards to kill
> updates.  Kills are multiplied by 100 by the server and sent to the
> client.  The client then divides by 100 and inputs the value into the
> player struct.  Effectively, any decimal places beyond the second are
> lost.  Since the kills are stored as a float with many decimal places on
> the server, but only to 2 decimal places on the client, this leads to a
> case where the server and client calculate differently regarding how many
> armies a ship can carry.

Rounding fixes this.

> I propose then to modify the server code to truncate kills at the second
> decimal place when it comes to troop capacity/beam up checking.  The code
> change would be as follows (note there is also a similar function in
> robot troop capacity logic but did not think this needed to be changed
> as robot troop capacity stays server side).

Why truncate? Round.

Cheers,
mark

-- 
mark at mielke.cc / markm at ncf.ca / markm at nortel.com     __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/