diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index bf4bc7b0f1..9194d442de 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -4056,6 +4056,9 @@ void Simulation::UpdateParticles(int start, int end) dy = parts[i].vy*ISTP/mv; fin_xf = parts[i].x; fin_yf = parts[i].y; + fin_x = (int)(fin_xf+0.5f); + fin_y = (int)(fin_yf+0.5f); + bool closedEholeStart = this->InBounds(fin_x, fin_y) && (bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL]); while (1) { mv -= ISTP; @@ -4092,7 +4095,7 @@ void Simulation::UpdateParticles(int start, int end) //block if particle can't move (0), or some special cases where it returns 1 (can_move = 3 but returns 1 meaning particle will be eaten) //also photons are still blocked (slowed down) by any particle (even ones it can move through), and absorb wall also blocks particles int eval = eval_move(t, fin_x, fin_y, NULL); - if (!eval || (can_move[t][pmap[fin_y][fin_x]&0xFF] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL) + if (!eval || (can_move[t][pmap[fin_y][fin_x]&0xFF] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || closedEholeStart!=(bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL])) { // found an obstacle clear_xf = fin_xf-dx; diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 801f766066..b4627846fd 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -207,6 +207,11 @@ class Simulation void clear_sim(); Simulation(); ~Simulation(); + + bool InBounds(int x, int y) + { + return (x>=0 && y>=0 && x