@@ -113,10 +113,12 @@ private static void ParseLogFile()
113113
114114 if ( baseDirectory . Contains ( "steamapps" ) )
115115 {
116+ SteamFolder . SetValue ( baseDirectory ) ;
116117 CurrentPlatform . SetValue ( PlatformTypes . TYPE_STEAM . ToString ( ) ) ;
117118 }
118119 else if ( baseDirectory . Contains ( "Epic Games" ) )
119120 {
121+ EpicFolder . SetValue ( baseDirectory ) ;
120122 CurrentPlatform . SetValue ( PlatformTypes . TYPE_EPIC . ToString ( ) ) ;
121123 }
122124 else
@@ -171,6 +173,7 @@ private static void ParseVersionFile()
171173 private static bool ParseRegistryKeys ( )
172174 {
173175 bool foundAtLeastOnePath = false ;
176+ bool foundInstallDir = false ;
174177 RegistryKey coderedKey = Registry . CurrentUser . OpenSubKey ( "CodeRedModding" ) ;
175178
176179 if ( coderedKey != null )
@@ -185,77 +188,111 @@ private static bool ParseRegistryKeys()
185188 {
186189 ModuleFolder . SetValue ( moduleFolder ) ;
187190 LibraryFile . SetValue ( moduleFolder / "DLL" / "CodeRed.dll" ) ;
191+ foundInstallDir = true ;
188192 }
189193 }
190194
191195 coderedKey . Close ( ) ;
192196 }
193197
194- RegistryKey epicKey = Registry . LocalMachine . OpenSubKey ( "SOFTWARE\\ WOW6432Node\\ EpicGames\\ Unreal Engine" ) ;
195-
196- if ( epicKey != null )
198+ if ( SteamFolder . IsNull ( ) )
197199 {
198- Object epicObj = epicKey . GetValue ( "INSTALLDIR" ) ;
199-
200- if ( epicObj != null )
200+ try
201201 {
202- Architecture . Path epicFolder = ( new Architecture . Path ( epicObj . ToString ( ) ) / "rocketleague" / "Binaries" / "Win64 ") ;
202+ RegistryKey steamKey = Registry . LocalMachine . OpenSubKey ( "SOFTWARE \\ WOW6432Node \\ Valve \\ Steam ") ;
203203
204- if ( epicFolder . Exists ( ) )
205- {
206- EpicFolder . SetValue ( epicFolder ) ;
207- foundAtLeastOnePath = true ;
208- }
209- else
204+ if ( steamKey != null )
210205 {
211- EpicFolder . SetValue ( "" ) ;
206+ Object steamObj = steamKey . GetValue ( "InstallPath" ) ;
207+
208+ if ( steamObj != null )
209+ {
210+ // We are phrasing the "libraryfolders.vdf" file here because it's possibe to have Steam installed on one drive, but have the "steamapps" folder on a different drive/location.
211+ // This is not stored in the registry and this file is the only place that I could find where it has path/drive info like this.
212+ // If anyone has a better solution or suggestion please do create an issue in the repo, or submit your own pull request.
213+
214+ Architecture . Path libraryFile = new Architecture . Path ( steamObj . ToString ( ) ) . Append ( "steamapps" ) . Append ( "libraryfolders.vdf" ) ;
215+
216+ if ( libraryFile . Exists ( ) )
217+ {
218+ string libraryContents = File . ReadAllText ( libraryFile . GetPath ( ) ) ;
219+ MatchCollection pathMatches = Regex . Matches ( libraryContents , "\" path\" \t \t \" (.*)\" " , RegexOptions . IgnoreCase | RegexOptions . RightToLeft ) ;
220+
221+ foreach ( Match match in pathMatches )
222+ {
223+ if ( match . Success && match . Groups [ 1 ] . Success )
224+ {
225+ Architecture . Path steamFolder = ( new Architecture . Path ( match . Groups [ 1 ] . Value ) / "steamapps" / "common" / "rocketleague" / "Binaries" / "Win64" ) ;
226+
227+ if ( steamFolder . Exists ( ) )
228+ {
229+ SteamFolder . SetValue ( steamFolder ) ;
230+ foundAtLeastOnePath = true ;
231+ break ;
232+ }
233+ else
234+ {
235+ SteamFolder . SetValue ( "" ) ;
236+ continue ;
237+ }
238+ }
239+ }
240+ }
241+ }
212242 }
213243 }
214- }
215-
216- RegistryKey steamKey = Registry . LocalMachine . OpenSubKey ( "SOFTWARE\\ WOW6432Node\\ Valve\\ Steam" ) ;
244+ catch ( Exception ex )
245+ {
217246
218- if ( steamKey != null )
247+ }
248+ }
249+ else
219250 {
220- Object steamObj = steamKey . GetValue ( "InstallPath" ) ;
251+ foundAtLeastOnePath = true ;
252+ }
221253
222- if ( steamObj != null )
254+ if ( EpicFolder . IsNull ( ) )
255+ {
256+ try
223257 {
224- // We are phrasing the "libraryfolders.vdf" file here because it's possibe to have Steam installed on one drive, but have the "steamapps" folder on a different drive/location.
225- // This is not stored in the registry and this file is the only place that I could find where it has path/drive info like this.
226- // If anyone has a better solution or suggestion please do create an issue in the repo, or submit your own pull request.
227-
228- Architecture . Path libraryFile = new Architecture . Path ( steamObj . ToString ( ) ) . Append ( "steamapps" ) . Append ( "libraryfolders.vdf" ) ;
258+ RegistryKey epicKey = Registry . LocalMachine . OpenSubKey ( "SOFTWARE\\ WOW6432Node\\ EpicGames\\ Unreal Engine" ) ;
229259
230- if ( libraryFile . Exists ( ) )
260+ if ( epicKey != null )
231261 {
232- string libraryContents = File . ReadAllText ( libraryFile . GetPath ( ) ) ;
233- MatchCollection pathMatches = Regex . Matches ( libraryContents , "\" path\" \t \t \" (.*)\" " , RegexOptions . IgnoreCase | RegexOptions . RightToLeft ) ;
262+ Object epicObj = epicKey . GetValue ( "INSTALLDIR" ) ;
234263
235- foreach ( Match match in pathMatches )
264+ if ( epicObj != null )
236265 {
237- if ( match . Success && match . Groups [ 1 ] . Success )
238- {
239- Architecture . Path steamFolder = ( new Architecture . Path ( match . Groups [ 1 ] . Value ) / "steamapps" / "common" / "rocketleague" / "Binaries" / "Win64" ) ;
266+ Architecture . Path epicFolder = ( new Architecture . Path ( epicObj . ToString ( ) ) / "rocketleague" / "Binaries" / "Win64" ) ;
240267
241- if ( steamFolder . Exists ( ) )
242- {
243- SteamFolder . SetValue ( steamFolder ) ;
244- foundAtLeastOnePath = true ;
245- break ;
246- }
247- else
248- {
249- SteamFolder . SetValue ( "" ) ;
250- continue ;
251- }
268+ if ( epicFolder . Exists ( ) )
269+ {
270+ EpicFolder . SetValue ( epicFolder ) ;
271+ foundAtLeastOnePath = true ;
272+ }
273+ else
274+ {
275+ EpicFolder . SetValue ( "" ) ;
252276 }
253277 }
254278 }
255279 }
280+ catch ( Exception ex )
281+ {
282+
283+ }
284+ }
285+ else
286+ {
287+ foundAtLeastOnePath = true ;
288+ }
289+
290+ if ( ! foundInstallDir && ! foundAtLeastOnePath )
291+ {
292+ return false ;
256293 }
257294
258- return foundAtLeastOnePath ;
295+ return foundInstallDir ;
259296 }
260297
261298 public static bool FindDirectories ( )
@@ -270,13 +307,20 @@ public static bool FindDirectories()
270307 ParseLogFile ( ) ;
271308 ParseVersionFile ( ) ;
272309
273- if ( ParseRegistryKeys ( ) )
310+ if ( ! ParseRegistryKeys ( ) )
274311 {
275- Initialized = true ;
312+ if ( ! ModuleFolder . IsNull ( ) )
313+ {
314+ MessageBox . Show ( "Error: Failed to locate the needed registry keys!" , Assembly . GetTitle ( ) , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
315+ }
316+ else
317+ {
318+ Initialized = true ;
319+ }
276320 }
277321 else
278322 {
279- MessageBox . Show ( "Error: Failed to locate the needed registry keys!" , Assembly . GetTitle ( ) , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
323+ Initialized = true ;
280324 }
281325 }
282326 else
0 commit comments