Skip to content

Commit 31d2897

Browse files
author
Martin Nielsen
committed
Patch 1.3.1 - Fixed stats reading incorrectly when having UNICODE letters in the player's name
1 parent 327bab5 commit 31d2897

7 files changed

Lines changed: 32 additions & 35 deletions

File tree

BetterOverwatch/Functions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
using System.Drawing;
55
using System.Drawing.Drawing2D;
66
using System.Drawing.Imaging;
7-
using System.Globalization;
87
using System.IO;
98
using System.Runtime.InteropServices;
109
using System.Text;
1110
using AForge.Imaging;
1211
using AForge.Imaging.Filters;
13-
using BetterOverwatch.Networking;
1412
using Image = System.Drawing.Image;
1513

1614
namespace BetterOverwatch
@@ -582,7 +580,6 @@ public static string FetchTextFromImage(Bitmap image, Network network)
582580
{
583581
text += FetchLetterFromImage(BetterOverwatchNetworks.playersNN, bitmaps[i], network);
584582
}
585-
//bitmaps[i].Save(@"C:\testData\" + Guid.NewGuid() + ".png");
586583
bitmaps[i].Dispose();
587584
}
588585
}

BetterOverwatch/GameMethods.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public static void ReadPlayMenu(Bitmap frame)
4040
Vars.gameData.state == State.Finished ||
4141
Vars.gameData.state == State.WaitForUpload)
4242
{
43-
if (!IsValidGame()) return;
4443
Server.CheckGameUpload();
4544
Vars.gameData = new GameData(Vars.gameData.currentRating);
4645
}
@@ -69,20 +68,20 @@ public static void ReadStats(Bitmap frame)
6968
{
7069
if (Vars.statsTimer.Elapsed.TotalSeconds < 20) return;
7170

72-
string eliminationsText = Functions.BitmapToText(frame, 129, 894, 40, 21, false, 110, Network.Numbers);
71+
string eliminationsText = Functions.BitmapToText(frame, 129, 895, 40, 23, false, 110, Network.Numbers);
7372
if (eliminationsText.Equals(string.Empty)) return;
74-
string damageText = Functions.BitmapToText(frame, 129, 958, 80, 21, false, 110, Network.Numbers);
73+
string damageText = Functions.BitmapToText(frame, 129, 959, 80, 23, false, 110, Network.Numbers);
7574
if (damageText.Equals(string.Empty)) return;
76-
string objKillsText = Functions.BitmapToText(frame, 379, 898, 40, 21, false, 110, Network.Numbers);
77-
if (objKillsText.Equals(string.Empty)) return;
78-
string healingText = Functions.BitmapToText(frame, 379, 958, 80, 21, false, 110, Network.Numbers);
75+
string objectiveKillsText = Functions.BitmapToText(frame, 379, 895, 40, 23, false, 110, Network.Numbers);
76+
if (objectiveKillsText.Equals(string.Empty)) return;
77+
string healingText = Functions.BitmapToText(frame, 379, 959, 80, 23, false, 110, Network.Numbers);
7978
if (healingText.Equals(string.Empty)) return;
80-
string deathsText = Functions.BitmapToText(frame, 629, 958, 40, 21, false, 110, Network.Numbers);
79+
string deathsText = Functions.BitmapToText(frame, 629, 959, 40, 23, false, 110, Network.Numbers);
8180
if (deathsText.Equals(string.Empty)) return;
8281

8382
if (int.TryParse(eliminationsText, out int eliminations) &&
8483
int.TryParse(damageText, out int damage) &&
85-
int.TryParse(objKillsText, out int objectiveKills) &&
84+
int.TryParse(objectiveKillsText, out int objectiveKills) &&
8685
int.TryParse(healingText, out int healing) &&
8786
int.TryParse(deathsText, out int deaths))
8887
{
@@ -98,6 +97,7 @@ public static void ReadStats(Bitmap frame)
9897
break;
9998
}
10099
}
100+
//frame.Save(@"C:\testData\" + eliminations + "_" + Guid.NewGuid() + ".png"); // test
101101
Vars.gameData.stats.Add(new Stat((int)Vars.gameData.gameTimer.Elapsed.TotalSeconds, eliminations, damage, objectiveKills, healing, deaths, heroStats));
102102
Vars.statsTimer.Restart();
103103
}
@@ -186,7 +186,6 @@ public static void ReadMainMenu(Bitmap frame)
186186
{
187187
if (menuText.Equals("PLAY"))
188188
{
189-
if (!IsValidGame()) return;
190189
Functions.DebugMessage("Recognized main menu");
191190
Vars.loopDelay = 250;
192191
Vars.gameData.state = State.Finished;
@@ -269,7 +268,6 @@ public static void ReadFinalScore(Bitmap frame)
269268
{
270269
if (Functions.CompareStrings(finalScoreText, "FIHNLSCORE") >= 40)
271270
{
272-
if (!IsValidGame()) return;
273271
Functions.DebugMessage("Recognized final score");
274272
Vars.gameData.state = State.Finished;
275273
Vars.gameData.timer.Stop();
@@ -339,7 +337,7 @@ public static void ReadPlayerNamesAndRank(Bitmap frame)
339337
playerRankX += 422;
340338
}
341339
}
342-
private static bool IsValidGame()
340+
public static bool IsValidGame()
343341
{
344342
if (Vars.gameData.timer.Elapsed.TotalSeconds < 300)
345343
{

BetterOverwatch/Networking/Server.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public static void VerifyToken()
6262
}
6363
}
6464
}
65-
catch { }
65+
catch {
66+
Program.authorizeForm = new AuthorizeForm();
67+
Program.authorizeForm.Show();
68+
}
6669
}
6770
public static bool FetchBlizzardAppOffset(string version)
6871
{
@@ -124,6 +127,7 @@ public static void CheckGameUpload()
124127
{
125128
string game = Vars.gameData.ToString();
126129
Vars.lastGameJSON = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<CompetitiveGame>(game), Formatting.Indented);
130+
if (!GameMethods.IsValidGame()) return;
127131
UploadGame(game);
128132
}
129133
public static void UploadGame(string gameData)

BetterOverwatch/Program.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class Program
2828
private static void Main()
2929
{
3030
Vars.initalize = new Initalize(
31-
"1.3.0",
31+
"1.3.1",
3232
"betteroverwatch.com",
3333
"https://api.github.com/repos/MartinNielsenDev/OverwatchTracker/releases/latest");
3434
Application.EnableVisualStyles();
@@ -149,7 +149,14 @@ public static void CaptureDesktop()
149149
{
150150
if (Functions.IsProcessOpen("Overwatch"))
151151
{
152-
trayMenu.ChangeTray("Visit play menu to update your skill rating", Resources.Icon_Wait);
152+
if (Vars.gameData.currentRating > 0)
153+
{
154+
trayMenu.ChangeTray("Ready to record, enter a competitive game to begin", Resources.Icon_Active);
155+
}
156+
else
157+
{
158+
trayMenu.ChangeTray("Visit play menu to update your skill rating", Resources.Icon_Wait);
159+
}
153160
Vars.overwatchRunning = true;
154161
}
155162
else
@@ -247,28 +254,20 @@ public static void CaptureDesktop()
247254
}
248255
if (Vars.gameData.state == State.Recording)
249256
{
250-
if (Vars.gameData.tabPressed && Vars.gameData.tabTimer.ElapsedMilliseconds > 250/*Functions.GetAsyncKeyState(0x09) < 0*/)
257+
if (Vars.gameData.tabPressed && Vars.gameData.tabTimer.ElapsedMilliseconds > 250)
251258
{
252-
//if (Vars.getInfoTimeout.ElapsedMilliseconds >= 250)
253-
//{
254-
if (GameMethods.ReadHeroPlayed(frame.DesktopImage))
255-
{
256-
GameMethods.ReadStats(frame.DesktopImage);
257-
}
258-
//Vars.getInfoTimeout.Restart();
259-
//}
260-
//else
261-
//{
262-
// Vars.getInfoTimeout.Restart();
263-
//}
259+
if (GameMethods.ReadHeroPlayed(frame.DesktopImage))
260+
{
261+
GameMethods.ReadStats(frame.DesktopImage);
262+
}
264263
}
265264
GameMethods.ReadRoundCompleted(frame.DesktopImage);
266265
GameMethods.ReadMainMenu(frame.DesktopImage);
267266
GameMethods.ReadFinalScore(frame.DesktopImage);
268267
}
269268
if (Vars.gameData.state == State.RoundComplete)
270269
{
271-
if (Vars.gameData.tabPressed && Vars.gameData.tabTimer.ElapsedMilliseconds > 250/*Functions.GetAsyncKeyState(0x09) < 0*/)
270+
if (Vars.gameData.tabPressed && Vars.gameData.tabTimer.ElapsedMilliseconds > 250)
272271
{
273272
GameMethods.ReadHeroPlayed(frame.DesktopImage);
274273
}

BetterOverwatch/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.3.0.0")]
35-
[assembly: AssemblyFileVersion("1.3.0.0")]
34+
[assembly: AssemblyVersion("1.3.1.0")]
35+
[assembly: AssemblyFileVersion("1.3.1.0")]

BetterOverwatch/TrayMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public TrayMenu()
2020
try
2121
{
2222
MenuItem debugTools = new MenuItem("Tools");
23-
debugTools.MenuItems.Add("Start test", StartTest);
23+
//debugTools.MenuItems.Add("Start test", StartTest);
2424
debugTools.MenuItems.Add("Open logs", OpenLogs);
2525
debugTools.MenuItems.Add("Export Last Game", FetchJson);
2626

BetterOverwatch/Vars.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ internal enum State
3636
Finished = 5,
3737
WaitForUpload = 6
3838
}
39-
4039
internal enum Network
4140
{
4241
Maps = 0,

0 commit comments

Comments
 (0)