diff --git a/game.cpp b/game.cpp index b8eefb41..0313d9ec 100644 --- a/game.cpp +++ b/game.cpp @@ -3136,27 +3136,28 @@ bool makeEmpty(cell *c) { int numgates = 0; -void toggleGates(cell *ct, eWall type, int rad) { - if(!ct) return; - if(ct->wall == waOpenGate && type == waClosePlate) { - bool onWorm = false; - if(isWorm(ct)) onWorm = true; - for(int i=0; itype; i++) - if(ct->mov[i] && ct->mov[i]->wall == waOpenGate && isWorm(ct->mov[i])) onWorm = true; - if(!onWorm) { - ct->wall = waClosedGate, numgates++; - if(rad<1) rad=1; - if(ct->item) { - playSound(ct, "hit-crush"+pick123()); - addMessage(XLAT("%The1 is crushed!", ct->item)); - ct->item = itNone; +void toggleGates(cell *c, eWall type, int rad) { + if(!c) return; + celllister cl(c, rad, 1000000, NULL); + for(cell *ct: cl.lst) { + if(ct->wall == waOpenGate && type == waClosePlate) { + bool onWorm = false; + if(isWorm(ct)) onWorm = true; + for(int i=0; itype; i++) + if(ct->mov[i] && ct->mov[i]->wall == waOpenGate && isWorm(ct->mov[i])) onWorm = true; + if(!onWorm) { + ct->wall = waClosedGate, numgates++; + if(rad<1) rad=1; + if(ct->item) { + playSound(ct, "hit-crush"+pick123()); + addMessage(XLAT("%The1 is crushed!", ct->item)); + ct->item = itNone; + } } } + if(ct->wall == waClosedGate && type == waOpenPlate) + ct->wall = waOpenGate, rad = 1, numgates++; } - if(ct->wall == waClosedGate && type == waOpenPlate) - ct->wall = waOpenGate, rad = 1, numgates++; - if(rad) for(int i=0; itype; i++) - toggleGates(ct->mov[i], type, rad-1); } void toggleGates(cell *ct, eWall type) {