prevent from segf when no button on scene

This commit is contained in:
arthur.jamet
2021-06-08 12:43:18 +02:00
parent b2789809bf
commit b21621375c
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -392,7 +392,6 @@ namespace BBM
// .addComponent<ControllableComponent>() // .addComponent<ControllableComponent>()
// .addComponent<KeyboardComponent>() // .addComponent<KeyboardComponent>()
// .addComponent<CollisionComponent>(WAL::Callback<WAL::Entity &, const WAL::Entity &>(), &MapGenerator::wallCollide, 3); // .addComponent<CollisionComponent>(WAL::Callback<WAL::Entity &, const WAL::Entity &>(), &MapGenerator::wallCollide, 3);
std::srand(std::time(nullptr));
MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene);
return scene; return scene;
} }
@@ -408,6 +407,7 @@ namespace BBM
int Runner::run() int Runner::run()
{ {
std::srand(std::time(nullptr));
WAL::Wal wal; WAL::Wal wal;
Runner::addSystems(wal); Runner::addSystems(wal);
Runner::enableRaylib(wal); Runner::enableRaylib(wal);
@@ -45,6 +45,8 @@ namespace BBM
currentButton = nullptr; currentButton = nullptr;
if (currentButton == nullptr && buttons.size()) if (currentButton == nullptr && buttons.size())
currentButton = &(**buttons.begin()); currentButton = &(**buttons.begin());
if (!currentButton)
return;
this->updateCurrentButton(); this->updateCurrentButton();
for (auto &[buttonEntity, clickComponent]: buttons) { for (auto &[buttonEntity, clickComponent]: buttons) {
if (buttonEntity == *currentButton) { if (buttonEntity == *currentButton) {