-
Notifications
You must be signed in to change notification settings - Fork 2
Fix name scan after BSG magnifier change and language switch race #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "RatScanner (Debug)", | ||
| "type": "coreclr", | ||
| "request": "launch", | ||
| "preLaunchTask": "build", | ||
| "program": "${workspaceFolder}/RatScanner/bin/Debug/net10.0-windows10.0.22621.0/RatScanner.exe", | ||
| "args": [], | ||
| "cwd": "${workspaceFolder}/RatScanner/bin/Debug/net10.0-windows10.0.22621.0", | ||
| "console": "integratedTerminal", | ||
| "stopAtEntry": false | ||
| } | ||
| ] | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for this one |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "build", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "build", | ||
| "${workspaceFolder}/RatScanner/RatScanner.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": true | ||
| }, | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "publish", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "publish", | ||
| "${workspaceFolder}/RatScanner/RatScanner.csproj", | ||
| "-c", | ||
| "Release", | ||
| "-o", | ||
| "${workspaceFolder}/publish", | ||
| "--runtime", | ||
| "win-x64", | ||
| "-p:PublishSingleFile=true", | ||
| "--self-contained", | ||
| "true" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| } | ||
| ] | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no automatic CI/CD to upgrade version and create release? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,8 @@ public class RatScannerMain : INotifyPropertyChanged { | |
|
|
||
| internal RatEyeEngine RatEyeEngine; | ||
|
|
||
| private Bitmap? _searchMarker; | ||
|
|
||
| public event PropertyChangedEventHandler? PropertyChanged; | ||
|
|
||
| internal ItemQueue ItemScans = new(); | ||
|
|
@@ -205,10 +207,31 @@ private RatEye.Config GetRatEyeConfig(bool highlighted = true) { | |
| InventoryConfig = new Config.Processing.Inventory() { | ||
| OptimizeHighlighted = highlighted, | ||
| }, | ||
| InspectionConfig = CreateInspectionConfig(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Severity Level: Major
|
||
| }, | ||
| }; | ||
| } | ||
|
|
||
| private Config.Processing.Inspection CreateInspectionConfig() { | ||
| if (_searchMarker == null) { | ||
| string path = RatConfig.Paths.SearchIcon; | ||
| if (!File.Exists(path)) { | ||
| Logger.LogError( | ||
| $"Search icon not found at: {path}\n\n" + | ||
| "Name scan requires Data/icon_search.png. Reinstall or update RatScanner so the full package is present."); | ||
| } | ||
|
|
||
| _searchMarker = new Bitmap(path); | ||
| Logger.LogInfo($"Loaded name-scan marker {_searchMarker.Width}x{_searchMarker.Height} from {path}"); | ||
| } | ||
|
|
||
| // MarkerItemScale is calibrated to template width: in-game icon is ~16px at 1080p | ||
| return new Config.Processing.Inspection() { | ||
| Marker = _searchMarker, | ||
| MarkerItemScale = 16f / _searchMarker.Width, | ||
| }; | ||
| } | ||
|
Comment on lines
+215
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Missing-file check logs but still crashes with an unhelpful exception. The 🛡️ Proposed fix: throw with the custom message private Config.Processing.Inspection CreateInspectionConfig() {
if (_searchMarker == null) {
string path = RatConfig.Paths.SearchIcon;
if (!File.Exists(path)) {
Logger.LogError(
$"Search icon not found at: {path}\n\n" +
"Name scan requires Data/icon_search.png. Reinstall or update RatScanner so the full package is present.");
- }
-
- _searchMarker = new Bitmap(path);
+ throw new FileNotFoundException(
+ "Search icon file is missing. Name scan requires Data/icon_search.png. Reinstall or update RatScanner so the full package is present.",
+ path);
+ }
+
+ _searchMarker = new Bitmap(path);
Logger.LogInfo($"Loaded name-scan marker {_searchMarker.Width}x{_searchMarker.Height} from {path}");
}🤖 Prompt for AI Agents |
||
|
|
||
| private Database RatStashDatabaseFromTarkovDev() { | ||
| List<Item> rsItems = new(); | ||
| if (!TarkovDevAPI.TryGetCachedItems(out TarkovDev.GraphQL.Item[] items) || items.Length == 0) { | ||
|
|
@@ -298,17 +321,25 @@ internal void NameScan(Vector2 position) { | |
| toolTipPosition += new Vector2(-(int)(marker.Width * scale), (int)(marker.Height * scale)); | ||
| toolTipPosition += position; | ||
|
|
||
| ItemNameScan tempNameScan = new( | ||
| inspection, | ||
| toolTipPosition, | ||
| RatConfig.ToolTip.Duration); | ||
|
|
||
| ItemScans.Enqueue(tempNameScan); | ||
| if (!TryEnqueueNameScan(inspection, toolTipPosition)) return; | ||
|
|
||
| RefreshOverlay(); | ||
| } | ||
| } | ||
|
|
||
| private bool TryEnqueueNameScan(RatEye.Processing.Inspection inspection, Vector2 toolTipPosition) { | ||
| if (!TarkovDevAPI.TryGetItemById(inspection.Item!.Id, out _)) { | ||
| Logger.LogWarning($"Skipping name scan: item {inspection.Item.Id} is not in cache yet."); | ||
| return false; | ||
| } | ||
|
Comment on lines
+331
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Add an explicit null guard for Severity Level: Major Why it matters? ⭐The helper dereferences Rule source 📖=== AGENTS.md === (line 66) (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** RatScanner/RatScannerMain.cs
**Line:** 318:321
**Comment:**
*Custom Rule: Add an explicit null guard for `inspection.Item` at the start of the helper and avoid relying on the null-forgiving operator when reading the item id.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix |
||
|
|
||
| ItemScans.Enqueue(new ItemNameScan( | ||
| inspection, | ||
| toolTipPosition, | ||
| RatConfig.ToolTip.Duration)); | ||
| return true; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Perform a name scan over the entire active screen | ||
| /// </summary> | ||
|
|
@@ -333,12 +364,7 @@ internal void NameScanScreen(object? _ = null) { | |
| Bitmap marker = RatEyeEngine.Config.ProcessingConfig.InspectionConfig.Marker; | ||
| toolTipPosition += new Vector2(0, (int)(marker.Height * scale)); | ||
|
|
||
| ItemNameScan tempNameScan = new( | ||
| inspection, | ||
| toolTipPosition, | ||
| RatConfig.ToolTip.Duration); | ||
|
|
||
| ItemScans.Enqueue(tempNameScan); | ||
| TryEnqueueNameScan(inspection, toolTipPosition); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Add an explicit null check for the nullable Severity Level: Major Why it matters? ⭐The loop variable is declared as Rule source 📖=== AGENTS.md === (line 66) (Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** RatScanner/RatScannerMain.cs
**Line:** 354:354
**Comment:**
*Custom Rule: Add an explicit null check for the nullable `inspection` value in the loop before passing it to the enqueue helper.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix |
||
| } | ||
| RefreshOverlay(); | ||
| } | ||
|
|
@@ -364,6 +390,10 @@ internal void IconScan(Vector2 position) { | |
| RatEye.Processing.Icon? icon = inventory.LocateIcon(); | ||
|
|
||
| if (icon?.DetectionConfidence <= 0 || icon?.Item == null) return; | ||
| if (!TarkovDevAPI.TryGetItemById(icon.Item.Id, out _)) { | ||
| Logger.LogWarning($"Skipping icon scan: item {icon.Item.Id} is not in cache yet."); | ||
| return; | ||
| } | ||
|
|
||
| Vector2 toolTipPosition = position; | ||
| toolTipPosition += icon.Position + icon.ItemPosition; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the .vscode/ dir is not on the .gitignore normally?