Did a full code review to identify things to fix and either fixed them or noted BUG where I should come back.
This commit is contained in:
parent
ae43dad499
commit
9abb39a3bf
14 changed files with 72 additions and 35 deletions
|
@ -6,6 +6,7 @@ using namespace fmt;
|
|||
|
||||
inline int make_split(Room &cur, bool horiz) {
|
||||
size_t dimension = horiz ? cur.height : cur.width;
|
||||
// BUG: this might be better as a configurable 4 number
|
||||
int min = dimension / 4;
|
||||
int max = dimension - min;
|
||||
|
||||
|
@ -77,11 +78,13 @@ void WorldBuilder::partition_map(Room &cur, int depth) {
|
|||
right.width = size_t(cur.width - split);
|
||||
}
|
||||
|
||||
// BUG: min room size should be configurable
|
||||
if(depth > 0 && left.width > 2 && left.height > 2) {
|
||||
left.depth = depth - 1;
|
||||
partition_map(left, depth-1);
|
||||
}
|
||||
|
||||
// BUG: min room size should be configurable
|
||||
if(depth > 0 && right.width > 2 && right.height > 2) {
|
||||
right.depth = depth - 1;
|
||||
partition_map(right, depth-1);
|
||||
|
@ -104,6 +107,7 @@ void WorldBuilder::tunnel_doors(PointList &holes, Room &src, Room &target) {
|
|||
}
|
||||
|
||||
void WorldBuilder::generate() {
|
||||
PointList holes;
|
||||
Room root{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
|
@ -111,13 +115,11 @@ void WorldBuilder::generate() {
|
|||
.height = $map.$height
|
||||
};
|
||||
|
||||
// BUG: depth should be configurable
|
||||
partition_map(root, 10);
|
||||
$map.INVARIANT();
|
||||
|
||||
place_rooms();
|
||||
|
||||
PointList holes;
|
||||
|
||||
for(size_t i = 0; i < $map.$rooms.size() - 1; i++) {
|
||||
tunnel_doors(holes, $map.$rooms[i], $map.$rooms[i+1]);
|
||||
}
|
||||
|
@ -159,6 +161,8 @@ void WorldBuilder::place_rooms() {
|
|||
cur.width -= 4;
|
||||
cur.height -= 4;
|
||||
|
||||
// BUG: should I do this each time I connect rooms
|
||||
// BUG: rather than once when the room is created?
|
||||
add_door(cur);
|
||||
make_room(cur.x, cur.y, cur.width, cur.height);
|
||||
}
|
||||
|
@ -166,6 +170,8 @@ void WorldBuilder::place_rooms() {
|
|||
|
||||
bool WorldBuilder::dig_tunnel(PointList &holes, Point &src, Point &target) {
|
||||
Matrix &paths = $map.paths();
|
||||
|
||||
// BUG: limit should be a constant since it never changes
|
||||
int limit = $map.limit();
|
||||
|
||||
dbc::check(paths[src.y][src.x] != limit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue