MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / executeForClient

Method executeForClient

source/game/StarUniverseServer.cpp:362–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362bool UniverseServer::executeForClient(ConnectionId clientId, function<void(WorldServer*, PlayerPtr)> action) {
363 RecursiveMutexLocker locker(m_mainLock);
364 ReadLocker clientsLocker(m_clientsLock);
365 bool success = false;
366 if (auto clientContext = m_clients.value(clientId)) {
367 if (auto currentWorld = clientContext->playerWorld()) {
368 locker.unlock();
369 currentWorld->executeAction([clientId, action, &success, &locker](WorldServerThread*, WorldServer* worldServer) {
370 locker.lock();
371 if (auto player = worldServer->clientPlayer(clientId)) {
372 action(worldServer, player);
373 success = true;
374 }
375 });
376 }
377 }
378 return success;
379}
380
381void UniverseServer::disconnectClient(ConnectionId clientId, String const& reason) {
382 RecursiveMutexLocker locker(m_mainLock);

Callers 15

setTileProtectionMethod · 0.80
setDungeonIdMethod · 0.80
setPlayerStartMethod · 0.80
spawnItemMethod · 0.80
spawnTreasureMethod · 0.80
spawnMonsterMethod · 0.80
spawnNpcMethod · 0.80
spawnVehicleMethod · 0.80
spawnStagehandMethod · 0.80
clearStagehandMethod · 0.80
spawnLiquidMethod · 0.80
entityEvalMethod · 0.80

Calls 6

executeActionMethod · 0.80
clientPlayerMethod · 0.80
valueMethod · 0.45
playerWorldMethod · 0.45
unlockMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected