[Server] Remove 'using namespace std'

pull/593/head
David Cernat 4 years ago
parent 4940687455
commit 2656569d31

@ -6,8 +6,6 @@
#include "Player.hpp"
#include "Script/Script.hpp"
using namespace std;
Cell::Cell(ESM::Cell cell) : cell(cell)
{
cellActorList.count = 0;

@ -5,8 +5,6 @@
#include "Player.hpp"
#include "Script/Script.hpp"
using namespace std;
CellController::CellController()
{

@ -10,7 +10,6 @@
#include <components/openmw-mp/Master/PacketMasterAnnounce.hpp>
#include "Networking.hpp"
using namespace std;
using namespace mwmp;
using namespace RakNet;
@ -50,7 +49,7 @@ void MasterClient::SetMaxPlayers(unsigned pl)
void MasterClient::SetHostname(std::string hostname)
{
mutexData.lock();
string substr = hostname.substr(0, 200);
std::string substr = hostname.substr(0, 200);
if (queryData.GetName() != substr)
{
queryData.SetName(substr.c_str());
@ -62,7 +61,7 @@ void MasterClient::SetHostname(std::string hostname)
void MasterClient::SetModname(std::string modname)
{
mutexData.lock();
string substr = modname.substr(0, 200);
std::string substr = modname.substr(0, 200);
if (queryData.GetGameMode() != substr)
{
queryData.SetGameMode(substr.c_str());
@ -236,7 +235,7 @@ void MasterClient::Thread()
void MasterClient::Start()
{
thrQuery = thread(&MasterClient::Thread, this);
thrQuery = std::thread(&MasterClient::Thread, this);
}
void MasterClient::Stop()

@ -28,7 +28,6 @@
#include "handleInput.cpp"
using namespace mwmp;
using namespace std;
Networking *Networking::sThis = 0;
@ -490,7 +489,7 @@ void Networking::stopServer(int code)
void signalHandler(int signum)
{
cout << "Interrupt signal (" << signum << ") received.\n";
std::cout << "Interrupt signal (" << signum << ") received.\n";
//15 is SIGTERM(Normal OS stop call), 2 is SIGINT(Ctrl+C)
if(signum == 15 or signum == 2)
{
@ -585,7 +584,7 @@ int Networking::mainLoop()
}
}
TimerAPI::Tick();
this_thread::sleep_for(chrono::milliseconds(1));
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
TimerAPI::Terminate();

@ -4,8 +4,6 @@
TPlayers Players::players;
TSlots Players::slots;
using namespace std;
void Players::deletePlayer(RakNet::RakNetGUID guid)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Deleting player with guid %lu", guid.g);
@ -89,12 +87,12 @@ void Player::setId(unsigned short id)
bool Player::isHandshaked()
{
return handshakeCounter == numeric_limits<int>::max();
return handshakeCounter == std::numeric_limits<int>::max();
}
void Player::setHandshake()
{
handshakeCounter = numeric_limits<int>::max();
handshakeCounter = std::numeric_limits<int>::max();
}
void Player::incrementHandshakeAttempts()

@ -1,9 +1,7 @@
#include <Script/ScriptFunction.hpp>
#include "PublicFnAPI.hpp"
using namespace std;
unordered_map<string, Public *> Public::publics;
std::unordered_map<std::string, Public *> Public::publics;
Public::~Public()
{
@ -25,7 +23,7 @@ boost::any Public::Call(const std::string &name, const std::vector<boost::any> &
{
auto it = publics.find(name);
if (it == publics.end())
throw runtime_error("Public with name \"" + name + "\" does not exist");
throw std::runtime_error("Public with name \"" + name + "\" does not exist");
return it->second->ScriptFunction::Call(args);
}
@ -36,7 +34,7 @@ const std::string &Public::GetDefinition(const std::string &name)
auto it = publics.find(name);
if (it == publics.end())
throw runtime_error("Public with name \"" + name + "\" does not exist");
throw std::runtime_error("Public with name \"" + name + "\" does not exist");
return it->second->def;
}
@ -49,7 +47,7 @@ bool Public::IsLua(const std::string &name)
#else
auto it = publics.find(name);
if (it == publics.end())
throw runtime_error("Public with name \"" + name + "\" does not exist");
throw std::runtime_error("Public with name \"" + name + "\" does not exist");
return it->second->script_type == SCRIPT_LUA;
#endif

@ -4,7 +4,6 @@
#include <iostream>
using namespace mwmp;
using namespace std;
Timer::Timer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args) : ScriptFunction(callback, 'v', def)
{
@ -27,8 +26,8 @@ void Timer::Tick()
if (isEnded)
return;
const auto duration = chrono::system_clock::now().time_since_epoch();
const auto time = chrono::duration_cast<chrono::milliseconds>(duration).count();
const auto duration = std::chrono::system_clock::now().time_since_epoch();
const auto time = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
if (time - startTime >= targetMsec)
{
@ -57,8 +56,8 @@ void Timer::Start()
{
isEnded = false;
const auto duration = chrono::system_clock::now().time_since_epoch();
const auto msec = chrono::duration_cast<chrono::milliseconds>(duration).count();
const auto duration = std::chrono::system_clock::now().time_since_epoch();
const auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
startTime = msec;
}
@ -125,7 +124,7 @@ void TimerAPI::FreeTimer(int timerid)
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
std::cerr << "Timer " << timerid << " not found!" << std::endl;
}
}
@ -137,7 +136,7 @@ void TimerAPI::ResetTimer(int timerid, long msec)
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
std::cerr << "Timer " << timerid << " not found!" << std::endl;
}
}
@ -152,7 +151,7 @@ void TimerAPI::StartTimer(int timerid)
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
std::cerr << "Timer " << timerid << " not found!" << std::endl;
}
}
@ -164,7 +163,7 @@ void TimerAPI::StopTimer(int timerid)
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
std::cerr << "Timer " << timerid << " not found!" << std::endl;
}
}
@ -177,7 +176,7 @@ bool TimerAPI::IsTimerElapsed(int timerid)
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
std::cerr << "Timer " << timerid << " not found!" << std::endl;
}
return ret;
}

@ -8,7 +8,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
static std::string tempCellDescription;

@ -5,7 +5,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
using namespace std;
using namespace ESM;
const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
@ -38,7 +37,7 @@ int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char
GET_PLAYER(pid, player, 0);
if (slot > 1)
throw invalid_argument("Incorrect attribute slot id");
throw std::invalid_argument("Incorrect attribute slot id");
return player->charClass.mData.mAttribute[slot];
}
@ -57,7 +56,7 @@ int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slo
GET_PLAYER(pid, player, 0);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
throw std::invalid_argument("Incorrect skill slot id");
return player->charClass.mData.mSkills[slot][1];
}
@ -68,7 +67,7 @@ int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slo
GET_PLAYER(pid, player, 0);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
throw std::invalid_argument("Incorrect skill slot id");
return player->charClass.mData.mSkills[slot][0];
}
@ -109,7 +108,7 @@ void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned cha
GET_PLAYER(pid, player,);
if (slot > 1)
throw invalid_argument("Incorrect attribute slot id");
throw std::invalid_argument("Incorrect attribute slot id");
player->charClass.mData.mAttribute[slot] = attrId;
@ -127,7 +126,7 @@ void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char sl
GET_PLAYER(pid, player,);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
throw std::invalid_argument("Incorrect skill slot id");
player->charClass.mData.mSkills[slot][1] = skillId;
}
@ -137,7 +136,7 @@ void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char sl
GET_PLAYER(pid, player,);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
throw std::invalid_argument("Incorrect skill slot id");
player->charClass.mData.mSkills[slot][0] = skillId;
}

@ -7,7 +7,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
static std::string tempCellDescription;

@ -9,8 +9,6 @@
#include <iostream>
#include <random>
using namespace std;
const char *MiscellaneousFunctions::GenerateRandomString(unsigned int length) noexcept
{
const std::string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

@ -5,7 +5,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
double PositionFunctions::GetPosX(unsigned short pid) noexcept
{

@ -9,7 +9,6 @@
#include "RecordsDynamic.hpp"
using namespace std;
using namespace mwmp;
SpellRecord tempSpell;

@ -7,7 +7,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
{

@ -7,7 +7,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
{

@ -11,7 +11,6 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
using namespace std;
using namespace ESM;
int StatsFunctions::GetAttributeCount() noexcept

@ -4,19 +4,18 @@
#include <Networking.hpp>
#include <Script/API/TimerAPI.hpp>
using namespace std;
using namespace mwmp;
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
{
return mwmp::TimerAPI::CreateTimer(callback, msec, "", vector<boost::any>());
return mwmp::TimerAPI::CreateTimer(callback, msec, "", std::vector<boost::any>());
}
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept
{
try
{
vector<boost::any> params;
std::vector<boost::any> params;
Utils::getArguments(params, args, types);
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);

@ -10,7 +10,6 @@
#include "Worldstate.hpp"
using namespace std;
using namespace mwmp;
BaseWorldstate *WorldstateFunctions::readWorldstate;

@ -3,14 +3,12 @@
#include <Script/Script.hpp>
#include <Script/Types.hpp>
using namespace std;
std::set<std::string> LangLua::packagePath;
std::set<std::string> LangLua::packageCPath;
void setLuaPath(lua_State* L, const char* path, bool cpath = false)
{
string field = cpath ? "cpath" : "path";
std::string field = cpath ? "cpath" : "path";
lua_getglobal(L, "package");
lua_getfield(L, -1, field.c_str());
@ -62,9 +60,9 @@ struct Lua_dispatch_ {
constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F];
auto arg = luabridge::Stack<typename CharType<F_.func.types[I - 1]>::type>::get(lua, I);
return Lua_dispatch_<I - 1, F>::template Lua_dispatch<R>(
forward<lua_State*>(lua),
std::forward<lua_State*>(lua),
arg,
forward<Args>(args)...);
std::forward<Args>(args)...);
}
};
@ -73,20 +71,20 @@ struct Lua_dispatch_<0, F> {
template<typename R, typename... Args>
inline static R Lua_dispatch(lua_State*&&, Args&&... args) noexcept {
constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F];
return reinterpret_cast<FunctionEllipsis<R>>(F_.func.addr)(forward<Args>(args)...);
return reinterpret_cast<FunctionEllipsis<R>>(F_.func.addr)(std::forward<Args>(args)...);
}
};
template<unsigned int I>
static typename enable_if<ScriptFunctions::functions[I].func.ret == 'v', int>::type wrapper(lua_State* lua) noexcept {
Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<void>(forward<lua_State*>(lua));
static typename std::enable_if<ScriptFunctions::functions[I].func.ret == 'v', int>::type wrapper(lua_State* lua) noexcept {
Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<void>(std::forward<lua_State*>(lua));
return 0;
}
template<unsigned int I>
static typename enable_if<ScriptFunctions::functions[I].func.ret != 'v', int>::type wrapper(lua_State* lua) noexcept {
static typename std::enable_if<ScriptFunctions::functions[I].func.ret != 'v', int>::type wrapper(lua_State* lua) noexcept {
auto ret = Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<
typename CharType<ScriptFunctions::functions[I].func.ret>::type>(forward<lua_State*>(lua));
typename CharType<ScriptFunctions::functions[I].func.ret>::type>(std::forward<lua_State*>(lua));
luabridge::Stack <typename CharType<ScriptFunctions::functions[I].func.ret>::type>::push (lua, ret);
return 1;
}
@ -169,8 +167,8 @@ void LangLua::LoadProgram(const char *filename)
int err = 0;
if ((err =luaL_loadfile(lua, filename)) != 0)
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
string(lua_tostring(lua, -1)) + "\"");
throw std::runtime_error("Lua script " + std::string(filename) + " error (" + std::to_string(err) + "): \"" +
std::string(lua_tostring(lua, -1)) + "\"");
constexpr auto functions_n = sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]);
@ -187,8 +185,8 @@ void LangLua::LoadProgram(const char *filename)
tes3mp.endNamespace();
if ((err = lua_pcall(lua, 0, 0, 0)) != 0) // Run once script for load in memory.
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
string(lua_tostring(lua, -1)) + "\"");
throw std::runtime_error("Lua script " + std::string(filename) + " error (" + std::to_string(err) + "): \"" +
std::string(lua_tostring(lua, -1)) + "\"");
}
int LangLua::FreeProgram()
@ -248,7 +246,7 @@ boost::any LangLua::Call(const char *name, const char *argl, int buf, ...)
break;
default:
throw runtime_error("C++ call: Unknown argument identifier " + argl[index]);
throw std::runtime_error("C++ call: Unknown argument identifier " + argl[index]);
}
}
@ -300,7 +298,7 @@ boost::any LangLua::Call(const char *name, const char *argl, const std::vector<b
luabridge::Stack<bool>::push(lua, boost::any_cast<int>(args.at(index)));
break;
default:
throw runtime_error("Lua call: Unknown argument identifier " + argl[index]);
throw std::runtime_error("Lua call: Unknown argument identifier " + argl[index]);
}
}

@ -3,11 +3,9 @@
#include <Script/API/TimerAPI.hpp>
#include <Script/API/PublicFnAPI.hpp>
using namespace std;
inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin, int args_n)
inline std::vector<boost::any> DefToVec(lua_State *lua, std::string types, int args_begin, int args_n)
{
vector<boost::any> args;
std::vector<boost::any> args;
for (int i = args_begin; i < args_n + args_begin; i++)
{
@ -51,8 +49,8 @@ inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin,
default:
{
stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << endl;
std::stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << std::endl;
throw std::runtime_error(ssErr.str());
}
}
@ -78,12 +76,12 @@ int LangLua::CallPublic(lua_State *lua)
int args_n = lua_gettop(lua) - 1;
string types = Public::GetDefinition(name);
std::string types = Public::GetDefinition(name);
if (args_n != (long)types.size())
throw invalid_argument("Script call: Number of arguments does not match definition");
throw std::invalid_argument("Script call: Number of arguments does not match definition");
vector<boost::any> args = DefToVec(lua, types, 2, args_n);
std::vector<boost::any> args = DefToVec(lua, types, 2, args_n);
boost::any result = Public::Call(&name[0], args);
if (result.empty())
@ -106,7 +104,7 @@ int LangLua::CreateTimer(lua_State *lua) noexcept
const char * callback= luabridge::Stack<const char*>::get(lua, 1);
int msec = luabridge::Stack<int>::get(lua, 2);
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, "", vector<boost::any>());
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, "", std::vector<boost::any>());
luabridge::push(lua, id);
return 1;
}
@ -120,7 +118,7 @@ int LangLua::CreateTimerEx(lua_State *lua)
int args_n = (int)lua_strlen(lua, 3);
vector<boost::any> args;
std::vector<boost::any> args;
for (int i = 4; i < args_n + 4; i++)
{
@ -164,8 +162,8 @@ int LangLua::CreateTimerEx(lua_State *lua)
default:
{
stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << endl;
std::stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << std::endl;
throw std::runtime_error(ssErr.str());
}
}

@ -7,8 +7,6 @@
#include <Script/SystemInterface.hpp>
#include <Script/Script.hpp>
using namespace std;
template<typename R>
bool SetScript(lib_t lib, const char *name, R value)
{
@ -25,7 +23,7 @@ void LangNative::LoadProgram(const char *filename)
FILE *file = fopen(filename, "rb");
if (!file)
throw runtime_error("Script not found: " + string(filename));
throw std::runtime_error("Script not found: " + std::string(filename));
fclose(file);
@ -36,16 +34,16 @@ void LangNative::LoadProgram(const char *filename)
#endif
if (!lib)
throw runtime_error("Was not able to load C++ script: " + string(filename));
throw std::runtime_error("Was not able to load C++ script: " + std::string(filename));
try
{
const char *prefix = SystemInterface<const char *>(lib, "prefix").result;
string pf(prefix);
std::string pf(prefix);
for (const auto &function : ScriptFunctions::functions)
if (!SetScript(lib, string(pf + function.name).c_str(), function.func.addr))
if (!SetScript(lib, std::string(pf + function.name).c_str(), function.func.addr))
LOG_MESSAGE_SIMPLE(TimedLog::LOG_WARN, "Script function pointer not found: %s", function.name);
}
catch (...)

@ -5,8 +5,6 @@
#include "LangLua/LangLua.hpp"
#endif
using namespace std;
Script::ScriptList Script::scripts;
std::string Script::moddir;
@ -15,7 +13,7 @@ Script::Script(const char *path)
FILE *file = fopen(path, "rb");
if (!file)
throw runtime_error("Script not found: " + string(path));
throw std::runtime_error("Script not found: " + std::string(path));
fclose(file);
@ -36,7 +34,7 @@ Script::Script(const char *path)
}
#endif
else
throw runtime_error("Script type not recognized: " + string(path));
throw std::runtime_error("Script type not recognized: " + std::string(path));
try
{

@ -6,9 +6,7 @@
#include "LangLua/LangLua.hpp"
#endif
using namespace std;
ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const string &def) :
ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const std::string &def) :
fCpp(fCpp), ret_type(ret_type), def(def), script_type(SCRIPT_CPP)
{
@ -30,12 +28,12 @@ ScriptFunction::~ScriptFunction()
#endif
}
boost::any ScriptFunction::Call(const vector<boost::any> &args)
boost::any ScriptFunction::Call(const std::vector<boost::any> &args)
{
boost::any result;
if (def.length() != args.size())
throw runtime_error("Script call: Number of arguments does not match definition");
throw std::runtime_error("Script call: Number of arguments does not match definition");
#if defined (ENABLE_LUA)
else if (script_type == SCRIPT_LUA)
{
@ -60,7 +58,7 @@ boost::any ScriptFunction::Call(const vector<boost::any> &args)
result = boost::any();
break;
default:
throw runtime_error("Lua call: Unknown return type" + ret_type);
throw std::runtime_error("Lua call: Unknown return type" + ret_type);
}
lua_settop(fLua.lua, 0);

@ -11,8 +11,6 @@ constexpr char TypeString<Types...>::value[];
constexpr ScriptFunctionData ScriptFunctions::functions[];
constexpr ScriptCallbackData ScriptFunctions::callbacks[];
using namespace std;
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
{
Public::MakePublic(_public, name, ret_type, def);
@ -20,11 +18,11 @@ void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_
boost::any ScriptFunctions::CallPublic(const char *name, va_list args) noexcept
{
vector<boost::any> params;
std::vector<boost::any> params;
try
{
string def = Public::GetDefinition(name);
std::string def = Public::GetDefinition(name);
Utils::getArguments(params, args, def);
return Public::Call(name, params);

@ -2,12 +2,10 @@
#include <cstdarg>
using namespace std;
const vector<string> Utils::split(const string &str, int delimiter)
const std::vector<std::string> Utils::split(const std::string &str, int delimiter)
{
string buffer;
vector<string> result;
std::string buffer;
std::vector<std::string> result;
for (auto symb:str)
if (symb != delimiter)
@ -94,7 +92,7 @@ void Utils::getArguments(std::vector<boost::any> &params, va_list args, const st
break;
default:
throw runtime_error("C++ call: Unknown argument identifier " + c);
throw std::runtime_error("C++ call: Unknown argument identifier " + c);
}
}
}

@ -1,6 +1,5 @@
using namespace std;
namespace mwmp_input {
string windowInputBuffer;
std::string windowInputBuffer;
void handler() {
char c;
#ifndef WIN32
@ -10,9 +9,9 @@ namespace mwmp_input {
while (_kbhit()) {
c = _getch();
#endif
cout << c << flush;
std::cout << c << std::flush;
if (c == '\n' || c == '\r') { // handle carriage return as new line on Windows
cout << endl;
std::cout << std::endl;
Script::Call<Script::CallbackIdentity("OnServerWindowInput")>(windowInputBuffer.c_str());
windowInputBuffer.assign("");
}

@ -31,7 +31,6 @@
#include <handler/exception_handler.h>
#endif
using namespace std;
using namespace mwmp;
#ifdef ENABLE_BREAKPAD
@ -190,15 +189,15 @@ int main(int argc, char *argv[])
LOG_INIT(logLevel);
int players = mgr.getInt("maximumPlayers", "General");
string address = mgr.getString("localAddress", "General");
std::string address = mgr.getString("localAddress", "General");
int port = mgr.getInt("port", "General");
string password = mgr.getString("password", "General");
std::string password = mgr.getString("password", "General");
string pluginHome = mgr.getString("home", "Plugins");
string dataDirectory = Utils::convertPath(pluginHome + "/data");
std::string pluginHome = mgr.getString("home", "Plugins");
std::string dataDirectory = Utils::convertPath(pluginHome + "/data");
vector<string> plugins(Utils::split(mgr.getString("plugins", "Plugins"), ','));
std::vector<std::string> plugins(Utils::split(mgr.getString("plugins", "Plugins"), ','));
std::string versionInfo = Utils::getVersionInfo("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "%s", versionInfo.c_str());
@ -220,7 +219,7 @@ int main(int argc, char *argv[])
RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance();
stringstream sstr;
std::stringstream sstr;
sstr << TES3MP_VERSION;
sstr << TES3MP_PROTO_VERSION;
// Remove carriage returns added to version file on Windows
@ -247,21 +246,21 @@ int main(int argc, char *argv[])
case RakNet::CRABNET_STARTED:
break;
case RakNet::CRABNET_ALREADY_STARTED:
throw runtime_error("Already started");
throw std::runtime_error("Already started");
case RakNet::INVALID_SOCKET_DESCRIPTORS:
throw runtime_error("Incorrect port or address");
throw std::runtime_error("Incorrect port or address");
case RakNet::INVALID_MAX_CONNECTIONS:
throw runtime_error("Max players cannot be negative or 0");
throw std::runtime_error("Max players cannot be negative or 0");
case RakNet::SOCKET_FAILED_TO_BIND:
case RakNet::SOCKET_PORT_ALREADY_IN_USE:
case RakNet::PORT_CANNOT_BE_ZERO:
throw runtime_error("Failed to bind port. Make sure a server isn't already running on that port.");
throw std::runtime_error("Failed to bind port. Make sure a server isn't already running on that port.");
case RakNet::SOCKET_FAILED_TEST_SEND:
case RakNet::SOCKET_FAMILY_NOT_SUPPORTED:
case RakNet::FAILED_TO_CREATE_NETWORK_THREAD:
case RakNet::COULD_NOT_GENERATE_GUID:
case RakNet::STARTUP_OTHER_FAILURE:
throw runtime_error("Cannot start server");
throw std::runtime_error("Cannot start server");
}
peer->SetMaximumIncomingConnections((unsigned short) (players));
@ -272,7 +271,7 @@ int main(int argc, char *argv[])
if (mgr.getBool("enabled", "MasterServer"))
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sharing server query info to master enabled.");
string masterAddr = mgr.getString("address", "MasterServer");
std::string masterAddr = mgr.getString("address", "MasterServer");
int masterPort = mgr.getInt("port", "MasterServer");
int updateRate = mgr.getInt("rate", "MasterServer");
@ -294,7 +293,7 @@ int main(int argc, char *argv[])
networking.InitQuery(masterAddr, (unsigned short) masterPort);
networking.getMasterClient()->SetMaxPlayers((unsigned) players);
networking.getMasterClient()->SetUpdateRate((unsigned) updateRate);
string hostname = mgr.getString("hostname", "General");
std::string hostname = mgr.getString("hostname", "General");
networking.getMasterClient()->SetHostname(hostname);
networking.getMasterClient()->SetRuleString("CommitHash", version.mCommitHash.substr(0, 10));

Loading…
Cancel
Save