From 565889ccbce8df61aeb59b9bfeb487ce8d4266e5 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 28 May 2017 18:26:48 +0800 Subject: [PATCH] [Client] Add commit hash to password --- apps/openmw/mwmp/Main.cpp | 8 ++++++++ apps/openmw/mwmp/Main.hpp | 2 ++ apps/openmw/mwmp/Networking.cpp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index 6babd07a8..462760e3d 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "../mwbase/environment.hpp" @@ -52,6 +53,12 @@ using namespace std; Main *Main::pMain = 0; std::string Main::addr = ""; std::string Main::passw = TES3MP_DEFAULT_PASSW; +std::string Main::resourceDir = ""; + +std::string Main::getResDir() +{ + return resourceDir; +} std::string loadSettings (Settings::Manager & settings) { @@ -115,6 +122,7 @@ void Main::configure(const boost::program_options::variables_map &variables) { Main::addr = variables["connect"].as(); Main::passw = variables["password"].as(); + resourceDir = variables["resources"].as().toStdString(); } static Settings::CategorySettingValueMap saveUserSettings; diff --git a/apps/openmw/mwmp/Main.hpp b/apps/openmw/mwmp/Main.hpp index 6cd02c87f..43dac31f3 100644 --- a/apps/openmw/mwmp/Main.hpp +++ b/apps/openmw/mwmp/Main.hpp @@ -29,6 +29,7 @@ namespace mwmp static void pressedKey(int key); static bool isValidPacketScript(std::string script); + static std::string getResDir(); Networking *getNetworking() const; LocalPlayer *getLocalPlayer() const; @@ -39,6 +40,7 @@ namespace mwmp void updateWorld(float dt) const; private: + static std::string resourceDir; static std::string addr; static std::string passw; Main (const Main&); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index f2e2dca5a..e56fe8c1d 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "Networking.hpp" #include "Main.hpp" @@ -250,6 +251,7 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector stringstream sstr(TES3MP_VERSION); sstr << TES3MP_PROTO_VERSION; + sstr << Version::getOpenmwVersion(Main::getResDir()).mCommitHash; 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";