Skip to content

Commit ed279e6

Browse files
committed
Adding "src\Launch.lua" as a location to search for launch.lua within every directory search.
1 parent 5e7af3b commit ed279e6

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

Launcher.cpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ bool IsValidLuaFile(const std::wstring &path, std::string &firstLine)
7272
return true;
7373
}
7474

75+
bool FindLaunchLua(std::wstring basePath, std::vector<std::wstring> &commandLine, std::string &firstLine)
76+
{
77+
std::wstring launchPath = basePath + L"Launch.lua";
78+
if (IsValidLuaFile(launchPath, firstLine))
79+
{
80+
commandLine.insert(commandLine.begin() + 1, launchPath);
81+
return true;
82+
}
83+
84+
launchPath = basePath + L"src\\Launch.lua";
85+
if (IsValidLuaFile(launchPath, firstLine))
86+
{
87+
commandLine.insert(commandLine.begin() + 1, launchPath);
88+
return true;
89+
}
90+
91+
return false;
92+
}
93+
7594
bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstLine)
7695
{
7796
// Determine if the first command-line parameter is the location of a valid launcher lua file
@@ -91,7 +110,7 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
91110

92111
// Search for the Launch.lua file in various locations it may exist
93112

94-
// Look in the same directory as the executable
113+
// Look in the same directory as the executable as well as the "src" folder within that
95114
{
96115
wchar_t wszModuleFilename[MAX_PATH]{};
97116
if (GetModuleFileName(nullptr, wszModuleFilename, MAX_PATH) > 0)
@@ -100,10 +119,8 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
100119
if (wszLastSlash != nullptr)
101120
{
102121
std::wstring basePath(wszModuleFilename, wszLastSlash + 1);
103-
basePath += L"Launch.lua";
104-
if (IsValidLuaFile(basePath, firstLine))
122+
if (FindLaunchLua(basePath, commandLine, firstLine))
105123
{
106-
commandLine.insert(commandLine.begin() + 1, basePath);
107124
return true;
108125
}
109126
}
@@ -121,10 +138,8 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
121138
{
122139
// Strip the quotes around the value
123140
std::wstring basePath = wszValue[0] == L'\"' ? std::wstring(wszValue + 1, wszValue + dwSize / sizeof(wchar_t) - 2) : std::wstring(wszValue, wszValue + dwSize / sizeof(wchar_t) - 1);
124-
basePath += L"\\Launch.lua";
125-
if (IsValidLuaFile(basePath, firstLine))
141+
if (FindLaunchLua(basePath, commandLine, firstLine))
126142
{
127-
commandLine.insert(commandLine.begin() + 1, basePath);
128143
return true;
129144
}
130145
}
@@ -136,10 +151,9 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
136151
if (SHGetSpecialFolderPath(nullptr, wszAppDataPath, CSIDL_APPDATA, false))
137152
{
138153
std::wstring basePath(wszAppDataPath);
139-
basePath += L"\\Path of Building Community\\Launch.lua";
140-
if (IsValidLuaFile(basePath, firstLine))
154+
basePath += L"\\Path of Building Community\\";
155+
if (FindLaunchLua(basePath, commandLine, firstLine))
141156
{
142-
commandLine.insert(commandLine.begin() + 1, basePath);
143157
return true;
144158
}
145159
}
@@ -151,10 +165,9 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
151165
if (SHGetSpecialFolderPath(nullptr, wszAppDataPath, CSIDL_COMMON_APPDATA, false))
152166
{
153167
std::wstring basePath(wszAppDataPath);
154-
basePath += L"\\Path of Building\\Launch.lua";
155-
if (IsValidLuaFile(basePath, firstLine))
168+
basePath += L"\\Path of Building\\";
169+
if (FindLaunchLua(basePath, commandLine, firstLine))
156170
{
157-
commandLine.insert(commandLine.begin() + 1, basePath);
158171
return true;
159172
}
160173
}

0 commit comments

Comments
 (0)