Page 1 of 1

[0.11.5] getcircuitcondition redux

Posted: Thu Dec 04, 2014 8:11 pm
by Kikkers
From the update notes:
kovarex wrote:
  • Fixed that LuaEntity::getcircuitcondition crashed the game for entities with non-zero condition, but no connection to the circuit network.
I think this fix triggered something else going wrong. I'm getting crashes when modifying circuit conditions while this function is called each tick.
Specifically, if I select a condition that evaluates to true where it was previously false, the game crashes.


It still only occurs in my mod, normal smart inserters are unaffected.

Re: [0.11.4] getcircuitcondition redux

Posted: Fri Dec 05, 2014 10:09 am
by kovarex
Can you provide a reproducible scenario?

Re: [0.11.4] getcircuitcondition redux

Posted: Fri Dec 05, 2014 1:00 pm
by Kikkers
Hmm, it seems that the exact same sequence does not always trigger the crash. I'll try to be more specific, give me a sec to test stuff, getcircuitcondition might not be the function to blame.

Re: [0.11.4] getcircuitcondition redux

Posted: Fri Dec 05, 2014 1:33 pm
by Kikkers
Okay, my assumption was wrong. It happens on a different function, either disconnectneighbour or connectneighbour. Not sure which one though, I've isolated this piece of code, which is executed each tick:

Code: Select all

	data[3].disconnectneighbour()
	data[3].disconnectneighbour(0)
	data[3].disconnectneighbour(1)
	data[3].connectneighbour(data[4]) -- copper
	data[3].connectneighbour(data[4], 0) -- red
	data[3].connectneighbour(data[4], 1) -- green
(data[3] and data[4] are entities of type electric-pole)

This works for a few ticks, then the game crashes.

Edit: While not really the right place to suggest it, but I would really like disconnectneighbour to optionally take a pole as an argument, so we can more easily remove only one specific connection.

Re: [0.11.5] getcircuitcondition redux

Posted: Thu Dec 11, 2014 1:47 pm
by kovarex
There was an error in the disconnectRed, disconnectGreen method related to this bugreport: https://forums.factorio.com/forum/vie ... =30&t=7122

I strongly believe that the bugfix should fix this problem as well (in 0.11.6), let me know if it isn't the case.

Re: [0.11.5] getcircuitcondition redux

Posted: Thu Dec 11, 2014 10:20 pm
by Kikkers
Looks like this doesn't trigger the crash anymore, consider this bug fixed (for now).

And also looks like you changed the behavior of the connect and disconnect funtions to now allow smart inserters as arguments. Glad you changed that, but I'll need to patch that in the mod :)
(I'm curious though, was this an intentional change? I can't find it in the patch notes. Kinda assuming it slipped your mind to mention it.)

Re: [0.11.5] getcircuitcondition redux

Posted: Thu Dec 11, 2014 11:33 pm
by Kikkers
Apparently this change in behavior actually broke my mod in a very minor way, but it comes down to the following:

I need to be able to disconnect and connect each connected wire. This requires the neighbours list to iterate over. This worked previously, but now, because you can't actually find a smart inserter in the neighbours list, this won't work in conjunction with the changes.

I hope you will soon be able to add smart inserters to the neighbours list as well (I'm guessing that will become necessary in 0.12.x anyway).