Page 1 of 1
[boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Tue Oct 29, 2024 9:29 pm
by doktorstick
The attached screenshot shows the result after the undo. I'll describe how it got there in prose. Initial condition was green wire connections:
far left chest -> electric pole -> station. I deleted the electric pole and the green wire from the station automatically connected to the far left chest. I then undid the pole deletion and the station now connects to the far left chest and the electric pole. The state of the wire connections did not return to the start.
In summary:
- green wire: chest -> pole -> station
- delete pole
- green wire: chest -> station
- undo
- green wire: chest -> pole -> station and chest -> station

- 10-29-2024, 16-23-01.png (957.97 KiB) Viewed 1396 times
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Tue Mar 04, 2025 12:52 pm
by kovarex
Hello, thanks for the bug report.
It is now fixed for the 2.0.39.
To be able to fix this properly, we had to make a change, that marking electric poles for deconstruction will also immediatelly disconnect all the wires. This is to be able to store all the wires changes into the undo action related to the removal of the electric pole.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Wed Mar 05, 2025 12:23 pm
by kovarex
This is very sad, but after several days of making this change and making everything work, we realized it is all bad idea.
The reason is simple, when you mark poles for deconstruction, they get disconnected, and undo works great, but when you "unmark" things for deconstruction, like when someone else wants to cancel the deconstruction of a big area for example, the electric poles are still disconnected.
This is a show stopper, and all the works was basically wasted time.
For this reason, we will just keep this bug in the game, as there is no nice solution to it.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 11:59 am
by Hares
kovarex wrote: Wed Mar 05, 2025 12:23 pm
This is very sad, but after several days of making this change and making everything work, we realized it is all bad idea.
The reason is simple, when you mark poles for deconstruction, they get disconnected, and undo works great, but when you "unmark" things for deconstruction, like when someone else wants to cancel the deconstruction of a big area for example, the electric poles are still disconnected.
This is a show stopper, and all the works was basically wasted time.
For this reason, we will just keep this bug in the game, as there is no nice solution to it.
Can you provide a real example when somebody marks segment for a deconstruction and then someone else cancels it without one of these players being a troll?
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:00 pm
by boskid
Hares wrote: Thu Mar 06, 2025 11:59 am
Can you provide a real example when somebody marks segment for a deconstruction and then someone else cancels it without one of these players being a troll?
It is not only case of trolls, a player itself when using cancel deconstruction would be also affected as that would be a new action so it could not use wires from the undo.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:08 pm
by Hares
boskid wrote: Thu Mar 06, 2025 12:00 pm
Hares wrote: Thu Mar 06, 2025 11:59 am
Can you provide a real example when somebody marks segment for a deconstruction and then someone else cancels it without one of these players being a troll?
It is not only case of trolls, a player itself when using cancel deconstruction would be also affected as that would be a new action so it could not use wires from the undo.
I got your point.
However, I don't see a problem there - you can use undo, or manually reconnect wires. It's hard for me to imagine a real use-case where you intentionally mark large portion of your base to deconstruction and only after that, without undoing it, unmark part of it (or unmark power poles only). I will deliberately take my attention on the next time I unmark smth for deconstruction to see if any poles are affected and if yes -- how many.
Also, if the same player is unmarking for deconstruction, the wires info can be extracted from the
undo history.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:14 pm
by boskid
Hares wrote: Thu Mar 06, 2025 12:08 pm
Also, if the same player is unmarking for deconstruction, the wires info can be extracted from the
undo history.
No. Even if we would allow digging in the undo action, a lot of undo related stuff depends on the order of applying actions and it could happen that there was record for wire removed but there was also record for wire added, then again removed and again added. Which record should be used? Other players interacting with shared world is also problematic for undo because the undo may be related to a state of the world that is not valid anymore and so undo may sometimes fail to apply. It could be that a single player could have an undo actions for "removed wire, then removed wire" applying to the same entity just because other player added a wire in between
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:23 pm
by Hares
boskid wrote: Thu Mar 06, 2025 12:14 pm
... there was record for wire removed but there was also record for wire added, then again removed and again added. Which record should be used?
- Restore the state when last deconstruction order was tasked (if any)
- Do not allow connecting wires to entities marked for deconstruction
Also, no need for complex conflict resolvers as, even in multiplayer, it's rare occasion when multiple players are working on the same part of factory, and if they actually do, the odds of conflicting actions within last few minutes are extremely low. Maybe we can make a poll on the topic, i.e. which buggy behaviour is more preferable (as all options described in this discussion are more or less buggy).
Edit:
Alternative proposal. Save wires within entity marked for deconstruction, and still do not allow connecting it as long as it marked for deconstruction.
Edit 2:
The race condition you are speaking of is also not relevant as the "commit war" case will also be problematic even without the proposed change, as the history might refer to the entity removed by a different player.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:34 pm
by boskid
Hares wrote: Thu Mar 06, 2025 12:23 pm
Edit:
Alternative proposal. Save wires within entity marked for deconstruction, and still do not allow connecting it as long as it marked for deconstruction.
1/ Have 2 poles (left and right) connected with wire
2/ Mark left pole to deconstruct. It removes wire and remembers it.
3/ Mark right pole to deconstruct. There are no wires so it remembers nothing.
4/ Cancel deconstruction of left pole. It cannot restore wire because other pole is still to be deconstructed.
5/ Cancel deconstruction of right pole. It has no wires stored so nothing is restored.
Even if you would say this is artificial scenario, it is one of the most common scenarios because of the entity search order of returning entities: selecting entities to deconstruct will visit entities one by one, lets say in order (left then right) and cancel will do the same: will visit entities one by one (also left then right).
In theory there exists a solution for this case, in step 4 the pole that is cancel deconstructed after seeing that other pole is still to be deconstructed could transfer those wires for the right pole to stopre so in step 5 the other pole would restore wires. But the rewiring can also happen when other entity is not an electric pole. It could be a power switch or a regular chest with circuit wires which are also rewired.
-- edit:
There exists a "true" solution: get rid of the rewiring because that is what causes new wires not seen by the undo (ordering deconstruction of entity remembers wires going out of that entity but it is not aware of wires that will be added by rewire). I am not sure if getting rid of this feature would be considered a fix.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:40 pm
by Hares
boskid wrote: Thu Mar 06, 2025 12:34 pm
Even if you would say this is artificial scenario, it is one of the most common scenarios because of the entity search order of returning entities: selecting entities to deconstruct will visit entities one by one, lets say in order (left then right) and cancel will do the same: will visit entities one by one (also left then right).
Fair point. Thanks, I didn't see it.
boskid wrote: Thu Mar 06, 2025 12:34 pm
There exists a "true" solution: get rid of the rewiring because that is what causes new wires not seen by the undo (ordering deconstruction of entity remembers wires going out of that entity but it is not aware of wires that will be added by rewire). I am not sure if getting rid of this feature would be considered a fix.
What rewiring are you referring to? Rewiring on entity removal, or rewiring at all? For me (advanced player) the 1st causes more problems than benefits, but I can clearly see this as a point of frustration for the new players. The 2nd is a crucial part of a game, and doing so will destroy circuit networks.
Re: [boskovarexid] [2.0.12] Undo of pole deletion doesn't remove direct circuit connection
Posted: Thu Mar 06, 2025 12:45 pm
by boskid
Rewiring is part of electric pole destroy logic where it tries to add wires connecting entities that were previously connected through the electric pole being removed. If you have 3 poles { left, center, right } and 2 wires { "left-center", "center-right" }, by removing center pole a new wire "left-right" will be added if those poles were within wire reach.