Codechange: pass std::string references to OpenBrowser

This commit is contained in:
rubidium42 2023-11-28 20:17:05 -04:00 committed by rubidium42
parent 8437b20fed
commit 27082f9efa
10 changed files with 19 additions and 19 deletions

View File

@ -145,16 +145,16 @@ struct HelpWindow : public Window {
new GameManualTextfileWindow(LICENSE_FILENAME);
break;
case WID_HW_WEBSITE:
OpenBrowser(WEBSITE_LINK.c_str());
OpenBrowser(WEBSITE_LINK);
break;
case WID_HW_WIKI:
OpenBrowser(WIKI_LINK.c_str());
OpenBrowser(WIKI_LINK);
break;
case WID_HW_BUGTRACKER:
OpenBrowser(BUGTRACKER_LINK.c_str());
OpenBrowser(BUGTRACKER_LINK);
break;
case WID_HW_COMMUNITY:
OpenBrowser(COMMUNITY_LINK.c_str());
OpenBrowser(COMMUNITY_LINK);
break;
}
}

View File

@ -384,7 +384,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
}
}
OpenBrowser(url.c_str());
OpenBrowser(url);
}
/**
@ -855,7 +855,7 @@ public:
case WID_NCL_OPEN_URL:
if (this->selected != nullptr) {
OpenBrowser(this->selected->url.c_str());
OpenBrowser(this->selected->url);
}
break;

View File

@ -2501,7 +2501,7 @@ struct NetworkAskSurveyWindow : public Window {
break;
case WID_NAS_LINK:
OpenBrowser(NETWORK_SURVEY_DETAILS_LINK.c_str());
OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
break;
case WID_NAS_NO:

View File

@ -94,7 +94,7 @@ bool HandleBootstrap();
extern void AfterLoadCompanyStats();
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
extern void OSOpenBrowser(const char *url);
extern void OSOpenBrowser(const std::string &url);
extern void RebuildTownCaches();
extern void ShowOSErrorBox(const char *buf, bool system);
extern std::string _config_file;
@ -370,7 +370,7 @@ void MakeNewgameSettingsLive()
}
}
void OpenBrowser(const char *url)
void OpenBrowser(const std::string &url)
{
/* Make sure we only accept urls that are sure to open a browser. */
if (StrStartsWith(url, "http://") || StrStartsWith(url, "https://")) {

View File

@ -90,7 +90,7 @@ void SwitchToMode(SwitchMode new_mode);
bool RequestNewGRFScan(struct NewGRFScanCallback *callback = nullptr);
void GenerateSavegameId();
void OpenBrowser(const char *url);
void OpenBrowser(const std::string &url);
void ChangeAutosaveFrequency(bool reset);
#endif /* OPENTTD_H */

View File

@ -143,9 +143,9 @@ void ShowOSErrorBox(const char *buf, bool system)
}
}
void OSOpenBrowser(const char *url)
void OSOpenBrowser(const std::string &url)
{
[ [ NSWorkspace sharedWorkspace ] openURL:[ NSURL URLWithString:[ NSString stringWithUTF8String:url ] ] ];
[ [ NSWorkspace sharedWorkspace ] openURL:[ NSURL URLWithString:[ NSString stringWithUTF8String:url.c_str() ] ] ];
}
/**

View File

@ -230,20 +230,20 @@ std::optional<std::string> GetClipboardContents()
#if defined(__EMSCRIPTEN__)
void OSOpenBrowser(const char *url)
void OSOpenBrowser(const std::string &url)
{
/* Implementation in pre.js */
EM_ASM({ if(window["openttd_open_url"]) window.openttd_open_url($0, $1) }, url, strlen(url));
EM_ASM({ if (window["openttd_open_url"]) window.openttd_open_url($0, $1) }, url.c_str(), url.size());
}
#elif !defined( __APPLE__)
void OSOpenBrowser(const char *url)
void OSOpenBrowser(const std::string &url)
{
pid_t child_pid = fork();
if (child_pid != 0) return;
const char *args[3];
args[0] = "xdg-open";
args[1] = url;
args[1] = url.c_str();
args[2] = nullptr;
execvp(args[0], const_cast<char * const *>(args));
Debug(misc, 0, "Failed to open url: {}", url);

View File

@ -52,7 +52,7 @@ void ShowOSErrorBox(const char *buf, bool)
MessageBox(GetActiveWindow(), OTTD2FS(buf).c_str(), L"Error!", MB_ICONSTOP | MB_TASKMODAL);
}
void OSOpenBrowser(const char *url)
void OSOpenBrowser(const std::string &url)
{
ShellExecute(GetActiveWindow(), L"open", OTTD2FS(url).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
}

View File

@ -495,7 +495,7 @@ struct GameOptionsWindow : Window {
break;
case WID_GO_SURVEY_LINK_BUTTON:
OpenBrowser(NETWORK_SURVEY_DETAILS_LINK.c_str());
OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
break;
case WID_GO_SURVEY_PREVIEW_BUTTON:

View File

@ -406,7 +406,7 @@ void TextfileWindow::NavigateHistory(int delta)
}
case HyperlinkType::Web:
OpenBrowser(link.destination.c_str());
OpenBrowser(link.destination);
break;
case HyperlinkType::File: