Files
source/Utils/message.h
T
aac53ce71d 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>
2026-07-23 19:29:55 -03:00

122 lines
4.0 KiB
C

#ifndef __MESSAGE_H
#define __MESSAGE_H
//#include "sgp.h"
#include "Font.h"
#include "Font Control.h"
#include "types.h"
#include "FileMan.h"
struct stringstruct{
STR16 pString16;
INT32 iVideoOverlay;
UINT32 uiFont;
UINT16 usColor;
UINT32 uiFlags;
BOOLEAN fBeginningOfNewString;
UINT32 uiTimeOfLastUpdate;
UINT32 uiPadding[ 5 ];
struct stringstruct *pNext;
struct stringstruct *pPrev;
};
#define MSG_INTERFACE 0
#define MSG_DIALOG 1
#define MSG_MPSYSTEM 2
#define MSG_DEBUG 3
#define MSG_UI_FEEDBACK 4
#define MSG_ERROR 5
#define MSG_BETAVERSION 6
#define MSG_TESTVERSION 7
#define MSG_MAP_UI_POSITION_MIDDLE 8
#define MSG_MAP_UI_POSITION_UPPER 9
#define MSG_MAP_UI_POSITION_LOWER 10
#define MSG_SKULL_UI_FEEDBACK 11
#define MSG_CHAT 12
// These defines correlate to defines in font.h
#define MSG_FONT_RED FONT_MCOLOR_RED
#define MSG_FONT_YELLOW FONT_MCOLOR_LTYELLOW
#define MSG_FONT_WHITE FONT_MCOLOR_WHITE
typedef struct stringstruct ScrollStringSt;
typedef ScrollStringSt *ScrollStringStPtr;
extern ScrollStringStPtr pStringS;
extern UINT32 StringCount;
extern UINT8 gubCurrentMapMessageString;
extern BOOLEAN fDisableJustForIan;
// are we allowed to beep on message scroll in tactical
extern BOOLEAN fOkToBeepNewMessage;
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, const CHAR16* pStringA, ...);
// same as screen message, but only display to mapscreen message system, not tactical
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
void ScrollString( void );
void DisplayStringsInMapScreenMessageList( void );
void InitGlobalMessageList( void );
void FreeGlobalMessageList( void );
UINT8 GetRangeOfMapScreenMessages( void );
void EnableDisableScrollStringVideoOverlay( BOOLEAN fEnable );
// OJW - 20090315 - Allow access to these functions outside of message
// adding chat log
ScrollStringStPtr GetNextString(ScrollStringStPtr pStringSt);
ScrollStringStPtr GetPrevString(ScrollStringStPtr pStringSt);
void SetStringPosition(ScrollStringStPtr pStringSt, UINT16 x, UINT16 y);
void SetStringColor(ScrollStringStPtr pStringSt, UINT16 color);
ScrollStringStPtr SetStringNext(ScrollStringStPtr pStringSt, ScrollStringStPtr pNext);
ScrollStringStPtr SetStringPrev(ScrollStringStPtr pStringSt, ScrollStringStPtr pPrev);
void SetString(ScrollStringStPtr pStringSt, STR16 String);
// will go and clear all displayed strings off the screen
void ClearDisplayedListOfTacticalStrings( void );
// OJW - 20090426
void SetTacticalMessageFilter( UINT ubPriority );
void RemoveTacticalMessageFilter ( void );
// clear ALL strings in the tactical Message Queue
void ClearTacticalMessageQueue( void );
BOOLEAN LoadMapScreenMessagesFromSaveGameFile( HWFILE hFile );
BOOLEAN SaveMapScreenMessagesToSaveGameFile( HWFILE hFile );
// use these if you are not Kris
void HideMessagesDuringNPCDialogue( void );
void UnHideMessagesDuringNPCDialogue( void );
// disable and enable scroll string, only to be used by Kris
void DisableScrollMessages( void );
void EnableScrollMessages( void );
/* unused functions, written by Mr. Carter, so don't expect these to work...
UINT8 GetTheRelativePositionOfCurrentMessage( void );
void MoveCurrentMessagePointerDownList( void );
void MoveCurrentMessagePointerUpList( void );
void ScrollToHereInMapScreenMessageList( UINT8 ubPosition );
BOOLEAN IsThereAnEmptySlotInTheMapScreenMessageList( void );
UINT8 GetFirstEmptySlotInTheMapScreenMessageList( void );
void RemoveMapScreenMessageListString( ScrollStringStPtr pStringSt );
BOOLEAN AreThereASetOfStringsAfterThisIndex( UINT8 ubMsgIndex, INT32 iNumberOfStrings );
UINT8 GetCurrentMessageValue( void );
UINT8 GetCurrentTempMessageValue( void );
UINT8 GetNewMessageValueGivenPosition( UINT8 ubPosition );
BOOLEAN IsThisTheLastMessageInTheList( void );
BOOLEAN IsThisTheFirstMessageInTheList( void );
void DisplayLastMessage( void );
*/
#endif