Skip to content

Commit

Permalink
Get rid of as many implicit CTString conversions as possible.
Browse files Browse the repository at this point in the history
- Fix case of included headers in affected source files.
  • Loading branch information
DreamyCecil committed Aug 12, 2024
1 parent 336f9fa commit 014ae5a
Show file tree
Hide file tree
Showing 127 changed files with 487 additions and 492 deletions.
2 changes: 1 addition & 1 deletion Sources/DecodeReport/DecodeReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void SubMain( int argc, char *argv[])
FindInMapFile(fnSymbols, CTString(strImage), ulSegment, ulOffset, strFunction, slDelta);
// out put the result
CTString strResult;
strResult.PrintF("%s (%s+0X%X)", strLine, strFunction, slDelta);
strResult.PrintF("%s (%s+0X%X)", strLine.ConstData(), strFunction.ConstData(), slDelta);
strmDst.PutLine_t(strResult.ConstData());
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/DedicatedServer/DedicatedServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ BOOL StartGame(CTString &strLevel)

void ExecScript(const CTString &str)
{
CPrintF("Executing: '%s'\n", str);
CPrintF("Executing: '%s'\n", str.ConstData());
CTString strCmd;
strCmd.PrintF("include \"%s\"", str);
strCmd.PrintF("include \"%s\"", str.ConstData());
_pShell->Execute(strCmd);
}

Expand Down Expand Up @@ -190,7 +190,7 @@ BOOL Init(int argc, char* argv[])

FinishTranslationTable();
} catch (char *strError) {
FatalError("%s %s", CTString(fnmTransTable), strError);
FatalError("%s %s", fnmTransTable.ConstData(), strError);
}

// always disable all warnings when in serious sam
Expand All @@ -212,7 +212,7 @@ BOOL Init(int argc, char* argv[])
_pGame->Initialize("UserData\\Game\\DedicatedServer.gms"); // [Cecil]

LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), _strSamVersion);
CPrintF(TRANS("Serious Sam version: %s\n"), _strSamVersion);
CPrintF(TRANS("Serious Sam version: %s\n"), _strSamVersion.ConstData());

SetConsoleCtrlHandler(HandlerRoutine, TRUE);

Expand Down Expand Up @@ -247,8 +247,8 @@ void RoundBegin(void)
{
// repeat generate script names
FOREVER {
strBegScript.PrintF("%s%d_begin.ini", ded_strConfig, iRound);
strEndScript.PrintF("%s%d_end.ini", ded_strConfig, iRound);
strBegScript.PrintF("%s%d_begin.ini", ded_strConfig.ConstData(), iRound);
strEndScript.PrintF("%s%d_end.ini", ded_strConfig.ConstData(), iRound);
// if start script exists
if (FileExists(strBegScript)) {
// stop searching
Expand Down
14 changes: 7 additions & 7 deletions Sources/Engine/Base/ErrorReporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void FatalError(const char *strFormat, ...)

#else
// [Cecil] SDL: Show fatal error
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TRANS("Fatal Error"), strBuffer, NULL);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TRANS("Fatal Error"), strBuffer.ConstData(), NULL);
SDL_Quit();
#endif

Expand All @@ -110,7 +110,7 @@ void ErrorMessage(const char *strFormat, ...) {
#if !SE1_PREFER_SDL
MessageBoxA(NULL, strBuffer.ConstData(), TRANS("Error"), MB_OK|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
#else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TRANS("Error"), strBuffer, _hwndCurrent);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TRANS("Error"), strBuffer.ConstData(), _hwndCurrent);
#endif
};

Expand All @@ -126,7 +126,7 @@ void WarningMessage(const char *strFormat, ...)
strBuffer.VPrintF(strFormat, arg);

// print it to console
CPrintF("%s\n", strBuffer);
CPrintF("%s\n", strBuffer.ConstData());
// if warnings are enabled
if( !con_bNoWarnings) {
#if !SE1_PREFER_SDL
Expand All @@ -135,7 +135,7 @@ void WarningMessage(const char *strFormat, ...)

#else
// [Cecil] SDL: Show warning
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, TRANS("Warning"), strBuffer, _hwndCurrent);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, TRANS("Warning"), strBuffer.ConstData(), _hwndCurrent);
#endif
}
}
Expand All @@ -149,15 +149,15 @@ void InfoMessage(const char *strFormat, ...)
strBuffer.VPrintF(strFormat, arg);

// print it to console
CPrintF("%s\n", strBuffer);
CPrintF("%s\n", strBuffer.ConstData());

#if !SE1_PREFER_SDL
// create message box
MessageBoxA(NULL, strBuffer.ConstData(), TRANS("Information"), MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND|MB_TASKMODAL);

#else
// [Cecil] SDL: Show information
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, TRANS("Information"), strBuffer, _hwndCurrent);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, TRANS("Information"), strBuffer.ConstData(), _hwndCurrent);
#endif
}

Expand All @@ -171,7 +171,7 @@ BOOL YesNoMessage(const char *strFormat, ...)
strBuffer.VPrintF(strFormat, arg);

// print it to console
CPrintF("%s\n", strBuffer);
CPrintF("%s\n", strBuffer.ConstData());

#if !SE1_PREFER_SDL
// create message box
Expand Down
8 changes: 4 additions & 4 deletions Sources/Engine/Base/IFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

#include "stdh.h"
#include "StdH.h"
#include <Engine/Base/IFeel.h>
#include <Engine/Base/FileName.h>
#include <Engine/Base/Stream.h>
Expand Down Expand Up @@ -99,7 +99,7 @@ CTString IFeel_GetProjectFileName()
if(strProduct == strDeviceName) return strProjectFile;
}
// device was not found, return default project file
CPrintF("No project file specified for device '%s'.\nUsing default project file\n",strProduct);
CPrintF("No project file specified for device '%s'.\nUsing default project file\n", strProduct.ConstData());
return strDefaultProjectFile;
}

Expand Down Expand Up @@ -211,12 +211,12 @@ BOOL IFeel_LoadFile(CTFileName fnFile)
BOOL hr = immLoadFile(fnmExpanded.ConstData());
if(hr)
{
CPrintF("IFeel project file '%s' loaded\n", fnFile);
CPrintF("IFeel project file '%s' loaded\n", fnFile.ConstData());
return TRUE;
}
else
{
CPrintF("Error loading IFeel project file '%s'\n", fnFile);
CPrintF("Error loading IFeel project file '%s'\n", fnFile.ConstData());
return FALSE;
}
}
Expand Down
28 changes: 14 additions & 14 deletions Sources/Engine/Base/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void Declaration(
if (!ShellTypeIsSame(ssNew.ss_istType, istType) ||
((ssNew.ss_ulFlags&SSF_CONSTANT)!=(ulQualifiers&SSF_CONSTANT))) {
// error
_pShell->ErrorF("Symbol '%s' is already declared diferrently", ssNew.ss_strName);
_pShell->ErrorF("Symbol '%s' is already declared diferrently", ssNew.ss_strName.ConstData());
return;
}

Expand All @@ -112,7 +112,7 @@ void Declaration(
NOTHING; // function values are not retained
} else {
// error
_pShell->ErrorF("'%s': old value couldn't be retained", ssNew.ss_strName);
_pShell->ErrorF("'%s': old value couldn't be retained", ssNew.ss_strName.ConstData());
return;
}
}
Expand Down Expand Up @@ -331,7 +331,7 @@ pre_func_opt
||_shell_ast[_shell_ast[$3->ss_istType].st_istBaseType].st_sttType!=STT_INDEX
||_shell_ast[$3->ss_istType].st_istFirstArgument!=_shell_ast[$3->ss_istType].st_istLastArgument
||_shell_ast[_shell_ast[$3->ss_istType].st_istFirstArgument].st_sttType!=STT_INDEX) {
_pShell->ErrorF("'%s' must return 'INDEX' and take 'INDEX' as input", $3->ss_strName);
_pShell->ErrorF("'%s' must return 'INDEX' and take 'INDEX' as input", $3->ss_strName.ConstData());
} else {
void *pv = $3->ss_pvValue;
$$ = (INDEX(*)(INDEX))$3->ss_pvValue;
Expand All @@ -347,7 +347,7 @@ post_func_opt
||_shell_ast[_shell_ast[$3->ss_istType].st_istBaseType].st_sttType!=STT_VOID
||_shell_ast[$3->ss_istType].st_istFirstArgument!=_shell_ast[$3->ss_istType].st_istLastArgument
||_shell_ast[_shell_ast[$3->ss_istType].st_istFirstArgument].st_sttType!=STT_INDEX) {
_pShell->ErrorF("'%s' must return 'void' and take 'INDEX' as input", $3->ss_strName);
_pShell->ErrorF("'%s' must return 'void' and take 'INDEX' as input", $3->ss_strName.ConstData());
} else {
$$ = (void(*)(INDEX))$3->ss_pvValue;
}
Expand Down Expand Up @@ -430,7 +430,7 @@ statement
| lvalue '=' expression ';' {
// if it is constant
if ($1.lv_pssSymbol->ss_ulFlags&SSF_CONSTANT) {
_pShell->ErrorF("Symbol '%s' is a constant", $1.lv_pssSymbol->ss_strName);
_pShell->ErrorF("Symbol '%s' is a constant", $1.lv_pssSymbol->ss_strName.ConstData());
// if it is not constant
} else {
// if it can be changed
Expand Down Expand Up @@ -473,7 +473,7 @@ statement
// if it is constant
if (ssSymbol.ss_ulFlags&SSF_CONSTANT) {
// error
_pShell->ErrorF("Symbol '%s' is a constant", ssSymbol.ss_strName);
_pShell->ErrorF("Symbol '%s' is a constant", ssSymbol.ss_strName.ConstData());
}

// get symbol type
Expand All @@ -496,7 +496,7 @@ statement
_pShell->ErrorF("Warning: assigning INDEX to FLOAT!");
*(FLOAT*)ssSymbol.ss_pvValue = $5.iIndex;
} else {
_pShell->ErrorF("Symbol '%s' and its initializer have different types", ssSymbol.ss_strName);
_pShell->ErrorF("Symbol '%s' and its initializer have different types", ssSymbol.ss_strName.ConstData());
}
}
| k_help identifier {
Expand Down Expand Up @@ -566,7 +566,7 @@ lvalue
$$.lv_pssSymbol = &ssSymbol;
if (!ssSymbol.IsDeclared()) {
// error
_pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName);
_pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName.ConstData());
fDummy = -666;
$$.lv_sttType = STT_VOID;
$$.lv_pvAddress = &fDummy;
Expand All @@ -578,7 +578,7 @@ lvalue
// if the identifier is something else
} else {
// error
_pShell->ErrorF("'%s' doesn't have a value", $1->ss_strName);
_pShell->ErrorF("'%s' doesn't have a value", $1->ss_strName.ConstData());
fDummy = -666.0f;
$$.lv_sttType = STT_VOID;
$$.lv_pvAddress = &fDummy;
Expand Down Expand Up @@ -616,7 +616,7 @@ lvalue
}
}
} else {
_pShell->ErrorF("'%s[]' doesn't have a value", $1->ss_strName);
_pShell->ErrorF("'%s[]' doesn't have a value", $1->ss_strName.ConstData());
fDummy = -666.0f;
$$.lv_pvAddress = &fDummy;
}
Expand Down Expand Up @@ -673,7 +673,7 @@ expression
} else {
$$.sttType = STT_FLOAT;
$$.fFloat = -666.0f;
_pShell->ErrorF("'%s' is of wrong type", $1.lv_pssSymbol->ss_strName);
_pShell->ErrorF("'%s' is of wrong type", $1.lv_pssSymbol->ss_strName.ConstData());
}
}
/* shift */
Expand Down Expand Up @@ -975,7 +975,7 @@ expression
// if the identifier is not declared
if (!$1->IsDeclared()) {
// error
_pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName);
_pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName.ConstData());
// if the identifier is declared
} else {
// get its type
Expand Down Expand Up @@ -1028,13 +1028,13 @@ expression
} else {
// error
$$.sttType = STT_VOID;
_pShell->ErrorF("Wrong parameters for '%s'", $1->ss_strName);
_pShell->ErrorF("Wrong parameters for '%s'", $1->ss_strName.ConstData());
}
// if the identifier is something else
} else {
// error
$$.sttType = STT_VOID;
_pShell->ErrorF("Can't call '%s'", $1->ss_strName);
_pShell->ErrorF("Can't call '%s'", $1->ss_strName.ConstData());
}
}

Expand Down
40 changes: 20 additions & 20 deletions Sources/Engine/Base/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ extern void PrintShellSymbolHelp(const CTString &strSymbol)
try {
CTString strHelp = GetShellSymbolHelp_t(strSymbol);
if (strHelp!="") {
CPrintF("%s\n", strHelp);
CPrintF("%s\n", strHelp.ConstData());
} else {
CPrintF( TRANS("No help found for '%s'.\n"), strSymbol);
CPrintF( TRANS("No help found for '%s'.\n"), strSymbol.ConstData());
}
// if failed
} catch(char *strError) {
// just print the error
CPrintF( TRANS("Cannot print help for '%s': %s\n"), strSymbol, strError);
CPrintF( TRANS("Cannot print help for '%s': %s\n"), strSymbol.ConstData(), strError);
}
}

Expand Down Expand Up @@ -354,23 +354,23 @@ extern void ListSymbolsByPattern(CTString strPattern)

// print its declaration to the console
if (st.st_sttType == STT_FUNCTION) {
CPrintF("void %s(void)", ss.ss_strName);
CPrintF("void %s(void)", ss.ss_strName.ConstData());

} else if (st.st_sttType == STT_STRING) {
CPrintF("CTString %s = \"%s\"", ss.ss_strName, *(CTString*)ss.ss_pvValue);
CPrintF("CTString %s = \"%s\"", ss.ss_strName.ConstData(), ((CTString *)ss.ss_pvValue)->ConstData());
} else if (st.st_sttType == STT_FLOAT) {
CPrintF("FLOAT %s = %g", ss.ss_strName, *(FLOAT*)ss.ss_pvValue);
CPrintF("FLOAT %s = %g", ss.ss_strName.ConstData(), *(FLOAT*)ss.ss_pvValue);
} else if (st.st_sttType == STT_INDEX) {
CPrintF("INDEX %s = %d (0x%08x)", ss.ss_strName, *(INDEX*)ss.ss_pvValue, *(INDEX*)ss.ss_pvValue);
CPrintF("INDEX %s = %d (0x%08x)", ss.ss_strName.ConstData(), *(INDEX*)ss.ss_pvValue, *(INDEX*)ss.ss_pvValue);
} else if (st.st_sttType == STT_ARRAY) {
// get base type
ShellType &stBase = _shell_ast[st.st_istBaseType];
if (stBase.st_sttType == STT_FLOAT) {
CPrintF("FLOAT %s[%d]", ss.ss_strName, st.st_ctArraySize);
CPrintF("FLOAT %s[%d]", ss.ss_strName.ConstData(), st.st_ctArraySize);
} else if (stBase.st_sttType == STT_INDEX) {
CPrintF("INDEX %s[%d]", ss.ss_strName, st.st_ctArraySize);
CPrintF("INDEX %s[%d]", ss.ss_strName.ConstData(), st.st_ctArraySize);
} else if (stBase.st_sttType == STT_STRING) {
CPrintF("CTString %s[%d]", ss.ss_strName, st.st_ctArraySize);
CPrintF("CTString %s[%d]", ss.ss_strName.ConstData(), st.st_ctArraySize);
} else {
ASSERT(FALSE);
}
Expand Down Expand Up @@ -400,7 +400,7 @@ static void ListSymbols(void)
void Echo(void* pArgs)
{
CTString str = *NEXTARGUMENT(CTString*);
CPrintF("%s", str);
CPutString(str.ConstData());
}


Expand Down Expand Up @@ -475,7 +475,7 @@ void LoadCommands(void)
// assign value
*(CTString*)ssNew.ss_pvValue = "!command "+strCmd;
} else {
_pShell->ErrorF("Symbol '%s' is not suitable to be a command", ssNew.ss_strName);
_pShell->ErrorF("Symbol '%s' is not suitable to be a command", ssNew.ss_strName.ConstData());
}
}
}
Expand Down Expand Up @@ -867,39 +867,39 @@ void CShell::StorePersistentSymbols(const CTFileName &fnScript)
if (stBase.st_sttType==STT_FLOAT) {
// dump all members as floats
for(INDEX i=0; i<st.st_ctArraySize; i++) {
fScript.FPrintF_t("%s[%d]=(FLOAT)%g;\n", ss.ss_strName, i, ((FLOAT*)ss.ss_pvValue)[i]);
fScript.FPrintF_t("%s[%d]=(FLOAT)%g;\n", ss.ss_strName.ConstData(), i, ((FLOAT*)ss.ss_pvValue)[i]);
}
// if index
} else if (stBase.st_sttType==STT_INDEX) {
// dump all members as indices
for(INDEX i=0; i<st.st_ctArraySize; i++) {
fScript.FPrintF_t("%s[%d]=(INDEX)%d;\n", ss.ss_strName, i, ((INDEX*)ss.ss_pvValue)[i]);
fScript.FPrintF_t("%s[%d]=(INDEX)%d;\n", ss.ss_strName.ConstData(), i, ((INDEX*)ss.ss_pvValue)[i]);
}
// if string
} else if (stBase.st_sttType==STT_STRING) {
// dump all members
for(INDEX i=0; i<st.st_ctArraySize; i++) {
fScript.FPrintF_t("%s[%d]=\"%s\";\n", ss.ss_strName, i, ScriptEsc(((CTString *)ss.ss_pvValue)[i]).ConstData());
fScript.FPrintF_t("%s[%d]=\"%s\";\n", ss.ss_strName.ConstData(), i, ScriptEsc(((CTString *)ss.ss_pvValue)[i]).ConstData());
}
// otherwise
} else {
ThrowF_t("%s is an array of wrong type", ss.ss_strName);
ThrowF_t("%s is an array of wrong type", ss.ss_strName.ConstData());
}
// if float
} else if (st.st_sttType==STT_FLOAT) {
// dump as float
fScript.FPrintF_t("persistent extern %sFLOAT %s=(FLOAT)%g;\n", strUser, ss.ss_strName, *(FLOAT*)ss.ss_pvValue);
fScript.FPrintF_t("persistent extern %sFLOAT %s=(FLOAT)%g;\n", strUser, ss.ss_strName.ConstData(), *(FLOAT*)ss.ss_pvValue);
// if index
} else if (st.st_sttType==STT_INDEX) {
// dump as index
fScript.FPrintF_t("persistent extern %sINDEX %s=(INDEX)%d;\n", strUser, ss.ss_strName, *(INDEX*)ss.ss_pvValue);
fScript.FPrintF_t("persistent extern %sINDEX %s=(INDEX)%d;\n", strUser, ss.ss_strName.ConstData(), *(INDEX*)ss.ss_pvValue);
// if string
} else if (st.st_sttType==STT_STRING) {
// dump as index
fScript.FPrintF_t("persistent extern %sCTString %s=\"%s\";\n", strUser, ss.ss_strName, ScriptEsc(*(CTString *)ss.ss_pvValue).ConstData());
fScript.FPrintF_t("persistent extern %sCTString %s=\"%s\";\n", strUser, ss.ss_strName.ConstData(), ScriptEsc(*(CTString *)ss.ss_pvValue).ConstData());
// otherwise
} else {
ThrowF_t("%s of wrong type", ss.ss_strName);
ThrowF_t("%s of wrong type", ss.ss_strName.ConstData());
}
}
} catch (char *strError) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Base/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ SLONG GetFileTimeStamp_t(const CTFileName &fnm)
// try to open file for reading
file_handle = _open(fnmExpanded.ConstData(), _O_RDONLY | _O_BINARY);
if(file_handle==-1) {
ThrowF_t(TRANS("Cannot open file '%s' for reading"), CTString(fnm));
ThrowF_t(TRANS("Cannot open file '%s' for reading"), fnm.ConstData());
return -1;
}
struct stat statFileStatus;
Expand Down
Loading

0 comments on commit 014ae5a

Please sign in to comment.