Added a RateCompareString function to StringUtils
Created a preprocessor template (define) for DoWith* functions Exported cWorld::FindAndDoWithPlayer(), cRoot::FindAndDoWithPlayer() and cRoot::ForEachPlayer() to Lua Added a function FindAndDoWithPlayer to cRoot and cWorld. It takes a part of a player name and finds a single player based on that. Fixed Core's MOTD to contain the correct URL to the MCServer site Fixed Core /kick command Fixed Core's WebAdmin kick git-svn-id: http://mc-server.googlecode.com/svn/trunk@779 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -172,6 +172,33 @@ int NoCaseCompare(const AString & s1, const AString & s2)
|
||||
|
||||
|
||||
|
||||
unsigned int RateCompareString(const AString & s1, const AString & s2 )
|
||||
{
|
||||
unsigned int MatchedLetters = 0;
|
||||
unsigned int s1Length = s1.length();
|
||||
|
||||
if( s1Length > s2.length() ) return 0; // Definitely not a match
|
||||
|
||||
for (unsigned int i = 0; i < s1Length; i++)
|
||||
{
|
||||
char c1 = (char)toupper( s1[i] );
|
||||
char c2 = (char)toupper( s2[i] );
|
||||
if( c1 == c2 )
|
||||
{
|
||||
++MatchedLetters;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return MatchedLetters;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith)
|
||||
{
|
||||
size_t pos1 = iHayStack.find(iNeedle);
|
||||
|
||||
Reference in New Issue
Block a user