Switching to Linux to find a memory bug and I want to keep a record of what caused it.

This commit is contained in:
Zed A. Shaw 2025-07-30 22:34:26 -04:00
parent be3eef7082
commit e51fb8627c
7 changed files with 23 additions and 42 deletions

View file

@ -60,34 +60,10 @@ shared_ptr<gui::BossFightUI> LevelManager::create_bossfight(shared_ptr<DinkyECS:
return make_shared<gui::BossFightUI>(world, boss_id);
}
DinkyECS::Entity LevelManager::spawn_enemy(std::string named) {
DinkyECS::Entity LevelManager::spawn_enemy(const std::string& named) {
(void)named;
auto& level = current();
auto &config = level.world->get_the<GameConfig>();
auto entity_data = config.enemies[named];
WorldBuilder builder(*level.map);
auto entity_id = builder.configure_entity_in_room(*level.world, entity_data, 0);
auto& entity_pos = level.world->get<Position>(entity_id);
auto player_pos = level.world->get<Position>(level.player);
for(matrix::box it{level.map->walls(),
player_pos.location.x, player_pos.location.y, 1}; it.next();)
{
if(level.map->can_move({it.x, it.y})) {
// this is where we move it closer to the player
entity_pos.location.x = it.x;
entity_pos.location.y = it.y;
break;
}
}
level.collision->insert(entity_pos.location, entity_id, true);
return entity_id;
dbc::log("THIS FUNCTION NEEDS A REWRITE");
return 0;
}
size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
@ -96,7 +72,9 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
auto scaling = scale_level();
auto map = make_shared<Map>(scaling.map_width, scaling.map_height);
WorldBuilder builder(*map);
auto collision = std::make_shared<SpatialMap>();
WorldBuilder builder(*map, *collision);
builder.generate(*world);
size_t index = $levels.size();
@ -104,7 +82,7 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
auto player = world->get_the<Player>();
$levels.emplace_back(index, player.entity, map, world,
make_shared<LightRender>(map->tiles()), builder.$collision);
make_shared<LightRender>(map->tiles()), collision);
dbc::check(index == $levels.size() - 1, "Level index is not the same as $levels.size() - 1, off by one error");
return index;