From 769274656efb4131374dd431a0e79b6902cc9007 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 19 Oct 2024 13:22:30 +0200 Subject: [PATCH] made FCommandLine::operator[] return a const char * and fixed two places where this triggered a compile error. --- src/common/console/c_commandline.cpp | 2 +- src/common/console/c_commandline.h | 2 +- src/common/rendering/r_videoscale.cpp | 2 +- src/gamedata/keysections.cpp | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/common/console/c_commandline.cpp b/src/common/console/c_commandline.cpp index 4f500ffe66..7fa9d1ff27 100644 --- a/src/common/console/c_commandline.cpp +++ b/src/common/console/c_commandline.cpp @@ -193,7 +193,7 @@ int FCommandLine::argc () return _argc; } -char *FCommandLine::operator[] (int i) +const char *FCommandLine::operator[] (int i) { if (_argv == NULL) { diff --git a/src/common/console/c_commandline.h b/src/common/console/c_commandline.h index dc5466df1c..4886aa9c71 100644 --- a/src/common/console/c_commandline.h +++ b/src/common/console/c_commandline.h @@ -44,7 +44,7 @@ public: FCommandLine (const char *commandline, bool no_escapes = false); ~FCommandLine (); int argc (); - char *operator[] (int i); + const char *operator[] (int i); const char *args () { return cmd; } void Shift(); diff --git a/src/common/rendering/r_videoscale.cpp b/src/common/rendering/r_videoscale.cpp index 705fe905f4..bfed3ec73b 100644 --- a/src/common/rendering/r_videoscale.cpp +++ b/src/common/rendering/r_videoscale.cpp @@ -248,7 +248,7 @@ CCMD (vid_scaletoheight) } } -inline bool atob(char* I) +inline bool atob(const char* I) { if (stricmp (I, "true") == 0 || stricmp (I, "1") == 0) return true; diff --git a/src/gamedata/keysections.cpp b/src/gamedata/keysections.cpp index bcde05eddd..25b71671ba 100644 --- a/src/gamedata/keysections.cpp +++ b/src/gamedata/keysections.cpp @@ -100,12 +100,11 @@ CCMD (addkeysection) } // Limit the ini name to 32 chars - if (strlen (argv[2]) > 32) - argv[2][32] = 0; + FString name(argv[2], 32); for (unsigned i = 0; i < KeySections.Size(); i++) { - if (KeySections[i].mTitle.CompareNoCase(argv[2]) == 0) + if (KeySections[i].mTitle.CompareNoCase(name) == 0) { CurrentKeySection = i; return;