From bb183457a63c49d0a79ad18c668b71d7b8c8e76e Mon Sep 17 00:00:00 2001 From: Koncord Date: Tue, 12 Sep 2017 21:30:37 +0800 Subject: [PATCH] [Master] Init BanAddress/UnbanAddress before opening script --- apps/master/MasterServer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/master/MasterServer.cpp b/apps/master/MasterServer.cpp index 27bba07d9..317f4174a 100644 --- a/apps/master/MasterServer.cpp +++ b/apps/master/MasterServer.cpp @@ -29,6 +29,9 @@ MasterServer::MasterServer(const std::string &luaScript) std::string package_path = state["package"]["path"]; state["package"]["path"] = Utils::convertPath(absPath.parent_path().string() + "/?.lua") + ";" + package_path; + state.set_function("BanAddress", &MasterServer::ban, this); + state.set_function("UnbanAddress", &MasterServer::unban, this); + state.script_file(luaScript); sol::table config = state["config"]; @@ -44,18 +47,12 @@ MasterServer::MasterServer(const std::string &luaScript) if (port.get_type() != sol::type::number) throw runtime_error("config.port is not correct"); - state.set_function("BanAddress", [this](const string &address) { - this->ban(address); - }); state.new_usertype("Server", "name", sol::property(&MasterServer::SServer::GetName), "gamemode", sol::property(&MasterServer::SServer::GetGameMode), "version", sol::property(&MasterServer::SServer::GetVersion) ); - state.set_function("UnbanAddress", [this](const string &address) { - this->unban(address); - }); peer = RakPeerInterface::GetInstance(); sockdescr = SocketDescriptor(port.as(), nullptr);