From 8437316c36f157be22c224e3224d314080ed29a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Mon, 1 Apr 2013 19:25:21 +0200 Subject: [PATCH] Topping: give a default empty move to the player. This avoids a crash if the player uses hints at the first turn. --- game/topping.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/game/topping.cpp b/game/topping.cpp index 6d6a5aa..c15c073 100644 --- a/game/topping.cpp +++ b/game/topping.cpp @@ -65,7 +65,19 @@ void Topping::start() { const PlayedRack &newRack = helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW); - setGameAndPlayersRack(newRack, false); + // FIXME: we assign an empty move to the player. It is not very clean, + // but at the moment it is needed to avoid a crash in History::addPenalty() + // when the player uses hints in the first turn. + // The actual bug lies probably in the design of the History class. + // + // The unfortunate consequence is that there will be 2 PlayerMoveCmd + // commands for the player, at every turn. Deleting the empty move is + // not possible (it would crash in the same way), and replacing it + // breaks the history of the game when going back to the previous turn. + // At the moment, having 2 PlayerMoveCmd doesn't seem to cause any + // particular problem, but it would be better to fix that + // nevertheless... + setGameAndPlayersRack(newRack, true); } catch (EndGameException &e) {