Page 1 of 1

[boskid][1.1.74] Furnace progress in quantum state after json migration

Posted: Mon Jan 16, 2023 8:06 pm
by Stringweasel
What
I'm changing the internal name of a furnace entity, and after the migration the previous crafting_progress is reset to zero and the machine idles.
- If I then add another burnable item of the same type then the progress starts at where it should have been (and not at zero)
- Or if I instead add a different burnable item then the progress starts at zero.

I would expect the furnace to continue burning the entity that was burning previously as if nothing changed, even though the internal name changed.

Note: I could not recreate the same behaviour with the vanilla furnace, the progress was always correct after the migration. But I could never get my modded furnace-type-machine to have the same effect. See first comment, I reproduced it by placing a single iron-ore in the furnace, letting it burn, and then migrating.
Reproduction
Attached is a `pre.zip` before migration, made with 0.3.0. As well as a `post.zip` which applied a migration contained in 0.3.1.

1. Open `post.zip` with 0.3.1. The game should be paused.
2. Notice both machines has a progress of zero. The items in the boxes is the same type that was burning in `pre.zip`.
3.a. Unpause, and after the inserter inserted the items notice the left machine start at around 80-ish% in the next tick, and right machine at 20-ish%.
4.b. Or rotate (delete) the inserters, and watch the machines stay idle after no input. (not expected)
4.c. Or insert some other allowed burnable item (different than what was being burned, as shown in the box) and notice the progress start at 0.

Re: [1.1.74] Furnace progress in quantum state after json migration

Posted: Mon Jan 16, 2023 9:13 pm
by Stringweasel
Just reproduced it with the vanilla furnace. To get it into the quantum state I only added a single iron-ore which then started burning, meaning there was nothing in t

1. New map with a single electric-furnace (+ supporting structures)
2. Add a single iron-ore and pause the game before the iron is completely melted.
3. There should now be nothing in the input or output slots, but the progress bar should be in-progress.
4. Exit the game. Write a tiny mod that migrates the furnace (see below)
5. Enter game with migration, and witness furnace now in a quantum state.

Pretty sure for the migration to work correctly there needs to be items in the input-inventory. When I tested it initially I added an entire stack of ore and that worked as expected. Meaning migration doesn't work if the furnace is burning without an item in the input-inventory.

Quick code you can add to create and migrate to a new furnace.

Code: Select all

--new.json
{
        "entity":
        [
            ["electric-furnace", "n"]
        ]        
}

-- data.lua
require "util"
n = table.deepcopy(data.raw["furnace"]["electric-furnace"])
n.name = "n"
data:extend{ n }

Re: [1.1.74] Furnace progress in quantum state after json migration

Posted: Fri Mar 10, 2023 1:21 pm
by boskid
I just verified and its not even because of the json migration. The issue also happens when loading such save file in a prototypes changed mode.

Re: [boskid][1.1.74] Furnace progress in quantum state after json migration

Posted: Sat Mar 11, 2023 8:33 am
by boskid
Ok i found and fixed the issue. It was related to technology effects reset in which case a furnace would stop crafting and would check what recipe it should be crafting based on the items in the ingredients slot. In this case because ingredients inventory was empty it would stay without a recipe but was not clearing the bonus progress as well as normal crafting progress. Issue is now fixed for 1.1.78: during the technology effects reset if the furnace is already crafting and the recipe is still valid, the furnace will continue crafting that recipe.