Fix yet another extremely rare pmap corruption

Don't just set the .type of struct Particle to 0, kids. Code tracked back to the times from before git; already present in b0ea52690b, the initial commit.

Reproduce with

	sim.clearSim()
	elem.property(elem.DEFAULT_PT_DMND, "Update", function(i, x, y)
		local ni = sim.photons(x, y)
		if ni then
			if not sim.partProperty(ni, "vx") then
				print(x, y)
				assert(false)
			end
		end
	end)
	local i = sim.partCreate(-1, 100, 100, elem.DEFAULT_PT_NEUT)
	sim.partProperty(i, "vx", 0)
	sim.partProperty(i, "vy", 2)
	sim.partCreate(-1, 100, 100, elem.DEFAULT_PT_DMND)
	sim.partCreate(-1, 100, 102, elem.DEFAULT_PT_PRTI)
	sim.paused(true)
	sim.framerender(1)

Though if done this way, it's actually a photons corruption.
This commit is contained in:
Tamás Bálint Misius
2024-10-03 10:58:28 +02:00
parent 126e636eb3
commit 82ec6b2775

View File

@@ -1216,7 +1216,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
if (!portalp[parts[ID(r)].tmp][count][nnx].type)
{
portalp[parts[ID(r)].tmp][count][nnx] = parts[i];
parts[i].type=PT_NONE;
kill_part(i);
break;
}
}