class Game_Deathmatch extends xDeathMatch
             config;

var array<string> BotClass[];
var array<string> BotSkin[];

var Spot_Info Spot_Info;

struct StartSpotInfo
{
	var PlayerStart Spot;
	var Controller Player;
	var bool bTaken;
	var byte TeamNum;
	var int SpotNum;
};
var array<StartSpotInfo> StartSpots;

var vector		StartOffset;

event InitGame( string Options, out string Error)
{
 AddToPackageMap("R");
 super.InitGame(Options,error);
}

static function PrecacheGameTextures(LevelInfo myLevel)
{
myLevel.AddPrecacheMaterial(Material'XEffects.TransTrailT');
}

function bool AllowTransloc()
{
	return false;
}

static function bool NeverAllowTransloc()
{
	return true;
}

function StartMatch()
{
    local int i;
    GotoState('MatchInProgress');
	Super(GameInfo).StartMatch();
	for (i = 0; i < StartSpots.Length; i++)
	StartSpots[i].bTaken = False;
}


function PostBeginPlay()
{

    local Spot_Info RCI;
	local PlayerStart PS;

	foreach AllActors (class'Spot_Info', RCI)
		Spot_Info = RCI;

	if (Spot_Info == None)
		Spot_Info = Spawn(class'Spot_Info', Self);

	foreach AllActors(class'PlayerStart', PS)
	{
		if (PS == None)
			continue;
		StartSpots.Length = StartSpots.Length + 1;
		StartSpots[StartSpots.Length-1].Spot = PS;
		StartSpots[StartSpots.Length-1].bTaken = False;
		StartSpots[StartSpots.Length-1].TeamNum = PS.TeamNumber;
		StartSpots[StartSpots.Length-1].Player = None;
		StartSpots[StartSpots.Length-1].SpotNum = StartSpots.Length-1;
	}
 	Super.PostBeginPlay();
}

event PlayerController Login(string Portal, string Options, out string Error)
{
	local PlayerController NewPlayer; //

	NewPlayer = Super.Login(Portal,Options,Error);
   	if (NewPlayer.PlayerReplicationInfo.bIsSpectator)
		NewPlayer.SpectateSpeed *= 2;


	if (Spot_Info == None)
		Spot_Info = Spawn(class'Spot_Info', Self);

	Player_Controller(NewPlayer).Spot_Info = Spot_Info;

	return NewPlayer;
}

event PreLogin
(
    string Options,
    string Address,
    string PlayerID,
    out string Error,
    out string FailCode
)
{}

event postlogin(playercontroller newplayer)
{
 super.postlogin(newplayer);

 if (Player_Controller(newplayer)!=none)
 {
  if(!newplayer.PlayerReplicationInfo.bIsSpectator)
    Player_Controller(newplayer).SelectCar();
 }

}

function RestartPlayer( Controller Player_Controller )
{
	if (Player_Controller.IsA('Player_Controller') == false && Player_Controller.IsA('Bot_AIController') == false)
	return;

	super.RestartPlayer(Player_Controller);
}

function bool CanLeaveVehicle(Vehicle V, Pawn P)
{
	return False;
}

function GiveCar(PlayerController PC)
{
 local Playerstart  PS;
 local Spot_Startspot Spot;

  PS = PlayerStart(PC.StartSpot);

 foreach AllActors (class'Spot_Startspot',Spot)
         if (Spot.tag == PS.event)
         {
          Spot.getcar(PC);
          break;
          }
}

function PlayerReset(Controller P, Car_R CarReset)
{
	local Mutator M;

	for (M = BaseMutator.NextMutator; M != None; M = M.NextMutator)
		if (Mutator_Base(M) != None)
			Mutator_Base(M).MutPlayerReset(P, CarReset);
}

defaultproperties
{
     BotClass(0)="R.Car_R1"
     BotSkin(0)="1"
     StartOffset=(X=150.000000)
     bAllowVehicles=True
     DefaultPlayerClassName="R.Car_R"
     MapPrefix="R"
     GoalScore=20
     TimeLimit=30
     PlayerControllerClassName="R.Player_Controller"
     GameName="R Mini-mod"
     Description="Car Deathmatch"
     Acronym="R"
}
