summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/g_public.h1
-rw-r--r--source/mvd_game.c101
-rw-r--r--source/mvd_local.h3
-rw-r--r--source/sv_local.h3
-rw-r--r--source/sv_main.c4
5 files changed, 78 insertions, 34 deletions
diff --git a/source/g_public.h b/source/g_public.h
index 789423e..4ab442d 100644
--- a/source/g_public.h
+++ b/source/g_public.h
@@ -42,6 +42,7 @@ typedef enum {
#define GMF_CLIENTNUM 1
#define GMF_PROPERINUSE 2
#define GMF_MVDSPEC 4
+#define GMF_WANT_ALL_DISCONNECTS 8
//===============================================================
diff --git a/source/mvd_game.c b/source/mvd_game.c
index b6d2c9c..84293cd 100644
--- a/source/mvd_game.c
+++ b/source/mvd_game.c
@@ -123,7 +123,10 @@ static void MVD_LayoutChannels( udpClient_t *client ) {
"xv 64 yv 48 string2 \"Name Map S/P\""
"yv 56 string \"------------ ------- ---\" xv 56 ";
static const char nochans[] =
- "yv 64 string \" <no active channels>\"";
+ "yv 72 string \" No active channels.\""
+ "yv 80 string \" Please wait until players\""
+ "yv 88 string \" connect.\""
+ ;
char layout[MAX_STRING_CHARS];
char buffer[MAX_QPATH];
mvd_t *mvd;
@@ -921,48 +924,66 @@ static void MVD_Join_f( udpClient_t *client ) {
MVD_TrySwitchChannel( client, mvd );
}
-static void MVD_Channels_f( udpClient_t *client ) {
- mvd_t *mvd;
+static void print_channel( client_t *cl, mvd_t *mvd ) {
mvd_player_t *player;
char buffer[MAX_QPATH];
size_t len, total;
int i;
- if( LIST_EMPTY( &mvd_active ) ) {
- Com_Printf( "No channels to watch.\n" );
- return;
+ total = 0;
+ for( i = 0; i < mvd->maxclients; i++ ) {
+ player = &mvd->players[i];
+ if( !player->inuse || player == mvd->dummy ) {
+ continue;
+ }
+ len = strlen( player->name );
+ if( total + len + 2 >= sizeof( buffer ) ) {
+ break;
+ }
+ if( total ) {
+ buffer[total+0] = ',';
+ buffer[total+1] = ' ';
+ total += 2;
+ }
+ memcpy( buffer + total, player->name, len );
+ total += len;
+ }
+ buffer[total] = 0;
+
+ SV_ClientPrintf( cl, PRINT_HIGH,
+ "%2d %-12.12s %-8.8s %3d %3d %s\n", mvd->id,
+ mvd->name, mvd->mapname,
+ List_Count( &mvd->udpClients ),
+ mvd->numplayers, buffer );
+}
+
+static void MVD_Channels_f( udpClient_t *client ) {
+ mvd_t *mvd;
+
+ if( Cmd_Argc() > 1 ) {
+ if( LIST_EMPTY( &mvd_ready ) ) {
+ Com_Printf( "No ready channels.\n" );
+ return;
+ }
+ } else {
+ if( LIST_EMPTY( &mvd_active ) ) {
+ Com_Printf( "No active channels.\n" );
+ return;
+ }
}
SV_ClientPrintf( client->cl, PRINT_HIGH,
"id name map spc plr who is playing\n"
"-- ------------ -------- --- --- --------------\n" );
- LIST_FOR_EACH( mvd_t, mvd, &mvd_active, active ) {
- total = 0;
- for( i = 0; i < mvd->maxclients; i++ ) {
- player = &mvd->players[i];
- if( !player->inuse || player == mvd->dummy ) {
- continue;
- }
- len = strlen( player->name );
- if( total + len + 2 >= sizeof( buffer ) ) {
- break;
- }
- if( total ) {
- buffer[total+0] = ',';
- buffer[total+1] = ' ';
- total += 2;
- }
- memcpy( buffer + total, player->name, len );
- total += len;
+ if( Cmd_Argc() > 1 ) {
+ LIST_FOR_EACH( mvd_t, mvd, &mvd_ready, ready ) {
+ print_channel( client->cl, mvd );
+ }
+ } else {
+ LIST_FOR_EACH( mvd_t, mvd, &mvd_active, active ) {
+ print_channel( client->cl, mvd );
}
- buffer[total] = 0;
-
- SV_ClientPrintf( client->cl, PRINT_HIGH,
- "%2d %-12.12s %-8.8s %3d %3d %s\n", mvd->id,
- mvd->name, mvd->mapname,
- List_Count( &mvd->udpClients ),
- mvd->numplayers, buffer );
}
}
@@ -972,6 +993,18 @@ static void MVD_Clients_f( udpClient_t *client ) {
client->layout_time = 0;
}
+static void MVD_Commands_f( udpClient_t *client ) {
+ SV_ClientPrintf( client->cl, PRINT_HIGH,
+ "chase [player_id] toggle chasecam mode\n"
+ "observe toggle observer mode\n"
+ "menu show main menu\n"
+ "score show scoreboard\n"
+ "channels [all] list active (or all) channels\n"
+ "join [channel_id] join specified channel\n"
+ "leave leave into the Waiting Room\n"
+ );
+}
+
static void MVD_GameClientCommand( edict_t *ent ) {
udpClient_t *client = EDICT_MVDCL( ent );
char *cmd;
@@ -1054,6 +1087,10 @@ static void MVD_GameClientCommand( edict_t *ent ) {
MVD_TrySwitchChannel( client, &mvd_waitingRoom );
return;
}
+ if( !strcmp( cmd, "commands" ) ) {
+ MVD_Commands_f( client );
+ return;
+ }
MVD_Say_f( client, 0 );
}
@@ -1096,7 +1133,7 @@ static void MVD_GameInit( void ) {
mvd_default_map = Cvar_Get( "mvd_default_map", "q2dm1", CVAR_LATCH );
mvd_stats_hack = Cvar_Get( "mvd_stats_hack", "0", 0 );
mvd_freeze_hack = Cvar_Get( "mvd_freeze_hack", "1", 0 );
- Cvar_Set( "g_features", va( "%d", GMF_CLIENTNUM|GMF_PROPERINUSE ) );
+ Cvar_Set( "g_features", va( "%d", MVD_FEATURES ) );
Z_TagReserve( ( sizeof( edict_t ) +
sizeof( udpClient_t ) ) * sv_maxclients->integer +
diff --git a/source/mvd_local.h b/source/mvd_local.h
index 03d98e6..8af34fb 100644
--- a/source/mvd_local.h
+++ b/source/mvd_local.h
@@ -28,6 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EDICT_MVDCL( ent ) (( udpClient_t * )( (ent)->client ))
#define CS_NUM( c, n ) ( ( char * )(c) + (n) * MAX_QPATH )
+// game features MVD client supports
+#define MVD_FEATURES (GMF_CLIENTNUM|GMF_PROPERINUSE|GMF_WANT_ALL_DISCONNECTS)
+
typedef enum {
MVD_DEAD, // not active at all
MVD_CONNECTING, // connect() in progress
diff --git a/source/sv_local.h b/source/sv_local.h
index 22d5457..d2b9940 100644
--- a/source/sv_local.h
+++ b/source/sv_local.h
@@ -59,6 +59,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SV_InfoSet( var, val ) \
Cvar_FullSet( var, val, CVAR_SERVERINFO|CVAR_ROM, CVAR_SET_DIRECT )
+// game features this server supports
+#define SV_FEATURES (GMF_CLIENTNUM|GMF_PROPERINUSE|GMF_MVDSPEC|GMF_WANT_ALL_DISCONNECTS)
+
typedef struct {
unsigned numEntities;
unsigned firstEntity;
diff --git a/source/sv_main.c b/source/sv_main.c
index baefaef..ae22597 100644
--- a/source/sv_main.c
+++ b/source/sv_main.c
@@ -197,7 +197,7 @@ void SV_DropClient( client_t *client, const char *reason ) {
MSG_WriteByte( svc_disconnect );
SV_ClientAddMessage( client, MSG_RELIABLE|MSG_CLEAR );
- if( oldstate == cs_spawned ) {
+ if( oldstate == cs_spawned || ( g_features->integer & GMF_WANT_ALL_DISCONNECTS ) ) {
// call the prog function for removing a client
// this will remove the body, among other things
ge->ClientDisconnect( client->edict );
@@ -1852,7 +1852,7 @@ void SV_Init( void ) {
sv_badauth_time = Cvar_Get( "sv_badauth_time", "1", 0 );
sv_badauth_time->changed = sv_badauth_time_changed;
- Cvar_Get( "sv_features", va( "%d", GMF_CLIENTNUM|GMF_MVDSPEC ), CVAR_ROM );
+ Cvar_Get( "sv_features", va( "%d", SV_FEATURES ), CVAR_ROM );
g_features = Cvar_Get( "g_features", "0", CVAR_ROM );
// set up default pmove parameters