Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Remove map note if favorite item is picked up

Open solonkovda opened this issue 7 months ago • 2 comments

Summary

Bugfixes "Picking favorite item back up will now remove map note if possible"

Purpose of change

If you enable map notes for dropped favorite item, i.e backpack and try to use this feature, you will soon end up with like 40 map notes. Personally, I would prefer the note being deleted once I repicked my item. #75785 is a good example of this.

Describe the solution

With the current note system, full handling of this is difficult as one tile can have multiple notes at the same time, so we are going with a simple "good enough" approximation. If an item's tile only has one note containing its precise name, the note will be deleted. This doesn't cover all the cases, but vast majority of them.

The solution is not perfect. It only handles picking item up or wielding it. It does not work with hauling, auto sort and other esoteric options.

Describe alternatives you've considered

Refactor the notes system, storing each note added to a tile as a separate object instead of bundling everything into one raw string. Then an universal solution could be produced, capable of handling any case.

Gating the removal behind autonote option being enabled. For it to trigger falsely someone would have to make a map note be the precise display name of an item and then proceed to pick this item up in the same tile - highly improbable.

Testing

Favorited an item and tried:

  • Dropping and picking them up -> success
  • Dropping and wielding them -> success
  • Dropping and hauling them -> does not work + autonote feature itself does not work as well
  • Dropping and autosorting them -> does not work

solonkovda avatar Jun 13 '25 22:06 solonkovda

Refactor the notes system, storing each note added to a tile as a separate object instead of bundling everything into one raw string. Then an universal solution could be produced, capable of handling any case.

I were planning on just adding a std::optional<std::unordered_set<*item>> dropped_favorites (not itype_id bc it wants to use the user renamed name where appropriate) to om_note and appending the names on the end of the note when displayed (maybe with caching?) but I got bogged down trying to figure out how to deal with AIM and dragging etc at the same time

Procyonae avatar Jun 14 '25 00:06 Procyonae

@Procyonae Are you requesting a change or is this mergeable?

Maleclypse avatar Jun 17 '25 04:06 Maleclypse

This is good to go

Procyonae avatar Jun 18 '25 09:06 Procyonae