From e8a907d89e37bf6eeab8e852c8439ae4899cd114 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 31 Jul 2013 11:16:11 +0200 Subject: Implemented the actual tab completion for commands and playernames. Each command is reported only if the player has the permission to use it. --- source/World.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/World.cpp') diff --git a/source/World.cpp b/source/World.cpp index da29565cb..880f6e5b2 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -2366,12 +2366,16 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, int a_EntityTy void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Results) { - // TODO - // DEBUG: - LOGWARNING("%s: Not implemented yet!", __FUNCTION__); - a_Results.push_back(a_Text + "_world1"); - a_Results.push_back(a_Text + "_world3"); - a_Results.push_back(a_Text + "_world2"); + cCSLock Lock(m_CSPlayers); + for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr) + { + if (NoCaseCompare((*itr)->GetName().substr(0, a_Text.length()), a_Text) != 0) + { + // Player name doesn't match + continue; + } + a_Results.push_back((*itr)->GetName()); + } } -- cgit v1.2.3