@@ -76,68 +76,97 @@ private void btnLaunch_Click(object sender, EventArgs e)
76
76
Process . Start ( "RicochetInfinity.exe" ) ;
77
77
if ( cbClose . Checked ) Close ( ) ;
78
78
}
79
- catch ( Exception ex )
79
+ catch
80
80
{
81
81
MessageBox . Show ( "RI executable not found!" ) ;
82
82
}
83
83
}
84
84
85
85
private void btnReviver_Click ( object sender , EventArgs e )
86
86
{
87
- if ( System . Environment . OSVersion . Version . Major >= 10 ) // swap this so the order is try-filestream-if os
87
+ try
88
88
{
89
- try
89
+ string [ ] lines = File . ReadAllLines ( "data2.dat" ) ;
90
+
91
+ if ( System . Environment . OSVersion . Version . Major >= 10 )
90
92
{
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" ) ;
94
95
95
96
try
96
97
{
97
98
progressBar1 . Visible = true ;
98
- /* using (var client = new WebClient())
99
+
100
+ using ( var client = new WebClient ( ) )
99
101
{
100
102
client . DownloadProgressChanged += wc_DownloadProgressChanged ;
101
103
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
+ }
106
105
107
- while ( ! reader . EndOfStream )
106
+ for ( int i = 0 ; i < lines . Length ; i ++ )
108
107
{
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" ;
117
111
}
112
+
113
+ File . WriteAllLines ( "data2.dat" , lines ) ;
114
+ progressBar1 . Visible = false ;
118
115
}
119
- catch ( Exception ex )
116
+ catch
120
117
{
121
- MessageBox . Show ( $ "{ ex } ") ;
122
118
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." ) ;
123
119
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 ;
124
131
}
125
132
}
126
- catch ( Exception ex )
133
+ else
127
134
{
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 ) ;
130
143
}
144
+
145
+ MessageBox . Show ( "Patching done!" ) ;
131
146
}
132
- else
147
+ catch ( Exception ex )
133
148
{
134
-
149
+ MessageBox . Show ( $ " { ex } " ) ;
135
150
}
136
151
}
137
152
138
153
void wc_DownloadProgressChanged ( object sender , DownloadProgressChangedEventArgs e )
139
154
{
140
155
progressBar1 . Value = e . ProgressPercentage ;
141
156
}
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
+ }
142
171
}
143
172
}
0 commit comments