nus-yam/ex-repair huggingface dataset:
Program: 56607
Project: 56607
Buggy source:
public final List<ISPosition2D> freeOccupiedArea(MapShapeFilter occupied,ISPosition2D occupiersPosition){
  short partiton=getPartition(occupiersPosition);
  List<ISPosition2D> totallyFreePositions=new ArrayList<ISPosition2D>();
  for (  ISPosition2D curr : occupied) {
    short x=curr.getX();
    short y=curr.getY();
    if (getPartitionAt(x,y) == partiton) {
      towers[x][y]--;
      if (towers[x][y] <= 0) {
        totallyFreePositions.add(curr);
        towers[x][y]=0;
      }
    }
  }
  return totallyFreePositions;
}

Fixed version (ground truth):
public final List<ISPosition2D> freeOccupiedArea(MapCircle occupied,ISPosition2D occupiersPosition){
  short partiton=getPartition(occupiersPosition);
  List<ISPosition2D> totallyFreePositions=new ArrayList<ISPosition2D>();
  for (  ISPosition2D curr : occupied) {
    short x=curr.getX();
    short y=curr.getY();
    if (isInBounds(x,y) && getPartitionAt(x,y) == partiton) {
      towers[x][y]--;
      if (towers[x][y] <= 0) {
        totallyFreePositions.add(curr);
        towers[x][y]=0;
      }
    }
  }
  return totallyFreePositions;
}
Program: 56609
Project: 56609
Buggy source:
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
  ois.defaultReadObject();
  Timer100Milli.add(this);
}

Fixed version (ground truth):
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
  ois.defaultReadObject();
  allBuildings.add(this);
  Timer100Milli.add(this);
}
Program: 56610
Project: 56610
Buggy source:
/** 
 * This method overrides the standard deserialize method to restore the movablesByID map and the nextID.
 * @param ois
 * @throws IOException
 * @throws ClassNotFoundException
 */
private final void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
  ois.defaultReadObject();
  movablesByID.put(this.id,this);
  nextID=Math.max(nextID,this.id + 1);
  MovableTimer.add(this);
}

Fixed version (ground truth):
/** 
 * This method overrides the standard deserialize method to restore the movablesByID map and the nextID.
 * @param ois
 * @throws IOException
 * @throws ClassNotFoundException
 */
private final void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
  ois.defaultReadObject();
  movablesByID.put(this.id,this);
  allMovables.add(this);
  nextID=Math.max(nextID,this.id + 1);
  MovableTimer.add(this);
}
Program: 56611
Project: 56611
Buggy source:
private static final boolean checkPosition(short offsetX,short offsetY,BitSet areaSet,short areaWidth,BuildingSet buildingSet){
  for (short x=0; x < buildingSet.width; x++) {
    for (short y=0; y < buildingSet.height; y++) {
      if (buildingSet.getWithoutOffset(x,y)) {
        if (!areaSet.get((x + offsetX + buildingSet.minX) + (y + offsetY + buildingSet.minY) * areaWidth)) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private static final boolean checkPosition(int offsetX,int offsetY,BitSet areaSet,short areaWidth,BuildingAreaBitSet buildingSet){
  for (short x=0; x < buildingSet.width; x++) {
    for (short y=0; y < buildingSet.height; y++) {
      if (buildingSet.getWithoutOffset(x,y)) {
        if (!areaSet.get((x + offsetX) + (y + offsetY) * areaWidth)) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 56613
Project: 56613
Buggy source:
public void setBuildingType(EBuildingType type){
  this.buildingType=type;
  if (type != null) {
    this.buildingSet=new BuildingSet(type);
  }
 else {
    this.buildingSet=null;
  }
  refreshMarkings();
}

Fixed version (ground truth):
public void setBuildingType(EBuildingType type){
  this.buildingType=type;
  refreshMarkings();
}
Program: 56614
Project: 56614
Buggy source:
@Override public void draw(GLDrawContext gl,Color color,float multiply){
  if (color == null) {
    gl.color(multiply,multiply,multiply,1);
  }
 else {
    gl.color(color.getRed() * multiply,color.getGreen() * multiply,color.getBlue() * multiply,color.getAlpha());
  }
  gl.drawTrianglesWithTexture(getTextureIndex(gl),getGeometryIndex(gl),2);
  return;
}

Fixed version (ground truth):
@Override public void draw(GLDrawContext gl,Color color,float multiply){
  if (color == null) {
    gl.color(multiply,multiply,multiply,1);
  }
 else {
    gl.color(color.getRed() * multiply,color.getGreen() * multiply,color.getBlue() * multiply,color.getAlpha());
  }
  int textureIndex=getTextureIndex(gl);
  int geometryIndex2=getGeometryIndex(gl);
  gl.drawTrianglesWithTexture(textureIndex,geometryIndex2,2);
}
Program: 56615
Project: 56615
Buggy source:
public void drawImageAtRect(GLDrawContext gl,float left,float bottom,float right,float top){
  tmpBuffer[0]=left;
  tmpBuffer[1]=top;
  tmpBuffer[5]=left;
  tmpBuffer[6]=bottom;
  tmpBuffer[9]=(float)height / textureHeight;
  tmpBuffer[10]=right;
  tmpBuffer[11]=bottom;
  tmpBuffer[13]=(float)width / textureWidth;
  tmpBuffer[14]=(float)height / textureHeight;
  tmpBuffer[15]=right;
  tmpBuffer[16]=top;
  tmpBuffer[18]=(float)width / textureWidth;
  gl.drawQuadWithTexture(getTextureIndex(gl),tmpBuffer);
}

Fixed version (ground truth):
public void drawImageAtRect(GLDrawContext gl,float left,float bottom,float right,float top){
  int textureIndex=getTextureIndex(gl);
  tmpBuffer[0]=left;
  tmpBuffer[1]=top;
  tmpBuffer[5]=left;
  tmpBuffer[6]=bottom;
  tmpBuffer[9]=(float)height / textureHeight;
  tmpBuffer[10]=right;
  tmpBuffer[11]=bottom;
  tmpBuffer[13]=(float)width / textureWidth;
  tmpBuffer[14]=(float)height / textureHeight;
  tmpBuffer[15]=right;
  tmpBuffer[16]=top;
  tmpBuffer[18]=(float)width / textureWidth;
  gl.drawQuadWithTexture(textureIndex,tmpBuffer);
}
Program: 56616
Project: 56616
Buggy source:
private void calculateConstructMarks(){
  MapRectangle area=this.mapArea;
  EBuildingType currBuildingType=this.buildingType;
  if (currBuildingType == null || area == null) {
    return;
  }
  RelativePoint[] usedPositions=currBuildingType.getProtectedTiles();
  if (lastArea != null) {
    removeConstructionMarks(lastArea,area);
  }
  for (  ISPosition2D pos : area) {
    short x=pos.getX();
    short y=pos.getY();
    byte value;
    if (map.canConstructAt(x,y,currBuildingType,player)) {
      value=calculateConstrMarkVal(x,y,usedPositions);
    }
 else {
      value=-1;
    }
    map.setConstructMarking(pos,value);
  }
  lastArea=area;
}

Fixed version (ground truth):
private void calculateConstructMarks(){
  MapRectangle area=this.mapArea;
  EBuildingType currBuildingType=this.buildingType;
  if (currBuildingType == null || area == null) {
    return;
  }
  if (lastArea != null) {
    removeConstructionMarks(lastArea,area);
  }
  final short minX=(short)(area.getLineStartX(0));
  final short maxX=(short)(area.getLineEndX(area.getLines() - 1));
  final short minY=(area.getMinY());
  final short width=(short)(maxX - minX + 1);
  final short height=area.getHeight();
  final short setWidth=(short)(width + buildingSet.width);
  final short setHeight=(short)(height + buildingSet.height);
  BitSet areaSet=new BitSet(setWidth * setHeight);
  final ELandscapeType[] landscapeTypes=buildingType.getGroundtypes();
  for (short y=0; y < setHeight; y++) {
    for (short x=0; x < setWidth; x++) {
      boolean canConstruct=map.canUsePositionForConstruction((short)(minX + x),(short)(y + minY),landscapeTypes,player);
      areaSet.set(x + y * setWidth,canConstruct);
    }
  }
  for (short y=(short)-buildingSet.minY; y < height; y++) {
    for (short x=(short)-buildingSet.minX; x < width; x++) {
      final short mapX=(short)(minX + x);
      final short mapY=(short)(minY + y);
      if (map.isInBounds(mapX,mapY)) {
        byte value;
        if (checkPosition(x,y,areaSet,setWidth,buildingSet)) {
          value=(byte)1;
        }
 else {
          value=-1;
        }
        map.setConstructMarking(mapX,mapY,value);
      }
    }
  }
  lastArea=area;
}
Program: 56617
Project: 56617
Buggy source:
/** 
 * Removes all construction marks in the given area.
 * @param area The area to remove the marks
 * @param notIn The area of marks that should be skipped.
 */
private void removeConstructionMarks(IMapArea area,IMapArea notIn){
  for (  ISPosition2D pos : area) {
    if (!notIn.contains(pos)) {
      map.setConstructMarking(pos,(byte)-1);
    }
  }
}

Fixed version (ground truth):
/** 
 * Removes all construction marks in the given area.
 * @param area The area to remove the marks
 * @param notIn The area of marks that should be skipped.
 */
private void removeConstructionMarks(IMapArea area,IMapArea notIn){
  for (  ISPosition2D pos : new MapShapeFilter(area,map.getWidth(),map.getHeight())) {
    if (!notIn.contains(pos)) {
      map.setConstructMarking(pos.getX(),pos.getY(),(byte)-1);
    }
  }
}
Program: 56618
Project: 56618
Buggy source:
public void setBuildingType(EBuildingType type){
  buildingType=type;
  refreshMarkings();
}

Fixed version (ground truth):
public void setBuildingType(EBuildingType type){
  this.buildingType=type;
  if (type != null) {
    this.buildingSet=new BuildingSet(type);
  }
 else {
    this.buildingSet=null;
  }
  refreshMarkings();
}
Program: 56619
Project: 56619
Buggy source:
/** 
 * Sets the given value to the given position.
 * @param pos position the value will be set to
 * @param value value to be set as construction mark value.
 */
void setConstructMarking(ISPosition2D pos,byte value);

Fixed version (ground truth):
/** 
 * Sets the given value to the given position.
 * @param x x coordinate
 * @param y y coordinate
 * @param value value to be set as construction mark value.
 */
void setConstructMarking(short x,short y,byte value);
Program: 56621
Project: 56621
Buggy source:
private boolean isAllowedLandscape(short x,short y,ELandscapeType[] landscapes){
  ELandscapeType landscapeAt=landscapeGrid.getLandscapeTypeAt(x,y);
  for (byte i=0; i < landscapes.length; i++) {
    if (landscapeAt == landscapes[i]) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private final boolean isAllowedLandscape(short x,short y,ELandscapeType[] landscapes){
  ELandscapeType landscapeAt=landscapeGrid.getLandscapeTypeAt(x,y);
  for (byte i=0; i < landscapes.length; i++) {
    if (landscapeAt == landscapes[i]) {
      return true;
    }
  }
  return false;
}
Program: 56622
Project: 56622
Buggy source:
@Override public void setConstructMarking(ISPosition2D pos,byte value){
  mapObjectsManager.setConstructionMarking(pos,value);
}

Fixed version (ground truth):
@Override public final void setConstructMarking(short x,short y,byte value){
  mapObjectsManager.setConstructionMarking(x,y,value);
}
Program: 56623
Project: 56623
Buggy source:
private boolean addMapObject(ISPosition2D pos,AbstractHexMapObject mapObject){
  for (  RelativePoint point : mapObject.getBlockedTiles()) {
    short x=point.calculateX(pos.getX());
    short y=point.calculateY(pos.getY());
    if (!grid.isInBounds(x,y) || grid.isBlocked(x,y)) {
      return false;
    }
  }
  grid.addMapObject(pos.getX(),pos.getY(),mapObject);
  setBlockedForObject(pos.getX(),pos.getY(),mapObject,true);
  return true;
}

Fixed version (ground truth):
private final boolean addMapObject(short x,short y,AbstractHexMapObject mapObject){
  for (  RelativePoint point : mapObject.getBlockedTiles()) {
    short currX=point.calculateX(x);
    short currY=point.calculateY(y);
    if (!grid.isInBounds(currX,currY) || grid.isBlocked(currX,currY)) {
      return false;
    }
  }
  grid.addMapObject(x,y,mapObject);
  setBlockedForObject(x,y,mapObject,true);
  return true;
}
Program: 56624
Project: 56624
Buggy source:
public void setConstructionMarking(ISPosition2D pos,byte value){
  if (value >= 0) {
    ConstructionMarkObject markObject=(ConstructionMarkObject)grid.getMapObject(pos.getX(),pos.getY(),EMapObjectType.CONSTRUCTION_MARK);
    if (markObject == null) {
      addMapObject(pos,new ConstructionMarkObject(value));
    }
 else {
      markObject.setConstructionValue(value);
    }
  }
 else {
    removeMapObjectType(pos.getX(),pos.getY(),EMapObjectType.CONSTRUCTION_MARK);
  }
}

Fixed version (ground truth):
public void setConstructionMarking(short x,short y,byte value){
  if (value >= 0) {
    ConstructionMarkObject markObject=(ConstructionMarkObject)grid.getMapObject(x,y,EMapObjectType.CONSTRUCTION_MARK);
    if (markObject == null) {
      addMapObject(x,y,new ConstructionMarkObject(value));
    }
 else {
      markObject.setConstructionValue(value);
    }
  }
 else {
    removeMapObjectType(x,y,EMapObjectType.CONSTRUCTION_MARK);
  }
}
Program: 56625
Project: 56625
Buggy source:
void setScreen(IMapArea screenArea);

Fixed version (ground truth):
void setScreen(MapRectangle screenArea);
Program: 56626
Project: 56626
Buggy source:
@Override public final void setScreen(IMapArea screenArea){
  constructionMarksCalculator.setScreen(screenArea);
}

Fixed version (ground truth):
@Override public final void setScreen(MapRectangle screenArea){
  constructionMarksCalculator.setScreen(screenArea);
}
Program: 56627
Project: 56627
Buggy source:
private void calculateConstructMarks(){
  IMapArea currMapArea=this.mapArea;
  EBuildingType currBuildingType=this.buildingType;
  if (currBuildingType == null || currMapArea == null) {
    return;
  }
  RelativePoint[] usedPositions=currBuildingType.getProtectedTiles();
  if (lastArea != null) {
    removeConstructionMarks(lastArea,currMapArea);
  }
  for (  ISPosition2D pos : currMapArea) {
    short x=pos.getX();
    short y=pos.getY();
    byte value;
    if (map.canConstructAt(x,y,currBuildingType,player)) {
      value=calculateConstrMarkVal(x,y,usedPositions);
    }
 else {
      value=-1;
    }
    map.setConstructMarking(pos,value);
  }
  lastArea=currMapArea;
}

Fixed version (ground truth):
private void calculateConstructMarks(){
  MapRectangle area=this.mapArea;
  EBuildingType currBuildingType=this.buildingType;
  if (currBuildingType == null || area == null) {
    return;
  }
  RelativePoint[] usedPositions=currBuildingType.getProtectedTiles();
  if (lastArea != null) {
    removeConstructionMarks(lastArea,area);
  }
  for (  ISPosition2D pos : area) {
    short x=pos.getX();
    short y=pos.getY();
    byte value;
    if (map.canConstructAt(x,y,currBuildingType,player)) {
      value=calculateConstrMarkVal(x,y,usedPositions);
    }
 else {
      value=-1;
    }
    map.setConstructMarking(pos,value);
  }
  lastArea=area;
}
Program: 56628
Project: 56628
Buggy source:
public void setScreen(IMapArea mapArea){
  this.mapArea=new MapShapeFilter(mapArea,map.getWidth(),map.getHeight());
  refreshMarkings();
}

Fixed version (ground truth):
public void setScreen(MapRectangle mapArea){
  this.mapArea=mapArea;
  refreshMarkings();
}
Program: 56629
Project: 56629
Buggy source:
/** 
 * Draws a circle to the buffer line. Each point is only brightened and onlydrawn if its x coordinate is in [0, mapWidth - 1] and its computed y coordinate is bigger than 0.
 */
final void drawCircleToBuffer(int bufferx,int buffery,int viewDistance,byte offset){
  MapCircle circle=new MapCircle(bufferx,buffery,Math.min(viewDistance + PADDING,MAX_VIEWDISTANCE));
  final int squaredViewDistance=viewDistance * viewDistance;
  CircleIterator iterator=circle.iterator();
  while (iterator.hasNext()) {
    final int currentY=iterator.nextY();
    final int currentX=iterator.nextX();
    int currentBufferY;
    if (currentX >= 0 && currentX < width && (currentBufferY=convertY(currentY)) >= 0) {
      if (buffer[currentX][currentBufferY] < CommonConstants.FOG_OF_WAR_VISIBLE + offset) {
        double squaredDistance=circle.squaredDistanceToCenter(currentX,currentY);
        byte newSight;
        if (squaredDistance < squaredViewDistance) {
          newSight=CommonConstants.FOG_OF_WAR_VISIBLE;
        }
 else {
          newSight=(byte)(CommonConstants.FOG_OF_WAR_VISIBLE - (Math.sqrt(squaredDistance) - viewDistance) / PADDING * CommonConstants.FOG_OF_WAR_VISIBLE);
        }
        increaseBufferAt(currentX,currentBufferY,(byte)(newSight + offset));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws a circle to the buffer line. Each point is only brightened and onlydrawn if its x coordinate is in [0, mapWidth - 1] and its computed y coordinate is bigger than 0.
 */
final void drawCircleToBuffer(int bufferx,int buffery,int viewDistance){
  MapCircle circle=new MapCircle(bufferx,buffery,Math.min(viewDistance + PADDING,MAX_VIEWDISTANCE));
  final int squaredViewDistance=viewDistance * viewDistance;
  CircleIterator iterator=circle.iterator();
  while (iterator.hasNext()) {
    final int currentY=iterator.nextY();
    final int currentX=iterator.nextX();
    int currentBufferY;
    if (currentX >= 0 && currentX < width && (currentBufferY=convertY(currentY)) >= 0) {
      if (buffer[currentX][currentBufferY] < CommonConstants.FOG_OF_WAR_VISIBLE) {
        double squaredDistance=circle.squaredDistanceToCenter(currentX,currentY);
        byte newSight;
        if (squaredDistance < squaredViewDistance) {
          newSight=CommonConstants.FOG_OF_WAR_VISIBLE;
        }
 else {
          newSight=(byte)(CommonConstants.FOG_OF_WAR_VISIBLE - (Math.sqrt(squaredDistance) - viewDistance) / PADDING * CommonConstants.FOG_OF_WAR_VISIBLE);
        }
        increaseBufferAt(currentX,currentBufferY,newSight);
      }
    }
  }
}
Program: 56630
Project: 56630
Buggy source:
@Override public void run(){
  while (true) {
    StopWatch watch=new MilliStopWatch();
    watch.start();
    loadFirstBuffer();
    for (short sweepline=(short)(BUFFER_HEIGHT / 2); sweepline < height - BUFFER_HEIGHT / 2; sweepline++) {
      doNextLine(sweepline);
      if (sweepline % 32 == 0) {
        try {
          Thread.sleep(100);
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
      }
    }
    loadLastBuffer();
    watch.stop("String_Node_Str");
    try {
      Thread.sleep(200);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    StopWatch watch=new MilliStopWatch();
    watch.start();
    loadFirstBuffer();
    for (short sweepline=(short)(BUFFER_HEIGHT / 2); sweepline < height - BUFFER_HEIGHT / 2; sweepline++) {
      doNextLine(sweepline);
      if (sweepline % 32 == 0) {
      }
    }
    loadLastBuffer();
    watch.stop("String_Node_Str");
    try {
      Thread.sleep(700);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}
Program: 56631
Project: 56631
Buggy source:
/** 
 * Adds everything that can see to the buffer.
 * @param buffery
 * @param mapy
 */
private final void applyBufferLine(short mapy){
  for (short x=0; x < width; x++) {
    int distance=getViewDistanceForPosition(x,mapy);
    if (distance > 0) {
      bufferdrawer.drawCircleToBuffer(x,mapy,distance,(byte)0);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds everything that can see to the buffer.
 * @param buffery
 * @param mapy
 */
private final void applyBufferLine(short mapy){
  for (short x=0; x < width; x++) {
    int distance=getViewDistanceForPosition(x,mapy);
    if (distance > 0) {
      bufferdrawer.drawCircleToBuffer(x,mapy,distance);
    }
  }
}
Program: 56632
Project: 56632
Buggy source:
public void startThread(IFogOfWarGrid grid){
  this.grid=grid;
  if (height > 3 * MAX_VIEWDISTANCE) {
    NewFoWThread thread=new NewFoWThread();
    thread.start();
  }
 else {
    SimpleCorrectionTread thread=new SimpleCorrectionTread();
    thread.start();
  }
  rebuildAll(sight);
}

Fixed version (ground truth):
@Override public void startThread(IFogOfWarGrid grid){
  this.grid=grid;
  if (height > 3 * MAX_VIEWDISTANCE) {
    FogCorrectionThread thread=new FogCorrectionThread();
    thread.start();
  }
 else {
    SimpleCorrectionTread thread=new SimpleCorrectionTread();
    thread.start();
  }
  rebuildAll(sight);
}
Program: 56633
Project: 56633
Buggy source:
final void rebuildAll(byte[][] buffer){
  CircleDrawer drawer=new CircleDrawer(buffer);
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      buffer[x][y]=dimDown(buffer[x][y]);
    }
  }
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      int distance=getViewDistanceForPosition(x,y);
      if (distance > 0) {
        drawer.drawCircleToBuffer(x,y,distance,(byte)0);
      }
    }
  }
}

Fixed version (ground truth):
final void rebuildAll(byte[][] buffer){
  CircleDrawer drawer=new CircleDrawer(buffer);
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      buffer[x][y]=dimDown(buffer[x][y]);
    }
  }
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      int distance=getViewDistanceForPosition(x,y);
      if (distance > 0) {
        drawer.drawCircleToBuffer(x,y,distance);
      }
    }
  }
}
Program: 56634
Project: 56634
Buggy source:
public final boolean isVisible(int centerx,int centery){
  return sight[centerx][centery] >= CommonConstants.FOG_OF_WAR_VISIBLE;
}

Fixed version (ground truth):
@Override public final boolean isVisible(int centerx,int centery){
  return sight[centerx][centery] >= CommonConstants.FOG_OF_WAR_VISIBLE;
}
Program: 56635
Project: 56635
Buggy source:
/** 
 * Gets the visible status of a map pint
 * @param x The x coordinate of the point in 0..(mapWidth - 1)
 * @param y The y coordinate of the point in 0..(mapHeight - 1)
 * @return The status from 0 to visible.
 */
public final byte getVisibleStatus(int x,int y){
  if (enabled) {
    return (byte)Math.min(sight[x][y],CommonConstants.FOG_OF_WAR_VISIBLE);
  }
 else {
    return CommonConstants.FOG_OF_WAR_VISIBLE;
  }
}

Fixed version (ground truth):
/** 
 * Gets the visible status of a map pint
 * @param x The x coordinate of the point in 0..(mapWidth - 1)
 * @param y The y coordinate of the point in 0..(mapHeight - 1)
 * @return The status from 0 to visible.
 */
@Override public final byte getVisibleStatus(int x,int y){
  if (enabled) {
    return (byte)Math.min(sight[x][y],CommonConstants.FOG_OF_WAR_VISIBLE);
  }
 else {
    return CommonConstants.FOG_OF_WAR_VISIBLE;
  }
}
Program: 56636
Project: 56636
Buggy source:
public final void toggleEnabled(){
  enabled=!enabled;
}

Fixed version (ground truth):
@Override public final void toggleEnabled(){
  enabled=!enabled;
}
Program: 56637
Project: 56637
Buggy source:
@Override public ISPosition2D next(){
  if (relativey < height && width > 0) {
    int x=getLineStartX(relativey) + relativex;
    int y=getLineY(relativey);
    ShortPoint2D pos=new ShortPoint2D(x,y);
    relativex++;
    if (relativex >= width) {
      relativex=0;
      relativey++;
    }
    return pos;
  }
 else {
    throw new NoSuchElementException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public ISPosition2D next(){
  if (relativeY < height && width > 0) {
    int x=getLineStartX(relativeY) + relativeX;
    int y=getLineY(relativeY);
    ShortPoint2D pos=new ShortPoint2D(x,y);
    relativeX++;
    if (relativeX >= width) {
      relativeX=0;
      relativeY++;
    }
    return pos;
  }
 else {
    throw new NoSuchElementException("String_Node_Str");
  }
}
Program: 56638
Project: 56638
Buggy source:
public final boolean containsLine(int y){
  return y >= miny && y < miny + height;
}

Fixed version (ground truth):
public final boolean containsLine(int y){
  return y >= getMinY() && y < getMinY() + height;
}
Program: 56639
Project: 56639
Buggy source:
@Override public boolean hasNext(){
  return relativey < height && width > 0;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return relativeY < height && width > 0;
}
Program: 56640
Project: 56640
Buggy source:
public MapRectangle(short minx,short miny,short width,short height){
  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.minx=minx;
  this.miny=miny;
  this.width=width;
  this.height=height;
}

Fixed version (ground truth):
public MapRectangle(short minx,short miny,short width,short height){
  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.minX=minx;
  this.minY=miny;
  this.width=width;
  this.height=height;
}
Program: 56641
Project: 56641
Buggy source:
public final int getLineY(int line){
  return miny + line;
}

Fixed version (ground truth):
public final int getLineY(int line){
  return getMinY() + line;
}
Program: 56642
Project: 56642
Buggy source:
public final boolean contains(int x,int y){
  if (!containsLine(y)) {
    return false;
  }
  if (x < getLineStartX(y - miny) || x > getLineEndX(y - miny)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
public final boolean contains(int x,int y){
  if (!containsLine(y)) {
    return false;
  }
  if (x < getLineStartX(y - getMinY()) || x > getLineEndX(y - getMinY())) {
    return false;
  }
  return true;
}
Program: 56643
Project: 56643
Buggy source:
/** 
 * Gets the first x coordinate contained by a line.
 * @param line The line relative to the first line of this rectangle.
 */
public final int getLineStartX(int line){
  return minx + getOffsetForLine(line);
}

Fixed version (ground truth):
/** 
 * Gets the first x coordinate contained by a line.
 * @param line The line relative to the first line of this rectangle.
 */
public final int getLineStartX(int line){
  return getMinX() + getOffsetForLine(line);
}
Program: 56644
Project: 56644
Buggy source:
/** 
 * Generates the texture data.
 * @param data The texture data buffer.
 * @throws IOException
 */
private static void addTextures(short[] data) throws IOException {
  AdvancedDatFileReader reader=ImageProvider.getInstance().getFileReader(LAND_FILE);
  ImageWriter imageWriter=new ImageWriter();
  imageWriter.data=data;
  ImageMetadata meta=new ImageMetadata();
  for (int index=0; index < TEXTURE_POSITIONS.length; index++) {
    int[] position=TEXTURE_POSITIONS[index];
    int x=position[0] * TEXTURE_GRID;
    int y=position[1] * TEXTURE_GRID;
    int start=y * TEXTURE_SIZE + x;
    int cellsize=position[2] * TEXTURE_GRID;
    imageWriter.arrayoffset=start;
    imageWriter.cellsize=cellsize;
    int end=(y + cellsize) * TEXTURE_SIZE + x;
    DatBitmapReader.uncompressImage(reader.getReaderForLandscape(index),AdvancedDatFileReader.LANDSCAPE_TRANSLATOR,meta,imageWriter);
    int arrayoffset=imageWriter.arrayoffset;
    int l=arrayoffset - start;
    while (arrayoffset < end) {
      for (int i=0; i < cellsize; i++) {
        data[arrayoffset + i]=data[arrayoffset - l + i];
      }
      arrayoffset+=TEXTURE_SIZE;
    }
  }
}

Fixed version (ground truth):
/** 
 * Generates the texture data.
 * @param data The texture data buffer.
 * @throws IOException
 */
private static void addTextures(short[] data) throws IOException {
  AdvancedDatFileReader reader=ImageProvider.getInstance().getFileReader(LAND_FILE);
  ImageWriter imageWriter=new ImageWriter();
  imageWriter.data=data;
  ImageMetadata meta=new ImageMetadata();
  for (int index=0; index < TEXTURE_POSITIONS.length; index++) {
    int[] position=TEXTURE_POSITIONS[index];
    int x=position[0] * TEXTURE_GRID;
    int y=position[1] * TEXTURE_GRID;
    int start=y * TEXTURE_SIZE + x;
    int cellsize=position[2] * TEXTURE_GRID;
    int end=(y + cellsize) * TEXTURE_SIZE + x;
    imageWriter.arrayoffset=start;
    imageWriter.cellsize=cellsize;
    imageWriter.maxoffset=end;
    DatBitmapReader.uncompressImage(reader.getReaderForLandscape(index),AdvancedDatFileReader.LANDSCAPE_TRANSLATOR,meta,imageWriter);
    int arrayoffset=imageWriter.arrayoffset;
    int l=arrayoffset - start;
    while (arrayoffset < end) {
      for (int i=0; i < cellsize; i++) {
        data[arrayoffset + i]=data[arrayoffset - l + i];
      }
      arrayoffset+=TEXTURE_SIZE;
    }
  }
}
Program: 56645
Project: 56645
Buggy source:
@Override public void writeLine(short[] data,int length) throws IOException {
  for (int i=0; i < cellsize; i++) {
    this.data[arrayoffset + i]=data[i % length];
  }
  arrayoffset+=TEXTURE_SIZE;
}

Fixed version (ground truth):
@Override public void writeLine(short[] data,int length) throws IOException {
  if (arrayoffset < maxoffset) {
    for (int i=0; i < cellsize; i++) {
      this.data[arrayoffset + i]=data[i % length];
    }
    arrayoffset+=TEXTURE_SIZE;
  }
}
Program: 56646
Project: 56646
Buggy source:
private void updateFiles(DefaultHttpClient httpClient) throws IOException, ClientProtocolException {
  final String url=SERVER_ROOT + "String_Node_Str";
  HttpGet httpRequest=new HttpGet(url);
  HttpResponse response=httpClient.execute(httpRequest);
  ZipInputStream inputStream=new ZipInputStream(response.getEntity().getContent());
  setUpdating(true);
  int files=0;
  byte[] buffer=new byte[1024];
  ZipEntry entry;
  while ((entry=inputStream.getNextEntry()) != null) {
    String name=entry.getName();
    if (name.startsWith(RESOURCE_PREFIX)) {
      String outfilename=destdir.getAbsolutePath() + "String_Node_Str" + name.substring(RESOURCE_PREFIX.length());
      File outfile=new File(outfilename);
      if (entry.isDirectory()) {
        if (outfile.exists() && !outfile.isDirectory()) {
          outfile.delete();
        }
        if (!outfile.isDirectory()) {
          outfile.mkdirs();
        }
      }
 else {
        File tmpfile=new File(outfilename + "String_Node_Str");
        tmpfile.deleteOnExit();
        FileOutputStream out=new FileOutputStream(tmpfile);
        while (true) {
          int len=inputStream.read(buffer);
          if (len <= 0) {
            break;
          }
          out.write(buffer,0,len);
        }
        out.close();
        tmpfile.renameTo(outfile);
        files++;
      }
    }
  }
  System.out.println("String_Node_Str" + files + "String_Node_Str");
  setUpdating(false);
}

Fixed version (ground truth):
private void updateFiles(DefaultHttpClient httpClient) throws IOException, ClientProtocolException {
  final String url=SERVER_ROOT + "String_Node_Str";
  HttpGet httpRequest=new HttpGet(url);
  HttpResponse response=httpClient.execute(httpRequest);
  ZipInputStream inputStream=new ZipInputStream(response.getEntity().getContent());
  setUpdating(true);
  int files=0;
  byte[] buffer=new byte[1024];
  ZipEntry entry;
  while ((entry=inputStream.getNextEntry()) != null) {
    String name=entry.getName();
    if (name.startsWith(RESOURCE_PREFIX)) {
      String outfilename=destdir.getAbsolutePath() + "String_Node_Str" + name.substring(RESOURCE_PREFIX.length());
      File outfile=new File(outfilename);
      if (entry.isDirectory()) {
        if (outfile.exists() && !outfile.isDirectory()) {
          outfile.delete();
        }
        if (!outfile.isDirectory()) {
          outfile.mkdirs();
        }
      }
 else {
        File tmpFile=new File(outfilename + "String_Node_Str");
        tmpFile.getParentFile().mkdirs();
        tmpFile.deleteOnExit();
        FileOutputStream out=new FileOutputStream(tmpFile);
        while (true) {
          int len=inputStream.read(buffer);
          if (len <= 0) {
            break;
          }
          out.write(buffer,0,len);
        }
        out.close();
        tmpFile.renameTo(outfile);
        files++;
      }
    }
  }
  System.out.println("String_Node_Str" + files + "String_Node_Str");
  setUpdating(false);
}
Program: 56647
Project: 56647
Buggy source:
@Override protected void subTimerEvent(){
  delayCtr++;
  if (delayCtr > 5) {
    delayCtr=0;
    if (!searchedSoldiers.isEmpty()) {
      if (request == null) {
        request=new DijkstraContinuableRequest(this,super.getPos().getX(),super.getPos().getY(),(short)1,Constants.TOWER_SOLDIER_SEARCH_AREA);
        request.setSearchType(searchedSoldiers.peek());
      }
      Path path=super.getGrid().getDijkstra().find(request);
      if (path != null) {
        System.out.println("String_Node_Str");
        IHexMovable soldier=super.getGrid().getMovable(path.getTargetPos());
        if (soldier != null && soldier.setOccupyableBuilding(this)) {
          searchedSoldiers.pop();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void subTimerEvent(){
  delayCtr++;
  if (delayCtr > 5) {
    delayCtr=0;
    if (!searchedSoldiers.isEmpty()) {
      if (request == null) {
        request=new DijkstraContinuableRequest(this,super.getPos().getX(),super.getPos().getY(),(short)1,Constants.TOWER_SOLDIER_SEARCH_AREA);
      }
      request.setSearchType(searchedSoldiers.peek());
      Path path=super.getGrid().getDijkstra().find(request);
      if (path != null) {
        System.out.println("String_Node_Str");
        IHexMovable soldier=super.getGrid().getMovable(path.getTargetPos());
        if (soldier != null && soldier.setOccupyableBuilding(this)) {
          searchedSoldiers.pop();
        }
      }
    }
  }
}
Program: 56648
Project: 56648
Buggy source:
private boolean isSoldierAt(short x,short y,ESearchType searchType){
  IMovable movable=movableGrid.getMovableAt(x,y);
  if (movable == null) {
    return false;
  }
 else {
    EMovableType type=movable.getMovableType();
switch (searchType) {
case SOLDIER_BOWMAN:
      return type == EMovableType.BOWMAN_L1 || type == EMovableType.BOWMAN_L2 || type == EMovableType.BOWMAN_L3;
case SOLDIER_SWORDSMAN:
    return type == EMovableType.SWORDSMAN_L1 || type == EMovableType.SWORDSMAN_L2 || type == EMovableType.SWORDSMAN_L3;
case SOLDIER_PIKEMAN:
  return type == EMovableType.PIKEMAN_L1 || type == EMovableType.PIKEMAN_L2 || type == EMovableType.PIKEMAN_L3;
default :
return false;
}
}
}

Fixed version (ground truth):
private boolean isSoldierAt(short x,short y,ESearchType searchType,byte player){
  IHexMovable movable=movableGrid.getMovableAt(x,y);
  if (movable == null) {
    return false;
  }
 else {
    if (movable.getPlayer() == player && movable.canOccupyBuilding()) {
      EMovableType type=movable.getMovableType();
switch (searchType) {
case SOLDIER_BOWMAN:
        return type == EMovableType.BOWMAN_L1 || type == EMovableType.BOWMAN_L2 || type == EMovableType.BOWMAN_L3;
case SOLDIER_SWORDSMAN:
      return type == EMovableType.SWORDSMAN_L1 || type == EMovableType.SWORDSMAN_L2 || type == EMovableType.SWORDSMAN_L3;
case SOLDIER_PIKEMAN:
    return type == EMovableType.PIKEMAN_L1 || type == EMovableType.PIKEMAN_L2 || type == EMovableType.PIKEMAN_L3;
default :
  return false;
}
}
 else {
return false;
}
}
}
Program: 56649
Project: 56649
Buggy source:
public final void appearAt(IBuildingsGrid grid,ISPosition2D pos){
  this.state=EBuildingState.CONSTRUCTED;
  positionAt(grid,pos);
  if (this.pos != null) {
    grid.setBlocked(buildingArea,true);
    finishConstruction();
  }
}

Fixed version (ground truth):
public final void appearAt(IBuildingsGrid grid,ISPosition2D pos){
  this.state=EBuildingState.CONSTRUCTED;
  positionAt(grid,pos);
  if (this.pos != null) {
    grid.setBlocked(buildingArea,true);
    finishConstruction();
  }
  appearedEvent();
}
Program: 56650
Project: 56650
Buggy source:
@Override protected void killedEvent(){
  if (!occupiers.isEmpty()) {
    MapShapeFilter occupied=getOccupyablePositions();
    super.getGrid().freeOccupiedArea(occupied,super.getPos());
  }
}

Fixed version (ground truth):
@Override protected void killedEvent(){
  if (occupiedArea) {
    MapShapeFilter occupied=getOccupyablePositions();
    super.getGrid().freeOccupiedArea(occupied,super.getPos());
  }
}
Program: 56651
Project: 56651
Buggy source:
@Override public void setSoldier(IBuildingOccupyableMovable soldier){
  for (  OccupyerPlace curr : emptyPlaces) {
    if (curr.getType() == soldier.getSoldierType()) {
      emptyPlaces.remove(curr);
      occupiers.add(new TowerOccupyer(curr,soldier));
      break;
    }
  }
  MapShapeFilter occupying=getOccupyablePositions();
  super.getGrid().occupyArea(occupying,super.getPos(),super.getPlayer());
}

Fixed version (ground truth):
@Override public void setSoldier(IBuildingOccupyableMovable soldier){
  for (  OccupyerPlace curr : emptyPlaces) {
    if (curr.getType() == soldier.getSoldierType()) {
      emptyPlaces.remove(curr);
      occupiers.add(new TowerOccupyer(curr,soldier));
      break;
    }
  }
  occupyArea();
}
Program: 56652
Project: 56652
Buggy source:
private boolean lookAtSearched(){
  if (currentJob.getSearchType() == ESearchType.FISHABLE) {
    for (    EDirection direction : EDirection.values()) {
      ISPosition2D pos=direction.getNextHexPoint(super.getPos());
      if (super.getGrid().isInBounds(pos) && super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.WATER) {
        super.setDirection(direction);
        return true;
      }
    }
    return false;
  }
 else   if (currentJob.getSearchType() == ESearchType.CUTTABLE_STONE) {
    super.setDirection(EDirection.NORTH_EAST);
    return true;
  }
 else   if (currentJob.getSearchType() == ESearchType.RIVER) {
    for (    EDirection direction : EDirection.values()) {
      ISPosition2D pos=direction.getNextHexPoint(super.getPos());
      if (super.getGrid().isInBounds(pos) && (super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER1 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER2 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER3 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER4)) {
        super.setDirection(direction);
        return true;
      }
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean lookAtSearched(){
  if (currentJob.getSearchType() == ESearchType.FISHABLE) {
    for (    EDirection direction : EDirection.values()) {
      ISPosition2D pos=direction.getNextHexPoint(super.getPos());
      if (super.getGrid().isInBounds(pos) && super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.WATER) {
        super.setDirection(direction);
        return true;
      }
    }
    return false;
  }
 else   if (currentJob.getSearchType() == ESearchType.CUTTABLE_STONE) {
    super.setDirection(EDirection.NORTH_WEST);
    return true;
  }
 else   if (currentJob.getSearchType() == ESearchType.RIVER) {
    for (    EDirection direction : EDirection.values()) {
      ISPosition2D pos=direction.getNextHexPoint(super.getPos());
      if (super.getGrid().isInBounds(pos) && (super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER1 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER2 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER3 || super.getGrid().getLandscapeTypeAt(pos) == ELandscapeType.RIVER4)) {
        super.setDirection(direction);
        return true;
      }
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 56653
Project: 56653
Buggy source:
private PanToAction getForMinimap(float relativex,float relativey){
  float minimapx=(relativex - constants.MINIMAP_BOTTOMLEFT_X) / constants.MINIMAP_WIDTH;
  float minimapy=((relativey - constants.UI_CENTERY) / (1 - constants.UI_CENTERY) - constants.MINIMAP_BOTTOM_Y) / constants.MINIMAP_HEIGHT;
  ISPosition2D clickPosition=minimap.getClickPosition(minimapx,minimapy);
  if (minimap.getContext().checkMapCoordinates(clickPosition.getX(),clickPosition.getY())) {
    return new PanToAction(clickPosition);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
private PanToAction getForMinimap(float relativex,float relativey){
  float minimapx=(relativex - constants.MINIMAP_BOTTOMLEFT_X) / constants.MINIMAP_WIDTH;
  float minimapy=((relativey - constants.UI_CENTERY) / (1 - constants.UI_CENTERY) - constants.MINIMAP_BOTTOM_Y) / constants.MINIMAP_HEIGHT;
  ISPosition2D clickPosition=minimap.getClickPositionIfOnMap(minimapx,minimapy);
  if (clickPosition != null) {
    return new PanToAction(clickPosition);
  }
 else {
    return null;
  }
}
Program: 56654
Project: 56654
Buggy source:
@Override public Action getActionFor(UIPoint position){
  float relativex=(float)position.getX() / this.uiBase.getPosition().getWidth();
  float relativey=(float)position.getY() / this.uiBase.getPosition().getHeight();
  Action action;
  if (relativey > constants.UI_CENTERY) {
    action=getForMinimap(relativex,relativey);
  }
 else {
    action=uiBase.getAction(relativex,relativey);
  }
  if (action != null && action.getActionType() == EActionType.CHANGE_PANEL) {
    mainPanel.setContent(((ChangePanelAction)action).getContent());
    return null;
  }
 else {
    return action;
  }
}

Fixed version (ground truth):
@Override public Action getActionFor(UIPoint position){
  float relativex=(float)position.getX() / this.uiBase.getPosition().getWidth();
  float relativey=(float)position.getY() / this.uiBase.getPosition().getHeight();
  Action action;
  if (relativey > constants.UI_CENTERY) {
    action=getForMinimap(relativex,relativey);
    startMapPosition=null;
  }
 else {
    action=uiBase.getAction(relativex,relativey);
  }
  if (action != null && action.getActionType() == EActionType.CHANGE_PANEL) {
    mainPanel.setContent(((ChangePanelAction)action).getContent());
    return null;
  }
 else {
    return action;
  }
}
Program: 56655
Project: 56655
Buggy source:
private Action getForMinimap(float relativex,float relativey){
  float minimapx=(relativex - constants.MINIMAP_BOTTOMLEFT_X) / constants.MINIMAP_WIDTH;
  float minimapy=((relativey - constants.UI_CENTERY) / (1 - constants.UI_CENTERY) - constants.MINIMAP_BOTTOM_Y) / constants.MINIMAP_HEIGHT;
  ISPosition2D clickPosition=minimap.getClickPosition(minimapx,minimapy);
  return new PanToAction(clickPosition);
}

Fixed version (ground truth):
private PanToAction getForMinimap(float relativex,float relativey){
  float minimapx=(relativex - constants.MINIMAP_BOTTOMLEFT_X) / constants.MINIMAP_WIDTH;
  float minimapy=((relativey - constants.UI_CENTERY) / (1 - constants.UI_CENTERY) - constants.MINIMAP_BOTTOM_Y) / constants.MINIMAP_HEIGHT;
  ISPosition2D clickPosition=minimap.getClickPosition(minimapx,minimapy);
  if (minimap.getContext().checkMapCoordinates(clickPosition.getX(),clickPosition.getY())) {
    return new PanToAction(clickPosition);
  }
 else {
    return null;
  }
}
Program: 56656
Project: 56656
Buggy source:
@Override public boolean handleDrawEvent(GODrawEvent event){
  return false;
}

Fixed version (ground truth):
@Override public boolean handleDrawEvent(GODrawEvent event){
  if (!containsPoint(event.getDrawPosition())) {
    return false;
  }
  Action action=getActionForDraw(event);
  if (action != null) {
    MapDrawContext context=minimap.getContext();
    float y=context.getScreen().getHeight() / 2;
    float x=context.getScreen().getWidth() / 2;
    startMapPosition=context.getPositionOnScreen(x,y);
    event.setHandler(new DrawMinimapHandler());
    return true;
  }
 else {
    return false;
  }
}
Program: 56657
Project: 56657
Buggy source:
@Override public void run(){
  while (true) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null) {
        if (!NetworkTimer.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.start();
          calculateConstructMarks();
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      removeConstructionMarks(mapArea);
      lastArea=null;
      Thread.sleep(30);
    }
 catch (    Throwable e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null) {
        if (!NetworkTimer.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.start();
          calculateConstructMarks();
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      removeConstructionMarks(lastArea);
      lastArea=null;
    }
 catch (    Throwable e) {
      e.printStackTrace();
    }
  }
}
Program: 56658
Project: 56658
Buggy source:
private void calculateConstructMarks(){
  IMapArea localMapArea=this.mapArea;
  if (buildingType == null || localMapArea == null) {
    return;
  }
  RelativePoint[] usedPositions=buildingType.getProtectedTiles();
  if (lastArea != null) {
    removeConstructionMarks(lastArea,localMapArea);
  }
  for (  ISPosition2D pos : localMapArea) {
    short x=pos.getX();
    short y=pos.getY();
    byte value;
    if (map.canConstructAt(x,y,buildingType,player)) {
      value=calculateConstrMarkVal(x,y,usedPositions);
    }
 else {
      value=-1;
    }
    map.setConstructMarking(pos,value);
  }
  lastArea=localMapArea;
}

Fixed version (ground truth):
private void calculateConstructMarks(){
  IMapArea currMapArea=this.mapArea;
  EBuildingType currBuildingType=this.buildingType;
  if (currBuildingType == null || currMapArea == null) {
    return;
  }
  RelativePoint[] usedPositions=currBuildingType.getProtectedTiles();
  if (lastArea != null) {
    removeConstructionMarks(lastArea,currMapArea);
  }
  for (  ISPosition2D pos : currMapArea) {
    short x=pos.getX();
    short y=pos.getY();
    byte value;
    if (map.canConstructAt(x,y,currBuildingType,player)) {
      value=calculateConstrMarkVal(x,y,usedPositions);
    }
 else {
      value=-1;
    }
    map.setConstructMarking(pos,value);
  }
  lastArea=currMapArea;
}
Program: 56659
Project: 56659
Buggy source:
@Override public Color getDebugColorAt(int x,int y){
  return debugColors[x][y];
}

Fixed version (ground truth):
@Override public Color getDebugColorAt(int x,int y){
  short value=(short)(partitionsGrid.getPartitionAt((short)x,(short)y) + 1);
  return new Color((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56660
Project: 56660
Buggy source:
public boolean isBlockedForPeople(short x,short y){
  return grid.isBlocked(x,y);
}

Fixed version (ground truth):
@Override public boolean isBlockedForPeople(short x,short y){
  return grid.isBlocked(x,y);
}
Program: 56661
Project: 56661
Buggy source:
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] pointsBuffer=new short[MAX_LENGTH];
  pointsBuffer[0]=inX;
  pointsBuffer[1]=inY;
  short length=2;
  while (length > 0) {
    short y=pointsBuffer[--length];
    short x=pointsBuffer[--length];
    if (partitions[x][y] != oldPartition) {
      continue;
    }
    setPartition(x,y,newPartition);
    for (byte i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
      short currX=(short)(x + neighborX[i]);
      short currY=(short)(y + neighborY[i]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition && !grid.isBlocked(currX,currY)) {
        if (length < MAX_LENGTH) {
          pointsBuffer[length++]=currX;
          pointsBuffer[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] pointsBuffer=new short[MAX_LENGTH];
  pointsBuffer[0]=inX;
  pointsBuffer[1]=inY;
  short length=2;
  while (length > 0) {
    short y=pointsBuffer[--length];
    short x=pointsBuffer[--length];
    if (partitions[x][y] != oldPartition) {
      continue;
    }
    setPartition(x,y,newPartition);
    boolean currIsBlocked=grid.isBlocked(x,y);
    for (byte i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
      short currX=(short)(x + neighborX[i]);
      short currY=(short)(y + neighborY[i]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition && (!currIsBlocked || grid.isBlocked(currX,currY))) {
        if (length < MAX_LENGTH) {
          pointsBuffer[length++]=currX;
          pointsBuffer[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}
Program: 56662
Project: 56662
Buggy source:
public boolean isInBounds(short x,short y){
  return 0 <= x && x < width && 0 <= y && y < height;
}

Fixed version (ground truth):
@Override public boolean isInBounds(short x,short y){
  return 0 <= x && x < width && 0 <= y && y < height;
}