From a03c2f501961655d80405bc1765bfadd8cccf59e Mon Sep 17 00:00:00 2001 From: Koncord Date: Sat, 27 Aug 2016 15:36:22 +0800 Subject: [PATCH] Now server & client sensitive to version --- apps/openmw-mp/main.cpp | 6 +++--- apps/openmw/mwmp/Networking.cpp | 4 ++-- components/openmw-mp/Version.hpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 components/openmw-mp/Version.hpp diff --git a/apps/openmw-mp/main.cpp b/apps/openmw-mp/main.cpp index 9e6881884..873b8616a 100644 --- a/apps/openmw-mp/main.cpp +++ b/apps/openmw-mp/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace std; using namespace mwmp; @@ -140,7 +141,7 @@ int main(int argc, char *argv[]) vector plugins (Utils::split(mgr.getString("plugins", "Plugins"), ',')); - printVersion("0.0.1b", 1); + printVersion(TES3MP_VERSION, TES3MP_PROTO_VERSION); setenv("AMXFILE", moddir.c_str(), 1); @@ -153,8 +154,7 @@ int main(int argc, char *argv[]) RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance(); - const char passw[8] = "1234567"; - peer->SetIncomingPassword(passw, sizeof(passw)); + peer->SetIncomingPassword(TES3MP_VERSION, (int)strlen(TES3MP_VERSION)); if (RakNet::NonNumericHostString(addr.c_str())) { diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 04acfc48f..383bebbda 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -17,6 +17,7 @@ #include "Networking.hpp" #include "../mwstate/statemanagerimp.hpp" #include +#include #include "DedicatedPlayer.hpp" #include "Main.hpp" @@ -100,10 +101,9 @@ void Networking::Connect(const std::string &ip, unsigned short port) RakNet::SystemAddress master; master.SetBinaryAddress(ip.c_str()); master.SetPortHostOrder(port); - const char passw[8] = "1234567"; std::string errmsg = ""; - if (peer->Connect(master.ToString(false), master.GetPort(), passw, sizeof(passw), 0, 0, 3, 500, 0) != RakNet::CONNECTION_ATTEMPT_STARTED) + if (peer->Connect(master.ToString(false), master.GetPort(), TES3MP_VERSION, (int) strlen(TES3MP_VERSION), 0, 0, 3, 500, 0) != RakNet::CONNECTION_ATTEMPT_STARTED) errmsg = "Connection attempt failed.\n"; bool queue = true; diff --git a/components/openmw-mp/Version.hpp b/components/openmw-mp/Version.hpp new file mode 100644 index 000000000..1c970a2ef --- /dev/null +++ b/components/openmw-mp/Version.hpp @@ -0,0 +1,11 @@ +// +// Created by koncord on 27.08.16. +// + +#ifndef OPENMW_VERSION_HPP +#define OPENMW_VERSION_HPP + +#define TES3MP_VERSION "0.0.1b" +#define TES3MP_PROTO_VERSION 1 + +#endif //OPENMW_VERSION_HPP