From: <ev...@us...> - 2011-04-27 19:58:16
|
Revision: 1536 http://rails.svn.sourceforge.net/rails/?rev=1536&view=rev Author: evos Date: 2011-04-27 19:58:09 +0000 (Wed, 27 Apr 2011) Log Message: ----------- Fixes for delayed train obsolescence (18AL rules). Modified Paths: -------------- trunk/18xx/rails/game/Game.java trunk/18xx/rails/game/OperatingRound.java trunk/18xx/rails/game/TrainType.java Modified: trunk/18xx/rails/game/Game.java =================================================================== --- trunk/18xx/rails/game/Game.java 2011-04-27 12:09:32 UTC (rev 1535) +++ trunk/18xx/rails/game/Game.java 2011-04-27 19:58:09 UTC (rev 1536) @@ -278,20 +278,31 @@ (List<PossibleAction>) actionObject; numberOfActions = executedActions.size(); for (PossibleAction action : executedActions) { - if (!gameManager.processOnReload(action)) { - log.error ("Load interrupted"); - DisplayBuffer.add(LocalText.getText("LoadInterrupted")); - break; + try { + if (!gameManager.processOnReload(action)) { + log.error ("Load interrupted"); + DisplayBuffer.add(LocalText.getText("LoadInterrupted")); + break; + } + } catch (Exception e) { + log.fatal("Action '"+action+"' reload exception", e); + throw new Exception ("Reload exception", e); } } } else if (actionObject instanceof PossibleAction) { // New style: separate PossibleActionsObjects, since Rails 1.3.1 while (actionObject instanceof PossibleAction) { numberOfActions++; - if (!gameManager.processOnReload((PossibleAction)actionObject)) { - log.error ("Load interrupted"); - DisplayBuffer.add(LocalText.getText("LoadInterrupted")); - break; + try { + if (!gameManager.processOnReload((PossibleAction)actionObject)) { + log.error ("Load interrupted"); + DisplayBuffer.add(LocalText.getText("LoadInterrupted")); + break; + } + } catch (Exception e) { + log.fatal("Action '"+((PossibleAction)actionObject).toString() + +"' reload exception", e); + throw new Exception ("Reload exception", e); } try { actionObject = ois.readObject(); @@ -328,7 +339,7 @@ return game; } catch (Exception e) { - log.error("Load failed", e); + log.fatal("Load failed", e); DisplayBuffer.add(LocalText.getText("LoadFailed", e.getMessage())); } Modified: trunk/18xx/rails/game/OperatingRound.java =================================================================== --- trunk/18xx/rails/game/OperatingRound.java 2011-04-27 12:09:32 UTC (rev 1535) +++ trunk/18xx/rails/game/OperatingRound.java 2011-04-27 19:58:09 UTC (rev 1536) @@ -1805,7 +1805,7 @@ TrainI oldTrain = operatingCompany.get().getPortfolio().getTrainOfType( exchangedTrain.getType()); - pool.buyTrain(oldTrain, 0); + train.moveTo(train.isObsolete() ? scrapHeap : pool); ReportBuffer.add(LocalText.getText("ExchangesTrain", companyName, exchangedTrain.getName(), @@ -1950,7 +1950,7 @@ // if (action.isForced()) moveStack.linkToPreviousMoveSet(); - pool.buyTrain(train, 0); + train.moveTo(train.isObsolete() ? scrapHeap : pool); ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", companyName, train.getName() )); @@ -2726,7 +2726,6 @@ } // Scan trains per company per player, operating company president // first - //int currentPlayerIndex = operatingCompany.getObject().getPresident().getIndex(); int currentPlayerIndex = getCurrentPlayer().getIndex(); for (int i = currentPlayerIndex; i < currentPlayerIndex + numberOfPlayers; i++) { Modified: trunk/18xx/rails/game/TrainType.java =================================================================== --- trunk/18xx/rails/game/TrainType.java 2011-04-27 12:09:32 UTC (rev 1535) +++ trunk/18xx/rails/game/TrainType.java 2011-04-27 19:58:09 UTC (rev 1536) @@ -435,14 +435,16 @@ public void setRusted(Portfolio lastBuyingCompany) { rusted.set(true); for (TrainI train : trains) { - if (obsoleting && train.getHolder() != lastBuyingCompany) { + Portfolio holder = train.getHolder(); + if (obsoleting && holder.getOwner() instanceof PublicCompanyI + && holder != lastBuyingCompany) { log.debug("Train " + train.getUniqueId() + " (owned by " - + train.getHolder().getName() + ") obsoleted"); + + holder.getName() + ") obsoleted"); train.setObsolete(); - train.getHolder().getTrainsModel().update(); + holder.getTrainsModel().update(); } else { log.debug("Train " + train.getUniqueId() + " (owned by " - + train.getHolder().getName() + ") rusted"); + + holder.getName() + ") rusted"); train.setRusted(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |