From 01300364ec077462bb499aa7058c3fb15cf28896 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 23 Apr 2020 02:18:39 -0300 Subject: This sketch should fix the two major bugs --- npc/maze0/config.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/npc/maze0/config.txt b/npc/maze0/config.txt index c729b58bf..305c95603 100644 --- a/npc/maze0/config.txt +++ b/npc/maze0/config.txt @@ -290,12 +290,59 @@ function script MazeFix { if (getd(.@v$+"$["+MAZESOUTH+"]") != "WALL") .@skip=true; - // If it doesn't, but is an edge, we don't care + // Finally skip + if (.@skip) { + .@y++; + continue; + } + + .@dirns=any(true, false); + + // If it doesn't, but is an edge, so we cannot enforce both rules // Do note (x,y) only goes to (MX-1, MY-1) because index if (.@x >= MAZE_MX-1 || .@y >= MAZE_MY-1) .@skip=true; // Finally skip + if (.@skip) { + // End of X axis (row) + if (.@x >= MAZE_MX-1) { + .@x1=0; .@al=true; + while (.@x1 < .@x) { + .@vi=MazeVar(.@x1, .@y); + // There's a wall somewhere + if (getd(.@v$+"$["+MAZE_EAST+"]") == "WALL") { + .@al=false; + break; + } + .@x1++; + } + // There's no walls, so we need safeties + if (.@al) { + // Could pick a random place, but... + .@skip=false; .@dirns=true; + } + // End of Y axis (column) + } else { + .@y1=0; .@al=true; + while (.@y1 < .@y) { + .@vi=MazeVar(.@x, .@y1); + // There's a wall somewhere + if (getd(.@v$+"$["+MAZESOUTH+"]") == "WALL") { + .@al=false; + break; + } + .@y1++; + } + // There's no walls, so we need safeties + if (.@al) { + // Could pick a random place, but... + .@skip=false; .@dirns=false; + } + } + } + + // All fine, continue to next row if (.@skip) { .@y++; continue; @@ -304,7 +351,7 @@ function script MazeFix { debugmes "(%d, %d) editing from %d", .@x, .@y, getd(.@v$+"_ID"); // At least one of those paths must be open - if (any(true, false)) { + if (.@dirns) { // Force the opening to south .@v2$=MazeVar(.@x, .@y+1); setd(.@v$+"$["+MAZESOUTH+"]", str(.@x)+"_"+str(.@y+1)); -- cgit v1.2.3-60-g2f50