Beispiel #1
0
void Cmd_Jail_f(gentity_t *ent)
{
	char buffer[MAX_TOKEN_CHARS];
	int clientNum;

	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 2)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mjail <client-name-or-number>\n\""));
		return;
	}

	trap_Argv(1, buffer, sizeof(buffer));

	clientNum = ClientNumberFromString(ent, buffer);

	if (clientNum == -1)
	{
		MM_SendMessage(ent - g_entities, va("print \"ERROR: Could not identify player %s\n\"", buffer));
		return;
	}

	gentity_t *target = &g_entities[clientNum];

	if (target->client->sess.jailed == qfalse)
		MM_JailClient(target, qfalse);
	else
	{
		target->client->sess.jailed = qfalse;
		ClientSpawn(target); // not sure how safe this is but what the heck lmao
	}
	
}
Beispiel #2
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum )
{
  gentity_t *ent;
  gclient_t *client;
  int       flags;

  ent = g_entities + clientNum;

  client = level.clients + clientNum;

  if( ent->r.linked )
    trap_UnlinkEntity( ent );

  G_InitGentity( ent );
  ent->touch = 0;
  ent->pain = 0;
  ent->client = client;

  client->pers.connected = CON_CONNECTED;
  client->pers.enterTime = level.time;
  client->pers.teamState.state = TEAM_BEGIN;
  client->pers.classSelection = PCL_NONE;

  // save eflags around this, because changing teams will
  // cause this to happen with a valid entity, and we
  // want to make sure the teleport bit is set right
  // so the viewpoint doesn't interpolate through the
  // world to the new position
  flags = client->ps.eFlags;
  memset( &client->ps, 0, sizeof( client->ps ) );
  memset( &client->pmext, 0, sizeof( client->pmext ) );
  client->ps.eFlags = flags;

  // locate ent at a spawn point

  ClientSpawn( ent, NULL, NULL, NULL );

  trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );

  // name can change between ClientConnect() and ClientBegin()
  G_admin_namelog_update( client, qfalse );

  // request the clients PTR code
  trap_SendServerCommand( ent - g_entities, "ptrcrequest" );

  G_LogPrintf( "ClientBegin: %i\n", clientNum );

  if( g_clientUpgradeNotice.integer )
  {
    if( !Q_stricmp( ent->client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) )
    {
      trap_SendServerCommand( client->ps.clientNum, va( "print \"^1Your client is out of date. Updating your client will allow you to "
        "become an admin on servers and download maps much more quickly. Please replace your client executable with the one "
        "at ^2http://trem.tjw.org/backport/^1 and reconnect. \n\"" ) );
    }
  }

  // count current clients and rank for scoreboard
  CalculateRanks( );
}
Beispiel #3
0
/*
================
respawn
================
*/
void respawn( gentity_t *ent )
{
    int i;

    SpawnCorpse( ent );

    // Clients can't respawn - they must go through the class cmd
    ent->client->pers.classSelection = PCL_NONE;
    ClientSpawn( ent, NULL, NULL, NULL );

    // stop any following clients that don't have sticky spec on
    for( i = 0; i < level.maxclients; i++ )
    {
        if( level.clients[ i ].sess.spectatorState == SPECTATOR_FOLLOW &&
                level.clients[ i ].sess.spectatorClient == ent - g_entities )
        {
            if( !( level.clients[ i ].pers.stickySpec ) )
            {
                if( !G_FollowNewClient( &g_entities[ i ], 1 ) )
                    G_StopFollowing( &g_entities[ i ] );
            }
            else
                G_FollowLockView( &g_entities[ i ] );
        }
    }
}
void PlayerCmd_spawn(scr_entref_t arg){

    gentity_t* gentity = NULL;
    vec3_t position;
    vec3_t direction;
	mvabuf;

    int entityNum = 0;

    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
        }
    }

    Scr_GetVector(0, position);
    Scr_GetVector(1, direction);

    ClientSpawn(gentity, position, direction);

}
Beispiel #5
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum )
{
	edict_s*    ent;
	
	ent = g_entities + clientNum;
	
	if ( ent->ent == 0 )
	{
		// this should never happen
		g_core->DropError( "ClientBegin on edict without entity!" );
		return;
	}
	
	Player* pl = dynamic_cast<Player*>( ent->ent );
	
	pl->pers.connected = CON_CONNECTED;
	pl->pers.enterTime = level.time;
	
	// locate ent at a spawn point
	ClientSpawn( ent );
	
	g_server->SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", pl->getNetName() ) );
	
	G_Printf( "ClientBegin: %i\n", clientNum );
	
}
Beispiel #6
0
void G_ChangeTeam( gentity_t *ent, team_t newTeam )
{
	team_t oldTeam = (team_t) ent->client->pers.team;

	if ( oldTeam == newTeam )
	{
		return;
	}

	G_LeaveTeam( ent );
	ent->client->pers.teamChangeTime = level.time;
	ent->client->pers.team = newTeam;
	ent->client->pers.teamInfo = level.startTime - 1;
	ent->client->pers.classSelection = PCL_NONE;
	ClientSpawn( ent, nullptr, nullptr, nullptr );

	if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS )
	{
		// Convert from human to alien credits
		ent->client->pers.credit =
		  ( int )( ent->client->pers.credit *
		           ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f );
	}
	else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS )
	{
		// Convert from alien to human credits
		ent->client->pers.credit =
		  ( int )( ent->client->pers.credit *
		           HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f );
	}

	if ( !g_cheats.integer )
	{
		if ( ent->client->noclip )
		{
			ent->client->noclip = false;
			ent->r.contents = ent->client->cliprcontents;
		}
		ent->flags &= ~( FL_GODMODE | FL_NOTARGET );
	}

	// Copy credits to ps for the client
	ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit;

	// Update PERS_UNLOCKABLES in the same frame as PERS_TEAM to prevent bad status change notifications
	ent->client->ps.persistant[ PERS_UNLOCKABLES ] = BG_UnlockablesMask( newTeam );

	ClientUserinfoChanged( ent->client->ps.clientNum, false );

	G_UpdateTeamConfigStrings();

	Beacon::PropagateAll( );

	G_LogPrintf( "ChangeTeam: %d %s: %s^* switched teams",
	             ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname );

	G_namelog_update_score( ent->client );
	TeamplayInfoMessage( ent );
}
/*
================
respawn
================
*/
void respawn( gentity_t *ent )
{
  SpawnCorpse( ent );

  // Clients can't respawn - they must go through the class cmd
  ent->client->pers.classSelection = PCL_NONE;
  ClientSpawn( ent, NULL, NULL, NULL );
}
Beispiel #8
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin(int clientNum)
{
  gentity_t      *ent;
  gclient_t      *client;
  gentity_t      *tent;
  int             flags;

  ent = g_entities + clientNum;

  client = level.clients + clientNum;

  if(ent->r.linked)
  {
    trap_UnlinkEntity(ent);
  }
  G_InitGentity(ent);
  ent->touch = 0;
  ent->pain = 0;
  ent->client = client;

  client->pers.connected = CON_CONNECTED;
  client->pers.enterTime = level.time;
  client->pers.teamState.state = TEAM_BEGIN;

  // save eflags around this, because changing teams will
  // cause this to happen with a valid entity, and we
  // want to make sure the teleport bit is set right
  // so the viewpoint doesn't interpolate through the
  // world to the new position
  flags = client->ps.eFlags;
  memset(&client->ps, 0, sizeof(client->ps));
  client->ps.eFlags = flags;

  // locate ent at a spawn point
  ClientSpawn(ent);

  if(client->sess.sessionTeam != TEAM_SPECTATOR)
  {
    // send event
    tent = G_TempEntity(ent->client->ps.origin, EV_PLAYER_TELEPORT_IN);
    tent->s.clientNum = ent->s.clientNum;

    if(g_gametype.integer != GT_TOURNAMENT)
    {
      trap_SendServerCommand(-1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname));
    }
  }
  G_LogPrintf("ClientBegin: %i\n", clientNum);

  // count current clients and rank for scoreboard
  CalculateRanks();

#ifdef G_LUA
  // Lua API callbacks
  G_LuaHook_ClientBegin(clientNum);
#endif
}
Beispiel #9
0
/*
================
respawn
================
*/
void respawn( gentity_t *ent ) {
	gentity_t	*tent;

	CopyToBodyQue (ent);
	ClientSpawn(ent);

	// add a teleportation effect
	tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
	tent->s.clientNum = ent->s.clientNum;
}
Beispiel #10
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum )
{
  gentity_t *ent;
  gclient_t *client;
  int       flags;

  ent = g_entities + clientNum;

  client = level.clients + clientNum;

  // ignore if client already entered the game
  if( client->pers.connected != CON_CONNECTING )
    return;

  if( ent->r.linked )
    trap_UnlinkEntity( ent );

  G_InitGentity( ent );
  ent->touch = 0;
  ent->pain = 0;
  ent->client = client;

  client->pers.connected = CON_CONNECTED;
  client->pers.enterTime = level.time;

  // save eflags around this, because changing teams will
  // cause this to happen with a valid entity, and we
  // want to make sure the teleport bit is set right
  // so the viewpoint doesn't interpolate through the
  // world to the new position
  flags = client->ps.eFlags;
  memset( &client->ps, 0, sizeof( client->ps ) );
  memset( &client->pmext, 0, sizeof( client->pmext ) );
  client->ps.eFlags = flags;

  // locate ent at a spawn point
  ClientSpawn( ent, NULL, NULL, NULL );

  trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );

  G_namelog_restore( client );

  G_LogPrintf( "ClientBegin: %i\n", clientNum );

  // count current clients and rank for scoreboard
  CalculateRanks( );

  // send the client a list of commands that can be used
  G_ListCommands( ent );
  
  // reset cuboidSelection
  client->cuboidSelection[ 0 ] =
  client->cuboidSelection[ 1 ] =
  client->cuboidSelection[ 2 ] = 32;
}
Beispiel #11
0
/*
===============
G_RespawnClients
===============
*/
void G_RespawnClients ( bool force, team_t team )
{
	// Respawn all clients back at a spawn pointer
	for (int i = 0; i < level.numConnectedClients; i ++ )
	{
		// Save the clients weapons
		playerState_t	ps;
		bool		ghost;

		gentity_t *	ent = &g_entities[level.sortedClients[i]];

		// Make sure they are actually connected
		if ( ent->client->pers.connected != CON_CONNECTED )
		{
			continue;
		}

		// Save the entire player state so certain things
		// can be maintained across rounds
		ps = ent->client->ps;

		ghost = ent->client->sess.ghost;

		// Spawn the requested team
		if ( ent->client->sess.team != team )
		{
			continue;
		}

		// Dont force them to respawn if they arent a ghost
		if ( !ghost && !force )
		{
			continue;
		}

		// If the client is a ghost then revert them
		if ( ent->client->sess.ghost )
		{
			// Clean up any following monkey business
			G_StopFollowing ( ent );

			// Disable being a ghost
			ent->client->ps.pm_flags &= ~PMF_GHOST;
			ent->client->ps.pm_type = PM_NORMAL;
			ent->client->sess.ghost = false;
		}
		
		ent->client->sess.noTeamChange = false;

		trap_UnlinkEntity (ent);
		ClientSpawn ( ent );
	}
}
Beispiel #12
0
/*
=================
G_ChangeTeam
=================
*/
void G_ChangeTeam( gentity_t *ent, team_t newTeam )
{
	team_t oldTeam = ent->client->pers.teamSelection;

	if ( oldTeam == newTeam )
	{
		return;
	}

	G_LeaveTeam( ent );
	ent->client->pers.teamChangeTime = level.time;
	ent->client->pers.teamSelection = newTeam;
	ent->client->pers.classSelection = PCL_NONE;
	ClientSpawn( ent, NULL, NULL, NULL );

	if ( oldTeam == TEAM_HUMANS && newTeam == TEAM_ALIENS )
	{
		// Convert from human to alien credits
		ent->client->pers.credit =
		  ( int )( ent->client->pers.credit *
		           ALIEN_MAX_CREDITS / HUMAN_MAX_CREDITS + 0.5f );
	}
	else if ( oldTeam == TEAM_ALIENS && newTeam == TEAM_HUMANS )
	{
		// Convert from alien to human credits
		ent->client->pers.credit =
		  ( int )( ent->client->pers.credit *
		           HUMAN_MAX_CREDITS / ALIEN_MAX_CREDITS + 0.5f );
	}

	if ( !g_cheats.integer )
	{
		if ( ent->client->noclip )
		{
			ent->client->noclip = qfalse;
			ent->r.contents = ent->client->cliprcontents;
		}
		ent->flags &= ~( FL_GODMODE | FL_NOTARGET );
	}

	// Copy credits to ps for the client
	ent->client->ps.persistant[ PERS_CREDIT ] = ent->client->pers.credit;

	ClientUserinfoChanged( ent->client->ps.clientNum, qfalse );

	G_UpdateTeamConfigStrings();

	G_LogPrintf( "ChangeTeam: %d %s: %s" S_COLOR_WHITE " switched teams\n",
	             ( int )( ent - g_entities ), BG_TeamName( newTeam ), ent->client->pers.netname );

	G_namelog_update_score( ent->client );
	TeamplayInfoMessage( ent );
}
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum )
{
  gentity_t *ent;
  gclient_t *client;
  int       flags;

  ent = g_entities + clientNum;

  client = level.clients + clientNum;

  if( ent->r.linked )
    trap_UnlinkEntity( ent );

  G_InitGentity( ent );
  ent->touch = 0;
  ent->pain = 0;
  ent->client = client;

  client->pers.connected = CON_CONNECTED;
  client->pers.enterTime = level.time;

  // save eflags around this, because changing teams will
  // cause this to happen with a valid entity, and we
  // want to make sure the teleport bit is set right
  // so the viewpoint doesn't interpolate through the
  // world to the new position
  flags = client->ps.eFlags;
  memset( &client->ps, 0, sizeof( client->ps ) );
  memset( &client->pmext, 0, sizeof( client->pmext ) );
  client->ps.eFlags = flags;

  // locate ent at a spawn point

  ClientSpawn( ent, NULL, NULL, NULL );

  trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );

  // name can change between ClientConnect() and ClientBegin()
  G_admin_namelog_update( client, qfalse );

  // request the clients PTR code
  trap_SendServerCommand( ent - g_entities, "ptrcrequest" );

  G_LogPrintf( "ClientBegin: %i\n", clientNum );

  // count current clients and rank for scoreboard
  CalculateRanks( );
}
Beispiel #14
0
/*
================
respawn
================
*/
void respawn( gentity_t *ent ) {
	gentity_t	*tent;

	//kick fragged bots from game
	if (IsBot(ent->client->ps.clientNum) ) {
		trap_DropClient( ent->client->ps.clientNum, "" );
		G_EndWave();	//check if the wave was won and handle it
		return;
	}

	CopyToBodyQue (ent);
	ClientSpawn(ent);

	// add a teleportation effect
	tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
	tent->s.clientNum = ent->s.clientNum;
}
Beispiel #15
0
/* JPW NERVE
================
reinforce
================
// -- called when time expires for a team deployment cycle and there is at least one guy ready to go
*/
void reinforce(gentity_t *ent) {
	int       p;
	gclient_t *rclient;

	if (!(ent->client->ps.pm_flags & PMF_LIMBO)) {
		G_Printf("player already deployed, skipping\n");
		return;
	}

	// DHM - Nerve :: restore persistant data now that we're out of Limbo
	rclient = ent->client;
	for (p = 0; p < MAX_PERSISTANT; p++)
		rclient->ps.persistant[p] = rclient->saved_persistant[p];
	// dhm

	// Respawn client
	ent->client->ps.pm_flags &= ~PMF_LIMBO; // JPW NERVE turns off limbo
	ClientSpawn(ent);
}
Beispiel #16
0
/**
Called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
*/
void ClientBegin(int clientNum)
{
	gentity_t	*ent;
	gclient_t	*client;
	int			flags;

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	if (ent->r.linked) {
		trap_UnlinkEntity(ent);
	}
	G_InitGentity(ent);
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset(&client->ps, 0, sizeof(client->ps));
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn(ent);

	G_LogPrintf("ClientBegin: %i\n", clientNum);

	// count current clients and rank for scoreboard
	CalculateRanks();

	CheckPings(qtrue);
	G_SendScoreboard(client);
}
Beispiel #17
0
/*
================
G_RankRunFrame
================
*/
void G_RankRunFrame()
{
	gentity_t*		ent;
	gentity_t*		ent2;
	grank_status_t	old_status;
	grank_status_t	status;
	int				time;
	int				i;
	int				j;

	if( !trap_RankCheckInit() ) 
	{
		trap_RankBegin( GR_GAMEKEY );
	}

	trap_RankPoll();
	
	if( trap_RankActive() )
	{
		for( i = 0; i < level.maxclients; i++ )
		{
			ent = &(g_entities[i]);
			if ( !ent->inuse )
				continue;
			if ( ent->client == NULL )
				continue;
			if ( ent->r.svFlags & SVF_BOT)
			{
				// no bots in ranked games
				trap_SendConsoleCommand( EXEC_INSERT, va("kick %s\n", 
					ent->client->pers.netname) );
				continue;
			}

			old_status = ent->client->client_status;
			status = trap_RankUserStatus( i );
			
			if( ent->client->client_status != status )
			{
				// inform client of current status
				// not needed for client side log in
				trap_SendServerCommand( i, va("rank_status %i\n",status) );
				if ( i == 0 )
				{
					int j = 0;
				}
				ent->client->client_status = status;
			}
			
			switch( status )
			{
			case QGR_STATUS_NEW:
			case QGR_STATUS_SPECTATOR:
				if( ent->client->sess.sessionTeam != TEAM_SPECTATOR )
				{
					ent->client->sess.sessionTeam = TEAM_SPECTATOR;
					ent->client->sess.spectatorState = SPECTATOR_FREE;
					ClientSpawn( ent );
					// make sure by now CS_GRAND rankingsGameID is ready
					trap_SendServerCommand( i, va("rank_status %i\n",status) );
					trap_SendServerCommand( i, "rank_menu\n" );
				}
				break;
			case QGR_STATUS_NO_USER:
			case QGR_STATUS_BAD_PASSWORD:
			case QGR_STATUS_TIMEOUT:
			case QGR_STATUS_NO_MEMBERSHIP:
			case QGR_STATUS_INVALIDUSER:
			case QGR_STATUS_ERROR:
				if( (ent->r.svFlags & SVF_BOT) == 0 )
				{
					trap_RankUserReset( ent->s.clientNum );
				}
				break;
			case QGR_STATUS_ACTIVE:
				if( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) &&
					(g_gametype.integer < GT_TEAM) )
				{
					SetTeam( ent, "free" );
				}

				if( old_status != QGR_STATUS_ACTIVE )
				{
					// player has just become active
					for( j = 0; j < level.maxclients; j++ )
					{
						ent2 = &(g_entities[j]);
						if ( !ent2->inuse )
							continue;
						if ( ent2->client == NULL )
							continue;
						if ( ent2->r.svFlags & SVF_BOT)
							continue;

						if( (i != j) && (trap_RankUserStatus( j ) == QGR_STATUS_ACTIVE) )
						{
							trap_RankReportInt( i, j, QGR_KEY_PLAYED_WITH, 1, 0 );
						}

						// send current scores so the player's rank will show 
						// up under the crosshair immediately
						DeathmatchScoreboardMessage( ent2 );
					}
				}
				break;
			default:
				break;
			}
		}

		// don't let ranked games last forever
		if( ((g_fraglimit.integer == 0) || (g_fraglimit.integer > 100)) && 
			((g_timelimit.integer == 0) || (g_timelimit.integer > 1000)) )
		{
			trap_Cvar_Set( "timelimit", "1000" );
		}
	}

	// tell time to clients so they can show current match rating
	if( level.intermissiontime == 0 )
	{
		for( i = 0; i < level.maxclients; i++ )
		{
			ent = &(g_entities[i]);
			if( ent->client == NULL )
			{
				continue;
			}

			time = (level.time - ent->client->pers.enterTime) / 1000;
			ent->client->ps.persistant[PERS_MATCH_TIME] = time;
		}
	}
}
Beispiel #18
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin(int clientNum) {
	gentity_t *ent;
	gclient_t *client;
	int       flags;
	int       spawn_count;

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	if (ent->r.linked) {
		trap_UnlinkEntity(ent);
	}

	G_InitGentity(ent);
	ent->touch  = 0;
	ent->pain   = 0;
	ent->client = client;

	client->pers.connected       = CON_CONNECTED;
	client->pers.teamState.state = TEAM_BEGIN;

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	// DHM - Nerve :: Also save PERS_SPAWN_COUNT, so that CG_Respawn happens

	spawn_count = client->ps.persistant[PERS_SPAWN_COUNT];

	//bani - proper fix for #328

	flags = client->ps.eFlags;
	memset(&client->ps, 0, sizeof (client->ps));
	client->ps.eFlags = flags;

	client->ps.persistant[PERS_SPAWN_COUNT] = spawn_count;

	// locate ent at a spawn point
	ClientSpawn(ent);


	// DHM - Nerve :: Start players in limbo mode if they change teams during the match
	if (client->sess.sessionTeam != TEAM_SPECTATOR && (level.time - level.startTime > FRAMETIME * GAME_INIT_FRAMES)) {
		ent->health     = 0;
		ent->r.contents = CONTENTS_CORPSE;

		client->ps.pm_type            = PM_DEAD;
		client->ps.stats[STAT_HEALTH] = 0;

		limbo(ent);
	}

	if (client->sess.sessionTeam != TEAM_SPECTATOR) {
		trap_SendServerCommand(-1, va("print \"[lof]%s" S_COLOR_WHITE " [lon]entered the game\n\"", client->pers.netname));
	}

	// count current clients and rank for scoreboard
	CalculateRanks();

	// No surface determined yet.
	ent->surfaceFlags = 0;

	// Nico, check for autologin
	if (g_useAPI.integer && client->pers.autoLogin && !client->sess.logged) {
		G_LogPrintf("ClientBegin: login client %d via autoLogin\n", clientNum);
		Cmd_Login_f(ent);
	}

	// Nico, check for checkpoints auto loading
	// if client is not spectator and if we are not in cupMode
	if (g_useAPI.integer && g_cupMode.integer == 0 && client->pers.autoLoadCheckpoints && client->sess.sessionTeam != TEAM_SPECTATOR) {
		G_LogPrintf("ClientBegin: loading checkpoints for client %d via autoLoadCheckpoints\n", clientNum);
		Cmd_LoadCheckpoints_real(ent, "0", 0); // "0" as ignore vlaue, because we load player checkpoints
	}

	G_LogPrintf("ClientBegin: %i\n", clientNum);
}
Beispiel #19
0
/*
================
respawn
================
*/
void respawn( gentity_t *ent ) {
	//CopyToBodyQue (ent);
	ClientSpawn(ent);
}
Beispiel #20
0
/*
===========
ClientBegin

Called when a client has finished connecting, and is ready
to be placed into the level. This will happen on every
level load and level restart, but doesn't happen on respawns.
============
*/
void ClientBegin( int clientNum )
{
	gentity_t       *ent;
	gclient_t       *client;
	int             flags;
	char            startMsg[ MAX_STRING_CHARS ];

	ent    = g_entities + clientNum;
	client = level.clients + clientNum;

	// ignore if client already entered the game
	if ( client->pers.connected != CON_CONNECTING )
	{
		return;
	}

	if ( ent->r.linked )
	{
		trap_UnlinkEntity( ent );
	}

	G_InitGentity( ent );

	// Create a basic client entity, will be replaced by a more specific one later.
	ent->entity = new ClientEntity({ent, client});

	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	ClientAdminChallenge( clientNum );

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	memset( &client->pmext, 0, sizeof( client->pmext ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent, nullptr, nullptr, nullptr );

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 entered the game") ), Quote( client->pers.netname ) ) );

	trap_Cvar_VariableStringBuffer( "g_mapStartupMessage", startMsg, sizeof( startMsg ) );

	if ( *startMsg )
	{
		trap_SendServerCommand( ent - g_entities, va( "cpd %d %s", g_mapStartupMessageDelay.integer, Quote( startMsg ) ) );
	}

	G_namelog_restore( client );

	G_LogPrintf( "ClientBegin: %i", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	// display the help menu, if connecting the first time
	if ( !client->sess.seenWelcome )
	{
		client->sess.seenWelcome = 1;

		// 0 - don't show
		// 1 - always show to all
		// 2 - show only to unregistered
		switch ( g_showHelpOnConnection.integer )
		{
		case 0:
			if (0)
		default:
			if ( !client->pers.admin )
		case 1:
			G_TriggerMenu( client->ps.clientNum, MN_WELCOME );
		}
	}
}
Beispiel #21
0
/*
================
ClientRespawn
================
*/
void ClientRespawn( gentity_t *ent ) {

    CopyToBodyQue (ent);
    ClientSpawn(ent);
}
Beispiel #22
0
/*
===========
ClientBegin

Called when a client has finished connecting, and is ready
to be placed into the level. This will happen on every
level load and level restart, but doesn't happen on respawns.
============
*/
void ClientBegin( int clientNum )
{
	gentity_t       *ent;
	gclient_t       *client;
	int             flags;
	g_admin_admin_t *admin;

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	admin = client->pers.admin;

	// ignore if client already entered the game
	if ( client->pers.connected != CON_CONNECTING )
	{
		return;
	}

	if ( ent->r.linked )
	{
		trap_UnlinkEntity( ent );
	}

	G_InitGentity( ent );
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	if ( !client->pers.pubkey_authenticated && admin && admin->pubkey[ 0 ] )
	{
		trap_SendServerCommand( ent - g_entities, va( "pubkey_decrypt %s", admin->msg2 ) );
		// copy the decrypted message because generating a new message will overwrite it
		G_admin_writeconfig();
	}

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	memset( &client->pmext, 0, sizeof( client->pmext ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent, NULL, NULL, NULL );

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 entered the game\n") ), Quote( client->pers.netname ) ) );

	G_namelog_restore( client );

	G_LogPrintf( "ClientBegin: %i\n", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	// send the client a list of commands that can be used
	if ( !client->pers.admin )
	{
		G_ListCommands( ent );
	}
}
Beispiel #23
0
/*
===========
ClientBegin

Called when a client has finished connecting, and is ready
to be placed into the level. This will happen on every
level load and level restart, but doesn't happen on respawns.
============
*/
void ClientBegin( int clientNum )
{
	gentity_t       *ent;
	gclient_t       *client;
	int             flags;
	char            startMsg[ MAX_STRING_CHARS ];

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	// ignore if client already entered the game
	if ( client->pers.connected != CON_CONNECTING )
	{
		return;
	}

	if ( ent->r.linked )
	{
		trap_UnlinkEntity( ent );
	}

	G_InitGentity( ent );
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	ClientAdminChallenge( clientNum );

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	memset( &client->pmext, 0, sizeof( client->pmext ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent, NULL, NULL, NULL );

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 entered the game\n") ), Quote( client->pers.netname ) ) );

	trap_Cvar_VariableStringBuffer( "g_mapStartupMessage", startMsg, sizeof( startMsg ) );

	if ( *startMsg )
	{
		trap_SendServerCommand( ent - g_entities, va( "cpd %d %s", g_mapStartupMessageDelay.integer, Quote( startMsg ) ) );
	}

	G_namelog_restore( client );

	G_LogPrintf( "ClientBegin: %i\n", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	// send the client a list of commands that can be used
	if ( !client->pers.admin )
	{
		G_ListCommands( ent );
	}
}
Beispiel #24
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum ) {
	gentity_t	*ent;
	gclient_t	*client;
	gentity_t	*tent;
	int			flags;

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	if ( ent->r.linked ) {
		trap_UnlinkEntity( ent );
	}
	G_InitGentity( ent );
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;
	client->pers.teamState.state = TEAM_BEGIN;

	// [ERGO MOD START]
	// no cycle or beat yet received
	client->pers.lastBikeCycleTime = -1;
	client->pers.lastHeartBeatTime = -1;
	client->pers.brSampleCount = 0;
	client->pers.hrSampleCount = 0;
	client->pers.brSampleSum = 0.0;
	client->pers.hrSampleSum = 0.0;
	client->pers.hrNumSamples = HR_DEFAULT_NUM_SAMPLES; // adjustable with key (keypad up / down)
	client->pers.currentCycleRate = 0;
	client->pers.currentHeartRate = 0;
	// set heart rate zones
	client->pers.minRecoveryHR = HR_RECOVERY_LOWER_BOUND * (float) client->sess.maxHeartRate;
	client->pers.minAerobicHR = HR_AEROBIC_LOWER_BOUND * (float) client->sess.maxHeartRate;
	client->pers.minAnaerobicHR = HR_ANAEROBIC_LOWER_BOUND * (float) client->sess.maxHeartRate;
	client->pers.maxAnaerobicHR = HR_ANAEROBIC_UPPER_BOUND * (float) client->sess.maxHeartRate;
	// set overall reward frequencies
	if (client->sess.targetHR == HR_TARGET_RECOVERY)
	{
		client->pers.rewardFrequencyRecovery = (float) REWARD_MAX_FREQUENCY;
		client->pers.rewardFrequencyAerobic = (float) REWARD_MED_FREQUENCY;
		client->pers.rewardFrequencyAnaerobic = (float) REWARD_MIN_FREQUENCY;
	}
	else if (client->sess.targetHR == HR_TARGET_AEROBIC)
	{
		client->pers.rewardFrequencyRecovery = (float) REWARD_MED_FREQUENCY;
		client->pers.rewardFrequencyAerobic = (float) REWARD_MAX_FREQUENCY;
		client->pers.rewardFrequencyAnaerobic = (float) REWARD_MIN_FREQUENCY;
	}
	else
	{
		client->pers.rewardFrequencyRecovery = (float) REWARD_MIN_FREQUENCY;
		client->pers.rewardFrequencyAerobic = (float) REWARD_MED_FREQUENCY;
		client->pers.rewardFrequencyAnaerobic = (float) REWARD_MAX_FREQUENCY;
	}
	// set and adjust reward drop percentages (considers disabled options of items, weapons, powerups)
	setRewardPercentages(ent);
	// punishment intervals
	client->pers.punishmentIntervals[0] = PUNISHMENT_INTERVAL_MAX;
	client->pers.punishmentIntervals[1] = PUNISHMENT_INTERVAL_MID;
	client->pers.punishmentIntervals[2] = PUNISHMENT_INTERVAL_MIN;
	// [ERGO MOD END]

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent );

	if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
		// send event
		tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
		tent->s.clientNum = ent->s.clientNum;

		if ( g_gametype.integer != GT_TOURNAMENT  ) {
			trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname) );
		}
	}
	G_LogPrintf( "ClientBegin: %i\n", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();
}
Beispiel #25
0
/*
================
ClientRespawn
================
*/
void ClientRespawn( edict_s* ent )
{


	ClientSpawn( ent );
}
Beispiel #26
0
/*
===========
ClientBegin

called when a client has finished connecting, and is ready
to be placed into the level.  This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
void ClientBegin( int clientNum, qboolean allowTeamReset ) {
	gentity_t	*ent;
	gclient_t	*client;
	gentity_t	*tent;
	int			flags, i;
	char		userinfo[MAX_INFO_VALUE], *modelname;

	ent = g_entities + clientNum;

	if ((ent->r.svFlags & SVF_BOT) && g_gametype.integer >= GT_TEAM)
	{
		if (allowTeamReset)
		{
			const char *team = "Red";
			int preSess;

			//SetTeam(ent, "");
			ent->client->sess.sessionTeam = PickTeam(-1);
			trap_GetUserinfo(clientNum, userinfo, MAX_INFO_STRING);

			if (ent->client->sess.sessionTeam == TEAM_SPECTATOR)
			{
				ent->client->sess.sessionTeam = TEAM_RED;
			}

			if (ent->client->sess.sessionTeam == TEAM_RED)
			{
				team = "Red";
			}
			else
			{
				team = "Blue";
			}

			Info_SetValueForKey( userinfo, "team", team );

			trap_SetUserinfo( clientNum, userinfo );

			ent->client->ps.persistant[ PERS_TEAM ] = ent->client->sess.sessionTeam;

			preSess = ent->client->sess.sessionTeam;
			G_ReadSessionData( ent->client );
			ent->client->sess.sessionTeam = preSess;
			G_WriteClientSessionData(ent->client);
			ClientUserinfoChanged( clientNum );
			ClientBegin(clientNum, qfalse);
			return;
		}
	}

	client = level.clients + clientNum;

	if ( ent->r.linked ) {
		trap_UnlinkEntity( ent );
	}
	G_InitGentity( ent );
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;
	client->pers.teamState.state = TEAM_BEGIN;

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;

	i = 0;

	while (i < NUM_FORCE_POWERS)
	{
		if (ent->client->ps.fd.forcePowersActive & (1 << i))
		{
			WP_ForcePowerStop(ent, i);
		}
		i++;
	}

	i = TRACK_CHANNEL_1;

	while (i < NUM_TRACK_CHANNELS)
	{
		if (ent->client->ps.fd.killSoundEntIndex[i-50] && ent->client->ps.fd.killSoundEntIndex[i-50] < MAX_GENTITIES && ent->client->ps.fd.killSoundEntIndex[i-50] > 0)
		{
			G_MuteSound(ent->client->ps.fd.killSoundEntIndex[i-50], CHAN_VOICE);
		}
		i++;
	}
	i = 0;

	memset( &client->ps, 0, sizeof( client->ps ) );
	client->ps.eFlags = flags;

	client->ps.hasDetPackPlanted = qfalse;

	//first-time force power initialization
	WP_InitForcePowers( ent );

	//init saber ent
	WP_SaberInitBladeData( ent );

	// First time model setup for that player.
	trap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );
	modelname = Info_ValueForKey (userinfo, "model");
	SetupGameGhoul2Model(client, modelname);

	if (ent->client->ghoul2)
	{
		ent->bolt_Head = trap_G2API_AddBolt(ent->client->ghoul2, 0, "cranium");
		ent->bolt_Waist = trap_G2API_AddBolt(ent->client->ghoul2, 0, "thoracic");
		ent->bolt_LArm = trap_G2API_AddBolt(ent->client->ghoul2, 0, "lradius");
		ent->bolt_RArm = trap_G2API_AddBolt(ent->client->ghoul2, 0, "rradius");
		ent->bolt_LLeg = trap_G2API_AddBolt(ent->client->ghoul2, 0, "ltibia");
		ent->bolt_RLeg = trap_G2API_AddBolt(ent->client->ghoul2, 0, "rtibia");
		ent->bolt_Motion = trap_G2API_AddBolt(ent->client->ghoul2, 0, "Motion");
	}

	// locate ent at a spawn point
	ClientSpawn( ent );

	if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
		// send event
		tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
		tent->s.clientNum = ent->s.clientNum;

		if ( g_gametype.integer != GT_TOURNAMENT  ) {
			trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " %s\n\"", client->pers.netname, G_GetStripEdString("SVINGAME", "PLENTER")) );
		}
	}
	G_LogPrintf( "ClientBegin: %i\n", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	G_ClearClientLog(clientNum);
}