33using System . IO ;
44using System . Reflection ;
55using Mono . Cecil ;
6- using PatchLoader ;
76using SybarisLoader . Util ;
87
98namespace SybarisLoader
@@ -25,7 +24,7 @@ public static void LoadPatchers()
2524
2625 Logger . Log ( LogLevel . Info , "Loading patchers" ) ;
2726
28- foreach ( string dll in Directory . GetFiles ( Utils . PatchesDir , "*.Patcher.dll" ) )
27+ foreach ( string dll in Directory . GetFiles ( Utils . SybarisDir , "*.Patcher.dll" ) )
2928 {
3029 Assembly assembly ;
3130
@@ -46,8 +45,7 @@ public static void LoadPatchers()
4645 if ( type . IsInterface )
4746 continue ;
4847
49- FieldInfo targetAssemblyNamesField =
50- type . GetField ( "TargetAssemblyNames" , BindingFlags . Static | BindingFlags . Public ) ;
48+ FieldInfo targetAssemblyNamesField = type . GetField ( "TargetAssemblyNames" , BindingFlags . Static | BindingFlags . Public ) ;
5149
5250 if ( targetAssemblyNamesField == null || targetAssemblyNamesField . FieldType != typeof ( string [ ] ) )
5351 continue ;
@@ -160,17 +158,23 @@ public static void Patch()
160158 }
161159
162160 /// <summary>
163- /// The entry point of the loader
161+ /// The entry point of the loader
164162 /// </summary>
165163 public static void Main ( )
166164 {
167165 if ( ! Directory . Exists ( Utils . SybarisDir ) )
168166 Directory . CreateDirectory ( Utils . SybarisDir ) ;
169- if ( ! Directory . Exists ( Utils . LogsDir ) )
170- Directory . CreateDirectory ( Utils . LogsDir ) ;
171167
172168 Configuration . Init ( ) ;
173169
170+ if ( ! Configuration . Options [ "debug" ] [ "logging" ] [ "outputDirectory" ] . IsString )
171+ Configuration . Options [ "debug" ] [ "logging" ] [ "enabled" ] = false ;
172+ else if ( ! Directory . Exists ( Configuration . Options [ "debug" ] [ "logging" ] [ "outputDirectory" ] ) )
173+ Directory . CreateDirectory ( Configuration . Options [ "debug" ] [ "logging" ] [ "outputDirectory" ] ) ;
174+
175+ if ( ! Directory . Exists ( Configuration . Options [ "debug" ] [ "outputAssemblies" ] [ "outputDirectory" ] ) )
176+ Directory . CreateDirectory ( Configuration . Options [ "debug" ] [ "outputAssemblies" ] [ "outputDirectory" ] ) ;
177+
174178 if ( Configuration . Options [ "debug" ] [ "logging" ] [ "enabled" ] )
175179 Logger . Enabled = true ;
176180 if ( Configuration . Options [ "debug" ] [ "logging" ] [ "redirectConsole" ] )
@@ -179,17 +183,7 @@ public static void Main()
179183 Logger . Log ( "===Sybaris Loader===" ) ;
180184 Logger . Log ( $ "Started on { DateTime . Now : R} ") ;
181185 Logger . Log ( $ "Game assembly directory: { Utils . GameAssembliesDir } ") ;
182- Logger . Log ( $ "Doorstop directory: { Utils . RootDir } ") ;
183-
184- if ( ! Directory . Exists ( Utils . PatchesDir ) )
185- {
186- Directory . CreateDirectory ( Utils . PatchesDir ) ;
187- Logger . Log ( LogLevel . Info , "No patches directory found! Created an empty one!" ) ;
188- Logger . Dispose ( ) ;
189- return ;
190- }
191-
192- Logger . Log ( LogLevel . Info , "Adding ResolveAssembly Handler" ) ;
186+ Logger . Log ( $ "Sybaris directory: { Utils . SybarisDir } ") ;
193187
194188 // We add a custom assembly resolver
195189 // Since assemblies don't unload, this event handler will be called always there is an assembly to resolve
@@ -214,7 +208,7 @@ public static void Main()
214208 public static Assembly ResolvePatchers ( object sender , ResolveEventArgs args )
215209 {
216210 // Try to resolve from patches directory
217- if ( Utils . TryResolveDllAssembly ( args . Name , Utils . PatchesDir , out Assembly patchAssembly ) )
211+ if ( Utils . TryResolveDllAssembly ( args . Name , Utils . SybarisDir , out Assembly patchAssembly ) )
218212 return patchAssembly ;
219213 return null ;
220214 }
@@ -237,8 +231,7 @@ private static void SavePatchedAssembly(byte[] assembly, string name)
237231 }
238232 catch ( Exception e )
239233 {
240- Logger . Log ( LogLevel . Warning ,
241- $ "Failed to create patched assembly directory to { outDir } !\n Reason: { e . Message } ") ;
234+ Logger . Log ( LogLevel . Warning , $ "Failed to create patched assembly directory to { outDir } !\n Reason: { e . Message } ") ;
242235 return ;
243236 }
244237
0 commit comments