Skip to content

Commit c0e86cb

Browse files
committed
v1.3.4
- Fixed the author header in the news tab not displaying names correctly, as well as titles being too long. - Fixed a specific case of the news tab not grabbing articles if you were outdated and had the game running. - Internal optimizations and improvements related to file streams and memory.
1 parent a0732d1 commit c0e86cb

13 files changed

Lines changed: 121 additions & 104 deletions

File tree

Architecture/Path.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private void Initialize(string str)
2323

2424
public Path()
2525
{
26-
IndirectPath = null;
26+
IndirectPath = "";
2727
}
2828

2929
public Path(string str)

Controls/CRNews.Designer.cs

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

Controls/CRNews.cs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ private class NewsStorage
2626
public string ThumbnailUrlAlt { get; set; }
2727
public Image ThumbnailImage { get; set; } = null;
2828
public string Title { get; set; }
29-
public string Calendar { get; set; }
29+
public string Timestamp { get; set; }
3030
public string Author { get; set; }
31-
public string Category { get; set; }
3231
public bool Parsed { get; set; } = false;
3332

3433
public NewsStorage(string bodyContent)
@@ -47,6 +46,12 @@ public void ParseJson(string bodyContent)
4746
if (titleMatch.Success && titleMatch.Groups[1].Success)
4847
{
4948
Title = titleMatch.Groups[1].Value;
49+
50+
if (Title.Length > 74) // Max length for title.
51+
{
52+
Title = Title.Substring(0, 74);
53+
Title += "...";
54+
}
5055
}
5156

5257
if (urlMatch.Success && urlMatch.Groups[1].Success)
@@ -60,6 +65,25 @@ public void ParseJson(string bodyContent)
6065
}
6166
}
6267
}
68+
69+
public void ParseBody(string bodyContent)
70+
{
71+
if (bodyContent.Contains("author"))
72+
{
73+
Match timestampMatch = Regex.Match(bodyContent.Replace("\\", ""), "(?<=\"className\":\"is-5 is-uppercase\",\"children\":\")(.*?)(?=\"})");
74+
Match authorMatch = Regex.Match(bodyContent, "(?<=\"author\" content=\")(.*?)(?=\")");
75+
76+
if (timestampMatch.Success && timestampMatch.Groups[1].Success)
77+
{
78+
Timestamp = timestampMatch.Groups[1].Value;
79+
}
80+
81+
if (authorMatch.Success && authorMatch.Groups[1].Success)
82+
{
83+
Author = authorMatch.Groups[1].Value;
84+
}
85+
}
86+
}
6387
}
6488

6589
public ControlTheme ControlType
@@ -379,34 +403,7 @@ private async Task<NewsStorage> ParseLink(NewsStorage newsStorage)
379403

380404
if (!string.IsNullOrEmpty(pageBody))
381405
{
382-
if (string.IsNullOrEmpty(newsStorage.Title))
383-
{
384-
Match titleMatch = Regex.Match(pageBody, "\"headline\": \"(.*)\"");
385-
386-
if (titleMatch.Success && titleMatch.Groups[1].Success)
387-
{
388-
newsStorage.Title = titleMatch.Groups[1].Value;
389-
}
390-
}
391-
392-
Match calendarMatch = Regex.Match(pageBody.Replace("\r", "").Replace(" ", "").Replace("\n", ""), "<p class=\"is-5 is-uppercase\">(.*?)<");
393-
Match userMatch = Regex.Match(pageBody, "\"author\": \"(.*)\"");
394-
Match categoryMatch = Regex.Match(pageBody, "\"category tag\">(.*)<\\/a><\\/p>");
395-
396-
if (calendarMatch.Success && calendarMatch.Groups[1].Success)
397-
{
398-
newsStorage.Calendar = calendarMatch.Groups[1].Value;
399-
}
400-
401-
if (userMatch.Success && userMatch.Groups[1].Success)
402-
{
403-
newsStorage.Author = userMatch.Groups[1].Value;
404-
}
405-
406-
if (categoryMatch.Success && categoryMatch.Groups[1].Success)
407-
{
408-
newsStorage.Category = categoryMatch.Groups[1].Value;
409-
}
406+
newsStorage.ParseBody(pageBody);
410407

411408
if (string.IsNullOrEmpty(newsStorage.ThumbnailUrl))
412409
{
@@ -541,9 +538,9 @@ private async void LoadIndex()
541538
newsStorage = _articles[_index];
542539
}
543540

544-
PublishDate = newsStorage.Calendar;
541+
PublishDate = newsStorage.Timestamp;
545542
PublishAuthor = newsStorage.Author;
546-
NewsCategory = newsStorage.Category;
543+
NewsCategory = "News"; // Psyonix removed category tags it seems like...have to do this for now.
547544
Title = newsStorage.Title;
548545

549546
if (newsStorage.ThumbnailImage == null)

Controls/CRUpdate.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ private void GameBtn_OnButtonClick(object sender, EventArgs e)
310310
{
311311
if (ButtonsEnabled)
312312
{
313+
if (ButtonClickDeny != null)
314+
{
315+
ButtonClickDeny.Invoke(this, e);
316+
}
317+
313318
HidePopup();
314319
}
315320
}

Forms/MainFrm.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.

Forms/MainFrm.resx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,6 @@
282282
<metadata name="DashboardTabBtn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
283283
<value>True</value>
284284
</metadata>
285-
<metadata name="InstallPopup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
286-
<value>True</value>
287-
</metadata>
288-
<metadata name="UpdatePopup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
289-
<value>True</value>
290-
</metadata>
291285
<metadata name="TermsPopup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
292286
<value>True</value>
293287
</metadata>
@@ -306,6 +300,12 @@
306300
<metadata name="TitleBar.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
307301
<value>True</value>
308302
</metadata>
303+
<metadata name="InstallPopup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
304+
<value>True</value>
305+
</metadata>
306+
<metadata name="UpdatePopup.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
307+
<value>True</value>
308+
</metadata>
309309
<metadata name="ProcessTmr.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
310310
<value>17, 17</value>
311311
</metadata>

Framework/Assembly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static class Assembly
88
private static readonly string _description = "Manages and injects the CodeRed module for Rocket League. ";
99
private static readonly string _product = "CodeRedLauncher";
1010
private static readonly string _copyright = "CodeRedModding 2024";
11-
private static readonly string _version = "1.3.3";
11+
private static readonly string _version = "1.3.4";
1212
private static readonly bool _termsOfUse = false;
1313
private static readonly bool _privatePolicy = false;
1414

Framework/Configuration.cs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Runtime.CompilerServices;
34

45
namespace CodeRedLauncher
56
{
@@ -136,11 +137,11 @@ private static bool ParseConfigFile()
136137
{
137138
if (_storageFile.Exists())
138139
{
139-
string[] fileLines = File.ReadAllLines(_storageFile.GetPath());
140-
141-
if (fileLines.Length > 0)
140+
using (StreamReader stream = new StreamReader(_storageFile.GetPath()))
142141
{
143-
foreach (string line in fileLines)
142+
string line;
143+
144+
while ((line = stream.ReadLine()) != null)
144145
{
145146
try
146147
{
@@ -162,22 +163,18 @@ private static bool ParseConfigFile()
162163
if (line.Contains("Manual")) { InjectionType.SetValue(InjectionTypes.Manual.ToString()); continue; }
163164
}
164165

165-
if (line.Contains(InjectionTimeout.Name)) { InjectionTimeout.SetValue(line.Substring((InjectionTimeout.Name.Length + 1), (line.Length - (InjectionTimeout.Name.Length + 1)))); continue; }
166+
if (line.Contains(InjectionTimeout.Name)) { InjectionTimeout.SetValue(line.Substring((InjectionTimeout.Name.Length + 1), (line.Length - (InjectionTimeout.Name.Length + 1)))); continue; }
166167
if (line.Contains(LightMode.Name)) { LightMode.SetValue(line.Contains("True") ? "True" : "False"); continue; }
167168
}
168169
catch
169170
{
170171
SetDefaultSettings(true);
171-
return true;
172+
break;
172173
}
173174
}
174-
175-
return true;
176-
}
177-
else
178-
{
179-
SetDefaultSettings(true);
180175
}
176+
177+
return true;
181178
}
182179
else
183180
{
@@ -266,22 +263,26 @@ public async static void SaveChanges()
266263
await File.Create(_storageFile.GetPath()).DisposeAsync();
267264
}
268265

269-
string file = _storageFile.GetPath();
270-
File.WriteAllText(file, string.Empty); // "Truncuating" the file without needing to open it in a stream.
271-
File.AppendAllText(file, PrivacyPolicy.Name + " " + PrivacyPolicy.GetStringValue() + "\n");
272-
File.AppendAllText(file, TermsOfUse.Name + " " + TermsOfUse.GetStringValue() + "\n");
273-
File.AppendAllText(file, PrivacyHash.Name + " " + PrivacyHash.GetStringValue() + "\n");
274-
File.AppendAllText(file, TermsHash.Name + " " + TermsHash.GetStringValue() + "\n");
275-
File.AppendAllText(file, AutoCheckUpdates.Name + " " + AutoCheckUpdates.GetStringValue() + "\n");
276-
File.AppendAllText(file, AutoInstallUpdates.Name + " " + AutoInstallUpdates.GetStringValue() + "\n");
277-
File.AppendAllText(file, PreventInjection.Name + " " + PreventInjection.GetStringValue() + "\n");
278-
File.AppendAllText(file, RunOnStartup.Name + " " + RunOnStartup.GetStringValue() + "\n");
279-
File.AppendAllText(file, MinimizeOnStartup.Name + " " + MinimizeOnStartup.GetStringValue() + "\n");
280-
File.AppendAllText(file, HideWhenMinimized.Name + " " + HideWhenMinimized.GetStringValue() + "\n");
281-
File.AppendAllText(file, InjectAllInstances.Name + " " + InjectAllInstances.GetStringValue() + "\n");
282-
File.AppendAllText(file, InjectionType.Name + " " + InjectionType.GetStringValue() + "\n");
283-
File.AppendAllText(file, InjectionTimeout.Name + " " + InjectionTimeout.GetStringValue() + "\n");
284-
File.AppendAllText(file, LightMode.Name + " " + LightMode.GetStringValue());
266+
string fileConents = "";
267+
fileConents += (PrivacyPolicy.Name + " " + PrivacyPolicy.GetStringValue() + Environment.NewLine);
268+
fileConents += (TermsOfUse.Name + " " + TermsOfUse.GetStringValue() + Environment.NewLine);
269+
fileConents += (PrivacyHash.Name + " " + PrivacyHash.GetStringValue() + Environment.NewLine);
270+
fileConents += (TermsHash.Name + " " + TermsHash.GetStringValue() + Environment.NewLine);
271+
fileConents += (AutoCheckUpdates.Name + " " + AutoCheckUpdates.GetStringValue() + Environment.NewLine);
272+
fileConents += (AutoInstallUpdates.Name + " " + AutoInstallUpdates.GetStringValue() + Environment.NewLine);
273+
fileConents += (PreventInjection.Name + " " + PreventInjection.GetStringValue() + Environment.NewLine);
274+
fileConents += (RunOnStartup.Name + " " + RunOnStartup.GetStringValue() + Environment.NewLine);
275+
fileConents += (MinimizeOnStartup.Name + " " + MinimizeOnStartup.GetStringValue() + Environment.NewLine);
276+
fileConents += (HideWhenMinimized.Name + " " + HideWhenMinimized.GetStringValue() + Environment.NewLine);
277+
fileConents += (InjectAllInstances.Name + " " + InjectAllInstances.GetStringValue() + Environment.NewLine);
278+
fileConents += (InjectionType.Name + " " + InjectionType.GetStringValue() + Environment.NewLine);
279+
fileConents += (InjectionTimeout.Name + " " + InjectionTimeout.GetStringValue() + Environment.NewLine);
280+
fileConents += (LightMode.Name + " " + LightMode.GetStringValue());
281+
282+
using (StreamWriter stream = new StreamWriter(_storageFile.GetPath(), false))
283+
{
284+
stream.Write(fileConents);
285+
}
285286
}
286287
else
287288
{

Framework/Logger.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ private async static void CreateLogFile()
5252
await File.Create(_logFile.GetPath()).DisposeAsync();
5353
}
5454

55-
File.WriteAllText(_logFile.GetPath(), string.Empty); // "Truncuating" the log file without needing to open it in a stream.
55+
using (StreamWriter stream = new StreamWriter(_logFile.GetPath(), false))
56+
{
57+
stream.Write(""); // Clearing the old log file.
58+
}
59+
5660
_initialized = true;
5761
}
5862
}
5963
}
6064

61-
private static string CreateTimestamp(StackTrace stackTrace)
65+
private static string CreateTimestamp()
6266
{
6367
return "[" + DateTime.Now.ToString() + "] ";
6468
}
@@ -67,7 +71,7 @@ public static void Write(string str, LogLevel level = LogLevel.LEVEL_NONE)
6771
{
6872
if (CheckInitialized())
6973
{
70-
string newLine = CreateTimestamp(new StackTrace(4));
74+
string newLine = CreateTimestamp();
7175

7276
switch (level)
7377
{
@@ -83,7 +87,11 @@ public static void Write(string str, LogLevel level = LogLevel.LEVEL_NONE)
8387
}
8488

8589
newLine += (str + Environment.NewLine);
86-
File.AppendAllText(_logFile.GetPath(), newLine);
90+
91+
using (StreamWriter stream = new StreamWriter(_logFile.GetPath(), true))
92+
{
93+
stream.Write(newLine);
94+
}
8795
}
8896
}
8997
}

Framework/Manager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ public static InjectionResults TryLoadIndividual(Process process, Architecture.P
344344
}
345345
else
346346
{
347+
_handleCache.Clear();
347348
return InjectionResults.ProcessNotFound;
348349
}
349350
}

0 commit comments

Comments
 (0)