summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:59:58 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:59:58 +0100
commit0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6 (patch)
tree81e4529268e419a79fd18be90a4e517e340ead88 /source/World.cpp
parentMoved command API into cPluginManager. (diff)
downloadcuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar.gz
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar.bz2
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar.lz
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar.xz
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.tar.zst
cuberite-0be125aa07a9d6cebf47b81fc23eb61cc96cd7b6.zip
Diffstat (limited to '')
-rw-r--r--source/World.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/source/World.cpp b/source/World.cpp
index 084bf8cd2..e5e8977bd 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -1752,33 +1752,30 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_
-bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback)
+bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback)
{
- cPlayer* BestMatch = 0;
+ cPlayer * BestMatch = NULL;
unsigned int BestRating = 0;
- unsigned int NumMatches = 0;
- unsigned int NameLength = a_PlayerName.length();
+ unsigned int NameLength = a_PlayerNameHint.length();
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- unsigned int Rating = RateCompareString (a_PlayerName, (*itr)->GetName());
- if (Rating > 0 && Rating >= BestRating)
+ unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
+ if (Rating >= BestRating)
{
BestMatch = *itr;
- if( Rating > BestRating ) NumMatches = 0;
BestRating = Rating;
- ++NumMatches;
}
- if (Rating == NameLength) // Perfect match
+ if (Rating == NameLength) // Perfect match
{
break;
}
} // for itr - m_Players[]
- if (NumMatches == 1)
+ if (BestMatch != NULL)
{
- LOG("Compared %s and %s with rating %i", a_PlayerName.c_str(), BestMatch->GetName().c_str(), BestRating );
+ LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating);
return a_Callback.Item (BestMatch);
}
return false;