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

Method FindAndDoWithPlayer

src/World.cpp:2420–2447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2418
2419
2420bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback)
2421{
2422 cPlayer * BestMatch = NULL;
2423 unsigned int BestRating = 0;
2424 unsigned int NameLength = a_PlayerNameHint.length();
2425
2426 cCSLock Lock(m_CSPlayers);
2427 for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
2428 {
2429 unsigned int Rating = RateCompareString (a_PlayerNameHint, (*itr)->GetName());
2430 if (Rating >= BestRating)
2431 {
2432 BestMatch = *itr;
2433 BestRating = Rating;
2434 }
2435 if (Rating == NameLength) // Perfect match
2436 {
2437 break;
2438 }
2439 } // for itr - m_Players[]
2440
2441 if (BestMatch != NULL)
2442 {
2443 LOG("Compared %s and %s with rating %i", a_PlayerNameHint.c_str(), BestMatch->GetName().c_str(), BestRating);
2444 return a_Callback.Item (BestMatch);
2445 }
2446 return false;
2447}
2448
2449
2450

Callers

nothing calls this directly

Calls 7

RateCompareStringFunction · 0.85
LOGFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
c_strMethod · 0.80
GetNameMethod · 0.45
ItemMethod · 0.45

Tested by

no test coverage detected