mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
let the text drawing path take a string it will not write to
DrawTextToScreen takes STR16, a mutable wchar_t*, for a string it only
measures and prints. Quest Debug System.cpp picks its text with a conditional:
DrawTextToScreen( gubFact[ usLoop1 ] ? L"True" : L"False", ... );
which has type const wchar_t*. clang-cl's MSVC compatibility lets a bare
string literal decay to wchar_t*, but not a const wchar_t* expression, so it
reports
error: no matching function for call to 'DrawTextToScreen'
note: candidate function not viable: 1st argument ('const wchar_t *')
would lose const qualifier
The parameter is const-correct in every function DrawTextToScreen hands the
string on to, so the change follows the string down the call chain rather
than stopping at the top:
DrawTextToScreen, ShadowText Utils/WordWrap.h
WFStringPixLength Utils/Font Control.h
mprintf, StringPixLength, sgp/Font.h
VarFindFontCenterCoordinates,
VarFindFontRightCoordinates
WinFontStringPixLength sgp/WinFont.h
gprintfdirty TileEngine/Render Dirty.h
The varargs members of that list copy the format string into a local buffer
before doing anything with it, and the measuring ones walk it and return a
width; none of the nine assigns through the parameter. Where StringPixLength
casts the string to UINT16* to walk it, the cast and the local now carry the
const rather than dropping it.
Callers are unaffected: every one already passes something that converts to
const CHAR16*. Both configurations build with no new diagnostics, and the
parse sweep drops from 9 error sites in 7 files to 5 in 3.
To check the claim that nothing writes through these parameters, read the
nine bodies; each is short.
This commit is contained in:
committed by
majcosta
parent
c6a4fdb393
commit
b147e47856
@@ -347,7 +347,7 @@ UINT16 WFGetFontHeight( INT32 FontNum )
|
||||
}
|
||||
|
||||
|
||||
INT16 WFStringPixLength( STR16 string,INT32 UseFont )
|
||||
INT16 WFStringPixLength( const CHAR16* string,INT32 UseFont )
|
||||
{
|
||||
return( StringPixLength( string, UseFont ) );
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ extern INT32 giCurWinFont;
|
||||
|
||||
// ATE: A few winfont wrappers..
|
||||
UINT16 WFGetFontHeight( INT32 FontNum );
|
||||
INT16 WFStringPixLength( STR16 string,INT32 UseFont );
|
||||
INT16 WFStringPixLength( const CHAR16* string,INT32 UseFont );
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -497,7 +497,7 @@ UINT16 DeleteWrappedString(WRAPPED_STRING *pWrappedString)
|
||||
// do you want to display it using dirty rects, TRUE or FALSE
|
||||
// flags for either LEFT_JUSTIFIED, CENTER_JUSTIFIED, RIGHT_JUSTIFIED
|
||||
|
||||
BOOLEAN DrawTextToScreen(STR16 pStr, UINT16 usLocX, UINT16 usLocY, UINT16 usWidth, INT32 iFont, UINT8 ubColor, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 ulFlags)
|
||||
BOOLEAN DrawTextToScreen(const CHAR16* pStr, UINT16 usLocX, UINT16 usLocY, UINT16 usWidth, INT32 iFont, UINT8 ubColor, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 ulFlags)
|
||||
{
|
||||
UINT16 usPosX = 0, usPosY = 0;
|
||||
UINT16 usFontHeight=0;
|
||||
@@ -1874,7 +1874,7 @@ INT32 GetNewTotalYPositionOfThisString( INT32 iTotalYPosition, INT32 iPageSize,
|
||||
return( iNewYPosition );
|
||||
}
|
||||
|
||||
void ShadowText(UINT32 uiDestVSurface, STR16 pString, INT32 iFont, UINT16 usPosX, UINT16 usPosY )
|
||||
void ShadowText(UINT32 uiDestVSurface, const CHAR16* pString, INT32 iFont, UINT16 usPosX, UINT16 usPosY )
|
||||
{
|
||||
UINT32 uiLength = StringPixLength( pString, iFont);
|
||||
UINT16 usFontHeight = WFGetFontHeight( iFont );
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ void CleanOutControlCodesFromString(STR16 pSourceString, STR16 pDestString);
|
||||
INT16 IanDisplayWrappedStringToPages(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT16 usPageHeight, UINT16 usTotalHeight, UINT16 usPageNumber,UINT8 ubGap,
|
||||
INT32 iFont, UINT8 ubColor, STR16 pString,
|
||||
UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 uiFlags, BOOLEAN *fOnLastPageFlag);
|
||||
BOOLEAN DrawTextToScreen(STR16 pStr, UINT16 LocX, UINT16 LocY, UINT16 usWidth, INT32 iFont, UINT8 ubColor, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 FLAGS);
|
||||
BOOLEAN DrawTextToScreen(const CHAR16* pStr, UINT16 LocX, UINT16 LocY, UINT16 usWidth, INT32 iFont, UINT8 ubColor, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 FLAGS);
|
||||
UINT16 IanWrappedStringHeight(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT8 ubGap,
|
||||
INT32 iFont, UINT8 ubColor, STR16 pString,
|
||||
UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 uiFlags);
|
||||
@@ -62,7 +62,7 @@ RecordPtr GetFirstRecordOnThisPage( RecordPtr RecordList, INT32 iFont, UINT16 us
|
||||
FileStringPtr GetFirstStringOnThisPage( FileStringPtr RecordList, INT32 iFont, UINT16 usWidth, UINT8 ubGap, INT32 iPage, INT32 iPageSize, FileRecordWidthPtr iWidthArray );
|
||||
|
||||
// Places a shadow the width an height of the string, to PosX, posY
|
||||
void ShadowText(UINT32 uiDestVSurface, STR16 pString, INT32 iFont, UINT16 usPosX, UINT16 usPosY );
|
||||
void ShadowText(UINT32 uiDestVSurface, const CHAR16* pString, INT32 iFont, UINT16 usPosX, UINT16 usPosY );
|
||||
|
||||
|
||||
BOOLEAN ReduceStringLength( STR16 pString, UINT32 uiWidthToFitIn, INT32 iFont );
|
||||
|
||||
Reference in New Issue
Block a user