From 031af9f785affd33bf8cc0358e75735e7587ca2b Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 5 Oct 2024 14:24:52 +0200 Subject: [PATCH 1/5] remove redundant findApp function Instead put a preprocessor check inside findExe() to ensure that macOS treats a found .app directory as executable path. --- Steam/steamshim_parent.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Steam/steamshim_parent.cpp b/Steam/steamshim_parent.cpp index 1011a42dd..26fec0849 100755 --- a/Steam/steamshim_parent.cpp +++ b/Steam/steamshim_parent.cpp @@ -49,7 +49,6 @@ static bool launchChild(ProcessType *pid); static int closeProcess(ProcessType *pid); static fs::path findExe(const boost::regex& regex); -static fs::path findApp(const boost::regex& regex); #ifdef _WIN32 @@ -208,7 +207,7 @@ static bool launchChild(ProcessType *pid) // we're the child. #ifdef __APPLE__ - auto app = findApp(boost::regex("Classic Marathon.*\\.app")); + auto app = findExe(boost::regex("Classic Marathon.*\\.app")); auto macos = app / "Contents" / "MacOS"; auto bin = boost::filesystem::directory_iterator(macos)->path().string(); #else @@ -246,10 +245,11 @@ fs::path findExe(const boost::regex& regex) fs::directory_iterator end; for (fs::directory_iterator it(this_exe.parent_path()); it != end; ++it) { +#ifndef __APPLE__ if (it->path() == this_exe) { continue; } - +#endif auto filename = it->path().filename().string(); if (boost::regex_match(filename, regex)) { return it->path(); @@ -259,20 +259,6 @@ fs::path findExe(const boost::regex& regex) return fs::path(); } -fs::path findApp(const boost::regex& regex) -{ - auto this_exe = boost::dll::program_location(); - - fs::directory_iterator end; - for (fs::directory_iterator it(this_exe.parent_path()); it != end; ++it) { - auto filename = it->path().filename().string(); - if (boost::regex_match(filename, regex)) { - return it->path(); - } - } - - return fs::path(); -} // THE ACTUAL PROGRAM. From 0884b991da9910cde9c1574d66475f2a6abf0a51 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 5 Oct 2024 14:29:45 +0200 Subject: [PATCH 2/5] sign-compare in steamshim_parent.cpp --- Steam/steamshim_parent.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Steam/steamshim_parent.cpp b/Steam/steamshim_parent.cpp index 26fec0849..53fc066ce 100755 --- a/Steam/steamshim_parent.cpp +++ b/Steam/steamshim_parent.cpp @@ -772,7 +772,7 @@ static void UpdateItem(PublishedFileId_t item_id, const item_upload_data& item_d auto tags = GetTagsForItemType(item_data.item_type, item_data.content_type); const char* tag_array[16]; - for (auto i = 0; i < tags.size(); i++) + for (size_t i = 0; i < tags.size(); i++) { tag_array[i] = tags[i].c_str(); } @@ -933,7 +933,7 @@ void SteamBridge::OnItemOwnedQueried(SteamUGCQueryCompleted_t* pCallback, bool b { if (!bIOFailure && pCallback->m_eResult == k_EResultOK) { - for (int i = 0; i < pCallback->m_unNumResultsReturned; i++) + for (uint32 i = 0; i < pCallback->m_unNumResultsReturned; i++) { SteamUGCDetails_t item_details; @@ -994,7 +994,7 @@ void SteamBridge::OnItemModQueried(SteamUGCQueryCompleted_t* pCallback, bool bIO { if (!bIOFailure && pCallback->m_eResult == k_EResultOK) { - for (int i = 0; i < pCallback->m_unNumResultsReturned; i++) + for (uint32 i = 0; i < pCallback->m_unNumResultsReturned; i++) { SteamUGCDetails_t item_details; @@ -1059,7 +1059,7 @@ void SteamBridge::OnItemScenarioQueried(SteamUGCQueryCompleted_t* pCallback, boo { if (!bIOFailure && pCallback->m_eResult == k_EResultOK) { - for (int i = 0; i < pCallback->m_unNumResultsReturned; i++) + for (uint32 i = 0; i < pCallback->m_unNumResultsReturned; i++) { SteamUGCDetails_t item_details; From 4db24298f65b7357c58ed011a7a1208ad2efe730 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 5 Oct 2024 14:32:25 +0200 Subject: [PATCH 3/5] missing default cases in nested switch statements --- Steam/steamshim_parent.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Steam/steamshim_parent.cpp b/Steam/steamshim_parent.cpp index 53fc066ce..ba90ad349 100755 --- a/Steam/steamshim_parent.cpp +++ b/Steam/steamshim_parent.cpp @@ -700,6 +700,8 @@ static std::vector GetTagsForItemType(ItemType item_type, ContentTy case ContentType::Theme: tags.push_back("Theme"); break; + default: + break; } break; case ItemType::Map: @@ -715,6 +717,8 @@ static std::vector GetTagsForItemType(ItemType item_type, ContentTy tags.push_back("Solo Map"); tags.push_back("Net Map"); break; + default: + break; } break; case ItemType::Physics: @@ -733,6 +737,8 @@ static std::vector GetTagsForItemType(ItemType item_type, ContentTy tags.push_back("Solo Script"); tags.push_back("Net Script"); break; + default: + break; } break; case ItemType::Sounds: From 5edc337dda04f60a480420b79ce5324d5e40eab6 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 5 Oct 2024 15:39:10 +0200 Subject: [PATCH 4/5] comment out unused parameters --- Steam/steamshim_parent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Steam/steamshim_parent.cpp b/Steam/steamshim_parent.cpp index ba90ad349..d45efb0b4 100755 --- a/Steam/steamshim_parent.cpp +++ b/Steam/steamshim_parent.cpp @@ -128,7 +128,7 @@ static int closeProcess(ProcessType *pid) return 0; } // closeProcess -int CALLBACK wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) +int CALLBACK wWinMain(_In_ HINSTANCE /*hInstance*/, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ LPWSTR lpCmdLine, _In_ int /*nCmdShow*/) { LpCmdLine = lpCmdLine; mainline(); From 6eb2f6c7e09d2d84c7777ac469dacd74f9b59fee Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 5 Oct 2024 15:41:19 +0200 Subject: [PATCH 5/5] rename variable LpCmdLine to GlpCmdLine This makes it more distinguishable from lpCmdLine --- Steam/steamshim_parent.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Steam/steamshim_parent.cpp b/Steam/steamshim_parent.cpp index d45efb0b4..d0582cddb 100755 --- a/Steam/steamshim_parent.cpp +++ b/Steam/steamshim_parent.cpp @@ -52,7 +52,7 @@ static fs::path findExe(const boost::regex& regex); #ifdef _WIN32 -static LPWSTR LpCmdLine = NULL; +static LPWSTR GlpCmdLine = NULL; static void fail(const char *err) { @@ -114,7 +114,7 @@ static bool launchChild(ProcessType *pid) memset(&si, 0, sizeof(si)); auto exe = findExe(boost::regex("Classic Marathon.*\\.exe")); - std::wstring args = L"\"" + exe.wstring() + L"\" " + (LpCmdLine ? LpCmdLine : L""); //should never be null but just in case + std::wstring args = L"\"" + exe.wstring() + L"\" " + (GlpCmdLine ? GlpCmdLine : L""); //should never be null but just in case return (CreateProcessW(exe.wstring().c_str(), args.data(), NULL, NULL, TRUE, 0, NULL, @@ -130,7 +130,7 @@ static int closeProcess(ProcessType *pid) int CALLBACK wWinMain(_In_ HINSTANCE /*hInstance*/, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ LPWSTR lpCmdLine, _In_ int /*nCmdShow*/) { - LpCmdLine = lpCmdLine; + GlpCmdLine = lpCmdLine; mainline(); ExitProcess(0); return 0; // just in case.