| 903 | } |
| 904 | |
| 905 | Maybe<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 |
| 930 | String CommandProcessor::handleCommand(ConnectionId connectionId, String const& command, String const& argumentString) { |
nothing calls this directly
no test coverage detected