From 00091491c3a0109f168dc1559341ceb70c4b8701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=B3=D0=B4=D0=B0=D0=BD=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=B3=D0=B5=D1=80?= Date: Thu, 21 Jul 2022 14:00:07 +0300 Subject: [PATCH] StormOpenFile has been replaced with StormOpenFileEx to fix a bug with looking for files on the local drive when we need to open a file from mpq. A mode for require has also been added, which allows the use of a dot in the path. --- README.md | 2 +- Src/EasyStormLib/EasyStormLib.cpp | 11 ++++------- Src/LuaHooks.cpp | 6 ++++++ Src/pch.h | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ae59822..91a541f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# War3 Lua - 1.1.8 (Outland) +# War3 Lua - 1.1.9 (Outland) [![build](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml/badge.svg)](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml) ![lua](https://img.shields.io/badge/lua-v5.4.4-blue) diff --git a/Src/EasyStormLib/EasyStormLib.cpp b/Src/EasyStormLib/EasyStormLib.cpp index 84db052..a1a1fa3 100644 --- a/Src/EasyStormLib/EasyStormLib.cpp +++ b/Src/EasyStormLib/EasyStormLib.cpp @@ -2,6 +2,8 @@ #include "EasyStormLib.h" #include "StormLib.h" +#define SFILE_OPEN_FROM_MPQ 0 + namespace Storm { Archive::Archive() { m_handle = NULL; @@ -51,7 +53,7 @@ namespace Storm { FillMemory(name, sizeof(name), 0); HANDLE _handle; - if (StormOpenFile(fileName.c_str(), &_handle)) { + if (StormOpenFileEx(NULL, fileName.c_str(), SFILE_OPEN_FROM_MPQ, &_handle)) { HANDLE _archive; if (StormGetFileArchive(_handle, &_archive)) { StormGetArchiveName(_archive, name, sizeof(name)); @@ -68,12 +70,7 @@ namespace Storm { HANDLE _handle = NULL; - if (m_handle) { - StormOpenFileEx(m_handle, name.c_str(), 0, &_handle); - } - else { - StormOpenFile(name.c_str(), &_handle); - } + StormOpenFileEx(m_handle ? m_handle : NULL, name.c_str(), SFILE_OPEN_FROM_MPQ, &_handle); if (_handle) { SIZE_T high; // Idk how i can use it on x32, so maximum size limit is 4gb diff --git a/Src/LuaHooks.cpp b/Src/LuaHooks.cpp index 445f1f7..57269d0 100644 --- a/Src/LuaHooks.cpp +++ b/Src/LuaHooks.cpp @@ -20,6 +20,12 @@ namespace LuaHooks { int searcher_Lua(lua_State* l) { Storm::Archive map; std::string scriptName = luaL_checkstring(l, 1); + + size_t it; + while ((it = scriptName.find('.')) != std::string::npos) { + scriptName.replace(it, 1, "\\"); + } + if (scriptName == "war3map") { map.Connect(*pMapMpq); } diff --git a/Src/pch.h b/Src/pch.h index da0baa3..2f1edaa 100644 --- a/Src/pch.h +++ b/Src/pch.h @@ -23,7 +23,7 @@ #define WAR3_LUA_MAJOR "1" #define WAR3_LUA_MINOR "1" -#define WAR3_LUA_RELEASE "8" +#define WAR3_LUA_RELEASE "9" #define WAR3_LUA_VERSION_NAME ANSI_COLOR_YELLOW "Outland" ANSI_COLOR_RESET #define WAR3_LUA_VERSION WAR3_LUA_MAJOR "." WAR3_LUA_MINOR "." WAR3_LUA_RELEASE