Compare commits

...

5 commits

Author SHA1 Message Date
Heavy Bob
58fcedb3d2 Added weapons for Player override
Also added streamlink file name for the streamerhandle.
2025-04-11 10:45:27 +10:00
Heavy Bob
47abbf9314 Fix. OMG 2025-04-11 10:18:00 +10:00
Heavy Bob
9b4b25921e Fixes 2025-04-11 10:10:38 +10:00
Heavy Bob
f8446f047e Hotfix 2025-04-11 09:59:56 +10:00
Heavy Bob
f21fad999f Fixes. 2025-04-11 08:04:46 +10:00
5 changed files with 1085 additions and 652 deletions

File diff suppressed because it is too large Load diff

View file

@ -23,28 +23,43 @@ namespace AutoTrackR2
protected override void OnStartup(StartupEventArgs e)
{
// Ensure crash log directory exists
Directory.CreateDirectory(Path.GetDirectoryName(CrashLogPath));
// Set up unhandled exception handlers
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
DispatcherUnhandledException += App_DispatcherUnhandledException;
const string appName = "AutoTrackR2";
bool createdNew;
_mutex = new Mutex(true, appName, out createdNew);
_mutexOwned = createdNew;
if (!createdNew)
try
{
// App is already running, silently exit
Current.Shutdown();
return;
}
// Ensure crash log directory exists
Directory.CreateDirectory(Path.GetDirectoryName(CrashLogPath));
base.OnStartup(e);
_streamlinkHandler = new StreamlinkHandler();
// Set up unhandled exception handlers
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
DispatcherUnhandledException += App_DispatcherUnhandledException;
const string appName = "AutoTrackR2";
bool createdNew;
_mutex = new Mutex(true, appName, out createdNew);
_mutexOwned = createdNew;
if (!createdNew)
{
// App is already running, show message and exit
MessageBox.Show("AutoTrackR2 is already running.", "AutoTrackR2", MessageBoxButton.OK, MessageBoxImage.Information);
Current.Shutdown();
return;
}
// Initialize StreamlinkHandler before creating the main window
_streamlinkHandler = new StreamlinkHandler();
// Create and show the main window
var mainWindow = new MainWindow();
mainWindow.Show();
base.OnStartup(e);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to start AutoTrackR2: {ex.Message}", "AutoTrackR2 Error", MessageBoxButton.OK, MessageBoxImage.Error);
Current.Shutdown();
}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
@ -95,20 +110,24 @@ namespace AutoTrackR2
protected override void OnExit(ExitEventArgs e)
{
if (_mutex != null && _mutexOwned)
try
{
try
if (_mutex != null && _mutexOwned)
{
_mutex.ReleaseMutex();
_mutex.Close();
_mutex = null;
}
catch (Exception ex)
{
// Log the mutex release error but don't throw
LogCrash(ex);
}
_mutex.Dispose();
}
base.OnExit(e);
catch (Exception ex)
{
// Log the error but don't prevent shutdown
File.AppendAllText(CrashLogPath, $"[{DateTime.Now}] Error during shutdown: {ex.Message}\n");
}
finally
{
base.OnExit(e);
}
}
}
}

View file

@ -0,0 +1,396 @@
using System.Collections.Generic;
namespace AutoTrackR2.Constants;
public static class Weapons
{
public static readonly List<string> List = new List<string>
{
"gmni_rifle_ballistic_01_firerats01",
"utfl_melee_01_gungame",
"volt_rifle_energy_01_black_gold01",
"behr_glauncher_ballistic_01_cen01",
"behr_optics_tsco_x16_s3",
"klwe_rifle_energy_01_black02",
"behr_optics_rdot_x1_s1",
"ksar_shotgun_energy_01_blue01",
"ksar_smg_energy_01_white02",
"gmni_optics_tsco_x4_s2",
"gmni_pistol_ballistic_01_white02",
"behr_lmg_ballistic_01",
"gmni_pistol_ballistic_01_gold01",
"grin_multitool_01_default_cutter",
"apar_special_ballistic_02_mag",
"apar_special_ballistic_01_mag",
"klwe_sniper_energy_01_tan01",
"ksar_shotgun_ballistic_01_green01",
"test_Gadget",
"ksar_rifle_energy_01_iae2023",
"Carryable_1H_CU_Glowstick_Orange",
"none_smg_energy_01",
"weapon_underbarrel_light_wide",
"volt_rifle_energy_01_tint01",
"nvtc_optics_holo_x1_s1_LAMP",
"gmni_pistol_ballistic_01_white01",
"grin_multitool_01_black01",
"ksar_shotgun_energy_01_tan01",
"ksar_shotgun_energy_01_cen01",
"ksar_rifle_energy_01_red_green01",
"ksar_smg_energy_01_mag",
"grin_multitool_01_default_grapple",
"behr_rifle_ballistic_02_civilian_blue01",
"nvtc_ubarrel_flsh_s1_02",
"nvtc_ubarrel_flsh_s1",
"lbco_sniper_energy_01",
"behr_rifle_ballistic_01_mag",
"apar_special_ballistic_01_tan01",
"none_smg_energy_01_mag",
"banu_melee_01_blue01",
"crlf_medgun_01_purple01",
"klwe_ubarrel_lasr_s1_02",
"ksar_melee_01",
"gmni_lmg_ballistic_01_mag",
"ksar_smg_energy_01_black01",
"gmni_smg_ballistic_01_firerats01",
"crlf_medgun_01_grey01",
"behr_pistol_ballistic_01_300",
"behr_sniper_ballistic_01_arctic01",
"sasu_pistol_toy_01_orange_purple01",
"klwe_sniper_energy_01_Luminalia_red01",
"Carryable_1H_CU_Glowstick_Yellow",
"klwe_lmg_energy_01",
"ksar_optics_tsco_x8_s3",
"ksar_rifle_energy_01_pink_red01",
"apar_special_ballistic_02_mat01",
"behr_glauncher_ballistic_01",
"ksar_shotgun_ballistic_01_firerats01",
"grin_salvage_repair_01",
"apar_special_ballistic_01_mat01",
"ksar_shotgun_ballistic_01_luminalia_blue01",
"gmni_smg_ballistic_01_Luminalia",
"apar_special_ballistic_02_missile",
"volt_rifle_energy_01_mag",
"ksar_pistol_ballistic_01_mag",
"ksar_shotgun_energy_01_green01",
"kegr_fire_extinguisher_01_mag",
"gmni_rifle_ballistic_01_iae2023",
"grin_multitool_01_healing",
"gmni_pistol_ballistic_01_red_black01",
"klwe_optics_disp_x8_s3",
"ksar_smg_energy_01_firerats01",
"behr_lmg_ballistic_01_yellow_grey01",
"behr_smg_ballistic_01_mag",
"klwe_smg_energy_01_blue_gold",
"gmni_sniper_ballistic_01_iae2201",
"sasu_pistol_toy_01_mag_ea_elim",
"nvtc_ubarrel_flsh_s1_04",
"gmni_pistol_ballistic_01_tan01",
"behr_lmg_ballistic_01_mag",
"klwe_rifle_energy_01_white01",
"Carryable_1H_CU_Glowstick_Green_Active",
"behr_shotgun_ballistic_01_blue_white01",
"Carryable_1H_CU_Glowstick_Pink",
"behr_optics_holo_x3_s1",
"klwe_smg_energy_01",
"klwe_sniper_energy_01_gold01",
"klwe_rifle_energy_01_gold01",
"lbco_pistol_energy_01",
"hdgw_pistol_ballistic_01_engraved02",
"gmni_sniper_ballistic_01_firerats01",
"klwe_rifle_energy_01_black01",
"none_shotgun_ballistic_01",
"gmni_sniper_ballistic_01_urban01",
"ksar_smg_energy_01_cc17a",
"behr_pistol_ballistic_01",
"gmni_smg_ballistic_01_mag",
"nvtc_optics_tsco_x4_s2_LAMP",
"behr_prx_kinetic_01",
"behr_smg_ballistic_01_iae2201",
"gmni_lmg_ballistic_01_firerats01",
"ksar_smg_energy_01_cc17b",
"ksar_pistol_ballistic_01_iae2023",
"ksar_smg_energy_01_black02",
"nvtc_optics_holo_x2_s1_LAMP",
"grin_multitool_01_cutter",
"utfl_melee_01_red01_gungame_rotated",
"gmni_rifle_ballistic_01_grey_red01",
"behr_shotgun_ballistic_01_mag",
"behr_rifle_ballistic_02_civilian",
"grin_multitool_01_default_salvage_repair",
"gmni_rifle_ballistic_01",
"gmni_sniper_ballistic_01_arctic01",
"grin_tool_salvage_repair_01",
"gmni_optics_tsco_x8_s3_firerats01",
"weapon_underbarrel_light_wide_blue_01",
"weapon_underbarrel_light_wide_gold_01",
"Carryable_1H_CY_universal_utensil_a",
"behr_smg_ballistic_01_white01",
"weapon_underbarrel_light_wide_red_01",
"klwe_ubarrel_lasr_s1",
"Carryable_1H_CU_Glowstick_Red_Active",
"gmni_shotgun_ballistic_01_red_black01",
"behr_smg_ballistic_01_black02",
"nvtc_optics_tsco_x4_s2",
"klwe_sniper_energy_01_black01",
"klwe_pistol_energy_01_black01",
"grin_multitool_01_brown01",
"volt_rifle_energy_01_camo01",
"klwe_sniper_energy_01_mag",
"klwe_sniper_energy_01_imp01",
"grin_multitool_01_default_charge_drain",
"apar_special_ballistic_01",
"ksar_shotgun_ballistic_01",
"kegr_fire_extinguisher_01_Igniter",
"ksar_smg_energy_01_green01",
"utfl_melee_01_red01_gungame",
"behr_glauncher_ballistic_01_black01",
"behr_rifle_ballistic_01_black02",
"grin_multitool_01_silver01",
"gmni_smg_ballistic_01_purple01",
"lbco_pistol_energy_01_acid01",
"gmni_sniper_ballistic_01_imp01",
"ksar_smg_energy_01",
"behr_smg_ballistic_01_tan01",
"gmni_pistol_ballistic_01_blue_white01",
"grin_tractor_01",
"lbco_optics_tsco_x16_s3",
"behr_sniper_ballistic_01",
"klwe_sniper_energy_01_white01",
"volt_rifle_energy_01_collector02",
"weaponMount_nvtc_optics_holo_x1_s1",
"Optics_Attachment",
"grin_multitool_01_default_tractorbeam_maelstromtest",
"ksar_melee_01_brown01",
"behr_rifle_ballistic_02_civilian_digi01",
"crlf_medgun_01_red01",
"grin_multitool_01_white01",
"klwe_pistol_energy_01_chromic01",
"behr_glauncher_ballistic_01_shin01",
"ksar_melee_01_red01",
"JanitorMob",
"ksar_shotgun_ballistic_01_mag",
"behr_rifle_ballistic_01_white02",
"klwe_sniper_energy_01_black02",
"klwe_sniper_energy_01",
"crlf_medgun_vial_01",
"grin_tool_01_mag",
"gmni_smg_ballistic_01",
"lbco_sniper_energy_01_chromic01",
"ksar_shotgun_energy_01_imp01",
"sasu_pistol_toy_01_mag",
"nvtc_ubarrel_lasr_s1",
"behr_sniper_ballistic_01_mag",
"grin_multitool_01",
"ksar_melee_01_blue01",
"lbco_sniper_energy_01_sunset01",
"ksar_rifle_energy_01_test_inf_ammo",
"ksar_rifle_energy_01_red01",
"ksar_sniper_ballistic_01",
"gmni_sniper_ballistic_01",
"ksar_rifle_energy_01_cian_black01",
"Carryable_1H_CU_Glowstick_Yellow_Active",
"behr_smg_ballistic_01_gold01",
"gmni_lmg_ballistic_01",
"gmni_rifle_ballistic_01_firerats02",
"grin_tractor_01_mag",
"klwe_sniper_energy_01_cen01",
"gmni_shotgun_ballistic_01",
"gmni_shotgun_ballistic_01_mag",
"volt_rifle_energy_01_collector03",
"hdgw_pistol_ballistic_01_mag",
"behr_rifle_ballistic_01",
"behr_smg_ballistic_01_white02",
"ksar_smg_energy_01_cc17",
"banu_melee_01_red01",
"behr_optics_tsco_x4_s2",
"vlk_spewgun_ballistic_01_mag_juvi",
"glsn_smg_energy_01",
"ksar_rifle_energy_01_blue_gold",
"gmni_lmg_ballistic_01_blue_gold",
"ksar_pistol_ballistic_01",
"sasu_pistol_toy_01",
"Multitool_Attachment",
"grin_multitool_01_energy_placeholder",
"gmni_pistol_ballistic_01_black02",
"ksar_melee_01_orange01",
"grin_multitool_01_mining",
"ksar_rifle_energy_01_firerats01",
"volt_rifle_energy_01_collector04",
"lbco_pistol_energy_01_mag",
"nvtc_optics_tsco_x8_s3_LAMP",
"ksar_smg_energy_01_spc_01",
"behr_pistol_ballistic_01_firerats01",
"banu_melee_01",
"ksar_shotgun_energy_01_white02",
"klwe_pistol_energy_01_white01",
"grin_multitool_01_salvage_repair",
"gmni_pistol_ballistic_01_mag",
"banu_melee_01_green01",
"rrs_melee_01_fallout01",
"volt_rifle_energy_01",
"ksar_sniper_ballistic_01_white_blue_01",
"behr_smg_ballistic_01_green01",
"kegr_fire_extinguisher_01",
"ksar_pistol_ballistic_01_headhunters01",
"apar_special_ballistic_01_black02",
"klwe_rifle_energy_01_mag",
"ksar_rifle_energy_01_firerats01_spc",
"klwe_lmg_energy_01_purple_blue01",
"ksar_pistol_ballistic_01_purple_pink01",
"nvtc_optics_holo_x3_s1",
"grin_multitool_resource_salvage_repair_01_filled",
"ksar_shotgun_energy_01_purple01",
"gmni_rifle_ballistic_01_mag",
"weapon_underbarrel_light_narrow_gold_01",
"lbco_sniper_energy_01_acid01",
"nvtc_optics_tsco_x4_s2_firerats01",
"gmni_pistol_ballistic_01_firerats01",
"klwe_rifle_energy_01_green01",
"lbco_pistol_energy_01_sunset01",
"sasu_pistol_toy_01_blue_pink01",
"volt_rifle_energy_01_tint02",
"gmni_smg_ballistic_01_spc_01",
"ksar_pistol_ballistic_01_yellow_black01",
"grin_multitool_02_AR_HUD",
"ksar_shotgun_energy_01_black01",
"klwe_rifle_energy_01_white02",
"ksar_smg_energy_01_gold01",
"grin_multitool_01_default_tractorbeam",
"utfl_melee_01_red01",
"gmni_pistol_ballistic_01_imp01",
"weapon_underbarrel_light_narrow_blue_01",
"behr_smg_ballistic_01_black01",
"weapon_underbarrel_light_wide_purple_01",
"nvtc_optics_rdot_x1_s1_firerats01",
"Carryable_1H_CY_universal_utensil_b",
"behr_lmg_ballistic_01_luminalia_green01",
"weapon_underbarrel_light_narrow_purple_01",
"gmni_lmg_ballistic_01_purple01",
"grin_multitool_01_default_mining",
"gmni_rifle_ballistic_01_yellow_blue01",
"crlf_medgun_01_yellow01",
"none_shotgun_ballistic_01_green01",
"ksar_shotgun_ballistic_01_iae2201",
"behr_rifle_ballistic_01_spc_01",
"grin_multitool_01_AI",
"weapon_underbarrel_light_narrow_red_01",
"nvtc_optics_holo_x1_s1",
"vlk_spewgun_ballistic_reference",
"ksar_shotgun_energy_01",
"none_shotgun_ballistic_01_mag",
"grin_multitool_01_tractorbeam",
"klwe_pistol_energy_01_tan01",
"glsn_shotgun_ballistic_01_mag",
"Tablet_Small",
"ksar_smg_energy_01_black_green01",
"klwe_rifle_energy_01",
"lbco_sniper_energy_imp01",
"ksar_rifle_energy_01_blue_gold_spc_01",
"Carryable_1H_CU_Glowstick_Blue",
"behr_optics_holo_x2_s1",
"grin_multitool_01_red01",
"weapon_underbarrel_light_narrow",
"hdgw_pistol_ballistic_01",
"behr_rifle_ballistic_02_mag_civilian",
"none_melee_01",
"gmni_lmg_ballistic_01_green_red01",
"ksar_rifle_energy_01",
"lbco_pistol_energy_01_chromic01",
"ksar_shotgun_energy_01_red01",
"nvtc_optics_holo_x3_s1_LAMP",
"klwe_smg_energy_01_mag",
"behr_glauncher_ballistic_01_mat01",
"Carryable_1H_CU_Glowstick_Red",
"ksar_shotgun_energy_01_black02",
"grin_multitool_01_orange01",
"vlk_spewgun_ballistic_01_juvi",
"Carryable_1H_CU_Glowstick_Green",
"klwe_rifle_energy_01_tan01",
"vlk_spewgun_ballistic_01_mag",
"banu_melee_02",
"apar_special_ballistic_02",
"behr_gren_frag_01",
"klwe_sniper_energy_01_green01",
"behr_optics_tsco_x8_s3",
"behr_rifle_ballistic_01_green01",
"grin_multitool_resource_salvage_repair_01",
"ksar_shotgun_energy_01_mag",
"behr_shotgun_ballistic_01",
"klwe_pistol_energy_01_black02",
"Carryable_1H_CU_Glowstick_Blue_Active",
"gmni_smg_ballistic_01_blue_white01",
"nvtc_ubarrel_flsh_s1_03",
"ksar_smg_energy_01_red01",
"ksar_pistol_ballistic_01_spc",
"gmni_shotgun_ballistic_01_pink_red01",
"klwe_pistol_energy_01_engraved01",
"crlf_medgun_01",
"gmni_pistol_ballistic_01",
"Carryable_1H_CY_universal_utensil_c",
"grin_cutter_01",
"rrs_melee_01_orange01",
"klwe_ubarrel_flsh_s1",
"gmni_smg_ballistic_01_grey_red01",
"Carryable_1H_CU_Flare_Medivac",
"utfl_melee_01_brown01",
"klwe_pistol_energy_01_gold01",
"gmni_sniper_ballistic_01_mag",
"grin_multitool_01_default_cutter_AI",
"ksar_shotgun_energy_01_gold01",
"ksar_shotgun_energy_01_black_purple01",
"lbco_pistol_energy_cen01",
"gmni_smg_ballistic_01_green_grey01",
"behr_rifle_ballistic_02_civilian_black01",
"klwe_pistol_energy_01_mag",
"grin_multitool_energy_01_mag",
"sasu_pistol_toy_01_blue_yellow01",
"nvtc_ubarrel_flsh_s1_firerats01",
"Underbarrel_Attachment",
"volt_rifle_energy_01_collector01",
"klwe_lmg_energy_01_iae2201",
"behr_sniper_ballistic_01_black01",
"ksar_smg_energy_01_tan01",
"apar_melee_01",
"behr_glauncher_ballistic_01_imp01",
"klwe_lmg_energy_01_mag",
"nvtc_optics_rdot_x1_s1",
"Carryable_1H_CU_Glowstick_Pink_Active",
"gmni_pistol_ballistic_01_green01",
"gmni_pistol_ballistic_01_green_grey01",
"lbco_sniper_energy_01_mag",
"Carryable_1H_CU_Glowstick_Pink_Active_Prison",
"behr_optics_holo_x1_s1",
"grin_multitool_01_default_healing",
"gmni_optics_tsco_x8_s3",
"behr_pistol_ballistic_01_mag",
"gmni_pistol_ballistic_01_cen01",
"gmni_optics_tsco_x4_s2_firerats01",
"klwe_pistol_energy_01",
"nvtc_optics_rdot_x1_s1_LAMP",
"nvtc_optics_holo_x2_s1",
"ksar_sniper_ballistic_01_mag",
"gmni_pistol_ballistic_01_pink_cian01",
"behr_lmg_ballistic_01_xenothreat01",
"behr_smg_ballistic_01",
"sasu_pistol_toy_01_ea_elim",
"klwe_pistol_energy_01_white02",
"Carryable_1H_CU_Glowstick_Luminalia",
"Carryable_1H_CY_cutlery_chopsticks_set_1_a",
"banu_melee_03",
"Carryable_1H_CU_Glowstick_Orange_Active",
"gmni_shotgun_ballistic_01_firerats01",
"vlk_spewgun_ballistic_01_mag_adult",
"klwe_rifle_energy_01_iae2201",
"nvtc_optics_tsco_x8_s3",
"hdgw_pistol_ballistic_01_engraved01",
"behr_rifle_ballistic_01_tan01",
"klwe_sniper_energy_01_white02",
"utfl_melee_01",
"gmni_sniper_ballistic_01_green_grey01",
"klwe_pistol_energy_01_green01",
"utfl_melee_01_grey01",
"ksar_rifle_energy_01_mag",
"grin_multitool_resource_healing_01",
"behr_glauncher_ballistic_01_mag"
};
}

View file

@ -1,5 +1,6 @@
using System.Text.RegularExpressions;
using AutoTrackR2.Constants;
using AutoTrackR2;
namespace AutoTrackR2.LogEventHandlers;
@ -17,9 +18,9 @@ public struct ActorDeathData
public class ActorDeathEvent : ILogEventHandler
{
public Regex Pattern { get; }
private Regex _cleanUpPattern = new Regex(@"^(.+?)_\d+$");
private Regex _shipManufacturerPattern;
private string _lastKillShip = string.Empty;
private Regex cleanUpPattern = new Regex(@"^(.+?)(?:_\d+)*$");
public ActorDeathEvent()
{
@ -29,12 +30,6 @@ public class ActorDeathEvent : ILogEventHandler
private bool IsValidShip(string shipName)
{
// Clean up the ship name first
if (_cleanUpPattern.IsMatch(shipName))
{
shipName = _cleanUpPattern.Match(shipName).Groups[1].Value;
}
// A valid ship must start with a known manufacturer
return _shipManufacturerPattern.IsMatch(shipName);
}
@ -57,10 +52,16 @@ public class ActorDeathEvent : ILogEventHandler
Timestamp = match.Groups["Timestamp"].Value
};
// Clean up weapon name
if (_cleanUpPattern.IsMatch(data.Weapon))
// Check if the damage type is TakeDown or Melee
if (data.DamageType == "TakeDown" || data.DamageType == "Melee")
{
data.Weapon = _cleanUpPattern.Match(data.Weapon).Groups[1].Value;
LocalPlayerData.PlayerShip = "Player";
}
// Check if the weapon is in our list of weapons
if (Weapons.List.Contains(data.Weapon))
{
LocalPlayerData.PlayerShip = "Player";
}
// First check if this is a valid ship
@ -80,8 +81,18 @@ public class ActorDeathEvent : ILogEventHandler
_lastKillShip = data.VictimShip;
}
}
// Clean up ship and weapon names (only if not set to Player or Passenger)
if (data.VictimShip != "Player" && data.VictimShip != "Passenger" && cleanUpPattern.IsMatch(data.VictimShip))
{
data.VictimShip = cleanUpPattern.Match(data.VictimShip).Groups[1].Value;
}
if (cleanUpPattern.IsMatch(data.Weapon))
{
data.Weapon = cleanUpPattern.Match(data.Weapon).Groups[1].Value;
}
TrackREventDispatcher.OnActorDeathEvent(data);
}
}

View file

@ -53,7 +53,7 @@ public class StreamlinkHandler
{
var outputPath = Path.Combine(
ConfigManager.VideoPath ?? Environment.GetFolderPath(Environment.SpecialFolder.MyVideos),
$"kill_{DateTime.Now:yyyyMMdd_HHmmss}.mp4"
$"{streamerHandle}_{DateTime.Now:yyyyMMdd_HHmmss}.mp4"
);
// Calculate the duration for recording (30 seconds before + configured duration after)