1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-11 18:00:34 +00:00

more efficient gate toggling algorithm

This commit is contained in:
Zeno Rogue 2018-04-12 11:00:12 +02:00
parent 2dfc12799d
commit e6a5c41c9b

View File

@ -3136,8 +3136,10 @@ bool makeEmpty(cell *c) {
int numgates = 0; int numgates = 0;
void toggleGates(cell *ct, eWall type, int rad) { void toggleGates(cell *c, eWall type, int rad) {
if(!ct) return; if(!c) return;
celllister cl(c, rad, 1000000, NULL);
for(cell *ct: cl.lst) {
if(ct->wall == waOpenGate && type == waClosePlate) { if(ct->wall == waOpenGate && type == waClosePlate) {
bool onWorm = false; bool onWorm = false;
if(isWorm(ct)) onWorm = true; if(isWorm(ct)) onWorm = true;
@ -3155,8 +3157,7 @@ void toggleGates(cell *ct, eWall type, int rad) {
} }
if(ct->wall == waClosedGate && type == waOpenPlate) if(ct->wall == waClosedGate && type == waOpenPlate)
ct->wall = waOpenGate, rad = 1, numgates++; ct->wall = waOpenGate, rad = 1, numgates++;
if(rad) for(int i=0; i<ct->type; i++) }
toggleGates(ct->mov[i], type, rad-1);
} }
void toggleGates(cell *ct, eWall type) { void toggleGates(cell *ct, eWall type) {