From cfb5835e177f8cf64b2414b4c7a7cf786f8ef73c Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 4 Dec 2017 10:38:47 +0200 Subject: [PATCH] [Server] Clean up method and variable names --- apps/openmw-mp/MasterClient.cpp | 4 ++-- apps/openmw-mp/MasterClient.hpp | 2 +- apps/openmw-mp/Script/LuaState.cpp | 18 +++++++++--------- apps/openmw-mp/Script/LuaState.hpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/openmw-mp/MasterClient.cpp b/apps/openmw-mp/MasterClient.cpp index 620e4d8f9..da0258d52 100644 --- a/apps/openmw-mp/MasterClient.cpp +++ b/apps/openmw-mp/MasterClient.cpp @@ -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()); diff --git a/apps/openmw-mp/MasterClient.hpp b/apps/openmw-mp/MasterClient.hpp index 1db086d5c..3d9165ff1 100644 --- a/apps/openmw-mp/MasterClient.hpp +++ b/apps/openmw-mp/MasterClient.hpp @@ -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); diff --git a/apps/openmw-mp/Script/LuaState.cpp b/apps/openmw-mp/Script/LuaState.cpp index dbbe90317..fbaef79fc 100644 --- a/apps/openmw-mp/Script/LuaState.cpp +++ b/apps/openmw-mp/Script/LuaState.cpp @@ -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 &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::vectorenv = 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); diff --git a/apps/openmw-mp/Script/LuaState.hpp b/apps/openmw-mp/Script/LuaState.hpp index 3914e94dc..9bd0a93bd 100644 --- a/apps/openmw-mp/Script/LuaState.hpp +++ b/apps/openmw-mp/Script/LuaState.hpp @@ -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 lua; sol::environment dataEnv;