Skip to content

fix: scope randombot ownership by realm#2284

Open
scarecr0w12 wants to merge 12 commits intomod-playerbots:test-stagingfrom
scarecr0w12:fix/randombot-account-ownership
Open

fix: scope randombot ownership by realm#2284
scarecr0w12 wants to merge 12 commits intomod-playerbots:test-stagingfrom
scarecr0w12:fix/randombot-account-ownership

Conversation

@scarecr0w12
Copy link
Copy Markdown

Pull Request Description

This change prevents one worldserver from deleting another worldserver's randombot auth accounts when both realms share the same auth database.

It adds a shared auth-db ownership table, playerbots_account_ownership, keyed by account ID and owned RealmID, and updates randombot account creation, assignment, and deletion to operate only on accounts owned by the current realm.

For pre-existing legacy rndbot* accounts, the code will auto-adopt only accounts that are clearly attributable to a single realm. If an account has characters on multiple realms, it is treated as ambiguous and skipped instead of being auto-claimed.

Feature Evaluation

  • Describe the minimum logic required to achieve the intended behavior.

    • Add a lightweight ownership registry in the shared auth DB.
    • Claim newly created randombot accounts for the current RealmID.
    • Reuse/adopt only accounts owned by the current realm.
    • Skip legacy accounts that have characters on multiple realms.
    • Limit deletion to accounts owned by the current realm.
  • Describe the processing cost when this logic executes across many bots.

    • The ownership logic runs during randombot account discovery/creation/deletion, not during normal per-bot AI ticks.
    • It adds a few login-db queries while scanning existing rndbot* accounts on startup, but it does not add meaningful per-bot/per-trigger runtime overhead once the bot population is active.

How to Test the Changes

  1. Use two worldservers with different RealmID values sharing the same auth DB.
  2. Apply the auth SQL for playerbots_account_ownership to the shared auth database.
  3. Start server A and allow it to create/adopt randombot accounts.
  4. Start server B and verify it only creates/adopts accounts for its own realm.
  5. Set AiPlayerbot.DeleteRandomBotAccounts = 1 on server A and restart it.
  6. Verify only server A owned randombot accounts are deleted and server B owned accounts remain available.
  7. Create or identify a legacy rndbot* account with characters on multiple realms and restart a patched server.
  8. Verify the account is logged as ambiguous and is not auto-claimed.

Additional validation completed in this workspace:

  • Built worldserver successfully after the code changes.
  • Created the missing acore_auth.playerbots_account_ownership table and verified the server starts with the new logic.

Impact Assessment

  • Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots?

      • No, not at all
      • Minimal impact (explain below)
      • Moderate impact (explain below)
    • Explanation: the extra work happens during account adoption/discovery at startup and delete flows, not inside normal per-bot decision making or tick processing.

  • Does this change modify default bot behavior?

      • No
      • Yes (explain why)
    • Explanation: randombot account reuse, assignment, and deletion are now realm-scoped instead of global across all rndbot* auth accounts.

  • Does this change add new decision branches or increase maintenance complexity?

      • No
      • Yes (explain below)
    • Explanation: there is added migration/ownership logic for legacy shared-auth setups, including ambiguous-account detection for accounts with characters on multiple realms.

AI Assistance

Was AI assistance used while working on this change?

    • No
    • Yes (explain below)
  • Purpose of usage: investigation, code generation, and PR drafting.

  • Influenced/generated areas: ownership-table SQL, randombot account ownership/adoption logic, and PR text.

  • All generated code was reviewed, adjusted, rebuilt, and validated before submission.

Final Checklist

    • Stability is not compromised.
    • Performance impact is understood, tested, and acceptable.
    • Added logic complexity is justified and explained.
    • Any new bot dialogue lines are translated.
    • Documentation updated if needed (Conf comments, WiKi commands).

Notes for Reviewers

  • This PR targets test-staging as requested by the repository template.
  • The new shared auth table is required for the feature to work:
    • sql/auth/base/playerbots_account_ownership.sql
    • sql/auth/updates/2026_04_04_00_playerbots_account_ownership.sql
  • Ambiguous legacy accounts with characters on multiple realms are intentionally skipped rather than auto-claimed to avoid destructive migration behavior.

@scarecr0w12
Copy link
Copy Markdown
Author

Updated the PR with the latest realm-scoped randombot ownership changes.

Included in this update:

  • added playerbots_account_ownership auth SQL (base + update)
  • scoped randombot account adoption, creation, assignment, and deletion by RealmID
  • limited random account selection to accounts owned by the current realm
  • preserved ambiguous legacy-account handling so cross-realm accounts are skipped instead of auto-claimed

Validation completed:

  • ./acore.sh compiler build passed successfully in this workspace

@hermensbas
Copy link
Copy Markdown
Collaborator

You are running multiple world-servers against the same database?

@scarecr0w12
Copy link
Copy Markdown
Author

You are running multiple world-servers against the same database?

Shared Auth, Separate Character/World

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.

6 participants