@@ -106,7 +106,7 @@ public static void AdjustContrast(Bitmap image, float value, bool invertColors =
106106 iR = 255 ;
107107 }
108108 }
109- if ( limeToWhite && iG == 255 && iR == 255 )
109+ if ( limeToWhite && iG == 255 && iR == 255 )
110110 {
111111 iB = 255 ;
112112 }
@@ -197,51 +197,43 @@ public static void InvertColors(Bitmap image)
197197
198198 image . UnlockBits ( data ) ;
199199 }
200- public static double CompareStrings ( string s , string t )
200+ public static double CompareStrings ( string string1 , string string2 )
201201 {
202- s = s . ToLower ( ) ;
203- t = t . ToLower ( ) ;
204- int n = s . Length ;
205- int m = t . Length ;
206- int [ , ] d = new int [ n + 1 , m + 1 ] ;
207-
208- if ( n == 0 ) return m ;
209- if ( m == 0 ) return n ;
210- for ( int i = 0 ; i <= n ; d [ i , 0 ] = i ++ ) { }
211- for ( int j = 0 ; j <= m ; d [ 0 , j ] = j ++ ) { }
212-
213- for ( int i = 1 ; i <= n ; i ++ )
202+ string1 = string1 . ToLower ( ) ;
203+ string2 = string2 . ToLower ( ) ;
204+ int [ , ] d = new int [ string1 . Length + 1 , string2 . Length + 1 ] ;
205+
206+ if ( string1 . Length == 0 ) return string2 . Length ;
207+ if ( string2 . Length == 0 ) return string1 . Length ;
208+ for ( int i = 0 ; i <= string1 . Length ; d [ i , 0 ] = i ++ ) { }
209+ for ( int j = 0 ; j <= string2 . Length ; d [ 0 , j ] = j ++ ) { }
210+
211+ for ( int i = 1 ; i <= string1 . Length ; i ++ )
214212 {
215- for ( int j = 1 ; j <= m ; j ++ )
213+ for ( int j = 1 ; j <= string2 . Length ; j ++ )
216214 {
217- int cost = ( t [ j - 1 ] == s [ i - 1 ] ) ? 0 : 1 ;
215+ int cost = ( string2 [ j - 1 ] == string1 [ i - 1 ] ) ? 0 : 1 ;
218216
219217 d [ i , j ] = Math . Min ( Math . Min ( d [ i - 1 , j ] + 1 , d [ i , j - 1 ] + 1 ) , d [ i - 1 , j - 1 ] + cost ) ;
220218 }
221219 }
222- int big = Math . Max ( s . Length , t . Length ) ;
220+ int big = Math . Max ( string1 . Length , string2 . Length ) ;
223221
224- return Math . Floor ( Convert . ToDouble ( big - d [ n , m ] ) / Convert . ToDouble ( big ) * 100 ) ;
222+ return Math . Floor ( Convert . ToDouble ( big - d [ string1 . Length , string2 . Length ] ) / Convert . ToDouble ( big ) * 100 ) ;
225223 }
226224 public static string CheckMaps ( string input )
227225 {
228226 for ( int i = 0 ; i < Vars . maps . Length ; i ++ )
229227 {
230- string map = Vars . maps [ i ] . Replace ( " " , String . Empty ) . ToLower ( ) ;
228+ string mapName = Vars . maps [ i ] . Replace ( " " , String . Empty ) . ToLower ( ) ;
231229
232- if ( input . ToLower ( ) . Contains ( map ) )
233- {
234- return Vars . maps [ i ] ;
235- }
236- else
237- {
238- double percent = CompareStrings ( input , map ) ;
230+ if ( input . ToLower ( ) . Contains ( mapName ) ) return Vars . maps [ i ] ;
231+ }
232+ for ( int i = 0 ; i < Vars . maps . Length ; i ++ )
233+ {
234+ string mapName = Vars . maps [ i ] . Replace ( " " , String . Empty ) . ToLower ( ) ;
239235
240- if ( percent >= 60 )
241- {
242- return Vars . maps [ i ] ;
243- }
244- }
236+ if ( CompareStrings ( input , mapName ) >= 60 ) return Vars . maps [ i ] ;
245237 }
246238 return String . Empty ;
247239 }
@@ -573,7 +565,7 @@ public static string FetchBattleTag()
573565 Process [ ] processes = Process . GetProcessesByName ( "Battle.net" ) ;
574566 foreach ( Process process in processes )
575567 {
576- if ( Vars . blizzardAppOffset == 0 )
568+ if ( Vars . blizzardAppOffset == 0 )
577569 {
578570 if ( ! Server . FetchBlizzardAppOffset ( process . MainModule . FileVersionInfo . FileVersion ) ) break ;
579571 }
@@ -622,7 +614,7 @@ public static string FetchLetterFromImage(BackPropNetwork network, Bitmap image,
622614 {
623615 return bestNode . ToString ( ) ;
624616 }
625- else if ( networkId == Network . PlayerNames )
617+ else if ( networkId == Network . PlayerNames )
626618 {
627619 return bestNode < 9 ? ( bestNode + 1 ) . ToString ( ) : Convert . ToChar ( 'A' + ( bestNode - 9 ) ) . ToString ( ) ;
628620 }
@@ -653,7 +645,7 @@ public static string FetchTextFromImage(Bitmap image, Network network)
653645 {
654646 text += FetchLetterFromImage ( BetterOverwatchNetworks . heroNamesNN , bitmaps [ i ] , network ) ;
655647 }
656- else if ( network == Network . PlayerNames )
648+ else if ( network == Network . PlayerNames )
657649 {
658650 text += FetchLetterFromImage ( BetterOverwatchNetworks . playersNN , bitmaps [ i ] , network ) ;
659651 }
0 commit comments