nus-yam/ex-repair huggingface dataset:
Program: 19928
Project: 19928
Buggy source:
private final void generateTextureVectors(int _frame){
  float tempLeft;
  float tempRight;
  if (length > 0) {
    float temp=((realWidth / (float)length) / imageWidth);
    tempLeft=temp * _frame;
    tempRight=temp * (_frame + 1);
  }
 else {
    tempLeft=0.0f;
    tempRight=1.0f;
  }
  if (isClamped) {
    texture[4]=53.0f;
    texture[6]=53.0f;
  }
 else {
    texture[0]=tempLeft;
    texture[1]=1.0f;
    texture[2]=tempLeft;
    texture[3]=0.0f;
    texture[4]=tempRight;
    texture[5]=1.0f;
    texture[6]=tempRight;
    texture[7]=0.0f;
  }
  ByteBuffer byteBuffer=ByteBuffer.allocateDirect(vertices.length * 4);
  byteBuffer.order(ByteOrder.nativeOrder());
  textureBuffer=byteBuffer.asFloatBuffer();
  textureBuffer.put(texture);
  textureBuffer.position(0);
  textureBuffer.clear();
}

Fixed version (ground truth):
private final void generateTextureVectors(int _frame){
  float tempLeft;
  float tempRight;
  if (length > 0) {
    float temp=((realWidth / (float)length) / imageWidth);
    tempLeft=temp * _frame;
    tempRight=temp * (_frame + 1);
  }
 else {
    tempLeft=0.0f;
    tempRight=1.0f;
  }
  if (isClamped) {
    texture[4]=53.0f;
    texture[6]=53.0f;
  }
 else {
    texture[0]=tempLeft;
    texture[1]=1.0f;
    texture[2]=tempLeft;
    texture[3]=0.0f;
    texture[4]=tempRight;
    texture[5]=1.0f;
    texture[6]=tempRight;
    texture[7]=0.0f;
  }
  textureBuffer.put(texture);
  textureBuffer.position(0);
  textureBuffer.clear();
}
Program: 19929
Project: 19929
Buggy source:
/** 
 * M��ritt�� objektin aktiiviseksi.
 */
@Override public void setActive(){
  state=Wrapper.FULL_ACTIVITY;
  boolean isPlaced=false;
  while (!isPlaced) {
    x=Utility.getRandom(-GameMode.mapWidth,GameMode.mapWidth);
    y=Utility.getRandom(-GameMode.mapHeight,GameMode.mapHeight);
    for (int i=wrapper.obstacles.size() - 1; i >= 0; --i) {
      if (Math.abs(x - wrapper.obstacles.get(i).x) > (Wrapper.gridSize + 300 * Options.scaleX) && Math.abs(x - wrapper.player.x) > 250 * Options.scaleX && Math.abs(y - wrapper.obstacles.get(i).y) > (Wrapper.gridSize + 300 * Options.scaleY) && Math.abs(y - wrapper.player.y) > 500 * Options.scaleY) {
        isPlaced=true;
        break;
      }
    }
  }
  if (collectableType == COLLECTABLE_TYPE_WEAPON) {
    int tempType=weaponType;
    while (weaponType == tempType) {
      weaponType=Utility.getRandom(1,6);
    }
  }
}

Fixed version (ground truth):
/** 
 * M��ritt�� objektin aktiiviseksi.
 */
@Override public void setActive(){
  state=Wrapper.FULL_ACTIVITY;
  boolean isPlaced=false;
  while (!isPlaced) {
    x=Utility.getRandom(-GameMode.mapWidth,GameMode.mapWidth);
    y=Utility.getRandom(-GameMode.mapHeight,GameMode.mapHeight);
    for (int i=wrapper.obstacles.size() - 1; i >= 0; --i) {
      if (Math.abs(x - wrapper.obstacles.get(i).x) > (Wrapper.gridSize + 300 * Options.scaleX) && Math.abs(x - wrapper.player.x) > 282 * Options.scaleX && Math.abs(y - wrapper.obstacles.get(i).y) > (Wrapper.gridSize + 300 * Options.scaleY) && Math.abs(y - wrapper.player.y) > 532 * Options.scaleY) {
        isPlaced=true;
        break;
      }
    }
  }
  if (collectableType == COLLECTABLE_TYPE_WEAPON) {
    int tempType=weaponType;
    while (weaponType == tempType) {
      weaponType=Utility.getRandom(1,6);
    }
  }
}
Program: 19931
Project: 19931
Buggy source:
/** 
 * P�ivitt�� obstacle-objektit
 */
protected void generateObstacles(){
  int tempDirection;
  int tempX;
  int tempY;
  for (int i=0; i < 3; ++i) {
    tempDirection=Utility.getRandom(0,359);
    tempX=Utility.getRandom(-mapWidth,mapWidth);
    tempY=Utility.getRandom(-mapHeight,mapHeight);
    if (tempX > -Options.scaledScreenWidth * 2 && tempX < Options.scaledScreenWidth * 2 && tempY > -Options.scaledScreenHeight * 2 && tempY < Options.scaledScreenHeight * 2) {
      --i;
    }
 else {
      asteroids[i]=new Obstacle(Obstacle.OBSTACLE_ASTEROID,0,tempX,tempY,2,tempDirection);
    }
  }
  planets[0]=new Obstacle(Obstacle.OBSTACLE_PLANET,Obstacle.PLANET_EARTH,400,-800,0,90);
  planets[1]=new Obstacle(Obstacle.OBSTACLE_PLANET,Obstacle.PLANET_X,-1000,-100,0,0);
  star=new Obstacle(Obstacle.OBSTACLE_STAR,0,900,800,0,0);
  boundaries[0]=new Boundary(-mapWidth,0,0);
  boundaries[1]=new Boundary(0,mapHeight,1);
  boundaries[2]=new Boundary(mapWidth,0,0);
  boundaries[3]=new Boundary(0,-mapHeight,1);
}

Fixed version (ground truth):
/** 
 * P�ivitt�� obstacle-objektit
 */
protected void generateObstacles(){
  int tempDirection;
  int tempX;
  int tempY;
  for (int i=0; i < 3; ++i) {
    tempDirection=Utility.getRandom(0,359);
    tempX=Utility.getRandom(-mapWidth,mapWidth);
    tempY=Utility.getRandom(-mapHeight,mapHeight);
    if (tempX > -Options.scaledScreenWidth * 2 && tempX < Options.scaledScreenWidth * 2 && tempY > -Options.scaledScreenHeight * 2 && tempY < Options.scaledScreenHeight * 2) {
      --i;
    }
 else {
      asteroids[i]=new Obstacle(Obstacle.OBSTACLE_ASTEROID,0,tempX,tempY,2,tempDirection);
    }
  }
  planets[0]=new Obstacle(Obstacle.OBSTACLE_PLANET,Obstacle.PLANET_EARTH,(int)(400 * Options.scaleX),(int)(-800 * Options.scaleY),0,90);
  planets[1]=new Obstacle(Obstacle.OBSTACLE_PLANET,Obstacle.PLANET_X,(int)(-1000 * Options.scaleX),(int)(-100 * Options.scaleY),0,0);
  star=new Obstacle(Obstacle.OBSTACLE_STAR,0,(int)(900 * Options.scaleX),(int)(800 * Options.scaleY),0,0);
  boundaries[0]=new Boundary(-mapWidth,0,0);
  boundaries[1]=new Boundary(0,mapHeight,1);
  boundaries[2]=new Boundary(mapWidth,0,0);
  boundaries[3]=new Boundary(0,-mapHeight,1);
}
Program: 19932
Project: 19932
Buggy source:
/** 
 * Piirt�� k�yt�ss� olevan tekstuurin ruudulle.
 * @param GL10 OpenGL-konteksti
 */
@Override public final void draw(GL10 _gl){
  GLRenderer.hudAnimations[usedAnimation].draw(_gl,-128 + CameraManager.xTranslate,180 + CameraManager.yTranslate,90,currentFrame);
  GLRenderer.hudAnimations[usedAnimation + 1].draw(_gl,128 + CameraManager.xTranslate,180 + CameraManager.yTranslate,90,currentFrame);
}

Fixed version (ground truth):
/** 
 * Piirt�� k�yt�ss� olevan tekstuurin ruudulle.
 * @param GL10 OpenGL-konteksti
 */
@Override public final void draw(GL10 _gl){
  GLRenderer.hudAnimations[usedAnimation].draw(_gl,-128 * Options.scaleX + CameraManager.xTranslate,180 * Options.scaleY + CameraManager.yTranslate,90,currentFrame);
  GLRenderer.hudAnimations[usedAnimation + 1].draw(_gl,128 * Options.scaleX + CameraManager.xTranslate,180 * Options.scaleY + CameraManager.yTranslate,90,currentFrame);
}
Program: 19933
Project: 19933
Buggy source:
/** 
 * Alustaa luokan muuttujat ja m��rittelee osumatarkistuksissa k�ytett�v�n ruudukon koon.
 */
private Wrapper(){
  gridSize=(int)(((Options.screenWidth * Options.scaleX) / 20) * 10);
  drawables=new ArrayList<GfxObject>();
  aiGroupOne=new ArrayList<AiObject>();
  aiGroupTwo=new ArrayList<AiObject>();
  aiGroupThree=new ArrayList<AiObject>();
  allies=new ArrayList<Ally>();
  enemies=new ArrayList<Enemy>();
  projectiles=new ArrayList<AbstractProjectile>();
  obstacles=new ArrayList<Obstacle>();
  scoreCollectables=new ArrayList<Collectable>();
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat ja m��rittelee osumatarkistuksissa k�ytett�v�n ruudukon koon.
 */
private Wrapper(){
  gridSize=(int)((Options.screenWidth * Options.scaleX) / 2);
  drawables=new ArrayList<GfxObject>();
  aiGroupOne=new ArrayList<AiObject>();
  aiGroupTwo=new ArrayList<AiObject>();
  aiGroupThree=new ArrayList<AiObject>();
  allies=new ArrayList<Ally>();
  enemies=new ArrayList<Enemy>();
  projectiles=new ArrayList<AbstractProjectile>();
  obstacles=new ArrayList<Obstacle>();
  scoreCollectables=new ArrayList<Collectable>();
}
Program: 19934
Project: 19934
Buggy source:
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  if (gameThread != null) {
    _gl.glClearColor(0.0f,0.0f,0.0f,0);
    _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    if (gameThread.gameState == GameThread.GAMESTATE_LOADING_RESOURCES) {
      if (loadingTexture == null) {
        loadingTexture=new GLSpriteSet(_gl,context,R.drawable.loading,1,false);
        storyTexture=new GLSpriteSet(_gl,context,R.drawable.story1,1,false);
      }
      loadingTexture.draw(_gl,0,0,90,0);
      if (!loadingStarted && !allLoaded) {
        loadingStarted=true;
      }
 else       if (loadingStarted && !allLoaded) {
        if (loadTextures(_gl)) {
          allLoaded=true;
        }
 else {
          System.exit(0);
        }
      }
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STORY) {
      storyTexture.draw(_gl,0,0,90,0);
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_GAME) {
      if (allLoaded && gameThread.allLoaded) {
        renderScene(_gl);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  if (gameThread != null) {
    if (gameThread.gameState == GameThread.GAMESTATE_LOADING_RESOURCES) {
      if (loadingTexture == null) {
        loadingTexture=new GLSpriteSet(_gl,context,R.drawable.loading,1,false);
        storyTexture=new GLSpriteSet(_gl,context,R.drawable.story1,1,false);
      }
      if (!loadingStarted && !allLoaded) {
        _gl.glClearColor(0.0f,0.0f,0.0f,0);
        _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        loadingTexture.draw(_gl,0,0,90,0);
        loadingStarted=true;
      }
 else       if (loadingStarted && !allLoaded) {
        _gl.glClearColor(0.0f,0.0f,0.0f,0);
        _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        loadingTexture.draw(_gl,0,0,90,0);
        if (loadTextures(_gl)) {
          allLoaded=true;
        }
 else {
          System.exit(0);
        }
      }
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STORY) {
      storyTexture.draw(_gl,0,0,90,0);
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_GAME) {
      if (allLoaded && gameThread.allLoaded) {
        _gl.glClearColor(0.0f,0.0f,0.0f,0);
        _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        renderScene(_gl);
      }
    }
  }
}
Program: 19935
Project: 19935
Buggy source:
/** 
 * Lataa tekstuurin muistiin ja muuntaa sen OpenGL-tekstuuriksi.
 * @param _context Ohjelman konteksti
 * @param _id      Resurssin tunnus
 * @param _gl      OpenGL-konteksti
 * @return Onnistuiko tekstuurin lataaminen?
 */
protected boolean loadBitmap(Context _context,int _id,GL10 _gl){
  Bitmap bitmap=null;
  try {
    bitmap=BitmapFactory.decodeResource(_context.getResources(),_id);
  }
 catch (  Exception e) {
  }
  if (imageWidth == 0) {
    imageWidth=(float)bitmap.getWidth();
    imageHeight=(float)bitmap.getHeight();
  }
  _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
  if (isClamped) {
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,GL10.GL_REPEAT);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  }
 else {
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  }
  GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,bitmap,0);
  bitmap.recycle();
  return true;
}

Fixed version (ground truth):
/** 
 * Lataa tekstuurin muistiin ja muuntaa sen OpenGL-tekstuuriksi.
 * @param _context Ohjelman konteksti
 * @param _id      Resurssin tunnus
 * @param _gl      OpenGL-konteksti
 * @return Onnistuiko tekstuurin lataaminen?
 */
protected boolean loadBitmap(Context _context,int _id,GL10 _gl){
  Bitmap bitmap=null;
  try {
    bitmap=BitmapFactory.decodeResource(_context.getResources(),_id);
  }
 catch (  Exception e) {
  }
  if (imageWidth == 0) {
    imageWidth=(float)bitmap.getWidth();
    imageHeight=(float)bitmap.getHeight();
  }
  _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
  _gl.glActiveTexture(sprites[0]);
  if (isClamped) {
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,GL10.GL_REPEAT);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  }
 else {
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
    _gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  }
  GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,bitmap,0);
  bitmap.recycle();
  return true;
}
Program: 19936
Project: 19936
Buggy source:
/** 
 * Piirt�� tekstuurin ruudulle.
 * @param _gl		 OpenGL-konteksti
 * @param _x         Tekstuurin X-koordinaatti
 * @param _y         Tekstuurin Y-koordinaatti
 * @param _direction Tekstuurin suunta (0 = oikealle)
 * @param _frame     Tekstuurin j�rjestysnumero (animaatioille, tekstuureilla aina 0)
 */
public final void draw(GL10 _gl,float _x,float _y,int _direction,int _frame){
  _gl.glLoadIdentity();
  _gl.glTranslatef(_x - CameraManager.xTranslate,_y - CameraManager.yTranslate,0);
  _gl.glRotatef((float)_direction - 90.0f,0.0f,0.0f,1.0f);
  _gl.glScalef(0.5f,0.5f,0.0f);
  if (cachedTexture != sprites[0] || cachedTexture == -1) {
    _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
    generateTextureVectors(_frame);
    cachedTexture=sprites[0];
    cachedFrame=_frame;
  }
 else {
    if (cachedFrame != _frame) {
      generateTextureVectors(_frame);
      cachedFrame=_frame;
    }
  }
  _gl.glFrontFace(GL10.GL_CW);
  _gl.glVertexPointer(3,GL10.GL_FLOAT,0,vertexBuffer);
  _gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
  _gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,vertices.length / 3);
}

Fixed version (ground truth):
/** 
 * Piirt�� tekstuurin ruudulle.
 * @param _gl		 OpenGL-konteksti
 * @param _x         Tekstuurin X-koordinaatti
 * @param _y         Tekstuurin Y-koordinaatti
 * @param _direction Tekstuurin suunta (0 = oikealle)
 * @param _frame     Tekstuurin j�rjestysnumero (animaatioille, tekstuureilla aina 0)
 */
public final void draw(GL10 _gl,float _x,float _y,int _direction,int _frame){
  _gl.glLoadIdentity();
  _gl.glTranslatef(_x - CameraManager.xTranslate,_y - CameraManager.yTranslate,0);
  _gl.glRotatef((float)_direction - 90.0f,0.0f,0.0f,1.0f);
  _gl.glScalef(0.5f,0.5f,0.0f);
  if (cachedTexture != sprites[0]) {
    cachedTexture=sprites[0];
    cachedFrame=_frame;
    _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
    generateTextureVectors(_frame);
  }
 else {
    if (cachedFrame != _frame) {
      generateTextureVectors(_frame);
      cachedFrame=_frame;
    }
  }
  _gl.glFrontFace(GL10.GL_CW);
  _gl.glVertexPointer(3,GL10.GL_FLOAT,0,vertexBuffer);
  _gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
  _gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,vertices.length / 3);
}
Program: 19938
Project: 19938
Buggy source:
/** 
 * Siirt�� pelin taukotilaan ja tallentaa ohjelman tilan, sill� onPausen j�lkeen prosessi saatetaan keskeytt�� kokonaan. Android kutsuu t�t� automaattisesti.
 */
@Override protected void onPause(){
  super.onPause();
}

Fixed version (ground truth):
/** 
 * Siirt�� pelin taukotilaan ja tallentaa ohjelman tilan, sill� onPausen j�lkeen prosessi saatetaan keskeytt�� kokonaan. Android kutsuu t�t� automaattisesti.
 */
@Override protected void onPause(){
  super.onPause();
  gameThread.setRunning(false);
}
Program: 19939
Project: 19939
Buggy source:
/** 
 * Tallentaa ohjelman tilan, sill� onStopin j�lkeen prosessi saatetaan keskeytt�� kokonaan. Android kutsuu t�t� automaattisesti kun ohjelma ei ole en�� aktiivinen.
 */
@Override protected void onStop(){
  super.onStop();
  Wrapper.destroy();
  CameraManager.destroy();
  EffectManager.destroy();
  gameThread.interrupt();
  gameThread=null;
  surfaceView=null;
  renderer=null;
  weaponManager=null;
}

Fixed version (ground truth):
/** 
 * Tallentaa ohjelman tilan, sill� onStopin j�lkeen prosessi saatetaan keskeytt�� kokonaan. Android kutsuu t�t� automaattisesti kun ohjelma ei ole en�� aktiivinen.
 */
@Override protected void onStop(){
  super.onStop();
  Wrapper.destroy();
  CameraManager.destroy();
  EffectManager.destroy();
  gameThread.interrupt();
  gameThread=null;
  surfaceView=null;
  GLRenderer.allLoaded=false;
  renderer=null;
  weaponManager=null;
}
Program: 19944
Project: 19944
Buggy source:
/** 
 * P�ivitt�� t�htitaustan.
 */
private void updateBackgroundStars(){
  backgroundManager.updatePositions();
}

Fixed version (ground truth):
/** 
 * P�ivitt�� t�htitaustan.
 */
private void updateBackgroundStars(){
}
Program: 19946
Project: 19946
Buggy source:
public BackgroundManager(Wrapper _wrapper){
  backgroundStars=new BackgroundStar[15];
  for (int i=0; i < 15; ++i) {
    backgroundStars[i]=new BackgroundStar(Utility.getRandom(-(Options.scaledScreenWidth / 2),Options.scaledScreenWidth / 2),Utility.getRandom(-(Options.scaledScreenHeight / 2),Options.scaledScreenHeight / 2),_wrapper);
  }
}

Fixed version (ground truth):
public BackgroundManager(Wrapper _wrapper){
  backgroundStars=new BackgroundStar[15];
  for (int i=0; i < 15; ++i) {
    backgroundStars[i]=new BackgroundStar(Utility.getRandom(-(Options.scaledScreenWidth),Options.scaledScreenWidth),Utility.getRandom(-(Options.scaledScreenHeight),Options.scaledScreenHeight),_wrapper);
    backgroundStars[i].direction=Utility.getRandom(0,359);
  }
}
Program: 19947
Project: 19947
Buggy source:
/** 
 * Tarkistetaan t�hden sijainti ja siirret��n, mik�li se on ulkona kuvasta.
 */
public void updatePosition(){
  if (x < CameraManager.xTranslate - 600) {
    x=Utility.getRandom((int)CameraManager.xTranslate + 420,(int)CameraManager.xTranslate + 590);
    y=Utility.getRandom((int)CameraManager.yTranslate - 235,(int)CameraManager.yTranslate + 235);
  }
 else   if (x > CameraManager.xTranslate + 600) {
    x=Utility.getRandom((int)CameraManager.xTranslate - 590,(int)CameraManager.xTranslate - 420);
    y=Utility.getRandom((int)CameraManager.yTranslate - 235,(int)CameraManager.yTranslate + 235);
  }
 else   if (y < CameraManager.yTranslate - 400) {
    x=Utility.getRandom((int)CameraManager.xTranslate - 395,(int)CameraManager.xTranslate + 395);
    y=Utility.getRandom((int)CameraManager.yTranslate + 245,(int)CameraManager.yTranslate + 390);
  }
 else   if (y > CameraManager.yTranslate + 400) {
    x=Utility.getRandom((int)CameraManager.xTranslate - 395,(int)CameraManager.xTranslate + 395);
    y=Utility.getRandom((int)CameraManager.yTranslate - 390,(int)CameraManager.yTranslate - 245);
  }
}

Fixed version (ground truth):
/** 
 * Tarkistetaan t�hden sijainti ja siirret��n, mik�li se on ulkona kuvasta.
 */
public void updatePosition(){
  int tempWidth=(int)((float)Options.screenWidth / 2);
  int tempHeight=(int)((float)Options.screenHeight / 2);
  if (x < CameraManager.xTranslate - tempWidth - Options.scaledScreenWidth) {
    x=Utility.getRandom((int)CameraManager.xTranslate + tempWidth + 10,(int)CameraManager.xTranslate + tempWidth + Options.scaledScreenWidth - 30);
    y=Utility.getRandom((int)CameraManager.yTranslate - tempHeight - Options.scaledScreenHeight + 20,(int)CameraManager.yTranslate + tempHeight + Options.scaledScreenHeight - 20);
  }
 else   if (x > CameraManager.xTranslate + tempWidth + Options.scaledScreenWidth) {
    x=Utility.getRandom((int)CameraManager.xTranslate - tempWidth - Options.scaledScreenWidth + 30,(int)CameraManager.xTranslate - tempWidth - 10);
    y=Utility.getRandom((int)CameraManager.yTranslate - tempHeight - Options.scaledScreenHeight + 20,(int)CameraManager.yTranslate + tempHeight + Options.scaledScreenHeight - 20);
  }
 else   if (y < CameraManager.yTranslate - tempHeight - Options.scaledScreenHeight) {
    x=Utility.getRandom((int)CameraManager.xTranslate - tempWidth - Options.scaledScreenWidth + 30,(int)CameraManager.xTranslate + tempWidth + Options.scaledScreenWidth - 30);
    y=Utility.getRandom((int)CameraManager.yTranslate + tempHeight + 10,(int)CameraManager.yTranslate + tempHeight + Options.scaledScreenHeight - 20);
  }
 else   if (y > CameraManager.yTranslate + tempHeight + Options.scaledScreenHeight) {
    x=Utility.getRandom((int)CameraManager.xTranslate - tempWidth - Options.scaledScreenWidth + 30,(int)CameraManager.xTranslate + tempWidth + Options.scaledScreenWidth - 30);
    y=Utility.getRandom((int)CameraManager.yTranslate - tempHeight - Options.scaledScreenHeight + 20,(int)CameraManager.yTranslate - tempHeight - 10);
  }
}
Program: 19948
Project: 19948
Buggy source:
/** 
 * Piirt�� objektin k�yt�ss� olevan tekstuurin tai animaation ruudulle.
 * @param GL10 OpenGL-konteksti
 */
@Override public void draw(GL10 _gl){
  GLRenderer.starBackgroundTexture.draw(_gl,x,y,0,currentFrame);
}

Fixed version (ground truth):
/** 
 * Piirt�� objektin k�yt�ss� olevan tekstuurin tai animaation ruudulle.
 * @param GL10 OpenGL-konteksti
 */
@Override public void draw(GL10 _gl){
  GLRenderer.starBackgroundTexture.draw(_gl,x,y,direction,currentFrame);
}
Program: 19949
Project: 19949
Buggy source:
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  if (gameThread != null) {
    _gl.glClearColor(0,0,0,0);
    _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    if (gameThread.gameState == GameThread.GAMESTATE_LOADING_RESOURCES) {
      loadingTexture.draw(_gl,0,0,90,0);
      if (!loadingStarted && !allLoaded) {
        loadingStarted=true;
      }
 else       if (loadingStarted && !allLoaded) {
        if (loadTextures(_gl)) {
          allLoaded=true;
        }
 else {
          System.exit(0);
        }
      }
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STORY) {
      storyTexture.draw(_gl,0,0,90,0);
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STARTUP) {
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_GAME) {
      if (allLoaded && gameThread.allLoaded) {
        renderScene(_gl);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  if (gameThread != null) {
    _gl.glClearColor(0.0f,0.0f,0.0f,0);
    _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    if (gameThread.gameState == GameThread.GAMESTATE_LOADING_RESOURCES) {
      if (loadingTexture == null) {
        loadingTexture=new GLSpriteSet(_gl,context,R.drawable.loading,1);
        storyTexture=new GLSpriteSet(_gl,context,R.drawable.story1,1);
      }
      loadingTexture.draw(_gl,0,0,90,0);
      if (!loadingStarted && !allLoaded) {
        loadingStarted=true;
      }
 else       if (loadingStarted && !allLoaded) {
        if (loadTextures(_gl)) {
          allLoaded=true;
        }
 else {
          System.exit(0);
        }
      }
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STORY) {
      storyTexture.draw(_gl,0,0,90,0);
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_STARTUP) {
    }
 else     if (gameThread.gameState == GameThread.GAMESTATE_GAME) {
      if (allLoaded && gameThread.allLoaded) {
        renderScene(_gl);
      }
    }
  }
}
Program: 19950
Project: 19950
Buggy source:
/** 
 * M��ritt�� OpenGL-asetukset ja lataa tekstuurit. Android kutsuu t�t� automaattisesti.
 * @param _gl     OpenGL-konteksti
 * @param _config OpenGL-asetukset
 */
public void onSurfaceCreated(GL10 _gl,EGLConfig _config){
  _gl.glShadeModel(GL10.GL_FLAT);
  _gl.glClearColor(0.0f,0.0f,0.0f,0.5f);
  _gl.glEnable(GL10.GL_ALPHA_TEST);
  _gl.glAlphaFunc(GL10.GL_GREATER,0);
  _gl.glEnable(GL10.GL_BLEND);
  _gl.glBlendFunc(GL10.GL_ONE,GL10.GL_ONE_MINUS_SRC_ALPHA);
  _gl.glEnable(GL10.GL_DEPTH_TEST);
  _gl.glClearDepthf(1.0f);
  _gl.glEnable(GL10.GL_TEXTURE_2D);
  _gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  _gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  loadingTexture=new GLSpriteSet(_gl,context,R.drawable.loading,1);
  storyTexture=new GLSpriteSet(_gl,context,R.drawable.story1,1);
}

Fixed version (ground truth):
/** 
 * M��ritt�� OpenGL-asetukset ja lataa tekstuurit. Android kutsuu t�t� automaattisesti.
 * @param _gl     OpenGL-konteksti
 * @param _config OpenGL-asetukset
 */
public void onSurfaceCreated(GL10 _gl,EGLConfig _config){
  _gl.glShadeModel(GL10.GL_FLAT);
  _gl.glClearColor(0.0f,0.0f,0.0f,0.5f);
  _gl.glEnable(GL10.GL_ALPHA_TEST);
  _gl.glAlphaFunc(GL10.GL_GREATER,0);
  _gl.glEnable(GL10.GL_BLEND);
  _gl.glBlendFunc(GL10.GL_ONE,GL10.GL_ONE_MINUS_SRC_ALPHA);
  _gl.glEnable(GL10.GL_DEPTH_TEST);
  _gl.glClearDepthf(1.0f);
  _gl.glEnable(GL10.GL_TEXTURE_2D);
  _gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  _gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
Program: 19951
Project: 19951
Buggy source:
/** 
 * Alustaa luokan muuttujat.
 * @param _gl        OpenGL-konteksti
 * @param _context   Ohjelman konteksti
 * @param _resources Ohjelman resurssit
 * @param _id        Tekstuurin tunnus
 * @param _length    Animaation pituus
 */
public GLSpriteSet(GL10 _gl,Context _context,int _id,int _length){
  sprites=new int[1];
  _gl.glGenTextures(length,sprites,0);
  if (!GLRenderer.loadingFailed) {
    length=_length;
    if (!loadBitmap(_context,_id,_gl)) {
      GLRenderer.loadingFailed=true;
    }
 else {
      createVertices();
      createBuffers();
    }
  }
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat.
 * @param _gl        OpenGL-konteksti
 * @param _context   Ohjelman konteksti
 * @param _resources Ohjelman resurssit
 * @param _id        Tekstuurin tunnus
 * @param _length    Animaation pituus
 */
public GLSpriteSet(GL10 _gl,Context _context,int _id,int _length){
  sprites=new int[1];
  _gl.glGenTextures(1,sprites,0);
  if (!GLRenderer.loadingFailed) {
    length=_length;
    if (!loadBitmap(_context,_id,_gl)) {
      GLRenderer.loadingFailed=true;
    }
 else {
      createVertices();
      createBuffers();
    }
  }
}
Program: 19952
Project: 19952
Buggy source:
/** 
 * Piirt�� tekstuurin ruudulle.
 * @param _gl		 OpenGL-konteksti
 * @param _x         Tekstuurin X-koordinaatti
 * @param _y         Tekstuurin Y-koordinaatti
 * @param _direction Tekstuurin suunta (0 = oikealle)
 * @param _frame     Tekstuurin j�rjestysnumero (animaatioille, tekstuureilla aina 0)
 */
public final void draw(GL10 _gl,float _x,float _y,int _direction,int _frame){
  _gl.glLoadIdentity();
  _gl.glTranslatef(_x - CameraManager.xTranslate,_y - CameraManager.yTranslate,0);
  _gl.glRotatef((float)_direction - 90.0f,0.0f,0.0f,1.0f);
  _gl.glScalef(Options.scale / 2,Options.scale / 2,0.0f);
  if (cachedTexture != sprites[0] || cachedTexture == -1) {
    _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
    cachedTexture=sprites[0];
  }
  if (length > 1) {
    if (cachedFrame != _frame) {
      float temp=((realWidth / (float)length) / imageWidth);
      float tempLeft=temp * _frame;
      float tempRight=temp * (_frame + 1);
      texture[0]=tempLeft;
      texture[1]=1.0f;
      texture[2]=tempLeft;
      texture[3]=0.0f;
      texture[4]=tempRight;
      texture[5]=1.0f;
      texture[6]=tempRight;
      texture[7]=0.0f;
      ByteBuffer byteBuffer=ByteBuffer.allocateDirect(vertices.length * 4);
      byteBuffer.order(ByteOrder.nativeOrder());
      textureBuffer=byteBuffer.asFloatBuffer();
      textureBuffer.put(texture);
      textureBuffer.position(0);
      textureBuffer.clear();
      cachedFrame=_frame;
    }
  }
  _gl.glFrontFace(GL10.GL_CW);
  _gl.glVertexPointer(3,GL10.GL_FLOAT,0,vertexBuffer);
  _gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
  _gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,vertices.length / 3);
}

Fixed version (ground truth):
/** 
 * Piirt�� tekstuurin ruudulle.
 * @param _gl		 OpenGL-konteksti
 * @param _x         Tekstuurin X-koordinaatti
 * @param _y         Tekstuurin Y-koordinaatti
 * @param _direction Tekstuurin suunta (0 = oikealle)
 * @param _frame     Tekstuurin j�rjestysnumero (animaatioille, tekstuureilla aina 0)
 */
public final void draw(GL10 _gl,float _x,float _y,int _direction,int _frame){
  _gl.glLoadIdentity();
  _gl.glTranslatef(_x - CameraManager.xTranslate,_y - CameraManager.yTranslate,0);
  _gl.glRotatef((float)_direction - 90.0f,0.0f,0.0f,1.0f);
  _gl.glScalef(Options.scale / 2,Options.scale / 2,0.0f);
  if (cachedTexture != sprites[0] || cachedTexture == -1) {
    _gl.glBindTexture(GL10.GL_TEXTURE_2D,sprites[0]);
    generateTextureVectors(_frame);
    cachedTexture=sprites[0];
    cachedFrame=_frame;
  }
 else {
    if (cachedFrame != _frame) {
      generateTextureVectors(_frame);
      cachedFrame=_frame;
    }
  }
  _gl.glFrontFace(GL10.GL_CW);
  _gl.glVertexPointer(3,GL10.GL_FLOAT,0,vertexBuffer);
  _gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
  _gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,vertices.length / 3);
}
Program: 19955
Project: 19955
Buggy source:
/** 
 * Palauttaa osoittimen t�h�n luokkaan.
 * @return SoundManager Osoitin t�h�n luokkaan
 */
synchronized public static SoundManager getInstance(){
  if (instance == null) {
    instance=new SoundManager();
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * Palauttaa osoittimen t�h�n luokkaan.
 */
synchronized public static void getInstance(){
  if (instance == null) {
    instance=new SoundManager();
  }
}
Program: 19956
Project: 19956
Buggy source:
/** 
 * Valmistelee s�ilytyspaikan ��nille.
 * @param Context Ohjelman konteksti
 */
public static final void initSounds(Context _context){
  context=_context;
  soundPool=new SoundPool(4,AudioManager.STREAM_MUSIC,0);
  soundPoolMap=new HashMap<Integer,Integer>();
  audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  loadSounds();
}

Fixed version (ground truth):
/** 
 * Valmistelee s�ilytyspaikan ��nille.
 * @param Context Ohjelman konteksti
 */
public static final void initSounds(Context _context){
  if (soundPool == null) {
    context=_context;
    soundPool=new SoundPool(4,AudioManager.STREAM_MUSIC,0);
    soundPoolMap=new HashMap<Integer,Integer>();
    audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    loadSounds();
  }
}
Program: 19957
Project: 19957
Buggy source:
/** 
 * P�ivitt�� vihollisten aloituspisteet kameran koordinaattien perusteella.
 */
protected void generateSpawnPoints(){
  for (int i=1; i < 8; ++i) {
    for (int j=0; j < 2; ++j) {
      spawnPoints[i][j][0]=(int)(Utility.getRandom(-3000,3000));
      spawnPoints[i][j][1]=(int)(Utility.getRandom(-3000,3000));
    }
  }
}

Fixed version (ground truth):
/** 
 * P�ivitt�� vihollisten aloituspisteet kameran koordinaattien perusteella.
 */
protected void generateSpawnPoints(){
  for (int i=1; i < 8; ++i) {
    for (int j=0; j < 2; ++j) {
      spawnPoints[i][j][0]=(int)(Utility.getRandom(-mapWidth,mapWidth));
      spawnPoints[i][j][1]=(int)(Utility.getRandom(-mapHeight,mapHeight));
      if (spawnPoints[i][j][0] > -Options.scaledScreenWidth * 2 && spawnPoints[i][j][0] < Options.scaledScreenWidth * 2) {
        if (spawnPoints[i][j][1] > -Options.scaledScreenHeight * 2 && spawnPoints[i][j][1] < Options.scaledScreenHeight * 2) {
          --j;
        }
      }
    }
  }
}
Program: 19959
Project: 19959
Buggy source:
/** 
 * P�ivitt�� efektien sijainnit
 */
public void updatePosition(){
  if (parentObject != null) {
    x=parentObject.x;
    y=parentObject.y;
  }
 else {
    x+=CameraManager.xTranslate;
    x+=CameraManager.xTranslate;
  }
}

Fixed version (ground truth):
/** 
 * P�ivitt�� efektien sijainnit
 */
public void updatePosition(){
  if (parentObject != null) {
    x=parentObject.x;
    y=parentObject.y;
  }
}
Program: 19962
Project: 19962
Buggy source:
/** 
 * K�sittelee t�rm�ykset.
 * @param _damage Osuman aiheuttama vahinko
 * @param _armorPiercing Osuman kyky l�p�ist� suojat (k�ytet��n, kun t�rm�ttiin ammukseen)
 */
@Override public final void triggerCollision(int _damage,int _armorPiercing){
  VibrateManager.vibrateOnHit();
  if (currentArmor > 0) {
    EffectManager.showPlayerArmorEffect(this);
    EffectManager.showArmorHitEffect(Hud.armorBar.x,Hud.armorBar.y);
  }
 else {
    EffectManager.showHealthHitEffect(Hud.healthBar.x,Hud.healthBar.y);
  }
  Utility.checkDamage(this,_damage,_armorPiercing);
  Hud.armorBar.updateValue(currentArmor);
  Hud.healthBar.updateValue(currentHealth);
  if (currentHealth <= 0 && wrapper.playerState == Wrapper.FULL_ACTIVITY) {
    wrapper.playerState=Wrapper.ONLY_ANIMATION;
    setAction(GLRenderer.ANIMATION_DESTROY,1,1,GfxObject.ACTION_DESTROYED,0,0);
  }
}

Fixed version (ground truth):
/** 
 * K�sittelee t�rm�ykset.
 * @param _damage Osuman aiheuttama vahinko
 * @param _armorPiercing Osuman kyky l�p�ist� suojat (k�ytet��n, kun t�rm�ttiin ammukseen)
 */
@Override public final void triggerCollision(int _damage,int _armorPiercing){
  VibrateManager.vibrateOnHit();
  if (currentArmor > 0) {
    EffectManager.showPlayerArmorEffect(this);
    EffectManager.showArmorHitEffect(Hud.armorBar.x,Hud.armorBar.y);
  }
 else {
    EffectManager.showHealthHitEffect(Hud.healthBar.x,Hud.healthBar.y);
  }
  Utility.checkDamage(this,_damage,_armorPiercing);
  hud.armorBar.updateValue(currentArmor);
  hud.healthBar.updateValue(currentHealth);
  if (currentHealth <= 0 && wrapper.playerState == Wrapper.FULL_ACTIVITY) {
    wrapper.playerState=Wrapper.ONLY_ANIMATION;
    setAction(GLRenderer.ANIMATION_DESTROY,1,1,GfxObject.ACTION_DESTROYED,0,0);
  }
}
Program: 19963
Project: 19963
Buggy source:
/** 
 * Alustaa luokan muuttujat.
 * @param _health Pelaajan el�m�t/kest�vyys
 * @param _armor Pelaajan puolustus
 * @param _gameMode Osoitin SurvivalModeen
 */
public Player(int _health,int _armor,GameMode _gameMode){
  super(6);
  wrapper=Wrapper.getInstance();
  gameMode=_gameMode;
  health=_health;
  currentHealth=_health;
  armor=_armor;
  currentArmor=_armor;
  Hud.healthBar.initBar(health);
  Hud.armorBar.initBar(armor);
  collisionRadius=(int)(25 * Options.scale);
  animationLength=new int[GLRenderer.AMOUNT_OF_PLAYER_ANIMATIONS];
  for (int i=0; i < GLRenderer.AMOUNT_OF_PLAYER_ANIMATIONS; ++i) {
    if (GLRenderer.playerAnimations[i] != null) {
      animationLength[i]=GLRenderer.playerAnimations[i].length;
    }
  }
  wrapper.addToList(this,Wrapper.CLASS_TYPE_PLAYER,4);
  ai=new PlayerAi(0,Wrapper.CLASS_TYPE_PLAYER);
  setMovementSpeed(0.0f);
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat.
 * @param _health Pelaajan el�m�t/kest�vyys
 * @param _armor Pelaajan puolustus
 * @param _gameMode Osoitin SurvivalModeen
 */
public Player(int _health,int _armor,GameMode _gameMode,Hud _hud){
  super(6);
  wrapper=Wrapper.getInstance();
  gameMode=_gameMode;
  hud=_hud;
  health=_health;
  currentHealth=_health;
  armor=_armor;
  currentArmor=_armor;
  Hud.healthBar.initBar(health);
  Hud.armorBar.initBar(armor);
  collisionRadius=(int)(25 * Options.scale);
  animationLength=new int[GLRenderer.AMOUNT_OF_PLAYER_ANIMATIONS];
  for (int i=0; i < GLRenderer.AMOUNT_OF_PLAYER_ANIMATIONS; ++i) {
    if (GLRenderer.playerAnimations[i] != null) {
      animationLength[i]=GLRenderer.playerAnimations[i].length;
    }
  }
  wrapper.addToList(this,Wrapper.CLASS_TYPE_PLAYER,4);
  ai=new PlayerAi(0,Wrapper.CLASS_TYPE_PLAYER);
  setMovementSpeed(0.0f);
}
Program: 19964
Project: 19964
Buggy source:
/** 
 * Luo pelikent�n taustat�hdet.
 */
private void generateStarBackground(){
  for (int i=0; i < 15; ++i) {
    backgroundStars[i]=new BackgroundStar(Utility.getRandom(-400,400),Utility.getRandom(-240,240));
  }
}

Fixed version (ground truth):
/** 
 * Luo pelikent�n taustat�hdet.
 */
private void generateStarBackground(){
  for (int i=0; i < 15; ++i) {
    backgroundStars[i]=new BackgroundStar(Utility.getRandom(-halfOfScreenWidth,halfOfScreenWidth),Utility.getRandom(-halfOfScreenHeight,halfOfScreenHeight));
  }
}
Program: 19965
Project: 19965
Buggy source:
/** 
 * K�sittelee objektin t�rm�ystarkistukset.
 */
public final void checkCollision(){
  for (int i=wrapper.collectables.size() - 1; i >= 0; --i) {
    if (Math.abs(x - wrapper.collectables.get(i).x) <= Wrapper.gridSize) {
      if (Math.abs(y - wrapper.collectables.get(i).y) <= Wrapper.gridSize) {
        if (Utility.isColliding(wrapper.collectables.get(i),this)) {
          wrapper.collectables.get(i).triggerCollision(0,0);
        }
      }
    }
  }
  if (Math.abs(wrapper.mothership.x - x) <= Wrapper.gridSize) {
    if (Math.abs(wrapper.mothership.y - y) <= Wrapper.gridSize) {
      if (Utility.isColliding(wrapper.mothership,this)) {
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * K�sittelee objektin t�rm�ystarkistukset.
 */
public final void checkCollision(){
  for (int i=wrapper.collectables.size() - 1; i >= 0; --i) {
    if (wrapper.collectableStates.get(i) == Wrapper.FULL_ACTIVITY) {
      if (Math.abs(x - wrapper.collectables.get(i).x) <= Wrapper.gridSize) {
        if (Math.abs(y - wrapper.collectables.get(i).y) <= Wrapper.gridSize) {
          if (Utility.isColliding(wrapper.collectables.get(i),this)) {
            wrapper.collectables.get(i).triggerCollision(0,0);
          }
        }
      }
    }
  }
  if (Math.abs(wrapper.mothership.x - x) <= Wrapper.gridSize) {
    if (Math.abs(wrapper.mothership.y - y) <= Wrapper.gridSize) {
      if (Utility.isColliding(wrapper.mothership,this)) {
      }
    }
  }
}
Program: 19968
Project: 19968
Buggy source:
/** 
 * P�ivitt�� pisteet.
 * @param _rank Tuhotun vihollisen taso, jonka perusteella pisteit� lis�t��n
 * @param _x    X-koordinaatti
 * @param _y    Y-koordinaatti
 */
public static void updateScore(int _rank,float _x,float _y){
  if (lastTime == 0) {
    lastTime=android.os.SystemClock.uptimeMillis();
    score+=(10 * _rank + 5 * _rank * currentWave);
  }
 else {
    newTime=android.os.SystemClock.uptimeMillis();
    if (newTime - lastTime <= 700) {
      ++comboMultiplier;
      score+=(10 * _rank + 5 * _rank * currentWave) * comboMultiplier;
      EffectManager.showComboMultiplier(comboMultiplier,_x,_y);
    }
 else {
      score+=(10 * _rank + 5 * _rank * currentWave);
      comboMultiplier=1;
      lastTime=android.os.SystemClock.uptimeMillis();
    }
  }
  Hud.updateScoreCounter(score);
}

Fixed version (ground truth):
/** 
 * P�ivitt�� pisteet.
 * @param _rank Tuhotun vihollisen taso, jonka perusteella pisteit� lis�t��n
 * @param _x    X-koordinaatti
 * @param _y    Y-koordinaatti
 */
public static void updateScore(int _rank,float _x,float _y){
  _rank*=18;
  if (lastTime == 0) {
    lastTime=android.os.SystemClock.uptimeMillis();
    score+=(10 * _rank + 5 * _rank * currentWave);
  }
 else {
    newTime=android.os.SystemClock.uptimeMillis();
    if (newTime - lastTime <= 700) {
      ++comboMultiplier;
      score+=(10 * _rank + 5 * _rank * currentWave) * comboMultiplier;
      EffectManager.showComboMultiplier(comboMultiplier,_x,_y);
    }
 else {
      score+=(10 * _rank + 5 * _rank * currentWave);
      comboMultiplier=1;
      lastTime=android.os.SystemClock.uptimeMillis();
    }
  }
  Hud.updateScoreCounter(score);
}
Program: 19969
Project: 19969
Buggy source:
/** 
 * P�ivitt�� obstacle-objektit
 */
protected void generateObstacles(){
  asteroids[0]=new Obstacle(1,-400,-400,randSpeed,randDirection);
  asteroids[1]=new Obstacle(1,800,800,randSpeed,randDirection);
  asteroids[2]=new Obstacle(1,-1200,400,randSpeed,randDirection);
  planets[0]=new Obstacle(0,0,-600,0,0);
  planets[1]=new Obstacle(0,800,0,0,0);
}

Fixed version (ground truth):
/** 
 * P�ivitt�� obstacle-objektit
 */
protected void generateObstacles(){
  int randDirection=Utility.getRandom(0,359);
  asteroids[0]=new Obstacle(1,-400,-400,2,randDirection);
  asteroids[1]=new Obstacle(1,800,800,2,randDirection);
  asteroids[2]=new Obstacle(1,-1200,400,2,randDirection);
  planets[0]=new Obstacle(0,0,-600,0,0);
  planets[1]=new Obstacle(0,800,0,0,0);
}
Program: 19970
Project: 19970
Buggy source:
/** 
 * Alustaa luokan muuttujat.
 * @param _type      Objektin tyyppi (tekstuurit m��ritell��n t�m�n perusteella)
 * @param _x         X-koordinaatti
 * @param _y         Y-koordinaatti
 * @param _speed     Liikkumisnopeus
 * @param _direction Liikkumissuunta
 */
public Obstacle(int _type,int _x,int _y,int _speed,int _direction){
  super(_speed);
  x=_x;
  y=_y;
  wrapper=Wrapper.getInstance();
  type=_type;
  if (type == OBSTACLE_PLANET || type == OBSTACLE_ASTEROID) {
    facingTurningDirection=Utility.getRandom(1,2);
  }
  if (type == OBSTACLE_PLANET) {
    setFacingTurningSpeed(1.0f);
    setFacingTurningDelay(0.03f);
  }
 else   if (type == OBSTACLE_ASTEROID) {
    setFacingTurningSpeed(1.0f);
    setFacingTurningDelay(0.25f);
  }
  if (type == OBSTACLE_PLANET) {
    collisionRadius=(int)(128 * Options.scale);
  }
 else   if (type == OBSTACLE_ASTEROID) {
    collisionRadius=(int)(54 * Options.scale);
  }
 else   if (type == OBSTACLE_STAR) {
    collisionRadius=(int)(245 * Options.scale);
  }
  listId=wrapper.addToList(this,Wrapper.CLASS_TYPE_OBSTACLE,0);
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat.
 * @param _type      Objektin tyyppi (tekstuurit m��ritell��n t�m�n perusteella)
 * @param _x         X-koordinaatti
 * @param _y         Y-koordinaatti
 * @param _speed     Liikkumisnopeus
 * @param _direction Liikkumissuunta
 */
public Obstacle(int _type,int _x,int _y,int _speed,int _direction){
  super(_speed);
  x=_x;
  y=_y;
  wrapper=Wrapper.getInstance();
  type=_type;
  if (type == OBSTACLE_PLANET || type == OBSTACLE_ASTEROID) {
    facingTurningDirection=Utility.getRandom(1,2);
  }
  if (type == OBSTACLE_PLANET) {
    setFacingTurningSpeed(1.0f);
    setFacingTurningDelay(0.03f);
  }
 else   if (type == OBSTACLE_ASTEROID) {
    setFacingTurningSpeed(1.0f);
    setFacingTurningDelay(0.25f);
  }
  if (type == OBSTACLE_PLANET) {
    collisionRadius=(int)(125 * Options.scale);
  }
 else   if (type == OBSTACLE_ASTEROID) {
    collisionRadius=(int)(50 * Options.scale);
  }
 else   if (type == OBSTACLE_STAR) {
    collisionRadius=(int)(260 * Options.scale);
  }
  listId=wrapper.addToList(this,Wrapper.CLASS_TYPE_OBSTACLE,0);
}
Program: 19971
Project: 19971
Buggy source:
/** 
 * K�sittelee objektin t�rm�ystarkistukset.
 */
public final void checkCollision(){
  for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
    if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
      if (Math.abs(x - wrapper.enemies.get(i).x) <= Wrapper.gridSize) {
        if (Math.abs(y - wrapper.enemies.get(i).y) <= Wrapper.gridSize) {
          if (Utility.isColliding(wrapper.enemies.get(i),this)) {
            wrapper.enemies.get(i).triggerCollision(GameObject.COLLISION_WITH_OBSTACLE,0,0);
          }
        }
      }
    }
  }
  for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
    if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
      if (Math.abs(x - wrapper.projectiles.get(i).x) <= Wrapper.gridSize) {
        if (Math.abs(y - wrapper.projectiles.get(i).y) <= Wrapper.gridSize) {
          if (Utility.isColliding(wrapper.projectiles.get(i),this)) {
            wrapper.projectiles.get(i).triggerCollision(GameObject.COLLISION_WITH_OBSTACLE,0,0);
          }
        }
      }
    }
  }
  if (Math.abs(x - wrapper.player.x) <= Wrapper.gridSize) {
    if (Math.abs(y - wrapper.player.y) <= Wrapper.gridSize) {
      if (Utility.isColliding(wrapper.player,this)) {
        wrapper.player.triggerCollision(10,20);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * K�sittelee objektin t�rm�ystarkistukset.
 */
public final void checkCollision(){
  for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
    if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
      if (Math.abs(x - wrapper.enemies.get(i).x) <= Wrapper.gridSize) {
        if (Math.abs(y - wrapper.enemies.get(i).y) <= Wrapper.gridSize) {
          if (Utility.isColliding(wrapper.enemies.get(i),this)) {
            wrapper.enemies.get(i).triggerCollision(GameObject.COLLISION_WITH_OBSTACLE,0,0);
          }
        }
      }
    }
  }
  for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
    if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
      if (Math.abs(x - wrapper.projectiles.get(i).x) <= Wrapper.gridSize) {
        if (Math.abs(y - wrapper.projectiles.get(i).y) <= Wrapper.gridSize) {
          if (Utility.isColliding(wrapper.projectiles.get(i),this)) {
            wrapper.projectiles.get(i).triggerCollision(GameObject.COLLISION_WITH_OBSTACLE,0,0);
          }
        }
      }
    }
  }
  if (Math.abs(x - wrapper.player.x) <= Wrapper.gridSize) {
    if (Math.abs(y - wrapper.player.y) <= Wrapper.gridSize) {
      if (Utility.isColliding(wrapper.player,this)) {
        wrapper.player.triggerCollision(1000,20);
      }
    }
  }
}
Program: 19972
Project: 19972
Buggy source:
/** 
 * K�sittelee t�rm�ykset.
 * @param _damage Osuman aiheuttama vahinko
 * @param _armorPiercing Osuman kyky l�p�ist� suojat (k�ytet��n, kun t�rm�ttiin ammukseen)
 */
@Override public final void triggerCollision(int _damage,int _armorPiercing){
  VibrateManager.vibrateOnHit();
  if (currentArmor > 0) {
    EffectManager.showPlayerArmorEffect(this);
  }
  Utility.checkDamage(this,_damage,_armorPiercing);
  Hud.armorBar.updateValue(currentArmor);
  Hud.healthBar.updateValue(currentHealth);
  if (currentHealth <= 0) {
    wrapper.playerState=Wrapper.ONLY_ANIMATION;
    setAction(GLRenderer.ANIMATION_DESTROY,1,1,GfxObject.ACTION_DESTROYED);
  }
}

Fixed version (ground truth):
/** 
 * K�sittelee t�rm�ykset.
 * @param _damage Osuman aiheuttama vahinko
 * @param _armorPiercing Osuman kyky l�p�ist� suojat (k�ytet��n, kun t�rm�ttiin ammukseen)
 */
@Override public final void triggerCollision(int _damage,int _armorPiercing){
  VibrateManager.vibrateOnHit();
  if (currentArmor > 0) {
    EffectManager.showPlayerArmorEffect(this);
  }
  Utility.checkDamage(this,_damage,_armorPiercing);
  Hud.armorBar.updateValue(currentArmor);
  Hud.healthBar.updateValue(currentHealth);
  if (currentHealth <= 0 && wrapper.playerState == Wrapper.FULL_ACTIVITY) {
    wrapper.playerState=Wrapper.ONLY_ANIMATION;
    setAction(GLRenderer.ANIMATION_DESTROY,1,1,GfxObject.ACTION_DESTROYED);
  }
}
Program: 19973
Project: 19973
Buggy source:
/** 
 * Laskee aiheutuneen vahingon m��r�n suojiin.
 * @param _damage Vaurion m��r�
 * @param _armorPiercing L�p�isykyky
 * @return Aiheutunut vahinko
 */
public static final int calculateDamageToArmor(int _damage,int _armorPiercing){
  return (int)((float)_damage * (1 - (float)_armorPiercing * 0.05));
}

Fixed version (ground truth):
/** 
 * Laskee aiheutuneen vahingon m��r�n suojiin.
 * @param _damage Vaurion m��r�
 * @param _armorPiercing L�p�isykyky
 * @return Aiheutunut vahinko
 */
public static final int calculateDamageToArmor(int _damage,int _armorPiercing){
  float multiplier=1.0f - (float)_armorPiercing * 0.05f;
  if (multiplier >= 0) {
    return (int)((float)_damage * multiplier);
  }
 else {
    return _damage;
  }
}