Skip to content

Commit 34f24af

Browse files
author
Martin Nielsen
committed
Patch 1.2.2 - Fixed Paris map detecting as Oasis
Added a logout button Fixed CaptureDesktop() not being run after creating a new user
1 parent 4169ea1 commit 34f24af

9 files changed

Lines changed: 164 additions & 173 deletions

File tree

OverwatchTracker/AuthorizeForm.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace BetterOverwatch
88
{
99
public partial class AuthorizeForm : Form
1010
{
11-
public bool shouldLink = false;
11+
public bool isLinking = false;
1212
public const int WM_NCLBUTTONDOWN = 0xA1;
1313
public const int HT_CAPTION = 0x2;
1414

@@ -26,14 +26,7 @@ protected override void OnPaint(PaintEventArgs e)
2626
}
2727
private void closeButton_Click(object sender, EventArgs e)
2828
{
29-
if (shouldLink)
30-
{
31-
Close();
32-
}
33-
else
34-
{
35-
Application.Exit();
36-
}
29+
Application.Exit();
3730
}
3831
public void MoveForm_MouseDown(object sender, MouseEventArgs e)
3932
{
@@ -47,13 +40,12 @@ private void borderPanel_Paint(object sender, PaintEventArgs e)
4740
{
4841
ControlPaint.DrawBorder(e.Graphics, this.borderPanel.ClientRectangle, Color.FromArgb(255, 57, 96, 130), ButtonBorderStyle.Solid);
4942
}
50-
5143
private async void authorizeButton_Click(object sender, EventArgs e)
5244
{
5345
Hide();
5446
Program.authorizeForm.authorizeButton.Enabled = false;
55-
Process.Start("https://eu.battle.net/oauth/authorize?response_type=code&client_id=20d78829a4e641e694d8ec7f1198dc8b&redirect_uri=http://betteroverwatch.com/api/authorize/" + (shouldLink ? "&state=" + Vars.settings.privateToken : ""));
56-
this.Focus();
47+
Process.Start("https://eu.battle.net/oauth/authorize?response_type=code&client_id=20d78829a4e641e694d8ec7f1198dc8b&redirect_uri=http://betteroverwatch.com/api/authorize/" + (isLinking ? "&state=" + Vars.settings.privateToken : ""));
48+
Focus();
5749
await Server.StartLocalAuthServer();
5850
}
5951
}

OverwatchTracker/Functions.cs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)