From: <ev...@us...> - 2011-04-01 10:04:05
|
Revision: 1505 http://rails.svn.sourceforge.net/rails/?rev=1505&view=rev Author: evos Date: 2011-04-01 10:03:59 +0000 (Fri, 01 Apr 2011) Log Message: ----------- Added city number check for home hexes, throwing a ConfigurationException in case of errors. Modified Paths: -------------- trunk/18xx/rails/game/MapHex.java trunk/18xx/rails/game/MapManager.java Modified: trunk/18xx/rails/game/MapHex.java =================================================================== --- trunk/18xx/rails/game/MapHex.java 2011-03-30 14:57:13 UTC (rev 1504) +++ trunk/18xx/rails/game/MapHex.java 2011-04-01 10:03:59 UTC (rev 1505) @@ -950,7 +950,7 @@ return foundCity; } - public void addHome(PublicCompanyI company, int cityNumber) { + public void addHome(PublicCompanyI company, int cityNumber) throws ConfigurationException { if (homes == null) homes = new HashMap<PublicCompanyI, City>(); if (cities.isEmpty()) { log.error("No cities for home station on hex " + name); @@ -959,6 +959,9 @@ if (cityNumber == 0) { homes.put(company, null); log.debug("Added home of " + company + " in hex " + this.toString() + " city not yet decided"); + } else if (cityNumber > cities.size()) { + throw new ConfigurationException ("Invalid city number "+cityNumber+" for hex "+name + +" which has "+cities.size()+" cities"); } else { City homeCity = cities.get(Math.max(cityNumber - 1, 0)); homes.put(company, homeCity); Modified: trunk/18xx/rails/game/MapManager.java =================================================================== --- trunk/18xx/rails/game/MapManager.java 2011-03-30 14:57:13 UTC (rev 1504) +++ trunk/18xx/rails/game/MapManager.java 2011-04-01 10:03:59 UTC (rev 1505) @@ -112,7 +112,7 @@ } } - public void finishConfiguration (GameManagerI gameManager) { + public void finishConfiguration (GameManagerI gameManager) throws ConfigurationException { MapHex hex; int i, j, k, dx, dy; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |