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

Method resolveWarpAction

source/game/StarUniverseServer.cpp:1879–1923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1877}
1878
1879WarpToWorld UniverseServer::resolveWarpAction(WarpAction warpAction, ConnectionId clientId, bool deploy) const {
1880 auto clientContext = m_clients.value(clientId);
1881 if (!clientContext)
1882 return {};
1883
1884 WorldId toWorldId;
1885 SpawnTarget spawnTarget;
1886 if (auto toWorld = warpAction.ptr<WarpToWorld>()) {
1887 if (!toWorld->world)
1888 toWorldId = clientContext->playerWorldId();
1889 else
1890 toWorldId = toWorld->world;
1891 spawnTarget = toWorld->target;
1892 } else if (auto toPlayerUuid = warpAction.ptr<WarpToPlayer>()) {
1893 if (auto toClientId = getClientForUuid(*toPlayerUuid)) {
1894 if (auto toClientWorld = m_clients.get(*toClientId)->playerWorld()) {
1895 if (auto toClientPosition = toClientWorld->playerRevivePosition(*toClientId)) {
1896 toWorldId = toClientWorld->worldId();
1897 if (deploy)
1898 spawnTarget.reset();
1899 else
1900 spawnTarget = SpawnTargetPosition(*toClientPosition);
1901 }
1902 }
1903 }
1904 } else if (auto shortcut = warpAction.ptr<WarpAlias>()) {
1905 if (*shortcut == WarpAlias::Return) {
1906 if (auto returnWarp = clientContext->playerReturnWarp()) {
1907 toWorldId = returnWarp.world;
1908 spawnTarget = returnWarp.target;
1909 }
1910 } else if (*shortcut == WarpAlias::OrbitedWorld) {
1911 if (auto warpAction = clientContext->orbitWarpAction()) {
1912 if (auto warpToWorld = warpAction->first.maybe<WarpToWorld>()) {
1913 toWorldId = warpToWorld->world;
1914 spawnTarget = warpToWorld->target;
1915 }
1916 }
1917 } else if (*shortcut == WarpAlias::OwnShip) {
1918 toWorldId = ClientShipWorldId(clientContext->playerUuid());
1919 }
1920 }
1921
1922 return WarpToWorld(toWorldId, spawnTarget);
1923}
1924
1925void UniverseServer::doDisconnection(ConnectionId clientId, String const& reason) {
1926 RecursiveMutexLocker locker(m_mainLock);

Callers

nothing calls this directly

Calls 11

WarpToWorldClass · 0.85
playerRevivePositionMethod · 0.80
playerReturnWarpMethod · 0.80
playerUuidMethod · 0.80
valueMethod · 0.45
playerWorldIdMethod · 0.45
playerWorldMethod · 0.45
getMethod · 0.45
worldIdMethod · 0.45
resetMethod · 0.45
orbitWarpActionMethod · 0.45

Tested by

no test coverage detected