diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 2 | ||||
-rw-r--r-- | src/game/g_active.c | 22 | ||||
-rw-r--r-- | src/game/g_client.c | 3 | ||||
-rw-r--r-- | src/game/g_cmds.c | 142 | ||||
-rw-r--r-- | src/game/g_combat.c | 12 | ||||
-rw-r--r-- | src/game/g_local.h | 7 |
6 files changed, 91 insertions, 97 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 83d509dd..b22a94e8 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -208,7 +208,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; TRAPPER_BP, //int buildPoints; - ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + ( 1 << S2 )|( 1 << S3 ), //int stages //NEEDS ADV BUILDER SO S2 AND UP TRAPPER_HEALTH, //int health; TRAPPER_REGEN, //int regenRate; TRAPPER_SPLASHDAMAGE, //int splashDamage; diff --git a/src/game/g_active.c b/src/game/g_active.c index ee5d1aa3..d22a8b2b 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1398,40 +1398,24 @@ SpectatorClientEndFrame void SpectatorClientEndFrame( gentity_t *ent ) { gclient_t *cl; + int clientNum, flags; // if we are doing a chase cam or a remote view, grab the latest info if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) { - int clientNum, flags; - clientNum = ent->client->sess.spectatorClient; - // team follow1 and team follow2 go to whatever clients are playing - if( clientNum == -1 ) - clientNum = level.follow1; - else if( clientNum == -2 ) - clientNum = level.follow2; - if( clientNum >= 0 ) { cl = &level.clients[ clientNum ]; if( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) { - flags = ( cl->ps.eFlags & ~( EF_VOTED | EF_TEAMVOTED ) ) | ( ent->client->ps.eFlags & ( EF_VOTED | EF_TEAMVOTED ) ); + flags = ( cl->ps.eFlags & ~( EF_VOTED | EF_TEAMVOTED ) ) | + ( ent->client->ps.eFlags & ( EF_VOTED | EF_TEAMVOTED ) ); ent->client->ps = cl->ps; ent->client->ps.pm_flags |= PMF_FOLLOW; ent->client->ps.eFlags = flags; - return; - } - else - { - // drop them to free spectators unless they are dedicated camera followers - if( ent->client->sess.spectatorClient >= 0 ) - { - ent->client->sess.spectatorState = SPECTATOR_FREE; - ClientBegin( ent->client - level.clients ); - } } } } diff --git a/src/game/g_client.c b/src/game/g_client.c index 24b7900c..e5c90d70 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1559,7 +1559,8 @@ void ClientDisconnect( int clientNum ) level.clients[ i ].sess.spectatorState == SPECTATOR_FOLLOW && level.clients[ i ].sess.spectatorClient == clientNum ) { - G_StopFollowing( &g_entities[ i ] ); + if( !G_FollowNewClient( &g_entities[ i ], 1 ) ) + G_StopFollowing( &g_entities[ i ] ); } } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 47e5b3ba..619989c7 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1991,6 +1991,7 @@ void G_StopFollowing( gentity_t *ent ) ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR; ent->client->sess.sessionTeam = TEAM_SPECTATOR; ent->client->sess.spectatorState = SPECTATOR_FREE; + ent->client->sess.spectatorClient = -1; ent->client->ps.pm_flags &= ~PMF_FOLLOW; ent->client->ps.stats[ STAT_STATE ] &= ~SS_WALLCLIMBING; @@ -2004,6 +2005,69 @@ void G_StopFollowing( gentity_t *ent ) /* ================= +G_FollowNewClient + +This was a really nice, elegant function. Then I fucked it up. +================= +*/ +qboolean G_FollowNewClient( gentity_t *ent, int dir ) +{ + int clientnum = ent->client->sess.spectatorClient; + int original = clientnum; + qboolean selectAny = qfalse; + + if( dir > 1 ) + dir = 1; + else if( dir < -1 ) + dir = -1; + else if( dir == 0 ) + return qtrue; + + // select any if no target exists + if( clientnum < 0 || clientnum >= level.maxclients ) + { + clientnum = original = 0; + selectAny = qtrue; + } + + do + { + clientnum += dir; + + if( clientnum >= level.maxclients ) + clientnum = 0; + + if( clientnum < 0 ) + clientnum = level.maxclients - 1; + + // avoid selecting existing follow target + if( clientnum == original && !selectAny ) + continue; //effectively break; + + // can't follow self + if( &level.clients[ clientnum ] == ent->client ) + continue; + + // can only follow connected clients + if( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) + continue; + + // can't follow another spectator + if( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) + continue; + + // this is good, we can use it + ent->client->sess.spectatorClient = clientnum; + ent->client->sess.spectatorState = SPECTATOR_FOLLOW; + return qtrue; + + } while( clientnum != original ); + + return qfalse; +} + +/* +================= Cmd_Follow_f ================= */ @@ -2016,43 +2080,10 @@ void Cmd_Follow_f( gentity_t *ent, qboolean toggle ) { if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) G_StopFollowing( ent ); - else - { - //follow somebody, anybody - int clientnum = ent->client->sess.spectatorClient; - int original = clientnum; - - do - { - clientnum++; - - if( clientnum >= level.maxclients ) - clientnum = 0; - - if( clientnum < 0 ) - clientnum = level.maxclients - 1; - - // can't follow self - if( &level.clients[ clientnum ] == ent->client ) - continue; - - // can only follow connected clients - if( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) - continue; - - // can't follow another spectator - if( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) - continue; - - // this is good, we can use it - ent->client->sess.spectatorClient = clientnum; - ent->client->sess.spectatorState = SPECTATOR_FOLLOW; - break; - - } while( clientnum != original ); - } + else if( ent->client->sess.spectatorState == SPECTATOR_FREE ) + G_FollowNewClient( ent, 1 ); } - else + else if( ent->client->sess.spectatorState == SPECTATOR_FREE ) { trap_Argv( 1, arg, sizeof( arg ) ); i = G_ClientNumberFromString( ent, arg ); @@ -2084,49 +2115,14 @@ Cmd_FollowCycle_f */ void Cmd_FollowCycle_f( gentity_t *ent, int dir ) { - int clientnum; - int original; - - // first set them to spectator + // won't work unless spectating if( ent->client->sess.spectatorState == SPECTATOR_NOT ) return; if( dir != 1 && dir != -1 ) G_Error( "Cmd_FollowCycle_f: bad dir %i", dir ); - clientnum = ent->client->sess.spectatorClient; - original = clientnum; - - do - { - clientnum += dir; - - if( clientnum >= level.maxclients ) - clientnum = 0; - - if( clientnum < 0 ) - clientnum = level.maxclients - 1; - - // can't follow self - if( &level.clients[ clientnum ] == ent->client ) - continue; - - // can only follow connected clients - if( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) - continue; - - // can't follow another spectator - if( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) - continue; - - // this is good, we can use it - ent->client->sess.spectatorClient = clientnum; - ent->client->sess.spectatorState = SPECTATOR_FOLLOW; - return; - - } while( clientnum != original ); - - // leave it where it was + G_FollowNewClient( ent, dir ); } /* diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 0bf8b1b8..515ecfe7 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -163,6 +163,18 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( level.intermissiontime ) return; + // stop any following clients + for( i = 0; i < level.maxclients; i++ ) + { + if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR && + level.clients[ i ].sess.spectatorState == SPECTATOR_FOLLOW && + level.clients[ i ].sess.spectatorClient == self->client->ps.clientNum ) + { + if( !G_FollowNewClient( &g_entities[ i ], 1 ) ) + G_StopFollowing( &g_entities[ i ] ); + } + } + self->client->ps.pm_type = PM_DEAD; self->suicideTime = 0; diff --git a/src/game/g_local.h b/src/game/g_local.h index 00b38bbe..2db714f2 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -600,9 +600,10 @@ char *G_NewString( const char *string ); // // g_cmds.c // -void Cmd_Score_f( gentity_t *ent ); -void G_StopFollowing( gentity_t *ent ); -void Cmd_Follow_f( gentity_t *ent, qboolean toggle ); +void Cmd_Score_f( gentity_t *ent ); +void G_StopFollowing( gentity_t *ent ); +qboolean G_FollowNewClient( gentity_t *ent, int dir ); +void Cmd_Follow_f( gentity_t *ent, qboolean toggle ); // // g_physics.c |