[General] Use more consistent variable names for password, address, etc.

master
David Cernat 5 years ago
parent 906d2a837d
commit e96091fd6b

@ -75,9 +75,9 @@ Networking::~Networking()
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
@ -111,10 +111,10 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
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)",
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);
return;
}

@ -190,15 +190,15 @@ int main(int argc, char *argv[])
LOG_INIT(logLevel);
int players = mgr.getInt("maximumPlayers", "General");
string addr = mgr.getString("localAddress", "General");
string address = mgr.getString("localAddress", "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 moddir = Utils::convertPath(plugin_home + "/data");
string pluginHome = mgr.getString("home", "Plugins");
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);
@ -222,13 +222,13 @@ int main(int argc, char *argv[])
return 1;
}
Script::SetModDir(moddir);
Script::SetModDir(dataDirectory);
#ifdef ENABLE_LUA
LangLua::AddPackagePath(Utils::convertPath(plugin_home + "/scripts/?.lua" + ";"
+ plugin_home + "/lib/lua/?.lua" + ";"));
LangLua::AddPackagePath(Utils::convertPath(pluginHome + "/scripts/?.lua" + ";"
+ pluginHome + "/lib/lua/?.lua" + ";"));
#ifdef _WIN32
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.dll"));
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.dll"));
#else
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.so"));
#endif
@ -246,18 +246,18 @@ int main(int argc, char *argv[])
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.");
return 1;
}
RakNet::SocketDescriptor sd((unsigned short) port, addr.c_str());
RakNet::SocketDescriptor sd((unsigned short) port, address.c_str());
try
{
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))
{
@ -284,7 +284,7 @@ int main(int argc, char *argv[])
peer->SetMaximumIncomingConnections((unsigned short) (players));
Networking networking(peer);
networking.setServerPassword(passw);
networking.setServerPassword(password);
if (mgr.getBool("enabled", "MasterServer"))
{

@ -51,8 +51,8 @@ using namespace mwmp;
using namespace std;
Main *Main::pMain = 0;
std::string Main::addr = "";
std::string Main::passw = TES3MP_DEFAULT_PASSW;
std::string Main::address = "";
std::string Main::serverPassword = TES3MP_DEFAULT_PASSW;
std::string Main::resourceDir = "";
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)
{
Main::addr = variables["connect"].as<string>();
Main::passw = variables["password"].as<string>();
Main::address = variables["connect"].as<string>();
Main::serverPassword = variables["password"].as<string>();
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");
Log::SetLevel(logLevel);
if (addr.empty())
if (address.empty())
{
pMain->server = mgr.getString("destinationAddress", "General");
pMain->port = (unsigned short) mgr.getInt("port", "General");
passw = mgr.getString("password", "General");
if (passw.empty())
passw = TES3MP_DEFAULT_PASSW;
serverPassword = mgr.getString("password", "General");
if (serverPassword.empty())
serverPassword = 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());
size_t delimPos = address.find(':');
pMain->server = address.substr(0, delimPos);
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);
RestoreMgr(mgr);

@ -39,8 +39,8 @@ namespace mwmp
private:
static std::string resourceDir;
static std::string addr;
static std::string passw;
static std::string address;
static std::string serverPassword;
Main (const Main&);
///< not implemented
Main& operator= (const Main&);

@ -232,6 +232,8 @@ namespace mwmp
}
RakNet::RakNetGUID guid;
std::string serverPassword;
GUIMessageBox guiMessageBox;
// Track only the indexes of the attributes that have been changed,
@ -295,7 +297,6 @@ namespace mwmp
std::string birthsign;
std::string chatMessage;
CharGenState charGenState;
std::string passw;
std::string sound;
Animation animation;

@ -1,7 +1,3 @@
//
// Created by koncord on 28.04.16.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketHandshake.hpp"
@ -17,8 +13,8 @@ void PacketHandshake::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
if (!RW(player->npc.mName, send, true, maxNameLen) ||
!RW(player->passw, send, true, maxPasswLen))
if (!RW(player->npc.mName, send, true, maxNameLength) ||
!RW(player->serverPassword, send, true, maxPasswordLength))
{
packetValid = false;
return;

@ -16,8 +16,8 @@ namespace mwmp
virtual void Packet(RakNet::BitStream *bs, bool send);
const static uint32_t maxNameLen = 256;
const static uint32_t maxPasswLen = 256;
const static uint32_t maxNameLength = 256;
const static uint32_t maxPasswordLength = 256;
};
}

Loading…
Cancel
Save