Program: 19958
Project: 19958
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,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  hud=_hud;
  halfOfScreenWidth=_dm.widthPixels;
  halfOfScreenHeight=_dm.heightPixels;
  mapWidth=1750;
  mapHeight=1250;
  overBoundWidth=mapWidth + 20;
  overBoundHeight=mapHeight + 20;
  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(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Mothership(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;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  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);
  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;
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[3];
  collectables=new Collectable[3];
  player=new Player(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Mothership(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;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  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);
  generateMap();
  startWave();
}