From 9e0b8b5bee6fec15df846334cffc2d8e913c0328 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 18 Aug 2013 11:58:19 +0100 Subject: Enhancements to Tabcompletion and Compile Fix Tab complete now finds the last word and matches accordingly, with a 20% increase in speed! Fixed missing comma breaking compilation --- source/BlockID.h | 2 +- source/World.cpp | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/BlockID.h b/source/BlockID.h index 8a60c16ce..3c4381ae1 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -170,7 +170,7 @@ enum ENUM_BLOCK_ID E_BLOCK_DROPPER = 158, E_BLOCK_STAINED_CLAY = 159, - E_BLOCK_HAY_BALE = 170 + E_BLOCK_HAY_BALE = 170, E_BLOCK_CARPET = 171, E_BLOCK_HARDENED_CLAY = 172, E_BLOCK_BLOCK_OF_COAL = 173, diff --git a/source/World.cpp b/source/World.cpp index 5c15a3965..6b82dce0f 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -2635,19 +2635,15 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr) { - for (unsigned int selected = 0; selected < a_Text.length(); selected++ ) + unsigned LastSpace = a_Text.find_last_of(" "); + std::string LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); + std::string PlayerName ((*itr)->GetName()); + std::size_t Found = PlayerName.find(LastWord); + if (Found!=0) { - std::string playername ((*itr)->GetName()); - std::string cut (a_Text.substr(selected, a_Text.length())); - std::size_t found = playername.find(cut); - if (found!=0) - { - //Player name doesn't match - continue; - } - a_Results.push_back((*itr)->GetName()); - break; + continue; } + a_Results.push_back((*itr)->GetName()); } } -- cgit v1.2.3