mirror of https://github.com/FreeCol/freecol.git
Added code for removing units on the non-visible parts of the client map.
This commit is contained in:
parent
71ab7ab6c1
commit
36a2fbcc81
|
@ -230,6 +230,7 @@ public final class InGameInputHandler implements MessageHandler {
|
|||
game.setCurrentPlayer(currentPlayer);
|
||||
|
||||
if (freeColClient.getMyPlayer().equals(currentPlayer)) {
|
||||
removeUnitsOutsideLOS();
|
||||
freeColClient.getCanvas().setEnabled(true);
|
||||
freeColClient.getCanvas().closeMenus();
|
||||
freeColClient.getInGameController().nextActiveUnit();
|
||||
|
@ -241,6 +242,21 @@ public final class InGameInputHandler implements MessageHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void removeUnitsOutsideLOS() {
|
||||
Player player = freeColClient.getMyPlayer();
|
||||
Map map = freeColClient.getGame().getMap();
|
||||
|
||||
Iterator tileIterator = map.getWholeMapIterator();
|
||||
while (tileIterator.hasNext()) {
|
||||
Tile t = map.getTile((Map.Position) tileIterator.next());
|
||||
if (t != null && !player.canSee(t) && t.getFirstUnit() != null) {
|
||||
t.disposeAllUnits();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles an "emigrateUnitInEuropeConfirmed"-message.
|
||||
*
|
||||
|
|
|
@ -187,6 +187,14 @@ public final class Tile extends FreeColGameObject implements Location {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disposes all units on this <code>Tile</code>.
|
||||
*/
|
||||
public void disposeAllUnits() {
|
||||
unitContainer.disposeAllUnits();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the first <code>Unit</code> on this tile.
|
||||
* @return The first <code>Unit</code> on this tile.
|
||||
|
|
|
@ -193,15 +193,21 @@ public class UnitContainer extends FreeColGameObject {
|
|||
* Removes all references to this object.
|
||||
*/
|
||||
public void dispose() {
|
||||
Iterator i = getUnitIterator();
|
||||
while (i.hasNext()) {
|
||||
((Unit) i.next()).dispose();
|
||||
}
|
||||
|
||||
disposeAllUnits();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disposes all units in this <code>UnitContainer</code>.
|
||||
*/
|
||||
public void disposeAllUnits() {
|
||||
for (int i=units.size()-1; i>=0; i--) {
|
||||
((Unit) units.get(i)).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepares this <code>UnitContainer</code> for a new turn.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue