@@ -72,6 +72,25 @@ bool IsValidLuaFile(const std::wstring &path, std::string &firstLine)
72
72
return true ;
73
73
}
74
74
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
+
75
94
bool InsertLaunchLua (std::vector<std::wstring> &commandLine, std::string &firstLine)
76
95
{
77
96
// 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
91
110
92
111
// Search for the Launch.lua file in various locations it may exist
93
112
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
95
114
{
96
115
wchar_t wszModuleFilename[MAX_PATH]{};
97
116
if (GetModuleFileName (nullptr , wszModuleFilename, MAX_PATH) > 0 )
@@ -100,10 +119,8 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
100
119
if (wszLastSlash != nullptr )
101
120
{
102
121
std::wstring basePath (wszModuleFilename, wszLastSlash + 1 );
103
- basePath += L" Launch.lua" ;
104
- if (IsValidLuaFile (basePath, firstLine))
122
+ if (FindLaunchLua (basePath, commandLine, firstLine))
105
123
{
106
- commandLine.insert (commandLine.begin () + 1 , basePath);
107
124
return true ;
108
125
}
109
126
}
@@ -121,10 +138,8 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
121
138
{
122
139
// Strip the quotes around the value
123
140
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))
126
142
{
127
- commandLine.insert (commandLine.begin () + 1 , basePath);
128
143
return true ;
129
144
}
130
145
}
@@ -136,10 +151,9 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
136
151
if (SHGetSpecialFolderPath (nullptr , wszAppDataPath, CSIDL_APPDATA, false ))
137
152
{
138
153
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))
141
156
{
142
- commandLine.insert (commandLine.begin () + 1 , basePath);
143
157
return true ;
144
158
}
145
159
}
@@ -151,10 +165,9 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
151
165
if (SHGetSpecialFolderPath (nullptr , wszAppDataPath, CSIDL_COMMON_APPDATA, false ))
152
166
{
153
167
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))
156
170
{
157
- commandLine.insert (commandLine.begin () + 1 , basePath);
158
171
return true ;
159
172
}
160
173
}
0 commit comments