Program: 19930
Project: 19930
Buggy source:
/** 
 * Alustaa luokan muuttujat, lukee pelitilan tarvitsemat tiedot ja k�ynnist�� pelin.
 * @param GameActivity   Pelitilan aloittava aktiviteetti
 * @param DisplayMetrics N�yt�n tiedot
 * @param Context		 Ohjelman konteksti
 * @param WeaponManager  Osoitin WeaponManageriin
 */
public GameMode(GameActivity _gameActivity,GameThread _gameThread,DisplayMetrics _dm,Context _context,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  gameThread=_gameThread;
  hud=_hud;
  weaponManager=_weaponManager;
  halfOfScreenWidth=_dm.widthPixels / 2;
  halfOfScreenHeight=_dm.heightPixels / 2;
  wrapper=Wrapper.getInstance();
  mapWidth=1700;
  mapHeight=1700;
  overBoundWidth=mapWidth + 700;
  overBoundHeight=mapHeight + 700;
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[2];
  scoreCollectables=new Collectable[3];
  boundaries=new Boundary[4];
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPointsX=new int[AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPointsY=new int[AMOUNT_OF_ENEMIES_PER_WAVE];
  XmlReader reader=new XmlReader(_context);
  int[] enemyStatsTemp=reader.readEnemyRanks();
  int rank=0;
  for (int i=0; i < enemyStatsTemp.length; ++i) {
    rank=(int)(i / 5);
    enemyStats[rank][i - rank * 5]=enemyStatsTemp[i];
  }
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  player=new Player(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Boss(0);
  mothership.direction=160;
  mothership.x=100 * Options.scaleX;
  mothership.y=90 * Options.scaleY;
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135 * Options.scaleX;
  turret1.y=8 * Options.scaleY;
  turret1.state=Wrapper.FULL_ACTIVITY;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret2.state=Wrapper.FULL_ACTIVITY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  turret3.state=Wrapper.FULL_ACTIVITY;
  reader.readGameMode(this,_weaponManager);
  generateMap();
  startWave();
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat, lukee pelitilan tarvitsemat tiedot ja k�ynnist�� pelin.
 * @param GameActivity   Pelitilan aloittava aktiviteetti
 * @param DisplayMetrics N�yt�n tiedot
 * @param Context		 Ohjelman konteksti
 * @param WeaponManager  Osoitin WeaponManageriin
 */
public GameMode(GameActivity _gameActivity,GameThread _gameThread,DisplayMetrics _dm,Context _context,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  gameThread=_gameThread;
  hud=_hud;
  weaponManager=_weaponManager;
  halfOfScreenWidth=_dm.widthPixels / 2;
  halfOfScreenHeight=_dm.heightPixels / 2;
  wrapper=Wrapper.getInstance();
  mapWidth=(int)(1700 * Options.scaleX);
  mapHeight=(int)(1700 * Options.scaleY);
  overBoundWidth=(int)(mapWidth + (700 * Options.scaleX));
  overBoundHeight=(int)(mapHeight + (700 * Options.scaleY));
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[2];
  scoreCollectables=new Collectable[3];
  boundaries=new Boundary[4];
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPointsX=new int[AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPointsY=new int[AMOUNT_OF_ENEMIES_PER_WAVE];
  XmlReader reader=new XmlReader(_context);
  int[] enemyStatsTemp=reader.readEnemyRanks();
  int rank=0;
  for (int i=0; i < enemyStatsTemp.length; ++i) {
    rank=(int)(i / 5);
    enemyStats[rank][i - rank * 5]=enemyStatsTemp[i];
  }
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  player=new Player(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Boss(0);
  mothership.direction=160;
  mothership.x=100 * Options.scaleX;
  mothership.y=90 * Options.scaleY;
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135 * Options.scaleX;
  turret1.y=8 * Options.scaleY;
  turret1.state=Wrapper.FULL_ACTIVITY;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret2.state=Wrapper.FULL_ACTIVITY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  turret3.state=Wrapper.FULL_ACTIVITY;
  reader.readGameMode(this,_weaponManager);
  generateMap();
  startWave();
}