Skip to content

[SBPP Checker] Callback and initial values - #894

Open
DosMike wants to merge 3 commits into
sbpp:mainfrom
DosMike:feature/sbpp_checker/notify_on_bans_checked
Open

DosMike wants to merge 3 commits into
sbpp:mainfrom
DosMike:feature/sbpp_checker/notify_on_bans_checked

Conversation

@DosMike

@DosMike DosMike commented May 25, 2023 •

Copy link
Copy Markdown

Description

As user of the SourceBans Checker API I would like to be notified when the bans and commbans counters are actually valid, or at least be provided with fallback values until they are.

Motivation and Context

As of 1.8.0 the values in g_iBanCounts[client] and g_iCommsCounts[client] remain stale between a disconnect and the async OnConnectBanCheck callback. This might cause issues if you want to rely on, or react to these values as soon as they are available. If a plugin is polling values this would currently still give incorrect results for quite some time, even if the the client is ingame AND authorized, thus resetting the values to -1.

How Has This Been Tested?

  • Smoke test in dev server + live env

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@DosMike
DosMike marked this pull request as ready for review June 1, 2023 19:29
@Rushaway

Rushaway commented Jun 1, 2024

Copy link
Copy Markdown
Contributor
  • Can you change the version to 1.8.1 ?
  • Forward has to be created in the AskPluginLoad2

@DosMike

DosMike commented Jun 13, 2024

Copy link
Copy Markdown
Author
  • Can you change the version to 1.8.1 ?
  • Forward has to be created in the AskPluginLoad2

There you go :)

Rushaway added a commit to srcdslab/sourcebans-pp that referenced this pull request Sep 3, 2026
…ial values

Ports upstream sbpp#894.

- Initialize g_iBanCounts/g_iMuteCounts/g_iGagCounts to -1 so the natives
  report "not yet available" rather than stale values before the async
  OnConnectBanCheck callback resolves.
- Reset those counts to -1 in OnClientDisconnect_Post.
- Add global forward SBPP_CheckerClientBanCheckPost(int iClient), created in
  AskPluginLoad2 and fired from OnConnectBanCheck once counts are populated
  (before the PrintCheckOnConnect guard so it always runs).
- Document the new -1 return contract and the forward in the include.

Adapted to fork divergence: fork splits comms into separate mute/gag counts
and uses SB_VERSION, so no manual VERSION bump; forward creation lives in the
fork's AskPluginLoad2 alongside g_bLate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: DosMike <xanatosefan@gmx.de>
Rushaway added a commit to srcdslab/sourcebans-pp that referenced this pull request Sep 6, 2026
* feat(checker): add SBPP_CheckerClientBanCheckPost forward and -1 initial values

Ports upstream sbpp#894.

- Initialize g_iBanCounts/g_iMuteCounts/g_iGagCounts to -1 so the natives
  report "not yet available" rather than stale values before the async
  OnConnectBanCheck callback resolves.
- Reset those counts to -1 in OnClientDisconnect_Post.
- Add global forward SBPP_CheckerClientBanCheckPost(int iClient), created in
  AskPluginLoad2 and fired from OnConnectBanCheck once counts are populated
  (before the PrintCheckOnConnect guard so it always runs).
- Document the new -1 return contract and the forward in the include.

Adapted to fork divergence: fork splits comms into separate mute/gag counts
and uses SB_VERSION, so no manual VERSION bump; forward creation lives in the
fork's AskPluginLoad2 alongside g_bLate.

Co-authored-by: DosMike <xanatosefan@gmx.de>

* review fixes

- SBPP_CheckerGetClientsComms returned -2 (the sum of two -1 sentinels)
  before the check resolved, breaking the "-1 if not yet available"
  contract the include now documents. Return -1 when either half is
  unavailable.
- OnConnectBanCheck only assigns the mute/gag counters from optional
  FetchRow() branches. If the result set ever came back short, those
  stayed at -1 while the ban count was populated, making commcount
  negative and firing bogus "Comm Warning" prints (the `if (commcount)`
  truthiness test passes for -1/-2). Clear the sentinel on both counters
  once the check completes, so post-check values are always >= 0.

This branch has not been deployed

No deployments
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.

2 participants