forked from teamnwah/openmw-tes3coop
[General] Use more consistent variable names for password, address, etc.
This commit is contained in:
parent
906d2a837d
commit
e96091fd6b
7 changed files with 37 additions and 40 deletions
|
@ -75,9 +75,9 @@ Networking::~Networking()
|
||||||
delete worldstatePacketController;
|
delete worldstatePacketController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Networking::setServerPassword(std::string passw) noexcept
|
void Networking::setServerPassword(std::string password) noexcept
|
||||||
{
|
{
|
||||||
serverPassword = passw.empty() ? TES3MP_DEFAULT_PASSW : passw;
|
serverPassword = password.empty() ? TES3MP_DEFAULT_PASSW : password;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Networking::isPassworded() const
|
bool Networking::isPassworded() const
|
||||||
|
@ -111,10 +111,10 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->passw != serverPassword)
|
if (player->serverPassword != serverPassword)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password for player %d, name: %s (pass: %s)",
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password for player %d, name: %s (pass: %s)",
|
||||||
player->getId(), player->npc.mName.c_str(), player->passw.c_str());
|
player->getId(), player->npc.mName.c_str(), player->serverPassword.c_str());
|
||||||
kickPlayer(player->guid);
|
kickPlayer(player->guid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,15 +190,15 @@ int main(int argc, char *argv[])
|
||||||
LOG_INIT(logLevel);
|
LOG_INIT(logLevel);
|
||||||
|
|
||||||
int players = mgr.getInt("maximumPlayers", "General");
|
int players = mgr.getInt("maximumPlayers", "General");
|
||||||
string addr = mgr.getString("localAddress", "General");
|
string address = mgr.getString("localAddress", "General");
|
||||||
int port = mgr.getInt("port", "General");
|
int port = mgr.getInt("port", "General");
|
||||||
|
|
||||||
string passw = mgr.getString("password", "General");
|
string password = mgr.getString("password", "General");
|
||||||
|
|
||||||
string plugin_home = mgr.getString("home", "Plugins");
|
string pluginHome = mgr.getString("home", "Plugins");
|
||||||
string moddir = Utils::convertPath(plugin_home + "/data");
|
string dataDirectory = Utils::convertPath(pluginHome + "/data");
|
||||||
|
|
||||||
vector<string> plugins (Utils::split(mgr.getString("plugins", "Plugins"), ','));
|
vector<string> plugins(Utils::split(mgr.getString("plugins", "Plugins"), ','));
|
||||||
|
|
||||||
Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
|
Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
|
||||||
|
|
||||||
|
@ -222,13 +222,13 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script::SetModDir(moddir);
|
Script::SetModDir(dataDirectory);
|
||||||
|
|
||||||
#ifdef ENABLE_LUA
|
#ifdef ENABLE_LUA
|
||||||
LangLua::AddPackagePath(Utils::convertPath(plugin_home + "/scripts/?.lua" + ";"
|
LangLua::AddPackagePath(Utils::convertPath(pluginHome + "/scripts/?.lua" + ";"
|
||||||
+ plugin_home + "/lib/lua/?.lua" + ";"));
|
+ pluginHome + "/lib/lua/?.lua" + ";"));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.dll"));
|
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.dll"));
|
||||||
#else
|
#else
|
||||||
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.so"));
|
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.so"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,18 +246,18 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
peer->SetIncomingPassword(sstr.str().c_str(), (int) sstr.str().size());
|
peer->SetIncomingPassword(sstr.str().c_str(), (int) sstr.str().size());
|
||||||
|
|
||||||
if (RakNet::NonNumericHostString(addr.c_str()))
|
if (RakNet::NonNumericHostString(address.c_str()))
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "You cannot use non-numeric addresses for the server.");
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "You cannot use non-numeric addresses for the server.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RakNet::SocketDescriptor sd((unsigned short) port, addr.c_str());
|
RakNet::SocketDescriptor sd((unsigned short) port, address.c_str());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (auto plugin : plugins)
|
for (auto plugin : plugins)
|
||||||
Script::LoadScript(plugin.c_str(), plugin_home.c_str());
|
Script::LoadScript(plugin.c_str(), pluginHome.c_str());
|
||||||
|
|
||||||
switch (peer->Startup((unsigned) players, &sd, 1))
|
switch (peer->Startup((unsigned) players, &sd, 1))
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,7 @@ int main(int argc, char *argv[])
|
||||||
peer->SetMaximumIncomingConnections((unsigned short) (players));
|
peer->SetMaximumIncomingConnections((unsigned short) (players));
|
||||||
|
|
||||||
Networking networking(peer);
|
Networking networking(peer);
|
||||||
networking.setServerPassword(passw);
|
networking.setServerPassword(password);
|
||||||
|
|
||||||
if (mgr.getBool("enabled", "MasterServer"))
|
if (mgr.getBool("enabled", "MasterServer"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,8 +51,8 @@ using namespace mwmp;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Main *Main::pMain = 0;
|
Main *Main::pMain = 0;
|
||||||
std::string Main::addr = "";
|
std::string Main::address = "";
|
||||||
std::string Main::passw = TES3MP_DEFAULT_PASSW;
|
std::string Main::serverPassword = TES3MP_DEFAULT_PASSW;
|
||||||
std::string Main::resourceDir = "";
|
std::string Main::resourceDir = "";
|
||||||
|
|
||||||
std::string Main::getResDir()
|
std::string Main::getResDir()
|
||||||
|
@ -118,8 +118,8 @@ void Main::optionsDesc(boost::program_options::options_description *desc)
|
||||||
|
|
||||||
void Main::configure(const boost::program_options::variables_map &variables)
|
void Main::configure(const boost::program_options::variables_map &variables)
|
||||||
{
|
{
|
||||||
Main::addr = variables["connect"].as<string>();
|
Main::address = variables["connect"].as<string>();
|
||||||
Main::passw = variables["password"].as<string>();
|
Main::serverPassword = variables["password"].as<string>();
|
||||||
resourceDir = variables["resources"].as<Files::EscapeHashString>().toStdString();
|
resourceDir = variables["resources"].as<Files::EscapeHashString>().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,22 +155,22 @@ bool Main::init(std::vector<std::string> &content, Files::Collections &collectio
|
||||||
|
|
||||||
int logLevel = mgr.getInt("logLevel", "General");
|
int logLevel = mgr.getInt("logLevel", "General");
|
||||||
Log::SetLevel(logLevel);
|
Log::SetLevel(logLevel);
|
||||||
if (addr.empty())
|
if (address.empty())
|
||||||
{
|
{
|
||||||
pMain->server = mgr.getString("destinationAddress", "General");
|
pMain->server = mgr.getString("destinationAddress", "General");
|
||||||
pMain->port = (unsigned short) mgr.getInt("port", "General");
|
pMain->port = (unsigned short) mgr.getInt("port", "General");
|
||||||
|
|
||||||
passw = mgr.getString("password", "General");
|
serverPassword = mgr.getString("password", "General");
|
||||||
if (passw.empty())
|
if (serverPassword.empty())
|
||||||
passw = TES3MP_DEFAULT_PASSW;
|
serverPassword = TES3MP_DEFAULT_PASSW;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t delim_pos = addr.find(':');
|
size_t delimPos = address.find(':');
|
||||||
pMain->server = addr.substr(0, delim_pos);
|
pMain->server = address.substr(0, delimPos);
|
||||||
pMain->port = atoi(addr.substr(delim_pos + 1).c_str());
|
pMain->port = atoi(address.substr(delimPos + 1).c_str());
|
||||||
}
|
}
|
||||||
get().mLocalPlayer->passw = passw;
|
get().mLocalPlayer->serverPassword = serverPassword;
|
||||||
|
|
||||||
pMain->mNetworking->connect(pMain->server, pMain->port, content, collections);
|
pMain->mNetworking->connect(pMain->server, pMain->port, content, collections);
|
||||||
RestoreMgr(mgr);
|
RestoreMgr(mgr);
|
||||||
|
|
|
@ -39,8 +39,8 @@ namespace mwmp
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string resourceDir;
|
static std::string resourceDir;
|
||||||
static std::string addr;
|
static std::string address;
|
||||||
static std::string passw;
|
static std::string serverPassword;
|
||||||
Main (const Main&);
|
Main (const Main&);
|
||||||
///< not implemented
|
///< not implemented
|
||||||
Main& operator= (const Main&);
|
Main& operator= (const Main&);
|
||||||
|
|
|
@ -232,6 +232,8 @@ namespace mwmp
|
||||||
}
|
}
|
||||||
|
|
||||||
RakNet::RakNetGUID guid;
|
RakNet::RakNetGUID guid;
|
||||||
|
std::string serverPassword;
|
||||||
|
|
||||||
GUIMessageBox guiMessageBox;
|
GUIMessageBox guiMessageBox;
|
||||||
|
|
||||||
// Track only the indexes of the attributes that have been changed,
|
// Track only the indexes of the attributes that have been changed,
|
||||||
|
@ -295,7 +297,6 @@ namespace mwmp
|
||||||
std::string birthsign;
|
std::string birthsign;
|
||||||
std::string chatMessage;
|
std::string chatMessage;
|
||||||
CharGenState charGenState;
|
CharGenState charGenState;
|
||||||
std::string passw;
|
|
||||||
|
|
||||||
std::string sound;
|
std::string sound;
|
||||||
Animation animation;
|
Animation animation;
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 28.04.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
#include "PacketHandshake.hpp"
|
#include "PacketHandshake.hpp"
|
||||||
|
|
||||||
|
@ -17,8 +13,8 @@ void PacketHandshake::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
if (!RW(player->npc.mName, send, true, maxNameLen) ||
|
if (!RW(player->npc.mName, send, true, maxNameLength) ||
|
||||||
!RW(player->passw, send, true, maxPasswLen))
|
!RW(player->serverPassword, send, true, maxPasswordLength))
|
||||||
{
|
{
|
||||||
packetValid = false;
|
packetValid = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,8 +16,8 @@ namespace mwmp
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||||
|
|
||||||
const static uint32_t maxNameLen = 256;
|
const static uint32_t maxNameLength = 256;
|
||||||
const static uint32_t maxPasswLen = 256;
|
const static uint32_t maxPasswordLength = 256;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue