From 2eb12e6bb35b53b3a1bb94640a927b1b462833ec Mon Sep 17 00:00:00 2001 From: Trevor Date: Fri, 15 May 2020 15:29:29 -0400 Subject: [PATCH] raid plugin: fix plugin not reseting when prescouting raids If you left a raid while a raid was currently being scouted/held in the same world then there was a chance the plugin would not reset and the scout overlay and timer would break. This was due to the plugin thinking that the player was in a raid party when he left and did not reset. This was fixed by reseting whenever the raid party varp changed while the player is outside of the raid. steps to reproduce: start a raid on account 1 scout another raid in the same world on account 2 leave the raid on account 1 and it will not reset correctly --- .../main/java/net/runelite/api/VarPlayer.java | 9 +++++++ .../client/plugins/raids/RaidsOverlay.java | 2 +- .../client/plugins/raids/RaidsPlugin.java | 24 ++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java index 3c6c616599..d9ea173d19 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java +++ b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java @@ -54,6 +54,15 @@ public enum VarPlayer SPECIAL_ATTACK_PERCENT(300), SPECIAL_ATTACK_ENABLED(301), + /** + * The ID of the party. This Var is only set in the raid bank area and the raid lobby + * + * This gets set to -1 when the raid starts. This is first set when the first player of the clan forms a party + * on the recruiting board and it changes again when the first person actually enters the raid. + * + * -1 : Not in a party or in the middle of an ongoing raid + * Anything else : This means that your clan has a raid party being formed and has not started yet + */ IN_RAID_PARTY(1427), NMZ_REWARD_POINTS(1060), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java index 9a7b0f9d69..605b504356 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java @@ -222,6 +222,6 @@ public class RaidsOverlay extends OverlayPanel } } - return plugin.isInRaidParty() && config.scoutOverlayAtBank(); + return plugin.getRaidPartyID() != -1 && config.scoutOverlayAtBank(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 3fa404ca88..c75b15f69b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -199,11 +199,14 @@ public class RaidsPlugin extends Plugin @Getter private boolean inRaidChambers; - // if the player is in a raid party or not - // This will be set when someone in the clan chat clicks the "make party button on the raids widget - // It will be reset when the raid ends but not if they leave the raid while it has not started yet + /* + * if the player is in a raid party or not + * This will be set when someone in the clan chat clicks the "make party" button on the raids widget + * It will change again when someone from your clan enters the raid to generate it + * It will be reset when the raid starts but not if they leave the raid while it has not started yet + */ @Getter - private boolean inRaidParty; + private int raidPartyID; private boolean chestOpened; private RaidsTimer timer; @@ -301,21 +304,20 @@ public class RaidsPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - boolean tempInParty = client.getVar(VarPlayer.IN_RAID_PARTY) != -1; + int tempPartyID = client.getVar(VarPlayer.IN_RAID_PARTY); boolean tempInRaid = client.getVar(Varbits.IN_RAID) == 1; // if the player's party state has changed - if (tempInParty != inRaidParty) + if (tempPartyID != raidPartyID) { - // if the player is no longer in a party then reset - if (!tempInParty - && loggedIn + // if the player is outside of a raid when the party state changed + if (loggedIn && !tempInRaid) { reset(); } - inRaidParty = tempInParty; + raidPartyID = tempPartyID; } // if the player's raid state has changed @@ -449,7 +451,7 @@ public class RaidsPlugin extends Plugin } else { - if (!inRaidParty) + if (raidPartyID == -1) { reset(); }