[Client] Add password to client params and to config file

pull/163/head
Koncord 8 years ago
parent 158e9b3b09
commit ea9c31a8f7

@ -25,6 +25,7 @@
#include "../mwmechanics/spellcasting.hpp"
#include <components/openmw-mp/Log.hpp>
#include <cstdlib>
#include <components/openmw-mp/Version.hpp>
#include "Networking.hpp"
#include "LocalPlayer.hpp"
@ -37,6 +38,7 @@ using namespace std;
Main *Main::pMain = 0;
std::string Main::addr = "";
std::string Main::passw = TES3MP_DEFAULT_PASSW;
std::string loadSettings (Settings::Manager & settings)
{
@ -85,13 +87,17 @@ Main::~Main()
void Main::optionsDesc(boost::program_options::options_description *desc)
{
namespace bpo = boost::program_options;
desc->add_options()("connect", bpo::value<std::string>()->default_value(""),
"connect to server (e.g. --connect=127.0.0.1:25565)");
desc->add_options()
("connect", bpo::value<std::string>()->default_value(""),
"connect to server (e.g. --connect=127.0.0.1:25565)")
("password", bpo::value<std::string>()->default_value(TES3MP_DEFAULT_PASSW),
"сonnect to a secured server. (e.g. --password=AnyPassword");
}
void Main::configure(const boost::program_options::variables_map &variables)
{
Main::addr = variables["connect"].as<string>();
Main::passw = variables["password"].as<string>();
}
static Settings::CategorySettingValueMap saveUserSettings;
@ -130,15 +136,19 @@ bool Main::init(std::vector<std::string> &content)
{
pMain->server = mgr.getString("server", "General");
pMain->port = (unsigned short) mgr.getInt("port", "General");
passw = mgr.getString("password", "General");
if (passw.empty())
passw = TES3MP_DEFAULT_PASSW;
}
else
{
size_t delim_pos = addr.find(':');
pMain->server = addr.substr(0, delim_pos);
pMain->port = atoi(addr.substr(delim_pos + 1).c_str());
}
get().mLocalPlayer->passw = passw;
pMain->mNetworking->connect(pMain->server, pMain->port);
RestoreMgr(mgr);
return pMain->mNetworking->isConnected();

@ -34,6 +34,7 @@ namespace mwmp
private:
static std::string addr;
static std::string passw;
Main (const Main&);
///< not implemented
Main& operator= (const Main&);

@ -189,7 +189,6 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
{
case ID_HANDSHAKE:
{
getLocalPlayer()->passw = "SuperPassword";
myPacket->Send(getLocalPlayer(), serverAddr);
break;
}

@ -1,6 +1,7 @@
[General]
server = mp.tes3mp.com
port = 25565
password =
# 0 - Verbose (spam), 1 - Info, 2 - Warnings, 3 - Errors, 4 - Only fatal errors
loglevel = 0

Loading…
Cancel
Save