mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-09 01:46:29 +02:00
fix crash when undoing if there were no snapshots
This commit is contained in:
@@ -233,6 +233,8 @@ GameController::~GameController()
|
|||||||
void GameController::HistoryRestore()
|
void GameController::HistoryRestore()
|
||||||
{
|
{
|
||||||
std::deque<Snapshot*> history = gameModel->GetHistory();
|
std::deque<Snapshot*> history = gameModel->GetHistory();
|
||||||
|
if (!history.size())
|
||||||
|
return;
|
||||||
unsigned int historyPosition = gameModel->GetHistoryPosition();
|
unsigned int historyPosition = gameModel->GetHistoryPosition();
|
||||||
unsigned int newHistoryPosition = std::max((int)historyPosition-1, 0);
|
unsigned int newHistoryPosition = std::max((int)historyPosition-1, 0);
|
||||||
// When undoing, save the current state as a final redo
|
// When undoing, save the current state as a final redo
|
||||||
|
Reference in New Issue
Block a user