[Server] Clean up method and variable names

sol2-server-rewrite
David Cernat 7 years ago
parent cd03d59056
commit cfb5835e17

@ -68,10 +68,10 @@ void MasterClient::SetHostname(std::string hostname)
mutexData.unlock();
}
void MasterClient::SetModname(std::string modname)
void MasterClient::SetGameModeName(std::string modeName)
{
mutexData.lock();
string substr = modname.substr(0, 200);
string substr = modeName.substr(0, 200);
if (queryData.GetGameMode() != substr)
{
queryData.SetGameMode(substr.c_str());

@ -24,7 +24,7 @@ public:
void SetPlayers(unsigned pl);
void SetMaxPlayers(unsigned pl);
void SetHostname(std::string hostname);
void SetModname(std::string hostname);
void SetGameModeName(std::string modeName);
void SetRuleString(std::string key, std::string value);
void SetRuleValue(std::string key, double value);
void PushPlugin(Plugin plugin);

@ -227,10 +227,10 @@ LuaState::LuaState()
}
});
lua->set_function("setModname", [](const std::string &modName) {
lua->set_function("setGameModeName", [](const std::string &modeName) {
auto mc = mwmp::Networking::getPtr()->getMasterClient();
if (mc)
mc->SetModname(modName);
mc->SetGameModeName(modeName);
});
lua->set_function("setHostname", [](const std::string &hostname) {
@ -281,7 +281,7 @@ LuaState::LuaState()
});
}
sol::environment LuaState::openScript(std::string homePath, std::string moduleName)
sol::environment LuaState::openModule(std::string homePath, std::string moduleName)
{
cout << "Loading module: " << homePath + "/modules/" + moduleName + "/main.lua" << endl;
@ -340,7 +340,7 @@ ObjectController &LuaState::getObjectCtrl()
return *objectCtrl;
}
int CompVersion(const string &wishVersion, const string &depVersionFound)
int compareVersion(const string &wishVersion, const string &depVersionFound)
{
unsigned startVer = 0;
@ -358,7 +358,7 @@ int CompVersion(const string &wishVersion, const string &depVersionFound)
auto wishIter = tokensWish.begin();
auto founditer = tokensFound.begin();
int bellowExpected = 0;
int belowExpected = 0;
for (int i = 0; i < 3; ++i)
{
@ -371,7 +371,7 @@ int CompVersion(const string &wishVersion, const string &depVersionFound)
if (v2 <= v1)
{
if (v2 == v1 && startVer == 1)
bellowExpected++;
belowExpected++;
else if (v2 < v1)
return -1; // found version below expected
continue;
@ -380,7 +380,7 @@ int CompVersion(const string &wishVersion, const string &depVersionFound)
return 1; // version higher than expected
}
if (bellowExpected == 3)
if (belowExpected == 3)
return -1; // found version below expected
return 0;
@ -400,7 +400,7 @@ void checkDependencies(const vector<ServerModuleInfo> &modules, const ServerModu
if (depEnvIt != modules.end())
{
const string &depVersionFound = depEnvIt->version;
if (CompVersion(depVersionRequest, depVersionFound) != 0)
if (compareVersion(depVersionRequest, depVersionFound) != 0)
{
stringstream sstr;
sstr << depNameRequest << ": version \"" << depVersionFound << "\" is not applicable for \""
@ -565,7 +565,7 @@ void LuaState::loadModules(const std::string &moduleDir, std::vector<std::string
for (auto &&module : sortedModuleList)
{
module->env = openScript(module->path.first, module->path.second);
module->env = openModule(module->path.first, module->path.second);
sol::table loaded = dataEnv["Core"]["loadedModules"];
loaded.add(module->name);

@ -46,7 +46,7 @@ public:
ActorController &getActorCtrl();
private:
sol::environment openScript(std::string path, std::string moduleName);
sol::environment openModule(std::string path, std::string moduleName);
private:
std::shared_ptr<sol::state> lua;
sol::environment dataEnv;

Loading…
Cancel
Save