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:
parent
2dfc12799d
commit
e6a5c41c9b
37
game.cpp
37
game.cpp
@ -3136,27 +3136,28 @@ 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;
|
||||||
if(ct->wall == waOpenGate && type == waClosePlate) {
|
celllister cl(c, rad, 1000000, NULL);
|
||||||
bool onWorm = false;
|
for(cell *ct: cl.lst) {
|
||||||
if(isWorm(ct)) onWorm = true;
|
if(ct->wall == waOpenGate && type == waClosePlate) {
|
||||||
for(int i=0; i<ct->type; i++)
|
bool onWorm = false;
|
||||||
if(ct->mov[i] && ct->mov[i]->wall == waOpenGate && isWorm(ct->mov[i])) onWorm = true;
|
if(isWorm(ct)) onWorm = true;
|
||||||
if(!onWorm) {
|
for(int i=0; i<ct->type; i++)
|
||||||
ct->wall = waClosedGate, numgates++;
|
if(ct->mov[i] && ct->mov[i]->wall == waOpenGate && isWorm(ct->mov[i])) onWorm = true;
|
||||||
if(rad<1) rad=1;
|
if(!onWorm) {
|
||||||
if(ct->item) {
|
ct->wall = waClosedGate, numgates++;
|
||||||
playSound(ct, "hit-crush"+pick123());
|
if(rad<1) rad=1;
|
||||||
addMessage(XLAT("%The1 is crushed!", ct->item));
|
if(ct->item) {
|
||||||
ct->item = itNone;
|
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; i<ct->type; i++)
|
|
||||||
toggleGates(ct->mov[i], type, rad-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleGates(cell *ct, eWall type) {
|
void toggleGates(cell *ct, eWall type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user