Program: 19960
Project: 19960
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,DisplayMetrics _dm,Context _context,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  halfOfScreenWidth=_dm.widthPixels;
  halfOfScreenHeight=_dm.heightPixels;
  mapWidth=1750;
  mapHeight=1250;
  overBoundWidth=mapWidth + 20;
  overBoundHeight=mapHeight + 20;
  camera=CameraManager.getInstance();
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[3];
  collectables=new Collectable[3];
  backgroundStars=new BackgroundStar[15];
  player=new Player(100,100,this);
  player.x=0;
  player.y=0;
  mothership=new Mothership(0);
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135;
  turret1.y=8;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280;
  turret2.y=-45;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332;
  turret3.y=84;
  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];
  }
  gameActivity=_gameActivity;
  weaponManager=_weaponManager;
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  spawnPoints=new int[9][3][2];
  reader.readGameMode(this,_weaponManager);
  generateStarBackground();
  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,DisplayMetrics _dm,Context _context,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  hud=_hud;
  halfOfScreenWidth=_dm.widthPixels;
  halfOfScreenHeight=_dm.heightPixels;
  mapWidth=1750;
  mapHeight=1250;
  overBoundWidth=mapWidth + 20;
  overBoundHeight=mapHeight + 20;
  camera=CameraManager.getInstance();
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[3];
  collectables=new Collectable[3];
  backgroundStars=new BackgroundStar[15];
  player=new Player(100,100,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Mothership(0);
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135;
  turret1.y=8;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280;
  turret2.y=-45;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332;
  turret3.y=84;
  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];
  }
  gameActivity=_gameActivity;
  weaponManager=_weaponManager;
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  spawnPoints=new int[9][3][2];
  reader.readGameMode(this,_weaponManager);
  generateStarBackground();
  generateMap();
  startWave();
}