diff options
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | source/mvd_client.c | 16 | ||||
-rw-r--r-- | source/mvd_game.c | 138 | ||||
-rw-r--r-- | source/mvd_local.h | 2 | ||||
-rw-r--r-- | source/mvd_parse.c | 5 | ||||
-rw-r--r-- | source/net_common.c | 2 | ||||
-rw-r--r-- | source/q_shared.h | 16 | ||||
-rw-r--r-- | source/sv_main.c | 20 |
8 files changed, 154 insertions, 47 deletions
@@ -50,7 +50,7 @@ hardlink="no" asm="no" anticheat="no" singleuser="no" -gldriver="libGL.so" +gldriver="libGL.so.1" indriver="" homedir="~/.q2pro" defcfg="/etc/default/q2pro" diff --git a/source/mvd_client.c b/source/mvd_client.c index 806f667..edcb826 100644 --- a/source/mvd_client.c +++ b/source/mvd_client.c @@ -806,10 +806,18 @@ mvd_t *MVD_SetChannel( int arg ) { return NULL; } - id = atoi( s ); - LIST_FOR_EACH( mvd_t, mvd, &mvd_channels, entry ) { - if( mvd->id == id ) { - return mvd; + if( COM_IsNumeric( s ) ) { + id = atoi( s ); + LIST_FOR_EACH( mvd_t, mvd, &mvd_channels, entry ) { + if( mvd->id == id ) { + return mvd; + } + } + } else { + LIST_FOR_EACH( mvd_t, mvd, &mvd_channels, entry ) { + if( !strcmp( mvd->name, s ) ) { + return mvd; + } } } diff --git a/source/mvd_game.c b/source/mvd_game.c index 04b90db..8486598 100644 --- a/source/mvd_game.c +++ b/source/mvd_game.c @@ -113,10 +113,11 @@ static void MVD_LayoutChannels( udpClient_t *client ) { static const char header[] = "xv 32 yv 8 picn inventory " "xv 240 yv 172 string2 " VERSION " " - "xv 64 yv 32 string2 \"Channel Map CL\"" - "yv 40 string \"------------- ------- --\" xv 56 "; + "xv 0 yv 32 cstring \"\020Channel Chooser\021\"" + "xv 64 yv 48 string2 \"Name Map CL\"" + "yv 56 string \"------------- ------- --\" xv 56 "; static const char nochans[] = - "yv 48 string \" <no channels>\""; + "yv 64 string \" <no channels>\""; char layout[MAX_STRING_CHARS]; char buffer[MAX_STRING_CHARS]; mvd_t *mvd; @@ -129,7 +130,7 @@ static void MVD_LayoutChannels( udpClient_t *client ) { if( cursor ) { clamp( client->layout_cursor, 0, cursor - 1 ); - y = 48; + y = 64; cursor = 0; LIST_FOR_EACH( mvd_t, mvd, &mvd_ready, ready ) { length = Com_sprintf( buffer, sizeof( buffer ), @@ -144,6 +145,9 @@ static void MVD_LayoutChannels( udpClient_t *client ) { memcpy( layout + total, buffer, length ); total += length; y += 8; + if( y > 172 ) { + break; + } cursor++; } @@ -163,23 +167,25 @@ static void MVD_LayoutChannels( udpClient_t *client ) { client->layout_time = svs.realtime; } -#define MENU_ITEMS 9 +#define MENU_ITEMS 10 #define YES "\xD9\xE5\xF3" #define NO "\xCE\xEF" static void MVD_LayoutMenu( udpClient_t *client ) { static const char format[] = "xv 32 yv 8 picn inventory " - "xv 72 yv 32 string \"Q2PRO MVD - Main Menu\" xv 56 " + "xv 0 yv 32 cstring \"\020Main Menu\021\" xv 56 " "yv 48 string2 \"%c%s in-eyes mode\"" "yv 56 string2 \"%cShow scoreboard\"" "yv 64 string2 \"%cShow spectators (%d)\"" "yv 72 string2 \"%cShow channels (%d)\"" "yv 80 string2 \"%cLeave this channel\"" "yv 96 string \"%cIgnore spectator chat: %s\"" - "yv 104 string \"%cIgnore player chat: %s\"" - "yv 112 string \"%cIgnore player FOV: %s\"" - "yv 128 string2 \"%cExit menu\"" + "yv 104 string \"%cIgnore connect msgs: %s\"" + "yv 112 string \"%cIgnore player chat: %s\"" + "yv 120 string \"%cIgnore player FOV: %s\"" + "yv 128 string \" (use 'set uf %d u' in cfg)\"" + "yv 144 string2 \"%cExit menu\"" "xv 240 yv 172 string2 " VERSION; char layout[MAX_STRING_CHARS]; char cur[MENU_ITEMS]; @@ -198,10 +204,12 @@ static void MVD_LayoutMenu( udpClient_t *client ) { cur[0], client->target ? "Leave" : "Enter", cur[1], cur[2], List_Count( &client->mvd->udpClients ), cur[3], List_Count( &mvd_ready ), cur[4], - cur[5], ( client->uf & UF_NOMVDCHAT ) ? YES : NO, - cur[6], ( client->uf & UF_NOGAMECHAT ) ? YES: NO, - cur[7], ( client->uf & UF_LOCALFOV ) ? YES : NO, - cur[8] ); + cur[5], ( client->uf & UF_MUTE_OBSERVERS ) ? YES : NO, + cur[6], ( client->uf & UF_MUTE_MISC ) ? YES : NO, + cur[7], ( client->uf & UF_MUTE_PLAYERS ) ? YES: NO, + cur[8], ( client->uf & UF_LOCALFOV ) ? YES : NO, + client->uf, + cur[9] ); // send the layout MSG_WriteByte( svc_layout ); @@ -464,6 +472,28 @@ static void MVD_FollowPrev( udpClient_t *client ) { MVD_FollowStart( client, target ); } +static mvd_player_t *MVD_MostFollowed( mvd_t *mvd ) { + int count[MAX_CLIENTS]; + udpClient_t *other; + mvd_player_t *target = NULL; + int i, maxcount = -1; + + memset( count, 0, sizeof( count ) ); + + LIST_FOR_EACH( udpClient_t, other, &mvd->udpClients, entry ) { + if( other->cl->state == cs_spawned && other->target ) { + count[ other->target - mvd->players ]++; + } + } + for( i = 0; i < mvd->maxclients; i++ ) { + if( mvd->players[i].inuse && maxcount < count[i] ) { + maxcount = count[i]; + target = &mvd->players[i]; + } + } + return target; +} + void MVD_UpdateClient( udpClient_t *client ) { mvd_t *mvd = client->mvd; mvd_player_t *target = client->target; @@ -525,7 +555,7 @@ void MVD_BroadcastPrintf( mvd_t *mvd, int level, int mask, const char *fmt, ... if( level < cl->messagelevel ) { continue; } - if( level == PRINT_CHAT && ( other->uf & mask ) ) { + if( other->uf & mask ) { continue; } SV_ClientAddMessage( cl, MSG_RELIABLE ); @@ -574,7 +604,7 @@ void MVD_TrySwitchChannel( udpClient_t *client, mvd_t *mvd ) { "[MVD] You may not switch channels too soon.\n" ); return; } - MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, 0, + MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, UF_MUTE_MISC, "[MVD] %s left the channel.\n", client->cl->name ); } @@ -617,7 +647,7 @@ static void MVD_Say_f( udpClient_t *client ) { "[MVD] Spectators may not talk on this server.\n" ); return; } - if( client->uf & UF_NOMVDCHAT ) { + if( client->uf & UF_MUTE_OBSERVERS ) { SV_ClientPrintf( client->cl, PRINT_HIGH, "[MVD] Please turn off ignore mode first.\n" ); return; @@ -651,11 +681,16 @@ static void MVD_Say_f( udpClient_t *client ) { text = Cmd_Args(); //text[128] = 0; // don't let it be too long - MVD_BroadcastPrintf( mvd, PRINT_CHAT, client->admin ? 0 : UF_NOMVDCHAT, + MVD_BroadcastPrintf( mvd, PRINT_CHAT, client->admin ? 0 : UF_MUTE_OBSERVERS, "{%s}: %s\n", client->cl->name, text ); } static void MVD_Observe_f( udpClient_t *client ) { + if( client->mvd == &mvd_waitingRoom ) { + SV_ClientPrintf( client->cl, PRINT_HIGH, + "[MVD] Please enter a channel first.\n" ); + return; + } if( client->target ) { MVD_FollowStop( client ); } else if( client->oldtarget && client->oldtarget->inuse ) { @@ -672,6 +707,12 @@ static void MVD_Follow_f( udpClient_t *client ) { char *s; int i, mask; + if( client->mvd == &mvd_waitingRoom ) { + SV_ClientPrintf( client->cl, PRINT_HIGH, + "[MVD] Please enter a channel first.\n" ); + return; + } + if( Cmd_Argc() < 2 ) { MVD_Observe_f( client ); return; @@ -697,7 +738,7 @@ static void MVD_Follow_f( udpClient_t *client ) { MVD_FollowStart( client, client->oldtarget ); } else { SV_ClientPrintf( client->cl, PRINT_HIGH, - "Previous target is not active.\n" ); + "[MVD] Previous target is not active.\n" ); } return; default: @@ -769,15 +810,18 @@ static void MVD_Invuse_f( udpClient_t *client ) { MVD_TrySwitchChannel( client, &mvd_waitingRoom ); return; case 5: - client->uf ^= UF_NOMVDCHAT; + client->uf ^= UF_MUTE_OBSERVERS; break; case 6: - client->uf ^= UF_NOGAMECHAT; + client->uf ^= UF_MUTE_MISC; break; case 7: - client->uf ^= UF_LOCALFOV; + client->uf ^= UF_MUTE_PLAYERS; break; case 8: + client->uf ^= UF_LOCALFOV; + break; + case 9: MVD_SetDefaultLayout( client ); break; } @@ -814,6 +858,11 @@ static void MVD_Join_f( udpClient_t *client ) { if( !mvd ) { return; } + if( mvd->state < MVD_WAITING ) { + SV_ClientPrintf( client->cl, PRINT_HIGH, + "[MVD] This channel is not ready yet.\n" ); + return; + } MVD_TrySwitchChannel( client, mvd ); } @@ -1048,6 +1097,7 @@ static qboolean MVD_GameClientConnect( edict_t *ent, char *userinfo ) { static void MVD_GameClientBegin( edict_t *ent ) { udpClient_t *client = EDICT_MVDCL( ent ); mvd_t *mvd = client->mvd; + mvd_player_t *target; client->floodTime = 0; client->floodHead = 0; @@ -1056,17 +1106,25 @@ static void MVD_GameClientBegin( edict_t *ent ) { client->jump_held = qfalse; if( !client->begin_time ) { - MVD_BroadcastPrintf( mvd, PRINT_MEDIUM, 0, + MVD_BroadcastPrintf( mvd, PRINT_MEDIUM, UF_MUTE_MISC, "[MVD] %s entered the channel\n", client->cl->name ); - } + target = MVD_MostFollowed( mvd ); + } else { + target = client->target; + } client->begin_time = svs.realtime; - // spawn the spectator - VectorScale( mvd->spawnOrigin, 8, client->ps.pmove.origin ); - VectorCopy( mvd->spawnAngles, client->ps.viewangles ); - MVD_SetDefaultLayout( client ); - MVD_FollowStop( client ); + + if( target && target->inuse ) { + // start chase cam mode + MVD_FollowStart( client, target ); + } else { + // spawn the spectator + VectorScale( mvd->spawnOrigin, 8, client->ps.pmove.origin ); + VectorCopy( mvd->spawnAngles, client->ps.viewangles ); + MVD_FollowStop( client ); + } } static void MVD_GameClientUserinfoChanged( edict_t *ent, char *userinfo ) { @@ -1090,12 +1148,34 @@ static void MVD_GameClientUserinfoChanged( edict_t *ent, char *userinfo ) { } } +void MVD_GameClientNameChanged( edict_t *ent, const char *name ) { + udpClient_t *client = EDICT_MVDCL( ent ); + client_t *cl = client->cl; + + if( client->begin_time ) { + MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, UF_MUTE_MISC, + "[MVD] %s changed name to %s\n", cl->name, name ); + } +} + +// called early from SV_Drop to prevent multiple disconnect messages +void MVD_GameClientDrop( edict_t *ent, const char *reason ) { + udpClient_t *client = EDICT_MVDCL( ent ); + client_t *cl = client->cl; + + if( client->begin_time ) { + MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, UF_MUTE_MISC, + "[MVD] %s was dropped: %s\n", cl->name, reason ); + client->begin_time = 0; + } +} + static void MVD_GameClientDisconnect( edict_t *ent ) { udpClient_t *client = EDICT_MVDCL( ent ); client_t *cl = client->cl; if( client->begin_time ) { - MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, 0, + MVD_BroadcastPrintf( client->mvd, PRINT_MEDIUM, UF_MUTE_MISC, "[MVD] %s disconnected\n", cl->name ); client->begin_time = 0; } diff --git a/source/mvd_local.h b/source/mvd_local.h index 4d44517..8450f7d 100644 --- a/source/mvd_local.h +++ b/source/mvd_local.h @@ -220,4 +220,6 @@ void MVD_RemoveClient( client_t *client ); void MVD_BroadcastPrintf( mvd_t *mvd, int level, int mask, const char *fmt, ... ) q_printf( 4, 5 ); void MVD_PrepWorldFrame( void ); +void MVD_GameClientNameChanged( edict_t *ent, const char *name ); +void MVD_GameClientDrop( edict_t *ent, const char *reason ); diff --git a/source/mvd_parse.c b/source/mvd_parse.c index b968539..946f54e 100644 --- a/source/mvd_parse.c +++ b/source/mvd_parse.c @@ -397,7 +397,7 @@ static void MVD_UnicastPrint( mvd_t *mvd, qboolean reliable, mvd_player_t *playe if( level < cl->messagelevel ) { continue; } - if( level == PRINT_CHAT && ( client->uf & UF_NOGAMECHAT ) ) { + if( level == PRINT_CHAT && ( client->uf & UF_MUTE_PLAYERS ) ) { continue; } target = client->target ? client->target : mvd->dummy; @@ -695,7 +695,8 @@ static void MVD_ParsePrint( mvd_t *mvd ) { int level = MSG_ReadByte(); char *string = MSG_ReadString(); - MVD_BroadcastPrintf( mvd, level, UF_NOGAMECHAT, "%s", string ); + MVD_BroadcastPrintf( mvd, level, level == PRINT_CHAT ? + UF_MUTE_PLAYERS : 0, "%s", string ); } /* diff --git a/source/net_common.c b/source/net_common.c index b2fbe7b..1474af2 100644 --- a/source/net_common.c +++ b/source/net_common.c @@ -1197,7 +1197,7 @@ qboolean NET_GetAddress( netsrc_t sock, netadr_t *adr ) { length = sizeof( address ); if( getsockname( udp_sockets[sock], ( struct sockaddr * ) - &address, &length ) == -1 ) + &address, &length ) == -1 ) { return qfalse; } diff --git a/source/q_shared.h b/source/q_shared.h index 9bd88a1..9933fc2 100644 --- a/source/q_shared.h +++ b/source/q_shared.h @@ -193,9 +193,14 @@ typedef struct vrect_s { // microsoft's fabs seems to be ungodly slow... static inline float Q_fabs( float f ) { - uint32_t tmp = *( uint32_t * )&f; - tmp &= 0x7FFFFFFF; - return *( float * )&tmp; + union { + uint32_t l; + float f; + } tmp; + + tmp.f = f; + tmp.l &= 0x7FFFFFFF; + return tmp.f; } #define Q_ftol( f ) ((long)(f)) @@ -1406,8 +1411,9 @@ ROGUE - VERSIONS #define UF_AUTOSCREENSHOT 1 #define UF_AUTORECORD 2 #define UF_LOCALFOV 4 -#define UF_NOGAMECHAT 8 -#define UF_NOMVDCHAT 16 +#define UF_MUTE_PLAYERS 8 +#define UF_MUTE_OBSERVERS 16 +#define UF_MUTE_MISC 32 /* ========================================================== diff --git a/source/sv_main.c b/source/sv_main.c index 5f7598f..85489e0 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -172,8 +172,13 @@ void SV_DropClient( client_t *client, const char *reason ) { if( reason ) { if( oldstate == cs_spawned ) { - SV_BroadcastPrintf( PRINT_HIGH, "%s was dropped: %s\n", - client->name, reason ); + // announce to others + if( sv.state == ss_broadcast ) { + MVD_GameClientDrop( client->edict, reason ); + } else { + SV_BroadcastPrintf( PRINT_HIGH, "%s was dropped: %s\n", + client->name, reason ); + } } // print this to client as they will not receive broadcast @@ -1640,9 +1645,14 @@ void SV_UserinfoChanged( client_t *cl ) { // mask off high bit for( i = 0; i < len; i++ ) name[i] &= 127; - if( dedicated->integer && cl->name[0] && strcmp( cl->name, name ) ) { - Com_Printf( "%s[%s] changed name to %s\n", cl->name, - NET_AdrToString( &cl->netchan->remote_address ), name ); + if( cl->name[0] && strcmp( cl->name, name ) ) { + if( dedicated->integer ) { + Com_Printf( "%s[%s] changed name to %s\n", cl->name, + NET_AdrToString( &cl->netchan->remote_address ), name ); + } + if( sv.state == ss_broadcast ) { + MVD_GameClientNameChanged( cl->edict, name ); + } } memcpy( cl->name, name, len + 1 ); |