Skip to content

fix: add rate limiting to party analyzer updates - #3728

Merged
dudantas merged 3 commits into
mainfrom
dudantas/add-party-tracker-limit-update
Jan 31, 2026
Merged

fix: add rate limiting to party analyzer updates#3728
dudantas merged 3 commits into
mainfrom
dudantas/add-party-tracker-limit-update

Conversation

@dudantas

@dudantas dudantas commented Oct 13, 2025

Copy link
Copy Markdown
Member

Introduces a 1-second interval between party analyzer updates by tracking the next allowed update time. This prevents excessive updates and improves network efficiency.

Summary by CodeRabbit

  • Bug Fixes
    • Applied rate limiting to party tracker analyzer updates to prevent excessive updates (max ~1s).
    • Ensures an immediate/forced party analytics refresh after key party actions so analytics remain up-to-date.

✏️ Tip: You can customize this high-level summary in your review settings.

Introduces a 1-second interval between party analyzer updates by tracking the next allowed update time. This prevents excessive updates and improves network efficiency.
Copilot AI review requested due to automatic review settings October 13, 2025 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Adds rate limiting to party analyzer updates to prevent excessive network requests by implementing a 1-second cooldown mechanism. This ensures updates are throttled to improve network efficiency and performance.

Key changes:

  • Added a member variable to track the next allowed update time
  • Implemented rate limiting logic in the update function with a 1-second interval

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/server/network/protocol/protocolgame.hpp Added member variable to track next allowed party analyzer update time
src/server/network/protocol/protocolgame.cpp Implemented rate limiting logic with 1-second cooldown in update function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sonarqubecloud

Copy link
Copy Markdown

@libergod libergod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works perfectly with #3725

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions Bot added the Stale No activity label Nov 13, 2025
@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a throttled, optional-forced update mechanism for party analytics: a new per-connection timestamp member prevents updates more than once per 1000ms, and updatePartyTrackerAnalyzer gained a bool force parameter to bypass the throttle when true.

Changes

Cohort / File(s) Summary
ProtocolGame implementation
src/server/network/protocol/protocolgame.cpp
Added in-file constant PARTY_ANALYZER_THROTTLE_MS = 1000 and throttle logic in updatePartyTrackerAnalyzer, resetting m_nextPartyAnalyzerUpdate when forced and gating updates otherwise. Updated one call-site to pass true.
ProtocolGame declaration
src/server/network/protocol/protocolgame.hpp
Changed signature updatePartyTrackerAnalyzer(const std::shared_ptr<Party>&, bool force = false) and added private member uint64_t m_nextPartyAnalyzerUpdate = 0.
Player implementation
src/creatures/players/player.cpp
Adjusted Player::updatePartyTrackerAnalyzer to accept bool force and forward it to the client updatePartyTrackerAnalyzer.
Player declaration
src/creatures/players/player.hpp
Changed public API: void updatePartyTrackerAnalyzer(bool force = false) const; (replaces parameterless version).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudge the party, then pause to rest,
A thousand ticks to do my best,
Sometimes I shove — sometimes I wait,
Throttle and hop, I celebrate! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding rate limiting (throttling) to party analyzer updates, which is the core objective of the pull request.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dudantas/add-party-tracker-limit-update

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: 1

🤖 Fix all issues with AI agents
In `@src/server/network/protocol/protocolgame.cpp`:
- Around line 8488-8494: The current 1s throttle using m_nextPartyAnalyzerUpdate
blocks immediate UI refreshes for explicit user actions; update the party
analyzer update path (where m_nextPartyAnalyzerUpdate and the time check are
used in protocolgame.cpp) so that user-driven events (e.g., handling
PARTYANALYZERACTION_PRICEVALUE) either pass a force flag to skip the rate-check
or reset m_nextPartyAnalyzerUpdate = 0 before calling the update routine to
guarantee an immediate refresh; also replace the literal 1000 with a named
constant (e.g., PARTY_ANALYZER_THROTTLE_MS) and document the per-connection
threading assumption near the code.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67412a8 and 110cbc0.

📒 Files selected for processing (2)
  • src/server/network/protocol/protocolgame.cpp
  • src/server/network/protocol/protocolgame.hpp
🧰 Additional context used
🧬 Code graph analysis (1)
src/server/network/protocol/protocolgame.cpp (2)
src/utils/tools.cpp (2)
  • OTSYS_TIME (1561-1566)
  • OTSYS_TIME (1561-1561)
src/utils/tools.hpp (1)
  • OTSYS_TIME (167-167)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: macos-macos-debug
  • GitHub Check: macos-macos-release
  • GitHub Check: ubuntu-22.04-linux-release
  • GitHub Check: ubuntu-22.04-linux-debug
  • GitHub Check: ubuntu-24.04-linux-release
  • GitHub Check: ubuntu-24.04-linux-debug
  • GitHub Check: windows-2022-windows-release
  • GitHub Check: build_docker_x86
  • GitHub Check: build_docker_arm
🔇 Additional comments (1)
src/server/network/protocol/protocolgame.hpp (1)

560-561: LGTM!

The member variable addition is well-designed:

  • uint64_t is appropriate for millisecond timestamp storage
  • Default initialization to 0 ensures the first update proceeds immediately
  • Naming follows the m_ prefix convention used for other members like m_playerDeathTime

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread src/server/network/protocol/protocolgame.cpp
@github-actions github-actions Bot removed the Stale No activity label Jan 15, 2026
@sonarqubecloud

Copy link
Copy Markdown

@dudantas
dudantas merged commit 76604c7 into main Jan 31, 2026
38 checks passed
@dudantas
dudantas deleted the dudantas/add-party-tracker-limit-update branch January 31, 2026 07:49
freestyle-Pdg pushed a commit to freestyle-Pdg/canary that referenced this pull request Mar 29, 2026
Bug Fixes:
- Applied rate limiting to party tracker analyzer updates to prevent
excessive updates (max ~1s).
- Ensures an immediate/forced party analytics refresh after key party
actions so analytics remain up-to-date.
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.

4 participants