src/MapGenerator/randomMine.cpp
/**
 * This function is used to calculate specific block around a block.
 */
This function is used to calculate specific block around a block.
This function is used to calculate specific block around a block .
uint8_t MapGenerator::typeAround(const uint16_t &row, const uint16_t &line,
                                 MinefieldPtr emptyField, BLOCKTYPE blockType) {
    MField::Map *map = emptyField->GetMap();
    int blocks = 0;
    for (int i = row - 1; i <= row + 1; ++i)
        for (int j = line - 1; j <= line + 1; ++j) {
            if (i >= 0 && j >= 0 && i < emptyField->GetRow() && j < emptyField->GetLine()) {
                if (!(i == row && j == line) && (*map)[i][j] == blockType) {
                    ++blocks;
                }
            }
        }
    return blocks;
}
uint8_t MapGenerator :: typeAround ( const uint16_t & row , const uint16_t & line , MinefieldPtr emptyField , BLOCKTYPE blockType ) { MField :: Map * map = emptyField -> GetMap ( ) ; int blocks = 0 ; for ( int i = row - 1 ; i <= row + 1 ; ++ i ) for ( int j = line - 1 ; j <= line + 1 ; ++ j ) { if ( i >= 0 && j >= 0 && i < emptyField -> GetRow ( ) && j < emptyField -> GetLine ( ) ) { if ( ! ( i == row && j == line ) && ( * map ) [ i ] [ j ] == blockType ) { ++ blocks ; } } } return blocks ; }
This function is used to calculate specific block around a block.
This function is used to calculate specific block around a block .