nus-yam/ex-repair huggingface dataset:
Program: 56353
Project: 56353
Buggy source:
@Override public final void setSelected(boolean selected){
  super.setSelected(selected);
  for (  TowerOccupyer curr : occupiers) {
    curr.getSoldier().setSelected(selected);
  }
  if (attackableTowerObject != null && attackableTowerObject.currDefender != null) {
    attackableTowerObject.currDefender.getSoldier().setSelected(selected);
  }
}

Fixed version (ground truth):
@Override public final void setSelected(boolean selected){
  super.setSelected(selected);
  for (  TowerOccupier curr : occupiers) {
    curr.getSoldier().setSelected(selected);
  }
  if (attackableTowerObject != null && attackableTowerObject.currDefender != null) {
    attackableTowerObject.currDefender.getSoldier().setSelected(selected);
  }
}
Program: 56354
Project: 56354
Buggy source:
/** 
 * Adds or removes the informable map object for the given soldier.
 * @param soldier
 * @param add if true, the object is added<br> if false, the object is removed.
 */
private void addInformableMapObject(TowerOccupyer soldier,boolean add){
  if (soldier.place.getType() == ESoldierType.BOWMAN) {
    ShortPoint2D position=getTowerBowmanSearchPosition(soldier.place);
    if (add) {
      super.getGrid().getMapObjectsManager().addInformableMapObjectAt(position,soldier.getSoldier().getMovable());
    }
 else {
      super.getGrid().getMapObjectsManager().removeMapObjectType(position.x,position.y,EMapObjectType.INFORMABLE_MAP_OBJECT);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds or removes the informable map object for the given soldier.
 * @param soldier
 * @param add if true, the object is added<br> if false, the object is removed.
 */
private void addInformableMapObject(TowerOccupier soldier,boolean add){
  if (soldier.place.getType() == ESoldierType.BOWMAN) {
    ShortPoint2D position=getTowerBowmanSearchPosition(soldier.place);
    if (add) {
      super.getGrid().getMapObjectsManager().addInformableMapObjectAt(position,soldier.getSoldier().getMovable());
    }
 else {
      super.getGrid().getMapObjectsManager().removeMapObjectType(position.x,position.y,EMapObjectType.INFORMABLE_MAP_OBJECT);
    }
  }
}
Program: 56355
Project: 56355
Buggy source:
@Override protected final void killedEvent(){
  setSelected(false);
  if (occupiedArea) {
    freeArea();
    int idx=0;
    FreeMapArea buildingArea=super.getBuildingArea();
    for (    TowerOccupyer curr : occupiers) {
      addInformableMapObject(curr,false);
      curr.getSoldier().leaveOccupyableBuilding(buildingArea.get(idx));
      idx++;
    }
    occupiers.clear();
  }
  setAttackableTowerObject(false);
}

Fixed version (ground truth):
@Override protected final void killedEvent(){
  setSelected(false);
  if (occupiedArea) {
    freeArea();
    int idx=0;
    FreeMapArea buildingArea=super.getBuildingArea();
    for (    TowerOccupier curr : occupiers) {
      addInformableMapObject(curr,false);
      curr.getSoldier().leaveOccupyableBuilding(buildingArea.get(idx));
      idx++;
    }
    occupiers.clear();
  }
  setAttackableTowerObject(false);
}
Program: 56356
Project: 56356
Buggy source:
private void initSoldierRequests(){
  final OccupyerPlace[] occupyerPlaces=super.getBuildingType().getOccupyerPlaces();
  if (occupyerPlaces.length > 0) {
    for (    OccupyerPlace currPlace : occupyerPlaces) {
      emptyPlaces.add(currPlace);
      searchedSoldiers.add(currPlace.getType() == ESoldierType.INFANTRY ? ESearchType.SOLDIER_SWORDSMAN : ESearchType.SOLDIER_BOWMAN);
    }
  }
}

Fixed version (ground truth):
private void initSoldierRequests(){
  final OccupyerPlace[] occupyerPlaces=super.getBuildingType().getOccupyerPlaces();
  if (occupyerPlaces.length > 0) {
    for (    OccupyerPlace currPlace : occupyerPlaces) {
      requestSoldierForPlace(currPlace);
    }
  }
}
Program: 56357
Project: 56357
Buggy source:
@Override public final OccupyerPlace addSoldier(IBuildingOccupyableMovable soldier){
  OccupyerPlace freePosition=findFreePositionFor(soldier.getSoldierType());
  emptyPlaces.remove(freePosition);
  currentlyCommingSoldiers[freePosition.getType().ordinal()]--;
  TowerOccupyer towerOccupier=new TowerOccupyer(freePosition,soldier);
  occupiers.add(towerOccupier);
  occupyAreaIfNeeded();
  soldier.setSelected(super.isSelected());
  addInformableMapObject(towerOccupier,true);
  return freePosition;
}

Fixed version (ground truth):
@Override public final OccupyerPlace addSoldier(IBuildingOccupyableMovable soldier){
  OccupyerPlace freePosition=findFreePositionFor(soldier.getSoldierType());
  emptyPlaces.remove(freePosition);
  currentlyCommingSoldiers[freePosition.getType().ordinal()]--;
  TowerOccupier towerOccupier=new TowerOccupier(freePosition,soldier);
  occupiers.add(towerOccupier);
  occupyAreaIfNeeded();
  soldier.setSelected(super.isSelected());
  addInformableMapObject(towerOccupier,true);
  return freePosition;
}
Program: 56358
Project: 56358
Buggy source:
@Override public void towerDefended(IBuildingOccupyableMovable soldier){
  inFight=false;
  if (attackableTowerObject.currDefender == null) {
    System.out.println();
  }
  occupiers.add(new TowerOccupyer(attackableTowerObject.currDefender.place,soldier));
  attackableTowerObject.currDefender=null;
}

Fixed version (ground truth):
@Override public void towerDefended(IBuildingOccupyableMovable soldier){
  inFight=false;
  if (attackableTowerObject.currDefender == null) {
    System.out.println();
  }
  occupiers.add(new TowerOccupier(attackableTowerObject.currDefender.place,soldier));
  attackableTowerObject.currDefender=null;
  doorHealth=0.1f;
}
Program: 56359
Project: 56359
Buggy source:
protected TowerOccupyer removeSoldier(){
  TowerOccupyer removedSoldier=occupiers.removeFirst();
  addInformableMapObject(removedSoldier,false);
  return removedSoldier;
}

Fixed version (ground truth):
protected TowerOccupier removeSoldier(){
  TowerOccupier removedSoldier=occupiers.removeFirst();
  addInformableMapObject(removedSoldier,false);
  return removedSoldier;
}
Program: 56360
Project: 56360
Buggy source:
public OccupyingBuilding(EBuildingType type,Player player){
  super(type,player);
  this.occupiers=new LinkedList<TowerOccupyer>();
  initSoldierRequests();
  delayCtr=(byte)RandomSingleton.getInt(0,3);
}

Fixed version (ground truth):
public OccupyingBuilding(EBuildingType type,Player player){
  super(type,player);
  this.occupiers=new LinkedList<TowerOccupier>();
  initSoldierRequests();
  delayCtr=(byte)RandomSingleton.getInt(0,3);
}
Program: 56361
Project: 56361
Buggy source:
@Override public final ShortPoint2D getPosition(IBuildingOccupyableMovable soldier){
  for (  TowerOccupyer curr : occupiers) {
    if (curr.getSoldier() == soldier) {
      return curr.place.getPosition().calculatePoint(super.getPos());
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public final ShortPoint2D getPosition(IBuildingOccupyableMovable soldier){
  for (  TowerOccupier curr : occupiers) {
    if (curr.getSoldier() == soldier) {
      return curr.place.getPosition().calculatePoint(super.getPos());
    }
  }
  return null;
}
Program: 56362
Project: 56362
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y) + 1;
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getTowerCountAt(x,y) + 1;
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56363
Project: 56363
Buggy source:
@Override public void mergeInto(PartitionManager newManager){
  super.mergeInto(newManager);
  counter=0;
  xSum=0;
  ySum=0;
}

Fixed version (ground truth):
public void mergeInto(Partition newPartition){
  super.mergeInto(newPartition);
  newPartition.counter+=this.counter;
  newPartition.xSum+=xSum;
  newPartition.ySum+=ySum;
  counter=0;
  xSum=0;
  ySum=0;
}
Program: 56364
Project: 56364
Buggy source:
/** 
 * Checks if the given partitions is divided and the both given positions are on separated parts of the partition.
 * @param partition
 * @param pos1
 * @param pos2
 */
private void checkIfDividePartition(Short partition,ShortPoint2D pos1,ShortPoint2D pos2){
  System.out.println("String_Node_Str" + partition + "String_Node_Str"+ pos1+ "String_Node_Str"+ pos2);
  if (!PartitionsDividedTester.isPartitionNotDivided(this,pos1,pos2,partition)) {
    dividePartition(partition,pos1,pos2);
  }
}

Fixed version (ground truth):
/** 
 * Checks if the given partitions is divided and the both given positions are on separated parts of the partition.
 * @param partition
 * @param pos1
 * @param pos2
 */
private void checkIfDividePartition(Short partition,ShortPoint2D pos1,ShortPoint2D pos2){
  System.out.println("String_Node_Str" + partition + "String_Node_Str"+ pos1+ "String_Node_Str"+ pos2);
  if (partition != NO_PLAYER_PARTITION_ID && !PartitionsDividedTester.isPartitionNotDivided(this,pos1,pos2,partition)) {
    dividePartition(partition,pos1,pos2);
  }
}
Program: 56365
Project: 56365
Buggy source:
public void mergeInto(PartitionManager newManager){
  newManager.bricklayerRequests.addAll(this.bricklayerRequests);
  newManager.diggerRequests.addAll(this.diggerRequests);
  newManager.joblessBearer.addAll(this.joblessBearer);
  newManager.joblessBricklayers.addAll(this.joblessBricklayers);
  newManager.joblessDiggers.addAll(this.joblessDiggers);
  newManager.joblessWorkers.addAll(this.joblessWorkers);
  newManager.materialOffers.addAll(this.materialOffers);
  newManager.materialRequests.addAll(this.materialRequests);
  newManager.soilderCreationRequests.addAll(this.soilderCreationRequests);
  newManager.workerCreationRequests.addAll(this.workerCreationRequests);
  newManager.workerRequests.addAll(this.workerRequests);
  newManager.toolProductionRequests.addAll(toolProductionRequests);
  newManager.weaponProductionRequests.addAll(weaponProductionRequests);
  newManager.toolRequestingWorkerRequests.merge(this.toolRequestingWorkerRequests);
}

Fixed version (ground truth):
public final void mergeInto(PartitionManager newManager){
  newManager.bricklayerRequests.addAll(this.bricklayerRequests);
  newManager.diggerRequests.addAll(this.diggerRequests);
  newManager.joblessBearer.addAll(this.joblessBearer);
  newManager.joblessBricklayers.addAll(this.joblessBricklayers);
  newManager.joblessDiggers.addAll(this.joblessDiggers);
  newManager.joblessWorkers.addAll(this.joblessWorkers);
  newManager.materialOffers.addAll(this.materialOffers);
  newManager.materialRequests.addAll(this.materialRequests);
  newManager.soilderCreationRequests.addAll(this.soilderCreationRequests);
  newManager.workerCreationRequests.addAll(this.workerCreationRequests);
  newManager.workerRequests.addAll(this.workerRequests);
  newManager.toolProductionRequests.addAll(toolProductionRequests);
  newManager.weaponProductionRequests.addAll(weaponProductionRequests);
  newManager.toolRequestingWorkerRequests.merge(this.toolRequestingWorkerRequests);
}
Program: 56366
Project: 56366
Buggy source:
public ErrorsWindow(ErrorList list,IScrollToAble scrollTo){
  this.list=list;
  this.scrollTo=scrollTo;
  elist=new JList<ILocatable>(list);
  elist.addListSelectionListener(this);
  window=new JFrame(EditorLabels.getLabel("String_Node_Str"));
  window.add(new JScrollPane(elist));
  window.setPreferredSize(new Dimension(500,300));
  window.pack();
  window.setVisible(true);
  window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

Fixed version (ground truth):
public ErrorsWindow(ErrorList list,IScrollToAble scrollTo){
  this.list=list;
  this.scrollTo=scrollTo;
  elist=new JList(list);
  elist.addListSelectionListener(this);
  window=new JFrame(EditorLabels.getLabel("String_Node_Str"));
  window.add(new JScrollPane(elist));
  window.setPreferredSize(new Dimension(500,300));
  window.pack();
  window.setVisible(true);
  window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
Program: 56367
Project: 56367
Buggy source:
public StopWatch(){
  start();
}

Fixed version (ground truth):
public StopWatch(){
  restart();
}
Program: 56368
Project: 56368
Buggy source:
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        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 (    InterruptedException e) {
    }
catch (    Throwable t) {
      t.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        if (!NetworkTimer.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.restart();
          calculateConstructMarks();
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      removeConstructionMarks(lastArea);
      lastArea=null;
    }
 catch (    InterruptedException e) {
    }
catch (    Throwable t) {
      t.printStackTrace();
    }
  }
}
Program: 56369
Project: 56369
Buggy source:
@Override public final void run(){
  mySleep(500);
  while (!canceled) {
    StopWatch watch=new MilliStopWatch();
    watch.start();
    if (enabled) {
      rebuildSight();
    }
    mySleep(800);
  }
}

Fixed version (ground truth):
@Override public final void run(){
  mySleep(500);
  while (!canceled) {
    StopWatch watch=new MilliStopWatch();
    watch.restart();
    if (enabled) {
      rebuildSight();
    }
    mySleep(800);
  }
}
Program: 56370
Project: 56370
Buggy source:
private final void occupyAreaIfNeeded(){
  if (!occupiedArea) {
    MapCircle occupying=getOccupyablePositions();
    super.getGrid().occupyAreaByTower(super.getPlayer(),occupying);
    occupiedArea=true;
  }
}

Fixed version (ground truth):
private final void occupyAreaIfNeeded(){
  if (!occupiedArea) {
    MapCircle occupying=new MapCircle(super.getPos(),CommonConstants.TOWER_RADIUS);
    super.getGrid().occupyAreaByTower(super.getPlayer(),occupying);
    occupiedArea=true;
  }
}
Program: 56371
Project: 56371
Buggy source:
private void initAdditionalGrids(){
  this.graphicsGrid=new GraphicsGrid();
  this.landmarksCorrection=new LandmarksCorrectingThread(new LandmarksGrid());
  this.constructionMarksGrid=new ConstructionMarksGrid();
  this.bordersThread=new BordersThread(new BordersThreadGrid());
  this.guiInputGrid=new GUIInputGrid();
}

Fixed version (ground truth):
private void initAdditionalGrids(){
  this.graphicsGrid=new GraphicsGrid();
  this.landmarksCorrection=new LandmarksCorrectingThread(new LandmarksThreadGrid());
  this.constructionMarksGrid=new ConstructionMarksGrid();
  this.bordersThread=new BordersThread(new BordersThreadGrid());
  this.guiInputGrid=new GUIInputGrid();
}
Program: 56372
Project: 56372
Buggy source:
/** 
 * sets this position blocked and protected.
 * @param x x coordinate
 * @param y y coordinate
 * @param blocked the position will be set to blocked and protected if blocked == true<br> otherwise it will be set to unblocked and unprotected.
 */
public void setBlockedAndProtected(short x,short y,boolean blocked){
  final int idx=x + y * width;
  this.blockedGrid.set(idx,blocked);
  this.protectedGrid.set(idx,blocked);
}

Fixed version (ground truth):
/** 
 * sets this position blocked and protected.
 * @param x x coordinate
 * @param y y coordinate
 * @param blocked the position will be set to blocked and protected if blocked == true<br> otherwise it will be set to unblocked and unprotected.
 */
public void setBlockedAndProtected(short x,short y,boolean blocked){
  final int idx=x + y * width;
  this.blockedGrid.set(idx,blocked);
  this.protectedGrid.set(idx,blocked);
  if (blockingChangedListener != null) {
    this.blockingChangedListener.blockingChanged(x,y,blocked);
  }
}
Program: 56373
Project: 56373
Buggy source:
/** 
 * @param pos1
 * @param pos2
 * @return The position with the bigger distance to the gravity center of this partition.
 */
public ShortPoint2D getPositionCloserToGravityCenter(ShortPoint2D pos1,ShortPoint2D pos2){
  int gravityX=xSum / counter;
  int gravityY=ySum / counter;
  int dist1=ShortPoint2D.getOnGridDist(gravityX - pos1.x,gravityY - pos1.y);
  int dist2=ShortPoint2D.getOnGridDist(gravityX - pos2.x,gravityY - pos2.y);
  return dist1 >= dist2 ? pos1 : pos2;
}

Fixed version (ground truth):
/** 
 * @param pos1
 * @param pos2
 * @return The position with the bigger distance to the gravity center of this partition.
 */
public ShortPoint2D getPositionCloserToGravityCenter(ShortPoint2D pos1,ShortPoint2D pos2){
  int gravityY;
  int gravityX;
  if (counter > 0) {
    gravityX=xSum / counter;
    gravityY=ySum / counter;
  }
 else {
    gravityX=0;
    gravityY=0;
  }
  int dist1=ShortPoint2D.getOnGridDist(gravityX - pos1.x,gravityY - pos1.y);
  int dist2=ShortPoint2D.getOnGridDist(gravityX - pos2.x,gravityY - pos2.y);
  return dist1 >= dist2 ? pos1 : pos2;
}
Program: 56374
Project: 56374
Buggy source:
public PartitionsGrid(short width,short height,byte numberOfPlayers,IBlockingProvider blockingProvider){
  this.width=width;
  this.height=height;
  this.blockingProvider=blockingProvider;
  this.players=new Player[numberOfPlayers];
  for (byte i=0; i < numberOfPlayers; i++) {
    Team team=new Team(i);
    this.players[i]=new Player(i,team);
  }
  this.partitions=new short[width * height];
  this.towers=new byte[width * height];
  this.partitionObjects[NO_PLAYER_PARTITION_ID]=new Partition((byte)-1,width * height);
  this.partitionRepresentative[NO_PLAYER_PARTITION_ID]=NO_PLAYER_PARTITION_ID;
  initAdditionalFields();
}

Fixed version (ground truth):
public PartitionsGrid(short width,short height,byte numberOfPlayers,IPartitionsGridBlockingProvider blockingProvider){
  this.width=width;
  this.height=height;
  this.blockingProvider=blockingProvider;
  blockingProvider.registerListener(this);
  this.players=new Player[numberOfPlayers];
  for (byte i=0; i < numberOfPlayers; i++) {
    Team team=new Team(i);
    this.players[i]=new Player(i,team);
  }
  this.partitions=new short[width * height];
  this.towers=new byte[width * height];
  this.partitionObjects[NO_PLAYER_PARTITION_ID]=new Partition((byte)-1,width * height);
  this.partitionRepresentative[NO_PLAYER_PARTITION_ID]=NO_PLAYER_PARTITION_ID;
  initAdditionalFields();
}
Program: 56375
Project: 56375
Buggy source:
@Override protected void constructionFinishedEvent(){
  placeFlag(true);
}

Fixed version (ground truth):
@Override protected void constructionFinishedEvent(){
}
Program: 56376
Project: 56376
Buggy source:
@Override public void timerEvent(){
  if (health <= 0) {
    return;
  }
switch (state) {
case SLEEPING:
    return;
case DOING_NOTHING:
  if (visible && enableNothingToDo) {
    doingNothingAction();
  }
break;
case GOING_SINGLE_STEP:
case PLAYING_ACTION:
progressCurrentAction();
break;
case PATHING:
pathingAction();
break;
}
if (moveToRequest != null) {
switch (state) {
case PATHING:
if (progress < 1) {
break;
}
setState(ENewMovableState.DOING_NOTHING);
case DOING_NOTHING:
ShortPoint2D oldTargetPos;
if (path != null) {
oldTargetPos=path.getTargetPos();
}
 else {
oldTargetPos=null;
}
goToPos(moveToRequest);
moveToRequest=null;
if (path != null) {
this.strategy.moveToPathSet(oldTargetPos,path.getTargetPos());
}
break;
}
}
if (state == ENewMovableState.DOING_NOTHING) {
strategy.action();
}
}

Fixed version (ground truth):
@Override public void timerEvent(){
  if (health <= 0) {
    return;
  }
switch (state) {
case SLEEPING:
    return;
case DOING_NOTHING:
  if (visible && enableNothingToDo) {
    doingNothingAction();
  }
break;
case GOING_SINGLE_STEP:
case PLAYING_ACTION:
progressCurrentAction();
break;
case PATHING:
pathingAction();
break;
default :
break;
}
if (moveToRequest != null) {
switch (state) {
case PATHING:
if (progress < 1) {
break;
}
setState(ENewMovableState.DOING_NOTHING);
case DOING_NOTHING:
ShortPoint2D oldTargetPos;
if (path != null) {
oldTargetPos=path.getTargetPos();
}
 else {
oldTargetPos=null;
}
goToPos(moveToRequest);
moveToRequest=null;
if (path != null) {
this.strategy.moveToPathSet(oldTargetPos,path.getTargetPos());
}
break;
default :
break;
}
}
if (state == ENewMovableState.DOING_NOTHING) {
strategy.action();
}
}
Program: 56377
Project: 56377
Buggy source:
private void handleJobFailed(boolean reportAsJobless){
switch (state) {
case INIT_CARRY_JOB:
case GOING_TO_OFFER:
    reoffer();
case TAKING:
  if (targetMovableType != null) {
    workerRequester.workerCreationRequestFailed(targetMovableType,super.getPos());
  }
case GOING_TO_REQUEST:
if (requester != null && requester.isDiggerRequestActive()) {
  requester.requestFailed();
}
break;
case INIT_BECOME_SOLDIER_JOB:
case GOING_TO_BARRACK:
barrack.bearerRequestFailed();
break;
case DROPPING:
break;
case INIT_CONVERT_WITH_TOOL_JOB:
reoffer();
case INIT_CONVERT_JOB:
workerRequester.workerCreationRequestFailed(targetMovableType,super.getPos());
break;
case DEAD_OBJECT:
break;
}
EMaterialType carriedMaterial=super.setMaterial(EMaterialType.NO_MATERIAL);
if (carriedMaterial != EMaterialType.NO_MATERIAL) {
super.getStrategyGrid().dropMaterial(super.getPos(),materialType,true);
}
offer=null;
requester=null;
materialType=null;
targetMovableType=null;
workerRequester=null;
state=EBearerState.JOBLESS;
if (reportAsJobless) {
reportAsJobless();
}
}

Fixed version (ground truth):
private void handleJobFailed(boolean reportAsJobless){
switch (state) {
case INIT_CARRY_JOB:
case GOING_TO_OFFER:
    reoffer();
case TAKING:
  if (targetMovableType != null) {
    workerRequester.workerCreationRequestFailed(targetMovableType,super.getPos());
  }
case GOING_TO_REQUEST:
if (requester != null && requester.isDiggerRequestActive()) {
  requester.requestFailed();
}
break;
case INIT_BECOME_SOLDIER_JOB:
case GOING_TO_BARRACK:
barrack.bearerRequestFailed();
break;
case DROPPING:
break;
case INIT_CONVERT_WITH_TOOL_JOB:
reoffer();
case INIT_CONVERT_JOB:
workerRequester.workerCreationRequestFailed(targetMovableType,super.getPos());
break;
case DEAD_OBJECT:
break;
case JOBLESS:
break;
default :
break;
}
EMaterialType carriedMaterial=super.setMaterial(EMaterialType.NO_MATERIAL);
if (carriedMaterial != EMaterialType.NO_MATERIAL) {
super.getStrategyGrid().dropMaterial(super.getPos(),materialType,true);
}
offer=null;
requester=null;
materialType=null;
targetMovableType=null;
workerRequester=null;
state=EBearerState.JOBLESS;
if (reportAsJobless) {
reportAsJobless();
}
}
Program: 56378
Project: 56378
Buggy source:
@Override protected short getSearchDistance(boolean isInTower){
  return isInTower ? Constants.TOWER_SEARCH_RADIUS : Constants.BOWMAN_ATTACK_RADIUS;
}

Fixed version (ground truth):
@Override protected short getSearchDistance(boolean isInTower){
  return isInTower ? Constants.TOWER_SEARCH_RADIUS : Constants.SOLDIER_SEARCH_RADIUS;
}
Program: 56379
Project: 56379
Buggy source:
@Override public void leaveOccupyableBuilding(ShortPoint2D newPosition){
  super.setPosition(newPosition);
  super.enableNothingToDoAction(true);
  super.setVisible(true);
  isInTower=false;
  state=ESoldierState.SEARCH_FOR_ENEMIES;
}

Fixed version (ground truth):
@Override public void leaveOccupyableBuilding(ShortPoint2D newPosition){
  super.setPosition(newPosition);
  super.enableNothingToDoAction(true);
  super.setVisible(true);
  isInTower=false;
  changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
}
Program: 56380
Project: 56380
Buggy source:
private void changeStateTo(ESoldierState state){
  this.state=state;
switch (state) {
case AGGRESSIVE:
    if (oldPathTarget != null) {
      super.goToPos(oldPathTarget);
      oldPathTarget=null;
    }
  break;
}
}

Fixed version (ground truth):
private void changeStateTo(ESoldierState state){
  this.state=state;
switch (state) {
case AGGRESSIVE:
    if (oldPathTarget != null) {
      super.goToPos(oldPathTarget);
      oldPathTarget=null;
    }
  break;
default :
break;
}
}
Program: 56381
Project: 56381
Buggy source:
@Override public void setDefendingAt(ShortPoint2D pos){
  super.setPosition(pos);
  state=ESoldierState.SEARCH_FOR_ENEMIES;
  defending=true;
}

Fixed version (ground truth):
@Override public void setDefendingAt(ShortPoint2D pos){
  super.setPosition(pos);
  changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
  defending=true;
}
Program: 56382
Project: 56382
Buggy source:
@Override public void informAboutAttackable(IAttackable other){
  if (state == ESoldierState.AGGRESSIVE && (!isInTower || getSoldierType() == ESoldierType.BOWMAN)) {
    state=ESoldierState.SEARCH_FOR_ENEMIES;
  }
}

Fixed version (ground truth):
@Override public void informAboutAttackable(IAttackable other){
  if (state == ESoldierState.AGGRESSIVE && (!isInTower || getSoldierType() == ESoldierType.BOWMAN)) {
    changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
  }
}
Program: 56383
Project: 56383
Buggy source:
@Override public void setOccupyableBuilding(IOccupyableBuilding building){
  this.building=building;
  this.state=ESoldierState.INIT_GOTO_TOWER;
  super.abortPath();
  this.oldPathTarget=null;
}

Fixed version (ground truth):
@Override public void setOccupyableBuilding(IOccupyableBuilding building){
  this.building=building;
  changeStateTo(ESoldierState.INIT_GOTO_TOWER);
  super.abortPath();
  this.oldPathTarget=null;
}
Program: 56384
Project: 56384
Buggy source:
@Override protected void action(){
switch (state) {
case AGGRESSIVE:
    break;
case HITTING:
  hitEnemy(enemy);
if (enemy.getHealth() <= 0) {
  enemy=null;
  state=ESoldierState.SEARCH_FOR_ENEMIES;
  break;
}
case SEARCH_FOR_ENEMIES:
IAttackable oldEnemy=enemy;
enemy=super.getStrategyGrid().getEnemyInSearchArea(getAttackPosition(),super.getMovable(),getSearchDistance(isInTower));
if (oldEnemy != null && oldEnemy != enemy) {
inSaveGotoMode=false;
}
if (enemy == null) {
if (defending) {
building.towerDefended(this);
defending=false;
}
changeStateTo(ESoldierState.AGGRESSIVE);
break;
}
if (isEnemyAttackable(enemy,isInTower)) {
super.lookInDirection(EDirection.getApproxDirection(super.getPos(),enemy.getPos()));
startAttackAnimation(enemy);
state=ESoldierState.HITTING;
}
 else if (!isInTower) {
state=ESoldierState.SEARCH_FOR_ENEMIES;
goToEnemy(enemy);
}
break;
case INIT_GOTO_TOWER:
super.goToPos(building.getDoor());
state=ESoldierState.GOING_TO_TOWER;
break;
case GOING_TO_TOWER:
if (building.isNotDestroyed() && building.getPlayer() == super.getPlayer()) {
OccupyerPlace place=building.addSoldier(this);
super.setPosition(place.getPosition().calculatePoint(building.getDoor()));
super.enableNothingToDoAction(false);
super.setVisible(false);
if (isBowman()) {
this.inTowerAttackPosition=building.getTowerBowmanSearchPosition(place);
}
state=ESoldierState.AGGRESSIVE;
isInTower=true;
}
 else {
state=ESoldierState.SEARCH_FOR_ENEMIES;
}
break;
}
}

Fixed version (ground truth):
@Override protected void action(){
switch (state) {
case AGGRESSIVE:
    break;
case HITTING:
  hitEnemy(enemy);
if (enemy.getHealth() <= 0) {
  enemy=null;
  changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
  break;
}
case SEARCH_FOR_ENEMIES:
IAttackable oldEnemy=enemy;
enemy=super.getStrategyGrid().getEnemyInSearchArea(getAttackPosition(),super.getMovable(),getSearchDistance(isInTower));
if (oldEnemy != null && oldEnemy != enemy) {
inSaveGotoMode=false;
}
if (enemy == null) {
if (defending) {
building.towerDefended(this);
defending=false;
}
changeStateTo(ESoldierState.AGGRESSIVE);
break;
}
if (isEnemyAttackable(enemy,isInTower)) {
super.lookInDirection(EDirection.getApproxDirection(super.getPos(),enemy.getPos()));
startAttackAnimation(enemy);
changeStateTo(ESoldierState.HITTING);
}
 else if (!isInTower) {
changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
goToEnemy(enemy);
}
break;
case INIT_GOTO_TOWER:
super.goToPos(building.getDoor());
changeStateTo(ESoldierState.GOING_TO_TOWER);
break;
case GOING_TO_TOWER:
if (building.isNotDestroyed() && building.getPlayer() == super.getPlayer()) {
OccupyerPlace place=building.addSoldier(this);
super.setPosition(place.getPosition().calculatePoint(building.getDoor()));
super.enableNothingToDoAction(false);
super.setVisible(false);
if (isBowman()) {
this.inTowerAttackPosition=building.getTowerBowmanSearchPosition(place);
}
changeStateTo(ESoldierState.AGGRESSIVE);
isInTower=true;
}
 else {
changeStateTo(ESoldierState.SEARCH_FOR_ENEMIES);
}
break;
}
}
Program: 56385
Project: 56385
Buggy source:
public void write() throws IOException {
  DataOutputStream out=new DataOutputStream(new FileOutputStream(file));
  shortBuffer.rewind();
  while (shortBuffer.hasRemaining()) {
    out.writeShort(shortBuffer.get());
  }
}

Fixed version (ground truth):
public void write() throws IOException {
  DataOutputStream out=new DataOutputStream(new FileOutputStream(file));
  shortBuffer.rewind();
  while (shortBuffer.hasRemaining()) {
    out.writeShort(shortBuffer.get());
  }
  out.close();
}
Program: 56386
Project: 56386
Buggy source:
@Override public void action(Action action){
switch (action.getActionType()) {
case MOVE_TO:
    movable.moveTo(((MoveToAction)action).getPosition());
  break;
case SPEED_FASTER:
NetworkTimer.multiplyGameSpeed(1.2f);
break;
case SPEED_SLOWER:
NetworkTimer.multiplyGameSpeed(1 / 1.2f);
break;
case FAST_FORWARD:
NetworkTimer.get().fastForward();
break;
}
}

Fixed version (ground truth):
@Override public void action(Action action){
switch (action.getActionType()) {
case MOVE_TO:
    movable.moveTo(((MoveToAction)action).getPosition());
  break;
case SPEED_FASTER:
NetworkTimer.multiplyGameSpeed(1.2f);
break;
case SPEED_SLOWER:
NetworkTimer.multiplyGameSpeed(1 / 1.2f);
break;
case FAST_FORWARD:
NetworkTimer.get().fastForward();
break;
default :
break;
}
}
Program: 56388
Project: 56388
Buggy source:
@Override public EMovableType popWeaponForBearer(){
  for (  RequestStack stack : super.getStacks()) {
    if (stack.getMaterialType() == EMaterialType.BOW || stack.getMaterialType() == EMaterialType.SWORD || stack.getMaterialType() == EMaterialType.SPEAR) {
      stack.pop();
      requestedBearer--;
      return getSoldierType(stack.getMaterialType());
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public EMovableType popWeaponForBearer(){
  List<RequestStack> stacks=super.getStacks();
  for (  RequestStack stack : stacks) {
    if (stack.getMaterialType() == EMaterialType.BOW || stack.getMaterialType() == EMaterialType.SWORD || stack.getMaterialType() == EMaterialType.SPEAR) {
      if (stack.hasMaterial()) {
        stack.pop();
        requestedBearer--;
        return getSoldierType(stack.getMaterialType());
      }
    }
  }
  return null;
}
Program: 56390
Project: 56390
Buggy source:
private boolean isProductive(){
switch (building.getBuildingType()) {
case FISHER:
    return hasProductiveResources(super.getPos(),EResourceType.FISH);
case COALMINE:
  return hasProductiveResources(building.getDoor(),EResourceType.COAL);
case IRONMINE:
return hasProductiveResources(building.getDoor(),EResourceType.IRON);
case GOLDMINE:
return hasProductiveResources(building.getDoor(),EResourceType.GOLD);
}
return false;
}

Fixed version (ground truth):
private boolean isProductive(){
switch (building.getBuildingType()) {
case FISHER:
    EDirection fishDirection=super.getStrategyGrid().getDirectionOfSearched(super.getPos(),ESearchType.FISHABLE);
  if (fishDirection != null) {
    return hasProductiveResources(fishDirection.getNextHexPoint(super.getPos()),EResourceType.FISH);
  }
 else {
    return false;
  }
case COALMINE:
return hasProductiveResources(building.getDoor(),EResourceType.COAL);
case IRONMINE:
return hasProductiveResources(building.getDoor(),EResourceType.IRON);
case GOLDMINE:
return hasProductiveResources(building.getDoor(),EResourceType.GOLD);
default :
return false;
}
}
Program: 56391
Project: 56391
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  short value=(short)(partitionsGrid.getPartitionAt((short)x,(short)y) + 1);
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  return landscapeGrid.getDebugColor(x,y);
}
Program: 56392
Project: 56392
Buggy source:
private final void checkLandmarks(ShortPoint2D startPos){
  short startX=startPos.getX();
  short startY=startPos.getY();
  if (grid.isBlocked(startX,startY))   return;
  short startPartition=grid.getPartitionAt(startPos.getX(),startPos.getY());
  for (  EDirection currDir : EDirection.values) {
    short currX=(short)(startX + currDir.gridDeltaX);
    short currY=(short)(startY + currDir.gridDeltaY);
    if (grid.isBlocked(currX,currY)) {
      if (needsRelabel(currX,currY,startPartition)) {
        System.out.println("String_Node_Str" + currX + "String_Node_Str"+ currY+ "String_Node_Str"+ startPartition);
        relabel(grid.getBlockedPartition(startX,startY),currX,currY,startPartition);
      }
    }
  }
}

Fixed version (ground truth):
private final void checkLandmarks(ShortPoint2D startPos){
  final short startX=startPos.getX();
  final short startY=startPos.getY();
  if (grid.isBlocked(startX,startY))   return;
  short startPartition=grid.getPartitionAt(startPos.getX(),startPos.getY());
  for (  EDirection currDir : EDirection.values) {
    short currX=(short)(startX + currDir.gridDeltaX);
    short currY=(short)(startY + currDir.gridDeltaY);
    if (grid.isBlocked(currX,currY)) {
      if (needsRelabel(currX,currY,startPartition)) {
        System.out.println("String_Node_Str" + currX + "String_Node_Str"+ currY+ "String_Node_Str"+ startPartition);
        relabel(grid.getBlockedPartition(startX,startY),currX,currY,startPartition);
      }
    }
  }
}
Program: 56395
Project: 56395
Buggy source:
public PartitionCalculatorAlgorithm(int minX,int minY,int width,int height,BitSet containing,boolean invertBitSet){
  this.minX=minX;
  this.minY=minY;
  this.width=width;
  this.height=height;
  this.containing=containing;
  this.invertBitSet=invertBitSet;
  this.partitionsGrid=new short[width * height];
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link PartitionCalculatorAlgorithm}. The given   {@link BitSet} defines the positions that need to be in the partitions and theones that mustn't.
 * @param minX The x offset of the  {@link BitSet}.
 * @param minY The y offset of the  {@link BitSet}.
 * @param width The width of the grid defined by the  {@link BitSet}.
 * @param height The height of the grid defined by the  {@link BitSet}.
 * @param containing The  {@link BitSet} defining the positions in the partitions and the ones not. <br>NOTE: The  {@link BitSet} must be indexed with x + y * width
 * @param invertBitSet If false: all positions returning TRUE are seen as in the partitions.<br> If true: all positions returning FALSE are seen as in the partitions.
 */
public PartitionCalculatorAlgorithm(int minX,int minY,int width,int height,BitSet containing,boolean invertBitSet){
  this.minX=minX;
  this.minY=minY;
  this.width=width;
  this.height=height;
  this.containing=containing;
  this.invertBitSet=invertBitSet;
  this.partitionsGrid=new short[width * height];
}
Program: 56396
Project: 56396
Buggy source:
protected Buffer getBuffer(int texture){
  for (int i=0; i < BUFFERS; i++) {
    if (drawBuffers[i].currentTexture == texture) {
      return drawBuffers[i];
    }
  }
  lastFreedBuffer++;
  if (lastFreedBuffer >= BUFFERS) {
    lastFreedBuffer=0;
  }
  Buffer buffer=drawBuffers[lastFreedBuffer];
  buffer.setForTexture(texture);
  return buffer;
}

Fixed version (ground truth):
public Buffer getBuffer(int texture){
  for (int i=0; i < BUFFERS; i++) {
    if (drawBuffers[i].currentTexture == texture) {
      return drawBuffers[i];
    }
  }
  lastFreedBuffer++;
  if (lastFreedBuffer >= BUFFERS) {
    lastFreedBuffer=0;
  }
  Buffer buffer=drawBuffers[lastFreedBuffer];
  buffer.setForTexture(texture);
  return buffer;
}
Program: 56397
Project: 56397
Buggy source:
private void drawWithConstructionMask(int x,int y,float maskState,Image unsafeimage,float color){
  if (!(unsafeimage instanceof SingleImage)) {
    return;
  }
  context.beginTileContext(x,y);
  SingleImage image=(SingleImage)unsafeimage;
  int tiles=6;
  float toplineBottom=(int)(maskState * image.getHeight()) / (float)image.getHeight();
  float toplineTop=Math.min(1,toplineBottom + .1f);
  float[] tris=new float[(tiles + 2) * 3 * 5];
  addPointToArray(tris,0,0,0,image);
  addPointToArray(tris,1,1,0,image);
  addPointToArray(tris,2,0,toplineBottom,image);
  addPointToArray(tris,3,1,0,image);
  addPointToArray(tris,4,1,toplineBottom,image);
  addPointToArray(tris,5,0,toplineBottom,image);
  for (int i=0; i < tiles; i++) {
    addPointToArray(tris,6 + i * 3,1.0f / tiles * i,toplineBottom,image);
    addPointToArray(tris,7 + i * 3,1.0f / tiles * (i + 1),toplineBottom,image);
    addPointToArray(tris,8 + i * 3,1.0f / tiles * (i + .5f),toplineTop,image);
  }
  GLDrawContext gl=context.getGl();
  gl.color(color,color,color,1);
  gl.drawTrianglesWithTexture(image.getTextureIndex(gl),tris);
  context.endTileContext();
}

Fixed version (ground truth):
private void drawWithConstructionMask(int x,int y,float maskState,Image unsafeimage,float color){
  if (!(unsafeimage instanceof SingleImage)) {
    return;
  }
  int height=context.getHeight(x,y);
  float viewX=context.getConverter().getViewX(x,y,height);
  float viewY=context.getConverter().getViewY(x,y,height);
  int iColor=Color.getABGR(color,color,color,1);
  SingleImage image=(SingleImage)unsafeimage;
  int tiles=6;
  float toplineBottom=1 - maskState;
  float toplineTop=Math.max(0,toplineBottom - .1f);
  image.drawTriangle(context.getGl(),buffer,viewX,viewY,0,1,1,1,0,toplineBottom,iColor);
  image.drawTriangle(context.getGl(),buffer,viewX,viewY,1,1,1,toplineBottom,0,toplineBottom,iColor);
  for (int i=0; i < tiles; i++) {
    image.drawTriangle(context.getGl(),buffer,viewX,viewY,1.0f / tiles * i,toplineBottom,1.0f / tiles * (i + 1),toplineBottom,1.0f / tiles * (i + .5f),toplineTop,iColor);
  }
}
Program: 56399
Project: 56399
Buggy source:
private void drawImage(IMovable movable,Image image){
  ShortPoint2D pos=movable.getPos();
  short x=pos.getX();
  short y=pos.getY();
  byte fogstatus=context.getVisibleStatus(x,y);
  if (fogstatus == 0) {
    return;
  }
  Color color=context.getPlayerColor(movable.getPlayer());
  float shade=MapObjectDrawer.getColor(fogstatus);
  float viewX;
  float viewY;
  if (movable.getAction() == EAction.WALKING) {
    int originx=x - movable.getDirection().getGridDeltaX();
    int originy=y - movable.getDirection().getGridDeltaY();
    viewX=betweenTilesX(originx,originy,x,y,movable.getMoveProgress());
    viewY=betweenTilesY;
  }
 else {
    int height=context.getHeight(x,y);
    viewX=context.getConverter().getViewX(x,y,height);
    viewY=context.getConverter().getViewY(x,y,height);
  }
  image.drawAt(context.getGl(),buffer,viewX,viewY,color,shade);
  if (movable.isSelected()) {
    drawSelectionMark(viewX,viewY,movable.getHealth());
  }
}

Fixed version (ground truth):
private void drawImage(IMovable movable,Image image){
  ShortPoint2D pos=movable.getPos();
  short x=pos.getX();
  short y=pos.getY();
  drawMovableAt(movable,image,x,y);
}
Program: 56400
Project: 56400
Buggy source:
protected void releaseRequestStacks(){
  for (  RequestStack curr : stacks) {
    curr.releaseRequests();
  }
  stacks=new LinkedList<RequestStack>();
}

Fixed version (ground truth):
protected void releaseRequestStacks(){
  if (stacks != null) {
    for (    RequestStack curr : stacks) {
      curr.releaseRequests();
    }
    stacks=new LinkedList<RequestStack>();
  }
}
Program: 56402
Project: 56402
Buggy source:
@Override public final void save() throws FileNotFoundException, IOException, InterruptedException {
  boolean pausing=NetworkTimer.isPausing();
  NetworkTimer.get().setPausing(true);
  try {
    Thread.sleep(30);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  MapList list=MapList.getDefaultList();
  list.saveMap(new UIState(0,new ShortPoint2D(0,0)),MainGrid.this);
  NetworkTimer.get().setPausing(pausing);
}

Fixed version (ground truth):
@Override public final void save() throws FileNotFoundException, IOException, InterruptedException {
  boolean pausing=NetworkTimer.isPausing();
  NetworkTimer.get().setPausing(true);
  try {
    Thread.sleep(100);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  MapList list=MapList.getDefaultList();
  list.saveMap(new UIState(0,new ShortPoint2D(0,0)),MainGrid.this);
  NetworkTimer.get().setPausing(pausing);
}
Program: 56403
Project: 56403
Buggy source:
@Override public final boolean setBuilding(ShortPoint2D position,Building newBuilding){
  if (MainGrid.this.isInBounds(position.getX(),position.getY())) {
    FreeMapArea area=new FreeMapArea(position,newBuilding.getBuildingType().getProtectedTiles());
    if (canConstructAt(area)) {
      setProtectedState(area,true);
      mapObjectsManager.addBuildingTo(position,newBuilding);
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public final boolean setBuilding(ShortPoint2D position,Building newBuilding){
  if (MainGrid.this.isInBounds(position.getX(),position.getY())) {
    FreeMapArea area=new FreeMapArea(position,newBuilding.getBuildingType().getProtectedTiles());
    if (canConstructAt(area)) {
      setProtectedState(area,true);
      mapObjectsManager.addBuildingTo(position,newBuilding);
      objectsGrid.setBuildingArea(area,newBuilding);
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}
Program: 56404
Project: 56404
Buggy source:
@Override public final void occupyArea(MapCircle toBeOccupied,IMapArea groundArea,byte player){
  List<ShortPoint2D> occupiedPositions=partitionsGrid.occupyArea(toBeOccupied,groundArea,player);
  bordersThread.checkPositions(occupiedPositions);
  landmarksCorrection.addLandmarkedPositions(occupiedPositions);
}

Fixed version (ground truth):
@Override public final void occupyArea(MapCircle toBeOccupied,IMapArea groundArea,byte player){
  List<ShortPoint2D> occupiedPositions=partitionsGrid.occupyArea(toBeOccupied,groundArea,player);
  for (  ShortPoint2D curr : occupiedPositions) {
    destroyBuildingOn(curr.getX(),curr.getY(),player);
  }
  bordersThread.checkPositions(occupiedPositions);
  landmarksCorrection.addLandmarkedPositions(occupiedPositions);
}
Program: 56405
Project: 56405
Buggy source:
@Override public final void removeBuildingAt(ShortPoint2D pos){
  IBuilding building=(IBuilding)objectsGrid.getMapObjectAt(pos.getX(),pos.getY(),EMapObjectType.BUILDING);
  mapObjectsManager.removeMapObjectType(pos.getX(),pos.getY(),EMapObjectType.BUILDING);
  FreeMapArea area=new FreeMapArea(pos,building.getBuildingType().getProtectedTiles());
  for (  ShortPoint2D curr : area) {
    short x=curr.getX();
    short y=curr.getY();
    if (isInBounds(x,y)) {
      flagsGrid.setBlockedAndProtected(x,y,false);
    }
  }
}

Fixed version (ground truth):
@Override public final void removeBuildingAt(ShortPoint2D pos){
  IBuilding building=(IBuilding)objectsGrid.getMapObjectAt(pos.getX(),pos.getY(),EMapObjectType.BUILDING);
  mapObjectsManager.removeMapObjectType(pos.getX(),pos.getY(),EMapObjectType.BUILDING);
  FreeMapArea area=new FreeMapArea(pos,building.getBuildingType().getProtectedTiles());
  objectsGrid.setBuildingArea(area,null);
  for (  ShortPoint2D curr : area) {
    short x=curr.getX();
    short y=curr.getY();
    if (isInBounds(x,y)) {
      flagsGrid.setBlockedAndProtected(x,y,false);
    }
  }
}
Program: 56406
Project: 56406
Buggy source:
public ObjectsGrid(short width,short height){
  this.width=width;
  this.height=height;
  this.objectsGrid=new AbstractHexMapObject[width * height];
}

Fixed version (ground truth):
public ObjectsGrid(short width,short height){
  this.width=width;
  this.height=height;
  this.objectsGrid=new AbstractHexMapObject[width * height];
  this.buildingsGrid=new Building[width * height];
}
Program: 56407
Project: 56407
Buggy source:
public final List<ShortPoint2D> freeOccupiedArea(MapCircle occupied,ShortPoint2D occupiersPosition){
  short partiton=getPartition(occupiersPosition);
  List<ShortPoint2D> totallyFreePositions=new ArrayList<ShortPoint2D>();
  for (  ShortPoint2D curr : occupied) {
    short x=curr.getX();
    short y=curr.getY();
    if (isInBounds(x,y) && getPartitionAt(x,y) == partiton) {
      final int idx=getIdx(x,y);
      towers[idx]--;
      if (towers[idx] <= 0) {
        totallyFreePositions.add(curr);
        towers[idx]=0;
      }
    }
  }
  return totallyFreePositions;
}

Fixed version (ground truth):
public final List<ShortPoint2D> freeOccupiedArea(MapCircle occupied,ShortPoint2D occupiersPosition){
  short partiton=getPartition(occupiersPosition);
  List<ShortPoint2D> totallyFreePositions=new LinkedList<ShortPoint2D>();
  for (  ShortPoint2D curr : occupied) {
    short x=curr.getX();
    short y=curr.getY();
    if (isInBounds(x,y) && getPartitionAt(x,y) == partiton) {
      final int idx=getIdx(x,y);
      towers[idx]--;
      if (towers[idx] <= 0) {
        totallyFreePositions.add(curr);
        towers[idx]=0;
      }
    }
  }
  return totallyFreePositions;
}
Program: 56408
Project: 56408
Buggy source:
public void draw(GLDrawContext context){
synchronized (update_syncobj) {
    if (!imageIsValid) {
      if (imageIndex < 0) {
        context.deleteTexture(imageIndex);
      }
      ShortBuffer data=ByteBuffer.allocateDirect(width * height * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
      for (int i=0; i < width * height; i++) {
        data.put((short)0x0001);
      }
      data.position(0);
      imageIndex=context.generateTexture(width,height,data);
      updatedLines.clear();
      imageIsValid=true;
    }
    if (!updatedLines.isEmpty()) {
      ShortBuffer currData=ByteBuffer.allocateDirect(width * 2).asShortBuffer();
      for (      Integer currLine : updatedLines) {
        currData.position(0);
        currData.put(buffer[currLine]);
        currData.position(0);
        context.updateTexture(imageIndex,0,currLine,width,1,currData);
      }
      updatedLines.clear();
    }
    update_syncobj.notifyAll();
  }
  context.color(1,1,1,1);
  context.drawQuadWithTexture(imageIndex,new float[]{0,0,0,0,0,width,0,0,1,0,(stride + 1) * width,height,0,1,1,stride * width,height,0,0,1});
  drawViewmark(context);
}

Fixed version (ground truth):
public void draw(GLDrawContext context){
synchronized (update_syncobj) {
    if (!imageIsValid) {
      if (imageIndex < 0) {
        context.deleteTexture(imageIndex);
      }
      ShortBuffer data=ByteBuffer.allocateDirect(width * height * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
      for (int i=0; i < width * height; i++) {
        data.put((short)0x0001);
      }
      data.position(0);
      imageIndex=context.generateTexture(width,height,data);
      updatedLines.clear();
      imageIsValid=true;
    }
    if (!updatedLines.isEmpty()) {
      ShortBuffer currData=ByteBuffer.allocateDirect(width * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
      for (      Integer currLine : updatedLines) {
        currData.position(0);
        currData.put(buffer[currLine]);
        currData.position(0);
        context.updateTexture(imageIndex,0,currLine,width,1,currData);
      }
      updatedLines.clear();
    }
    update_syncobj.notifyAll();
  }
  context.color(1,1,1,1);
  context.drawQuadWithTexture(imageIndex,new float[]{0,0,0,0,0,width,0,0,1,0,(stride + 1) * width,height,0,1,1,stride * width,height,0,0,1});
  drawViewmark(context);
}