From 7592b1729cae74ea67506cad8917608c33665ec8 Mon Sep 17 00:00:00 2001
From: BubbaGumpShrump <joshua.p.farrell@gmail.com>
Date: Fri, 13 Dec 2024 10:32:55 -0500
Subject: [PATCH] Error Fix - GameMode and GameVersion tracking

---
 AutoTrackR2/KillTrackR_MainScript.ps1      | 35 +++++++++++-----------
 AutoTrackR2/UpdatePage.xaml.cs             |  2 +-
 AutoTrackR2_Setup/AutoTrackR2_Setup.vdproj |  6 ++--
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/AutoTrackR2/KillTrackR_MainScript.ps1 b/AutoTrackR2/KillTrackR_MainScript.ps1
index de9c561..9fc3298 100644
--- a/AutoTrackR2/KillTrackR_MainScript.ps1
+++ b/AutoTrackR2/KillTrackR_MainScript.ps1
@@ -1,4 +1,4 @@
-$TrackRver = "2.0"
+$TrackRver = "2.0r"
 
 # Path to the config file
 $appName = "AutoTrackR2"
@@ -100,11 +100,12 @@ $ueePattern = '<p class="entry citizen-record">\s*<span class="label">UEE Citize
 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
 $process = Get-Process | Where-Object {$_.Name -like "AutoTrackR2"}
 $global:killTally = 0
-
+$global:GameMode = ""
+$global:GameVersion = ""
 
 # Load historic kills from csv
 if (Test-Path "$scriptFolder\Kill-Log.csv") {
-	$historicKills = Import-CSV "$scriptFolder\Kill-log.csv" | Sort-Object -Property KillTime
+	$historicKills = Import-CSV "$scriptFolder\Kill-log.csv"
 	foreach ($kill in $historicKills) {
 		Write-Output "NewKill=throwaway,$($kill.EnemyPilot),$($kill.EnemyShip),$($kill.OrgAffiliation),$($kill.Enlisted),$($kill.RecordNumber),$($kill.KillTime),$($kill.PFP)"
 		$global:killTally++
@@ -144,15 +145,15 @@ Do {
 		Write-Output "PlayerShip=$global:loadOut"
 
 		If ($line -match $versionPattern){
-			$GameVersion = $matches['gameversion']
+			$global:GameVersion = $matches['gameversion']
 		}
 		if ($line -match $acPattern){
-			$GameMode = "AC"
+			$global:GameMode = "AC"
 		}
 		if ($line -match $puPattern){
-			$GameMode = "PU"
+			$global:GameMode = "PU"
 		}
-		Write-Output "GameMode=$GameMode"
+		Write-Output "GameMode=$global:GameMode"
 
 	}
     # If no match found, print "Logged In: False"
@@ -237,7 +238,7 @@ function Read-LogEntry {
 					$ship = $ship -replace '-00(1|2|3|4|5|6|7|8|9|0)$', ''
 				}
 
-				$KillTime = (Get-Date).ToUniversalTime().ToString("d MMM yyyy H:mm 'UTC'")
+				$KillTime = (Get-Date).ToUniversalTime().ToString("dd MMM yyyy HH:mm 'UTC'")
 			
 				# Get Enlisted Date
 				if ($($page1.content) -match $joinDatePattern) {
@@ -279,7 +280,7 @@ function Read-LogEntry {
 				Write-Output "KillTally=$global:killTally"
 				Write-Output "NewKill=throwaway,$enemyPilot,$enemyShip,$enemyOrgs,$joinDate2,$citizenRecord,$killTime,$victimPFP"
 
-				$GameMode = $GameMode.ToLower()
+				$global:GameMode = $global:GameMode.ToLower()
 				# Send to API
 				# Define the data to send
 				If ($null -ne $apiUrl -and $offlineMode -eq $false){
@@ -291,8 +292,8 @@ function Read-LogEntry {
 						weapon			= $weapon
 						method			= $damageType
 						loadout_ship	= $ship
-						game_version	= $GameVersion
-						gamemode		= $GameMode
+						game_version	= $global:GameVersion
+						gamemode		= $global:GameMode
 						trackr_version	= $TrackRver
 					}
 
@@ -332,8 +333,8 @@ function Read-LogEntry {
 					Weapon           = $weapon
 					Ship             = $ship
 					Method           = $damageType
-					Mode             = $GameMode
-					GameVersion      = $GameVersion
+					Mode             = $global:GameMode
+					GameVersion      = $global:GameVersion
 					TrackRver		 = $TrackRver
 					Logged			 = $logMode
 					PFP				 = $victimPFP
@@ -405,12 +406,12 @@ function Read-LogEntry {
 
 	# Detect PU or AC
 	if ($line -match $puPattern) {
-		$GameMode = "PU"
-		Write-Output "GameMode=$GameMode"
+		$global:GameMode = "PU"
+		Write-Output "GameMode=$global:GameMode"
 	}
 	if ($line -match $acPattern) {
-		$GameMode = "AC"
-		Write-Output "GameMode=$GameMode"
+		$global:GameMode = "AC"
+		Write-Output "GameMode=$global:GameMode"
 	}
 
 	#Set loadout 
diff --git a/AutoTrackR2/UpdatePage.xaml.cs b/AutoTrackR2/UpdatePage.xaml.cs
index 9bdc0a7..b085d80 100644
--- a/AutoTrackR2/UpdatePage.xaml.cs
+++ b/AutoTrackR2/UpdatePage.xaml.cs
@@ -9,7 +9,7 @@ namespace AutoTrackR2
 {
     public partial class UpdatePage : UserControl
     {
-        private string currentVersion = "v2.0-beta.3";
+        private string currentVersion = "v2.0-release";
         private string latestVersion;
 
         public UpdatePage()
diff --git a/AutoTrackR2_Setup/AutoTrackR2_Setup.vdproj b/AutoTrackR2_Setup/AutoTrackR2_Setup.vdproj
index f96f87f..d54d1bd 100644
--- a/AutoTrackR2_Setup/AutoTrackR2_Setup.vdproj
+++ b/AutoTrackR2_Setup/AutoTrackR2_Setup.vdproj
@@ -198,15 +198,15 @@
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:AutoTrackR2_Setup"
-        "ProductCode" = "8:{C1E9844A-80C7-4576-8F4C-12503B1F3036}"
-        "PackageCode" = "8:{F0B55802-525C-4754-8265-85508C09D73E}"
+        "ProductCode" = "8:{288819A9-947F-47BE-900E-205C7D7EAAF7}"
+        "PackageCode" = "8:{94C078B7-DD3E-4091-9F5E-780DE3481E1C}"
         "UpgradeCode" = "8:{0B78A147-D0DE-4F72-8906-A62611787CA7}"
         "AspNetVersion" = "8:"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:FALSE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:2.0.13"
+        "ProductVersion" = "8:2.0.2"
         "Manufacturer" = "8:GrieferNET"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:discord.gg/griefernet"