class repl_GT extends KFStoryGameInfo;


// we have some SteamStatsAndAchievements none errors on game startup
// Engine.GameInfo
event PostLogin(PlayerController NewPlayer)
{
  local class<HUD> HudClass;
  local class<Scoreboard> ScoreboardClass;

  if (!bIsSaveGame)
  {
    // Log player's login.
    if (GameStats != none)
    {
      GameStats.ConnectEvent(NewPlayer.PlayerReplicationInfo);
      GameStats.GameEvent("NameChange",NewPlayer.PlayerReplicationInfo.playername,NewPlayer.PlayerReplicationInfo);
    }

    if (!bDelayedStart)
    {
      // start match, or let player enter, immediately
      bRestartLevel = false;  // let player spawn once in levels that must be restarted after every death
      if (bWaitingToStartMatch)
        StartMatch();
      else
        RestartPlayer(newPlayer);
      bRestartLevel = default.bRestartLevel;
    }
  }

  // tell client what hud and scoreboard to use
  if (HUDType == "")
    log("No HUDType specified in GameInfo", 'Log');
  else
  {
    HudClass = class<HUD>(DynamicLoadObject(HUDType, class'Class'));

    if (HudClass == none)
      log("Can't find HUD class "$HUDType, 'Error');
  }

  if (ScoreBoardType != "")
  {
    ScoreboardClass = class<Scoreboard>(DynamicLoadObject(ScoreBoardType, class'Class'));

    if (ScoreboardClass == none)
      log("Can't find ScoreBoard class "$ScoreBoardType, 'Error');
  }

  NewPlayer.ClientSetHUD(HudClass, ScoreboardClass);
  SetWeaponViewShake(NewPlayer);

  if (bIsSaveGame)
    return;

  if (NewPlayer.Pawn != none)
    NewPlayer.Pawn.ClientSetRotation(NewPlayer.Pawn.Rotation);

  if (VotingHandler != none)
    VotingHandler.PlayerJoin(NewPlayer);

  if (AccessControl != none)
    NewPlayer.LoginDelay = AccessControl.LoginDelaySeconds;

  // hmmm, maybe we can set netspeed here?
  NewPlayer.ClientCapBandwidth(NewPlayer.Player.CurrentNetSpeed);
  NotifyLogin(NewPlayer.PlayerReplicationInfo.PlayerID);

  if (Level.NetMode != NM_Client)
  {
    NewPlayer.SteamStatsAndAchievements = spawn(NewPlayer.default.SteamStatsAndAchievementsClass, NewPlayer);
    // ADDITION!!! none check
    if (NewPlayer.SteamStatsAndAchievements != none && !NewPlayer.SteamStatsAndAchievements.Initialize(NewPlayer))
    {
      NewPlayer.SteamStatsAndAchievements.destroy();
      NewPlayer.SteamStatsAndAchievements = none;
    }
  }

  log("New Player" @ NewPlayer.PlayerReplicationInfo.PlayerName @ "id=" $ NewPlayer.GetPlayerIDHash());
}

defaultproperties
{
     GameName="Dummy Floor"
     Description="Dummy Floor for tests"
     Acronym="KF"
}
