From b7e5e771665b707076dee3850ee7a27708252271 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 28 Oct 2017 03:58:53 +0300 Subject: [PATCH] [Server] Fix getCaseInsensitiveFilename, simplify Players.size() --- apps/openmw-mp/Players.cpp | 4 +--- apps/openmw-mp/Script/LuaState.cpp | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw-mp/Players.cpp b/apps/openmw-mp/Players.cpp index 8b305b3bc..6f3979422 100644 --- a/apps/openmw-mp/Players.cpp +++ b/apps/openmw-mp/Players.cpp @@ -19,9 +19,7 @@ void Players::Init(LuaState &lua) func(player); }); - playersTable.set_function("size", [](){ - return store.size(); - }); + playersTable.set_function("size", &Players::size); } diff --git a/apps/openmw-mp/Script/LuaState.cpp b/apps/openmw-mp/Script/LuaState.cpp index 5cf2bbcc2..6deee4431 100644 --- a/apps/openmw-mp/Script/LuaState.cpp +++ b/apps/openmw-mp/Script/LuaState.cpp @@ -145,13 +145,15 @@ LuaState::LuaState() lua->set_function("getCaseInsensitiveFilename", [](const char *folderPath, const char *filename) { if (!boost::filesystem::exists(folderPath)) return "invalid"; + static std::string foundFilename; boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr) { if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename)) { - return itr->path().filename().string().c_str(); + foundFilename = itr->path().filename().string(); + return foundFilename.c_str(); } } return "invalid";