Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public interface ITrackerLocationService
/// <param name="location">The location to clear.</param>
/// <param name="confidence">The speech recognition confidence.</param>
/// <param name="autoTracked">If this was tracked by the auto tracker</param>
void Clear(Location location, float? confidence = null, bool autoTracked = false, bool stateResponse = true, bool allowLocationComments = false, bool updateTreasureCount = true);
/// <param name="stateResponse">If the location being cleared will be commented on by tracker</param>
/// <param name="allowLocationComments">If location specific comments should be stated</param>
/// <param name="updateTreasureCount">If the dungeon treasure count should be updated, if applicable</param>
/// <param name="stateTreasureResponse">If the dungeon treasure count should be commented on. If not specified, the value of stateResponse will be used.</param>
void Clear(Location location, float? confidence = null, bool autoTracked = false, bool stateResponse = true, bool allowLocationComments = false, bool updateTreasureCount = true, bool? stateTreasureResponse = null);

/// <summary>
/// Unclears an item from the specified location.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using SnesConnectorLibrary;
Expand Down Expand Up @@ -85,21 +86,29 @@ private async void OnMemorySync(SnesData firstDataSet, SnesData? firstPrevData)
{
if (_itemDetailLength == 4)
{
// var fromPlayerId = firstBlockResponse.Data.ReadUInt16(i * 4)!.Value;
var itemId = (ItemType)firstBlockResponse.Data.ReadUInt16(i * 4 + 2)!.Value;
receivedItems.Add(Tracker.World.AllItems.First(x => x.Type == itemId && x.IsLocalPlayerItem));
}
else
{
// var fromPlayerId = firstBlockResponse.Data.ReadUInt8(i * 2)!.Value;
var itemId = (ItemType)firstBlockResponse.Data.ReadUInt8(i * 2 + 1)!.Value;
receivedItems.Add(Tracker.World.AllItems.First(x => x.Type == itemId && x.IsLocalPlayerItem));
var itemId = firstBlockResponse.Data.ReadUInt8(i * 2 + 1)!.Value;
try
{
var itemType = (ItemType)itemId;
receivedItems.Add(Tracker.World.AllItems.First(x => x.Type == itemType && x.IsLocalPlayerItem));
}
catch (Exception)
{
logger.LogWarning("Invalid item type {Id} received", itemId);
}
}
}

logger.LogInformation("Received Items: {Items}", string.Join(",", receivedItems));

Tracker.ItemTracker.TrackItems(receivedItems, true, true);
if (receivedItems.Count > 0)
{
logger.LogInformation("Received Items: {Items}", string.Join(",", receivedItems));
Tracker.ItemTracker.TrackItems(receivedItems, true, true);
}

trackerState.GiftedItemCount = newItemCount.Value;
await Tracker.SaveAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public bool TrackItem(Item item, string? trackedAs = null, float? confidence = n
{
logger.LogInformation("Clearing location for item {ItemType}", item.Type.GetDescription());

Tracker.LocationTracker.Clear(location, confidence, autoTracked, stateResponse: false, allowLocationComments: true, updateTreasureCount: true);
Tracker.LocationTracker.Clear(location, confidence, autoTracked, stateResponse: false, allowLocationComments: true, updateTreasureCount: true, stateTreasureResponse: true);

// If this is a parsed AP/Mainline rom and this is an item for another player, let's comment on it
if (stateResponse && item is { IsLocalPlayerItem: false } && World.Config.RomGenerator != RomGenerator.Cas)
Expand All @@ -197,6 +197,8 @@ public bool TrackItem(Item item, string? trackedAs = null, float? confidence = n
item.Metadata.NameWithArticle, item.PlayerName]);
}
}

return true;
}

if (!didTrack)
Expand Down Expand Up @@ -233,7 +235,7 @@ public bool TrackItem(Item item, string? trackedAs = null, float? confidence = n
// Clear the location if it's for the local player's world
if (location != null && location.World == World && !location.Cleared)
{
Tracker.LocationTracker.Clear(location, confidence, autoTracked, !silent, true);
Tracker.LocationTracker.Clear(location, confidence, autoTracked, !silent && !isGTPreBigKey, true);
undoActions.Add(autoTracked ? null : PopUndo().Action);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class TrackerLocationService(ILogger<TrackerTreasureService> logger, IP
public event EventHandler<LocationClearedEventArgs>? LocationCleared;
public event EventHandler<LocationClearedEventArgs>? LocationMarked;

public void Clear(Location location, float? confidence = null, bool autoTracked = false, bool stateResponse = true, bool allowLocationComments = false, bool updateTreasureCount = true)
public void Clear(Location location, float? confidence = null, bool autoTracked = false, bool stateResponse = true, bool allowLocationComments = false, bool updateTreasureCount = true, bool? stateTreasureCount = null)
{
if (stateResponse && allowLocationComments)
{
Expand All @@ -48,7 +48,7 @@ public void Clear(Location location, float? confidence = null, bool autoTracked
}

var undoTrackTreasure = updateTreasureCount
? Tracker.TreasureTracker.TryTrackDungeonTreasure(location, confidence, stateResponse: stateResponse)
? Tracker.TreasureTracker.TryTrackDungeonTreasure(location, confidence, stateResponse: stateTreasureCount ?? stateResponse)
: null;

// Important: clear only after tracking dungeon treasure, as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public bool UntrackDungeonTreasure(IHasTreasure region, int amount = 1)
}

var dungeon = location.GetTreasureRegion();
if (dungeon != null && (location.Item.IsTreasure || World.Config.ZeldaKeysanity))
if (dungeon != null && (location.Item.IsTreasure || World.Config.ZeldaKeysanity || !location.Item.IsLocalPlayerItem))
{
if (TrackDungeonTreasure(dungeon, confidence, 1, autoTracked, stateResponse))
{
Expand Down