From: <sti...@us...> - 2007-11-25 13:52:11
|
Revision: 3275 http://freecol.svn.sourceforge.net/freecol/?rev=3275&view=rev Author: stiangre Date: 2007-11-25 05:52:14 -0800 (Sun, 25 Nov 2007) Log Message: ----------- Ported r3273 from branches/0.7.x/trunk: The AI should not be able to build colonies without naval access to Europe (until the wagon train code is ready). This fixes a problem with the AI building colonies adjacent to inland lakes. Modified Paths: -------------- freecol/trunk/src/net/sf/freecol/client/gui/TilePopup.java freecol/trunk/src/net/sf/freecol/common/model/Tile.java Modified: freecol/trunk/src/net/sf/freecol/client/gui/TilePopup.java =================================================================== --- freecol/trunk/src/net/sf/freecol/client/gui/TilePopup.java 2007-11-25 13:45:12 UTC (rev 3274) +++ freecol/trunk/src/net/sf/freecol/client/gui/TilePopup.java 2007-11-25 13:52:14 UTC (rev 3275) @@ -148,7 +148,7 @@ if (u.isCarrier()) { AIUnit au = (AIUnit) freeColClient.getFreeColServer().getAIMain().getAIObject(u); if (au.getMission() != null && au.getMission() instanceof TransportMission) { - JMenuItem menuItem = new JMenuItem("Transport list for: " + u.toString()); + JMenuItem menuItem = new JMenuItem("Transport list for: " + u.toString() + " (" + u.hashCode() + ")"); menuItem.setActionCommand("TL" + Unit.getXMLElementTagName() + u.getId()); menuItem.addActionListener(this); add(menuItem); Modified: freecol/trunk/src/net/sf/freecol/common/model/Tile.java =================================================================== --- freecol/trunk/src/net/sf/freecol/common/model/Tile.java 2007-11-25 13:45:12 UTC (rev 3274) +++ freecol/trunk/src/net/sf/freecol/common/model/Tile.java 2007-11-25 13:52:14 UTC (rev 3275) @@ -430,6 +430,53 @@ // TODO: Uncomment when wagon train code has been written: // value -= 20; value = 0; + } else { + // TODO: Remove when wagon train code has been written. START + final GoalDecider gd = new GoalDecider() { + private PathNode goal = null; + + public PathNode getGoal() { + return goal; + } + + public boolean hasSubGoals() { + return false; + } + + public boolean check(Unit u, PathNode pathNode) { + Map map = getGame().getMap(); + + if (pathNode.getTile().getType() == Tile.HIGH_SEAS) { + goal = pathNode; + return true; + } + if (map.isAdjacentToMapEdge(pathNode.getTile())) { + goal = pathNode; + return true; + } + return false; + } + }; + final CostDecider cd = new CostDecider() { + public int getCost(Unit unit, Tile oldTile, Tile newTile, int movesLeft, int turns) { + if (newTile.isLand()) { + return ILLEGAL_MOVE; + } else { + return 1; + } + } + public int getMovesLeft() { + return 0; + } + public boolean isNewTurn() { + return false; + } + }; + final PathNode n = getMap().search(this, gd, cd, Integer.MAX_VALUE); + if (n == null) { + value = 0; + } + // END-TODO } return Math.max(0, value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |