diff --git a/apps/openmw-mp/Script/Functions/Books.cpp b/apps/openmw-mp/Script/Functions/Books.cpp index 3b6b905ae..62e49bb2b 100644 --- a/apps/openmw-mp/Script/Functions/Books.cpp +++ b/apps/openmw-mp/Script/Functions/Books.cpp @@ -1,6 +1,8 @@ #include "Books.hpp" -#include + #include + +#include #include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/Cells.cpp b/apps/openmw-mp/Script/Functions/Cells.cpp index 42a955998..90549a513 100644 --- a/apps/openmw-mp/Script/Functions/Cells.cpp +++ b/apps/openmw-mp/Script/Functions/Cells.cpp @@ -1,9 +1,11 @@ #include "Cells.hpp" -#include + +#include #include + +#include #include #include -#include #include using namespace std; diff --git a/apps/openmw-mp/Script/Functions/CharClass.cpp b/apps/openmw-mp/Script/Functions/CharClass.cpp index 45aac4266..19e87a58b 100644 --- a/apps/openmw-mp/Script/Functions/CharClass.cpp +++ b/apps/openmw-mp/Script/Functions/CharClass.cpp @@ -3,9 +3,11 @@ // #include "CharClass.hpp" + +#include + #include #include -#include using namespace std; using namespace ESM; diff --git a/apps/openmw-mp/Script/Functions/Dialogue.cpp b/apps/openmw-mp/Script/Functions/Dialogue.cpp index 714e844fe..13f9811c1 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.cpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.cpp @@ -1,6 +1,8 @@ #include "Dialogue.hpp" -#include + #include + +#include #include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/Factions.cpp b/apps/openmw-mp/Script/Functions/Factions.cpp index e8935a881..41200d677 100644 --- a/apps/openmw-mp/Script/Functions/Factions.cpp +++ b/apps/openmw-mp/Script/Functions/Factions.cpp @@ -1,8 +1,10 @@ #include "Factions.hpp" -#include + +#include #include + +#include #include -#include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index d82085a17..fcf5860f8 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -3,9 +3,11 @@ // #include "GUI.hpp" + +#include + #include #include -#include void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept { diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 0626a1c34..44d957ef5 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -3,11 +3,13 @@ // #include "Items.hpp" -#include + +#include #include + +#include #include #include -#include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/Mechanics.cpp b/apps/openmw-mp/Script/Functions/Mechanics.cpp index 62dcc33ae..bf499045a 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.cpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.cpp @@ -1,9 +1,11 @@ #include "Mechanics.hpp" -#include + #include -#include #include +#include +#include + #include using namespace std; diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp index 180c5bf18..7270fe3e0 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -1,11 +1,33 @@ #include "Miscellaneous.hpp" + +#include +#include + #include #include -#include #include using namespace std; +static std::string tempFilename; + +const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept +{ + if (!boost::filesystem::exists(folderPath)) return "invalid"; + + 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)) + { + tempFilename = itr->path().filename().string(); + return tempFilename.c_str(); + } + } + return "invalid"; +} + unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept { return Players::getLastPlayerId(); diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp index 158921bbe..487b924ec 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -4,17 +4,30 @@ #include "../Types.hpp" #define MISCELLANEOUSAPI \ - {"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\ + {"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\ \ - {"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\ - {"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\ + {"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\ \ - {"LogMessage", MiscellaneousFunctions::LogMessage},\ - {"LogAppend", MiscellaneousFunctions::LogAppend} + {"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\ + {"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\ + \ + {"LogMessage", MiscellaneousFunctions::LogMessage},\ + {"LogAppend", MiscellaneousFunctions::LogAppend} class MiscellaneousFunctions { public: + + /** + * \brief Get the first filename in a folder that has a case insensitive match with the filename + * argument. + * + * This is used to retain case insensitivity when opening data files on Linux. + * + * \return The filename that matches. + */ + static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept; + /** * \brief Get the last player ID currently connected to the server. * diff --git a/apps/openmw-mp/Script/Functions/Quests.cpp b/apps/openmw-mp/Script/Functions/Quests.cpp index 6bd577079..7c85ec956 100644 --- a/apps/openmw-mp/Script/Functions/Quests.cpp +++ b/apps/openmw-mp/Script/Functions/Quests.cpp @@ -1,8 +1,10 @@ #include "Quests.hpp" -#include + +#include #include + +#include #include -#include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/Settings.cpp b/apps/openmw-mp/Script/Functions/Settings.cpp index 7572c1d3a..36486b17f 100644 --- a/apps/openmw-mp/Script/Functions/Settings.cpp +++ b/apps/openmw-mp/Script/Functions/Settings.cpp @@ -1,9 +1,11 @@ #include "Settings.hpp" -#include + #include -#include #include +#include +#include + #include using namespace std; diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index 05fbf5011..00c242529 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -1,8 +1,10 @@ #include "Spells.hpp" -#include + +#include #include + +#include #include -#include using namespace mwmp; diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index 1d531ba2b..4c5deec13 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -3,14 +3,16 @@ // #include "Stats.hpp" -#include -#include -#include +#include + #include #include #include #include -#include +#include + +#include +#include using namespace std; using namespace ESM; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index ea7487095..296b6eee3 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -592,7 +592,7 @@ namespace MWScript */ if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen()) { - if (!ref.getRefData().isEnabled()) + if (!ref.getRefData().isEnabled() && ref.getCell() != nullptr) { mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset(); @@ -620,7 +620,7 @@ namespace MWScript */ if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen()) { - if (ref.getRefData().isEnabled()) + if (ref.getRefData().isEnabled() && ref.getCell() != nullptr) { mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); worldEvent->reset();