• R/O
  • SSH

zandronum-zdoom-sync: Commit


Commit MetaInfo

Revision9479c4fa2f10ca1cf39ff93ee59da8bf57d64f54 (tree)
Time2017-12-13 05:12:42
AuthorLeonard <hobbax3@gmai...>
CommiterLeonard

Log Message

Removed unnecessary formatting code from Zandronum (fixes 1165).

Important things to note:
-It's still possible to say colorized stuff in the chat but only from the console
-Bot chat lines used to always be formatted
Considering our chat code is already very different from ZDoom, we should still enforce the formatting on chat lines.

Change Summary

Incremental Difference

diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/botcommands.cpp
--- a/src/botcommands.cpp Mon Nov 27 16:12:12 2017 +0100
+++ b/src/botcommands.cpp Tue Dec 12 21:12:42 2017 +0100
@@ -2081,14 +2081,8 @@
20812081 pFile = new CChatFile;
20822082 if ( pFile->LoadChatFile( szFilename ) == false )
20832083 {
2084- // Temporarily disable the use of color codes.
2085- CONSOLE_SetAllowColorCodes( false );
2086-
20872084 Printf( "botcmd_SayFromFile: Couldn't open file %s!\n", szFilename );
20882085
2089- // Re-enable the use of color codes.
2090- CONSOLE_SetAllowColorCodes( true );
2091-
20922086 // Free the file before leaving.
20932087 delete( pFile );
20942088 return;
@@ -2097,14 +2091,8 @@
20972091 sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection ));
20982092 if ( stricmp( szInString, "NULL" ) == 0 )
20992093 {
2100- // Temporarily disable the use of color codes.
2101- CONSOLE_SetAllowColorCodes( false );
2102-
21032094 Printf( "botcmd_SayFromFile: Couldn't find section %s in file %s!\n", szSection, szFilename );
21042095
2105- // Re-enable the use of color codes.
2106- CONSOLE_SetAllowColorCodes( true );
2107-
21082096 // Free the file before leaving.
21092097 delete( pFile );
21102098 return;
@@ -2148,14 +2136,8 @@
21482136 pFile = new CChatFile;
21492137 if ( pFile->LoadChatFile( szFilename ) == false )
21502138 {
2151- // Temporarily disable the use of color codes.
2152- CONSOLE_SetAllowColorCodes( false );
2153-
21542139 Printf( "botcmd_SayFromFile: Couldn't open file %s!\n", szFilename );
21552140
2156- // Re-enable the use of color codes.
2157- CONSOLE_SetAllowColorCodes( true );
2158-
21592141 // Free the file before leaving.
21602142 delete( pFile );
21612143 return;
@@ -2164,14 +2146,8 @@
21642146 sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection ));
21652147 if ( stricmp( szInString, "NULL" ) == 0 )
21662148 {
2167- // Temporarily disable the use of color codes.
2168- CONSOLE_SetAllowColorCodes( false );
2169-
21702149 Printf( "botcmd_SayFromChatFile: Couldn't find section %s in file %s!\n", szSection, szFilename );
21712150
2172- // Re-enable the use of color codes.
2173- CONSOLE_SetAllowColorCodes( true );
2174-
21752151 // Free the file before leaving.
21762152 delete( pFile );
21772153 return;
@@ -2644,14 +2620,8 @@
26442620 pFile = new CChatFile;
26452621 if ( pFile->LoadChatLump( szLumpname ) == false )
26462622 {
2647- // Temporarily disable the use of color codes.
2648- CONSOLE_SetAllowColorCodes( false );
2649-
26502623 Printf( "botcmd_SayFromLump: Couldn't open lump %s!\n", szLumpname );
26512624
2652- // Re-enable the use of color codes.
2653- CONSOLE_SetAllowColorCodes( true );
2654-
26552625 // Free the file before leaving.
26562626 delete( pFile );
26572627 return;
@@ -2660,14 +2630,8 @@
26602630 sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection ));
26612631 if ( stricmp( szInString, "NULL" ) == 0 )
26622632 {
2663- // Temporarily disable the use of color codes.
2664- CONSOLE_SetAllowColorCodes( false );
2665-
26662633 Printf( "botcmd_SayFromLump: Couldn't find section %s in lump %s!\n", szSection, szLumpname );
26672634
2668- // Re-enable the use of color codes.
2669- CONSOLE_SetAllowColorCodes( true );
2670-
26712635 // Free the file before leaving.
26722636 delete( pFile );
26732637 return;
@@ -2711,14 +2675,8 @@
27112675 pFile = new CChatFile;
27122676 if ( pFile->LoadChatLump( szLumpname ) == false )
27132677 {
2714- // Temporarily disable the use of color codes.
2715- CONSOLE_SetAllowColorCodes( false );
2716-
27172678 Printf( "botcmd_SayFromChatLump: Couldn't open lump %s!\n", szLumpname );
27182679
2719- // Re-enable the use of color codes.
2720- CONSOLE_SetAllowColorCodes( true );
2721-
27222680 // Free the file before leaving.
27232681 delete pFile;
27242682 return;
@@ -2727,14 +2685,8 @@
27272685 sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection ));
27282686 if ( stricmp( szInString, "NULL" ) == 0 )
27292687 {
2730- // Temporarily disable the use of color codes.
2731- CONSOLE_SetAllowColorCodes( false );
2732-
27332688 Printf( "botcmd_SayFromChatLump: Couldn't find section %s in lump %s!\n", szSection, szLumpname );
27342689
2735- // Re-enable the use of color codes.
2736- CONSOLE_SetAllowColorCodes( true );
2737-
27382690 // Free the file before leaving.
27392691 delete pFile;
27402692 return;
diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/c_console.cpp
--- a/src/c_console.cpp Mon Nov 27 16:12:12 2017 +0100
+++ b/src/c_console.cpp Tue Dec 12 21:12:42 2017 +0100
@@ -237,9 +237,6 @@
237237
238238 static int NotifyTop, NotifyTopGoal;
239239
240-// [BC] Should we allow color codes?
241-static bool g_bAllowColorCodes = true;
242-
243240 // [BC] Is there a player executing a remote control command? If so, display messages that
244241 // are printed in the console as a result of his actions to him as well.
245242 static ULONG g_ulRCONPlayer = MAXPLAYERS;
@@ -690,13 +687,6 @@
690687
691688 //*****************************************************************************
692689 //
693-void CONSOLE_SetAllowColorCodes( bool bAllow )
694-{
695- g_bAllowColorCodes = bAllow;
696-}
697-
698-//*****************************************************************************
699-//
700690 void CONSOLE_SetRCONPlayer( ULONG ulPlayer )
701691 {
702692 g_ulRCONPlayer = ulPlayer;
@@ -973,7 +963,6 @@
973963 strcpy (copy,outlinecopy);
974964 */
975965 FString copy = outlinecopy;
976- V_ColorizeString( copy );
977966 V_RemoveColorCodes( copy );
978967
979968 static bool needPrependedTimestamp = true;
@@ -1040,9 +1029,6 @@
10401029 if ( G15_IsReady() )
10411030 G15_Printf( outlinecopy );
10421031
1043- if ( g_bAllowColorCodes )
1044- V_ColorizeString( outlinecopy );
1045-
10461032 // User wishes to remove color from all messages.
10471033 if ( con_colorinmessages == 0 )
10481034 V_RemoveColorCodes( outlinecopy );
diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/c_console.h
--- a/src/c_console.h Mon Nov 27 16:12:12 2017 +0100
+++ b/src/c_console.h Tue Dec 12 21:12:42 2017 +0100
@@ -74,7 +74,6 @@
7474 void C_FlushDisplay (void);
7575
7676 // [BC] New function prototypes.
77-void CONSOLE_SetAllowColorCodes( bool bAllow );
7877 void CONSOLE_SetRCONPlayer( ULONG ulPlayer );
7978
8079 void C_InitTicker (const char *label, unsigned int max, bool showpercent=true);
diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/chat.cpp
--- a/src/chat.cpp Mon Nov 27 16:12:12 2017 +0100
+++ b/src/chat.cpp Tue Dec 12 21:12:42 2017 +0100
@@ -788,12 +788,6 @@
788788
789789 ChatString = pszString;
790790
791- // [RC] Remove linebreaks and other escape codes from chat.
792- ChatString.Substitute("\\", "\\\\");
793-
794- // [RC] ...but allow chat colors.
795- ChatString.Substitute("\\\\c", "\\c");
796-
797791 // [BB] Remove invalid color codes, those can confuse the printing and create new lines.
798792 V_RemoveInvalidColorCodes( ChatString );
799793
diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/menu/multiplayermenu.cpp
--- a/src/menu/multiplayermenu.cpp Mon Nov 27 16:12:12 2017 +0100
+++ b/src/menu/multiplayermenu.cpp Tue Dec 12 21:12:42 2017 +0100
@@ -343,6 +343,7 @@
343343 {
344344 unsigned int teamId = i / MAX_BOTS_PER_TEAM;
345345 FString botName = BOTINFO_GetName( botId );
346+ V_ColorizeString( botName );
346347 V_RemoveColorCodes( botName );
347348
348349 if ( teamId < teams.Size() )
@@ -362,6 +363,7 @@
362363 if ( BOTINFO_GetRevealed( botId ) && ( BOTINFO_GetName( botId ) != NULL ))
363364 {
364365 FString botName = BOTINFO_GetName( botId );
366+ V_ColorizeString( botName );
365367 V_RemoveColorCodes( botName );
366368 BOTSPAWN_AddToTable( botName, NULL );
367369 }
diff -r a98fb2bc6ad1 -r 9479c4fa2f10 src/v_text.cpp
--- a/src/v_text.cpp Mon Nov 27 16:12:12 2017 +0100
+++ b/src/v_text.cpp Tue Dec 12 21:12:42 2017 +0100
@@ -501,7 +501,6 @@
501501 szString[length] = 0;
502502
503503 // Remove the colors.
504- V_ColorizeString( szString );
505504 V_RemoveColorCodes( szString );
506505
507506 // Convert back and clean up.
@@ -820,6 +819,7 @@
820819 }
821820
822821 // [BB] Removes invalid color codes, i.e. \cX where X not in [a,u] or '-'.
822+// Note: this, just like V_RemoveColorCodes, expects already formatted strings.
823823 void V_RemoveInvalidColorCodes( char *pszString )
824824 {
825825 if ( pszString == NULL )
@@ -831,14 +831,14 @@
831831 {
832832 // [BB] If there is an color code start followed by an invalid char, remove the
833833 // leading '\' to disable the color code.
834- if ( V_ColorCodeStart ( pszString, i )
835- && ( pszString[i+2] != '-' )
836- && ( pszString[i+2] != '!' )
837- && ( pszString[i+2] != '*' )
838- && ( pszString[i+2] != '+' )
839- && ( pszString[i+2] != '[' )
840- && ( ( pszString[i+2] < 'a' ) || ( pszString[i+2] > 'v' ) )
841- && ( ( pszString[i+2] < 'A' ) || ( pszString[i+2] > 'V' ) ) )
834+ if ( pszString[i] == TEXTCOLOR_ESCAPE
835+ && ( pszString[i+1] != '-' )
836+ && ( pszString[i+1] != '!' )
837+ && ( pszString[i+1] != '*' )
838+ && ( pszString[i+1] != '+' )
839+ && ( pszString[i+1] != '[' )
840+ && ( ( pszString[i+1] < 'a' ) || ( pszString[i+1] > 'v' ) )
841+ && ( ( pszString[i+1] < 'A' ) || ( pszString[i+1] > 'V' ) ) )
842842 pszString[i] = ' ';
843843 }
844844 }
Show on old repository browser