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:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent e1ae72a5f6
commit aac53ce71d
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -610,7 +610,7 @@ void UnHideMessagesDuringNPCDialogue( void )
return;
}
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...)
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, const CHAR16* pStringA, ...)
{
//__try
//{