mirror of
https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense.git
synced 2026-03-18 21:30:36 +01:00
Fix segFault (forgot to check if tower have graphics in clearTower)
# To do: - Upgrade des tours - Dasagne - Easter egg - I'm a teapot
This commit is contained in:
@@ -321,7 +321,7 @@ void Game::mousePressEvent(QMouseEvent* event) {
|
||||
placeTower(event);
|
||||
}
|
||||
|
||||
void Game::endRound() {
|
||||
void Game::endRound() const {
|
||||
if(player->getHealth() == player->getPreviousHealth()) {
|
||||
player->heal(5);
|
||||
}
|
||||
@@ -330,9 +330,10 @@ void Game::endRound() {
|
||||
|
||||
void Game::clearTowers() {
|
||||
for (auto* tower : towers) {
|
||||
if (tower->getGraphics()->scene() == &gameMap) {
|
||||
if (tower != nullptr && tower->getGraphics() != nullptr && tower->getGraphics()->scene() == &gameMap) {
|
||||
gameMap.removeItem(tower->getGraphics());
|
||||
}
|
||||
delete tower;
|
||||
}
|
||||
towers.clear(); // Clear the list of towers after deleting them
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
void gameOver();
|
||||
void resetGame();
|
||||
void placeTower(QMouseEvent* event);
|
||||
void endRound();
|
||||
void endRound() const;
|
||||
void clearTowers();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user