From 82ec6b27755eb2020f8a8b18b2bdee62857f731d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Thu, 3 Oct 2024 10:58:28 +0200 Subject: [PATCH] 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 b0ea52690ba5, 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. --- src/simulation/Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index e3b54b317..c3507daaa 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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; } }