lib/proceduralDunGen.h
/// Test if a hypothetical path doesn't go out of bounds of the map array.
Test if a hypothetical path doesn't go out of bounds of the map array.
Test if a hypothetical path doesn ' t go out of bounds of the map array .
int testPath(int **map, int rows, int cols, struct inertPoint inert, int length)
{
    if (length < 1) return 0;
    if (inert.dir == NORTH)
        while(length != 0){
            --inert.row; --length;
            if(inert.row <= 1) return 0;
            if(map[inert.row][inert.col] != WALL) return 0;
        }
    if (inert.dir == SOUTH)
        while(length != 0){
            ++inert.row; --length;
            if(inert.row >= (rows - 2)) return 0;
            if(map[inert.row][inert.col] != WALL) return 0;
        }
    if (inert.dir == WEST)
        while(length != 0){
            --inert.col; --length;
            if(inert.col <= 1) return 0;
            if(map[inert.row][inert.col] != WALL) return 0;
        }
    if (inert.dir == EAST)
        while(length != 0){
            ++inert.col; --length;
            if(inert.col >= (cols - 2)) return 0;
            if(map[inert.row][inert.col] != WALL) return 0;
        }
    return 1;
}
int testPath ( int * * map , int rows , int cols , struct inertPoint inert , int length ) { if ( length < 1 ) return 0 ; if ( inert . dir == NORTH ) while ( length != 0 ) { -- inert . row ; -- length ; if ( inert . row <= 1 ) return 0 ; if ( map [ inert . row ] [ inert . col ] != WALL ) return 0 ; } if ( inert . dir == SOUTH ) while ( length != 0 ) { ++ inert . row ; -- length ; if ( inert . row >= ( rows - 2 ) ) return 0 ; if ( map [ inert . row ] [ inert . col ] != WALL ) return 0 ; } if ( inert . dir == WEST ) while ( length != 0 ) { -- inert . col ; -- length ; if ( inert . col <= 1 ) return 0 ; if ( map [ inert . row ] [ inert . col ] != WALL ) return 0 ; } if ( inert . dir == EAST ) while ( length != 0 ) { ++ inert . col ; -- length ; if ( inert . col >= ( cols - 2 ) ) return 0 ; if ( map [ inert . row ] [ inert . col ] != WALL ) return 0 ; } return 1 ; }
Test if a hypothetical path doesn't go out of bounds of the map array.
Test if a hypothetical path doesn ' t go out of bounds of the map array .