1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+ using System . Windows . Forms ;
8+
9+ namespace BMBF_Corrupted_songs_detector
10+ {
11+ class Program
12+ {
13+ [ STAThread ]
14+ static void Main ( string [ ] args )
15+ {
16+ Console . WriteLine ( "Please select the BMBF Log." ) ;
17+ OpenFileDialog ofd = new OpenFileDialog ( ) ;
18+ if ( ofd . ShowDialog ( ) == DialogResult . OK )
19+ {
20+ //Get the path of specified file
21+ if ( ! File . Exists ( ofd . FileName ) )
22+ {
23+ Console . WriteLine ( "The file doesn't exist." ) ;
24+ Console . ReadLine ( ) ;
25+ return ;
26+ }
27+
28+ }
29+ Console . WriteLine ( "found " + ofd . FileName ) ;
30+ Console . WriteLine ( "at which line would you want to start?" ) ;
31+ String result = Console . ReadLine ( ) ;
32+ if ( result == "" ) result = "0" ;
33+ int start = Convert . ToInt32 ( result ) ;
34+ int i = 0 ;
35+ StreamReader r = new StreamReader ( ofd . FileName ) ;
36+ String line = "" ;
37+ List < String > found = new List < string > ( ) ;
38+ while ( ( line = r . ReadLine ( ) ) != null )
39+ {
40+ if ( i >= start && line . Length > 28 )
41+ {
42+ if ( line . Substring ( 25 , 3 ) == "ERR" )
43+ {
44+ String err ;
45+ if ( line . Contains ( "custom_level_" ) && line . Contains ( "Cover" ) )
46+ {
47+ err = "Custom level contains unsupported cover format (" + line . Substring ( line . IndexOf ( "custom_level_" ) , 53 ) + ")" ;
48+ if ( ! found . Contains ( err ) )
49+ {
50+ found . Add ( err ) ;
51+ }
52+ }
53+ else if ( line . Contains ( "custom_level_" ) && line . Contains ( "failed to load" ) )
54+ {
55+ err = "Custom level (" + line . Substring ( line . IndexOf ( "custom_level_" ) , 53 ) + ") couldn't load at line " + i ;
56+ if ( ! found . Contains ( err ) )
57+ {
58+ found . Add ( err ) ;
59+ }
60+ }
61+ else if ( line . Contains ( "Exception writing assets file sharedassets0.assets Object reference not set to an instance of an object" ) )
62+ {
63+ err = "QuestomAssets Problem at line " + i ;
64+ if ( ! found . Contains ( err ) )
65+ {
66+ found . Add ( err ) ;
67+ }
68+ }
69+ }
70+ else if ( line . Substring ( 25 , 3 ) == "MSG" )
71+ {
72+ String msg ;
73+ if ( line . Contains ( "custom songs to inject" ) )
74+ {
75+ StringReader s = new StringReader ( line . Substring ( line . IndexOf ( "Found" ) ) ) ;
76+ s . ReadWord ( ) ;
77+ msg = s . ReadWord ( ) + " Songs at line " + i ;
78+ found . Add ( msg ) ;
79+ }
80+ else if ( line . Contains ( "starting up" ) && line . Contains ( "BMBF Service" ) )
81+ {
82+ StringReader s = new StringReader ( line . Substring ( line . IndexOf ( "BMBF Service" ) ) ) ;
83+ s . ReadWord ( ) ;
84+ s . ReadWord ( ) ;
85+ StringReader time = new StringReader ( line ) ;
86+ msg = "\n BMBF Service " + s . ReadWord ( ) + " started at " + time . ReadWord ( ) + " " + time . ReadWord ( ) + " (line " + i + ")" ;
87+ found . Add ( msg ) ;
88+ }
89+ }
90+ }
91+ i ++ ;
92+ }
93+ Console . WriteLine ( "\n common fixes:" ) ;
94+ Console . WriteLine ( "- Questom asset problem: tell the person to delete the songs with a unsupported cover format. If that doesn't help tell them to delete songs that failed to load." ) ;
95+ Console . WriteLine ( "\n ---Log Start---" ) ;
96+ foreach ( String c in found )
97+ {
98+ Console . WriteLine ( c ) ;
99+ }
100+ Console . WriteLine ( "\n \n ---Log End---" ) ;
101+ Console . ReadLine ( ) ;
102+ }
103+ }
104+ }
105+ public static class StringReaderExtensions
106+ {
107+ public static string ReadWord ( this StringReader reader )
108+ {
109+ string result = "" ;
110+
111+ // Read characters until we find a space
112+ while ( true )
113+ {
114+ char nextChar = ( char ) reader . Read ( ) ;
115+ if ( nextChar == ' ' ) { break ; }
116+
117+ result += nextChar ;
118+ }
119+
120+ return result ; // Return the characters without the space
121+ }
122+ }
0 commit comments