feat: add SBPP_BanPlayerBySteamId native for offline player bans - #23
Open
Rushaway wants to merge 2 commits into
Open
feat: add SBPP_BanPlayerBySteamId native for offline player bans#23Rushaway wants to merge 2 commits into
Rushaway wants to merge 2 commits into
Conversation
Ports upstream sbpp#1511 onto the srcdslab fork. Adds SBPP_BanPlayerBySteamId, a native for banning players who are no longer connected to the server (TK managers, anti-cheat, etc.). It accepts a SteamID2 string and player name directly instead of a client index. - Validates SteamID2 format before inserting - Runs a duplicate-check SELECT first, skipping the INSERT on an active ban - Fires SBPP_OnBanPlayer with iTarget = -1 only after the INSERT succeeds - Falls back to a server-lookup subquery for sid when serverID == -1 Fork adaptation: the INSERT keeps the fork's admin_name column and the IFNULL((SELECT user FROM %s_admins ...)) subquery, matching the fork's UTIL_InsertBan / Native_SBBanPlayer statements. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Sigibert <christoph.ziegler@hotmail.de>
Rushaway
force-pushed
the
port/pr-1511
branch
from
September 3, 2026 08:56
4f62816 to
32ed879
Compare
Follow-up review pass on the sbpp#1511 port. - Grow the INSERT buffer from 1024 to 2048. The fork's extra admin_name column adds a second IFNULL((SELECT user FROM %s_admins ...)) subquery plus two more adminAuth expansions, pushing the worst-case rendering to ~1210 bytes (128-byte escaped authid, 64-byte escaped name, 256-byte escaped reason, four DatabasePrefix expansions). FormatEx would have silently truncated that into invalid SQL. - Size reasonEscaped as sizeof(reason) * 2 + 1 (257) instead of 256. SQL_EscapeString refuses to write anything when the destination is one byte short, so a 128-char reason of all quotes would have spliced an uninitialised buffer into the INSERT. - Replace the "STEAM_" prefix test with UTIL_IsValidSteamID2(), a full STEAM_X:Y:Z check. The INSERT slices authid[8] to build the '^STEAM_[0-9]:%s$' REGEXP, so "STEAM_junk" previously produced a garbage ban row instead of an error. The helper short-circuits before reading past the terminator on every truncated prefix. - Reject negative iTime, which would otherwise store a negative length and an ends timestamp in the past. - Bounds-check iAdmin before IsClientInGame()/g_sSteamIDs[] and require the ban flag, mirroring Native_SBBanPlayer. An out-of-range index previously faulted the native. - Normalise a non-live iAdmin to 0 so SBPP_OnBanPlayer subscribers never receive an unusable client index. - Use the callback's db handle rather than the global DB, make both callbacks public, and drop the "[SBPP] " log prefix, matching SelectAddbanCallback / InsertAddbanCallback. - Document the new error conditions on the native and the iTarget = -1 contract on the SBPP_OnBanPlayer forward. Verified with spcomp 1.12.0.7253: sbpp_main, sbpp_sleuth and sbpp_report all compile clean with no warnings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Sigibert <christoph.ziegler@hotmail.de>
Member
Author
Review: approve after fixes (pushed as
|
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.
Ports upstream sbpp#1511 onto the srcdslab fork.
What it adds
SBPP_BanPlayerBySteamId(int iAdmin, const char[] steamId, const char[] name, int iTime, const char[] sReason)— a native for recording a ban in the SBPP database for a player who is no longer connected (TK managers, anti-cheat, and other automated systems that fire after the target disconnects).SBPP_BanPlayerrequires a live client index; this native takes aSTEAM_0:X:Ystring and a display name instead.Behaviour (unchanged from upstream):
steamIdis not SteamID2 format.sidwhenserverID == -1.SBPP_OnBanPlayerwithiTarget = -1only after the INSERT succeeds.sourcebanspp.incgains the native declaration andMarkNativeAsOptional.Fork adaptations
The fork's
_bansINSERT statements carry an extraadmin_namecolumn populated by anIFNULL((SELECT user FROM %s_admins WHERE authid = ... OR authid REGEXP ...), '')subquery. The ported INSERT (both theserverID == -1and registered-server branches) was adjusted to include that column and subquery, matching the fork's existingUTIL_InsertBan/Native_SBBanPlayerqueries. No fork behaviour was reverted.Notes
plugin-buildworkflow.🤖 Generated with Claude Code