From 21c8821d052fd8ad08eea23092d47bb0dbc753dd Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 3 Dec 2019 13:21:10 +0200 Subject: [PATCH] [General] Ignore carriage returns in resources/version file --- apps/openmw-mp/main.cpp | 2 ++ apps/openmw/mwmp/Networking.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/main.cpp b/apps/openmw-mp/main.cpp index 444c66d0b..7aa11c62f 100644 --- a/apps/openmw-mp/main.cpp +++ b/apps/openmw-mp/main.cpp @@ -222,6 +222,8 @@ int main(int argc, char *argv[]) stringstream sstr; sstr << TES3MP_VERSION; sstr << TES3MP_PROTO_VERSION; + // Remove carriage returns added to version file on Windows + version.mCommitHash.erase(std::remove(version.mCommitHash.begin(), version.mCommitHash.end(), '\r'), version.mCommitHash.end()); sstr << version.mCommitHash; peer->SetIncomingPassword(sstr.str().c_str(), (int) sstr.str().size()); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 54893ed84..365c9a1d5 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -279,7 +279,10 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector stringstream sstr; sstr << TES3MP_VERSION; sstr << TES3MP_PROTO_VERSION; - sstr << Version::getOpenmwVersion(Main::getResDir()).mCommitHash; + std::string commitHashString = Version::getOpenmwVersion(Main::getResDir()).mCommitHash; + // Remove carriage returns added to version file on Windows + commitHashString.erase(std::remove(commitHashString.begin(), commitHashString.end(), '\r'), commitHashString.end()); + sstr << commitHashString; if (peer->Connect(master.ToString(false), master.GetPort(), sstr.str().c_str(), (int) sstr.str().size(), 0, 0, 3, 500, 0) != RakNet::CONNECTION_ATTEMPT_STARTED) errmsg = "Connection attempt failed.\n";