예제 #1
0
bool will_flood_stop(map *m, bool fill[SEEX * MAPSIZE][SEEY * MAPSIZE],
                     int x, int y)
{
 if (x == 0 || y == 0 || x == SEEX * MAPSIZE - 1 || y == SEEY * MAPSIZE - 1)
  return false;

 fill[x][y] = true;
 bool skip_north = (fill[x][y - 1] || m->ter(x, y - 1) == t_wall_h ||
                                      m->ter(x, y - 1) == t_wall_v ||  
                                      m->ter(x, y - 1) == t_wall_wood),
      skip_south = (fill[x][y + 1] || m->ter(x, y + 1) == t_wall_h ||
                                      m->ter(x, y + 1) == t_wall_v ||
                                      m->ter(x, y + 1) == t_wall_wood),
      skip_east  = (fill[x + 1][y] || m->ter(x + 1, y) == t_wall_h ||
                                      m->ter(x + 1, y) == t_wall_v ||  
                                      m->ter(x + 1, y) == t_wall_wood),
      skip_west  = (fill[x - 1][y] || m->ter(x - 1, y) == t_wall_h ||
                                      m->ter(x - 1, y) == t_wall_v ||
                                      m->ter(x - 1, y) == t_wall_wood);

 return ((skip_north || will_flood_stop(m, fill, x    , y - 1)) &&
         (skip_east  || will_flood_stop(m, fill, x + 1, y    )) &&
         (skip_south || will_flood_stop(m, fill, x    , y + 1)) &&
         (skip_west  || will_flood_stop(m, fill, x - 1, y    ))   );
}
예제 #2
0
bool will_flood_stop(map *m, bool fill[SEEX * MAPSIZE][SEEY * MAPSIZE],
                     int x, int y)
{
 if (x == 0 || y == 0 || x == SEEX * MAPSIZE - 1 || y == SEEY * MAPSIZE - 1)
  return false;

 fill[x][y] = true;
 bool skip_north = (fill[x][y - 1] || m->has_flag(supports_roof, x, y - 1)),
      skip_south = (fill[x][y + 1] || m->has_flag(supports_roof, x, y + 1)),
      skip_east  = (fill[x + 1][y] || m->has_flag(supports_roof, x + 1, y)),
      skip_west  = (fill[x - 1][y] || m->has_flag(supports_roof, x - 1, y));

 return ((skip_north || will_flood_stop(m, fill, x    , y - 1)) &&
         (skip_east  || will_flood_stop(m, fill, x + 1, y    )) &&
         (skip_south || will_flood_stop(m, fill, x    , y + 1)) &&
         (skip_west  || will_flood_stop(m, fill, x - 1, y    ))   );
}
예제 #3
0
bool construct::able_between_walls(game *g, point p)
{
 bool fill[SEEX * MAPSIZE][SEEY * MAPSIZE];
 for (int x = 0; x < SEEX * MAPSIZE; x++) {
  for (int y = 0; y < SEEY * MAPSIZE; y++)
   fill[x][y] = false;
 }

 return (will_flood_stop(&(g->m), fill, p.x, p.y)); // See bottom of file
}