Skip to content

Commit 1e72f40

Browse files
author
Martin Nielsen
committed
Patch 1.4.4 - More fixes to role queue support
1 parent 1190815 commit 1e72f40

7 files changed

Lines changed: 99 additions & 61 deletions

File tree

BetterOverwatch/AppData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ internal class AppData
2424
public static Stopwatch
2525
frameTimer = new Stopwatch(),
2626
getInfoTimeout = new Stopwatch(),
27-
statsTimer = new Stopwatch();
27+
statsTimer = new Stopwatch(),
28+
ratingsTimer = new Stopwatch();
2829
}
2930
internal enum State
3031
{

BetterOverwatch/Forms/WinratesForm.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BetterOverwatch/Functions.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public static bool BitmapIsCertainColor(Bitmap image, int red, int green, int bl
191191
int g = row[(x * 4) + 1];
192192
int r = row[(x * 4) + 2];
193193

194-
if (blue - b > 8 || green - g > 8 || red - r > 8)
194+
if (blue - b > 12 || green - g > 12 || red - r > 12)
195195
return false;
196196
}
197197
}
@@ -225,27 +225,32 @@ public static void InvertColors(Bitmap image)
225225
}
226226
public static double CompareStrings(string string1, string string2)
227227
{
228-
string1 = string1.ToLower();
229-
string2 = string2.ToLower();
230-
int[,] d = new int[string1.Length + 1, string2.Length + 1];
228+
try
229+
{
230+
string1 = string1.ToLower();
231+
string2 = string2.ToLower();
232+
int[,] d = new int[string1.Length + 1, string2.Length + 1];
231233

232-
if (string1.Length == 0) return string2.Length;
233-
if (string2.Length == 0) return string1.Length;
234-
for (int i = 0; i <= string1.Length; d[i, 0] = i++) { }
235-
for (int j = 0; j <= string2.Length; d[0, j] = j++) { }
234+
if (string1.Length == 0) return string2.Length;
235+
if (string2.Length == 0) return string1.Length;
236+
for (int i = 0; i <= string1.Length; d[i, 0] = i++) { }
237+
for (int j = 0; j <= string2.Length; d[0, j] = j++) { }
236238

237-
for (int i = 1; i <= string1.Length; i++)
238-
{
239-
for (int j = 1; j <= string2.Length; j++)
239+
for (int i = 1; i <= string1.Length; i++)
240240
{
241-
int cost = (string2[j - 1] == string1[i - 1]) ? 0 : 1;
241+
for (int j = 1; j <= string2.Length; j++)
242+
{
243+
int cost = (string2[j - 1] == string1[i - 1]) ? 0 : 1;
242244

243-
d[i, j] = Math.Min(Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost);
245+
d[i, j] = Math.Min(Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost);
246+
}
244247
}
245-
}
246-
int big = Math.Max(string1.Length, string2.Length);
248+
int big = Math.Max(string1.Length, string2.Length);
247249

248-
return Math.Floor(Convert.ToDouble(big - d[string1.Length, string2.Length]) / Convert.ToDouble(big) * 100);
250+
return Math.Floor(Convert.ToDouble(big - d[string1.Length, string2.Length]) / Convert.ToDouble(big) * 100);
251+
}
252+
catch (Exception e) { Console.WriteLine($"CompareStrings error: {e}"); }
253+
return 0.00;
249254
}
250255
public static string CheckMaps(string input)
251256
{
@@ -295,10 +300,10 @@ public static string BitmapToText(Bitmap frame, int x, int y, int width, int hei
295300
AdjustContrast(result, 255f, invertColors, limeToWhite);
296301
}
297302
output = FetchTextFromImage(result, network);
298-
//result.Save(@"C:\test\" + Guid.NewGuid() + ".png");
303+
299304
result.Dispose();
300305
}
301-
catch { }
306+
catch (Exception e) { Console.WriteLine($"BitmapToText error: {e}"); }
302307
return output;
303308
}
304309
public static int[,] LabelImage(Bitmap image, out int labelCount)
@@ -593,11 +598,8 @@ public static string FetchTextFromImage(Bitmap image, Network network)
593598
{
594599
text += FetchLetterFromImage(BetterOverwatchNetworks.teamSkillRatingNN, bitmaps[i], network);
595600
}
596-
else if(network == Network.Ratings)
601+
else if (network == Network.Ratings)
597602
{
598-
//StringBuilder sb = GetHashFromImage(bitmaps[i]);
599-
//bitmaps[i].Save($@"D:\Repos\Visual Studio 2019\NeuralNetwork.Trainer\NeuralNetwork.Trainer\TrainData\ratings_rolequeue\test_data\{FetchLetterFromImage(BetterOverwatchNetworks.ratingsNN, bitmaps[i], network)}_{sb.ToString()}.png");
600-
601603
text += FetchLetterFromImage(BetterOverwatchNetworks.ratingsNN, bitmaps[i], network);
602604
}
603605
else if (network == Network.Numbers)
@@ -612,7 +614,7 @@ public static string FetchTextFromImage(Bitmap image, Network network)
612614
{
613615
text += FetchLetterFromImage(BetterOverwatchNetworks.playersNN, bitmaps[i], network);
614616
}
615-
//bitmaps[i].Save($@"C:\test\{text}_{Guid.NewGuid()}.png");
617+
616618
bitmaps[i].Dispose();
617619
}
618620
}
@@ -641,7 +643,9 @@ public static void DebugMessage(string msg)
641643
catch { }
642644
Debug.WriteLine(msg);
643645
}
644-
private static StringBuilder GetHashFromImage(Bitmap bitmap) // DEBUG
646+
/*
647+
* UNUSED METHODS
648+
private static StringBuilder GetHashFromImage(Bitmap bitmap) // DEBUG
645649
{
646650
byte[] bytes;
647651
using (MemoryStream ms = new MemoryStream())
@@ -661,9 +665,6 @@ private static StringBuilder GetHashFromImage(Bitmap bitmap) // DEBUG
661665
662666
return sb;
663667
}
664-
/*
665-
* UNUSED METHODS
666-
667668
private static Bitmap Downscale(Image original)
668669
{
669670
double widthPercent = (double)original.Width / 1920 * 1366;

BetterOverwatch/GameMethods.cs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Drawing;
1+
using System;
2+
using System.Drawing;
23
using System.IO;
34
using System.Text.RegularExpressions;
45
using BetterOverwatch.Game;
@@ -85,23 +86,38 @@ public static void ReadRoleRatings(Bitmap frame)
8586
AppData.gameData.currentRatings.tank = tankRating;
8687
if (AppData.settings.outputToTextFiles)
8788
{
88-
File.WriteAllText("tank.txt", tankRating.ToString());
89+
try
90+
{
91+
File.WriteAllText("tank.txt", tankRating.ToString());
92+
Functions.DebugMessage($"Updated tank.txt with '{tankRating}'");
93+
}
94+
catch (Exception e) { Functions.DebugMessage($"Failed to update tank.txt : {e.Message}"); }
8995
}
9096
}
9197
if (damageCheck)
9298
{
9399
AppData.gameData.currentRatings.damage = damageRating;
94100
if (AppData.settings.outputToTextFiles)
95101
{
96-
File.WriteAllText("damage.txt", damageRating.ToString());
102+
try
103+
{
104+
File.WriteAllText("damage.txt", damageRating.ToString());
105+
Functions.DebugMessage($"Updated damage.txt with '{damageRating}'");
106+
}
107+
catch (Exception e) { Functions.DebugMessage($"Failed to update damage.txt : {e.Message}"); }
97108
}
98109
}
99110
if (supportCheck)
100111
{
101112
AppData.gameData.currentRatings.support = supportRating;
102113
if (AppData.settings.outputToTextFiles)
103114
{
104-
File.WriteAllText("support.txt", supportRating.ToString());
115+
try
116+
{
117+
File.WriteAllText("support.txt", supportRating.ToString());
118+
Functions.DebugMessage($"Updated support.txt with '{supportRating}'");
119+
}
120+
catch (Exception e) { Functions.DebugMessage($"Failed to update support.txt : {e.Message}"); }
105121
}
106122
}
107123
AppData.successSound.Play();
@@ -173,6 +189,7 @@ public static void ReadStats(Bitmap frame)
173189
}
174190
AppData.gameData.stats.Add(new Stat((int)AppData.gameData.gameTimer.Elapsed.TotalSeconds, eliminations, damage, objectiveKills, healing, deaths, heroStats));
175191
AppData.statsTimer.Restart();
192+
Functions.DebugMessage($"Hero stats recorded after {AppData.gameData.gameTimer.Elapsed.TotalSeconds} seconds");
176193
}
177194
}
178195
public static void ReadCompetitiveGameEntered(Bitmap frame)
@@ -214,7 +231,7 @@ public static void ReadMap(Bitmap frame)
214231
{
215232
AppData.gameData.map = mapText;
216233
AppData.getInfoTimeout.Restart();
217-
Functions.DebugMessage("Recognized map: '" + mapText + "'");
234+
Functions.DebugMessage($"Recognized map: '{mapText}'");
218235
}
219236
}
220237
}
@@ -233,7 +250,7 @@ public static void ReadTeamsSkillRating(Bitmap frame)
233250
if (int.TryParse(team1Rating, out int rating) && rating > 999 && rating < 5000)
234251
{
235252
AppData.gameData.team1Rating = rating;
236-
Functions.DebugMessage("Recognized team 1 SR: '" + team1Rating + "'");
253+
Functions.DebugMessage($"Recognized team 1 rating: '{team1Rating}'");
237254
}
238255
}
239256
}
@@ -249,7 +266,7 @@ public static void ReadTeamsSkillRating(Bitmap frame)
249266
if (int.TryParse(team2Rating, out int rating) && rating > 999 && rating < 5000)
250267
{
251268
AppData.gameData.team2Rating = rating;
252-
Functions.DebugMessage("Recognized team 2 SR: '" + team2Rating + "'");
269+
Functions.DebugMessage($"Recognized team 2 rating: '{team2Rating}'");
253270
}
254271
}
255272
}
@@ -302,6 +319,7 @@ public static bool ReadHeroPlayed(Bitmap frame)
302319
}
303320
AppData.gameData.heroTimer.Restart();
304321
AppData.gameData.heroesPlayed.Add(new HeroPlayed(Constants.heroList[h].name, (int)AppData.gameData.gameTimer.Elapsed.TotalSeconds));
322+
Functions.DebugMessage($"Now playing hero {Constants.heroList[h].name} at {AppData.gameData.gameTimer.Elapsed.TotalSeconds} seconds");
305323
return true;
306324
}
307325
}
@@ -310,20 +328,20 @@ public static bool ReadHeroPlayed(Bitmap frame)
310328
}
311329
public static void ReadRoundCompleted(Bitmap frame)
312330
{
313-
string roundCompletedText = Functions.BitmapToText(frame, 940, 160, 290, 76);
331+
string roundCompletedText = Functions.BitmapToText(frame, 940, 160, 290, 80);
314332

315-
if (!roundCompletedText.Equals(string.Empty))
333+
if (roundCompletedText != string.Empty && Functions.CompareStrings(roundCompletedText, "COMPLETE") >= 70)
316334
{
317-
if (Functions.CompareStrings(roundCompletedText, "COMPLETED") >= 70)
335+
if (AppData.gameData.heroesPlayed.Count > 0)
318336
{
319337
AppData.gameData.heroesPlayed[AppData.gameData.heroesPlayed.Count - 1].time = (int)AppData.gameData.heroTimer.Elapsed.TotalSeconds;
320-
//Vars.gameData.heroesPlayed.Add(new HeroPlayed(Vars.gameData.heroesPlayed[Vars.gameData.heroesPlayed.Count - 1].name, (int)Vars.gameData.gameTimer.Elapsed.TotalSeconds));
321-
AppData.gameData.state = State.RoundComplete;
322-
AppData.gameData.heroTimer.Stop();
323-
AppData.gameData.gameTimer.Stop();
324-
AppData.getInfoTimeout.Restart();
325-
Functions.DebugMessage($"Recognized round completed");
326338
}
339+
//Vars.gameData.heroesPlayed.Add(new HeroPlayed(Vars.gameData.heroesPlayed[Vars.gameData.heroesPlayed.Count - 1].name, (int)Vars.gameData.gameTimer.Elapsed.TotalSeconds));
340+
AppData.gameData.state = State.RoundComplete;
341+
AppData.gameData.heroTimer.Stop();
342+
AppData.gameData.gameTimer.Stop();
343+
AppData.getInfoTimeout.Restart();
344+
Functions.DebugMessage($"Recognized round completed");
327345
}
328346
}
329347
public static bool ReadRoundStarted(Bitmap frame)
@@ -412,14 +430,15 @@ public static void ReadPlayerNamesAndRank(Bitmap frame)
412430
playerNameX += 945;
413431
playerRankX += 422;
414432
}
433+
Functions.DebugMessage("Captured player list");
415434
}
416435
public static bool IsValidGame()
417436
{
418-
if (AppData.gameData.timer.Elapsed.TotalSeconds < 300)
437+
if (AppData.gameData.timer.Elapsed.TotalSeconds < 300 && !ScreenCaptureHandler.debug)
419438
{
420439
if (AppData.gameData.state >= State.Recording)
421440
{
422-
Functions.DebugMessage("Invalid game");
441+
Functions.DebugMessage($"Invalid game state={AppData.gameData.state} gameData.timer={AppData.gameData.timer.Elapsed.TotalSeconds}");
423442
ScreenCaptureHandler.trayMenu.ChangeTray("Ready to record, enter a competitive game to begin", Resources.Icon_Active);
424443
}
425444
return false;

BetterOverwatch/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class Program
2222
private static void Main()
2323
{
2424
AppData.initalize = new Initalize(
25-
"1.4.3",
25+
"1.4.4",
2626
"betteroverwatch.com",
2727
"https://api.github.com/repos/MartinNielsenDev/OverwatchTracker/releases/latest");
2828
Application.EnableVisualStyles();

BetterOverwatch/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// General Information about an assembly is controlled through the following
55
// set of attributes. Change these attribute values to modify the information
66
// associated with an assembly.
7-
[assembly: AssemblyTitle("Better Overwatch - BETA Ratings")]
7+
[assembly: AssemblyTitle("Better Overwatch")]
88
[assembly: AssemblyDescription("A competitive match tracker for Overwatch")]
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("http://betteroverwatch.com")]
@@ -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.4.3.0")]
35-
[assembly: AssemblyFileVersion("1.4.3.0")]
34+
[assembly: AssemblyVersion("1.4.4.0")]
35+
[assembly: AssemblyFileVersion("1.4.4.0")]

0 commit comments

Comments
 (0)