Program: 173709
Project: 173709
Buggy source:
public <T extends PossibleAction>void setMapRelatedActions(List<T> actions){
  GUIHex selectedHex=mapPanel.getMap().getSelectedHex();
  int nextSubStep=ORUIManager.INACTIVE;
  allowedTileLays.clear();
  allowedTokenLays.clear();
  for (  T action : actions) {
    if (action instanceof LayTile) {
      allowedTileLays.add((LayTile)action);
    }
 else     if (action instanceof LayToken) {
      allowedTokenLays.add((LayToken)action);
    }
  }
  if (allowedTileLays.size() == 0 && tileLayingEnabled) {
    if (selectedHex != null) {
      selectedHex.removeTile();
      selectedHex.setSelected(false);
      mapPanel.getMap().repaint(selectedHex.getBounds());
      selectedHex=null;
    }
    for (    MapHex hex : hexUpgrades) {
      GUIHex guiHex=map.getHexByName(hex.getName());
      guiHex.setSelectable(false);
      mapPanel.getMap().repaint(guiHex.getBounds());
    }
    hexUpgrades=null;
  }
  if (allowedTokenLays.size() == 0 && tokenLayingEnabled) {
    if (selectedHex != null) {
      selectedHex.removeToken();
      selectedHex.setSelected(false);
      mapPanel.getMap().repaint(selectedHex.getBounds());
      selectedHex=null;
    }
    for (    MapHex hex : hexUpgrades) {
      GUIHex guiHex=map.getHexByName(hex.getName());
      guiHex.setSelectable(false);
      mapPanel.getMap().repaint(guiHex.getBounds());
    }
    hexUpgrades=null;
  }
  if (allowedTileLays.size() > 0) {
    nextSubStep=ORUIManager.SELECT_HEX_FOR_TILE;
    mapPanel.setAllowedTileLays(allowedTileLays);
    if (hexUpgrades != null) {
      for (      MapHex hex : hexUpgrades) {
        GUIHex guiHex=map.getHexByName(hex.getName());
        guiHex.setSelectable(false);
      }
    }
    boolean mapHexes=false;
    hexUpgrades=new ArrayList<MapHex>();
    if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) {
      for (      LayTile layTile : allowedTileLays) {
switch (layTile.getType()) {
case (LayTile.GENERIC):
          mapHexes=true;
        break;
case (LayTile.SPECIAL_PROPERTY):
      SpecialPropertyI sp=layTile.getSpecialProperty();
    if (sp == null || !(sp instanceof SpecialTileLay) || ((SpecialTileLay)sp).requiresConnection())     break;
case (LayTile.LOCATION_SPECIFIC):
  if (layTile.getLocations() != null)   hexUpgrades.addAll(layTile.getLocations());
}
}
if (mapHexes) {
SimpleGraph<NetworkVertex,NetworkEdge> companyGraph=getCompanyGraph();
List<MapHex> mapHexUpgrades=NetworkGraphBuilder.getMapHexes(companyGraph);
for (MapHex hex : mapHexUpgrades) {
if (hex.isUpgradeableNow(gameUIManager.getCurrentPhase())) hexUpgrades.add(hex);
}
String autoScroll=Config.getGameSpecific("String_Node_Str");
if (Util.hasValue(autoScroll) && autoScroll.equalsIgnoreCase("String_Node_Str")) {
}
 else {
mapPanel.scrollPaneShowRectangle(NetworkVertex.getVertexMapCoverage(map,companyGraph.vertexSet()));
}
}
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(true);
}
}
}
if (allowedTokenLays.size() > 0) {
nextSubStep=ORUIManager.SELECT_HEX_FOR_TOKEN;
mapPanel.setAllowedTokenLays(allowedTokenLays);
if (hexUpgrades != null) {
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(false);
}
}
boolean mapHexes=false;
hexUpgrades=new ArrayList<MapHex>();
if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) {
for (LayToken layToken : allowedTokenLays) {
SpecialPropertyI sp=layToken.getSpecialProperty();
if (sp == null) {
mapHexes=true;
}
 else if (layToken.getLocations() != null) hexUpgrades.addAll(layToken.getLocations());
}
if (mapHexes) {
hexUpgrades=NetworkGraphBuilder.getStationHexes(getCompanyGraph(),orComp);
for (LayToken layToken : allowedTokenLays) {
if (layToken.getLocations() != null) hexUpgrades.addAll(layToken.getLocations());
}
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(true);
}
}
}
}
setLocalStep(nextSubStep);
tileLayingEnabled=allowedTileLays.size() > 0;
tokenLayingEnabled=allowedTokenLays.size() > 0;
upgradePanel.setTileMode(tileLayingEnabled);
upgradePanel.setTokenMode(tokenLayingEnabled);
setLocalAction(false);
}

Fixed version (ground truth):
public <T extends PossibleAction>void setMapRelatedActions(List<T> actions){
  GUIHex selectedHex=mapPanel.getMap().getSelectedHex();
  int nextSubStep=ORUIManager.INACTIVE;
  allowedTileLays.clear();
  allowedTokenLays.clear();
  for (  T action : actions) {
    if (action instanceof LayTile) {
      allowedTileLays.add((LayTile)action);
    }
 else     if (action instanceof LayToken) {
      allowedTokenLays.add((LayToken)action);
    }
  }
  if (allowedTileLays.size() == 0 && tileLayingEnabled) {
    if (selectedHex != null) {
      selectedHex.removeTile();
      selectedHex.setSelected(false);
      mapPanel.getMap().repaint(selectedHex.getBounds());
      selectedHex=null;
    }
    for (    MapHex hex : hexUpgrades) {
      GUIHex guiHex=map.getHexByName(hex.getName());
      guiHex.setSelectable(false);
      mapPanel.getMap().repaint(guiHex.getBounds());
    }
    hexUpgrades=null;
  }
  if (allowedTokenLays.size() == 0 && tokenLayingEnabled) {
    if (selectedHex != null) {
      selectedHex.removeToken();
      selectedHex.setSelected(false);
      mapPanel.getMap().repaint(selectedHex.getBounds());
      selectedHex=null;
    }
    for (    MapHex hex : hexUpgrades) {
      GUIHex guiHex=map.getHexByName(hex.getName());
      guiHex.setSelectable(false);
      mapPanel.getMap().repaint(guiHex.getBounds());
    }
    hexUpgrades=null;
  }
  if (allowedTileLays.size() > 0) {
    nextSubStep=ORUIManager.SELECT_HEX_FOR_TILE;
    mapPanel.setAllowedTileLays(allowedTileLays);
    if (hexUpgrades != null) {
      for (      MapHex hex : hexUpgrades) {
        GUIHex guiHex=map.getHexByName(hex.getName());
        guiHex.setSelectable(false);
      }
    }
    boolean mapHexes=false;
    hexUpgrades=new ArrayList<MapHex>();
    if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) {
      for (      LayTile layTile : allowedTileLays) {
switch (layTile.getType()) {
case (LayTile.GENERIC):
          mapHexes=true;
        break;
case (LayTile.SPECIAL_PROPERTY):
      SpecialPropertyI sp=layTile.getSpecialProperty();
    if (sp == null || !(sp instanceof SpecialTileLay) || ((SpecialTileLay)sp).requiresConnection())     break;
case (LayTile.LOCATION_SPECIFIC):
  if (layTile.getLocations() != null)   hexUpgrades.addAll(layTile.getLocations());
}
}
if (mapHexes) {
SimpleGraph<NetworkVertex,NetworkEdge> companyGraph=getCompanyGraph();
List<MapHex> mapHexUpgrades=NetworkGraphBuilder.getMapHexes(companyGraph);
for (MapHex hex : mapHexUpgrades) {
if (hex.isUpgradeableNow(gameUIManager.getCurrentPhase())) hexUpgrades.add(hex);
}
String autoScroll=Config.getGameSpecific("String_Node_Str");
if (Util.hasValue(autoScroll) && autoScroll.equalsIgnoreCase("String_Node_Str")) {
}
 else {
mapPanel.scrollPaneShowRectangle(NetworkVertex.getVertexMapCoverage(map,companyGraph.vertexSet()));
}
}
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(true);
}
}
}
if (allowedTokenLays.size() > 0) {
nextSubStep=ORUIManager.SELECT_HEX_FOR_TOKEN;
mapPanel.setAllowedTokenLays(allowedTokenLays);
if (hexUpgrades != null) {
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(false);
}
}
boolean mapHexes=false;
hexUpgrades=new ArrayList<MapHex>();
if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) {
for (LayToken layToken : allowedTokenLays) {
SpecialPropertyI sp=layToken.getSpecialProperty();
if (sp == null) {
mapHexes=true;
}
 else if (layToken.getLocations() != null) hexUpgrades.addAll(layToken.getLocations());
}
if (mapHexes) {
hexUpgrades.addAll(NetworkGraphBuilder.getTokenableStationHexes(getCompanyGraph(),orComp));
for (MapHex hex : hexUpgrades) {
GUIHex guiHex=map.getHexByName(hex.getName());
guiHex.setSelectable(true);
}
}
}
}
setLocalStep(nextSubStep);
tileLayingEnabled=allowedTileLays.size() > 0;
tokenLayingEnabled=allowedTokenLays.size() > 0;
upgradePanel.setTileMode(tileLayingEnabled);
upgradePanel.setTokenMode(tokenLayingEnabled);
setLocalAction(false);
}