Manual port of fixes for radar and disconect crashes

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2013-08-29 00:46:22 +02:00
parent 791a9cf238
commit 9d26d84a13
3 changed files with 47 additions and 36 deletions

View file

@ -1052,21 +1052,26 @@ static void CG_DrawStatusBar( void )
vec4_t radColor;
CG_DrawPic(40, 100, 100, 100, cgs.media.radarShader);
int32_t i;
for (i = 0; i < cg.snap->numEntities; i++) // Go through all entities in VIS range
{
if ( cg.snap->entities[i].eType == ET_PLAYER ) // If the Entity is a Player
{
/*if(cg.snap->entities[i].time == -1){
CG_Printf("Radar: decoy found, going to next ent\n");
continue;
}*/
// Calculate How Far Away They Are
x = (cg.snap->entities[i].pos.trBase[0] - cg.predictedPlayerState.origin[0]);
int32_t x = (cg.snap->entities[i].pos.trBase[0] - cg.predictedPlayerState.origin[0]);
y = (cg.snap->entities[i].pos.trBase[1] - cg.predictedPlayerState.origin[1]);
z = (cg.snap->entities[i].pos.trBase[2] - cg.predictedPlayerState.origin[2]);
int32_t z = (cg.snap->entities[i].pos.trBase[2] - cg.predictedPlayerState.origin[2]);
tmpVec[0] = x;
tmpVec[1] = y;
tmpVec[2] = 0.0;
// Convert Vector to Angle
vectoangles(tmpVec, eAngle);
h = sqrt((x*x) + (y*y)); // Get Range
int32_t h = sqrt((x*x) + (y*y)); // Get Range
// We only Want "YAW" value
dAngle[0] = 0.0;
@ -1097,13 +1102,19 @@ static void CG_DrawStatusBar( void )
}
else
{
if ( cgs.clientinfo[cg.snap->entities[i].number].pClass >= 0 )
{
radColor[0] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[0] / 255.0f;
radColor[1] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[1] / 255.0f;
radColor[2] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[2] / 255.0f;
radColor[3] = 1.0f;
}
if(cg.snap->entities[i].time != -1)
if ( cgs.clientinfo[cg.snap->entities[i].number].pClass >= 0 && cg.snap->entities[i].time != -1 )
{
radColor[0] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[0] / 255.0f;
radColor[1] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[1] / 255.0f;
radColor[2] = (float)cgs.classData[cgs.clientinfo[cg.snap->entities[i].number].pClass].radarColor[2] / 255.0f;
radColor[3] = 1.0f;
}
else
{
VectorCopy( colorTable[CT_BLACK], radColor );
radColor[3] = colorTable[CT_BLACK][3];
}
else
{
VectorCopy( colorTable[CT_BLACK], radColor );
@ -1111,7 +1122,9 @@ static void CG_DrawStatusBar( void )
}
if ( cgs.clientinfo[cg.snap->entities[i].number].isAdmin && !cgs.clientinfo[cg.snap->ps.clientNum].isAdmin )
{
continue;
}
if ( z > 64 )
{

View file

@ -1530,6 +1530,8 @@ qboolean PlaceDecoy(gentity_t *ent)
decoy->s.number = decoy-g_entities;
//--------------------------- SPECIALIZED DECOY SETUP
decoy->s.time= -1; // tell cgame this is a decoy so it does not mess up the radar
decoy->parent = ent;
(decoy->s).eType = (ent->s).eType; // set to type PLAYER

View file

@ -2271,13 +2271,13 @@ call trap_DropClient(), which will call this and do
server system housekeeping.
============
*/
void G_Client_Disconnect( int clientNum ) {
gentity_t *ent;
gentity_t *tent;
int i;
void G_Client_Disconnect( int32_t clientNum ) {
gentity_t* ent = NULL;
gentity_t* tent = NULL;
int32_t i = 0;
ent = g_entities + clientNum;
if ( !ent->client ) {
ent = &g_entities[clientNum];
if ( (ent == NULL) || (ent->client == NULL) ) {
return;
}
@ -2296,31 +2296,30 @@ void G_Client_Disconnect( int clientNum ) {
g_entities[clientNum].client->noclip = qfalse;
//TiM: Log the player's IP and name. If they reconnect again, it'll announce their deceipt >:)
if ( rpg_renamedPlayers.integer && !(ent->r.svFlags & SVF_BOT) ) {
int l;
qboolean foundName=qfalse;
if ( (rpg_renamedPlayers.integer != 0) && ((ent->r.svFlags & SVF_BOT) == 0) ) {
int32_t l = 0;
qboolean foundName = qfalse;
//Do a chek to see if this player has disconnected b4. else we'll be wasting a slot.
for ( l = 0; l < MAX_RECON_NAMES; l++ ) {
if ( !g_reconData[l].ipAddress[0] ) {
for ( ; l < MAX_RECON_NAMES; l++ ) {
if ( g_reconData[l].ipAddress[0] == 0 ) {
continue;
}
if ( !Q_stricmp( ent->client->pers.ip, g_reconData[l].ipAddress ) ) {
if ( Q_stricmp( ent->client->pers.ip, g_reconData[l].ipAddress ) == 0 ) {
foundName=qtrue;
break;
}
}
if ( foundName ) {
memset( &g_reconData[i], 0, sizeof( g_reconData[i] ) );
memset( &g_reconData[l], 0, sizeof( g_reconData[l] ) );
//IP Address
Q_strncpyz( g_reconData[i].ipAddress, ent->client->pers.ip, sizeof( g_reconData[i].ipAddress ) );
Q_strncpyz( g_reconData[l].ipAddress, ent->client->pers.ip, sizeof( g_reconData[l].ipAddress ) );
//Player Name
Q_strncpyz( g_reconData[i].previousName, ent->client->pers.netname, sizeof( g_reconData[i].previousName ) );
}
else {
Q_strncpyz( g_reconData[l].previousName, ent->client->pers.netname, sizeof( g_reconData[l].previousName ) );
} else {
memset( &g_reconData[g_reconNum], 0, sizeof( g_reconData[g_reconNum] ) );
//IP Address
@ -2338,8 +2337,8 @@ void G_Client_Disconnect( int clientNum ) {
}
// send effect if they were completely connected
if ( ent->client->pers.connected == CON_CONNECTED
&& ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
if ( (ent->client->pers.connected == CON_CONNECTED)
&& (ent->client->sess.sessionTeam != TEAM_SPECTATOR) ) {
vec3_t org;
VectorCopy( ent->client->ps.origin, org );
@ -2352,21 +2351,18 @@ void G_Client_Disconnect( int clientNum ) {
// Especially important for stuff like CTF flags
TossClientItems ( ent, qtrue );
}
G_LogPrintf( "ClientDisconnect: %i (%s)\n", clientNum, g_entities[clientNum].client->pers.ip );
// if we are playing in tourney mode and losing, give a win to the other player
if ( g_gametype.integer == GT_TOURNAMENT && !level.intermissiontime
&& !level.warmupTime && level.sortedClients[1] == clientNum ) {
if ( (g_gametype.integer == GT_TOURNAMENT) && (level.intermissiontime == 0)
&& (level.warmupTime == 0) && (level.sortedClients[1] == clientNum) ) {
level.clients[ level.sortedClients[0] ].sess.wins++;
G_Client_UserinfoChanged( level.sortedClients[0] );
}
if ( g_gametype.integer == GT_TOURNAMENT && ent->client->sess.sessionTeam == TEAM_FREE && level.intermissiontime )
{
if ( (g_gametype.integer == GT_TOURNAMENT) && (ent->client->sess.sessionTeam == TEAM_FREE) && (level.intermissiontime != 0) ) {
trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
level.restarted = qtrue;
level.changemap = NULL;
level.intermissiontime = 0;
}
@ -2385,7 +2381,7 @@ void G_Client_Disconnect( int clientNum ) {
G_Client_CalculateRanks( qfalse );
if ( ent->r.svFlags & SVF_BOT ) {
if ( (ent->r.svFlags & SVF_BOT) != 0 ) {
BotAIShutdownClient( clientNum );
}