diff --git a/levelmanager.cpp b/levelmanager.cpp index 910b42c..85a3a65 100644 --- a/levelmanager.cpp +++ b/levelmanager.cpp @@ -10,22 +10,20 @@ LevelManager::LevelManager() { } size_t LevelManager::create_level() { - GameLevel level; - level.index = $levels.size(); + auto world = make_shared(); + save::load_configs(*world); - level.world = make_shared(); - save::load_configs(*level.world); + auto map = make_shared(GAME_MAP_X, GAME_MAP_Y); + WorldBuilder builder(*map); + builder.generate(*world); - level.map = make_shared(GAME_MAP_X, GAME_MAP_Y); - WorldBuilder builder(*level.map); - builder.generate(*level.world); + size_t index = $levels.size(); - level.lights = make_shared(level.map->width(), level.map->height()); + $levels.emplace_back(index, map, world, + make_shared(map->width(), map->height())); - $levels.push_back(level); - - dbc::check(level.index == $levels.size() - 1, "Level index is not the same as $levels.size() - 1, off by one error"); - return level.index; + dbc::check(index == $levels.size() - 1, "Level index is not the same as $levels.size() - 1, off by one error"); + return index; } GameLevel &LevelManager::next() { diff --git a/levelmanager.hpp b/levelmanager.hpp index 16af2e2..461a981 100644 --- a/levelmanager.hpp +++ b/levelmanager.hpp @@ -8,10 +8,10 @@ struct GameLevel { - size_t index = 0; - std::shared_ptr map = nullptr; - std::shared_ptr world = nullptr; - std::shared_ptr lights = nullptr; + size_t index; + std::shared_ptr map; + std::shared_ptr world; + std::shared_ptr lights; }; class LevelManager { diff --git a/lights.cpp b/lights.cpp index c5a2762..dbd6cf8 100644 --- a/lights.cpp +++ b/lights.cpp @@ -9,7 +9,7 @@ namespace lighting { for(matrix::box it{$lightmap, at.x, at.y, (size_t)floor(source.radius)}; it.next();) { if($paths.$paths[it.y][it.x] != WALL_PATH_LIMIT) { $lightmap[it.y][it.x] = light_level(source.strength, it.distance(), it.x, it.y); - has_light.push_back({it.x, it.y}); + has_light.emplace_back(it.x, it.y); } } } diff --git a/map.cpp b/map.cpp index f640722..080d7f9 100644 --- a/map.cpp +++ b/map.cpp @@ -209,9 +209,6 @@ void Map::expand() { } void Map::add_room(Room &room) { - // println(">>ADDING ROOM x/y={},{}; w/h={},{}; map={},{}", - // room.x, room.y, room.width, room.height, $width, $height); - room.x++; room.y++; room.width--; diff --git a/pathing.cpp b/pathing.cpp index c6ad3cc..8cc3bba 100644 --- a/pathing.cpp +++ b/pathing.cpp @@ -9,7 +9,7 @@ inline void add_neighbors(PointList &neighbors, Matrix &closed, size_t y, size_t for(matrix::box it{closed, x, y, 1}; it.next();) { if(closed[it.y][it.x] == 0) { closed[it.y][it.x] = 1; - neighbors.push_back({.x=it.x, .y=it.y}); + neighbors.emplace_back(it.x, it.y); } } } @@ -39,7 +39,7 @@ void Pathing::compute_paths(Matrix &walls) { if($input[y][x] == 0) { $paths[y][x] = 0; closed[y][x] = 1; - starting_pixels.push_back({x,y}); + starting_pixels.emplace_back(x,y); } } diff --git a/worldbuilder.cpp b/worldbuilder.cpp index 4bf65c7..f45bdb8 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -286,7 +286,7 @@ inline bool random_path(Map &map, PointList &holes, Point src, Point target) { inline void straight_path(Map &map, PointList &holes, Point src, Point target) { for(matrix::line dig{src, target}; dig.next();) { - holes.push_back({size_t(dig.x), size_t(dig.y)}); + holes.emplace_back(size_t(dig.x), size_t(dig.y)); Point expand{(size_t)dig.x+1, (size_t)dig.y}; if(map.inmap(expand.x, expand.y)) {