Propagate client admin status to WorldServers

This commit is contained in:
Kae 2024-07-20 05:35:06 +10:00
parent 42c8933f55
commit f46d796253
5 changed files with 9 additions and 7 deletions

View File

@ -835,7 +835,7 @@ void UniverseServer::warpPlayers() {
// Checking the spawn target validity then adding the client is not // Checking the spawn target validity then adding the client is not
// perfect, it can still become invalid in between, if we fail at // perfect, it can still become invalid in between, if we fail at
// adding the client we need to warp them back. // adding the client we need to warp them back.
if (toWorld && toWorld->addClient(clientId, warpToWorld.target, !clientContext->remoteAddress())) { if (toWorld && toWorld->addClient(clientId, warpToWorld.target, !clientContext->remoteAddress(), clientContext->canBecomeAdmin())) {
clientContext->setPlayerWorld(toWorld); clientContext->setPlayerWorld(toWorld);
m_chatProcessor->joinChannel(clientId, printWorldId(warpToWorld.world)); m_chatProcessor->joinChannel(clientId, printWorldId(warpToWorld.world));

View File

@ -209,7 +209,7 @@ bool WorldServer::spawnTargetValid(SpawnTarget const& spawnTarget) const {
return true; return true;
} }
bool WorldServer::addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal) { bool WorldServer::addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal, bool isAdmin) {
if (m_clientInfo.contains(clientId)) if (m_clientInfo.contains(clientId))
return false; return false;
@ -245,6 +245,7 @@ bool WorldServer::addClient(ConnectionId clientId, SpawnTarget const& spawnTarge
auto& clientInfo = m_clientInfo.add(clientId, make_shared<ClientInfo>(clientId, tracker)); auto& clientInfo = m_clientInfo.add(clientId, make_shared<ClientInfo>(clientId, tracker));
clientInfo->local = isLocal; clientInfo->local = isLocal;
clientInfo->admin = isAdmin;
auto worldStartPacket = make_shared<WorldStartPacket>(); auto worldStartPacket = make_shared<WorldStartPacket>();
auto& templateData = worldStartPacket->templateData = m_worldTemplate->store(); auto& templateData = worldStartPacket->templateData = m_worldTemplate->store();
@ -2387,7 +2388,7 @@ bool WorldServer::isVisibleToPlayer(RectF const& region) const {
} }
WorldServer::ClientInfo::ClientInfo(ConnectionId clientId, InterpolationTracker const trackerInit) WorldServer::ClientInfo::ClientInfo(ConnectionId clientId, InterpolationTracker const trackerInit)
: clientId(clientId), skyNetVersion(0), weatherNetVersion(0), pendingForward(false), started(false), interpolationTracker(trackerInit) {} : clientId(clientId), skyNetVersion(0), weatherNetVersion(0), pendingForward(false), started(false), local(false), admin(false), interpolationTracker(trackerInit) {}
List<RectI> WorldServer::ClientInfo::monitoringRegions(EntityMapPtr const& entityMap) const { List<RectI> WorldServer::ClientInfo::monitoringRegions(EntityMapPtr const& entityMap) const {
return clientState.monitoringRegions([entityMap](EntityId entityId) -> Maybe<RectI> { return clientState.monitoringRegions([entityMap](EntityId entityId) -> Maybe<RectI> {

View File

@ -87,7 +87,7 @@ public:
// Returns false if the client id already exists, or the spawn target is // Returns false if the client id already exists, or the spawn target is
// invalid. // invalid.
bool addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal); bool addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal, bool isAdmin = false);
// Removes client, sends the WorldStopPacket, and returns any pending packets // Removes client, sends the WorldStopPacket, and returns any pending packets
// for that client // for that client
@ -277,6 +277,7 @@ private:
bool pendingForward; bool pendingForward;
bool started; bool started;
bool local; bool local;
bool admin;
List<PacketPtr> outgoingPackets; List<PacketPtr> outgoingPackets;

View File

@ -66,10 +66,10 @@ bool WorldServerThread::spawnTargetValid(SpawnTarget const& spawnTarget) {
} }
} }
bool WorldServerThread::addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal) { bool WorldServerThread::addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal, bool isAdmin) {
try { try {
RecursiveMutexLocker locker(m_mutex); RecursiveMutexLocker locker(m_mutex);
if (m_worldServer->addClient(clientId, spawnTarget, isLocal)) { if (m_worldServer->addClient(clientId, spawnTarget, isLocal, isAdmin)) {
m_clients.add(clientId); m_clients.add(clientId);
return true; return true;
} }

View File

@ -38,7 +38,7 @@ public:
bool spawnTargetValid(SpawnTarget const& spawnTarget); bool spawnTargetValid(SpawnTarget const& spawnTarget);
bool addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal); bool addClient(ConnectionId clientId, SpawnTarget const& spawnTarget, bool isLocal, bool isAdmin = false);
// Returns final outgoing packets // Returns final outgoing packets
List<PacketPtr> removeClient(ConnectionId clientId); List<PacketPtr> removeClient(ConnectionId clientId);