@@ -127,129 +127,6 @@ public static void AddPostPatchCallback(ModuleManagerPostPatchCallback callback)
127127 postPatchCallbacks . Add ( callback ) ;
128128 }
129129
130- private static IEnumerable < string > GenerateModList ( IPatchProgress progress , IBasicLogger logger )
131- {
132- #region List of mods
133-
134- //string envInfo = "ModuleManager env info\n";
135- //envInfo += " " + Environment.OSVersion.Platform + " " + ModuleManager.intPtr.ToInt64().ToString("X16") + "\n";
136- //envInfo += " " + Convert.ToString(ModuleManager.intPtr.ToInt64(), 2) + " " + Convert.ToString(ModuleManager.intPtr.ToInt64() >> 63, 2) + "\n";
137- //string gamePath = Environment.GetCommandLineArgs()[0];
138- //envInfo += " Args: " + gamePath.Split(Path.DirectorySeparatorChar).Last() + " " + string.Join(" ", Environment.GetCommandLineArgs().Skip(1).ToArray()) + "\n";
139- //envInfo += " Executable SHA256 " + FileSHA(gamePath);
140- //
141- //log(envInfo);
142-
143- List < string > mods = new List < string > ( ) ;
144-
145- StringBuilder modListInfo = new StringBuilder ( ) ;
146-
147- modListInfo . Append ( "compiling list of loaded mods...\n Mod DLLs found:\n " ) ;
148-
149- string format = " {0,-40}{1,-25}{2,-25}{3,-25}{4}\n " ;
150-
151- modListInfo . AppendFormat (
152- format ,
153- "Name" ,
154- "Assembly Version" ,
155- "Assembly File Version" ,
156- "KSPAssembly Version" ,
157- "SHA256"
158- ) ;
159-
160- modListInfo . Append ( '\n ' ) ;
161-
162- foreach ( AssemblyLoader . LoadedAssembly mod in AssemblyLoader . loadedAssemblies )
163- {
164-
165- if ( string . IsNullOrEmpty ( mod . assembly . Location ) ) //Diazo Edit for xEvilReeperx AssemblyReloader mod
166- continue ;
167-
168- FileVersionInfo fileVersionInfo = FileVersionInfo . GetVersionInfo ( mod . assembly . Location ) ;
169-
170- AssemblyName assemblyName = mod . assembly . GetName ( ) ;
171-
172- string kspAssemblyVersion ;
173- if ( mod . versionMajor == 0 && mod . versionMinor == 0 )
174- kspAssemblyVersion = "" ;
175- else
176- kspAssemblyVersion = mod . versionMajor + "." + mod . versionMinor ;
177-
178- string fileSha = "" ;
179- try
180- {
181- fileSha = FileUtils . FileSHA ( mod . assembly . Location ) ;
182- }
183- catch ( Exception e )
184- {
185- progress . Exception ( "Exception while generating SHA for assembly " + assemblyName . Name , e ) ;
186- }
187-
188- modListInfo . AppendFormat (
189- format ,
190- assemblyName . Name ,
191- assemblyName . Version ,
192- fileVersionInfo . FileVersion ,
193- kspAssemblyVersion ,
194- fileSha
195- ) ;
196-
197- // modlist += String.Format(" {0,-50} SHA256 {1}\n", modInfo, FileSHA(mod.assembly.Location));
198-
199- if ( ! mods . Contains ( assemblyName . Name , StringComparer . OrdinalIgnoreCase ) )
200- mods . Add ( assemblyName . Name ) ;
201- }
202-
203- modListInfo . Append ( "Non-DLL mods added (:FOR[xxx]):\n " ) ;
204- foreach ( UrlDir . UrlConfig cfgmod in GameDatabase . Instance . root . AllConfigs )
205- {
206- if ( CommandParser . Parse ( cfgmod . type , out string name ) != Command . Insert )
207- {
208- if ( name . Contains ( ":FOR[" ) )
209- {
210- name = name . RemoveWS ( ) ;
211-
212- // check for FOR[] blocks that don't match loaded DLLs and add them to the pass list
213- try
214- {
215- string dependency = name . Substring ( name . IndexOf ( ":FOR[" ) + 5 ) ;
216- dependency = dependency . Substring ( 0 , dependency . IndexOf ( ']' ) ) ;
217- if ( ! mods . Contains ( dependency , StringComparer . OrdinalIgnoreCase ) )
218- {
219- // found one, now add it to the list.
220- mods . Add ( dependency ) ;
221- modListInfo . AppendFormat ( " {0}\n " , dependency ) ;
222- }
223- }
224- catch ( ArgumentOutOfRangeException )
225- {
226- progress . Error ( cfgmod , "Skipping :FOR init for line " + name +
227- ". The line most likely contains a space that should be removed" ) ;
228- }
229- }
230- }
231- }
232- modListInfo . Append ( "Mods by directory (sub directories of GameData):\n " ) ;
233- string gameData = Path . Combine ( Path . GetFullPath ( KSPUtil . ApplicationRootPath ) , "GameData" ) ;
234- foreach ( string subdir in Directory . GetDirectories ( gameData ) )
235- {
236- string name = Path . GetFileName ( subdir ) ;
237- string cleanName = name . RemoveWS ( ) ;
238- if ( ! mods . Contains ( cleanName , StringComparer . OrdinalIgnoreCase ) )
239- {
240- mods . Add ( cleanName ) ;
241- modListInfo . AppendFormat ( " {0}\n " , cleanName ) ;
242- }
243- }
244- logger . Info ( modListInfo . ToString ( ) ) ;
245-
246- mods . Sort ( ) ;
247-
248- #endregion List of mods
249-
250- return mods ;
251- }
252-
253130 private IEnumerator ProcessPatch ( )
254131 {
255132 status = "Checking Cache" ;
@@ -276,7 +153,7 @@ private IEnumerator ProcessPatch()
276153 IPatchProgress progress = new PatchProgress ( logger ) ;
277154 status = "Pre patch init" ;
278155 logger . Info ( status ) ;
279- IEnumerable < string > mods = GenerateModList ( progress , logger ) ;
156+ IEnumerable < string > mods = ModListGenerator . GenerateModList ( progress , logger ) ;
280157
281158 yield return null ;
282159
0 commit comments