nus-yam/ex-repair huggingface dataset:
Program: 164052
Project: 164052
Buggy source:
private boolean actInteract(HeroAction.Interact action){
  NPC npc=action.npc;
  if (Dungeon.level.adjacent(pos,npc.pos)) {
    ready();
    sprite.turnTo(pos,npc.pos);
    npc.interact();
    return false;
  }
 else {
    if (Level.fieldOfView[npc.pos] && getCloser(npc.pos)) {
      return true;
    }
 else {
      ready();
      return false;
    }
  }
}

Fixed version (ground truth):
private boolean actInteract(HeroAction.Interact action){
  NPC npc=action.npc;
  if (Dungeon.level.adjacent(pos,npc.pos)) {
    ready();
    sprite.turnTo(pos,npc.pos);
    return npc.interact();
  }
 else {
    if (Level.fieldOfView[npc.pos] && getCloser(npc.pos)) {
      return true;
    }
 else {
      ready();
      return false;
    }
  }
}
Program: 164054
Project: 164054
Buggy source:
@Override public void interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  Sample.INSTANCE.play(Assets.SND_GHOST);
  if (Quest.given) {
    if (Quest.weapon != null) {
      if (Quest.processed) {
        GameScene.show(new WndSadGhost(this,Quest.type));
      }
 else {
switch (Quest.type) {
case 1:
default :
          GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
        break;
case 2:
      GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
    break;
case 3:
  GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
break;
}
int newPos=-1;
for (int i=0; i < 10; i++) {
newPos=Dungeon.level.randomRespawnCell();
if (newPos != -1) {
break;
}
}
if (newPos != -1) {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
pos=newPos;
sprite.place(pos);
sprite.visible=Dungeon.visible[pos];
}
}
}
}
 else {
Mob questBoss;
String txt_quest;
switch (Quest.type) {
case 1:
default :
questBoss=new FetidRat();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
case 2:
questBoss=new GnollTrickster();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
case 3:
questBoss=new GreatCrab();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
}
questBoss.pos=Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) {
GameScene.add(questBoss);
GameScene.show(new WndQuest(this,txt_quest));
Quest.given=true;
Journal.add(Journal.Feature.GHOST);
}
}
}

Fixed version (ground truth):
@Override public boolean interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  Sample.INSTANCE.play(Assets.SND_GHOST);
  if (Quest.given) {
    if (Quest.weapon != null) {
      if (Quest.processed) {
        GameScene.show(new WndSadGhost(this,Quest.type));
      }
 else {
switch (Quest.type) {
case 1:
default :
          GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
        break;
case 2:
      GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
    break;
case 3:
  GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
break;
}
int newPos=-1;
for (int i=0; i < 10; i++) {
newPos=Dungeon.level.randomRespawnCell();
if (newPos != -1) {
break;
}
}
if (newPos != -1) {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
pos=newPos;
sprite.place(pos);
sprite.visible=Dungeon.visible[pos];
}
}
}
}
 else {
Mob questBoss;
String txt_quest;
switch (Quest.type) {
case 1:
default :
questBoss=new FetidRat();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
case 2:
questBoss=new GnollTrickster();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
case 3:
questBoss=new GreatCrab();
txt_quest=Messages.get(this,"String_Node_Str",Dungeon.hero.givenName());
break;
}
questBoss.pos=Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) {
GameScene.add(questBoss);
GameScene.show(new WndQuest(this,txt_quest));
Quest.given=true;
Journal.add(Journal.Feature.GHOST);
}
}
return false;
}
Program: 164055
Project: 164055
Buggy source:
@Override public void interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  if (Quest.given) {
    DwarfToken tokens=Dungeon.hero.belongings.getItem(DwarfToken.class);
    if (tokens != null && (tokens.quantity() >= 8 || (!Quest.alternative && tokens.quantity() >= 6))) {
      GameScene.show(new WndImp(this,tokens));
    }
 else {
      tell(Quest.alternative ? Messages.get(this,"String_Node_Str",Dungeon.hero.givenName()) : Messages.get(this,"String_Node_Str",Dungeon.hero.givenName()));
    }
  }
 else {
    tell(Quest.alternative ? Messages.get(this,"String_Node_Str") : Messages.get(this,"String_Node_Str"));
    Quest.given=true;
    Quest.completed=false;
    Journal.add(Journal.Feature.IMP);
  }
}

Fixed version (ground truth):
@Override public boolean interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  if (Quest.given) {
    DwarfToken tokens=Dungeon.hero.belongings.getItem(DwarfToken.class);
    if (tokens != null && (tokens.quantity() >= 8 || (!Quest.alternative && tokens.quantity() >= 6))) {
      GameScene.show(new WndImp(this,tokens));
    }
 else {
      tell(Quest.alternative ? Messages.get(this,"String_Node_Str",Dungeon.hero.givenName()) : Messages.get(this,"String_Node_Str",Dungeon.hero.givenName()));
    }
  }
 else {
    tell(Quest.alternative ? Messages.get(this,"String_Node_Str") : Messages.get(this,"String_Node_Str"));
    Quest.given=true;
    Quest.completed=false;
    Journal.add(Journal.Feature.IMP);
  }
  return false;
}
Program: 164056
Project: 164056
Buggy source:
@Override public void interact(){
  int curPos=pos;
  moveSprite(pos,Dungeon.hero.pos);
  move(Dungeon.hero.pos);
  Dungeon.hero.sprite.move(Dungeon.hero.pos,curPos);
  Dungeon.hero.move(curPos);
  Dungeon.hero.spend(1 / Dungeon.hero.speed());
  Dungeon.hero.busy();
}

Fixed version (ground truth):
@Override public boolean interact(){
  int curPos=pos;
  moveSprite(pos,Dungeon.hero.pos);
  move(Dungeon.hero.pos);
  Dungeon.hero.sprite.move(Dungeon.hero.pos,curPos);
  Dungeon.hero.move(curPos);
  Dungeon.hero.spend(1 / Dungeon.hero.speed());
  Dungeon.hero.busy();
  return true;
}
Program: 164057
Project: 164057
Buggy source:
abstract public void interact();

Fixed version (ground truth):
abstract public boolean interact();
Program: 164058
Project: 164058
Buggy source:
@Override public void interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  if (state == SLEEPING) {
    notice();
    yell(Messages.get(this,"String_Node_Str"));
    state=WANDERING;
  }
 else {
    yell(Messages.get(this,"String_Node_Str"));
  }
}

Fixed version (ground truth):
@Override public boolean interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  if (state == SLEEPING) {
    notice();
    yell(Messages.get(this,"String_Node_Str"));
    state=WANDERING;
  }
 else {
    yell(Messages.get(this,"String_Node_Str"));
  }
  return true;
}
Program: 164059
Project: 164059
Buggy source:
@Override public void interact(){
  yell(Messages.get(this,Random.element(LINE_KEYS)));
}

Fixed version (ground truth):
@Override public boolean interact(){
  yell(Messages.get(this,Random.element(LINE_KEYS)));
  return false;
}
Program: 164060
Project: 164060
Buggy source:
@Override public void interact(){
  sell();
}

Fixed version (ground truth):
@Override public boolean interact(){
  sell();
  return false;
}
Program: 164062
Project: 164062
Buggy source:
@Override public void interact(){
  if (!DriedRose.talkedTo) {
    DriedRose.talkedTo=true;
    GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
  }
 else {
    int curPos=pos;
    moveSprite(pos,Dungeon.hero.pos);
    move(Dungeon.hero.pos);
    Dungeon.hero.sprite.move(Dungeon.hero.pos,curPos);
    Dungeon.hero.move(curPos);
    Dungeon.hero.spend(1 / Dungeon.hero.speed());
    Dungeon.hero.busy();
  }
}

Fixed version (ground truth):
@Override public boolean interact(){
  if (!DriedRose.talkedTo) {
    DriedRose.talkedTo=true;
    GameScene.show(new WndQuest(this,Messages.get(this,"String_Node_Str")));
    return false;
  }
 else {
    int curPos=pos;
    moveSprite(pos,Dungeon.hero.pos);
    move(Dungeon.hero.pos);
    Dungeon.hero.sprite.move(Dungeon.hero.pos,curPos);
    Dungeon.hero.move(curPos);
    Dungeon.hero.spend(1 / Dungeon.hero.speed());
    Dungeon.hero.busy();
    return true;
  }
}
Program: 164064
Project: 164064
Buggy source:
public void resume(){
  curAction=lastAction;
  lastAction=null;
  damageInterrupt=false;
  act();
}

Fixed version (ground truth):
public void resume(){
  curAction=lastAction;
  lastAction=null;
  damageInterrupt=false;
  next();
}
Program: 164065
Project: 164065
Buggy source:
@Override public void draw(){
  super.draw();
  if (!updated.isEmpty()) {
    updateVertices();
    quads.limit(bufferLength * 16);
    if (buffer == null)     buffer=new Vertexbuffer(quads);
 else {
      if (fullUpdate) {
        buffer.updateVertices(quads);
        fullUpdate=false;
      }
 else {
        buffer.updateVertices(quads,topLeftUpdating * 16,bottomRightUpdating * 16);
      }
    }
    topLeftUpdating=0;
    updating.setEmpty();
  }
  Camera c=Camera.main;
  if (camX == null || camX != (int)c.scroll.x / 16 || camY != (int)c.scroll.y / 16 || camW != (int)Math.ceil(c.width / cellW) || camH != (int)Math.ceil(c.height / cellH)) {
    camX=(int)c.scroll.x / 16;
    camY=(int)c.scroll.y / 16;
    camW=(int)Math.ceil(c.width / cellW);
    camH=(int)Math.ceil(c.height / cellH);
    if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)     return;
    topLeft=Math.max(camX,0) + Math.max(camY * mapWidth,0);
    while (bufferPositions[topLeft] == -1)     topLeft++;
    bottomRight=Math.min(camX + camW,mapWidth - 1) + Math.min((camY + camH) * mapWidth,(mapHeight - 1) * mapWidth);
    while (bufferPositions[bottomRight] == -1)     bottomRight--;
    length=bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
  }
  if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)   return;
  NoosaScript script=NoosaScriptNoLighting.get();
  texture.bind();
  script.uModel.valueM4(matrix);
  script.camera(camera);
  script.drawQuadSet(buffer,length,bufferPositions[topLeft]);
}

Fixed version (ground truth):
@Override public void draw(){
  super.draw();
  if (!updated.isEmpty()) {
    updateVertices();
    quads.limit(bufferLength * 16);
    if (buffer == null)     buffer=new Vertexbuffer(quads);
 else {
      if (fullUpdate) {
        buffer.updateVertices(quads);
        fullUpdate=false;
      }
 else {
        buffer.updateVertices(quads,topLeftUpdating * 16,bottomRightUpdating * 16);
      }
    }
    topLeftUpdating=0;
    updating.setEmpty();
  }
  Camera c=Camera.main;
  if (camX == null || camX != (int)c.scroll.x / 16 || camY != (int)c.scroll.y / 16 || camW != (int)Math.ceil(c.width / cellW) || camH != (int)Math.ceil(c.height / cellH)) {
    camX=(int)c.scroll.x / 16;
    camY=(int)c.scroll.y / 16;
    camW=(int)Math.ceil(c.width / cellW);
    camH=(int)Math.ceil(c.height / cellH);
    if (camX >= mapWidth || camY >= mapHeight || camW + camW <= 0 || camH + camH <= 0)     return;
    topLeft=Math.max(camX,0) + Math.max(camY * mapWidth,0);
    while (bufferPositions[topLeft] == -1)     topLeft++;
    bottomRight=Math.min(camX + camW,mapWidth - 1) + Math.min((camY + camH) * mapWidth,(mapHeight - 1) * mapWidth);
    while (bufferPositions[bottomRight] == -1)     bottomRight--;
    length=bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
  }
  if (camX >= mapWidth || camY >= mapHeight || camW + camW <= 0 || camH + camH <= 0)   return;
  NoosaScript script=NoosaScriptNoLighting.get();
  texture.bind();
  script.uModel.valueM4(matrix);
  script.camera(camera);
  script.drawQuadSet(buffer,length,bufferPositions[topLeft]);
}
Program: 164066
Project: 164066
Buggy source:
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.HIGH_GRASS);
  fill(level,room,2,Terrain.GRASS);
  room.entrance().set(Room.Door.Type.REGULAR);
  if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
    if (Random.Int(2) == 0) {
      level.plant(new Sungrass.Seed(),level.pointToCell(room.random()));
    }
  }
 else {
    int bushes=Random.Int(3);
    if (bushes == 0) {
      level.plant(new Sungrass.Seed(),level.pointToCell(room.random()));
    }
 else     if (bushes == 1) {
      level.plant(new BlandfruitBush.Seed(),level.pointToCell(room.random()));
    }
 else     if (Random.Int(5) == 0) {
      level.plant(new Sungrass.Seed(),level.pointToCell(room.random()));
      level.plant(new BlandfruitBush.Seed(),level.pointToCell(room.random()));
    }
  }
  Foliage light=(Foliage)level.blobs.get(Foliage.class);
  if (light == null) {
    light=new Foliage();
  }
  for (int i=room.top + 1; i < room.bottom; i++) {
    for (int j=room.left + 1; j < room.right; j++) {
      light.seed(level,j + level.width() * i,1);
    }
  }
  level.blobs.put(Foliage.class,light);
}

Fixed version (ground truth):
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.HIGH_GRASS);
  fill(level,room,2,Terrain.GRASS);
  room.entrance().set(Room.Door.Type.REGULAR);
  if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
    if (Random.Int(2) == 0) {
      level.plant(new Sungrass.Seed(),level.pointToCell(room.random()));
    }
  }
 else {
    int bushes=Random.Int(3);
    if (bushes == 0) {
      level.plant(new Sungrass.Seed(),level.pointToCell(room.random()));
    }
 else     if (bushes == 1) {
      level.plant(new BlandfruitBush.Seed(),level.pointToCell(room.random()));
    }
 else     if (Random.Int(5) == 0) {
      int plant1, plant2;
      plant1=level.pointToCell(room.random());
      level.plant(new Sungrass.Seed(),plant1);
      do {
        plant2=level.pointToCell(room.random());
      }
 while (plant2 == plant1);
      level.plant(new BlandfruitBush.Seed(),plant2);
    }
  }
  Foliage light=(Foliage)level.blobs.get(Foliage.class);
  if (light == null) {
    light=new Foliage();
  }
  for (int i=room.top + 1; i < room.bottom; i++) {
    for (int j=room.left + 1; j < room.right; j++) {
      light.seed(level,j + level.width() * i,1);
    }
  }
  level.blobs.put(Foliage.class,light);
}
Program: 164067
Project: 164067
Buggy source:
protected void evolve(){
  boolean[] blocking=Level.solid;
  int cell;
  for (int i=area.top - 1; i <= area.bottom; i++) {
    for (int j=area.left - 1; j <= area.right; j++) {
      cell=j + i * Dungeon.level.width();
      if (!blocking[cell]) {
        int count=1;
        int sum=cur[cell];
        if (!blocking[cell - 1]) {
          sum+=cur[cell - 1];
          count++;
        }
        if (!blocking[cell + 1]) {
          sum+=cur[cell + 1];
          count++;
        }
        if (!blocking[cell - Dungeon.level.width()]) {
          sum+=cur[cell - Dungeon.level.width()];
          count++;
        }
        if (!blocking[cell + Dungeon.level.width()]) {
          sum+=cur[cell + Dungeon.level.width()];
          count++;
        }
        int value=sum >= count ? (sum / count) - 1 : 0;
        off[cell]=value;
        if (value > 0) {
          if (i < area.top)           area.top=i;
 else           if (i >= area.bottom)           area.bottom=i + 1;
          if (j < area.left)           area.left=j;
 else           if (j >= area.right)           area.right=j + 1;
        }
        volume+=value;
      }
 else {
        off[cell]=0;
      }
    }
  }
}

Fixed version (ground truth):
protected void evolve(){
  boolean[] blocking=Level.solid;
  int cell;
  for (int i=area.top - 1; i <= area.bottom; i++) {
    for (int j=area.left - 1; j <= area.right; j++) {
      cell=j + i * Dungeon.level.width();
      if (!blocking[cell]) {
        int count=1;
        int sum=cur[cell];
        if (j > area.left && !blocking[cell - 1]) {
          sum+=cur[cell - 1];
          count++;
        }
        if (j < area.right && !blocking[cell + 1]) {
          sum+=cur[cell + 1];
          count++;
        }
        if (i > area.top && !blocking[cell - Dungeon.level.width()]) {
          sum+=cur[cell - Dungeon.level.width()];
          count++;
        }
        if (i < area.bottom && !blocking[cell + Dungeon.level.width()]) {
          sum+=cur[cell + Dungeon.level.width()];
          count++;
        }
        int value=sum >= count ? (sum / count) - 1 : 0;
        off[cell]=value;
        if (value > 0) {
          if (i < area.top)           area.top=i;
 else           if (i >= area.bottom)           area.bottom=i + 1;
          if (j < area.left)           area.left=j;
 else           if (j >= area.right)           area.right=j + 1;
        }
        volume+=value;
      }
 else {
        off[cell]=0;
      }
    }
  }
}
Program: 164068
Project: 164068
Buggy source:
@Override public int proc(Armor armor,Char attacker,Char defender,int damage){
  if (Random.Int(20) == 0) {
    ArrayList<Integer> spawnPoints=new ArrayList<>();
    for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
      int p=defender.pos + PathFinder.NEIGHBOURS8[i];
      if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
        spawnPoints.add(p);
      }
    }
    if (spawnPoints.size() > 0) {
      Mob m=null;
      if (Random.Int(2) == 0 && defender instanceof Hero) {
        m=new MirrorImage();
        ((MirrorImage)m).duplicate((Hero)defender);
      }
 else {
        if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS)) {
          m=Bestiary.mutable(Dungeon.depth % 5 == 0 ? Dungeon.depth - 1 : Dungeon.depth);
        }
 else {
          try {
            m=(Mob)defender.getClass().newInstance();
            Bundle store=new Bundle();
            defender.storeInBundle(store);
            m.restoreFromBundle(store);
            m.HP=m.HT;
          }
 catch (          Exception e) {
            ShatteredPixelDungeon.reportException(e);
            m=null;
          }
        }
      }
      if (m != null) {
        GameScene.add(m);
        ScrollOfTeleportation.appear(m,Random.element(spawnPoints));
      }
    }
  }
  return damage;
}

Fixed version (ground truth):
@Override public int proc(Armor armor,Char attacker,Char defender,int damage){
  if (Random.Int(20) == 0) {
    ArrayList<Integer> spawnPoints=new ArrayList<>();
    for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
      int p=defender.pos + PathFinder.NEIGHBOURS8[i];
      if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
        spawnPoints.add(p);
      }
    }
    if (spawnPoints.size() > 0) {
      Mob m=null;
      if (Random.Int(2) == 0 && defender instanceof Hero) {
        m=new MirrorImage();
        ((MirrorImage)m).duplicate((Hero)defender);
      }
 else {
        if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS)) {
          m=Bestiary.mutable(Dungeon.depth % 5 == 0 ? Dungeon.depth - 1 : Dungeon.depth);
        }
 else {
          try {
            m=(Mob)attacker.getClass().newInstance();
            Bundle store=new Bundle();
            attacker.storeInBundle(store);
            m.restoreFromBundle(store);
            m.HP=m.HT;
          }
 catch (          Exception e) {
            ShatteredPixelDungeon.reportException(e);
            m=null;
          }
        }
      }
      if (m != null) {
        GameScene.add(m);
        ScrollOfTeleportation.appear(m,Random.element(spawnPoints));
      }
    }
  }
  return damage;
}
Program: 164070
Project: 164070
Buggy source:
protected void evolve(){
  boolean[] blocking=Level.solid;
  int cell;
  for (int i=area.top - 1; i <= area.bottom; i++) {
    for (int j=area.left - 1; j <= area.right; j++) {
      cell=j + i * Dungeon.level.width();
      if (!blocking[cell]) {
        int count=1;
        int sum=cur[cell];
        if (j > area.left && !blocking[cell - 1]) {
          sum+=cur[cell - 1];
          count++;
        }
        if (j < area.right && !blocking[cell + 1]) {
          sum+=cur[cell + 1];
          count++;
        }
        if (i > area.top && !blocking[cell - Dungeon.level.width()]) {
          sum+=cur[cell - Dungeon.level.width()];
          count++;
        }
        if (i < area.bottom && !blocking[cell + Dungeon.level.width()]) {
          sum+=cur[cell + Dungeon.level.width()];
          count++;
        }
        int value=sum >= count ? (sum / count) - 1 : 0;
        off[cell]=value;
        if (value > 0) {
          if (i < area.top)           area.top=i;
 else           if (i >= area.bottom)           area.bottom=i + 1;
          if (j < area.left)           area.left=j;
 else           if (j >= area.right)           area.right=j + 1;
        }
        volume+=value;
      }
 else {
        off[cell]=0;
      }
    }
  }
}

Fixed version (ground truth):
protected void evolve(){
  boolean[] blocking=Level.solid;
  int cell;
  for (int i=area.top - 1; i <= area.bottom; i++) {
    for (int j=area.left - 1; j <= area.right; j++) {
      cell=j + i * Dungeon.level.width();
      if (Dungeon.level.insideMap(cell)) {
        if (!blocking[cell]) {
          int count=1;
          int sum=cur[cell];
          if (j > area.left && !blocking[cell - 1]) {
            sum+=cur[cell - 1];
            count++;
          }
          if (j < area.right && !blocking[cell + 1]) {
            sum+=cur[cell + 1];
            count++;
          }
          if (i > area.top && !blocking[cell - Dungeon.level.width()]) {
            sum+=cur[cell - Dungeon.level.width()];
            count++;
          }
          if (i < area.bottom && !blocking[cell + Dungeon.level.width()]) {
            sum+=cur[cell + Dungeon.level.width()];
            count++;
          }
          int value=sum >= count ? (sum / count) - 1 : 0;
          off[cell]=value;
          if (value > 0) {
            if (i < area.top)             area.top=i;
 else             if (i >= area.bottom)             area.bottom=i + 1;
            if (j < area.left)             area.left=j;
 else             if (j >= area.right)             area.right=j + 1;
          }
          volume+=value;
        }
 else {
          off[cell]=0;
        }
      }
    }
  }
}
Program: 164071
Project: 164071
Buggy source:
public boolean insideMap(int tile){
  return !((tile < 0 || tile >= length()) || (tile < width() || tile >= length() - width()) || (tile % width() == 0 || tile % width() == width() - 1));
}

Fixed version (ground truth):
public boolean insideMap(int tile){
  return !((tile < width || tile >= length - width) || (tile % width == 0 || tile % width == width - 1));
}
Program: 164072
Project: 164072
Buggy source:
@Override public void draw(){
  super.draw();
  if (!updated.isEmpty()) {
    updateVertices();
    quads.limit(bufferLength * 16);
    if (buffer == null)     buffer=new Vertexbuffer(quads);
 else {
      if (fullUpdate) {
        buffer.updateVertices(quads);
        fullUpdate=false;
      }
 else {
        buffer.updateVertices(quads,topLeftUpdating * 16,bottomRightUpdating * 16);
      }
    }
    topLeftUpdating=0;
    updating.setEmpty();
  }
  Camera c=Camera.main;
  if (camX == null || camX != (int)c.scroll.x / 16 || camY != (int)c.scroll.y / 16 || camW != (int)Math.ceil(c.width / cellW) || camH != (int)Math.ceil(c.height / cellH)) {
    camX=(int)c.scroll.x / 16;
    camY=(int)c.scroll.y / 16;
    camW=(int)Math.ceil(c.width / cellW);
    camH=(int)Math.ceil(c.height / cellH);
    if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)     return;
    topLeft=Math.max(camX,0) + Math.max(camY * mapWidth,0);
    while (bufferPositions[topLeft] == -1)     topLeft++;
    bottomRight=Math.min(camX + camW,mapWidth - 1) + Math.min((camY + camH) * mapWidth,mapHeight * (mapWidth - 1));
    while (bufferPositions[bottomRight] == -1)     bottomRight--;
    length=bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
  }
  if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)   return;
  NoosaScript script=NoosaScriptNoLighting.get();
  texture.bind();
  script.uModel.valueM4(matrix);
  script.camera(camera);
  script.drawQuadSet(buffer,length,bufferPositions[topLeft]);
}

Fixed version (ground truth):
@Override public void draw(){
  super.draw();
  if (!updated.isEmpty()) {
    updateVertices();
    quads.limit(bufferLength * 16);
    if (buffer == null)     buffer=new Vertexbuffer(quads);
 else {
      if (fullUpdate) {
        buffer.updateVertices(quads);
        fullUpdate=false;
      }
 else {
        buffer.updateVertices(quads,topLeftUpdating * 16,bottomRightUpdating * 16);
      }
    }
    topLeftUpdating=0;
    updating.setEmpty();
  }
  Camera c=Camera.main;
  if (camX == null || camX != (int)c.scroll.x / 16 || camY != (int)c.scroll.y / 16 || camW != (int)Math.ceil(c.width / cellW) || camH != (int)Math.ceil(c.height / cellH)) {
    camX=(int)c.scroll.x / 16;
    camY=(int)c.scroll.y / 16;
    camW=(int)Math.ceil(c.width / cellW);
    camH=(int)Math.ceil(c.height / cellH);
    if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)     return;
    topLeft=Math.max(camX,0) + Math.max(camY * mapWidth,0);
    while (bufferPositions[topLeft] == -1)     topLeft++;
    bottomRight=Math.min(camX + camW,mapWidth - 1) + Math.min((camY + camH) * mapWidth,(mapHeight - 1) * mapWidth);
    while (bufferPositions[bottomRight] == -1)     bottomRight--;
    length=bufferPositions[bottomRight] - bufferPositions[topLeft] + 1;
  }
  if (camX > mapWidth || camY > mapHeight || camW + camW < 0 || camH + camH < 0)   return;
  NoosaScript script=NoosaScriptNoLighting.get();
  texture.bind();
  script.uModel.valueM4(matrix);
  script.camera(camera);
  script.drawQuadSet(buffer,length,bufferPositions[topLeft]);
}
Program: 164073
Project: 164073
Buggy source:
@Override public void cast(Hero user,int dst){
  throwEquiped=isEquipped(user);
  if (throwEquiped)   Dungeon.quickslot.convertToPlaceholder(this);
  super.cast(user,dst);
}

Fixed version (ground truth):
@Override public void cast(Hero user,int dst){
  throwEquiped=isEquipped(user) && !cursed;
  if (throwEquiped)   Dungeon.quickslot.convertToPlaceholder(this);
  super.cast(user,dst);
}
Program: 164074
Project: 164074
Buggy source:
public Gizmo add(Gizmo g){
  if (g.parent == this) {
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  for (int i=0; i < length; i++) {
    if (members.get(i) == null) {
      members.set(i,g);
      g.parent=this;
      return g;
    }
  }
  members.add(g);
  g.parent=this;
  length++;
  return g;
}

Fixed version (ground truth):
public synchronized Gizmo add(Gizmo g){
  if (g.parent == this) {
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  for (int i=0; i < length; i++) {
    if (members.get(i) == null) {
      members.set(i,g);
      g.parent=this;
      return g;
    }
  }
  members.add(g);
  g.parent=this;
  length++;
  return g;
}
Program: 164075
Project: 164075
Buggy source:
public Gizmo erase(Gizmo g){
  int index=members.indexOf(g);
  if (index != -1) {
    members.set(index,null);
    g.parent=null;
    return g;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo erase(Gizmo g){
  int index=members.indexOf(g);
  if (index != -1) {
    members.set(index,null);
    g.parent=null;
    return g;
  }
 else {
    return null;
  }
}
Program: 164076
Project: 164076
Buggy source:
public Gizmo bringToFront(Gizmo g){
  if (members.contains(g)) {
    members.remove(g);
    members.add(g);
    return g;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo bringToFront(Gizmo g){
  if (members.contains(g)) {
    members.remove(g);
    members.add(g);
    return g;
  }
 else {
    return null;
  }
}
Program: 164077
Project: 164077
Buggy source:
public Gizmo addToBack(Gizmo g){
  if (g.parent == this) {
    sendToBack(g);
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  if (members.get(0) == null) {
    members.set(0,g);
    g.parent=this;
    return g;
  }
  members.add(0,g);
  g.parent=this;
  length++;
  return g;
}

Fixed version (ground truth):
public synchronized Gizmo addToBack(Gizmo g){
  if (g.parent == this) {
    sendToBack(g);
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  if (members.get(0) == null) {
    members.set(0,g);
    g.parent=this;
    return g;
  }
  members.add(0,g);
  g.parent=this;
  length++;
  return g;
}
Program: 164078
Project: 164078
Buggy source:
public Gizmo addToFront(Gizmo g){
  if (g.parent == this) {
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  for (int i=length - 1; i >= 0; i--) {
    if (members.get(i) == null) {
      if (i == 0 || members.get(i - 1) != null) {
        members.set(i,g);
        g.parent=this;
        return g;
      }
    }
 else {
      break;
    }
  }
  members.add(g);
  g.parent=this;
  length++;
  return g;
}

Fixed version (ground truth):
public synchronized Gizmo addToFront(Gizmo g){
  if (g.parent == this) {
    return g;
  }
  if (g.parent != null) {
    g.parent.remove(g);
  }
  for (int i=length - 1; i >= 0; i--) {
    if (members.get(i) == null) {
      if (i == 0 || members.get(i - 1) != null) {
        members.set(i,g);
        g.parent=this;
        return g;
      }
    }
 else {
      break;
    }
  }
  members.add(g);
  g.parent=this;
  length++;
  return g;
}
Program: 164079
Project: 164079
Buggy source:
public Gizmo replace(Gizmo oldOne,Gizmo newOne){
  int index=members.indexOf(oldOne);
  if (index != -1) {
    members.set(index,newOne);
    newOne.parent=this;
    oldOne.parent=null;
    return newOne;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo replace(Gizmo oldOne,Gizmo newOne){
  int index=members.indexOf(oldOne);
  if (index != -1) {
    members.set(index,newOne);
    newOne.parent=this;
    oldOne.parent=null;
    return newOne;
  }
 else {
    return null;
  }
}
Program: 164080
Project: 164080
Buggy source:
public void clear(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null) {
      g.parent=null;
    }
  }
  members.clear();
  length=0;
}

Fixed version (ground truth):
public synchronized void clear(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null) {
      g.parent=null;
    }
  }
  members.clear();
  length=0;
}
Program: 164081
Project: 164081
Buggy source:
@Override public void destroy(){
  super.destroy();
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null) {
      g.destroy();
    }
  }
  members.clear();
  members=null;
  length=0;
}

Fixed version (ground truth):
@Override public synchronized void destroy(){
  super.destroy();
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null) {
      g.destroy();
    }
  }
  members.clear();
  members=null;
  length=0;
}
Program: 164082
Project: 164082
Buggy source:
@Override public void update(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.active && !(freezeEmitters && Game.timeTotal > 1f && g instanceof Emitter)) {
      g.update();
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void update(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.active && !(freezeEmitters && Game.timeTotal > 1f && g instanceof Emitter)) {
      g.update();
    }
  }
}
Program: 164083
Project: 164083
Buggy source:
public Gizmo getFirstAvailable(Class<? extends Gizmo> c){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && !g.exists && ((c == null) || g.getClass() == c)) {
      return g;
    }
  }
  return null;
}

Fixed version (ground truth):
public synchronized Gizmo getFirstAvailable(Class<? extends Gizmo> c){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && !g.exists && ((c == null) || g.getClass() == c)) {
      return g;
    }
  }
  return null;
}
Program: 164084
Project: 164084
Buggy source:
public Gizmo sendToBack(Gizmo g){
  if (members.contains(g)) {
    members.remove(g);
    members.add(0,g);
    return g;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo sendToBack(Gizmo g){
  if (members.contains(g)) {
    members.remove(g);
    members.add(0,g);
    return g;
  }
 else {
    return null;
  }
}
Program: 164085
Project: 164085
Buggy source:
@Override public void draw(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.isVisible()) {
      g.draw();
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void draw(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.isVisible()) {
      g.draw();
    }
  }
}
Program: 164086
Project: 164086
Buggy source:
public int countLiving(){
  int count=0;
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.alive) {
      count++;
    }
  }
  return count;
}

Fixed version (ground truth):
public synchronized int countLiving(){
  int count=0;
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists && g.alive) {
      count++;
    }
  }
  return count;
}
Program: 164087
Project: 164087
Buggy source:
@Override public void kill(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists) {
      g.kill();
    }
  }
  super.kill();
}

Fixed version (ground truth):
@Override public synchronized void kill(){
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && g.exists) {
      g.kill();
    }
  }
  super.kill();
}
Program: 164088
Project: 164088
Buggy source:
public Gizmo remove(Gizmo g){
  if (members.remove(g)) {
    length--;
    g.parent=null;
    return g;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo remove(Gizmo g){
  if (members.remove(g)) {
    length--;
    g.parent=null;
    return g;
  }
 else {
    return null;
  }
}
Program: 164089
Project: 164089
Buggy source:
public Gizmo random(){
  if (length > 0) {
    return members.get((int)(Math.random() * length));
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public synchronized Gizmo random(){
  if (length > 0) {
    return members.get((int)(Math.random() * length));
  }
 else {
    return null;
  }
}
Program: 164090
Project: 164090
Buggy source:
public Gizmo recycle(Class<? extends Gizmo> c){
  Gizmo g=getFirstAvailable(c);
  if (g != null) {
    return g;
  }
 else   if (c == null) {
    return null;
  }
 else {
    try {
      return add(c.newInstance());
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  return null;
}

Fixed version (ground truth):
public synchronized Gizmo recycle(Class<? extends Gizmo> c){
  Gizmo g=getFirstAvailable(c);
  if (g != null) {
    return g;
  }
 else   if (c == null) {
    return null;
  }
 else {
    try {
      return add(c.newInstance());
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  return null;
}
Program: 164091
Project: 164091
Buggy source:
public int countDead(){
  int count=0;
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && !g.alive) {
      count++;
    }
  }
  return count;
}

Fixed version (ground truth):
public synchronized int countDead(){
  int count=0;
  for (int i=0; i < length; i++) {
    Gizmo g=members.get(i);
    if (g != null && !g.alive) {
      count++;
    }
  }
  return count;
}
Program: 164092
Project: 164092
Buggy source:
public int indexOf(Gizmo g){
  return members.indexOf(g);
}

Fixed version (ground truth):
public synchronized int indexOf(Gizmo g){
  return members.indexOf(g);
}
Program: 164093
Project: 164093
Buggy source:
@Override public void draw(){
  super.draw();
  if (dirty) {
    verticesBuffer.position(0);
    verticesBuffer.put(vertices);
    if (buffer == null)     buffer=new Vertexbuffer(verticesBuffer);
 else     buffer.updateVertices(verticesBuffer);
    dirty=false;
  }
  NoosaScript script=NoosaScript.get();
  texture.bind();
  script.camera(camera());
  script.uModel.valueM4(matrix);
  script.lighting(rm,gm,bm,am,ra,ga,ba,aa);
  script.drawQuad(buffer);
}

Fixed version (ground truth):
@Override public void draw(){
  if (texture == null)   return;
  super.draw();
  if (dirty) {
    verticesBuffer.position(0);
    verticesBuffer.put(vertices);
    if (buffer == null)     buffer=new Vertexbuffer(verticesBuffer);
 else     buffer.updateVertices(verticesBuffer);
    dirty=false;
  }
  NoosaScript script=NoosaScript.get();
  texture.bind();
  script.camera(camera());
  script.uModel.valueM4(matrix);
  script.lighting(rm,gm,bm,am,ra,ga,ba,aa);
  script.drawQuad(buffer);
}
Program: 164094
Project: 164094
Buggy source:
public static void setMapSize(int width,int height){
  int size=width * height;
  PathFinder.size=size;
  distance=new int[size];
  goals=new boolean[size];
  queue=new int[size];
  maxVal=new int[size];
  Arrays.fill(maxVal,Integer.MAX_VALUE);
  dir=new int[]{-1,+1,-width,+width,-width - 1,-width + 1,+width - 1,+width + 1};
  NEIGHBOURS4=new int[]{-width,-1,+1,+width};
  NEIGHBOURS8=new int[]{-width - 1,-width,-width + 1,-1,+1,+width - 1,+width,+width + 1};
  NEIGHBOURS9=new int[]{-width - 1,-width,-width + 1,-1,0,+1,+width - 1,+width,+width + 1};
}

Fixed version (ground truth):
public static void setMapSize(int width,int height){
  int size=width * height;
  PathFinder.size=size;
  distance=new int[size];
  goals=new boolean[size];
  queue=new int[size];
  maxVal=new int[size];
  Arrays.fill(maxVal,Integer.MAX_VALUE);
  dir=new int[]{-1,+1,-width,+width,-width - 1,-width + 1,+width - 1,+width + 1};
  NEIGHBOURS4=new int[]{-width,-1,+1,+width};
  NEIGHBOURS8=new int[]{-width - 1,-width,-width + 1,-1,+1,+width - 1,+width,+width + 1};
  NEIGHBOURS9=new int[]{-width - 1,-width,-width + 1,-1,0,+1,+width - 1,+width,+width + 1};
  CIRCLE=new int[]{-width - 1,-width,-width + 1,+1,+width + 1,+width,+width - 1,-1};
}
Program: 164095
Project: 164095
Buggy source:
private void spreadFlames(int cell,float strength){
  if (strength >= 0 && Level.passable[cell]) {
    affectedCells.add(cell);
    if (strength >= 1.5f) {
      visualCells.remove(cell);
      spreadFlames(cell + PathFinder.NEIGHBOURS8[left(direction)],strength - 1.5f);
      spreadFlames(cell + PathFinder.NEIGHBOURS8[direction],strength - 1.5f);
      spreadFlames(cell + PathFinder.NEIGHBOURS8[right(direction)],strength - 1.5f);
    }
 else {
      visualCells.add(cell);
    }
  }
 else   if (!Level.passable[cell])   visualCells.add(cell);
}

Fixed version (ground truth):
private void spreadFlames(int cell,float strength){
  if (strength >= 0 && Level.passable[cell]) {
    affectedCells.add(cell);
    if (strength >= 1.5f) {
      visualCells.remove(cell);
      spreadFlames(cell + PathFinder.CIRCLE[left(direction)],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE[direction],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE[right(direction)],strength - 1.5f);
    }
 else {
      visualCells.add(cell);
    }
  }
 else   if (!Level.passable[cell])   visualCells.add(cell);
}
Program: 164096
Project: 164096
Buggy source:
@Override protected void fx(Ballistica bolt,Callback callback){
  affectedCells=new HashSet<>();
  visualCells=new HashSet<>();
  int maxDist=(int)(4 * Math.pow(1.5,(chargesPerCast() - 1)));
  int dist=Math.min(bolt.dist,maxDist);
  for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
    if (bolt.sourcePos + PathFinder.NEIGHBOURS8[i] == bolt.path.get(1)) {
      direction=i;
      break;
    }
  }
  float strength=maxDist;
  for (  int c : bolt.subPath(1,dist)) {
    strength--;
    affectedCells.add(c);
    if (strength > 1) {
      spreadFlames(c + PathFinder.NEIGHBOURS8[left(direction)],strength - 1);
      spreadFlames(c + PathFinder.NEIGHBOURS8[direction],strength - 1);
      spreadFlames(c + PathFinder.NEIGHBOURS8[right(direction)],strength - 1);
    }
 else {
      visualCells.add(c);
    }
  }
  visualCells.remove(bolt.path.get(dist));
  for (  int cell : visualCells) {
    MagicMissile.fire(curUser.sprite.parent,bolt.sourcePos,cell,null);
  }
  MagicMissile.fire(curUser.sprite.parent,bolt.sourcePos,bolt.path.get(dist),callback);
  Sample.INSTANCE.play(Assets.SND_ZAP);
}

Fixed version (ground truth):
@Override protected void fx(Ballistica bolt,Callback callback){
  affectedCells=new HashSet<>();
  visualCells=new HashSet<>();
  int maxDist=(int)(4 * Math.pow(1.5,(chargesPerCast() - 1)));
  int dist=Math.min(bolt.dist,maxDist);
  for (int i=0; i < PathFinder.CIRCLE.length; i++) {
    if (bolt.sourcePos + PathFinder.CIRCLE[i] == bolt.path.get(1)) {
      direction=i;
      break;
    }
  }
  float strength=maxDist;
  for (  int c : bolt.subPath(1,dist)) {
    strength--;
    affectedCells.add(c);
    if (strength > 1) {
      spreadFlames(c + PathFinder.CIRCLE[left(direction)],strength - 1);
      spreadFlames(c + PathFinder.CIRCLE[direction],strength - 1);
      spreadFlames(c + PathFinder.CIRCLE[right(direction)],strength - 1);
    }
 else {
      visualCells.add(c);
    }
  }
  visualCells.remove(bolt.path.get(dist));
  for (  int cell : visualCells) {
    MagicMissile.fire(curUser.sprite.parent,bolt.sourcePos,cell,null);
  }
  MagicMissile.fire(curUser.sprite.parent,bolt.sourcePos,bolt.path.get(dist),callback);
  Sample.INSTANCE.play(Assets.SND_ZAP);
}
Program: 164097
Project: 164097
Buggy source:
@Override protected void onZap(Ballistica bolt){
  for (  int cell : affectedCells) {
    GameScene.add(Blob.seed(cell,1 + chargesPerCast(),Fire.class));
    Char ch=Actor.findChar(cell);
    if (ch != null) {
      int damage=damageRoll();
      ch.damage(damage,this);
      Buff.affect(ch,Burning.class).reignite(ch);
switch (chargesPerCast()) {
case 1:
        break;
case 2:
      Buff.affect(ch,Cripple.class,4f);
    break;
case 3:
  Buff.affect(ch,Paralysis.class,4f);
break;
}
}
}
}

Fixed version (ground truth):
@Override protected void onZap(Ballistica bolt){
  for (  int cell : affectedCells) {
    if (Level.flamable[cell] || !Dungeon.level.adjacent(bolt.sourcePos,cell))     GameScene.add(Blob.seed(cell,1 + chargesPerCast(),Fire.class));
    Char ch=Actor.findChar(cell);
    if (ch != null) {
      int damage=damageRoll();
      ch.damage(damage,this);
      Buff.affect(ch,Burning.class).reignite(ch);
switch (chargesPerCast()) {
case 1:
        break;
case 2:
      Buff.affect(ch,Cripple.class,4f);
    break;
case 3:
  Buff.affect(ch,Paralysis.class,4f);
break;
}
}
}
}
Program: 164098
Project: 164098
Buggy source:
private void spreadRegrowth(int cell,float strength){
  if (strength >= 0 && Level.passable[cell] && !Level.losBlocking[cell]) {
    affectedCells.add(cell);
    if (strength >= 1.5f) {
      spreadRegrowth(cell + PathFinder.NEIGHBOURS8[left(direction)],strength - 1.5f);
      spreadRegrowth(cell + PathFinder.NEIGHBOURS8[direction],strength - 1.5f);
      spreadRegrowth(cell + PathFinder.NEIGHBOURS8[right(direction)],strength - 1.5f);
    }
 else {
      visualCells.add(cell);
    }
  }
 else   if (!Level.passable[cell] || Level.losBlocking[cell])   visualCells.add(cell);
}

Fixed version (ground truth):
private void spreadRegrowth(int cell,float strength){
  if (strength >= 0 && Level.passable[cell] && !Level.losBlocking[cell]) {
    affectedCells.add(cell);
    if (strength >= 1.5f) {
      spreadRegrowth(cell + PathFinder.CIRCLE[left(direction)],strength - 1.5f);
      spreadRegrowth(cell + PathFinder.CIRCLE[direction],strength - 1.5f);
      spreadRegrowth(cell + PathFinder.CIRCLE[right(direction)],strength - 1.5f);
    }
 else {
      visualCells.add(cell);
    }
  }
 else   if (!Level.passable[cell] || Level.losBlocking[cell])   visualCells.add(cell);
}
Program: 164099
Project: 164099
Buggy source:
protected void fx(Ballistica bolt,Callback callback){
  affectedCells=new HashSet<>();
  visualCells=new HashSet<>();
  int maxDist=Math.round(1.2f + chargesPerCast() * .8f);
  int dist=Math.min(bolt.dist,maxDist);
  for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
    if (bolt.sourcePos + PathFinder.NEIGHBOURS8[i] == bolt.path.get(1)) {
      direction=i;
      break;
    }
  }
  float strength=maxDist;
  for (  int c : bolt.subPath(1,dist)) {
    strength--;
    if (!Level.losBlocking[c]) {
      affectedCells.add(c);
      spreadRegrowth(c + PathFinder.NEIGHBOURS8[left(direction)],strength - 1);
      spreadRegrowth(c + PathFinder.NEIGHBOURS8[direction],strength - 1);
      spreadRegrowth(c + PathFinder.NEIGHBOURS8[right(direction)],strength - 1);
    }
 else {
      visualCells.add(c);
    }
  }
  visualCells.remove(bolt.path.get(dist));
  for (  int cell : visualCells) {
    MagicMissile.foliage(curUser.sprite.parent,bolt.sourcePos,cell,null);
  }
  MagicMissile.foliage(curUser.sprite.parent,bolt.sourcePos,bolt.path.get(dist),callback);
  Sample.INSTANCE.play(Assets.SND_ZAP);
}

Fixed version (ground truth):
protected void fx(Ballistica bolt,Callback callback){
  affectedCells=new HashSet<>();
  visualCells=new HashSet<>();
  int maxDist=Math.round(1.2f + chargesPerCast() * .8f);
  int dist=Math.min(bolt.dist,maxDist);
  for (int i=0; i < PathFinder.CIRCLE.length; i++) {
    if (bolt.sourcePos + PathFinder.CIRCLE[i] == bolt.path.get(1)) {
      direction=i;
      break;
    }
  }
  float strength=maxDist;
  for (  int c : bolt.subPath(1,dist)) {
    strength--;
    if (!Level.losBlocking[c]) {
      affectedCells.add(c);
      spreadRegrowth(c + PathFinder.CIRCLE[left(direction)],strength - 1);
      spreadRegrowth(c + PathFinder.CIRCLE[direction],strength - 1);
      spreadRegrowth(c + PathFinder.CIRCLE[right(direction)],strength - 1);
    }
 else {
      visualCells.add(c);
    }
  }
  visualCells.remove(bolt.path.get(dist));
  for (  int cell : visualCells) {
    MagicMissile.foliage(curUser.sprite.parent,bolt.sourcePos,cell,null);
  }
  MagicMissile.foliage(curUser.sprite.parent,bolt.sourcePos,bolt.path.get(dist),callback);
  Sample.INSTANCE.play(Assets.SND_ZAP);
}
Program: 164100
Project: 164100
Buggy source:
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    Sample.INSTANCE.play(Assets.SND_MELD);
    Dungeon.observe();
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    Sample.INSTANCE.play(Assets.SND_MELD);
    if (Dungeon.level != null)     Dungeon.observe();
    return true;
  }
 else {
    return false;
  }
}
Program: 164101
Project: 164101
Buggy source:
public void level(int value){
  if (level < value) {
    level=value;
    pos=target.pos;
  }
}

Fixed version (ground truth):
public void level(int value){
  if (level < value) {
    level=value;
  }
  pos=target.pos;
}
Program: 164102
Project: 164102
Buggy source:
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch == Dungeon.hero) {
    Buff.affect(ch,Health.class).level=ch.HT;
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch == Dungeon.hero) {
    Buff.affect(ch,Health.class).boost(ch.HT);
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  }
}
Program: 164103
Project: 164103
Buggy source:
public void boost(int amount){
  level+=amount;
}

Fixed version (ground truth):
public void boost(int amount){
  level+=amount;
  pos=target.pos;
}
Program: 164104
Project: 164104
Buggy source:
public static void selectCell(CellSelector.Listener listener){
  cellSelector.listener=listener;
  scene.prompt(listener.prompt());
}

Fixed version (ground truth):
public static void selectCell(CellSelector.Listener listener){
  cellSelector.listener=listener;
  if (scene != null)   scene.prompt(listener.prompt());
}