feat: online players get grant changes at once

Adding or removing a grant sends the existing PLAYER_ACTION refresh through master to every world: REFRESH_ACCOUNT
for an account's grants, REFRESH_CHARACTER for a character's. A world with that account's sessions (or the loaded
character) drops the grants it kept, so the next command reads them again: no relog. The dashboard toasts whether the
player was online. The dashboard's own open pages already get the new rights on their next request, and their
WebSockets are checked again.

Check: with a character in game, grant it /spawn on the dashboard (toast: "Applied in game at once") and use /spawn
without relogging; remove the grant and /spawn is refused again at once. With the player offline the toast says it
applies when they next play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 01:13:35 -05:00
parent e00d22152e
commit 641fd72969
3 changed files with 28 additions and 9 deletions

View File

@@ -48,10 +48,12 @@ namespace {
return static_cast<uint32_t>(users.size());
}
// Pick up a GM level change: lower the in-game level if it now exceeds the account's maximum
// Pick up a GM level change: lower the in-game level if it now exceeds the account's maximum. Also a change of the
// account's permission grants: they are read again the next time a command is used
uint32_t RefreshAccount(uint32_t accountId) {
const auto users = UserManager::Instance()->GetUsersForAccount(accountId);
if (users.empty()) return 0;
for (auto* user : users) user->ForgetGrants();
const auto info = Database::Get()->GetAccountInfo(users.front()->GetUsername());
if (!info) return 0;
@@ -83,10 +85,12 @@ namespace {
return static_cast<uint32_t>(users.size());
}
// Restrictions or permission grants of a character changed
uint32_t RefreshCharacter(LWOOBJID characterId) {
auto* entity = PlayerManager::GetPlayer(characterId);
auto* character = entity ? entity->GetCharacter() : nullptr;
if (!character) return 0;
if (auto* user = character->GetParentUser()) user->ForgetGrants();
const auto info = Database::Get()->GetCharacterInfo(characterId);
if (!info) return 0;