Skip to content

Commit 1dbb1b2

Browse files
committed
logging errors to ummm debug txt thing
1 parent 5a2272e commit 1dbb1b2

File tree

6 files changed

+39
-21
lines changed

6 files changed

+39
-21
lines changed

Aimmy2/AILogic/AIManager.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@ private async Task InitializeModel(SessionOptions sessionOptions, string modelPa
163163
await Application.Current.Dispatcher.BeginInvoke(new Action(() => new NoticeBar($"Error starting the model via CUDA: {ex.Message}\n\nFalling back to DirectML, performance may be poor.", 5000).Show()));
164164
try
165165
{
166+
FileManager.LogError($"Error starting the model via CUDA: {ex}");
166167
await LoadModelAsync(sessionOptions, modelPath, useCUDA: false);
167168
}
168169
catch (Exception e)
169170
{
171+
FileManager.LogError($"Error starting the model via Tensorrt: {e}");
170172
await Application.Current.Dispatcher.BeginInvoke(new Action(() => new NoticeBar($"Error starting the model via Tensorrt: {e.Message}, you won't be able to aim assist at all.", 5000).Show()));
171173
}
172174
}
@@ -193,6 +195,7 @@ private async Task LoadModelAsync(SessionOptions sessionOptions, string modelPat
193195
}
194196
catch (Exception ex)
195197
{
198+
FileManager.LogError($"Error starting the model: {ex}");
196199
await Application.Current.Dispatcher.BeginInvoke(new Action(() => new NoticeBar($"Error starting the model: {ex.Message}", 5000).Show()));
197200
_onnxModel?.Dispose();
198201
}
@@ -218,6 +221,8 @@ private void ValidateOnnxShape()
218221
, 15000)
219222
.Show()
220223
));
224+
225+
FileManager.LogError("Output shape does not match the expected shape of 1x5x8400. This model will not work with Aimmy, please use an YOLOv8 model converted to ONNXv8.");
221226
}
222227
}
223228
}
@@ -276,7 +281,7 @@ private async void AiLoop()
276281
double averageTime = totalTime / 1000.0;
277282
//Debug.WriteLine($"Average loop iteration time: {averageTime} ms");
278283
MessageBox.Show($"Average loop iteration time: {averageTime} ms", "Share this iteration time on our discord!");
279-
LogError($"Average loop iteration time: {averageTime} ms");
284+
FileManager.LogError($"Average loop iteration time: {averageTime} ms");
280285
totalTime = 0;
281286
iterationCount = 0;
282287
}
@@ -659,7 +664,7 @@ private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction clo
659664
}
660665
catch (Exception e)
661666
{
662-
LogError("Error capturing screen:" + e);
667+
FileManager.LogError("Error capturing screen:" + e);
663668
return null;
664669
}
665670
return null;
@@ -695,11 +700,11 @@ private Rectangle ClampRectangle(Rectangle rect, int screenWidth, int screenHeig
695700
{
696701
if (result == Vortice.DXGI.ResultCode.DeviceRemoved) // This usually happens when using closest to mouse
697702
{
698-
LogError("Device removed, reinitializing D3D11.");
703+
FileManager.LogError("Device removed, reinitializing D3D11.");
699704
ReinitializeD3D11();
700705
return null;
701706
}
702-
LogError("Failed to acquire next frame: " + result);
707+
FileManager.LogError("Failed to acquire next frame: " + result);
703708
ReinitializeD3D11();
704709
return null;
705710
}
@@ -779,24 +784,16 @@ private Rectangle ClampRectangle(Rectangle rect, int screenWidth, int screenHeig
779784
}
780785
catch (SharpGenException ex)
781786
{
782-
LogError("SharpGenException: " + ex);
787+
FileManager.LogError("SharpGenException: " + ex);
783788
return null;
784789
}
785790
catch (Exception e)
786791
{
787-
LogError("Error capturing screen: " + e);
792+
FileManager.LogError("Error capturing screen: " + e);
788793
return null;
789794
}
790795
}
791-
private void LogError(string message)
792-
{
793-
if (Dictionary.toggleState["Debug Mode"])
794-
{
795-
string logFilePath = "debug.txt";
796-
using StreamWriter writer = new StreamWriter(logFilePath, true);
797-
writer.WriteLine($"[{DateTime.Now}]: {message}");
798-
}
799-
}
796+
800797
//private Bitmap? DeprecatedScreen(Rectangle detectionBox) // if for some reason they want to use the old method...
801798
//{
802799
// if (_screenCaptureBitmap == null || _screenCaptureBitmap.Width != detectionBox.Width || _screenCaptureBitmap.Height != detectionBox.Height)

Aimmy2/MainWindow.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ public async Task LoadStoreMenu()
943943
}
944944
catch (Exception e)
945945
{
946+
FileManager.LogError("Error loading store menu: " + e);
946947
new NoticeBar(e.Message, 10000).Show();
947948
return;
948949
}
@@ -1080,8 +1081,10 @@ private void LoadConfig(string path = "bin\\configs\\Default.cfg", bool loading_
10801081
uiManager.S_AIMinimumConfidence!.Slider.Value = MainWindow.GetValueOrDefault(Dictionary.sliderSettings, "AI Minimum Confidence", 50);
10811082
}
10821083
}
1083-
catch (Exception e)
1084+
1085+
catch(Exception e)
10841086
{
1087+
FileManager.LogError("Error loading config " + e);
10851088
MessageBox.Show($"Error loading config, possibly outdated\n{e}");
10861089
}
10871090
}
@@ -1110,6 +1113,7 @@ private void LoadAntiRecoilConfig(string path = "bin\\anti_recoil_configs\\Defau
11101113
}
11111114
catch (Exception e)
11121115
{
1116+
FileManager.LogError("Error loading anti-recoil config: " + e);
11131117
throw new Exception($"Error loading config, possibly outdated\n{e}");
11141118
}
11151119
}

Aimmy2/MouseMovementLibraries/ddxoftSupport/ddxoftMain.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using Other;
2+
using System.IO;
23
using System.Net.Http;
34
using System.Security.Principal;
45
using System.Windows;
@@ -28,8 +29,9 @@ private static async Task DownloadDdxoft()
2829
new NoticeBar($"{ddxoftpath} has downloaded successfully, please re-select ddxoft Virtual Input Driver to load the DLL.", 4000).Show();
2930
}
3031
}
31-
catch
32+
catch(Exception e)
3233
{
34+
FileManager.LogError("Failed to download ddxoft.dll: " + e);
3335
new NoticeBar($"{ddxoftpath} has failed to install, please try a different Mouse Movement Method.", 4000).Show();
3436
}
3537
}
@@ -60,6 +62,7 @@ public static async Task<bool> DLLLoading()
6062
}
6163
catch (Exception ex)
6264
{
65+
FileManager.LogError("Failed to load ddxoft: " + ex);
6366
MessageBox.Show("Failed to load ddxoft virtual input driver.\n\n" + ex.ToString(), "Aimmy");
6467
return false;
6568
}

Aimmy2/Other/FileManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private void CheckForRequiredFolders()
6363
}
6464
catch (Exception ex)
6565
{
66+
LogError("Error creating a required directory: " + ex);
6667
MessageBox.Show($"Error creating a required directory: {ex}");
6768
Application.Current.Shutdown();
6869
}
@@ -202,7 +203,15 @@ public void LoadConfigsIntoListBox(object? sender, FileSystemEventArgs? e)
202203
});
203204
}
204205
}
205-
206+
public static void LogError(string message)
207+
{
208+
if (Dictionary.toggleState["Debug Mode"])
209+
{
210+
string logFilePath = "debug.txt";
211+
using StreamWriter writer = new StreamWriter(logFilePath, true);
212+
writer.WriteLine($"[{DateTime.Now}]: {message}");
213+
}
214+
}
206215
public static async Task<HashSet<string>> RetrieveAndAddFiles(string repoLink, string localPath, HashSet<string> allFiles)
207216
{
208217
try
@@ -227,6 +236,7 @@ public static async Task<HashSet<string>> RetrieveAndAddFiles(string repoLink, s
227236
}
228237
catch (Exception ex)
229238
{
239+
LogError(ex.ToString());
230240
throw new Exception(ex.ToString());
231241
}
232242
}

Aimmy2/Other/GetSpecs.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Management;
1+
using Other;
2+
using System.Management;
23
using Visuality;
34

45
namespace Aimmy2.Class
@@ -20,6 +21,8 @@ internal class GetSpecs
2021
}
2122
catch (Exception e)
2223
{
24+
25+
FileManager.LogError("Failed to get specs: " + e);
2326
new NoticeBar(e.Message, 10000).Show();
2427
return "Not Found";
2528
}

Aimmy2/Other/KeybindNameManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public static string ConvertToRegularKey(string keyName)
4646
var key = (Key)kc.ConvertFromString(keyName)!;
4747
return KeybindNames.TryGetValue(key.ToString(), out var displayName) ? displayName : key.ToString();
4848
}
49-
catch (Exception)
49+
catch (Exception ex)
5050
{
51+
FileManager.LogError("Failed to grab keybind (most likely a missing keybind from dictionary) " + ex);
5152
return keyName;
5253
}
5354
}

0 commit comments

Comments
 (0)