1
0

fixed /tp command

made cWorld::DoWithPlayer case insensitive

git-svn-id: http://mc-server.googlecode.com/svn/trunk@662 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
lapayo94@gmail.com 2012-07-13 17:22:58 +00:00
parent abf9e3f6dd
commit f4b66cbbdb
3 changed files with 28 additions and 11 deletions

View File

@ -3,16 +3,21 @@ function HandleTPCommand( Split, Player )
Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName]" )
return true
end
local World = Player:GetWorld()
local OtherPlayer = World:GetPlayer( Split[2] )
if( OtherPlayer == nil ) then
Player:SendMessage( cChatColor.Green .. "Can't find player " .. Split[2] )
elseif( OtherPlayer == Player ) then
World = Player:GetWorld()
local TeleportDestination = function(OtherPlayer)
if( OtherPlayer == Player ) then
Player:SendMessage( cChatColor.Green .. "Already there :)" )
else
Player:TeleportToEntity( OtherPlayer )
Player:SendMessage( cChatColor.Green .. "You teleported to "..OtherPlayer:GetName().."!" )
OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName().." teleported to you!" )
end
end
if (not(World:DoWithPlayer(Split[2], TeleportDestination))) then
Player:SendMessage( cChatColor.Green .. "Can't find player " .. Split[2] )
end
return true
end

View File

@ -200,3 +200,15 @@ public:
//Common functions
//Taken from http://stackoverflow.com/questions/11635/case-insensitive-string-comparison-in-c
inline bool iequals(const std::string& a, const std::string& b)
{
unsigned int sz = a.size();
if (b.size() != sz)
return false;
for (unsigned int i = 0; i < sz; ++i)
if (tolower(a[i]) != tolower(b[i]))
return false;
return true;
}

View File

@ -1534,7 +1534,7 @@ bool cWorld::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if ((*itr)->GetName() == a_PlayerName)
if (iequals((*itr)->GetName(), a_PlayerName))
{
a_Callback.Item(*itr);
return true;