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:
Zed A. Shaw 2024-12-04 21:43:59 -05:00
parent ae43dad499
commit 9abb39a3bf
14 changed files with 72 additions and 35 deletions

View file

@ -66,6 +66,7 @@ Point Map::place_entity(size_t room_index) {
dbc::check(room_index < $rooms.size(), "room_index is out of bounds, not enough rooms");
Room &start = $rooms[room_index];
// BUG: this can place someone in a wall on accident, move them if they're stuck
return {start.x+1, start.y+1};
}
@ -142,12 +143,14 @@ bool Map::neighbors(Point &out, bool random) {
int cur = paths[out.y][out.x];
// pick a random start of directions
// BUG: is uniform inclusive of the dir.size()?
int rand_start = Random::uniform<int>(0, dirs.size());
// go through all possible directions
for(size_t i = 0; i < dirs.size(); i++) {
// but start at the random start, effectively randomizing
// which valid direction to go
// BUG: this might be wrong given the above ranom from 0-size
Point dir = dirs[(i + rand_start) % dirs.size()];
if(!inmap(dir.x, dir.y)) continue; //skip unpathable stuff
int weight = cur - paths[dir.y][dir.x];