nus-yam/ex-repair huggingface dataset:
Program: 163851
Project: 163851
Buggy source:
@Override public int proc(Armor armor,Char attacker,Char defender,int damage){
  if (damage == 0) {
    return 0;
  }
  int level=Math.max(0,armor.level());
  float percent=(level + 1) / (float)(level + 6);
  int amount=(int)Math.ceil(damage * percent);
  DeferedDamage deferred=Buff.affect(defender,DeferedDamage.class);
  deferred.prolong(amount);
  defender.sprite.showStatus(CharSprite.WARNING,Messages.get(this,"String_Node_Str",amount));
  return damage - amount;
}

Fixed version (ground truth):
@Override public int proc(Armor armor,Char attacker,Char defender,int damage){
  int realDamage=damage - Random.NormalIntRange(armor.DRMin(),armor.DRMax());
  if (realDamage <= 0) {
    return 0;
  }
  int level=Math.max(0,armor.level());
  float percent=(level + 1) / (float)(level + 6);
  int amount=(int)Math.ceil(realDamage * percent);
  DeferedDamage deferred=Buff.affect(defender,DeferedDamage.class);
  deferred.prolong(amount);
  defender.sprite.showStatus(CharSprite.WARNING,Messages.get(this,"String_Node_Str",amount));
  return damage - amount;
}
Program: 163852
Project: 163852
Buggy source:
@Override public void update(){
  super.update();
  waitingTime+=Game.elapsed;
  float p=timeLeft / TIME_TO_FADE;
switch (phase) {
case FADE_IN:
    message.alpha(1 - p);
  if ((timeLeft-=Game.elapsed) <= 0) {
    if (!thread.isAlive() && error == null) {
      phase=Phase.FADE_OUT;
      timeLeft=TIME_TO_FADE;
    }
 else {
      phase=Phase.STATIC;
    }
  }
break;
case FADE_OUT:
message.alpha(p);
if ((timeLeft-=Game.elapsed) <= 0) {
Game.switchScene(GameScene.class);
}
break;
case STATIC:
if (error != null) {
String errorMsg;
if (error instanceof FileNotFoundException) errorMsg=Messages.get(this,"String_Node_Str");
 else if (error instanceof IOException) errorMsg=Messages.get(this,"String_Node_Str");
 else if (error.getMessage() != null && error.getMessage().equals("String_Node_Str")) errorMsg=Messages.get(this,"String_Node_Str");
 else throw new RuntimeException("String_Node_Str",error);
add(new WndError(errorMsg){
public void onBackPressed(){
super.onBackPressed();
Game.switchScene(StartScene.class);
}
}
);
error=null;
}
 else if ((int)waitingTime == 10) {
waitingTime=11f;
ShatteredPixelDungeon.reportException(new RuntimeException("String_Node_Str" + Dungeon.seed + "String_Node_Str"+ Dungeon.depth));
}
break;
}
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  waitingTime+=Game.elapsed;
  float p=timeLeft / TIME_TO_FADE;
switch (phase) {
case FADE_IN:
    message.alpha(1 - p);
  if ((timeLeft-=Game.elapsed) <= 0) {
    if (!thread.isAlive() && error == null) {
      phase=Phase.FADE_OUT;
      timeLeft=TIME_TO_FADE;
    }
 else {
      phase=Phase.STATIC;
    }
  }
break;
case FADE_OUT:
message.alpha(p);
if ((timeLeft-=Game.elapsed) <= 0) {
Game.switchScene(GameScene.class);
thread=null;
error=null;
}
break;
case STATIC:
if (error != null) {
String errorMsg;
if (error instanceof FileNotFoundException) errorMsg=Messages.get(this,"String_Node_Str");
 else if (error instanceof IOException) errorMsg=Messages.get(this,"String_Node_Str");
 else if (error.getMessage() != null && error.getMessage().equals("String_Node_Str")) errorMsg=Messages.get(this,"String_Node_Str");
 else throw new RuntimeException("String_Node_Str",error);
add(new WndError(errorMsg){
public void onBackPressed(){
super.onBackPressed();
Game.switchScene(StartScene.class);
}
}
);
thread=null;
error=null;
}
 else if ((int)waitingTime == 10) {
waitingTime=11f;
String s="String_Node_Str";
for (StackTraceElement t : thread.getStackTrace()) {
s+="String_Node_Str";
s+=t.toString();
}
ShatteredPixelDungeon.reportException(new RuntimeException("String_Node_Str" + "String_Node_Str" + Dungeon.seed + "String_Node_Str"+ Dungeon.depth+ "String_Node_Str"+ s));
}
break;
}
}
Program: 163854
Project: 163854
Buggy source:
@Override public void onDetach(){
  super.onDetach();
  for (  Item item : items) {
    ((Wand)item).stopCharging();
  }
}

Fixed version (ground truth):
@Override public void onDetach(){
  super.onDetach();
  for (  Item item : items) {
    if (item instanceof Wand) {
      ((Wand)item).stopCharging();
    }
 else     if (item instanceof MissileWeapon) {
      ((MissileWeapon)item).holster=false;
    }
  }
}
Program: 163855
Project: 163855
Buggy source:
public static void add(Object key,SmartTexture tx){
  all.put(key,tx);
}

Fixed version (ground truth):
public synchronized static void add(Object key,SmartTexture tx){
  all.put(key,tx);
}
Program: 163856
Project: 163856
Buggy source:
public static boolean contains(Object key){
  return all.containsKey(key);
}

Fixed version (ground truth):
public synchronized static boolean contains(Object key){
  return all.containsKey(key);
}
Program: 163857
Project: 163857
Buggy source:
public static void reload(){
  for (  SmartTexture tx : all.values()) {
    tx.reload();
  }
}

Fixed version (ground truth):
public synchronized static void reload(){
  for (  SmartTexture tx : all.values()) {
    tx.reload();
  }
}
Program: 163858
Project: 163858
Buggy source:
public static SmartTexture createSolid(int color){
  final String key="String_Node_Str" + color;
  if (all.containsKey(key)) {
    return all.get(key);
  }
 else {
    Bitmap bmp=Bitmap.createBitmap(1,1,Bitmap.Config.ARGB_8888);
    bmp.eraseColor(color);
    SmartTexture tx=new SmartTexture(bmp);
    all.put(key,tx);
    return tx;
  }
}

Fixed version (ground truth):
public synchronized static SmartTexture createSolid(int color){
  final String key="String_Node_Str" + color;
  if (all.containsKey(key)) {
    return all.get(key);
  }
 else {
    Bitmap bmp=Bitmap.createBitmap(1,1,Bitmap.Config.ARGB_8888);
    bmp.eraseColor(color);
    SmartTexture tx=new SmartTexture(bmp);
    all.put(key,tx);
    return tx;
  }
}
Program: 163859
Project: 163859
Buggy source:
public static SmartTexture get(Object src){
  if (all.containsKey(src)) {
    return all.get(src);
  }
 else   if (src instanceof SmartTexture) {
    return (SmartTexture)src;
  }
 else {
    SmartTexture tx=new SmartTexture(getBitmap(src));
    all.put(src,tx);
    return tx;
  }
}

Fixed version (ground truth):
public synchronized static SmartTexture get(Object src){
  if (all.containsKey(src)) {
    return all.get(src);
  }
 else   if (src instanceof SmartTexture) {
    return (SmartTexture)src;
  }
 else {
    SmartTexture tx=new SmartTexture(getBitmap(src));
    all.put(src,tx);
    return tx;
  }
}
Program: 163860
Project: 163860
Buggy source:
public static void clear(){
  for (  Texture txt : all.values()) {
    txt.delete();
  }
  all.clear();
}

Fixed version (ground truth):
public synchronized static void clear(){
  for (  Texture txt : all.values()) {
    txt.delete();
  }
  all.clear();
}
Program: 163861
Project: 163861
Buggy source:
public static SmartTexture createGradient(int... colors){
  final String key="String_Node_Str" + colors;
  if (all.containsKey(key)) {
    return all.get(key);
  }
 else {
    Bitmap bmp=Bitmap.createBitmap(colors.length,1,Bitmap.Config.ARGB_8888);
    for (int i=0; i < colors.length; i++) {
      bmp.setPixel(i,0,colors[i]);
    }
    SmartTexture tx=new SmartTexture(bmp);
    tx.filter(Texture.LINEAR,Texture.LINEAR);
    tx.wrap(Texture.CLAMP,Texture.CLAMP);
    all.put(key,tx);
    return tx;
  }
}

Fixed version (ground truth):
public synchronized static SmartTexture createGradient(int... colors){
  final String key="String_Node_Str" + colors;
  if (all.containsKey(key)) {
    return all.get(key);
  }
 else {
    Bitmap bmp=Bitmap.createBitmap(colors.length,1,Bitmap.Config.ARGB_8888);
    for (int i=0; i < colors.length; i++) {
      bmp.setPixel(i,0,colors[i]);
    }
    SmartTexture tx=new SmartTexture(bmp);
    tx.filter(Texture.LINEAR,Texture.LINEAR);
    tx.wrap(Texture.CLAMP,Texture.CLAMP);
    all.put(key,tx);
    return tx;
  }
}
Program: 163862
Project: 163862
Buggy source:
public static void remove(Object key){
  SmartTexture tx=all.get(key);
  if (tx != null) {
    all.remove(key);
    tx.delete();
  }
}

Fixed version (ground truth):
public synchronized static void remove(Object key){
  SmartTexture tx=all.get(key);
  if (tx != null) {
    all.remove(key);
    tx.delete();
  }
}
Program: 163863
Project: 163863
Buggy source:
@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;
}

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();
    }
  }
  if (members != null) {
    members.clear();
    members=null;
  }
  length=0;
}
Program: 163864
Project: 163864
Buggy source:
@Override protected boolean affectHero(Hero hero){
  Sample.INSTANCE.play(Assets.SND_DRINK);
  hero.HP=hero.HT;
  hero.sprite.emitter().start(Speck.factory(Speck.HEALING),0.4f,4);
  PotionOfHealing.cure(hero);
  hero.belongings.uncurseEquipped();
  ((Hunger)hero.buff(Hunger.class)).satisfy(Hunger.STARVING);
  CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  Dungeon.hero.interrupt();
  GLog.p(Messages.get(this,"String_Node_Str"));
  return true;
}

Fixed version (ground truth):
@Override protected boolean affectHero(Hero hero){
  if (!hero.isAlive())   return false;
  Sample.INSTANCE.play(Assets.SND_DRINK);
  hero.HP=hero.HT;
  hero.sprite.emitter().start(Speck.factory(Speck.HEALING),0.4f,4);
  PotionOfHealing.cure(hero);
  hero.belongings.uncurseEquipped();
  ((Hunger)hero.buff(Hunger.class)).satisfy(Hunger.STARVING);
  CellEmitter.get(pos).start(ShaftParticle.FACTORY,0.2f,3);
  Dungeon.hero.interrupt();
  GLog.p(Messages.get(this,"String_Node_Str"));
  return true;
}
Program: 163865
Project: 163865
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(ITEMS,items);
  bundle.put(LEVEL,level);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  if (items != null)   bundle.put(ITEMS,items);
  bundle.put(LEVEL,level);
}
Program: 163866
Project: 163866
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void restoreFromBundle(Bundle bundle){
  items=new ArrayList<>((Collection<Item>)((Collection<?>)bundle.getCollection(ITEMS)));
  adjustStats(bundle.getInt(LEVEL));
  super.restoreFromBundle(bundle);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void restoreFromBundle(Bundle bundle){
  if (bundle.contains(ITEMS)) {
    items=new ArrayList<>((Collection<Item>)((Collection<?>)bundle.getCollection(ITEMS)));
  }
  adjustStats(bundle.getInt(LEVEL));
  super.restoreFromBundle(bundle);
}
Program: 163867
Project: 163867
Buggy source:
@Override public void activate(){
  if (Dungeon.bossLevel()) {
    return;
  }
  int nMobs=1;
  if (Random.Int(2) == 0) {
    nMobs++;
    if (Random.Int(2) == 0) {
      nMobs++;
    }
  }
  ArrayList<Integer> candidates=new ArrayList<>();
  for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
    int p=pos + PathFinder.NEIGHBOURS8[i];
    if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
      candidates.add(p);
    }
  }
  ArrayList<Integer> respawnPoints=new ArrayList<>();
  while (nMobs > 0 && candidates.size() > 0) {
    int index=Random.index(candidates);
    respawnPoints.add(candidates.remove(index));
    nMobs--;
  }
  ArrayList<Mob> mobs=new ArrayList<>();
  for (  Integer point : respawnPoints) {
    Mob mob=Dungeon.level.createMob();
    mob.state=mob.WANDERING;
    mob.pos=point;
    GameScene.add(mob,DELAY);
    mobs.add(mob);
  }
  for (  Mob mob : mobs) {
    ScrollOfTeleportation.appear(mob,mob.pos);
    Dungeon.level.press(mob.pos,mob,true);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  if (Dungeon.bossLevel()) {
    return;
  }
  int nMobs=1;
  if (Random.Int(2) == 0) {
    nMobs++;
    if (Random.Int(2) == 0) {
      nMobs++;
    }
  }
  ArrayList<Integer> candidates=new ArrayList<>();
  for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
    int p=pos + PathFinder.NEIGHBOURS8[i];
    if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
      candidates.add(p);
    }
  }
  ArrayList<Integer> respawnPoints=new ArrayList<>();
  while (nMobs > 0 && candidates.size() > 0) {
    int index=Random.index(candidates);
    respawnPoints.add(candidates.remove(index));
    nMobs--;
  }
  ArrayList<Mob> mobs=new ArrayList<>();
  for (  Integer point : respawnPoints) {
    Mob mob=Dungeon.level.createMob();
    if (mob != null) {
      mob.state=mob.WANDERING;
      mob.pos=point;
      GameScene.add(mob,DELAY);
      mobs.add(mob);
    }
  }
  for (  Mob mob : mobs) {
    ScrollOfTeleportation.appear(mob,mob.pos);
    Dungeon.level.press(mob.pos,mob,true);
  }
}
Program: 163868
Project: 163868
Buggy source:
@Override public void destroy(){
synchronized (inputs) {
    for (int i=0; i < inputs.length; i++) {
      if (inputs[i].item != null) {
        if (!inputs[i].item.collect()) {
          Dungeon.level.drop(inputs[i].item,Dungeon.hero.pos);
        }
      }
      inputs[i]=null;
    }
  }
  super.destroy();
}

Fixed version (ground truth):
@Override public void destroy(){
synchronized (inputs) {
    for (int i=0; i < inputs.length; i++) {
      if (inputs[i] != null && inputs[i].item != null) {
        if (!inputs[i].item.collect()) {
          Dungeon.level.drop(inputs[i].item,Dungeon.hero.pos);
        }
      }
      inputs[i]=null;
    }
  }
  super.destroy();
}
Program: 163869
Project: 163869
Buggy source:
protected void placeItems(Bag container){
  Belongings stuff=Dungeon.hero.belongings;
  placeItem(stuff.weapon != null ? stuff.weapon : new Placeholder(ItemSpriteSheet.WEAPON_HOLDER));
  placeItem(stuff.armor != null ? stuff.armor : new Placeholder(ItemSpriteSheet.ARMOR_HOLDER));
  placeItem(stuff.misc1 != null ? stuff.misc1 : new Placeholder(ItemSpriteSheet.RING_HOLDER));
  placeItem(stuff.misc2 != null ? stuff.misc2 : new Placeholder(ItemSpriteSheet.RING_HOLDER));
  boolean backpack=(container == Dungeon.hero.belongings.backpack);
  if (!backpack) {
    count=nCols;
    col=0;
    row=1;
  }
  for (  Item item : container.items) {
    placeItem(item);
  }
  while (count - (backpack ? 4 : nCols) < container.size) {
    placeItem(null);
  }
}

Fixed version (ground truth):
protected void placeItems(Bag container){
  Belongings stuff=Dungeon.hero.belongings;
  placeItem(stuff.weapon != null ? stuff.weapon : new Placeholder(ItemSpriteSheet.WEAPON_HOLDER));
  placeItem(stuff.armor != null ? stuff.armor : new Placeholder(ItemSpriteSheet.ARMOR_HOLDER));
  placeItem(stuff.misc1 != null ? stuff.misc1 : new Placeholder(ItemSpriteSheet.RING_HOLDER));
  placeItem(stuff.misc2 != null ? stuff.misc2 : new Placeholder(ItemSpriteSheet.RING_HOLDER));
  boolean backpack=(container == Dungeon.hero.belongings.backpack);
  if (!backpack) {
    count=nCols;
    col=0;
    row=1;
  }
  for (  Item item : container.items.toArray(new Item[0])) {
    placeItem(item);
  }
  while (count - (backpack ? 4 : nCols) < container.size) {
    placeItem(null);
  }
}
Program: 163870
Project: 163870
Buggy source:
@Override protected void layout(){
  super.layout();
  if (icon != null) {
    icon.x=x + (width - icon.width()) / 2;
    icon.y=y + (height - icon.height()) / 2;
    PixelScene.align(icon);
    if (!members.contains(icon))     add(icon);
  }
}

Fixed version (ground truth):
@Override protected synchronized void layout(){
  super.layout();
  if (icon != null) {
    icon.x=x + (width - icon.width()) / 2;
    icon.y=y + (height - icon.height()) / 2;
    PixelScene.align(icon);
    if (!members.contains(icon))     add(icon);
  }
}
Program: 163871
Project: 163871
Buggy source:
public static void updateIcon(){
  if (instance != null) {
    if (instance.icon != null) {
      instance.icon.killAndErase();
      instance.icon=null;
    }
    if (action != null) {
      instance.icon=action.getIcon();
      instance.needsLayout=true;
    }
  }
}

Fixed version (ground truth):
public static void updateIcon(){
  if (instance != null) {
synchronized (instance) {
      if (instance.icon != null) {
        instance.icon.killAndErase();
        instance.icon=null;
      }
      if (action != null) {
        instance.icon=action.getIcon();
        instance.needsLayout=true;
      }
    }
  }
}
Program: 163872
Project: 163872
Buggy source:
@Override public void update(){
  super.update();
  if (!Dungeon.hero.ready) {
    if (icon != null)     icon.alpha(0.5f);
  }
 else {
    if (icon != null)     icon.alpha(1f);
  }
  if (!visible && action != null) {
    visible=true;
    updateIcon();
    flash();
  }
 else {
    visible=action != null;
  }
  if (needsLayout) {
    layout();
    needsLayout=false;
  }
}

Fixed version (ground truth):
@Override public synchronized void update(){
  super.update();
  if (!Dungeon.hero.ready) {
    if (icon != null)     icon.alpha(0.5f);
  }
 else {
    if (icon != null)     icon.alpha(1f);
  }
  if (!visible && action != null) {
    visible=true;
    updateIcon();
    flash();
  }
 else {
    visible=action != null;
  }
  if (needsLayout) {
    layout();
    needsLayout=false;
  }
}
Program: 163874
Project: 163874
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  exp=bundle.getInt(EXP);
  charge=Math.min(chargeCap,bundle.getInt(CHARGE));
  partialCharge=bundle.getFloat(PARTIALCHARGE);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  exp=bundle.getInt(EXP);
  if (chargeCap > 0)   charge=Math.min(chargeCap,bundle.getInt(CHARGE));
 else   charge=bundle.getInt(CHARGE);
  partialCharge=bundle.getFloat(PARTIALCHARGE);
}
Program: 163875
Project: 163875
Buggy source:
protected void rangedHit(Char enemy,int cell){
  if (parent != null) {
    if (parent.durability <= parent.durabilityPerUse()) {
      durability=0;
      parent.durability=MAX_DURABILITY;
    }
 else {
      parent.durability-=parent.durabilityPerUse();
    }
    parent=null;
  }
 else {
    durability-=durabilityPerUse();
  }
  if (durability > 0) {
    if (enemy.isAlive() && sticky)     Buff.affect(enemy,PinCushion.class).stick(this);
 else     Dungeon.level.drop(this,enemy.pos).sprite.drop();
  }
}

Fixed version (ground truth):
protected void rangedHit(Char enemy,int cell){
  if (parent != null) {
    if (parent.durability <= parent.durabilityPerUse()) {
      durability=0;
      parent.durability=MAX_DURABILITY;
    }
 else {
      parent.durability-=parent.durabilityPerUse();
    }
    parent=null;
  }
 else {
    durability-=durabilityPerUse();
  }
  if (durability > 0) {
    if (enemy.isAlive() && sticky) {
      PinCushion p=Buff.affect(enemy,PinCushion.class);
      if (p.target == enemy) {
        p.stick(this);
        return;
      }
    }
    Dungeon.level.drop(this,enemy.pos).sprite.drop();
  }
}
Program: 163876
Project: 163876
Buggy source:
public static Mimic spawnAt(int pos,List<Item> items){
  if (Dungeon.level.pit[pos])   return null;
  Char ch=Actor.findChar(pos);
  if (ch != null) {
    ArrayList<Integer> candidates=new ArrayList<>();
    for (    int n : PathFinder.NEIGHBOURS8) {
      int cell=pos + n;
      if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
        candidates.add(cell);
      }
    }
    if (candidates.size() > 0) {
      int newPos=Random.element(candidates);
      Actor.addDelayed(new Pushing(ch,ch.pos,newPos),-1);
      ch.pos=newPos;
      Dungeon.level.press(newPos,ch);
    }
 else {
      return null;
    }
  }
  Mimic m=new Mimic();
  m.items=new ArrayList<>(items);
  m.adjustStats(Dungeon.depth);
  m.pos=pos;
  m.state=m.HUNTING;
  GameScene.add(m,1);
  m.sprite.turnTo(pos,Dungeon.hero.pos);
  if (Dungeon.level.heroFOV[m.pos]) {
    CellEmitter.get(pos).burst(Speck.factory(Speck.STAR),10);
    Sample.INSTANCE.play(Assets.SND_MIMIC);
  }
  Item reward=null;
  do {
switch (Random.Int(5)) {
case 0:
      reward=new Gold().random();
    break;
case 1:
  reward=Generator.randomMissile();
break;
case 2:
reward=Generator.randomArmor();
break;
case 3:
reward=Generator.randomWeapon();
break;
case 4:
reward=Generator.random(Generator.Category.RING);
break;
}
}
 while (reward == null || !Challenges.isItemBlocked(reward));
m.items.add(reward);
return m;
}

Fixed version (ground truth):
public static Mimic spawnAt(int pos,List<Item> items){
  if (Dungeon.level.pit[pos])   return null;
  Char ch=Actor.findChar(pos);
  if (ch != null) {
    ArrayList<Integer> candidates=new ArrayList<>();
    for (    int n : PathFinder.NEIGHBOURS8) {
      int cell=pos + n;
      if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
        candidates.add(cell);
      }
    }
    if (candidates.size() > 0) {
      int newPos=Random.element(candidates);
      Actor.addDelayed(new Pushing(ch,ch.pos,newPos),-1);
      ch.pos=newPos;
      Dungeon.level.press(newPos,ch);
    }
 else {
      return null;
    }
  }
  Mimic m=new Mimic();
  m.items=new ArrayList<>(items);
  m.adjustStats(Dungeon.depth);
  m.pos=pos;
  m.state=m.HUNTING;
  GameScene.add(m,1);
  m.sprite.turnTo(pos,Dungeon.hero.pos);
  if (Dungeon.level.heroFOV[m.pos]) {
    CellEmitter.get(pos).burst(Speck.factory(Speck.STAR),10);
    Sample.INSTANCE.play(Assets.SND_MIMIC);
  }
  Item reward=null;
  do {
switch (Random.Int(5)) {
case 0:
      reward=new Gold().random();
    break;
case 1:
  reward=Generator.randomMissile();
break;
case 2:
reward=Generator.randomArmor();
break;
case 3:
reward=Generator.randomWeapon();
break;
case 4:
reward=Generator.random(Generator.Category.RING);
break;
}
}
 while (reward == null || Challenges.isItemBlocked(reward));
m.items.add(reward);
return m;
}
Program: 163877
Project: 163877
Buggy source:
public void paint(Level level){
  Painter.fill(level,this,Terrain.WALL);
  Painter.fill(level,this,1,Terrain.EMPTY);
  Door entrance=entrance();
  entrance.set(Door.Type.LOCKED);
  Point well=null;
  if (entrance.x == left) {
    well=new Point(right - 1,Random.Int(2) == 0 ? top + 1 : bottom - 1);
  }
 else   if (entrance.x == right) {
    well=new Point(left + 1,Random.Int(2) == 0 ? top + 1 : bottom - 1);
  }
 else   if (entrance.y == top) {
    well=new Point(Random.Int(2) == 0 ? left + 1 : right - 1,bottom - 1);
  }
 else   if (entrance.y == bottom) {
    well=new Point(Random.Int(2) == 0 ? left + 1 : right - 1,top + 1);
  }
  Painter.set(level,well,Terrain.EMPTY_WELL);
  int remains=level.pointToCell(random());
  while (level.map[remains] == Terrain.EMPTY_WELL) {
    remains=level.pointToCell(random());
  }
  level.drop(new IronKey(Dungeon.depth),remains).type=Heap.Type.SKELETON;
  Item mainLoot=null;
  do {
switch (Random.Int(3)) {
case 0:
      mainLoot=Generator.random(Generator.Category.RING);
case 1:
    mainLoot=Generator.random(Generator.Category.ARTIFACT);
case 2:
  mainLoot=Generator.random(Random.oneOf(Generator.Category.WEAPON,Generator.Category.ARMOR));
}
}
 while (mainLoot == null || !Challenges.isItemBlocked(mainLoot));
level.drop(mainLoot,remains);
int n=Random.IntRange(1,2);
for (int i=0; i < n; i++) {
level.drop(prize(level),remains);
}
}

Fixed version (ground truth):
public void paint(Level level){
  Painter.fill(level,this,Terrain.WALL);
  Painter.fill(level,this,1,Terrain.EMPTY);
  Door entrance=entrance();
  entrance.set(Door.Type.LOCKED);
  Point well=null;
  if (entrance.x == left) {
    well=new Point(right - 1,Random.Int(2) == 0 ? top + 1 : bottom - 1);
  }
 else   if (entrance.x == right) {
    well=new Point(left + 1,Random.Int(2) == 0 ? top + 1 : bottom - 1);
  }
 else   if (entrance.y == top) {
    well=new Point(Random.Int(2) == 0 ? left + 1 : right - 1,bottom - 1);
  }
 else   if (entrance.y == bottom) {
    well=new Point(Random.Int(2) == 0 ? left + 1 : right - 1,top + 1);
  }
  Painter.set(level,well,Terrain.EMPTY_WELL);
  int remains=level.pointToCell(random());
  while (level.map[remains] == Terrain.EMPTY_WELL) {
    remains=level.pointToCell(random());
  }
  level.drop(new IronKey(Dungeon.depth),remains).type=Heap.Type.SKELETON;
  Item mainLoot=null;
  do {
switch (Random.Int(3)) {
case 0:
      mainLoot=Generator.random(Generator.Category.RING);
    break;
case 1:
  mainLoot=Generator.random(Generator.Category.ARTIFACT);
break;
case 2:
mainLoot=Generator.random(Random.oneOf(Generator.Category.WEAPON,Generator.Category.ARMOR));
break;
}
}
 while (mainLoot == null || Challenges.isItemBlocked(mainLoot));
level.drop(mainLoot,remains);
int n=Random.IntRange(1,2);
for (int i=0; i < n; i++) {
level.drop(prize(level),remains);
}
}
Program: 163878
Project: 163878
Buggy source:
@Override public void add(Buff buff){
  super.add(buff);
  if (buff instanceof Amok || buff instanceof Corruption) {
    state=HUNTING;
  }
 else   if (buff instanceof Terror) {
    state=FLEEING;
  }
 else   if (buff instanceof Sleep) {
    state=SLEEPING;
    this.sprite().showSleep();
    postpone(Sleep.SWS);
  }
}

Fixed version (ground truth):
@Override public void add(Buff buff){
  super.add(buff);
  if (buff instanceof Amok || buff instanceof Corruption) {
    state=HUNTING;
  }
 else   if (buff instanceof Terror) {
    state=FLEEING;
  }
 else   if (buff instanceof Sleep) {
    state=SLEEPING;
    postpone(Sleep.SWS);
  }
}
Program: 163879
Project: 163879
Buggy source:
@Override public boolean act(){
  if (berserking()) {
    if (target.HP <= 0) {
      target.SHLD-=Math.min(target.SHLD,2);
      if (target.SHLD == 0) {
        target.die(this);
        if (!target.isAlive())         Dungeon.fail(this.getClass());
      }
    }
 else {
      state=State.EXHAUSTED;
      exhaustion=EXHAUSTION_START;
      levelRecovery=LEVEL_RECOVER_START;
      BuffIndicator.refreshHero();
      target.SHLD=0;
      pastRages++;
    }
  }
 else {
    float percentHP=target.HP / (float)target.HT;
    if (percentHP > targetHPPercent()) {
      target.HP=(int)Math.max(target.HT * targetHPPercent(),target.HP - pastRages);
    }
    if (state == State.EXHAUSTED) {
      exhaustion--;
      if (exhaustion == 0) {
        state=State.RECOVERING;
        BuffIndicator.refreshHero();
      }
    }
  }
  spend(TICK);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (berserking()) {
    if (target.HP <= 0) {
      target.SHLD-=Math.min(target.SHLD,2);
      if (target.SHLD == 0) {
        target.die(this);
        if (!target.isAlive())         Dungeon.fail(this.getClass());
      }
    }
 else {
      state=State.EXHAUSTED;
      exhaustion=EXHAUSTION_START;
      levelRecovery=LEVEL_RECOVER_START;
      BuffIndicator.refreshHero();
      target.SHLD=0;
      pastRages++;
    }
  }
 else {
    if (target.HP > targetHPMax()) {
      target.HP=Math.max(targetHPMax(),target.HP - 1);
      if (target instanceof Hero) {
        ((Hero)target).resting=false;
        target.remove(MagicalSleep.class);
      }
    }
    if (state == State.EXHAUSTED) {
      exhaustion--;
      if (exhaustion == 0) {
        state=State.RECOVERING;
        BuffIndicator.refreshHero();
      }
    }
  }
  spend(TICK);
  return true;
}
Program: 163880
Project: 163880
Buggy source:
public int damageFactor(int dmg){
  float bonus;
  if (state == State.EXHAUSTED) {
    bonus=1f - ((float)Math.sqrt(exhaustion) / 8f);
  }
 else {
    float percentMissing=1f - target.HP / (float)target.HT;
    bonus=1f + (float)Math.pow(percentMissing,3);
  }
  return Math.round(dmg * bonus);
}

Fixed version (ground truth):
public int damageFactor(int dmg){
  float bonus;
  if (state == State.BERSERK) {
    bonus=2f;
  }
 else   if (state == State.EXHAUSTED) {
    bonus=1f - ((float)Math.sqrt(exhaustion) / 10f);
  }
 else {
    float percentMissing=1f - target.HP / (float)targetHPMax();
    bonus=1f + (0.5f * (float)Math.pow(percentMissing,2));
  }
  return Math.round(dmg * bonus);
}
Program: 163881
Project: 163881
Buggy source:
@Override public String desc(){
  float dispDamage=damageFactor(100);
  String text;
switch (state) {
case NORMAL:
default :
    text=Messages.get(this,"String_Node_Str",dispDamage);
  break;
case BERSERK:
return Messages.get(this,"String_Node_Str");
case EXHAUSTED:
text=Messages.get(this,"String_Node_Str",exhaustion,dispDamage);
break;
case RECOVERING:
text=Messages.get(this,"String_Node_Str",levelRecovery,dispDamage);
break;
}
if (pastRages == 0) {
text+="String_Node_Str" + Messages.get(this,"String_Node_Str");
}
 else {
text+="String_Node_Str" + Messages.get(this,"String_Node_Str",pastRages,(int)(targetHPPercent() * 100));
}
return text;
}

Fixed version (ground truth):
@Override public String desc(){
  float dispDamage=damageFactor(100);
  String text;
switch (state) {
case NORMAL:
default :
    text=Messages.get(this,"String_Node_Str",dispDamage);
  break;
case BERSERK:
return Messages.get(this,"String_Node_Str");
case EXHAUSTED:
text=Messages.get(this,"String_Node_Str",exhaustion,dispDamage);
break;
case RECOVERING:
text=Messages.get(this,"String_Node_Str",levelRecovery,dispDamage);
break;
}
if (pastRages == 0) {
text+="String_Node_Str" + Messages.get(this,"String_Node_Str");
}
 else {
int dispPercent=(int)(targetHPMax() / (float)target.HT * 100);
text+="String_Node_Str" + Messages.get(this,"String_Node_Str",pastRages,dispPercent);
}
return text;
}
Program: 163882
Project: 163882
Buggy source:
@Override public boolean act(){
  if (target instanceof Mob && ((Mob)target).state != ((Mob)target).SLEEPING) {
    detach();
    return true;
  }
  if (target instanceof Hero) {
    target.HP=Math.min(target.HP + 1,target.HT);
    ((Hero)target).resting=true;
    if (target.HP == target.HT) {
      GLog.p(Messages.get(this,"String_Node_Str"));
      detach();
    }
  }
  spend(STEP);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target instanceof Mob && ((Mob)target).state != ((Mob)target).SLEEPING) {
    detach();
    return true;
  }
  if (target instanceof Hero) {
    target.HP=Math.min(target.HP + 1,target.HT);
    ((Hero)target).resting=true;
    if (target.HP == target.buff(Regeneration.class).regencap()) {
      GLog.p(Messages.get(this,"String_Node_Str"));
      detach();
    }
  }
  spend(STEP);
  return true;
}
Program: 163883
Project: 163883
Buggy source:
@Override public boolean attachTo(Char target){
  if (!target.isImmune(Sleep.class) && super.attachTo(target)) {
    if (target instanceof Hero)     if (target.HP == target.HT) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      detach();
      return true;
    }
 else {
      GLog.i(Messages.get(this,"String_Node_Str"));
    }
 else     if (target instanceof Mob)     ((Mob)target).state=((Mob)target).SLEEPING;
    target.paralysed++;
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (!target.isImmune(Sleep.class) && super.attachTo(target)) {
    if (target instanceof Hero)     if (target.HP == target.buff(Regeneration.class).regencap()) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      detach();
      return true;
    }
 else {
      GLog.i(Messages.get(this,"String_Node_Str"));
    }
 else     if (target instanceof Mob)     ((Mob)target).state=((Mob)target).SLEEPING;
    target.paralysed++;
    return true;
  }
 else {
    return false;
  }
}
Program: 163884
Project: 163884
Buggy source:
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < target.HT && !((Hero)target).isStarving()) {
      LockedFloor lock=target.buff(LockedFloor.class);
      if (target.HP > 0 && (lock == null || lock.regenOn())) {
        target.HP+=1;
        if (target.HP == target.HT) {
          ((Hero)target).resting=false;
        }
      }
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    if (regenBuff != null)     if (regenBuff.isCursed())     spend(REGENERATION_DELAY * 1.5f);
 else     spend(REGENERATION_DELAY - regenBuff.itemLevel() * 0.9f);
 else     spend(REGENERATION_DELAY);
  }
 else {
    diactivate();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < regencap() && !((Hero)target).isStarving()) {
      LockedFloor lock=target.buff(LockedFloor.class);
      if (target.HP > 0 && (lock == null || lock.regenOn())) {
        target.HP+=1;
        if (target.HP == regencap()) {
          ((Hero)target).resting=false;
        }
      }
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    if (regenBuff != null)     if (regenBuff.isCursed())     spend(REGENERATION_DELAY * 1.5f);
 else     spend(REGENERATION_DELAY - regenBuff.itemLevel() * 0.9f);
 else     spend(REGENERATION_DELAY);
  }
 else {
    diactivate();
  }
  return true;
}
Program: 163885
Project: 163885
Buggy source:
@Override public void onHit(MagesStaff staff,Char attacker,Char defender,int damage){
  Chill chill=defender.buff(Chill.class);
  if (chill != null && Random.IntRange(2,10) > chill.cooldown()) {
    new FlavourBuff(){
{
        actPriority=VFX_PRIO;
      }
      public boolean act(){
        Buff.affect(target,Frost.class,Frost.duration(target) * Random.Float(1f,2f));
        return super.act();
      }
    }
.attachTo(defender);
  }
}

Fixed version (ground truth):
@Override public void onHit(MagesStaff staff,Char attacker,Char defender,int damage){
  Chill chill=defender.buff(Chill.class);
  if (chill != null && Random.IntRange(2,10) <= chill.cooldown()) {
    new FlavourBuff(){
{
        actPriority=VFX_PRIO;
      }
      public boolean act(){
        Buff.affect(target,Frost.class,Frost.duration(target) * Random.Float(1f,2f));
        return super.act();
      }
    }
.attachTo(defender);
  }
}
Program: 163886
Project: 163886
Buggy source:
@Override public void onDeath(){
  Badges.validateDeathFromPoison();
  Dungeon.fail(getClass());
  GLog.n(Messages.get(Poison.class,"String_Node_Str"));
}

Fixed version (ground truth):
@Override public void onDeath(){
  Badges.validateDeathFromPoison();
  Dungeon.fail(getClass());
  GLog.n(Messages.get(this,"String_Node_Str"));
}
Program: 163887
Project: 163887
Buggy source:
@Override public String desc(){
  return Messages.get(this,"String_Node_Str",dispTurns(left),damage);
}

Fixed version (ground truth):
@Override public String desc(){
  return Messages.get(this,"String_Node_Str",dispTurns(left),(int)damage);
}
Program: 163888
Project: 163888
Buggy source:
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    target.alignment=Char.Alignment.ALLY;
    if (target instanceof Mob) {
      ((Mob)target).rollToDropLoot();
    }
    PinCushion p=target.buff(PinCushion.class);
    if (p != null) {
      p.detach();
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    target.alignment=Char.Alignment.ALLY;
    return true;
  }
 else {
    return false;
  }
}
Program: 163889
Project: 163889
Buggy source:
private void corruptEnemy(Mob enemy){
  if (enemy.buff(Corruption.class) != null || enemy.buff(Doom.class) != null) {
    GLog.w(Messages.get(this,"String_Node_Str"));
    return;
  }
  if (!enemy.properties().contains(Char.Property.BOSS) && !enemy.properties().contains(Char.Property.MINIBOSS) && !enemy.immunities().contains(Corruption.class)) {
    enemy.HP=enemy.HT;
    for (    Buff buff : enemy.buffs()) {
      if (buff.type == Buff.buffType.NEGATIVE && !(buff instanceof SoulMark)) {
        buff.detach();
      }
    }
    Buff.affect(enemy,Corruption.class);
    Statistics.enemiesSlain++;
    Badges.validateMonstersSlain();
    Statistics.qualifiedForNoKilling=false;
    if (enemy.EXP > 0 && curUser.lvl <= enemy.maxLvl) {
      curUser.sprite.showStatus(CharSprite.POSITIVE,Messages.get(enemy,"String_Node_Str",enemy.EXP));
      curUser.earnExp(enemy.EXP);
    }
  }
 else {
    Buff.affect(enemy,Doom.class);
  }
}

Fixed version (ground truth):
private void corruptEnemy(Mob enemy){
  if (enemy.buff(Corruption.class) != null || enemy.buff(Doom.class) != null) {
    GLog.w(Messages.get(this,"String_Node_Str"));
    return;
  }
  if (!enemy.properties().contains(Char.Property.BOSS) && !enemy.properties().contains(Char.Property.MINIBOSS) && !enemy.immunities().contains(Corruption.class)) {
    enemy.HP=enemy.HT;
    for (    Buff buff : enemy.buffs()) {
      if (buff.type == Buff.buffType.NEGATIVE && !(buff instanceof SoulMark)) {
        buff.detach();
      }
 else       if (buff instanceof PinCushion) {
        buff.detach();
      }
    }
    Buff.affect(enemy,Corruption.class);
    Statistics.enemiesSlain++;
    Badges.validateMonstersSlain();
    Statistics.qualifiedForNoKilling=false;
    if (enemy.EXP > 0 && curUser.lvl <= enemy.maxLvl) {
      curUser.sprite.showStatus(CharSprite.POSITIVE,Messages.get(enemy,"String_Node_Str",enemy.EXP));
      curUser.earnExp(enemy.EXP);
    }
    enemy.rollToDropLoot();
  }
 else {
    Buff.affect(enemy,Doom.class);
  }
}
Program: 163890
Project: 163890
Buggy source:
@Override public void die(Object cause){
  Dungeon.level.drop(new MysteryMeat(),pos).sprite.drop();
  super.die(cause);
  Statistics.piranhasKilled++;
  Badges.validatePiranhasKilled();
}

Fixed version (ground truth):
@Override public void die(Object cause){
  super.die(cause);
  Statistics.piranhasKilled++;
  Badges.validatePiranhasKilled();
}
Program: 163892
Project: 163892
Buggy source:
@Override public synchronized void updateMap(){
  super.updateMap();
  data=new int[size];
  for (int cell=0; cell < data.length; cell++) {
    if (!Dungeon.level.discoverable[cell] || !Dungeon.level.insideMap(cell)) {
      data[cell]=CLEARED;
    }
 else {
      updateMapCell(cell);
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void updateMap(){
  super.updateMap();
  data=new int[size];
  for (int cell=0; cell < data.length; cell++) {
    if (!Dungeon.level.discoverable[cell] || (cell - mapWidth) <= 0 || (cell + mapWidth) >= size) {
      data[cell]=CLEARED;
    }
 else {
      updateMapCell(cell);
    }
  }
}
Program: 163894
Project: 163894
Buggy source:
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_EAT)) {
    if (!isEquipped(hero))     GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
 else     if (charge == 0)     GLog.i(Messages.get(this,"String_Node_Str"));
 else {
      int chargesToUse=Math.max(1,hero.buff(Hunger.class).hunger() / (int)(Hunger.STARVING / 10));
      if (chargesToUse > charge)       chargesToUse=charge;
      hero.buff(Hunger.class).satisfy((Hunger.STARVING / 10) * chargesToUse);
switch (hero.heroClass) {
case WARRIOR:
        if (hero.HP < hero.HT) {
          hero.HP=Math.min(hero.HP + 5,hero.HT);
          hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
        }
      break;
case MAGE:
    Buff.affect(hero,Recharging.class,4f);
  ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
}
Statistics.foodEaten++;
charge-=chargesToUse;
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero,SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
GLog.i(Messages.get(this,"String_Node_Str"));
hero.spend(Food.TIME_TO_EAT);
Badges.validateFoodEaten();
if (charge >= 15) image=ItemSpriteSheet.ARTIFACT_HORN4;
 else if (charge >= 10) image=ItemSpriteSheet.ARTIFACT_HORN3;
 else if (charge >= 5) image=ItemSpriteSheet.ARTIFACT_HORN2;
updateQuickslot();
}
}
 else if (action.equals(AC_STORE)) {
GameScene.selectItem(itemSelector,mode,Messages.get(this,"String_Node_Str"));
}
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_EAT)) {
    if (!isEquipped(hero))     GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
 else     if (charge == 0)     GLog.i(Messages.get(this,"String_Node_Str"));
 else {
      int chargesToUse=Math.max(1,hero.buff(Hunger.class).hunger() / (int)(Hunger.STARVING / 10));
      if (chargesToUse > charge)       chargesToUse=charge;
      hero.buff(Hunger.class).satisfy((Hunger.STARVING / 10) * chargesToUse);
switch (hero.heroClass) {
case WARRIOR:
        if (hero.HP < hero.HT) {
          hero.HP=Math.min(hero.HP + 5,hero.HT);
          hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
        }
      break;
case MAGE:
    Buff.affect(hero,Recharging.class,4f);
  ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
}
Statistics.foodEaten++;
charge-=chargesToUse;
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero,SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
GLog.i(Messages.get(this,"String_Node_Str"));
hero.spend(Food.TIME_TO_EAT);
Badges.validateFoodEaten();
if (charge >= 15) image=ItemSpriteSheet.ARTIFACT_HORN4;
 else if (charge >= 10) image=ItemSpriteSheet.ARTIFACT_HORN3;
 else if (charge >= 5) image=ItemSpriteSheet.ARTIFACT_HORN2;
 else image=ItemSpriteSheet.ARTIFACT_HORN1;
updateQuickslot();
}
}
 else if (action.equals(AC_STORE)) {
GameScene.selectItem(itemSelector,mode,Messages.get(this,"String_Node_Str"));
}
}
Program: 163895
Project: 163895
Buggy source:
public FogOfWar(int mapWidth,int mapHeight){
  super();
  this.mapWidth=mapWidth;
  this.mapHeight=mapHeight;
  mapLength=mapHeight * mapWidth;
  pWidth=mapWidth * PIX_PER_TILE;
  pHeight=mapHeight * PIX_PER_TILE;
  width2=1;
  while (width2 < pWidth) {
    width2<<=1;
  }
  height2=1;
  while (height2 < pHeight) {
    height2<<=1;
  }
  float size=DungeonTilemap.SIZE / PIX_PER_TILE;
  width=width2 * size;
  height=height2 * size;
  texture(TextureCache.createBufferTex("String_Node_Str",width2,height2));
  scale.set(DungeonTilemap.SIZE / PIX_PER_TILE,DungeonTilemap.SIZE / PIX_PER_TILE);
  toUpdate=new ArrayList<>();
  toUpdate.add(new Rect(0,0,mapWidth,mapHeight));
}

Fixed version (ground truth):
public FogOfWar(int mapWidth,int mapHeight){
  super();
  this.mapWidth=mapWidth;
  this.mapHeight=mapHeight;
  mapLength=mapHeight * mapWidth;
  pWidth=mapWidth * PIX_PER_TILE;
  pHeight=mapHeight * PIX_PER_TILE;
  width2=1;
  while (width2 < pWidth) {
    width2<<=1;
  }
  height2=1;
  while (height2 < pHeight) {
    height2<<=1;
  }
  float size=DungeonTilemap.SIZE / PIX_PER_TILE;
  width=width2 * size;
  height=height2 * size;
  BufferTexture tx=new BufferTexture(width2,height2);
  TextureCache.add(FogOfWar.class,tx);
  texture(tx);
  scale.set(DungeonTilemap.SIZE / PIX_PER_TILE,DungeonTilemap.SIZE / PIX_PER_TILE);
  toUpdate=new ArrayList<>();
  toUpdate.add(new Rect(0,0,mapWidth,mapHeight));
}
Program: 163896
Project: 163896
Buggy source:
@Override public void destroy(){
  super.destroy();
  if (texture != null) {
    texture.delete();
  }
}

Fixed version (ground truth):
@Override public void destroy(){
  super.destroy();
  if (texture != null) {
    TextureCache.remove(FogOfWar.class);
  }
}
Program: 163897
Project: 163897
Buggy source:
public void discover(int pos,int oldValue){
  final Image tile=new Image(texture);
  tile.frame(tileset.get(getTileVisual(pos,oldValue,false)));
  tile.point(tileToWorld(pos));
  parent.add(tile);
  parent.add(new AlphaTweener(tile,0,0.6f){
    protected void onComplete(){
      tile.killAndErase();
      killAndErase();
    }
  }
);
}

Fixed version (ground truth):
public void discover(int pos,int oldValue){
  int visual=getTileVisual(pos,oldValue,false);
  if (visual < 0)   return;
  final Image tile=new Image(texture);
  tile.frame(tileset.get(getTileVisual(pos,oldValue,false)));
  tile.point(tileToWorld(pos));
  parent.add(tile);
  parent.add(new AlphaTweener(tile,0,0.6f){
    protected void onComplete(){
      tile.killAndErase();
      killAndErase();
    }
  }
);
}
Program: 163898
Project: 163898
Buggy source:
public static Camera add(Camera camera){
  all.add(camera);
  return camera;
}

Fixed version (ground truth):
public static synchronized Camera add(Camera camera){
  all.add(camera);
  return camera;
}
Program: 163899
Project: 163899
Buggy source:
public static void updateAll(){
  int length=all.size();
  for (int i=0; i < length; i++) {
    Camera c=all.get(i);
    if (c.exists && c.active) {
      c.update();
    }
  }
}

Fixed version (ground truth):
public static synchronized void updateAll(){
  for (  Camera c : all) {
    if (c.exists && c.active) {
      c.update();
    }
  }
}
Program: 163900
Project: 163900
Buggy source:
public static Camera remove(Camera camera){
  all.remove(camera);
  return camera;
}

Fixed version (ground truth):
public static synchronized Camera remove(Camera camera){
  all.remove(camera);
  return camera;
}
Program: 163901
Project: 163901
Buggy source:
public static Camera reset(Camera newCamera){
  invW2=2f / Game.width;
  invH2=2f / Game.height;
  int length=all.size();
  for (int i=0; i < length; i++) {
    all.get(i).destroy();
  }
  all.clear();
  return main=add(newCamera);
}

Fixed version (ground truth):
public static synchronized Camera reset(Camera newCamera){
  invW2=2f / Game.width;
  invH2=2f / Game.height;
  int length=all.size();
  for (int i=0; i < length; i++) {
    all.get(i).destroy();
  }
  all.clear();
  return main=add(newCamera);
}
Program: 163902
Project: 163902
Buggy source:
@Override public void update(){
  super.update();
  x=target.sprite.center().x - SIZE / 2;
  y=target.sprite.y - SIZE;
switch (phase) {
case FADE_IN:
    alpha(passed / duration);
  scale.set(passed / duration);
break;
case STATIC:
break;
case FADE_OUT:
alpha(1 - passed / duration);
break;
}
if ((passed+=Game.elapsed) > duration) {
switch (phase) {
case FADE_IN:
phase=Phase.STATIC;
duration=STATIC_TIME;
break;
case STATIC:
phase=Phase.FADE_OUT;
duration=FADE_OUT_TIME;
break;
case FADE_OUT:
kill();
break;
}
passed=0;
}
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  if (target.sprite != null) {
    x=target.sprite.center().x - SIZE / 2;
    y=target.sprite.y - SIZE;
  }
switch (phase) {
case FADE_IN:
    alpha(passed / duration);
  scale.set(passed / duration);
break;
case STATIC:
break;
case FADE_OUT:
alpha(1 - passed / duration);
break;
}
if ((passed+=Game.elapsed) > duration) {
switch (phase) {
case FADE_IN:
phase=Phase.STATIC;
duration=STATIC_TIME;
break;
case STATIC:
phase=Phase.FADE_OUT;
duration=FADE_OUT_TIME;
break;
case FADE_OUT:
kill();
break;
}
passed=0;
}
}
Program: 163903
Project: 163903
Buggy source:
@Override public void doSpecial(){
  for (  Mob mob : Dungeon.level.mobs) {
    if (Dungeon.level.heroFOV[mob.pos]) {
      Buff.affect(mob,Burning.class).reignite(mob);
      Buff.prolong(mob,Roots.class,3);
    }
  }
  curUser.HP-=(curUser.HP / 3);
  curUser.spend(Actor.TICK);
  curUser.sprite.operate(curUser.pos);
  curUser.busy();
  curUser.sprite.centerEmitter().start(ElmoParticle.FACTORY,0.15f,4);
  Sample.INSTANCE.play(Assets.SND_READ);
}

Fixed version (ground truth):
@Override public void doSpecial(){
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    if (Dungeon.level.heroFOV[mob.pos]) {
      Buff.affect(mob,Burning.class).reignite(mob);
      Buff.prolong(mob,Roots.class,3);
    }
  }
  curUser.HP-=(curUser.HP / 3);
  curUser.spend(Actor.TICK);
  curUser.sprite.operate(curUser.pos);
  curUser.busy();
  curUser.sprite.centerEmitter().start(ElmoParticle.FACTORY,0.15f,4);
  Sample.INSTANCE.play(Assets.SND_READ);
}
Program: 163904
Project: 163904
Buggy source:
@Override protected void layout(){
  image.x=0;
  image.y=Math.max(0,name.height() + GAP + health.height() - image.height);
  name.x=image.width + GAP;
  name.y=image.height - health.height() - GAP- name.baseLine();
  float w=width - image.width - GAP;
  health.setRect(image.width + GAP,image.height - health.height(),w,health.height());
  buffs.setPos(name.x + name.width() + GAP - 1,name.y + name.baseLine() - BuffIndicator.SIZE - 2);
  height=health.bottom();
}

Fixed version (ground truth):
@Override protected void layout(){
  image.x=0;
  image.y=Math.max(0,name.height() + health.height() - image.height);
  name.x=image.width + GAP;
  name.y=Math.max(0,image.height - health.height() - name.height());
  float w=width - image.width - GAP;
  health.setRect(image.width + GAP,name.y + name.height(),w,health.height());
  buffs.setPos(name.x + name.width() + GAP - 1,name.y + name.baseLine() - BuffIndicator.SIZE - 2);
  height=health.bottom();
}