Bug fixes and code refactor#10538
Merged
Merged
Conversation
|
|
|
This plugin requires reviews from Plugin Hub reviewers. The reviewer will request any additional changes if needed. Internal use only: Reviewer details Maintainer details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Big thanks to zneix for this update. He has been added as a collaborator to help maintain, as well as added to the authors.
Core changes
Switched to using Varbit NEX_BARRIER which allows to tell exactly when Nex died, player left or if Nex is alive - this removes need for scanning list of all npcs around each tick.
Using Nex's overhead text to track fight start down to exact starting tick (it's always 4 ticks after "Fill my soul with smoke!")
Kills are also correctly flagged as either finished or cancelled now through state tracking - only finished kills count towards the averages now which resolves the core problem of Worley03/nex-droprate-calculator#1
Switched the way overlay is handled: as per suggestion from a friend experienced with runelite plugins, overlay is only added/removed at start/shutdown. render function automatically handles config changes
Because of this, listener onConfigChanged was removed since it's unnecessary
Player average calculation is done through weighted division of how many players were present each tick - this represents the average amount of players across whole kill more accurately
Bugfixes
Fights do not get added to averages unless they were fully finished (easy thanks to varbit tracking)
Minutes were not correctly calculated in duration function and would display over 60 minutes if a fight was gonna take this long (I know that's likely not gonna happen, but still)
This also removes redundant roundings and I decided to add decimal fraction of seconds to display correct timing
Showing contribution in green if contribution is also equal to treshold - this makes it appear green in solo kills which I sometimes do
Unique drop chance calculation used to be calculated before accounting for contribution own & total from a given tick which resulted in 1/2147483647 being shown on overlay for 1 tick as well as lagging behind by a tick with actual values
MVP & min contribution checks were updated - in a rare occasion where player didn't get minimal contribution but someone received a unique drop, that'd still be broadcasted as a chat message and be falsely assumed player qualified when they didn't
Small new things
Due to switch in player average calculation, I decided that in event of players leaving mid-kill to show "current players / players when started" format on the overlay. I think it looks good and is more useful than showing average number of players, but if desired, this can be easily changed to display the average instead, example:
playercount_on_overlay
Added precise timing to the panel's time tracking, time is now tracked accurately from very first tick to exact last one, so the panel could be now used as a reference for ongoing kill better,
Example Screenshot - ingame fight time matches panel (click to expand)
More Detailed code style changes
Replaced deprecated runelite api usages with equivalents
Defined config keys as constants in Config class
Moved couple helper/data formatting functions into a new Utils class
Introduced RunState class for more organised run state categorisation & tracking
Current and last runs as well as averages are all tracked under the Panel class which eliminates duplication of having to update currentRun on both panel & overlay
Removed excessive functions for setting lastRun & resetting averages - this is mostly achieved due to moving things out of NexDroprateCalculatorRun class and delegating it into RunAverages inside NexDroprateCalculatorPanel
Moved UI creation away from init function into separate classes RunDisplaySection & AverageDisplaySection which have shared elements stored in the parent abstract class DisplaySection - this helps to avoid hardcoding default values while defining UI elements and keepings things more organised
deinit function for panel was removed since it's already being set to null inside shutDown function
Formatting for these is done through new Formatter class and eliminates duplicating of HTML strings
Overlay rendering is done through adding each element which is cleaner and allows for adding new elements (I wanted to include pet drop chance there later) later & also removes array allocating which is better optimisation
... Few smaller duplication removals and overall attempt at objectifying things better, keeping them in 1 place
Summary by CodeRabbit
New Features
Configurable overlay toggle with right-click context-menu access
New run states enum for clearer run status
Utility formatting for durations and fraction display
Improvements
Modular, redesigned panel with separate run and averages sections
Event-driven, more accurate fight/run tracking (contributions, MVP/minimum)
Streamlined run lifecycle and aggregated per-hour/per-run metrics with reset control
Refactor
Simplified run and overlay logic for clearer, more maintainable behavior