From 713d6206035eb4e2cac61afff5716b8079f7713a Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Wed, 16 Aug 2023 23:35:44 -0700 Subject: [PATCH] Convert all hsMessageBox inputs to ST::string --- Sources/Plasma/Apps/plClient/plClient.cpp | 2 +- .../PubUtilLib/plMessageBox/hsMessageBox.cpp | 10 ----- .../PubUtilLib/plMessageBox/hsMessageBox.h | 2 - .../PubUtilLib/plNetClient/plNetClientMgr.cpp | 3 +- .../PubUtilLib/plResMgr/plResManager.cpp | 41 +++++++++---------- 5 files changed, 22 insertions(+), 36 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 6b1d14a3de..9f6b741dd9 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -493,7 +493,7 @@ bool plClient::InitPipeline(hsWindowHndl display, uint32_t devType) #ifdef PLASMA_EXTERNAL_RELEASE hsMessageBox(ST_LITERAL("There was an error initializing the video card.\nSetting defaults."), ST_LITERAL("Error"), hsMessageBoxNormal); #else - hsMessageBox( pipe->GetErrorString(), "Error creating pipeline", hsMessageBoxNormal ); + hsMessageBox(ST::string(pipe->GetErrorString()), ST_LITERAL("Error creating pipeline"), hsMessageBoxNormal); #endif delete pipe; devSel.GetDefault(&dmr); diff --git a/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.cpp b/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.cpp index 59df69e66c..7b155e09a3 100644 --- a/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.cpp +++ b/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.cpp @@ -57,13 +57,3 @@ hsMessageBoxResult hsMessageBox(const ST::string& message, const ST::string& cap return hsMBoxCancel; } #endif - -hsMessageBoxResult hsMessageBox(const char* message, const char* caption, hsMessageBoxKind kind, hsMessageBoxIcon icon) -{ - return hsMessageBox(ST::string::from_latin_1(message), ST::string::from_latin_1(caption), kind, icon); -} - -hsMessageBoxResult hsMessageBox(const wchar_t* message, const wchar_t* caption, hsMessageBoxKind kind, hsMessageBoxIcon icon) -{ - return hsMessageBox(ST::string::from_wchar(message), ST::string::from_wchar(caption), kind, icon); -} diff --git a/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.h b/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.h index 26390d4a38..7c1dd546d8 100644 --- a/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.h +++ b/Sources/Plasma/PubUtilLib/plMessageBox/hsMessageBox.h @@ -75,7 +75,5 @@ enum hsMessageBoxResult { // RETURN VALUES FROM hsMessageBox extern bool hsMessageBox_SuppressPrompts; hsMessageBoxResult hsMessageBox(const ST::string& message, const ST::string& caption, hsMessageBoxKind kind, hsMessageBoxIcon icon=hsMessageBoxIconAsterisk); -hsMessageBoxResult hsMessageBox(const char* message, const char* caption, hsMessageBoxKind kind, hsMessageBoxIcon icon=hsMessageBoxIconAsterisk); -hsMessageBoxResult hsMessageBox(const wchar_t* message, const wchar_t* caption, hsMessageBoxKind kind, hsMessageBoxIcon icon=hsMessageBoxIconAsterisk); #endif // _hsMessageBox_h_ diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 36c0a7789d..361018b4cd 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -1163,7 +1163,8 @@ void plNetClientMgr::IDisableNet () { { // KI may not be loaded ST::string title = ST::format("{} Error", plProduct::CoreName()); - hsMessageBox(fDisableMsg->str, title.c_str(), hsMessageBoxNormal, hsMessageBoxIconError ); + ST::string errMsg = ST::string(fDisableMsg->str); + hsMessageBox(errMsg, title, hsMessageBoxNormal, hsMessageBoxIconError); plClientMsg *quitMsg = new plClientMsg(plClientMsg::kQuit); quitMsg->Send(hsgResMgr::ResMgr()->FindKey(kClient_KEY)); } diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp index 2f89e11cd2..8535fc4313 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp @@ -1367,26 +1367,24 @@ bool plResManager::VerifyPages() // Given an array of pages that are invalid (major version out-of-date or // whatnot), asks the user what we should do about them. -static void ICatPageNames(std::vector& pages, char* buf, int bufSize) +static ST::string ICatPageNames(std::vector& pages, const ST::string& msg) { + ST::string_stream ss; + ss << msg; + for (size_t i = 0; i < pages.size(); i++) { if (i >= 25) { - strcat(buf, "...\n"); + ss << ST_LITERAL("...\n"); break; } ST::string pageFile = pages[i]->GetPagePath().GetFileName(); - if (strlen(buf) + pageFile.size() > bufSize - 5) - { - strcat(buf, "...\n"); - break; - } - - strcat(buf, pageFile.c_str()); - strcat(buf, "\n"); + ss << pageFile << ST_LITERAL("\n"); } + + return ss.to_string(); } bool plResManager::IDeleteBadPages(std::vector& invalidPages, bool conflictingSeqNums) @@ -1394,19 +1392,19 @@ bool plResManager::IDeleteBadPages(std::vector& invalidPage #ifndef PLASMA_EXTERNAL_RELEASE if (!hsMessageBox_SuppressPrompts) { - char msg[4096]; + ST::string msg; // Prompt what to do if (conflictingSeqNums) - strcpy(msg, "The following pages have conflicting sequence numbers. This usually happens when " - "you copy data files between machines that had random sequence numbers assigned at " - "export. To avoid crashing, these pages will be deleted:\n\n"); + msg = ST_LITERAL("The following pages have conflicting sequence numbers. This usually happens when " + "you copy data files between machines that had random sequence numbers assigned at " + "export. To avoid crashing, these pages will be deleted:\n\n"); else - strcpy(msg, "The following pages are out of date and will be deleted:\n\n"); + msg = ST_LITERAL("The following pages are out of date and will be deleted:\n\n"); - ICatPageNames(invalidPages, msg, sizeof(msg)); + msg = ICatPageNames(invalidPages, msg); - hsMessageBox(msg, "Warning", hsMessageBoxNormal); + hsMessageBox(msg, ST_LITERAL("Warning"), hsMessageBoxNormal); } #endif // PLASMA_EXTERNAL_RELEASE @@ -1433,14 +1431,13 @@ bool plResManager::IWarnNewerPages(std::vector &newerPages) #ifndef PLASMA_EXTERNAL_RELEASE if (!hsMessageBox_SuppressPrompts) { - char msg[4096]; // Prompt what to do - strcpy(msg, "The following pages have newer version numbers than this client and cannot be \nloaded. " - "They will be ignored but their files will NOT be deleted:\n\n"); + ST::string msg = ST_LITERAL("The following pages have newer version numbers than this client and cannot be \nloaded. " + "They will be ignored but their files will NOT be deleted:\n\n"); - ICatPageNames(newerPages, msg, sizeof(msg)); + msg = ICatPageNames(newerPages, msg); - hsMessageBox(msg, "Warning", hsMessageBoxNormal); + hsMessageBox(msg, ST_LITERAL("Warning"), hsMessageBoxNormal); } #endif // PLASMA_EXTERNAL_RELEASE