From da016b298ce845d4f719e08ae6c1d904ad0863ce Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 21 Mar 2022 13:47:39 -0400 Subject: game shouldn't crash if all lamps are in unloaded chunks --- src/game.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index b5d667a..66b488c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -920,10 +920,14 @@ void Game::updatePlaying(size_t frameTime) { } } - std::uniform_int_distribution lampDist(0, lamps.size() - 1); - std::tuple popPos = lamps[lampDist(rng)]; + if (lamps.empty()) { + losing = LoseState::PoppingPlayer; + } else { + std::uniform_int_distribution lampDist(0, lamps.size() - 1); + std::tuple popPos = lamps[lampDist(rng)]; - popLamp(std::get<0>(popPos), std::get<1>(popPos), 1); + popLamp(std::get<0>(popPos), std::get<1>(popPos), 1); + } } } -- cgit 1.4.1