From c19081e01d7fb9452a9af6af81b324168882c6f0 Mon Sep 17 00:00:00 2001 From: mimooh Date: Sun, 13 Nov 2016 14:58:16 +0100 Subject: [PATCH 1/2] be much more conservative with file checksums for now --- src/stratagus/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp index bd8d240ac..4a8fa7ccc 100644 --- a/src/stratagus/script.cpp +++ b/src/stratagus/script.cpp @@ -217,7 +217,7 @@ int LuaLoadFile(const std::string &file, const std::string &strArg) if (GetFileContent(file, content) == false) { return -1; } - if (file.rfind(".lua") != -1) { + if (file.rfind("stratagus.lua") != -1 && file.find("scripts/") != -1) { FileChecksums ^= fletcher32(content); } const int status = luaL_loadbuffer(Lua, content.c_str(), content.size(), file.c_str()); From 135ceee0259ae87f10a987e9322ad3a66e90b08d Mon Sep 17 00:00:00 2001 From: mimooh Date: Sun, 13 Nov 2016 21:23:29 +0100 Subject: [PATCH 2/2] Remove \r line endings before checksumming lua files, to sidestep issues when Windows git autoconverted line endings --- src/stratagus/script.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp index 4a8fa7ccc..6d6d81403 100644 --- a/src/stratagus/script.cpp +++ b/src/stratagus/script.cpp @@ -218,7 +218,9 @@ int LuaLoadFile(const std::string &file, const std::string &strArg) return -1; } if (file.rfind("stratagus.lua") != -1 && file.find("scripts/") != -1) { - FileChecksums ^= fletcher32(content); + // First, remove '\r' characters from the input. These are added, for example, by Windows Git, and should be ignored + content.erase(std::remove(content.begin(), content.end(), '\r'), content.end()); + FileChecksums ^= fletcher32(content); } const int status = luaL_loadbuffer(Lua, content.c_str(), content.size(), file.c_str());