summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_active.c4
-rw-r--r--src/game/g_cmds.c75
-rw-r--r--src/game/g_local.h2
3 files changed, 58 insertions, 23 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 7ef3c810..516bac5a 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -360,8 +360,8 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd )
}
}
- if( ( client->buttons & BUTTON_ATTACK2 ) && !( client->oldbuttons & BUTTON_ATTACK2 ) )
- Cmd_FollowCycle_f( ent, 1 );
+ if( ( client->buttons & BUTTON_USE_HOLDABLE ) && !( client->oldbuttons & BUTTON_USE_HOLDABLE ) )
+ Cmd_Follow_f( ent );
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 1145bad1..5762d3f0 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1839,30 +1839,65 @@ void Cmd_Follow_f( gentity_t *ent )
{
if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW )
G_StopFollowing( ent );
-
- return;
- }
+ 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;
- trap_Argv( 1, arg, sizeof( arg ) );
- i = G_ClientNumberFromString( ent, arg );
-
- if( i == -1 )
- return;
+ // can't follow self
+ if( &level.clients[ clientnum ] == ent->client )
+ continue;
- // can't follow self
- if( &level.clients[ i ] == ent->client )
- return;
+ // can only follow connected clients
+ if( level.clients[ clientnum ].pers.connected != CON_CONNECTED )
+ continue;
- // can't follow another spectator
- if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR )
- return;
+ // can't follow another spectator
+ if( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR )
+ continue;
- // first set them to spectator
- if( ent->client->sess.sessionTeam != TEAM_SPECTATOR )
- G_ChangeTeam( ent, PTE_NONE );
+ // this is good, we can use it
+ ent->client->sess.spectatorClient = clientnum;
+ ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
+ break;
+
+ } while( clientnum != original );
+ }
+ }
+ else
+ {
+ trap_Argv( 1, arg, sizeof( arg ) );
+ i = G_ClientNumberFromString( ent, arg );
+
+ if( i == -1 )
+ return;
+
+ // can't follow self
+ if( &level.clients[ i ] == ent->client )
+ return;
+
+ // can't follow another spectator
+ if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR )
+ return;
- ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
- ent->client->sess.spectatorClient = i;
+ // first set them to spectator
+ if( ent->client->sess.sessionTeam != TEAM_SPECTATOR )
+ G_ChangeTeam( ent, PTE_NONE );
+
+ ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
+ ent->client->sess.spectatorClient = i;
+ }
}
/*
@@ -1877,7 +1912,7 @@ void Cmd_FollowCycle_f( gentity_t *ent, int dir )
// first set them to spectator
if( ent->client->sess.spectatorState == SPECTATOR_NOT )
- G_ChangeTeam( ent, PTE_NONE );
+ return;
if( dir != 1 && dir != -1 )
G_Error( "Cmd_FollowCycle_f: bad dir %i", dir );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 99f6ebf4..5f73424d 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -565,7 +565,7 @@ char *G_NewString( const char *string );
//
void Cmd_Score_f( gentity_t *ent );
void G_StopFollowing( gentity_t *ent );
-void Cmd_FollowCycle_f( gentity_t *ent, int dir );
+void Cmd_Follow_f( gentity_t *ent );
//
// g_physics.c