[0.15.40] LuaLogisticNetwork.get_item_count(item) overflow

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

[0.15.40] LuaLogisticNetwork.get_item_count(item) overflow

Post by Mylon »

When a logistic net has a negative amount of a good, using the API to get the amount the logistic network contains reports a ridiculously high number.

https://imgur.com/a/LBRdG

I'm not sure exactly how to reproduce the negative amount, but it seems like a case of trying to assign an unsigned int from a signed int.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [0.15.40] LuaLogisticNetwork.get_item_count(item) overflow

Post by Optera »

Logistic network readout has a few caveats.
1) Items transported by robots are not shown in any readout.
2) Negative amounts happen because bots are scheduled to pick up their cargo capacity regardless of how much is in storage.
Together those can produce negative numbers quite often in networks with low storage amounts.

To me that looks like that window is displaying the values as unsigned 32bit or 64bit int while internally Factorio uses 32bit signed int.
You could possibly do something like this to read the MSB as sign.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.40] LuaLogisticNetwork.get_item_count(item) overflow

Post by Rseding91 »

Thanks for the report. This was fixed for 0.16 a few months ago.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”