Page 1 of 1

Resource limits

Posted: Sat Oct 10, 2015 11:24 pm
by orzelek
I had RSO trigger message like on last screenshot in this post:
https://forums.factorio.com/forum/vie ... 76#p112276

It seems there is a limit on amount of resource in one node - whats the limit so I can protect the mod from generating that error by capping the values?

Re: Resource limits

Posted: Sat Oct 10, 2015 11:55 pm
by Zeblote
There seems to be a limit of 4294967295. Does that make sense? :D

Re: Resource limits

Posted: Sun Oct 11, 2015 12:51 am
by orzelek
Zeblote wrote:There seems to be a limit of 4294967295. Does that make sense? :D
I played around and it's a 32 bit value but seems to be signed. So actual limit is about 2.1e9 or things go into negative.

I'm adding a hard limit of 1e9 just in case.

Re: Resource limits

Posted: Sun Oct 11, 2015 1:42 am
by keyboardhack
orzelek wrote:
Zeblote wrote:There seems to be a limit of 4294967295. Does that make sense? :D
I played around and it's a 32 bit value but seems to be signed. So actual limit is about 2.1e9 or things go into negative.

I'm adding a hard limit of 1e9 just in case.
The actual value is probably (2^31) - 1 = 2147483647
Different number type limits

Re: Resource limits

Posted: Mon Oct 12, 2015 7:45 pm
by LordFedora
well, 2.14e9 is about 2.1e9...

the 4.29e9 would be if it's an unsigned int

so technically correct?

Re: Resource limits

Posted: Mon Oct 12, 2015 8:58 pm
by Zeblote
It doesn't make sense for it to be signed. Why would you have negative resources?

Tho maybe it is...

Re: Resource limits

Posted: Mon Oct 12, 2015 11:06 pm
by orzelek
The negative part got me also.
I encountered that kind of amounts with mod only so might be why - devs didn't expect that big resource piles :D

As for the exact values - I was lazy thats all ;)
In practice 2e9 or 2.14e9 works - I stayed with 1e9 just in case. Oil patch with that value has lots of % but seems workable.

Re: Resource limits

Posted: Mon Oct 19, 2015 9:31 am
by bobingabout
Why would it be signed? when coding in C/C++ (and persumable C#, never looked into it), if you don't explicitly tell a value to be unsigned, it will default to signed.

When coding myself I tend to make sure I get what I want by using the self predefined uint32, which I defined as an unsigned long. (I think, it could have actually been something more secure, I'm not sure without looking it up).


Yes... depending on what software you compile with, what OS you are using, and what the target platform is, int can be a huge number of different things, including 16bit and 64bit variables.