nus-yam/ex-repair huggingface dataset:
Program: 163995
Project: 163995
Buggy source:
public Point random(int m){
  return new Point(Random.Int(left + m,right - m),Random.Int(top + m,bottom - m));
}

Fixed version (ground truth):
public Point random(int m){
  return new Point(Random.IntRange(left + m,right - m),Random.IntRange(top + m,bottom - m));
}
Program: 163996
Project: 163996
Buggy source:
public void setSize(int w,int h){
  width=w;
  height=h;
  length=w * h;
  map=new int[length];
  Arrays.fill(map,Terrain.WALL);
  Arrays.fill(map,feeling == Level.Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
  visited=new boolean[length];
  mapped=new boolean[length];
  Dungeon.visible=new boolean[length];
  fieldOfView=new boolean[length()];
  passable=new boolean[length()];
  losBlocking=new boolean[length()];
  flamable=new boolean[length()];
  secret=new boolean[length()];
  solid=new boolean[length()];
  avoid=new boolean[length()];
  water=new boolean[length()];
  pit=new boolean[length()];
}

Fixed version (ground truth):
public void setSize(int w,int h){
  width=w;
  height=h;
  length=w * h;
  map=new int[length];
  Arrays.fill(map,Terrain.WALL);
  Arrays.fill(map,feeling == Level.Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
  visited=new boolean[length];
  mapped=new boolean[length];
  Dungeon.visible=new boolean[length];
  fieldOfView=new boolean[length()];
  passable=new boolean[length()];
  losBlocking=new boolean[length()];
  flamable=new boolean[length()];
  secret=new boolean[length()];
  solid=new boolean[length()];
  avoid=new boolean[length()];
  water=new boolean[length()];
  pit=new boolean[length()];
  PathFinder.setMapSize(w,h);
}
Program: 163997
Project: 163997
Buggy source:
public static void resetMap(){
  if (scene != null) {
    scene.tiles.map(Dungeon.level.map,Dungeon.level.width());
    scene.terrainFeatures.map(Dungeon.level.map,Dungeon.level.width());
    scene.walls.map(Dungeon.level.map,Dungeon.level.width());
  }
  updateFog();
}

Fixed version (ground truth):
public static void resetMap(){
  if (scene != null) {
    scene.tiles.map(Dungeon.level.map,Dungeon.level.width());
    scene.visualGrid.map(Dungeon.level.map,Dungeon.level.width());
    scene.terrainFeatures.map(Dungeon.level.map,Dungeon.level.width());
    scene.walls.map(Dungeon.level.map,Dungeon.level.width());
  }
  updateFog();
}
Program: 163998
Project: 163998
Buggy source:
@Override protected void layout(){
  super.layout();
  icon.x=x + (width - icon.width) / 2;
  icon.y=y + (height - icon.height) / 2;
  if (topLeft != null) {
    topLeft.x=x;
    topLeft.y=y;
  }
  if (topRight != null) {
    topRight.x=x + (width - topRight.width());
    topRight.y=y;
  }
  if (bottomRight != null) {
    bottomRight.x=x + (width - bottomRight.width());
    bottomRight.y=y + (height - bottomRight.height());
  }
  if (bottomRightIcon != null) {
    bottomRightIcon.x=x + (width - bottomRightIcon.width()) - 1;
    bottomRightIcon.y=y + (height - bottomRightIcon.height());
  }
}

Fixed version (ground truth):
@Override protected void layout(){
  super.layout();
  icon.x=x + (width - icon.width) / 2f;
  icon.y=y + (height - icon.height) / 2f;
  PixelScene.align(icon);
  if (topLeft != null) {
    topLeft.x=x;
    topLeft.y=y;
    PixelScene.align(topLeft);
  }
  if (topRight != null) {
    topRight.x=x + (width - topRight.width());
    topRight.y=y;
    PixelScene.align(topRight);
  }
  if (bottomRight != null) {
    bottomRight.x=x + (width - bottomRight.width());
    bottomRight.y=y + (height - bottomRight.height());
    PixelScene.align(bottomRight);
  }
  if (bottomRightIcon != null) {
    bottomRightIcon.x=x + (width - bottomRightIcon.width()) - 1;
    bottomRightIcon.y=y + (height - bottomRightIcon.height());
    PixelScene.align(bottomRightIcon);
  }
}
Program: 163999
Project: 163999
Buggy source:
@Override protected void layout(){
  health.visible=!Float.isNaN(healthLvl);
  imIcon.x=x + (Math.max(0,8 - imIcon.width() / 2));
  imIcon.y=y + (Math.max(0,8 - imIcon.height() / 2));
  int imWidth=(int)Math.max(imIcon.width(),16);
  int imHeight=(int)Math.max(imIcon.height(),16);
  tfLabel.maxWidth((int)(width - (imWidth + GAP)));
  tfLabel.setPos(x + imWidth + GAP,imHeight > tfLabel.height() ? y + (imHeight - tfLabel.height()) / 2 : y);
  PixelScene.align(tfLabel);
  if (health.visible) {
    health.setRect(tfLabel.left(),tfLabel.bottom(),tfLabel.maxWidth(),0);
    height=Math.max(imHeight,health.bottom());
  }
 else {
    height=Math.max(imHeight,tfLabel.height());
  }
}

Fixed version (ground truth):
@Override protected void layout(){
  health.visible=!Float.isNaN(healthLvl);
  imIcon.x=x + (Math.max(0,8 - imIcon.width() / 2));
  imIcon.y=y + (Math.max(0,8 - imIcon.height() / 2));
  PixelScene.align(imIcon);
  int imWidth=(int)Math.max(imIcon.width(),16);
  int imHeight=(int)Math.max(imIcon.height(),16);
  tfLabel.maxWidth((int)(width - (imWidth + GAP)));
  tfLabel.setPos(x + imWidth + GAP,imHeight > tfLabel.height() ? y + (imHeight - tfLabel.height()) / 2 : y);
  PixelScene.align(tfLabel);
  if (health.visible) {
    health.setRect(tfLabel.left(),tfLabel.bottom(),tfLabel.maxWidth(),0);
    height=Math.max(imHeight,health.bottom());
  }
 else {
    height=Math.max(imHeight,tfLabel.height());
  }
}
Program: 164000
Project: 164000
Buggy source:
@Override protected void createItems(){
  int nItems=3;
  int bonus=RingOfWealth.getBonus(Dungeon.hero,RingOfWealth.Wealth.class);
  bonus=Math.min(bonus,10);
  while (Random.Float() < (0.3f + bonus * 0.05f)) {
    nItems++;
  }
  for (int i=0; i < nItems; i++) {
    Heap.Type type=null;
switch (Random.Int(20)) {
case 0:
      type=Heap.Type.SKELETON;
    break;
case 1:
case 2:
case 3:
case 4:
  type=Heap.Type.CHEST;
break;
case 5:
type=Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST;
break;
default :
type=Heap.Type.HEAP;
}
int cell=randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) map[cell]=Terrain.GRASS;
drop(Generator.random(),cell).type=type;
}
for (Item item : itemsToSpawn) {
int cell;
do {
cell=randomDropCell();
if (item instanceof Scroll) {
while (traps.get(cell) instanceof FireTrap) {
cell=randomDropCell();
}
}
 else if (item instanceof Potion) {
while (traps.get(cell) instanceof ChillingTrap) {
cell=randomDropCell();
}
}
}
 while (traps.get(cell) instanceof ExplosiveTrap);
drop(item,cell).type=Heap.Type.HEAP;
if (map[cell] == Terrain.HIGH_GRASS) map[cell]=Terrain.GRASS;
}
Item item=Bones.get();
if (item != null) {
int cell=randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) map[cell]=Terrain.GRASS;
drop(item,cell).type=Heap.Type.REMAINS;
}
}

Fixed version (ground truth):
@Override protected void createItems(){
  int nItems=3;
  int bonus=RingOfWealth.getBonus(Dungeon.hero,RingOfWealth.Wealth.class);
  bonus=Math.min(bonus,10);
  while (Random.Float() < (0.3f + bonus * 0.05f)) {
    nItems++;
  }
  for (int i=0; i < nItems; i++) {
    Heap.Type type=null;
switch (Random.Int(20)) {
case 0:
      type=Heap.Type.SKELETON;
    break;
case 1:
case 2:
case 3:
case 4:
  type=Heap.Type.CHEST;
break;
case 5:
type=Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST;
break;
default :
type=Heap.Type.HEAP;
}
int cell=randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell]=Terrain.GRASS;
losBlocking[cell]=false;
}
drop(Generator.random(),cell).type=type;
}
for (Item item : itemsToSpawn) {
int cell;
do {
cell=randomDropCell();
if (item instanceof Scroll) {
while (traps.get(cell) instanceof FireTrap) {
cell=randomDropCell();
}
}
 else if (item instanceof Potion) {
while (traps.get(cell) instanceof ChillingTrap) {
cell=randomDropCell();
}
}
}
 while (traps.get(cell) instanceof ExplosiveTrap);
drop(item,cell).type=Heap.Type.HEAP;
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell]=Terrain.GRASS;
losBlocking[cell]=false;
}
}
Item item=Bones.get();
if (item != null) {
int cell=randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell]=Terrain.GRASS;
losBlocking[cell]=false;
}
drop(item,cell).type=Heap.Type.REMAINS;
}
}
Program: 164002
Project: 164002
Buggy source:
public void drop(Item item){
  if (item.stackable && type != Type.FOR_SALE) {
    for (    Item i : items) {
      if (i.isSimilar(item)) {
        i.quantity+=item.quantity;
        item=i;
        break;
      }
    }
    items.remove(item);
  }
  if (item instanceof Dewdrop && type != Type.FOR_SALE) {
    items.add(item);
  }
 else {
    items.addFirst(item);
  }
  if (sprite != null) {
    if (type == Type.HEAP || type == Type.FOR_SALE)     sprite.view(items.peek());
 else     sprite.view(image(),glowing());
  }
}

Fixed version (ground truth):
public void drop(Item item){
  if (item.stackable && type != Type.FOR_SALE) {
    for (    Item i : items) {
      if (i.isSimilar(item)) {
        i.quantity+=item.quantity;
        item=i;
        break;
      }
    }
    items.remove(item);
  }
  if (item instanceof Dewdrop && type != Type.FOR_SALE) {
    items.add(item);
  }
 else {
    items.addFirst(item);
  }
  if (sprite != null) {
    if (type == Type.HEAP || type == Type.FOR_SALE)     sprite.view(items.peek());
 else     sprite.view(image(),glowing());
    sprite.place(pos);
  }
}
Program: 164003
Project: 164003
Buggy source:
public Item pickUp(){
  Item item=items.removeFirst();
  if (items.isEmpty()) {
    destroy();
  }
 else   if (sprite != null) {
    sprite.view(image(),glowing());
  }
  return item;
}

Fixed version (ground truth):
public Item pickUp(){
  Item item=items.removeFirst();
  if (items.isEmpty()) {
    destroy();
  }
 else   if (sprite != null) {
    sprite.view(image(),glowing());
    sprite.place(pos);
  }
  return item;
}
Program: 164004
Project: 164004
Buggy source:
public PointF center(PointF p){
  x=p.x - width / 2;
  y=p.y - height / 2;
  return p;
}

Fixed version (ground truth):
public PointF center(Visual v){
  return new PointF(x + (width() - v.width()) / 2f,y + (height() - v.height()) / 2f);
}
Program: 164005
Project: 164005
Buggy source:
@Override protected boolean affectHero(Hero hero){
  Sample.INSTANCE.play(Assets.SND_DRINK);
  emitter.parent.add(new Identification(DungeonTilemap.tileCenterToWorld(pos)));
  hero.belongings.observe();
  for (int i=0; i < Dungeon.level.length(); i++) {
    int terr=Dungeon.level.map[i];
    if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
      Dungeon.level.discover(i);
      if (Dungeon.visible[i]) {
        GameScene.discoverTile(i,terr);
      }
    }
  }
  Buff.affect(hero,Awareness.class,Awareness.DURATION);
  Dungeon.observe();
  Dungeon.hero.interrupt();
  GLog.p(Messages.get(this,"String_Node_Str"));
  Journal.remove(Feature.WELL_OF_AWARENESS);
  return true;
}

Fixed version (ground truth):
@Override protected boolean affectHero(Hero hero){
  Sample.INSTANCE.play(Assets.SND_DRINK);
  emitter.parent.add(new Identification(hero.sprite.center()));
  hero.belongings.observe();
  for (int i=0; i < Dungeon.level.length(); i++) {
    int terr=Dungeon.level.map[i];
    if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
      Dungeon.level.discover(i);
      if (Dungeon.visible[i]) {
        GameScene.discoverTile(i,terr);
      }
    }
  }
  Buff.affect(hero,Awareness.class,Awareness.DURATION);
  Dungeon.observe();
  Dungeon.hero.interrupt();
  GLog.p(Messages.get(this,"String_Node_Str"));
  Journal.remove(Feature.WELL_OF_AWARENESS);
  return true;
}
Program: 164006
Project: 164006
Buggy source:
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || Level.pit[chain.path.get(1)])   return false;
 else {
    int newPos=-1;
    for (    int i : chain.subPath(1,chain.dist)) {
      if (!Level.solid[i] && Actor.findChar(i) == null) {
        newPos=i;
        break;
      }
    }
    if (newPos == -1) {
      return false;
    }
 else {
      final int newPosFinal=newPos;
      yell(Messages.get(this,"String_Node_Str"));
      sprite.parent.add(new Chains(pos,enemy.pos,new Callback(){
        public void call(){
          Actor.addDelayed(new Pushing(enemy,enemy.pos,newPosFinal,new Callback(){
            public void call(){
              enemy.pos=newPosFinal;
              Dungeon.level.press(newPosFinal,enemy);
              Cripple.prolong(enemy,Cripple.class,4f);
              if (enemy == Dungeon.hero) {
                Dungeon.hero.interrupt();
                Dungeon.observe();
                GameScene.updateFog();
              }
            }
          }
),-1);
          next();
        }
      }
));
    }
  }
  chainsUsed=true;
  return true;
}

Fixed version (ground truth):
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || Level.pit[chain.path.get(1)])   return false;
 else {
    int newPos=-1;
    for (    int i : chain.subPath(1,chain.dist)) {
      if (!Level.solid[i] && Actor.findChar(i) == null) {
        newPos=i;
        break;
      }
    }
    if (newPos == -1) {
      return false;
    }
 else {
      final int newPosFinal=newPos;
      yell(Messages.get(this,"String_Node_Str"));
      sprite.parent.add(new Chains(sprite.center(),enemy.sprite.center(),new Callback(){
        public void call(){
          Actor.addDelayed(new Pushing(enemy,enemy.pos,newPosFinal,new Callback(){
            public void call(){
              enemy.pos=newPosFinal;
              Dungeon.level.press(newPosFinal,enemy);
              Cripple.prolong(enemy,Cripple.class,4f);
              if (enemy == Dungeon.hero) {
                Dungeon.hero.interrupt();
                Dungeon.observe();
                GameScene.updateFog();
              }
            }
          }
),-1);
          next();
        }
      }
));
    }
  }
  chainsUsed=true;
  return true;
}
Program: 164007
Project: 164007
Buggy source:
public Arc(int from,int to){
  start=DungeonTilemap.tileCenterToWorld(from);
  end=DungeonTilemap.tileCenterToWorld(to);
  arc1=new Image(Effects.get(Effects.Type.LIGHTNING));
  arc1.x=start.x - arc1.origin.x;
  arc1.y=start.y - arc1.origin.y;
  arc1.origin.set(0,arc1.height() / 2);
  add(arc1);
  arc2=new Image(Effects.get(Effects.Type.LIGHTNING));
  arc2.origin.set(0,arc2.height() / 2);
  add(arc2);
}

Fixed version (ground truth):
public Arc(PointF from,PointF to){
  start=from;
  end=to;
  arc1=new Image(Effects.get(Effects.Type.LIGHTNING));
  arc1.x=start.x - arc1.origin.x;
  arc1.y=start.y - arc1.origin.y;
  arc1.origin.set(0,arc1.height() / 2);
  add(arc1);
  arc2=new Image(Effects.get(Effects.Type.LIGHTNING));
  arc2.origin.set(0,arc2.height() / 2);
  add(arc2);
}
Program: 164008
Project: 164008
Buggy source:
public static void hit(int pos,float angle){
  Group parent=Dungeon.hero.sprite.parent;
  Wound w=(Wound)parent.recycle(Wound.class);
  parent.bringToFront(w);
  w.reset(pos);
  w.angle=angle;
}

Fixed version (ground truth):
public static void hit(int pos,float angle){
  Group parent=Dungeon.hero.sprite.parent;
  Surprise s=(Surprise)parent.recycle(Surprise.class);
  parent.bringToFront(s);
  s.reset(pos);
  s.angle=angle;
}
Program: 164009
Project: 164009
Buggy source:
public void reset(int p){
  revive();
  x=(p % Dungeon.level.width()) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - width) / 2;
  y=(p / Dungeon.level.width()) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - height) / 2;
  time=TIME_TO_FADE;
}

Fixed version (ground truth):
public void reset(Visual v){
  revive();
  point(v.center(this));
  time=TIME_TO_FADE;
}
Program: 164010
Project: 164010
Buggy source:
public void reset(int p){
  revive();
  x=(p % Dungeon.level.width()) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - width) / 2;
  y=(p / Dungeon.level.width()) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - height) / 2;
  time=TIME_TO_FADE;
}

Fixed version (ground truth):
public void reset(Visual v){
  revive();
  point(v.center(this));
  time=TIME_TO_FADE;
}
Program: 164011
Project: 164011
Buggy source:
public synchronized void dispatch(T t){
  canceled=false;
  for (  Listener<T> listener : listeners) {
    if (listeners.contains(listener)) {
      listener.onSignal(t);
      if (canceled) {
        return;
      }
    }
  }
}

Fixed version (ground truth):
public synchronized void dispatch(T t){
  canceled=false;
  for (  Listener<T> listener : listeners) {
    listener.onSignal(t);
    if (canceled) {
      return;
    }
  }
}
Program: 164012
Project: 164012
Buggy source:
public boolean berserking(){
  if (target.HP == 0 && state == State.NORMAL) {
    WarriorShield shield=target.buff(WarriorShield.class);
    if (shield != null) {
      state=State.BERSERK;
      BuffIndicator.refreshHero();
      target.SHLD=shield.maxShield() * 5;
      SpellSprite.show(target,SpellSprite.BERSERK);
      Sample.INSTANCE.play(Assets.SND_CHALLENGE);
      GameScene.flash(0xFF0000);
    }
  }
  return state == State.BERSERK;
}

Fixed version (ground truth):
public boolean berserking(){
  if (target.HP == 0 && state == State.NORMAL) {
    WarriorShield shield=target.buff(WarriorShield.class);
    if (shield != null) {
      state=State.BERSERK;
      BuffIndicator.refreshHero();
      target.SHLD=shield.maxShield() * 5;
      SpellSprite.show(target,SpellSprite.BERSERK);
      Sample.INSTANCE.play(Assets.SND_CHALLENGE);
      GameScene.flash(0xFF0000);
    }
  }
  return state == State.BERSERK && target.SHLD > 0;
}
Program: 164013
Project: 164013
Buggy source:
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER && berserk != null && berserk.berserking()) {
    return true;
  }
  return super.isAlive();
}

Fixed version (ground truth):
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER) {
    if (berserk == null)     berserk=Buff.affect(this,Berserk.class);
    if (berserk.berserking())     return true;
  }
  return super.isAlive();
}
Program: 164014
Project: 164014
Buggy source:
private void checkEnemies(){
  candidates.clear();
  int v=Dungeon.hero.visibleEnemies();
  for (int i=0; i < v; i++) {
    Mob mob=Dungeon.hero.visibleEnemy(i);
    if (Dungeon.hero.canAttack(mob)) {
      candidates.add(mob);
    }
  }
  if (!candidates.contains(lastTarget)) {
    if (candidates.isEmpty()) {
      lastTarget=null;
    }
 else {
      active=true;
      lastTarget=Random.element(candidates);
      updateImage();
      flash();
    }
  }
 else {
    if (!bg.visible) {
      active=true;
      flash();
    }
  }
  visible(lastTarget != null);
  enable(bg.visible);
}

Fixed version (ground truth):
private synchronized void checkEnemies(){
  candidates.clear();
  int v=Dungeon.hero.visibleEnemies();
  for (int i=0; i < v; i++) {
    Mob mob=Dungeon.hero.visibleEnemy(i);
    if (Dungeon.hero.canAttack(mob)) {
      candidates.add(mob);
    }
  }
  if (!candidates.contains(lastTarget)) {
    if (candidates.isEmpty()) {
      lastTarget=null;
    }
 else {
      active=true;
      lastTarget=Random.element(candidates);
      updateImage();
      flash();
    }
  }
 else {
    if (!bg.visible) {
      active=true;
      flash();
    }
  }
  visible(lastTarget != null);
  enable(bg.visible);
}
Program: 164015
Project: 164015
Buggy source:
@Override public void update(){
  super.update();
  if (!bg.visible) {
    enable(false);
    if (delay > 0f)     delay-=Game.elapsed;
    if (delay <= 0f)     active=false;
  }
 else {
    delay=0.75f;
    active=true;
    if (Dungeon.hero.isAlive()) {
      enable(Dungeon.hero.ready);
    }
 else {
      visible(false);
      enable(false);
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void update(){
  super.update();
  if (!bg.visible) {
    enable(false);
    if (delay > 0f)     delay-=Game.elapsed;
    if (delay <= 0f)     active=false;
  }
 else {
    delay=0.75f;
    active=true;
    if (Dungeon.hero.isAlive()) {
      enable(Dungeon.hero.ready);
    }
 else {
      visible(false);
      enable(false);
    }
  }
}
Program: 164016
Project: 164016
Buggy source:
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_EAT)) {
switch (holiday) {
case NONE:
default :
      break;
case HWEEN:
    hero.HP=Math.min(hero.HP + hero.HT / 10,hero.HT);
  hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
break;
case XMAS:
Buff.affect(hero,Recharging.class,2f);
ScrollOfRecharging.charge(hero);
break;
}
}
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_EAT)) {
switch (holiday) {
case NONE:
      break;
case HWEEN:
    hero.HP=Math.min(hero.HP + hero.HT / 10,hero.HT);
  hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
break;
case XMAS:
Buff.affect(hero,Recharging.class,2f);
ScrollOfRecharging.charge(hero);
break;
}
}
}
Program: 164017
Project: 164017
Buggy source:
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER) {
    if (berserk == null)     berserk=Buff.affect(this,Berserk.class);
    if (berserk.berserking())     return true;
  }
  return super.isAlive();
}

Fixed version (ground truth):
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER && berserk != null && berserk.berserking()) {
    return true;
  }
  return super.isAlive();
}
Program: 164018
Project: 164018
Buggy source:
@Override public void damage(int dmg,Object src){
  if (buff(TimekeepersHourglass.timeStasis.class) != null)   return;
  if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt) {
    interrupt();
    resting=false;
  }
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.w(Messages.get(this,"String_Node_Str"));
  }
  CapeOfThorns.Thorns thorns=buff(CapeOfThorns.Thorns.class);
  if (thorns != null) {
    dmg=thorns.proc(dmg,(src instanceof Char ? (Char)src : null),this);
  }
  int tenacity=RingOfTenacity.getBonus(this,RingOfTenacity.Tenacity.class);
  if (tenacity != 0)   dmg=(int)Math.ceil((float)dmg * Math.pow(0.85,tenacity * ((float)(HT - HP) / HT)));
  if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class) && RingOfElements.FULL.contains(src.getClass())) {
    dmg-=Random.NormalIntRange(belongings.armor.DRMin(),belongings.armor.DRMax()) / 2;
  }
  super.damage(dmg,src);
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  if (buff(TimekeepersHourglass.timeStasis.class) != null)   return;
  if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt) {
    interrupt();
    resting=false;
  }
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.w(Messages.get(this,"String_Node_Str"));
  }
  CapeOfThorns.Thorns thorns=buff(CapeOfThorns.Thorns.class);
  if (thorns != null) {
    dmg=thorns.proc(dmg,(src instanceof Char ? (Char)src : null),this);
  }
  int tenacity=RingOfTenacity.getBonus(this,RingOfTenacity.Tenacity.class);
  if (tenacity != 0)   dmg=(int)Math.ceil((float)dmg * Math.pow(0.85,tenacity * ((float)(HT - HP) / HT)));
  if (belongings.armor != null && belongings.armor.hasGlyph(AntiMagic.class) && RingOfElements.FULL.contains(src.getClass())) {
    dmg-=Random.NormalIntRange(belongings.armor.DRMin(),belongings.armor.DRMax()) / 2;
  }
  if (subClass == HeroSubClass.BERSERKER && berserk == null) {
    berserk=Buff.affect(this,Berserk.class);
  }
  super.damage(dmg,src);
}
Program: 164019
Project: 164019
Buggy source:
@Override public boolean doPickUp(Hero hero){
  if (super.doPickUp(hero)) {
    GLog.n(Messages.get("String_Node_Str"));
    Buff.affect(hero,DustGhostSpawner.class);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean doPickUp(Hero hero){
  if (super.doPickUp(hero)) {
    GLog.n(Messages.get(this,"String_Node_Str"));
    Buff.affect(hero,DustGhostSpawner.class);
    return true;
  }
  return false;
}
Program: 164020
Project: 164020
Buggy source:
public void put(String key,Collection<? extends Bundlable> collection){
  JSONArray array=new JSONArray();
  for (  Bundlable object : collection) {
    if (object != null) {
      Bundle bundle=new Bundle();
      bundle.put(CLASS_NAME,object.getClass().getName());
      object.storeInBundle(bundle);
      array.put(bundle.data);
    }
  }
  try {
    data.put(key,array);
  }
 catch (  JSONException e) {
    reportException(e);
  }
}

Fixed version (ground truth):
public void put(String key,Collection<? extends Bundlable> collection){
  JSONArray array=new JSONArray();
  for (  Bundlable object : collection) {
    if (object != null) {
      Class cl=object.getClass();
      if (!cl.isMemberClass() || Modifier.isStatic(cl.getModifiers())) {
        Bundle bundle=new Bundle();
        bundle.put(CLASS_NAME,cl.getName());
        object.storeInBundle(bundle);
        array.put(bundle.data);
      }
    }
  }
  try {
    data.put(key,array);
  }
 catch (  JSONException e) {
    reportException(e);
  }
}
Program: 164021
Project: 164021
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  if (bundle.contains(LENGTH)) {
    cur=new int[bundle.getInt(LENGTH)];
  }
 else {
    cur=new int[1024];
  }
  off=new int[cur.length];
  int[] data=bundle.getIntArray(CUR);
  if (data != null) {
    int start=bundle.getInt(START);
    for (int i=0; i < data.length; i++) {
      cur[i + start]=data[i];
      volume+=data[i];
    }
  }
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  if (bundle.contains(CUR)) {
    if (bundle.contains(LENGTH)) {
      cur=new int[bundle.getInt(LENGTH)];
    }
 else {
      cur=new int[1024];
    }
    off=new int[cur.length];
    int[] data=bundle.getIntArray(CUR);
    int start=bundle.getInt(START);
    for (int i=0; i < data.length; i++) {
      cur[i + start]=data[i];
      volume+=data[i];
    }
  }
}
Program: 164022
Project: 164022
Buggy source:
@Override public void filter(int minMode,int maxMode){
  fModeMin=minMode;
  fModeMax=maxMode;
  if (id != -1)   super.filter(fModeMin=minMode,fModeMax=maxMode);
}

Fixed version (ground truth):
@Override public void filter(int minMode,int maxMode){
  if (fModeMin == minMode && fModeMax == maxMode)   return;
  fModeMin=minMode;
  fModeMax=maxMode;
  if (id != -1)   super.filter(fModeMin,fModeMax);
}
Program: 164023
Project: 164023
Buggy source:
@Override protected void generate(){
  super.generate();
  bitmap(bitmap,premultiplied);
  filter(fModeMin,fModeMax);
  wrap(wModeH,wModeV);
}

Fixed version (ground truth):
@Override protected void generate(){
  super.generate();
  bitmap(bitmap,premultiplied);
  super.filter(fModeMin,fModeMax);
  super.wrap(wModeH,wModeV);
}
Program: 164024
Project: 164024
Buggy source:
@Override public void wrap(int s,int t){
  wModeH=s;
  wModeV=t;
  if (id != -1)   super.wrap(wModeH=s,wModeV=t);
}

Fixed version (ground truth):
@Override public void wrap(int s,int t){
  if (wModeH == s && wModeV == t)   return;
  wModeH=s;
  wModeV=t;
  if (id != -1)   super.wrap(wModeH,wModeV);
}
Program: 164025
Project: 164025
Buggy source:
public void move(int step){
  if (Dungeon.level.adjacent(step,pos) && buff(Vertigo.class) != null) {
    sprite.interruptMotion();
    int newPos=pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
    if (!(Level.passable[newPos] || Level.avoid[newPos]) || Actor.findChar(newPos) != null)     return;
 else {
      sprite.move(pos,newPos);
      step=newPos;
    }
  }
  if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
    Door.leave(pos,this);
  }
  pos=step;
  if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
    Door.enter(pos,this);
  }
  if (this != Dungeon.hero) {
    sprite.visible=Dungeon.visible[pos];
  }
}

Fixed version (ground truth):
public void move(int step){
  if (Dungeon.level.adjacent(step,pos) && buff(Vertigo.class) != null) {
    sprite.interruptMotion();
    int newPos=pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
    if (!(Level.passable[newPos] || Level.avoid[newPos]) || Actor.findChar(newPos) != null)     return;
 else {
      sprite.move(pos,newPos);
      step=newPos;
    }
  }
  if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
    Door.leave(pos);
  }
  pos=step;
  if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
    Door.enter(pos);
  }
  if (this != Dungeon.hero) {
    sprite.visible=Dungeon.visible[pos];
  }
}
Program: 164026
Project: 164026
Buggy source:
@Override protected void evolve(){
  boolean[] flamable=Level.flamable;
  int cell;
  int fire;
  boolean observe=false;
  for (int i=area.left - 1; i <= area.right; i++) {
    for (int j=area.top - 1; j <= area.bottom; j++) {
      cell=i + j * Dungeon.level.width();
      if (cur[cell] > 0) {
        burn(cell);
        fire=cur[cell] - 1;
        if (flamable[cell] && Random.Int(fire + 1) == 0) {
          int oldTile=Dungeon.level.map[cell];
          Dungeon.level.destroy(cell);
          observe=true;
          GameScene.updateMap(cell);
          if (Dungeon.visible[cell]) {
            GameScene.discoverTile(cell,oldTile);
          }
        }
      }
 else {
        if (flamable[cell] && (cur[cell - 1] > 0 || cur[cell + 1] > 0 || cur[cell - Dungeon.level.width()] > 0 || cur[cell + Dungeon.level.width()] > 0)) {
          fire=4;
          burn(cell);
          area.union(i,j);
        }
 else {
          fire=0;
        }
      }
      volume+=(off[cell]=fire);
    }
  }
  if (observe) {
    Dungeon.observe();
  }
}

Fixed version (ground truth):
@Override protected void evolve(){
  boolean[] flamable=Level.flamable;
  int cell;
  int fire;
  boolean observe=false;
  for (int i=area.left - 1; i <= area.right; i++) {
    for (int j=area.top - 1; j <= area.bottom; j++) {
      cell=i + j * Dungeon.level.width();
      if (cur[cell] > 0) {
        burn(cell);
        fire=cur[cell] - 1;
        if (fire <= 0 && flamable[cell]) {
          int oldTile=Dungeon.level.map[cell];
          Dungeon.level.destroy(cell);
          observe=true;
          GameScene.updateMap(cell);
          if (Dungeon.visible[cell]) {
            GameScene.discoverTile(cell,oldTile);
          }
        }
      }
 else {
        if (flamable[cell] && (cur[cell - 1] > 0 || cur[cell + 1] > 0 || cur[cell - Dungeon.level.width()] > 0 || cur[cell + Dungeon.level.width()] > 0)) {
          fire=4;
          burn(cell);
          area.union(i,j);
        }
 else {
          fire=0;
        }
      }
      volume+=(off[cell]=fire);
    }
  }
  if (observe) {
    Dungeon.observe();
  }
}
Program: 164028
Project: 164028
Buggy source:
public static void reallyDie(Object cause){
  int length=Dungeon.level.length();
  int[] map=Dungeon.level.map;
  boolean[] visited=Dungeon.level.visited;
  boolean[] discoverable=Level.discoverable;
  for (int i=0; i < length; i++) {
    int terr=map[i];
    if (discoverable[i]) {
      visited[i]=true;
      if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
        Dungeon.level.discover(i);
      }
    }
  }
  Bones.leave();
  Dungeon.observe();
  Dungeon.hero.belongings.identify();
  int pos=Dungeon.hero.pos;
  ArrayList<Integer> passable=new ArrayList<Integer>();
  for (  Integer ofs : PathFinder.NEIGHBOURS8) {
    int cell=pos + ofs;
    if ((Level.passable[cell] || Level.avoid[cell]) && Dungeon.level.heaps.get(cell) == null) {
      passable.add(cell);
    }
  }
  Collections.shuffle(passable);
  ArrayList<Item> items=new ArrayList<Item>(Dungeon.hero.belongings.backpack.items);
  for (  Integer cell : passable) {
    if (items.isEmpty()) {
      break;
    }
    Item item=Random.element(items);
    Dungeon.level.drop(item,cell).sprite.drop(pos);
    items.remove(item);
  }
  GameScene.gameOver();
  if (cause instanceof Hero.Doom) {
    ((Hero.Doom)cause).onDeath();
  }
  Dungeon.deleteGame(Dungeon.hero.heroClass,true);
}

Fixed version (ground truth):
public static void reallyDie(Object cause){
  int length=Dungeon.level.length();
  int[] map=Dungeon.level.map;
  boolean[] visited=Dungeon.level.visited;
  boolean[] discoverable=Level.discoverable;
  for (int i=0; i < length; i++) {
    int terr=map[i];
    if (discoverable[i]) {
      visited[i]=true;
      if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
        Dungeon.level.discover(i);
      }
    }
  }
  Bones.leave();
  Dungeon.observe();
  GameScene.updateFog();
  Dungeon.hero.belongings.identify();
  int pos=Dungeon.hero.pos;
  ArrayList<Integer> passable=new ArrayList<Integer>();
  for (  Integer ofs : PathFinder.NEIGHBOURS8) {
    int cell=pos + ofs;
    if ((Level.passable[cell] || Level.avoid[cell]) && Dungeon.level.heaps.get(cell) == null) {
      passable.add(cell);
    }
  }
  Collections.shuffle(passable);
  ArrayList<Item> items=new ArrayList<Item>(Dungeon.hero.belongings.backpack.items);
  for (  Integer cell : passable) {
    if (items.isEmpty()) {
      break;
    }
    Item item=Random.element(items);
    Dungeon.level.drop(item,cell).sprite.drop(pos);
    items.remove(item);
  }
  GameScene.gameOver();
  if (cause instanceof Hero.Doom) {
    ((Hero.Doom)cause).onDeath();
  }
  Dungeon.deleteGame(Dungeon.hero.heroClass,true);
}
Program: 164029
Project: 164029
Buggy source:
@Override public int defenseProc(Char enemy,int damage){
  if (HP >= damage + 2) {
    ArrayList<Integer> candidates=new ArrayList<>();
    boolean[] passable=Level.passable;
    int[] neighbours={pos + 1,pos - 1,pos + Dungeon.level.width(),pos - Dungeon.level.width()};
    for (    int n : neighbours) {
      if (passable[n] && Actor.findChar(n) == null) {
        candidates.add(n);
      }
    }
    if (candidates.size() > 0) {
      Swarm clone=split();
      clone.HP=(HP - damage) / 2;
      clone.pos=Random.element(candidates);
      clone.state=clone.HUNTING;
      if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
        Door.enter(clone.pos,clone);
      }
      GameScene.add(clone,SPLIT_DELAY);
      Actor.addDelayed(new Pushing(clone,pos,clone.pos),-1);
      HP-=clone.HP;
    }
  }
  return super.defenseProc(enemy,damage);
}

Fixed version (ground truth):
@Override public int defenseProc(Char enemy,int damage){
  if (HP >= damage + 2) {
    ArrayList<Integer> candidates=new ArrayList<>();
    boolean[] passable=Level.passable;
    int[] neighbours={pos + 1,pos - 1,pos + Dungeon.level.width(),pos - Dungeon.level.width()};
    for (    int n : neighbours) {
      if (passable[n] && Actor.findChar(n) == null) {
        candidates.add(n);
      }
    }
    if (candidates.size() > 0) {
      Swarm clone=split();
      clone.HP=(HP - damage) / 2;
      clone.pos=Random.element(candidates);
      clone.state=clone.HUNTING;
      if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
        Door.enter(clone.pos);
      }
      GameScene.add(clone,SPLIT_DELAY);
      Actor.addDelayed(new Pushing(clone,pos,clone.pos),-1);
      HP-=clone.HP;
    }
  }
  return super.defenseProc(enemy,damage);
}
Program: 164031
Project: 164031
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.CIRCLE8[left(direction)],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE8[direction],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE8[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] || Level.flamable[cell])) {
    affectedCells.add(cell);
    if (strength >= 1.5f) {
      visualCells.remove(cell);
      spreadFlames(cell + PathFinder.CIRCLE8[left(direction)],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE8[direction],strength - 1.5f);
      spreadFlames(cell + PathFinder.CIRCLE8[right(direction)],strength - 1.5f);
    }
 else {
      visualCells.add(cell);
    }
  }
 else   if (!Level.passable[cell])   visualCells.add(cell);
}
Program: 164032
Project: 164032
Buggy source:
public void press(int cell,Char ch){
  if (ch != null && pit[cell] && !ch.flying) {
    if (ch == Dungeon.hero) {
      Chasm.heroFall(cell);
    }
 else     if (ch instanceof Mob) {
      Chasm.mobFall((Mob)ch);
    }
    return;
  }
  Trap trap=null;
switch (map[cell]) {
case Terrain.SECRET_TRAP:
    GLog.i(Messages.get(Level.class,"String_Node_Str"));
case Terrain.TRAP:
  trap=traps.get(cell);
break;
case Terrain.HIGH_GRASS:
HighGrass.trample(this,cell,ch);
break;
case Terrain.WELL:
WellWater.affectCell(cell);
break;
case Terrain.ALCHEMY:
if (ch == null) {
Alchemy.transmute(cell);
}
break;
case Terrain.DOOR:
Door.enter(cell,ch);
break;
}
TimekeepersHourglass.timeFreeze timeFreeze=Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (trap != null) {
if (timeFreeze == null) {
if (ch == Dungeon.hero) Dungeon.hero.interrupt();
trap.trigger();
}
 else {
Sample.INSTANCE.play(Assets.SND_TRAP);
discover(cell);
timeFreeze.setDelayedPress(cell);
}
}
Plant plant=plants.get(cell);
if (plant != null) {
plant.trigger();
}
}

Fixed version (ground truth):
public void press(int cell,Char ch){
  if (ch != null && pit[cell] && !ch.flying) {
    if (ch == Dungeon.hero) {
      Chasm.heroFall(cell);
    }
 else     if (ch instanceof Mob) {
      Chasm.mobFall((Mob)ch);
    }
    return;
  }
  Trap trap=null;
switch (map[cell]) {
case Terrain.SECRET_TRAP:
    GLog.i(Messages.get(Level.class,"String_Node_Str"));
case Terrain.TRAP:
  trap=traps.get(cell);
break;
case Terrain.HIGH_GRASS:
HighGrass.trample(this,cell,ch);
break;
case Terrain.WELL:
WellWater.affectCell(cell);
break;
case Terrain.ALCHEMY:
if (ch == null) {
Alchemy.transmute(cell);
}
break;
case Terrain.DOOR:
Door.enter(cell);
break;
}
TimekeepersHourglass.timeFreeze timeFreeze=Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (trap != null) {
if (timeFreeze == null) {
if (ch == Dungeon.hero) Dungeon.hero.interrupt();
trap.trigger();
}
 else {
Sample.INSTANCE.play(Assets.SND_TRAP);
discover(cell);
timeFreeze.setDelayedPress(cell);
}
}
Plant plant=plants.get(cell);
if (plant != null) {
plant.trigger();
}
}
Program: 164033
Project: 164033
Buggy source:
public void mobPress(Mob mob){
  int cell=mob.pos;
  if (pit[cell] && !mob.flying) {
    Chasm.mobFall(mob);
    return;
  }
  Trap trap=null;
switch (map[cell]) {
case Terrain.TRAP:
    trap=traps.get(cell);
  break;
case Terrain.DOOR:
Door.enter(cell,mob);
break;
}
if (trap != null) {
trap.trigger();
}
Plant plant=plants.get(cell);
if (plant != null) {
plant.trigger();
}
}

Fixed version (ground truth):
public void mobPress(Mob mob){
  int cell=mob.pos;
  if (pit[cell] && !mob.flying) {
    Chasm.mobFall(mob);
    return;
  }
  Trap trap=null;
switch (map[cell]) {
case Terrain.TRAP:
    trap=traps.get(cell);
  break;
case Terrain.DOOR:
Door.enter(cell);
break;
}
if (trap != null) {
trap.trigger();
}
Plant plant=plants.get(cell);
if (plant != null) {
plant.trigger();
}
}
Program: 164034
Project: 164034
Buggy source:
public static void leave(int pos,Char ch){
  if (Dungeon.level.heaps.get(pos) == null) {
    Level.set(pos,Terrain.DOOR);
    GameScene.updateMap(pos);
    if (ch != Dungeon.hero && Dungeon.visible[pos])     Dungeon.observe();
  }
}

Fixed version (ground truth):
public static void leave(int pos){
  if (Dungeon.level.heaps.get(pos) == null) {
    Level.set(pos,Terrain.DOOR);
    GameScene.updateMap(pos);
    if (Dungeon.visible[pos])     Dungeon.observe();
  }
}
Program: 164035
Project: 164035
Buggy source:
public static void enter(int pos,Char ch){
  Level.set(pos,Terrain.OPEN_DOOR);
  GameScene.updateMap(pos);
  if (ch == Dungeon.hero) {
    Sample.INSTANCE.play(Assets.SND_OPEN);
  }
 else   if (Dungeon.visible[pos]) {
    Sample.INSTANCE.play(Assets.SND_OPEN);
    Dungeon.observe();
  }
}

Fixed version (ground truth):
public static void enter(int pos){
  Level.set(pos,Terrain.OPEN_DOOR);
  GameScene.updateMap(pos);
  if (Dungeon.visible[pos]) {
    Dungeon.observe();
    Sample.INSTANCE.play(Assets.SND_OPEN);
  }
}
Program: 164037
Project: 164037
Buggy source:
public static void ready(){
  selectCell(defaultCellListener);
  QuickSlotButton.cancel();
}

Fixed version (ground truth):
public static void ready(){
  selectCell(defaultCellListener);
  QuickSlotButton.cancel();
  scene.toolbar.examining=false;
}
Program: 164038
Project: 164038
Buggy source:
public static void refreshAllBuffers(){
  for (  Vertexbuffer buf : buffers) {
    buf.updateVertices();
    buf.updateGLData();
  }
}

Fixed version (ground truth):
public static void refreshAllBuffers(){
synchronized (buffers) {
    for (    Vertexbuffer buf : buffers) {
      buf.updateVertices();
      buf.updateGLData();
    }
  }
}
Program: 164039
Project: 164039
Buggy source:
public Vertexbuffer(FloatBuffer vertices){
  int[] ptr=new int[1];
  GLES20.glGenBuffers(1,ptr,0);
  id=ptr[0];
  this.vertices=vertices;
  buffers.add(this);
  updateStart=0;
  updateEnd=vertices.limit();
}

Fixed version (ground truth):
public Vertexbuffer(FloatBuffer vertices){
synchronized (buffers) {
    int[] ptr=new int[1];
    GLES20.glGenBuffers(1,ptr,0);
    id=ptr[0];
    this.vertices=vertices;
    buffers.add(this);
    updateStart=0;
    updateEnd=vertices.limit();
  }
}
Program: 164040
Project: 164040
Buggy source:
public void delete(){
  GLES20.glDeleteBuffers(1,new int[]{id},0);
  buffers.remove(this);
}

Fixed version (ground truth):
public void delete(){
synchronized (buffers) {
    GLES20.glDeleteBuffers(1,new int[]{id},0);
    buffers.remove(this);
  }
}
Program: 164042
Project: 164042
Buggy source:
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER) {
    Berserk berserk=buff(Berserk.class);
    if (berserk != null && berserk.berserking()) {
      return true;
    }
  }
  return super.isAlive();
}

Fixed version (ground truth):
@Override public boolean isAlive(){
  if (subClass == HeroSubClass.BERSERKER && berserk != null && berserk.berserking()) {
    return true;
  }
  return super.isAlive();
}
Program: 164043
Project: 164043
Buggy source:
@Override public int damageRoll(){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  int dmg;
  int bonus=RingOfForce.getBonus(this,RingOfForce.Force.class);
  if (wep != null) {
    dmg=wep.damageRoll(this) + bonus;
  }
 else {
    if (bonus != 0) {
      dmg=RingOfForce.damageRoll(this);
    }
 else {
      dmg=Random.NormalIntRange(1,Math.max(STR() - 8,1));
    }
  }
  if (dmg < 0)   dmg=0;
  if (subClass == HeroSubClass.BERSERKER) {
    dmg=Buff.affect(this,Berserk.class).damageFactor(dmg);
  }
  return buff(Fury.class) != null ? (int)(dmg * 1.5f) : dmg;
}

Fixed version (ground truth):
@Override public int damageRoll(){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  int dmg;
  int bonus=RingOfForce.getBonus(this,RingOfForce.Force.class);
  if (wep != null) {
    dmg=wep.damageRoll(this) + bonus;
  }
 else {
    if (bonus != 0) {
      dmg=RingOfForce.damageRoll(this);
    }
 else {
      dmg=Random.NormalIntRange(1,Math.max(STR() - 8,1));
    }
  }
  if (dmg < 0)   dmg=0;
  if (subClass == HeroSubClass.BERSERKER) {
    berserk=Buff.affect(this,Berserk.class);
    dmg=berserk.damageFactor(dmg);
  }
  return buff(Fury.class) != null ? (int)(dmg * 1.5f) : dmg;
}
Program: 164044
Project: 164044
Buggy source:
public void earnExp(int exp){
  this.exp+=exp;
  float percent=exp / (float)maxExp();
  EtherealChains.chainsRecharge chains=buff(EtherealChains.chainsRecharge.class);
  if (chains != null)   chains.gainExp(percent);
  HornOfPlenty.hornRecharge horn=buff(HornOfPlenty.hornRecharge.class);
  if (horn != null)   horn.gainCharge(percent);
  if (subClass == HeroSubClass.BERSERKER)   Buff.affect(this,Berserk.class).recover(percent);
  boolean levelUp=false;
  while (this.exp >= maxExp()) {
    this.exp-=maxExp();
    if (lvl < MAX_LEVEL) {
      lvl++;
      levelUp=true;
      HT+=5;
      HP+=5;
      attackSkill++;
      defenseSkill++;
    }
 else {
      Buff.prolong(this,Bless.class,30f);
      this.exp=0;
      GLog.p(Messages.get(this,"String_Node_Str"));
      Sample.INSTANCE.play(Assets.SND_LEVELUP);
    }
    if (lvl < 10) {
      updateAwareness();
    }
  }
  if (levelUp) {
    GLog.p(Messages.get(this,"String_Node_Str"),lvl);
    sprite.showStatus(CharSprite.POSITIVE,Messages.get(Hero.class,"String_Node_Str"));
    Sample.INSTANCE.play(Assets.SND_LEVELUP);
    Badges.validateLevelReached();
  }
}

Fixed version (ground truth):
public void earnExp(int exp){
  this.exp+=exp;
  float percent=exp / (float)maxExp();
  EtherealChains.chainsRecharge chains=buff(EtherealChains.chainsRecharge.class);
  if (chains != null)   chains.gainExp(percent);
  HornOfPlenty.hornRecharge horn=buff(HornOfPlenty.hornRecharge.class);
  if (horn != null)   horn.gainCharge(percent);
  if (subClass == HeroSubClass.BERSERKER) {
    berserk=Buff.affect(this,Berserk.class);
    berserk.recover(percent);
  }
  boolean levelUp=false;
  while (this.exp >= maxExp()) {
    this.exp-=maxExp();
    if (lvl < MAX_LEVEL) {
      lvl++;
      levelUp=true;
      HT+=5;
      HP+=5;
      attackSkill++;
      defenseSkill++;
    }
 else {
      Buff.prolong(this,Bless.class,30f);
      this.exp=0;
      GLog.p(Messages.get(this,"String_Node_Str"));
      Sample.INSTANCE.play(Assets.SND_LEVELUP);
    }
    if (lvl < 10) {
      updateAwareness();
    }
  }
  if (levelUp) {
    GLog.p(Messages.get(this,"String_Node_Str"),lvl);
    sprite.showStatus(CharSprite.POSITIVE,Messages.get(Hero.class,"String_Node_Str"));
    Sample.INSTANCE.play(Assets.SND_LEVELUP);
    Badges.validateLevelReached();
  }
}
Program: 164045
Project: 164045
Buggy source:
@Override protected void onClick(){
  GameScene.show(new WndInfoBuff(buff));
}

Fixed version (ground truth):
@Override protected void onClick(){
  if (buff.icon() != NONE)   GameScene.show(new WndInfoBuff(buff));
}
Program: 164047
Project: 164047
Buggy source:
@Override public synchronized void updateMapCell(int cell){
  super.updateMapCell(Math.max(0,cell - mapWidth - 1));
  super.updateMapCell(Math.min(size - 1,cell + mapWidth + 1));
  for (  int i : PathFinder.NEIGHBOURS9)   if (cell + i >= 0 && cell + i <= 1023)   data[cell + i]=getTileVisual(cell + i,map[cell + i]);
}

Fixed version (ground truth):
@Override public synchronized void updateMapCell(int cell){
  if (Dungeon.level.insideMap(cell)) {
    super.updateMapCell(cell - mapWidth - 1);
    super.updateMapCell(cell + mapWidth + 1);
    for (    int i : PathFinder.NEIGHBOURS9)     data[cell + i]=getTileVisual(cell + i,map[cell + i]);
  }
 else {
    super.updateMapCell(cell);
    data[cell]=getTileVisual(cell,map[cell]);
  }
}
Program: 164048
Project: 164048
Buggy source:
@Override public void filter(int minMode,int maxMode){
  if (fModeMin == minMode && fModeMax == maxMode)   return;
  fModeMin=minMode;
  fModeMax=maxMode;
  if (id != -1)   super.filter(fModeMin,fModeMax);
}

Fixed version (ground truth):
@Override public void filter(int minMode,int maxMode){
  fModeMin=minMode;
  fModeMax=maxMode;
  if (id != -1)   super.filter(fModeMin,fModeMax);
}
Program: 164049
Project: 164049
Buggy source:
@Override protected void generate(){
  super.generate();
  bitmap(bitmap,premultiplied);
  super.filter(fModeMin,fModeMax);
  super.wrap(wModeH,wModeV);
}

Fixed version (ground truth):
@Override protected void generate(){
  super.generate();
  bitmap(bitmap,premultiplied);
  filter(fModeMin,fModeMax);
  wrap(wModeH,wModeV);
}
Program: 164050
Project: 164050
Buggy source:
@Override public void wrap(int s,int t){
  if (wModeH == s && wModeV == t)   return;
  wModeH=s;
  wModeV=t;
  if (id != -1)   super.wrap(wModeH,wModeV);
}

Fixed version (ground truth):
@Override public void wrap(int s,int t){
  wModeH=s;
  wModeV=t;
  if (id != -1)   super.wrap(wModeH,wModeV);
}
Program: 164051
Project: 164051
Buggy source:
public ShadowBox(){
  super(Assets.SHADOW,1);
  texture.filter(SmartTexture.LINEAR,SmartTexture.LINEAR);
  scale.set(SIZE,SIZE);
}

Fixed version (ground truth):
public ShadowBox(){
  super(Assets.SHADOW,1);
  if (texture.id == -1)   texture.filter(SmartTexture.LINEAR,SmartTexture.LINEAR);
  scale.set(SIZE,SIZE);
}