Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid client index in Basebans menu #1998

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Commits on May 11, 2023

  1. Fix invalid client index in Basebans menu

    Fix alliedmodders#1768
    
    The `sm_admin`-triggered Menu flow for banning players is caching client
    indices inside the basebans.sp `PlayerInfo` struct, and can then
    incorrectly use them in the menu callback without checking for the
    related client's UserId validity. This leads to bug alliedmodders#1768 occurring when
    the ban target player disconnects from the server before the banning
    admin could complete the banmenu UI flow.
    
    Since the related menu callbacks can't rely on the cached client index,
    I have removed the basebans.sp `PlayerInfo.banTarget` member entirely,
    in favor of the `PlayerInfo.banTarget`, and instead call
    `GetClientOfUserId(...)` to get & validate the target client index where
    necessary. The `PrepareBan(...)` function has been refactored to take a
    ban target UserId (instead of the target client index) accordingly.
    Rainyan committed May 11, 2023
    Configuration menu
    Copy the full SHA
    bf72128 View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2023

  1. Use auth strings when banning from menu

    When an admin initiates a ban from a BaseBans GUI menu, track players by
    their AuthId (SteamID) instead of userid, so that the admin is able to
    target players who disconnect after that menu was constructed.
    
    If the target player is still connected, use their userid to ban the
    same as before this commit.
    
    If the target has disconnected, write a ban using their stored AuthId
    value, as with "sm_addban".
    
    This commit also revertss the `(admin==0)` check from PrepareBan that
    was mistakenly added by bf72128,
    because it would prevent banning from server/RCON (client index 0).
    Rainyan committed Oct 15, 2023
    Configuration menu
    Copy the full SHA
    f9ec381 View commit details
    Browse the repository at this point in the history
  2. Use userid to find client when possible

    Only fall back to authid lookup if userid no longer resolved to client index
    Rainyan committed Oct 15, 2023
    Configuration menu
    Copy the full SHA
    5ac6be0 View commit details
    Browse the repository at this point in the history
  3. Refactor

    In function "PrepareBan", use the global PlayerInfo struct array
    members directly, instead of passing them as function parameters.
    Rainyan committed Oct 15, 2023
    Configuration menu
    Copy the full SHA
    67f5fcd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9b06d85 View commit details
    Browse the repository at this point in the history
  5. Fix client validity checks

    Unify the client validity checks with AddTargetsToMenuByAuthId checks
    Rainyan committed Oct 15, 2023
    Configuration menu
    Copy the full SHA
    3b6f18e View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2023

  1. Use MAX_TARGET_LENGTH

    Use MAX_TARGET_LENGTH over defining a new custom length
    Rainyan committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    69988c8 View commit details
    Browse the repository at this point in the history