[0.17.39] get_inventory() fails

Bugs that are actually features.
Post Reply
Oarc
Fast Inserter
Fast Inserter
Posts: 100
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

[0.17.39] get_inventory() fails

Post by Oarc »

Hello,

I am seeing this failure occasionally but I don't know how to reproduce it:
Linux headless server, running custom scenario, no mods, map was started sometime between .35 and .37 updates I think.

Code: Select all

69711.329 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_built_entity (ID 6)
real number expected got nil.
stack traceback:
        ..._0.17/factorio/temp/currently-playing/lib/oarc_utils.lua:697: in function 'AutofillTurret'
        ..._0.17/factorio/temp/currently-playing/lib/oarc_utils.lua:955: in function 'Autofill'
        ...actorio_0.17/factorio/temp/currently-playing/control.lua:216: in function <...actorio_0.17/factorio/temp/currently-playing/control.lua:214>
stack traceback:
        [C]: in function 'get_inventory'
        ..._0.17/factorio/temp/currently-playing/lib/oarc_utils.lua:697: in function 'AutofillTurret'
        ..._0.17/factorio/temp/currently-playing/lib/oarc_utils.lua:955: in function 'Autofill'
        ...actorio_0.17/factorio/temp/currently-playing/control.lua:216: in function <...actorio_0.17/factorio/temp/currently-playing/control.lua:214>
69711.329 Info ServerMultiplayerManager.cpp:776: updateTick(3474305) changing state from(InGame) to(Failed)
69711.329 Quitting: multiplayer error.
The line in question where the failure occurs is this:

Code: Select all

local mainInv = player.get_inventory(defines.inventory.character_main)
I have used this code for quite awhile (years) and never had a failure before until .38/.39 updates. The only change I made was during the player->character renaming I think.

My expectation is that regardless of the player's state, character is dead/alive/god-mode, the get_inventory function should at worst return nil.

I am not writing or changing defines.inventory anywhere. I am using a scenario only, no mods.

I am not sure if this is a bug, but from my understanding of this error report, it is saying that I am passing get_inventory nil, instead of a number?
Attachments
factorio-current (1).log
(78.72 KiB) Downloaded 53 times

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.17.39] get_inventory() fails

Post by kovarex »

This looks, like the inventory index wasn't passed and nil was passed instead. I don't really know how could this happen, but we would need more isolated case to figure it out.

Oarc
Fast Inserter
Fast Inserter
Posts: 100
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

Re: [0.17.39] get_inventory() fails

Post by Oarc »

Yeah I agree, I just couldn't figure out a way to reproduce it.

The only thing I can say for sure is that I've used that specific code for quite a long time, and it's only recently started to fail since the last 1 or 2 updates.

I'll let you know if I'm able to reliably repro or if I have any other useful info.

Oarc
Fast Inserter
Fast Inserter
Posts: 100
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

Re: [0.17.39] get_inventory() fails

Post by Oarc »

@Kovarex

I found a way to reproduce the problem, but I feel like it's a corrupted save file or something?
https://transfer.sh/1wAPq/oarc-save-broken.zip

If you load that save, and try to place a turret, it causes the error immediately.

I just have no idea how my scenario / map file got like this in the first place. It's not like my server lost power mid-save or anything, even then, I'd expect it just fail to load instead of this weird failure.

If I start a fresh game with the same scenario code, I don't think I see the error anymore.

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.17.39] get_inventory() fails

Post by Bilka »

Oarc wrote:
Fri May 17, 2019 4:07 am
I found a way to reproduce the problem, but I feel like it's a corrupted save file or something?
https://transfer.sh/1wAPq/oarc-save-broken.zip
That save contains old scenario code, line 697 of oarc_utils is "local mainInv = player.get_inventory(defines.inventory.player_main)" which leads to the error in game versions that have the player -> character rename.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Oarc
Fast Inserter
Fast Inserter
Posts: 100
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

Re: [0.17.39] get_inventory() fails

Post by Oarc »

Ah... I didn't catch that, sorry for wasting your time, thanks for the help!

Post Reply

Return to “Not a bug”