MCPcopy Create free account
hub / github.com/cuberite/cuberite / TabCompleteUserName

Method TabCompleteUserName

src/World.cpp:3003–3021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3001
3002
3003void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Results)
3004{
3005 cCSLock Lock(m_CSPlayers);
3006 for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr)
3007 {
3008 size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space
3009
3010 AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word
3011 AString PlayerName ((*itr)->GetName());
3012 size_t Found = PlayerName.find(LastWord); // Try to find last word in playername
3013
3014 if (Found == AString::npos)
3015 {
3016 continue; // No match
3017 }
3018
3019 a_Results.push_back(PlayerName); // Match!
3020 }
3021}
3022
3023
3024

Callers 1

HandleTabCompletionMethod · 0.80

Calls 3

beginMethod · 0.80
endMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected