Resource limits

Place to get help with not working mods / modding interface.
Post Reply
orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Resource limits

Post 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?

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: Resource limits

Post by Zeblote »

There seems to be a limit of 4294967295. Does that make sense? :D

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Resource limits

Post 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.

keyboardhack
Filter Inserter
Filter Inserter
Posts: 478
Joined: Sat Aug 23, 2014 11:43 pm
Contact:

Re: Resource limits

Post 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
Waste of bytes : P

LordFedora
Filter Inserter
Filter Inserter
Posts: 310
Joined: Fri Nov 07, 2014 3:46 am
Contact:

Re: Resource limits

Post by LordFedora »

well, 2.14e9 is about 2.1e9...

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

so technically correct?

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: Resource limits

Post by Zeblote »

It doesn't make sense for it to be signed. Why would you have negative resources?

Tho maybe it is...

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Resource limits

Post 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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Resource limits

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding help”