Revision | 9479c4fa2f10ca1cf39ff93ee59da8bf57d64f54 (tree) |
---|---|
Time | 2017-12-13 05:12:42 |
Author | Leonard <hobbax3@gmai...> |
Commiter | Leonard |
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.
@@ -2081,14 +2081,8 @@ | ||
2081 | 2081 | pFile = new CChatFile; |
2082 | 2082 | if ( pFile->LoadChatFile( szFilename ) == false ) |
2083 | 2083 | { |
2084 | - // Temporarily disable the use of color codes. | |
2085 | - CONSOLE_SetAllowColorCodes( false ); | |
2086 | - | |
2087 | 2084 | Printf( "botcmd_SayFromFile: Couldn't open file %s!\n", szFilename ); |
2088 | 2085 | |
2089 | - // Re-enable the use of color codes. | |
2090 | - CONSOLE_SetAllowColorCodes( true ); | |
2091 | - | |
2092 | 2086 | // Free the file before leaving. |
2093 | 2087 | delete( pFile ); |
2094 | 2088 | return; |
@@ -2097,14 +2091,8 @@ | ||
2097 | 2091 | sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection )); |
2098 | 2092 | if ( stricmp( szInString, "NULL" ) == 0 ) |
2099 | 2093 | { |
2100 | - // Temporarily disable the use of color codes. | |
2101 | - CONSOLE_SetAllowColorCodes( false ); | |
2102 | - | |
2103 | 2094 | Printf( "botcmd_SayFromFile: Couldn't find section %s in file %s!\n", szSection, szFilename ); |
2104 | 2095 | |
2105 | - // Re-enable the use of color codes. | |
2106 | - CONSOLE_SetAllowColorCodes( true ); | |
2107 | - | |
2108 | 2096 | // Free the file before leaving. |
2109 | 2097 | delete( pFile ); |
2110 | 2098 | return; |
@@ -2148,14 +2136,8 @@ | ||
2148 | 2136 | pFile = new CChatFile; |
2149 | 2137 | if ( pFile->LoadChatFile( szFilename ) == false ) |
2150 | 2138 | { |
2151 | - // Temporarily disable the use of color codes. | |
2152 | - CONSOLE_SetAllowColorCodes( false ); | |
2153 | - | |
2154 | 2139 | Printf( "botcmd_SayFromFile: Couldn't open file %s!\n", szFilename ); |
2155 | 2140 | |
2156 | - // Re-enable the use of color codes. | |
2157 | - CONSOLE_SetAllowColorCodes( true ); | |
2158 | - | |
2159 | 2141 | // Free the file before leaving. |
2160 | 2142 | delete( pFile ); |
2161 | 2143 | return; |
@@ -2164,14 +2146,8 @@ | ||
2164 | 2146 | sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection )); |
2165 | 2147 | if ( stricmp( szInString, "NULL" ) == 0 ) |
2166 | 2148 | { |
2167 | - // Temporarily disable the use of color codes. | |
2168 | - CONSOLE_SetAllowColorCodes( false ); | |
2169 | - | |
2170 | 2149 | Printf( "botcmd_SayFromChatFile: Couldn't find section %s in file %s!\n", szSection, szFilename ); |
2171 | 2150 | |
2172 | - // Re-enable the use of color codes. | |
2173 | - CONSOLE_SetAllowColorCodes( true ); | |
2174 | - | |
2175 | 2151 | // Free the file before leaving. |
2176 | 2152 | delete( pFile ); |
2177 | 2153 | return; |
@@ -2644,14 +2620,8 @@ | ||
2644 | 2620 | pFile = new CChatFile; |
2645 | 2621 | if ( pFile->LoadChatLump( szLumpname ) == false ) |
2646 | 2622 | { |
2647 | - // Temporarily disable the use of color codes. | |
2648 | - CONSOLE_SetAllowColorCodes( false ); | |
2649 | - | |
2650 | 2623 | Printf( "botcmd_SayFromLump: Couldn't open lump %s!\n", szLumpname ); |
2651 | 2624 | |
2652 | - // Re-enable the use of color codes. | |
2653 | - CONSOLE_SetAllowColorCodes( true ); | |
2654 | - | |
2655 | 2625 | // Free the file before leaving. |
2656 | 2626 | delete( pFile ); |
2657 | 2627 | return; |
@@ -2660,14 +2630,8 @@ | ||
2660 | 2630 | sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection )); |
2661 | 2631 | if ( stricmp( szInString, "NULL" ) == 0 ) |
2662 | 2632 | { |
2663 | - // Temporarily disable the use of color codes. | |
2664 | - CONSOLE_SetAllowColorCodes( false ); | |
2665 | - | |
2666 | 2633 | Printf( "botcmd_SayFromLump: Couldn't find section %s in lump %s!\n", szSection, szLumpname ); |
2667 | 2634 | |
2668 | - // Re-enable the use of color codes. | |
2669 | - CONSOLE_SetAllowColorCodes( true ); | |
2670 | - | |
2671 | 2635 | // Free the file before leaving. |
2672 | 2636 | delete( pFile ); |
2673 | 2637 | return; |
@@ -2711,14 +2675,8 @@ | ||
2711 | 2675 | pFile = new CChatFile; |
2712 | 2676 | if ( pFile->LoadChatLump( szLumpname ) == false ) |
2713 | 2677 | { |
2714 | - // Temporarily disable the use of color codes. | |
2715 | - CONSOLE_SetAllowColorCodes( false ); | |
2716 | - | |
2717 | 2678 | Printf( "botcmd_SayFromChatLump: Couldn't open lump %s!\n", szLumpname ); |
2718 | 2679 | |
2719 | - // Re-enable the use of color codes. | |
2720 | - CONSOLE_SetAllowColorCodes( true ); | |
2721 | - | |
2722 | 2680 | // Free the file before leaving. |
2723 | 2681 | delete pFile; |
2724 | 2682 | return; |
@@ -2727,14 +2685,8 @@ | ||
2727 | 2685 | sprintf( szInString, "%s", pFile->ChooseRandomEntry( szSection )); |
2728 | 2686 | if ( stricmp( szInString, "NULL" ) == 0 ) |
2729 | 2687 | { |
2730 | - // Temporarily disable the use of color codes. | |
2731 | - CONSOLE_SetAllowColorCodes( false ); | |
2732 | - | |
2733 | 2688 | Printf( "botcmd_SayFromChatLump: Couldn't find section %s in lump %s!\n", szSection, szLumpname ); |
2734 | 2689 | |
2735 | - // Re-enable the use of color codes. | |
2736 | - CONSOLE_SetAllowColorCodes( true ); | |
2737 | - | |
2738 | 2690 | // Free the file before leaving. |
2739 | 2691 | delete pFile; |
2740 | 2692 | return; |
@@ -237,9 +237,6 @@ | ||
237 | 237 | |
238 | 238 | static int NotifyTop, NotifyTopGoal; |
239 | 239 | |
240 | -// [BC] Should we allow color codes? | |
241 | -static bool g_bAllowColorCodes = true; | |
242 | - | |
243 | 240 | // [BC] Is there a player executing a remote control command? If so, display messages that |
244 | 241 | // are printed in the console as a result of his actions to him as well. |
245 | 242 | static ULONG g_ulRCONPlayer = MAXPLAYERS; |
@@ -690,13 +687,6 @@ | ||
690 | 687 | |
691 | 688 | //***************************************************************************** |
692 | 689 | // |
693 | -void CONSOLE_SetAllowColorCodes( bool bAllow ) | |
694 | -{ | |
695 | - g_bAllowColorCodes = bAllow; | |
696 | -} | |
697 | - | |
698 | -//***************************************************************************** | |
699 | -// | |
700 | 690 | void CONSOLE_SetRCONPlayer( ULONG ulPlayer ) |
701 | 691 | { |
702 | 692 | g_ulRCONPlayer = ulPlayer; |
@@ -973,7 +963,6 @@ | ||
973 | 963 | strcpy (copy,outlinecopy); |
974 | 964 | */ |
975 | 965 | FString copy = outlinecopy; |
976 | - V_ColorizeString( copy ); | |
977 | 966 | V_RemoveColorCodes( copy ); |
978 | 967 | |
979 | 968 | static bool needPrependedTimestamp = true; |
@@ -1040,9 +1029,6 @@ | ||
1040 | 1029 | if ( G15_IsReady() ) |
1041 | 1030 | G15_Printf( outlinecopy ); |
1042 | 1031 | |
1043 | - if ( g_bAllowColorCodes ) | |
1044 | - V_ColorizeString( outlinecopy ); | |
1045 | - | |
1046 | 1032 | // User wishes to remove color from all messages. |
1047 | 1033 | if ( con_colorinmessages == 0 ) |
1048 | 1034 | V_RemoveColorCodes( outlinecopy ); |
@@ -74,7 +74,6 @@ | ||
74 | 74 | void C_FlushDisplay (void); |
75 | 75 | |
76 | 76 | // [BC] New function prototypes. |
77 | -void CONSOLE_SetAllowColorCodes( bool bAllow ); | |
78 | 77 | void CONSOLE_SetRCONPlayer( ULONG ulPlayer ); |
79 | 78 | |
80 | 79 | void C_InitTicker (const char *label, unsigned int max, bool showpercent=true); |
@@ -788,12 +788,6 @@ | ||
788 | 788 | |
789 | 789 | ChatString = pszString; |
790 | 790 | |
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 | - | |
797 | 791 | // [BB] Remove invalid color codes, those can confuse the printing and create new lines. |
798 | 792 | V_RemoveInvalidColorCodes( ChatString ); |
799 | 793 |
@@ -343,6 +343,7 @@ | ||
343 | 343 | { |
344 | 344 | unsigned int teamId = i / MAX_BOTS_PER_TEAM; |
345 | 345 | FString botName = BOTINFO_GetName( botId ); |
346 | + V_ColorizeString( botName ); | |
346 | 347 | V_RemoveColorCodes( botName ); |
347 | 348 | |
348 | 349 | if ( teamId < teams.Size() ) |
@@ -362,6 +363,7 @@ | ||
362 | 363 | if ( BOTINFO_GetRevealed( botId ) && ( BOTINFO_GetName( botId ) != NULL )) |
363 | 364 | { |
364 | 365 | FString botName = BOTINFO_GetName( botId ); |
366 | + V_ColorizeString( botName ); | |
365 | 367 | V_RemoveColorCodes( botName ); |
366 | 368 | BOTSPAWN_AddToTable( botName, NULL ); |
367 | 369 | } |
@@ -501,7 +501,6 @@ | ||
501 | 501 | szString[length] = 0; |
502 | 502 | |
503 | 503 | // Remove the colors. |
504 | - V_ColorizeString( szString ); | |
505 | 504 | V_RemoveColorCodes( szString ); |
506 | 505 | |
507 | 506 | // Convert back and clean up. |
@@ -820,6 +819,7 @@ | ||
820 | 819 | } |
821 | 820 | |
822 | 821 | // [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. | |
823 | 823 | void V_RemoveInvalidColorCodes( char *pszString ) |
824 | 824 | { |
825 | 825 | if ( pszString == NULL ) |
@@ -831,14 +831,14 @@ | ||
831 | 831 | { |
832 | 832 | // [BB] If there is an color code start followed by an invalid char, remove the |
833 | 833 | // 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' ) ) ) | |
842 | 842 | pszString[i] = ' '; |
843 | 843 | } |
844 | 844 | } |