OpenXcom Forum

Modding => OXCE Bugs => OpenXcom Extended => OXCE Bugs FIXED => Topic started by: evilbananas on June 06, 2022, 06:14:56 pm

Title: [FIXED] Storage Space issue
Post by: evilbananas on June 06, 2022, 06:14:56 pm
I have a base that has 225 storage space.  The only thing in the base is scrap metal as you can see in the attached screenshots below. 

If I try to transfer 1 more piece of scrap metal to reach my storage limit of 225, I get an error that their is not enough space at the base.


Title: Re: Storage Space
Post by: Yankes on June 06, 2022, 07:22:19 pm
Space is not integer, you could have 224.1 used space. Save could be more productive to see what exactly code did there.
Title: Re: Storage Space
Post by: R1dO on June 06, 2022, 07:49:41 pm
It is probably due to floating point calculations.

From your second screenshot it can be observed the base is only 1 item away from the max amount (storage space 224.9 vs 225), which means (up to) 0.1 space available.
Unfortunately 0.1 has no exact representation in floating point, the closest one can get is something like:
"0.100000001490116119384765625" [1]
This number is slightly larger causing the result after transfer to be larger than 225 leading to the mentioned error.

P.s. This is assuming OXC(E) does not take into account floating point accuracy when comparing base fill levels (have not looked at that part of the code).

[1] Courtesy: 1st answer of following stackoverflow post => https://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal (https://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal)
Title: Re: Storage Space
Post by: evilbananas on June 06, 2022, 08:11:57 pm
I have attached the save file to the original post.  It's for the latest X-Piratez - N1.1
Title: Re: Storage Space
Post by: Meridian on June 07, 2022, 11:30:30 am
Fixed.
https://github.com/MeridianOXC/OpenXcom/commit/080e21cc099573e3e6ed510db5901d4c6138383e