Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv17929/rails/game Modified Files: Portfolio.java StockMarket.java OperatingRound.java TrainType.java Game.java GameManager.java Added Files: BuildInfo.java Log Message: Fixed some bugs: - 1830: free D&H token wasn't free - 18EU: only one 8-train buyable Also added Rails version and date in saved files and reportng in the log of same. Bulld date included in BuildInfo, which is rewritten on each build via a new build.xml Ant script. Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Portfolio.java 4 Nov 2009 20:33:22 -0000 1.39 --- Portfolio.java 5 Nov 2009 22:50:37 -0000 1.40 *************** *** 373,377 **** public void addTrain(TrainI train) { - trains.add(train); TrainTypeI type = train.getType(); --- 373,376 ---- Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** OperatingRound.java 31 Oct 2009 17:08:27 -0000 1.74 --- OperatingRound.java 5 Nov 2009 22:50:37 -0000 1.75 *************** *** 548,552 **** cost = operatingCompany.getBaseTokenLayCost(); if (stl != null && stl.isFree()) cost = 0; ! // Does the company have the money? if (cost > operatingCompany.getCash()) { --- 548,552 ---- cost = operatingCompany.getBaseTokenLayCost(); if (stl != null && stl.isFree()) cost = 0; ! // Does the company have the money? if (cost > operatingCompany.getCash()) { *************** *** 736,740 **** operatingCompany.addBonus(new Bonus(operatingCompany, sbt.getName(), ! sbt.getValue(), sbt.getLocations())); --- 736,740 ---- operatingCompany.addBonus(new Bonus(operatingCompany, sbt.getName(), ! sbt.getValue(), sbt.getLocations())); Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** GameManager.java 4 Nov 2009 20:33:22 -0000 1.66 --- GameManager.java 5 Nov 2009 22:50:37 -0000 1.67 *************** *** 4,7 **** --- 4,8 ---- import java.io.*; import java.lang.reflect.Constructor; + import java.text.SimpleDateFormat; import java.util.*; *************** *** 151,155 **** protected ReportBuffer reportBuffer; ! protected String name; protected String key; --- 152,156 ---- protected ReportBuffer reportBuffer; ! protected String gmName; protected String key; *************** *** 183,187 **** */ public GameManager() { ! name = GM_NAME; key = GM_KEY; NDC.clear(); --- 184,188 ---- */ public GameManager() { ! gmName = GM_NAME; key = GM_KEY; NDC.clear(); *************** *** 769,774 **** new ObjectOutputStream(new FileOutputStream(new File( filepath))); oos.writeObject(saveFileVersionID); ! oos.writeObject(name); oos.writeObject(gameOptions); oos.writeObject(playerNames); --- 770,777 ---- new ObjectOutputStream(new FileOutputStream(new File( filepath))); + oos.writeObject(Game.version+" "+BuildInfo.timeStamp); + oos.writeObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); oos.writeObject(saveFileVersionID); ! oos.writeObject(gameName); oos.writeObject(gameOptions); oos.writeObject(playerNames); *************** *** 1211,1215 **** */ public String getName () { ! return name; } --- 1214,1218 ---- */ public String getName () { ! return gmName; } Index: Game.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Game.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Game.java 30 Oct 2009 21:53:03 -0000 1.34 --- Game.java 5 Nov 2009 22:50:37 -0000 1.35 *************** *** 12,16 **** public class Game { ! public static final String version = "1.0.5"; /** The component Manager */ --- 12,16 ---- public class Game { ! public static final String version = "1.0.6+"; /** The component Manager */ *************** *** 81,84 **** --- 81,85 ---- log.info("========== Start of rails.game " + name + " =========="); + log.info("Rails version "+version); // Have the ComponentManager work through the other rails.game files *************** *** 184,187 **** --- 185,189 ---- log.debug("Loading game from file " + filepath); + String filename = filepath.replaceAll(".*[/\\\\]", ""); try { *************** *** 189,193 **** new ObjectInputStream(new FileInputStream( new File(filepath))); ! long versionID = (Long) ois.readObject(); long saveFileVersionID = GameManager.saveFileVersionID; if (versionID != saveFileVersionID) { --- 191,211 ---- new ObjectInputStream(new FileInputStream( new File(filepath))); ! ! // New in 1.0.7: Rails version & save date/time. ! // Allow for older saved file versions. ! Object object = ois.readObject(); ! if (object instanceof String) { ! log.info("Reading Rails "+(String)object+" saved file "+filename); ! object = ois.readObject(); ! } else { ! log.info("Reading Rails (pre-1.0.7) saved file "+filename); ! } ! if (object instanceof String) { ! log.info("File was saved at "+(String)object); ! object = ois.readObject(); ! } ! ! long versionID = (Long) object; ! log.debug("Saved versionID="+versionID+" (object="+object+")"); long saveFileVersionID = GameManager.saveFileVersionID; if (versionID != saveFileVersionID) { *************** *** 197,200 **** --- 215,219 ---- } String name = (String) ois.readObject(); + log.debug("Saved game="+name); Map<String, String> selectedGameOptions = (Map<String, String>) ois.readObject(); Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** StockMarket.java 31 Oct 2009 17:08:26 -0000 1.21 --- StockMarket.java 5 Nov 2009 22:50:37 -0000 1.22 *************** *** 316,320 **** if (from != null) from.removeToken(company); if (to != null) to.addToken(company); - // company.getCurrentPriceModel().setState(to); } --- 316,319 ---- *************** *** 349,368 **** } - /* Brett's original code */ - - /** - * @return Returns the companiesStarted. - */ - /* - * public ArrayList getCompaniesStarted() { return companiesStarted; } - */ - - /** - * @return Returns the ipoPile. - */ - /* - * public ArrayList getIpoPile() { return ipoPile; } - */ - public PublicCertificate removeShareFromPile(PublicCertificate stock) { if (ipoPile.contains(stock)) { --- 348,351 ---- --- NEW FILE: BuildInfo.java --- package rails.game; public class BuildInfo { public static final String timeStamp="2009/11/05"; } Index: TrainType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/TrainType.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TrainType.java 4 Nov 2009 20:33:22 -0000 1.26 --- TrainType.java 5 Nov 2009 22:50:37 -0000 1.27 *************** *** 264,267 **** --- 264,268 ---- log.warn("Unexpected exception", e); } + train.init(this, lastIndex++); return train; } |