Wynntils / Wynntils-Legacy

Wynntils is a Wynncraft Mod that seeks to enhance the user's gameplay with a variety of customizable options and additions.
https://wynntils.com
GNU Affero General Public License v3.0
158 stars 91 forks source link

fix: mythic detection & /guild list spam #594

Closed byBackfish closed 2 years ago

byBackfish commented 2 years ago

Fixes mythics in chests not being detected by Wynntils Removes the /guild list spam

The problem with the mythic's not being detected, was that Wynn sends two item change packets. One with empty items, one with the actual items. This PR makes Wynntils ignore the first, empty, packet and only handle the second, actual, packet. Before, Wynntils would only check the first packet, and then ignore the second, as the lastProcessedChestID was the same as the ID of the second packet

magicus commented 2 years ago

I looked through the code with more context. I just can't understand how this patch is supposed to fix the stated problem "mythics in chests not being detected by Wynntils". All you are doing is adding a quick way out if there are no "actual" items in the container. I was thinking I'd see another use of actualItems where it was iterated over, looking for a mythic.

byBackfish commented 2 years ago

Wynncraft sends the chest items twice. The first time, everything is empty. Shortly after, the actual items "generate". So that the chest doesn't get handled twice, there is a check "if last Processed Chest == this Chest, then return". This would only take the first, empty, chest contents, and ignore the actual items. By adding this check, if the chest contains items or is empty, and then returning early. By doing this, the lastProcessedChestId is only set, if the chest contains items. This way, the first packet with the empty items is ignored, and only the second packet with the actual items is handled

magicus commented 2 years ago

Aha, I see. I think it would be great if you could include this description as a comment (possibly shorted down a bit).

byBackfish commented 2 years ago

👍