diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_players.c | 4 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 12 | ||||
-rw-r--r-- | src/game/g_client.c | 8 | ||||
-rw-r--r-- | src/game/g_cmds.c | 55 | ||||
-rw-r--r-- | src/game/g_local.h | 2 | ||||
-rw-r--r-- | src/game/g_maprotation.c | 6 | ||||
-rw-r--r-- | src/game/g_ptr.c | 36 |
7 files changed, 45 insertions, 78 deletions
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index f729164a..9a7be70b 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -110,9 +110,9 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) if( len < 0 ) return qfalse; - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) { - CG_Printf( "File %s too long\n", filename ); + CG_Printf( "File %s is %s\n", filename, len == 0 ? "empty" : "too long" ); trap_FS_FCloseFile( f ); return qfalse; } diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index e2f7d363..3f290b5d 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -102,12 +102,13 @@ static qboolean CG_ParseWeaponAnimationFile( const char *filename, weaponInfo_t // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if( len <= 0 ) + if( len < 0 ) return qfalse; - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) { - CG_Printf( "File %s too long\n", filename ); + trap_FS_FCloseFile( f ); + CG_Printf( "File %s is %s\n", filename, len == 0 ? "empty" : "too long" ); return qfalse; } @@ -540,9 +541,10 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) if( len < 0 ) return qfalse; - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) { - CG_Printf( "File %s too long\n", filename ); + trap_FS_FCloseFile( f ); + CG_Printf( "File %s is %s\n", filename, len == 0 ? "empty" : "too long" ); return qfalse; } diff --git a/src/game/g_client.c b/src/game/g_client.c index d0f9349f..49ae26a9 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -890,9 +890,10 @@ static qboolean G_NonSegModel( const char *filename ) if( len < 0 ) return qfalse; - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) { - G_Printf( "File %s too long\n", filename ); + trap_FS_FCloseFile( f ); + G_Printf( "File %s is %s\n", filename, len == 0 ? "empty" : "too long" ); return qfalse; } @@ -1676,6 +1677,9 @@ void ClientDisconnect( int clientNum ) tent->s.clientNum = ent->s.clientNum; } + if( ent->client->pers.connection ) + ent->client->pers.connection->clientNum = -1; + G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum, ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index cf43a485..cf72c427 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1753,7 +1753,7 @@ void Cmd_Destroy_f( gentity_t *ent ) } // Prevent destruction of the last spawn - if( !g_markDeconstruct.integer ) + if( !g_markDeconstruct.integer && !g_cheats.integer ) { if( ent->client->pers.teamSelection == PTE_ALIENS && traceEnt->s.modelindex == BA_A_SPAWN ) @@ -2678,6 +2678,9 @@ void Cmd_PTRCVerify_f( gentity_t *ent ) char s[ MAX_TOKEN_CHARS ] = { 0 }; int code; + if( ent->client->pers.connection ) + return; + trap_Argv( 1, s, sizeof( s ) ); if( !s[ 0 ] ) @@ -2685,16 +2688,16 @@ void Cmd_PTRCVerify_f( gentity_t *ent ) code = atoi( s ); - if( G_VerifyPTRC( code ) ) + connection = G_FindConnectionForCode( code ); + if( connection && connection->clientNum == -1 ) { - connection = G_FindConnectionForCode( code ); - // valid code if( connection->clientTeam != PTE_NONE ) trap_SendServerCommand( ent->client->ps.clientNum, "ptrcconfirm" ); // restore mapping ent->client->pers.connection = connection; + connection->clientNum = ent->client->ps.clientNum; } else { @@ -2722,6 +2725,13 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) int code; connectionRecord_t *connection; + if( ent->client->pers.joinedATeam ) + { + trap_SendServerCommand( ent - g_entities, + "print \"You cannot use a PTR code after joining a team\n\"" ); + return; + } + trap_Argv( 1, s, sizeof( s ) ); if( !s[ 0 ] ) @@ -2729,28 +2739,15 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) code = atoi( s ); - if( G_VerifyPTRC( code ) ) + connection = ent->client->pers.connection; + if( connection && connection->ptrCode == code ) { - if( ent->client->pers.joinedATeam ) - { - trap_SendServerCommand( ent - g_entities, - "print \"You cannot use a PTR code after joining a team\n\"" ); - } - else - { - // valid code - connection = G_FindConnectionForCode( code ); + // set the correct team + G_ChangeTeam( ent, connection->clientTeam ); - if( connection ) - { - // set the correct team - G_ChangeTeam( ent, connection->clientTeam ); - - // set the correct credit - ent->client->ps.persistant[ PERS_CREDIT ] = 0; - G_AddCreditToClient( ent->client, connection->clientCredit, qtrue ); - } - } + // set the correct credit + ent->client->ps.persistant[ PERS_CREDIT ] = 0; + G_AddCreditToClient( ent->client, connection->clientCredit, qtrue ); } else { @@ -2911,12 +2908,12 @@ commands_t cmds[ ] = { { "damage", CMD_CHEAT|CMD_LIVING, Cmd_Damage_f }, // game commands - { "ptrcverify", 0, Cmd_PTRCVerify_f }, - { "ptrcrestore", 0, Cmd_PTRCRestore_f }, + { "ptrcverify", CMD_SPEC, Cmd_PTRCVerify_f }, + { "ptrcrestore", CMD_SPEC, Cmd_PTRCRestore_f }, - { "follow", 0, Cmd_Follow_f }, - { "follownext", 0, Cmd_FollowCycle_f }, - { "followprev", 0, Cmd_FollowCycle_f }, + { "follow", CMD_SPEC, Cmd_Follow_f }, + { "follownext", CMD_SPEC, Cmd_FollowCycle_f }, + { "followprev", CMD_SPEC, Cmd_FollowCycle_f }, { "where", CMD_TEAM, Cmd_Where_f }, { "teamvote", CMD_TEAM, Cmd_TeamVote_f }, diff --git a/src/game/g_local.h b/src/game/g_local.h index 4e4fb523..625baa71 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1088,10 +1088,8 @@ void G_InitMapRotations( void ); // void G_UpdatePTRConnection( gclient_t *client ); connectionRecord_t *G_GenerateNewConnection( gclient_t *client ); -qboolean G_VerifyPTRC( int code ); void G_ResetPTRConnections( void ); connectionRecord_t *G_FindConnectionForCode( int code ); -void G_DeletePTRConnection( connectionRecord_t *connection ); //some maxs diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index b34370b8..968ba487 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -313,9 +313,11 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) if( len < 0 ) return qfalse; - if( len >= sizeof( text ) - 1 ) + if( len == 0 || len >= sizeof( text ) - 1 ) { - G_Printf( S_COLOR_RED "ERROR: map rotation file %s too long\n", fileName ); + trap_FS_FCloseFile( f ); + G_Printf( S_COLOR_RED "ERROR: map rotation file %s is %s\n", fileName, + len == 0 ? "empty" : "too long" ); return qfalse; } diff --git a/src/game/g_ptr.c b/src/game/g_ptr.c index 1b44f091..898ad7f5 100644 --- a/src/game/g_ptr.c +++ b/src/game/g_ptr.c @@ -110,29 +110,6 @@ connectionRecord_t *G_GenerateNewConnection( gclient_t *client ) /* =============== -G_VerifyPTRC - -Check a PTR code for validity -=============== -*/ -qboolean G_VerifyPTRC( int code ) -{ - int i; - - if( code == 0 ) - return qfalse; - - for( i = 0; i < MAX_CLIENTS; i++ ) - { - if( connections[ i ].ptrCode == code ) - return qtrue; - } - - return qfalse; -} - -/* -=============== G_FindConnectionForCode Finds a connection for a given code @@ -156,19 +133,6 @@ connectionRecord_t *G_FindConnectionForCode( int code ) /* =============== -G_DeletePTRConnection - -Finds a connection and deletes it -=============== -*/ -void G_DeletePTRConnection( connectionRecord_t *connection ) -{ - if( connection ) - memset( connection, 0, sizeof( connectionRecord_t ) ); -} - -/* -=============== G_ResetPTRConnections Invalidate any existing codes |