diff options
author | Andrey Nazarov <skuller@skuller.net> | 2008-09-28 18:03:56 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2008-09-28 18:03:56 +0000 |
commit | cbe71bc9831ea939c86dae6a6ebbd92bdebf8fbf (patch) | |
tree | 42bb9a8aee2310bb2e9fbd3ebeae315603e1c004 /source | |
parent | b952a73bd5087e2b2e25a143c58c1f1d25e7cd3a (diff) |
Made MVD observers switch to the previous chase target during map change
after the intermission.
Ensure end-of-match scoreboard and MVD client list are reliably delivered.
Properly reset cursor position when switching between layouts.
Diffstat (limited to 'source')
-rw-r--r-- | source/mvd_client.c | 19 | ||||
-rw-r--r-- | source/mvd_game.c | 36 | ||||
-rw-r--r-- | source/mvd_parse.c | 3 |
3 files changed, 44 insertions, 14 deletions
diff --git a/source/mvd_client.c b/source/mvd_client.c index 5c7570c..16cec3e 100644 --- a/source/mvd_client.c +++ b/source/mvd_client.c @@ -201,7 +201,7 @@ void MVD_ClearState( mvd_t *mvd ) { mvd->layout[0] = 0; mvd->framenum = 0; - mvd->intermission = qfalse; + //mvd->intermission = qfalse; } void MVD_BeginWaiting( mvd_t *mvd ) { @@ -458,7 +458,7 @@ void MVD_GetStream( const char *uri ) { } void MVD_ChangeLevel( mvd_t *mvd ) { - udpClient_t *u; + udpClient_t *client; if( sv.state != ss_broadcast ) { MVD_Spawn_f(); // the game is just starting @@ -469,14 +469,21 @@ void MVD_ChangeLevel( mvd_t *mvd ) { MSG_WriteByte( svc_stufftext ); MSG_WriteString( va( "changing map=%s; reconnect\n", mvd->mapname ) ); - LIST_FOR_EACH( udpClient_t, u, &mvd->udpClients, entry ) { - SV_ClientReset( u->cl ); - u->cl->spawncount = mvd->servercount; - SV_ClientAddMessage( u->cl, MSG_RELIABLE ); + LIST_FOR_EACH( udpClient_t, client, &mvd->udpClients, entry ) { + if( mvd->intermission && client->cl->state == cs_spawned ) { + // make them switch to previous target instead of MVD dummy + client->target = client->oldtarget; + client->oldtarget = NULL; + } + SV_ClientReset( client->cl ); + client->cl->spawncount = mvd->servercount; + SV_ClientAddMessage( client->cl, MSG_RELIABLE ); } SZ_Clear( &msg_write ); + mvd->intermission = qfalse; + SV_SendAsyncPackets(); } diff --git a/source/mvd_game.c b/source/mvd_game.c index 84293cd..aa55926 100644 --- a/source/mvd_game.c +++ b/source/mvd_game.c @@ -59,7 +59,7 @@ static void MVD_LayoutClients( udpClient_t *client ) { size_t len, total; udpClient_t *cl; mvd_t *mvd = client->mvd; - int y, i, prestep; + int y, i, prestep, flags; // calculate prestep if( client->layout_cursor < 0 ) { @@ -107,10 +107,16 @@ static void MVD_LayoutClients( udpClient_t *client ) { layout[total] = 0; + // the very first layout update is reliably delivered + flags = MSG_CLEAR; + if( !client->layout_time ) { + flags |= MSG_RELIABLE; + } + // send the layout MSG_WriteByte( svc_layout ); MSG_WriteData( layout, total + 1 ); - SV_ClientAddMessage( client->cl, MSG_CLEAR ); + SV_ClientAddMessage( client->cl, flags ); client->layout_time = svs.realtime; } @@ -242,11 +248,17 @@ static void MVD_LayoutScores( udpClient_t *client ) { mvd_t *mvd = client->mvd; char *layout = mvd->layout[0] ? mvd->layout : "xv 100 yv 60 string \"<no scoreboard>\""; + int flags = MSG_CLEAR; + + // end-of-match scoreboard is reliably delivered + if( mvd->intermission ) { + flags |= MSG_RELIABLE; + } // send the layout MSG_WriteByte( svc_layout ); MSG_WriteString( layout ); - SV_ClientAddMessage( client->cl, MSG_CLEAR ); + SV_ClientAddMessage( client->cl, flags ); client->layout_time = svs.realtime; } @@ -658,7 +670,7 @@ void MVD_TrySwitchChannel( udpClient_t *client, mvd_t *mvd ) { return; } MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, UF_MUTE_MISC, - "[MVD] %s left the channel.\n", client->cl->name ); + "[MVD] %s left the channel\n", client->cl->name ); } MVD_SwitchChannel( client, mvd ); @@ -864,9 +876,11 @@ static void MVD_Invuse_f( udpClient_t *client ) { break; case 2: client->layout_type = LAYOUT_CLIENTS; + client->layout_cursor = 0; break; case 3: client->layout_type = LAYOUT_CHANNELS; + client->layout_cursor = 0; break; case 4: MVD_TrySwitchChannel( client, &mvd_waitingRoom ); @@ -962,12 +976,14 @@ static void MVD_Channels_f( udpClient_t *client ) { if( Cmd_Argc() > 1 ) { if( LIST_EMPTY( &mvd_ready ) ) { - Com_Printf( "No ready channels.\n" ); + SV_ClientPrintf( client->cl, PRINT_HIGH, + "No ready channels.\n" ); return; } } else { if( LIST_EMPTY( &mvd_active ) ) { - Com_Printf( "No active channels.\n" ); + SV_ClientPrintf( client->cl, PRINT_HIGH, + "No active channels.\n" ); return; } } @@ -991,6 +1007,7 @@ static void MVD_Clients_f( udpClient_t *client ) { // TODO: dump them in console client->layout_type = LAYOUT_CLIENTS; client->layout_time = 0; + client->layout_cursor = 0; } static void MVD_Commands_f( udpClient_t *client ) { @@ -1249,6 +1266,9 @@ static void MVD_GameClientBegin( edict_t *ent ) { memset( &client->lastcmd, 0, sizeof( client->lastcmd ) ); memset( &client->ps, 0, sizeof( client->ps ) ); client->jump_held = qfalse; + client->layout_type = LAYOUT_NONE; + client->layout_time = 0; + client->layout_cursor = 0; if( !client->begin_time ) { MVD_BroadcastPrintf( mvd, PRINT_MEDIUM, UF_MUTE_MISC, @@ -1422,7 +1442,9 @@ static void MVD_IntermissionStart( mvd_t *mvd ) { } client->oldtarget = client->target; client->target = mvd->dummy; - MVD_SetFollowLayout( client ); + if( client->layout_type < LAYOUT_SCORES ) { + MVD_SetDefaultLayout( client ); + } } } diff --git a/source/mvd_parse.c b/source/mvd_parse.c index d587d1e..5873bcf 100644 --- a/source/mvd_parse.c +++ b/source/mvd_parse.c @@ -298,7 +298,7 @@ static void MVD_UnicastLayout( mvd_t *mvd, qboolean reliable, mvd_player_t *play MSG_ReadString( mvd->layout, sizeof( mvd->layout ) ); - // send to all relevant clients + // force an update to all relevant clients LIST_FOR_EACH( udpClient_t, client, &mvd->udpClients, entry ) { if( client->cl->state < cs_spawned ) { continue; @@ -1021,6 +1021,7 @@ static void MVD_ParseServerData( mvd_t *mvd ) { MVD_CheckActive( mvd ); } + // case all UDP clients to reconnect MVD_ChangeLevel( mvd ); } |