Skip to content

Fixes for buffing and party invites#13

Merged
kis1yi merged 2 commits into
Silkroad-Developer-Community:mainfrom
kis1yi:pt-buffs
Jun 2, 2026
Merged

Fixes for buffing and party invites#13
kis1yi merged 2 commits into
Silkroad-Developer-Community:mainfrom
kis1yi:pt-buffs

Conversation

@kis1yi

@kis1yi kis1yi commented Jun 2, 2026

Copy link
Copy Markdown
Member
  • Buffs and attack speed have been significantly increased by fixing the buffs' callback
  • Fixed a bug that caused party settings to be reset when inviting players after the party was disbanded
  • Added logging of the server closing the gateway connection before establishing a handshake

Summary by CodeRabbit

  • New Features

    • Party auto-settings now initialize when the bot joins parties.
  • Bug Fixes

    • Fixed buff removal to properly match buffs by identifier.
    • Improved connection handling to detect gateway disconnections during handshake.
    • Corrected expired buff handling to fire removal events properly.
  • Refactor

    • Enhanced skill casting callback system for improved action-state validation.

- Buffs and attack speed have been significantly increased by fixing the buffs' callback
- Fixed a bug that caused party settings to be reset when inviting players after the party was disbanded
- Added logging of the server closing the gateway connection before establishing a handshake
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kis1yi, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 6 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 16acf190-56ed-47e9-8074-f68ab9bbdd94

📥 Commits

Reviewing files that changed from the base of the PR and between 9959b98 and b777398.

📒 Files selected for processing (1)
  • Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs
📝 Walkthrough

Walkthrough

This PR improves buff casting reliability and event consistency across skill management, network handling, and UI state. It adds network handshake detection to prevent premature gateway disconnections, refactors skill casting with refined callback logic and timeout handling, aligns buff removal events with UI matching logic, and initializes party settings automatically based on bot configuration.

Changes

Buff Casting and Event Consistency

Layer / File(s) Summary
Network Socket Handshake and Error Handling
Library/RSBot.Core/Network/Socket/Server.cs
Server class adds two boolean flags to track handshake state, derives opcodes from received packets to detect premature gateway closure after 0x5000, updates handshake flags before protocol processing, and simplifies error handling by removing verbose logging and tightening socket exception behavior.
Skill Casting Flow Refactoring
Library/RSBot.Core/Components/SkillManager.cs
CastBuff method replaces previous two-callback flow with castCallback and actionStateCallback; packet dispatch behavior now depends on awaitBuffResponse and Basic_Activity flags; computed timeout based on casting/action/preparing times is used to await cast completion and conditionally await action-state completion.
Buff Removal Event and UI Consistency
Botbases/RSBot.Training/Bundle/Buff/BuffBundle.cs, Plugins/RSBot.Skills/Views/Main.cs
BuffBundle fires OnRemoveBuff event using the active-buff info object and resolves playerSkill by info.Id; Skills/Main simplifies buff-list item removal matching to use only Token equality, ensuring UI state aligns with removal events.

Party Auto-Settings Initialization

Layer / File(s) Summary
Party Settings Refresh in Invite Check
Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs
CheckForPlayers now assigns Game.Party.Settings with a new PartySettings instance when the bot is not in a party, using Config values for experience auto-share, item auto-share, and invitation allowance, before the existing CanInvite guard.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit's code hops through the night,
Buff events glow with token light,
Sockets handshake, clean and true,
Party settings sparkle new! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main changes: it addresses fixes for buffing mechanics (callback corrections in BuffBundle and SkillManager) and party invite handling (AutoPartyBundle settings fix).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs (1)

73-78: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Extract duplicated settings initialization logic.

This initialization logic is duplicated at lines 166-171 in CheckForPlayers(). Consider extracting it into a private helper method like InitializePartySettingsFromConfig() to adhere to the DRY principle and simplify future maintenance.

♻️ Proposed refactor to eliminate duplication
+    private void InitializePartySettingsFromConfig()
+    {
+        if (!Game.Party.IsInParty)
+            Game.Party.Settings = new PartySettings(
+                Config.ExperienceAutoShare,
+                Config.ItemAutoShare,
+                Config.AllowInvitations
+            );
+    }
+
     public void Refresh()
     {
         Config = new AutoPartyConfig
         {
             // ... existing config initialization ...
         };

-        if (!Game.Party.IsInParty)
-            Game.Party.Settings = new PartySettings(
-                Config.ExperienceAutoShare,
-                Config.ItemAutoShare,
-                Config.AllowInvitations
-            );
+        InitializePartySettingsFromConfig();
     }

Then replace lines 166-171 with a call to InitializePartySettingsFromConfig().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs` around lines 73 -
78, Extract the duplicated PartySettings initialization into a private helper:
create InitializePartySettingsFromConfig() that sets Game.Party.Settings = new
PartySettings(Config.ExperienceAutoShare, Config.ItemAutoShare,
Config.AllowInvitations) and call this helper in both the current location and
inside CheckForPlayers() instead of duplicating the constructor call; ensure the
helper is private and used wherever those three Config fields are applied to
Game.Party.Settings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Library/RSBot.Core/Components/SkillManager.cs`:
- Around line 487-499: The current code reuses the full timeout for both
castCallback.AwaitResponse and actionStateCallback.AwaitResponse, effectively
doubling the allowed wait; change to compute a single deadline (e.g., now +
timeout) before calling castCallback.AwaitResponse, then after castCallback
returns compute the remaining time (deadline - now) and pass only that remaining
timeout to actionStateCallback.AwaitResponse (and return immediately if
remaining <= 0); reference the existing symbols castCallback,
actionStateCallback, AwaitResponse, IsCompleted, and the timeout calculation
using skill.Record.Action_CastingTime/Action_ActionDuration/Action_PreparingTime
to implement this.

In `@Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs`:
- Around line 166-171: Add a null-guard at the start of CheckForPlayers(): if
Config is null, bail out (return) or skip logic that reads Config to avoid
NullReferenceException; specifically protect usages such as Game.Party.Settings
= new PartySettings(Config.ExperienceAutoShare, Config.ItemAutoShare,
Config.AllowInvitations) and all other accesses to Config within
CheckForPlayers() (e.g., the conditions referencing Config at the spots around
the Game.Party checks and subsequent logic). Ensure Refresh() still initializes
Config later, so the guard simply prevents early execution when Config is
missing rather than changing initialization flow.

---

Outside diff comments:
In `@Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs`:
- Around line 73-78: Extract the duplicated PartySettings initialization into a
private helper: create InitializePartySettingsFromConfig() that sets
Game.Party.Settings = new PartySettings(Config.ExperienceAutoShare,
Config.ItemAutoShare, Config.AllowInvitations) and call this helper in both the
current location and inside CheckForPlayers() instead of duplicating the
constructor call; ensure the helper is private and used wherever those three
Config fields are applied to Game.Party.Settings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b8bdc54-5f69-465b-8398-0b7dedcc7c05

📥 Commits

Reviewing files that changed from the base of the PR and between 32c2fc0 and 9959b98.

📒 Files selected for processing (5)
  • Botbases/RSBot.Training/Bundle/Buff/BuffBundle.cs
  • Library/RSBot.Core/Components/SkillManager.cs
  • Library/RSBot.Core/Network/Socket/Server.cs
  • Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs
  • Plugins/RSBot.Skills/Views/Main.cs

Comment on lines +487 to +499
var timeout =
skill.Record.Action_CastingTime
+ skill.Record.Action_ActionDuration
+ skill.Record.Action_PreparingTime
+ 1500;

castCallback.AwaitResponse(timeout);

if (skill.Record.Basic_Activity != 1 && awaitBuffResponse)
callback.AwaitResponse();
if (!castCallback.IsCompleted)
return;

if (skill.Record.Basic_Activity != 1)
actionStateCallback.AwaitResponse(timeout);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep a single timeout budget for the full cast lifecycle.

timeout already models the whole cast window. Reusing that full value for actionStateCallback.AwaitResponse(...) can block almost 2× that budget when the 0xB070 response arrives late, which slows the non-basic buff path and attack loop. Carry a deadline forward and wait only on the remaining time for the second callback.

⏱️ Proposed fix
         var timeout =
             skill.Record.Action_CastingTime
             + skill.Record.Action_ActionDuration
             + skill.Record.Action_PreparingTime
             + 1500;
+        var deadline = Environment.TickCount64 + timeout;
 
         castCallback.AwaitResponse(timeout);
 
         if (!castCallback.IsCompleted)
             return;
 
         if (skill.Record.Basic_Activity != 1)
-            actionStateCallback.AwaitResponse(timeout);
+        {
+            var remaining = (int)Math.Max(0L, deadline - Environment.TickCount64);
+            actionStateCallback.AwaitResponse(remaining);
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var timeout =
skill.Record.Action_CastingTime
+ skill.Record.Action_ActionDuration
+ skill.Record.Action_PreparingTime
+ 1500;
castCallback.AwaitResponse(timeout);
if (skill.Record.Basic_Activity != 1 && awaitBuffResponse)
callback.AwaitResponse();
if (!castCallback.IsCompleted)
return;
if (skill.Record.Basic_Activity != 1)
actionStateCallback.AwaitResponse(timeout);
var timeout =
skill.Record.Action_CastingTime
skill.Record.Action_ActionDuration
skill.Record.Action_PreparingTime
1500;
var deadline = Environment.TickCount64 + timeout;
castCallback.AwaitResponse(timeout);
if (!castCallback.IsCompleted)
return;
if (skill.Record.Basic_Activity != 1)
{
var remaining = (int)Math.Max(0L, deadline - Environment.TickCount64);
actionStateCallback.AwaitResponse(remaining);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Library/RSBot.Core/Components/SkillManager.cs` around lines 487 - 499, The
current code reuses the full timeout for both castCallback.AwaitResponse and
actionStateCallback.AwaitResponse, effectively doubling the allowed wait; change
to compute a single deadline (e.g., now + timeout) before calling
castCallback.AwaitResponse, then after castCallback returns compute the
remaining time (deadline - now) and pass only that remaining timeout to
actionStateCallback.AwaitResponse (and return immediately if remaining <= 0);
reference the existing symbols castCallback, actionStateCallback, AwaitResponse,
IsCompleted, and the timeout calculation using
skill.Record.Action_CastingTime/Action_ActionDuration/Action_PreparingTime to
implement this.

Comment thread Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs Outdated
@kis1yi kis1yi merged commit 745afe0 into Silkroad-Developer-Community:main Jun 2, 2026
1 of 2 checks passed
@kis1yi kis1yi deleted the pt-buffs branch June 2, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant