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

Method playerCidFromCommand

source/game/StarCommandProcessor.cpp:905–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905Maybe<ConnectionId> CommandProcessor::playerCidFromCommand(String const& player, UniverseServer* universe) {
906 char const* const UsernamePrefix = "@";
907 char const* const CidPrefix = "$";
908 char const* const UUIDPrefix = "$$";
909
910 if (player.beginsWith(UsernamePrefix)) {
911 return universe->findNick(player.substr(strlen(UsernamePrefix)));
912 } else if (player.beginsWith(UUIDPrefix)) {
913 try {
914 auto uuidString = player.substr(strlen(UUIDPrefix));
915 return universe->clientForUuid(Uuid(uuidString));
916 } catch (UuidException const&) {
917 // pass to base case
918 }
919 } else if (player.beginsWith(CidPrefix)) {
920 auto cidString = player.substr(strlen(CidPrefix));
921 auto cid = maybeLexicalCast<ConnectionId>(cidString).value(ServerConnectionId);
922 if (universe->isConnectedClient(cid))
923 return cid;
924 }
925
926 return universe->findNick(player);
927}
928
929//wow, wtf. TODO: replace with hashmap
930String CommandProcessor::handleCommand(ConnectionId connectionId, String const& command, String const& argumentString) {

Callers

nothing calls this directly

Calls 7

UuidClass · 0.85
clientForUuidMethod · 0.80
beginsWithMethod · 0.45
findNickMethod · 0.45
substrMethod · 0.45
valueMethod · 0.45
isConnectedClientMethod · 0.45

Tested by

no test coverage detected