mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
let ScreenMsg take a format string it will not write to
STR16 is CHAR16*, so ScreenMsg asked for a mutable format string it has no
intention of mutating: the body only hands it to va_start and vswprintf, and
vswprintf takes it as const.
Calls that pass a literal are accepted anyway under the MSVC rules clang-cl
applies. Calls that pass anything else are not, and DynamicDialogue.cpp picks
the format at runtime:
ScreenMsg( FONT_MCOLOR_LTGREEN, MSG_INTERFACE,
...sOpinionModifier >= 0 ? L"%s: %s +%d" : L"%s: %s %d", ... );
The conditional has type const wchar_t*, and there is nowhere for it to go.
Declaring the parameter const CHAR16* is what the function always meant. Every
existing caller still compiles: a literal and a CHAR16* both convert.
Verification:
ninja -C build parse # DynamicDialogue.cpp clean
ninja -C build -k 0 # Release, four applications, green
ninja -C build-debug -k 0 # Debug, four applications, green
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
committed by
majcosta
co-authored by
Claude Opus 4.8
parent
e1ae72a5f6
commit
aac53ce71d
+1
-1
@@ -610,7 +610,7 @@ void UnHideMessagesDuringNPCDialogue( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...)
|
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, const CHAR16* pStringA, ...)
|
||||||
{
|
{
|
||||||
//__try
|
//__try
|
||||||
//{
|
//{
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ extern BOOLEAN fDisableJustForIan;
|
|||||||
// are we allowed to beep on message scroll in tactical
|
// are we allowed to beep on message scroll in tactical
|
||||||
extern BOOLEAN fOkToBeepNewMessage;
|
extern BOOLEAN fOkToBeepNewMessage;
|
||||||
|
|
||||||
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
|
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, const CHAR16* pStringA, ...);
|
||||||
|
|
||||||
// same as screen message, but only display to mapscreen message system, not tactical
|
// same as screen message, but only display to mapscreen message system, not tactical
|
||||||
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
|
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
|
||||||
|
|||||||
Reference in New Issue
Block a user