# HG changeset patch # User Adam Kaminski # Date 1632230750 14400 # Tue Sep 21 09:25:50 2021 -0400 # Node ID 61947626089ddb6e20890252948f736533a59d77 # Parent 0b0c864652272a3c7f8925ce3f499211e841ee57 Cleaned up and moved the code responsible for drawing the MOTD, and fixed the MOTD not using the color to print mid-screen messages with. diff -r 0b0c86465227 -r 61947626089d src/c_console.cpp --- a/src/c_console.cpp Sun Sep 19 15:48:29 2021 -0400 +++ b/src/c_console.cpp Tue Sep 21 09:25:50 2021 -0400 @@ -2271,6 +2271,28 @@ } } +// [AK] Prints the MOTD in the centre of the screen. +void C_MOTDPrint (FString msg) +{ + if (msg.Len( ) <= 0) + return; + + FString ConsoleString; + ConsoleString.Format ("%s\n%s\n%s\n", bar1, msg, bar3); + + // Add this message to the console window. + AddToConsole (-1, ConsoleString); + + // We cannot create the message if there's no status bar to attach it to. + if (StatusBar == NULL) + return; + + // [AK] Print the MOTD in the same color the user wishes to print mid-screen messages in. + EColorRange Color = static_cast (PrintColors[PRINTLEVELS]); + DHUDMessageFadeOut* pMsg = new DHUDMessageFadeOut (SmallFont, msg, 1.5f, 0.375f, 0, 0, Color, cl_motdtime, 0.35f); + StatusBar->AttachMessage (pMsg, MAKE_ID('M','O','T','D')); +} + /****** Tab completion code ******/ struct TabData diff -r 0b0c86465227 -r 61947626089d src/c_console.h --- a/src/c_console.h Sun Sep 19 15:48:29 2021 -0400 +++ b/src/c_console.h Tue Sep 21 09:25:50 2021 -0400 @@ -84,6 +84,7 @@ class FFont; void C_MidPrint (FFont *font, const char *message); void C_MidPrintBold (FFont *font, const char *message); +void C_MOTDPrint (FString message); // [AK] bool C_Responder (event_t *ev); diff -r 0b0c86465227 -r 61947626089d src/cl_main.cpp --- a/src/cl_main.cpp Sun Sep 19 15:48:29 2021 -0400 +++ b/src/cl_main.cpp Tue Sep 21 09:25:50 2021 -0400 @@ -2801,46 +2801,6 @@ //***************************************************************************** // -// :(. This is needed so that the MOTD can be printed in the color the user wishes to print -// mid-screen messages in. -extern int PrintColors[7]; -void CLIENT_DisplayMOTD( void ) -{ - FString ConsoleString; - - if ( g_MOTD.Len( ) <= 0 ) - return; - - // Add pretty colors/formatting! - V_ColorizeString( g_MOTD ); - - ConsoleString.AppendFormat( TEXTCOLOR_RED - "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" - "\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_TAN - "\n\n%s\n" TEXTCOLOR_RED - "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" - "\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_NORMAL "\n\n" , - g_MOTD.GetChars() ); - - // Add this message to the console window. - AddToConsole( -1, ConsoleString ); - - // We cannot create the message if there's no status bar to attach it to. - if ( StatusBar == NULL ) - return; - - StatusBar->AttachMessage( new DHUDMessageFadeOut( SmallFont, g_MOTD, - 1.5f, - 0.375f, - 0, - 0, - (EColorRange)PrintColors[5], - cl_motdtime, - 0.35f ), MAKE_ID('M','O','T','D') ); -} - -//***************************************************************************** -// AActor *CLIENT_FindThingByNetID( LONG lNetID ) { return ( g_NetIDList.findPointerByID ( lNetID ) ); @@ -3383,7 +3343,7 @@ } // Display the message of the day. - CLIENT_DisplayMOTD( ); + C_MOTDPrint( g_MOTD ); } //***************************************************************************** @@ -5693,6 +5653,8 @@ g_MOTD = motd; // [BB] Some cleaning of the string since we can't trust the server. V_RemoveTrailingCrapFromFString ( g_MOTD ); + // [AK] Add pretty colors/formatting! + V_ColorizeString( g_MOTD ); } //***************************************************************************** @@ -9518,7 +9480,10 @@ //***************************************************************************** // [Dusk] Redisplay the MOTD -CCMD( motd ) {CLIENT_DisplayMOTD();} +CCMD( motd ) +{ + C_MOTDPrint( g_MOTD ); +} //***************************************************************************** // CONSOLE VARIABLES diff -r 0b0c86465227 -r 61947626089d src/cl_main.h --- a/src/cl_main.h Sun Sep 19 15:48:29 2021 -0400 +++ b/src/cl_main.h Tue Sep 21 09:25:50 2021 -0400 @@ -162,7 +162,6 @@ void CLIENT_SpawnMissile( const PClass *pType, fixed_t X, fixed_t Y, fixed_t Z, fixed_t VelX, fixed_t VelY, fixed_t VelZ, LONG lNetID, LONG lTargetNetID ); void CLIENT_MoveThing( AActor *pActor, fixed_t X, fixed_t Y, fixed_t Z ); AActor *CLIENT_FindThingByNetID( LONG lID ); -void CLIENT_DisplayMOTD( void ); void CLIENT_RestoreSpecialPosition( AActor *pActor ); void CLIENT_RestoreSpecialDoomThing( AActor *pActor, bool bFog ); AInventory *CLIENT_FindPlayerInventory( ULONG ulPlayer, const PClass *pType );