@@ -76,68 +76,97 @@ private void btnLaunch_Click(object sender, EventArgs e)
7676 Process . Start ( "RicochetInfinity.exe" ) ;
7777 if ( cbClose . Checked ) Close ( ) ;
7878 }
79- catch ( Exception ex )
79+ catch
8080 {
8181 MessageBox . Show ( "RI executable not found!" ) ;
8282 }
8383 }
8484
8585 private void btnReviver_Click ( object sender , EventArgs e )
8686 {
87- if ( System . Environment . OSVersion . Version . Major >= 10 ) // swap this so the order is try-filestream-if os
87+ try
8888 {
89- try
89+ string [ ] lines = File . ReadAllLines ( "data2.dat" ) ;
90+
91+ if ( System . Environment . OSVersion . Version . Major >= 10 )
9092 {
91- //File.Copy(".\\libcurl.dll", ".\\libcurl.dll.bak", true);
92- //File.Delete(".\\libcurl.dll");
93- FileStream data2 = new FileStream ( "data2.dat" , FileMode . Open , FileAccess . ReadWrite ) ;
93+ File . Copy ( ".\\ libcurl.dll" , ".\\ libcurl.dll.bak" , true ) ;
94+ File . Delete ( ".\\ libcurl.dll" ) ;
9495
9596 try
9697 {
9798 progressBar1 . Visible = true ;
98- /* using (var client = new WebClient())
99+
100+ using ( var client = new WebClient ( ) )
99101 {
100102 client . DownloadProgressChanged += wc_DownloadProgressChanged ;
101103 client . DownloadFileAsync ( new System . Uri ( "https://www.ricochetuniverse.com/misc/libcurl.dll" ) , "libcurl.dll" ) ;
102- } */
103-
104- StreamReader reader = new StreamReader ( data2 ) ;
105- StreamWriter writer = new StreamWriter ( data2 ) ;
104+ }
106105
107- while ( ! reader . EndOfStream )
106+ for ( int i = 0 ; i < lines . Length ; i ++ )
108107 {
109- string line = reader . ReadLine ( ) ;
110- if ( line . Length >= 11 )
111- {
112- if ( line . Substring ( 0 , 11 ) == "Catalog URL" )
113- {
114- writer . Write ( "Catalog URL=https://www.ricochetuniverse.com/gateway/catalog.php" ) ; // doesn't seem to work
115- }
116- }
108+ if ( lines [ i ] . Length >= 11 )
109+ if ( lines [ i ] . Substring ( 0 , 11 ) == "Catalog URL" )
110+ lines [ i ] = "Catalog URL=https://www.ricochetuniverse.com/gateway/catalog.php" ;
117111 }
112+
113+ File . WriteAllLines ( "data2.dat" , lines ) ;
114+ progressBar1 . Visible = false ;
118115 }
119- catch ( Exception ex )
116+ catch
120117 {
121- MessageBox . Show ( $ "{ ex } ") ;
122118 MessageBox . Show ( "Unable to download new version of libcurl.dll! Data2 will be patched to connect to the http version of Ricochet Universe instead of https." ) ;
123119 File . Move ( ".\\ libcurl.dll.bak" , ".\\ libcurl.dll" ) ;
120+
121+ for ( int i = 0 ; i < lines . Length ; i ++ )
122+ {
123+ if ( lines [ i ] . Length >= 11 )
124+ if ( lines [ i ] . Substring ( 0 , 11 ) == "Catalog URL" )
125+ lines [ i ] = "Catalog URL=http://www.ricochetuniverse.com/gateway/catalog.php" ;
126+ }
127+
128+ File . WriteAllLines ( "data2.dat" , lines ) ;
129+
130+ progressBar1 . Visible = false ;
124131 }
125132 }
126- catch ( Exception ex )
133+ else
127134 {
128- MessageBox . Show ( $ "{ ex } ") ;
129- throw ;
135+ for ( int i = 0 ; i < lines . Length ; i ++ )
136+ {
137+ if ( lines [ i ] . Length >= 11 )
138+ if ( lines [ i ] . Substring ( 0 , 11 ) == "Catalog URL" )
139+ lines [ i ] = "Catalog URL=http://www.ricochetuniverse.com/gateway/catalog.php" ;
140+ }
141+
142+ File . WriteAllLines ( "data2.dat" , lines ) ;
130143 }
144+
145+ MessageBox . Show ( "Patching done!" ) ;
131146 }
132- else
147+ catch ( Exception ex )
133148 {
134-
149+ MessageBox . Show ( $ " { ex } " ) ;
135150 }
136151 }
137152
138153 void wc_DownloadProgressChanged ( object sender , DownloadProgressChangedEventArgs e )
139154 {
140155 progressBar1 . Value = e . ProgressPercentage ;
141156 }
157+
158+ private void Form1_DragEnter ( object sender , DragEventArgs e )
159+ {
160+ if ( e . Data . GetDataPresent ( DataFormats . FileDrop ) ) e . Effect = DragDropEffects . Copy ;
161+ }
162+
163+ private void Form1_DragDrop ( object sender , DragEventArgs e )
164+ {
165+ string [ ] files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
166+ /* foreach (string file in files)
167+ {
168+ File.Copy(file, $".\\{file}", true);
169+ } */
170+ }
142171 }
143172}
0 commit comments