Skip to content

Commit

Permalink
StormOpenFile has been replaced with StormOpenFileEx to fix a bug wit…
Browse files Browse the repository at this point in the history
…h 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.
  • Loading branch information
Ev3nt committed Jul 21, 2022
1 parent 502be34 commit 0009149
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# War3 Lua - 1.1.8 (<span style="color:orange">Outland</span>)
# War3 Lua - 1.1.9 (<span style="color:orange">Outland</span>)

[![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)
Expand Down
11 changes: 4 additions & 7 deletions Src/EasyStormLib/EasyStormLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "EasyStormLib.h"
#include "StormLib.h"

#define SFILE_OPEN_FROM_MPQ 0

namespace Storm {
Archive::Archive() {
m_handle = NULL;
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Src/LuaHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0009149

Please sign in to comment.