Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce compiler noise for steamshim_parent.cpp #524

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions Steam/steamshim_parent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ 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

static LPWSTR LpCmdLine = NULL;
static LPWSTR GlpCmdLine = NULL;

static void fail(const char *err)
{
Expand Down Expand Up @@ -115,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,
Expand All @@ -129,9 +128,9 @@ 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;
GlpCmdLine = lpCmdLine;
mainline();
ExitProcess(0);
return 0; // just in case.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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.

Expand Down Expand Up @@ -714,6 +700,8 @@ static std::vector<std::string> GetTagsForItemType(ItemType item_type, ContentTy
case ContentType::Theme:
tags.push_back("Theme");
break;
default:
break;
}
break;
case ItemType::Map:
Expand All @@ -729,6 +717,8 @@ static std::vector<std::string> GetTagsForItemType(ItemType item_type, ContentTy
tags.push_back("Solo Map");
tags.push_back("Net Map");
break;
default:
break;
}
break;
case ItemType::Physics:
Expand All @@ -747,6 +737,8 @@ static std::vector<std::string> GetTagsForItemType(ItemType item_type, ContentTy
tags.push_back("Solo Script");
tags.push_back("Net Script");
break;
default:
break;
}
break;
case ItemType::Sounds:
Expand Down Expand Up @@ -786,7 +778,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();
}
Expand Down Expand Up @@ -947,7 +939,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;

Expand Down Expand Up @@ -1008,7 +1000,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;

Expand Down Expand Up @@ -1073,7 +1065,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;

Expand Down