Skip to content

Commit 455dfab

Browse files
authored
[GEN][ZH] Demote throw to assert in InGameUI::message, InGameUI::messageColor (#860)
1 parent 0b628dd commit 455dfab

File tree

6 files changed

+80
-52
lines changed

6 files changed

+80
-52
lines changed

Generals/Code/GameEngine/Source/Common/System/AsciiString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ void AsciiString::format_va(const char* format, va_list args)
387387
}
388388
else
389389
{
390-
DEBUG_ASSERTCRASH(false, ("AsciiString::format_va failed with code:%d format:\"%s\"", result, format));
390+
DEBUG_CRASH(("AsciiString::format_va failed with code:%d format:\"%s\"", result, format));
391391
}
392392
}
393393

Generals/Code/GameEngine/Source/Common/System/UnicodeString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void UnicodeString::format_va(const WideChar* format, va_list args)
324324
}
325325
else
326326
{
327-
DEBUG_ASSERTCRASH(false, ("UnicodeString::format_va failed with code:%d", result));
327+
DEBUG_CRASH(("UnicodeString::format_va failed with code:%d", result));
328328
}
329329
}
330330

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,16 +1968,21 @@ void InGameUI::message( AsciiString stringManagerLabel, ... )
19681968

19691969
// construct the final text after formatting
19701970
va_list args;
1971-
va_start( args, stringManagerLabel );
1971+
va_start( args, stringManagerLabel );
19721972
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
1973-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, stringManagerString.str(), args ) < 0 )
1974-
throw ERROR_OUT_OF_MEMORY;
1975-
formattedMessage.set( buf );
1976-
va_end(args);
1977-
1978-
// add the text to the ui
1979-
addMessageText( formattedMessage );
1973+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, stringManagerString.str(), args );
1974+
va_end(args);
19801975

1976+
if( result >= 0 )
1977+
{
1978+
formattedMessage.set( buf );
1979+
// add the text to the ui
1980+
addMessageText( formattedMessage );
1981+
}
1982+
else
1983+
{
1984+
DEBUG_CRASH(("InGameUI::message failed with code:%d", result));
1985+
}
19811986
} // end
19821987

19831988
//-------------------------------------------------------------------------------------------------
@@ -1990,16 +1995,21 @@ void InGameUI::message( UnicodeString format, ... )
19901995

19911996
// construct the final text after formatting
19921997
va_list args;
1993-
va_start( args, format );
1998+
va_start( args, format );
19941999
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
1995-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args ) < 0 )
1996-
throw ERROR_OUT_OF_MEMORY;
1997-
formattedMessage.set( buf );
1998-
va_end(args);
1999-
2000-
// add the text to the ui
2001-
addMessageText( formattedMessage );
2000+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args );
2001+
va_end(args);
20022002

2003+
if( result >= 0 )
2004+
{
2005+
formattedMessage.set( buf );
2006+
// add the text to the ui
2007+
addMessageText( formattedMessage );
2008+
}
2009+
else
2010+
{
2011+
DEBUG_CRASH(("InGameUI::message failed with code:%d", result));
2012+
}
20032013
} // end message
20042014

20052015
//-------------------------------------------------------------------------------------------------
@@ -2012,16 +2022,20 @@ void InGameUI::messageColor( const RGBColor *rgbColor, UnicodeString format, ...
20122022

20132023
// construct the final text after formatting
20142024
va_list args;
2015-
va_start( args, format );
2025+
va_start( args, format );
20162026
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
2017-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args ) < 0 )
2018-
throw ERROR_OUT_OF_MEMORY;
2019-
formattedMessage.set( buf );
2020-
va_end(args);
2021-
2022-
// add the text to the ui
2023-
addMessageText( formattedMessage, rgbColor );
2027+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args );
20242028

2029+
if( result >= 0 )
2030+
{
2031+
formattedMessage.set( buf );
2032+
// add the text to the ui
2033+
addMessageText( formattedMessage, rgbColor );
2034+
}
2035+
else
2036+
{
2037+
DEBUG_CRASH(("InGameUI::messageColor failed with code:%d", result));
2038+
}
20252039
} // end message
20262040

20272041
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/Common/System/AsciiString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void AsciiString::format_va(const char* format, va_list args)
300300
}
301301
else
302302
{
303-
DEBUG_ASSERTCRASH(false, ("AsciiString::format_va failed with code:%d format:\"%s\"", result, format));
303+
DEBUG_CRASH(("AsciiString::format_va failed with code:%d format:\"%s\"", result, format));
304304
}
305305
}
306306

GeneralsMD/Code/GameEngine/Source/Common/System/UnicodeString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void UnicodeString::format_va(const WideChar* format, va_list args)
324324
}
325325
else
326326
{
327-
DEBUG_ASSERTCRASH(false, ("UnicodeString::format_va failed with code:%d", result));
327+
DEBUG_CRASH(("UnicodeString::format_va failed with code:%d", result));
328328
}
329329
}
330330

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,16 +2024,21 @@ void InGameUI::message( AsciiString stringManagerLabel, ... )
20242024

20252025
// construct the final text after formatting
20262026
va_list args;
2027-
va_start( args, stringManagerLabel );
2027+
va_start( args, stringManagerLabel );
20282028
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
2029-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, stringManagerString.str(), args ) < 0 )
2030-
throw ERROR_OUT_OF_MEMORY;
2031-
formattedMessage.set( buf );
2032-
va_end(args);
2033-
2034-
// add the text to the ui
2035-
addMessageText( formattedMessage );
2029+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, stringManagerString.str(), args );
2030+
va_end(args);
20362031

2032+
if( result >= 0 )
2033+
{
2034+
formattedMessage.set( buf );
2035+
// add the text to the ui
2036+
addMessageText( formattedMessage );
2037+
}
2038+
else
2039+
{
2040+
DEBUG_CRASH(("InGameUI::message failed with code:%d", result));
2041+
}
20372042
} // end
20382043

20392044
//-------------------------------------------------------------------------------------------------
@@ -2046,16 +2051,21 @@ void InGameUI::message( UnicodeString format, ... )
20462051

20472052
// construct the final text after formatting
20482053
va_list args;
2049-
va_start( args, format );
2054+
va_start( args, format );
20502055
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
2051-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args ) < 0 )
2052-
throw ERROR_OUT_OF_MEMORY;
2053-
formattedMessage.set( buf );
2054-
va_end(args);
2055-
2056-
// add the text to the ui
2057-
addMessageText( formattedMessage );
2056+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args );
2057+
va_end(args);
20582058

2059+
if( result >= 0 )
2060+
{
2061+
formattedMessage.set( buf );
2062+
// add the text to the ui
2063+
addMessageText( formattedMessage );
2064+
}
2065+
else
2066+
{
2067+
DEBUG_CRASH(("InGameUI::message failed with code:%d", result));
2068+
}
20592069
} // end message
20602070

20612071
//-------------------------------------------------------------------------------------------------
@@ -2068,16 +2078,20 @@ void InGameUI::messageColor( const RGBColor *rgbColor, UnicodeString format, ...
20682078

20692079
// construct the final text after formatting
20702080
va_list args;
2071-
va_start( args, format );
2081+
va_start( args, format );
20722082
WideChar buf[ UnicodeString::MAX_FORMAT_BUF_LEN ];
2073-
if( _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args ) < 0 )
2074-
throw ERROR_OUT_OF_MEMORY;
2075-
formattedMessage.set( buf );
2076-
va_end(args);
2077-
2078-
// add the text to the ui
2079-
addMessageText( formattedMessage, rgbColor );
2083+
int result = _vsnwprintf(buf, sizeof( buf )/sizeof( WideChar ) - 1, format.str(), args );
20802084

2085+
if( result >= 0 )
2086+
{
2087+
formattedMessage.set( buf );
2088+
// add the text to the ui
2089+
addMessageText( formattedMessage, rgbColor );
2090+
}
2091+
else
2092+
{
2093+
DEBUG_CRASH(("InGameUI::messageColor failed with code:%d", result));
2094+
}
20812095
} // end message
20822096

20832097
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)