From: Erik V. <ev...@us...> - 2009-11-25 18:48:29
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14410/rails/game Modified Files: GameManager.java GameManagerI.java Game.java Log Message: Better handling of load errors. If the game engine deems a move invalid, processing stops at that point, and play can be resumed from there. A sensible set of messages is displayed. Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** GameManager.java 8 Nov 2009 10:45:49 -0000 1.69 --- GameManager.java 25 Nov 2009 18:48:19 -0000 1.70 *************** *** 634,638 **** boolean result = true; ! DisplayBuffer.clear(); --- 634,638 ---- boolean result = true; ! DisplayBuffer.clear(); *************** *** 735,742 **** * @see rails.game.GameManagerI#processOnReload(java.util.List) */ ! public void processOnReload(List<PossibleAction> actions) throws Exception { for (PossibleAction action : actions) { // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (!possibleActions.contains(action.getClass()) --- 735,743 ---- * @see rails.game.GameManagerI#processOnReload(java.util.List) */ ! public boolean processOnReload(List<PossibleAction> actions) throws Exception { for (PossibleAction action : actions) { + DisplayBuffer.clear(); // TEMPORARY FIX TO ALLOW OLD 1856 SAVED FILES TO BE PROCESSED if (!possibleActions.contains(action.getClass()) *************** *** 750,759 **** try { log.debug("Action: " + action); ! getCurrentRound().process(action); getCurrentRound().setPossibleActions(); } catch (Exception e) { log.debug("Error while reprocessing " + action.toString(), e); throw new Exception("Reload failure", e); - } new AddToList<PossibleAction>(executedActions, action, --- 751,767 ---- try { log.debug("Action: " + action); ! if (!getCurrentRound().process(action)) { ! String msg = "Player "+action.getPlayerName()+"\'s action \"" ! +action.toString()+"\"\n in "+getCurrentRound().getRoundName() ! +" is considered invalid by the game engine"; ! log.error(msg); ! DisplayBuffer.add(msg); ! if (moveStack.isOpen()) moveStack.finish(); ! return false; ! } getCurrentRound().setPossibleActions(); } catch (Exception e) { log.debug("Error while reprocessing " + action.toString(), e); throw new Exception("Reload failure", e); } new AddToList<PossibleAction>(executedActions, action, *************** *** 761,764 **** --- 769,773 ---- if (moveStack.isOpen()) moveStack.finish(); } + return true; } Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Game.java 22 Nov 2009 18:48:40 -0000 1.39 --- Game.java 25 Nov 2009 18:48:19 -0000 1.40 *************** *** 72,77 **** public boolean setup() { - ReportBuffer.add(LocalText.getText("GameIs", name)); - try { // Have the ComponentManager work through the other rails.game files --- 72,75 ---- *************** *** 90,93 **** --- 88,92 ---- log.info("========== Start of rails.game " + name + " =========="); log.info("Rails version "+version); + ReportBuffer.add(LocalText.getText("GameIs", name)); // Have the ComponentManager work through the other rails.game files *************** *** 247,251 **** log.debug("Starting to execute loaded actions"); ! game.getGameManager().processOnReload(executedActions); return game; --- 246,253 ---- log.debug("Starting to execute loaded actions"); ! if (!game.getGameManager().processOnReload(executedActions)) { ! log.error ("Load interrupted"); ! DisplayBuffer.add(LocalText.getText("LoadInterrupted")); ! } return game; Index: GameManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManagerI.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** GameManagerI.java 4 Nov 2009 20:33:22 -0000 1.21 --- GameManagerI.java 25 Nov 2009 18:48:19 -0000 1.22 *************** *** 49,53 **** public abstract boolean process(PossibleAction action); ! public abstract void processOnReload(List<PossibleAction> actions) throws Exception; --- 49,53 ---- public abstract boolean process(PossibleAction action); ! public abstract boolean processOnReload(List<PossibleAction> actions) throws Exception; |