diff --git a/src/network/network.cpp b/src/network/network.cpp index 929b270ac9..7078174476 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1154,7 +1154,7 @@ void Network::KickPlayer(int playerId) void Network::SetPassword(const char* password) { - Network::password = password; + Network::password = password == nullptr ? "" : password; } void Network::ShutdownClient() diff --git a/src/platform/posix.c b/src/platform/posix.c index 4865ffa232..ec9f69f7c1 100644 --- a/src/platform/posix.c +++ b/src/platform/posix.c @@ -49,8 +49,8 @@ utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; /** - * The function that is called directly from the host application (rct2.exe)'s WinMain. This will be removed when OpenRCT2 can - * be built as a stand alone application. + * The function that is called directly from the host application (rct2.exe)'s WinMain. + * This will be removed when OpenRCT2 can be built as a stand alone application. */ int main(int argc, const char **argv) { @@ -138,8 +138,9 @@ bool platform_original_game_data_exists(const utf8 *path) wcstombs(buffer, wPath, len); buffer[len] = '\0'; free(wPath); + char separator = platform_get_path_separator(); char checkPath[MAX_PATH]; - sprintf(checkPath, "%s%c%s%c%s", buffer, platform_get_path_separator(), "Data", platform_get_path_separator(), "g1.dat"); + sprintf(checkPath, "%s%c%s%c%s", buffer, separator, "Data", separator, "g1.dat"); return platform_file_exists(checkPath); } @@ -661,6 +662,10 @@ void platform_resolve_user_data_path() const char separator[2] = { platform_get_path_separator(), 0 }; if (gCustomUserDataPath[0] != 0) { + if (!platform_ensure_directory_exists(gCustomUserDataPath)) { + log_error("Failed to create directory \"%s\", make sure you have permissions.", gCustomUserDataPath); + return; + } if (realpath(gCustomUserDataPath, _userDataDirectoryPath) == NULL) { log_error("Could not resolve path \"%s\"", gCustomUserDataPath); return; @@ -764,8 +769,10 @@ uint16 platform_get_locale_language(){ const char *langString = setlocale(LC_MESSAGES, ""); if(langString != NULL){ // The locale has the following form: - // language[_territory[.codeset]][@modifier] (see https://www.gnu.org/software/libc/manual/html_node/Locale-Names.html) - char pattern[32]; // longest on my system is 29 with codeset and modifier, so 32 for the pattern should be more than enough + // language[_territory[.codeset]][@modifier] + // (see https://www.gnu.org/software/libc/manual/html_node/Locale-Names.html) + // longest on my system is 29 with codeset and modifier, so 32 for the pattern should be more than enough + char pattern[32]; //strip the codeset and modifier part int length = strlen(langString); { @@ -781,7 +788,9 @@ uint16 platform_get_locale_language(){ //find _ if present const char *strip = strchr(pattern, '_'); if(strip != NULL){ - pattern[strip - pattern] = '?'; // could also use '-', but '?' is more flexible. Maybe LanguagesDescriptors will change. pattern is now "language?territory" + // could also use '-', but '?' is more flexible. Maybe LanguagesDescriptors will change. + // pattern is now "language?territory" + pattern[strip - pattern] = '?'; } // Iterate through all available languages @@ -862,7 +871,11 @@ uint8 platform_get_locale_temperature_format(){ #endif if(langstring != NULL){ - if(!fnmatch("*_US*", langstring, 0) || !fnmatch("*_BS*", langstring, 0) || !fnmatch("*_BZ*", langstring, 0) || !fnmatch("*_PW*", langstring, 0)){ + if (!fnmatch("*_US*", langstring, 0) || + !fnmatch("*_BS*", langstring, 0) || + !fnmatch("*_BZ*", langstring, 0) || + !fnmatch("*_PW*", langstring, 0)) + { return TEMPERATURE_FORMAT_F; } }