Index: /trunk/src/game/Level3.cpp
===================================================================
--- /trunk/src/game/Level3.cpp (revision 177)
+++ /trunk/src/game/Level3.cpp (revision 184)
@@ -1,21 +1,21 @@
 /*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+*
+* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
 
 #include "Common.h"
@@ -164,5 +164,5 @@
 }
 
-bool ChatHandler::HandleReloadAllLocalesCommand(const char* args)
+bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/)
 {
     HandleReloadLocalesCreatureCommand("a");
@@ -175,5 +175,5 @@
 }
 
-bool ChatHandler::HandleReloadConfigCommand(const char* arg)
+bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/)
 {
     sLog.outString( "Re-Loading config settings..." );
@@ -435,5 +435,5 @@
     sLog.outString( "Re-Loading Spell Elixir types..." );
     spellmgr.LoadSpellElixirs();
-    SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded.");
+    SendGlobalSysMessage("DB table `spell_elixir` (spell elixir types) reloaded.");
     return true;
 }
@@ -698,4 +698,5 @@
         return false;
 
+    /// must be NULL if targeted syntax and must be not nULL if not targeted
     char* arg2 = strtok(NULL, " ");
 
@@ -704,25 +705,18 @@
     uint32 targetSecurity = 0;
 
-	/// only target player different from self allowed (if targetPlayer!=NULL then not console)
+    /// only target player different from self allowed (if targetPlayer!=NULL then not console)
     Player* targetPlayer = getSelectedPlayer();
     if(targetPlayer && m_session->GetPlayer()!=targetPlayer)
     {
         /// wrong command syntax or unexpected targeting
-		if(arg2)
-			return false;
+        if(arg2)
+            return false;
+
+        /// security level expected in arg2 after this if.
+        arg2 = arg1;
 
         targetAccountId = targetPlayer->GetSession()->GetAccountId();
         targetSecurity = targetPlayer->GetSession()->GetSecurity();
         if(!accmgr.GetName(targetAccountId,targetAccountName))
-		{
-			PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str());
-			SetSentErrorMessage(true);
-			return false;
-		}
-    }
-    else
-    {
-        targetAccountName = arg1;
-        if(!AccountMgr::normilizeString(targetAccountName))
         {
             PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str());
@@ -730,7 +724,21 @@
             return false;
         }
+    }
+    else
+    {
+        /// wrong command syntax (second arg expected)
+        if(!arg2)
+            return false;
+
+        targetAccountName = arg1;
+        if(!AccountMgr::normilizeString(targetAccountName))
+        {
+            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str());
+            SetSentErrorMessage(true);
+            return false;
+        }
 
         targetAccountId = accmgr.GetId(targetAccountName);
-		targetSecurity = accmgr.GetSecurity(targetAccountId);
+        targetSecurity = accmgr.GetSecurity(targetAccountId);
     }
 
@@ -744,9 +752,9 @@
 
     /// m_session==NULL only for console
-	uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE;
-
-	/// can set security level only for target with less security and to less security that we have
-	/// This is also reject self apply in fact
-	if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity )
+    uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE;
+
+    /// can set security level only for target with less security and to less security that we have
+    /// This is also reject self apply in fact
+    if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity )
     {
         SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
@@ -770,74 +778,74 @@
 bool ChatHandler::HandleAccountSetPasswordCommand(const char* args)
 {
-	if(!*args)
-		return false;
-
-	///- Get the command line arguments
-	char *szAccount = strtok ((char*)args," ");
-	char *szPassword1 =  strtok (NULL," ");
-	char *szPassword2 =  strtok (NULL," ");
-
-	if (!szAccount||!szPassword1 || !szPassword2)
-		return false;
-
-	std::string account_name = szAccount;
-	if(!AccountMgr::normilizeString(account_name))
-	{
-		PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	uint32 targetAccountId = accmgr.GetId(account_name);
-	if (!targetAccountId)
-	{
-		PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	uint32 targetSecurity = accmgr.GetSecurity(targetAccountId);
-
-	/// m_session==NULL only for console
-	uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE;
-
-	/// can set password only for target with less security
-	/// This is also reject self apply in fact
-	if (targetSecurity >= plSecurity)
-	{
-		SendSysMessage (LANG_YOURS_SECURITY_IS_LOW);
-		SetSentErrorMessage (true);
-		return false;
-	}
-
-	if (strcmp(szPassword1,szPassword2))
-	{
-		SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
-		SetSentErrorMessage (true);
-		return false;
-	}
-
-	AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1);
-
-	switch(result)
-	{
-		case AOR_OK:
-			SendSysMessage(LANG_COMMAND_PASSWORD);
-			break;
-		case AOR_NAME_NOT_EXIST:
-			PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-			SetSentErrorMessage(true);
-			return false;
-		case AOR_PASS_TOO_LONG:
-			SendSysMessage(LANG_PASSWORD_TOO_LONG);
-			SetSentErrorMessage(true);
-			return false;
-		default:
-			SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
-			SetSentErrorMessage(true);
-			return false;
-	}
-
-	return true;
+    if(!*args)
+        return false;
+
+    ///- Get the command line arguments
+    char *szAccount = strtok ((char*)args," ");
+    char *szPassword1 =  strtok (NULL," ");
+    char *szPassword2 =  strtok (NULL," ");
+
+    if (!szAccount||!szPassword1 || !szPassword2)
+        return false;
+
+    std::string account_name = szAccount;
+    if(!AccountMgr::normilizeString(account_name))
+    {
+        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    uint32 targetAccountId = accmgr.GetId(account_name);
+    if (!targetAccountId)
+    {
+        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    uint32 targetSecurity = accmgr.GetSecurity(targetAccountId);
+
+    /// m_session==NULL only for console
+    uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE;
+
+    /// can set password only for target with less security
+    /// This is also reject self apply in fact
+    if (targetSecurity >= plSecurity)
+    {
+        SendSysMessage (LANG_YOURS_SECURITY_IS_LOW);
+        SetSentErrorMessage (true);
+        return false;
+    }
+
+    if (strcmp(szPassword1,szPassword2))
+    {
+        SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
+        SetSentErrorMessage (true);
+        return false;
+    }
+
+    AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1);
+
+    switch(result)
+    {
+        case AOR_OK:
+            SendSysMessage(LANG_COMMAND_PASSWORD);
+            break;
+        case AOR_NAME_NOT_EXIST:
+            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+            SetSentErrorMessage(true);
+            return false;
+        case AOR_PASS_TOO_LONG:
+            SendSysMessage(LANG_PASSWORD_TOO_LONG);
+            SetSentErrorMessage(true);
+            return false;
+        default:
+            SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
+            SetSentErrorMessage(true);
+            return false;
+    }
+
+    return true;
 }
 
@@ -935,5 +943,4 @@
     if (!*args)
         return false;
-
 
     // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
@@ -1412,5 +1419,5 @@
         "5916",
         "6634",
-        //"6718", phasing stealth, annoing for learn all case.
+        //"6718", phasing stealth, annoying for learn all case.
         "6719",
         "8822",
@@ -1772,5 +1779,5 @@
         }
 
-        if(!spellid)                                        // ??? none spells in telent
+        if(!spellid)                                        // ??? none spells in talent
             continue;
 
@@ -2020,11 +2027,12 @@
             {
                 Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true);
+
                 // remove binding (let GM give it to another player later)
                 if (pl==plTarget)
                     item->SetBinding( false );
 
-            pl->SendNewItem(item,1,false,true);
-            if (pl!=plTarget)
-                plTarget->SendNewItem(item,1,true,false);
+                pl->SendNewItem(item,1,false,true);
+                if (pl!=plTarget)
+                    plTarget->SendNewItem(item,1,true,false);
             }
             else
@@ -2043,4 +2051,5 @@
         return false;
     }
+
     return true;
 }
@@ -2056,12 +2065,12 @@
 
     uint32 item_id = atol(cId);
-	if(!item_id)
-	{
-		PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_id);
+    if(!item_id)
+    {
+        PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_id);
     if(!itemProto)
     {
@@ -2089,5 +2098,5 @@
 
     result=CharacterDatabase.PQuery(
-    //          0        1             2             3        4                  5
+        //          0        1             2             3        4                  5
         "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name "
         "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters "
@@ -2143,5 +2152,5 @@
     {
         result=CharacterDatabase.PQuery(
-        //          0                     1            2              3               4            5               6
+            //          0                     1            2              3               4            5               6
             "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name "
             "FROM mail,mail_items,characters as char_s,characters as char_r "
@@ -2193,5 +2202,5 @@
     {
         result=CharacterDatabase.PQuery(
-        //           0                      1                       2                   3
+            //           0                      1                       2                   3
             "SELECT  auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
             "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
@@ -2220,43 +2229,43 @@
 
     // guild bank case
-	uint32 guild_count = 0;
-	result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id);
-	if(result)
-	{
-		guild_count = (*result)[0].GetUInt32();
-		delete result;
-	}
-
-	result=CharacterDatabase.PQuery(
-		//      0             1           2
-		"SELECT gi.item_guid, gi.guildid, guild.name "
-		"FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ",
-		item_id,uint32(count));
-
-	if(result)
-	{
-		do
-		{
-			Field *fields = result->Fetch();
-			uint32 item_guid = fields[0].GetUInt32();
-			uint32 guild_guid = fields[1].GetUInt32();
-			std::string guild_name = fields[2].GetCppString();
-
-			char const* item_pos = "[in guild bank]";
-
-			PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos);
-		} while (result->NextRow());
-
-		int64 res_count = result->GetRowCount();
-
-		delete result;
-
-		if(count > res_count)
-			count-=res_count;
-		else if(count)
-			count = 0;
-	}
-
-	if(inv_count+mail_count+auc_count+guild_count == 0)
+    uint32 guild_count = 0;
+    result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id);
+    if(result)
+    {
+        guild_count = (*result)[0].GetUInt32();
+        delete result;
+    }
+
+    result=CharacterDatabase.PQuery(
+        //      0             1           2
+        "SELECT gi.item_guid, gi.guildid, guild.name "
+        "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ",
+        item_id,uint32(count));
+
+    if(result)
+    {
+        do
+        {
+            Field *fields = result->Fetch();
+            uint32 item_guid = fields[0].GetUInt32();
+            uint32 guild_guid = fields[1].GetUInt32();
+            std::string guild_name = fields[2].GetCppString();
+
+            char const* item_pos = "[in guild bank]";
+
+            PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos);
+        } while (result->NextRow());
+
+        int64 res_count = result->GetRowCount();
+
+        delete result;
+
+        if(count > res_count)
+            count-=res_count;
+        else if(count)
+            count = 0;
+    }
+
+    if(inv_count+mail_count+auc_count+guild_count == 0)
     {
         SendSysMessage(LANG_COMMAND_NOITEMFOUND);
@@ -2281,13 +2290,13 @@
 
     uint32 go_id = atol(cId);
-	if(!go_id)
-	{
-		PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id);
-		SetSentErrorMessage(true);
-		return false;
-	}
+    if(!go_id)
+    {
+        PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id);
+        SetSentErrorMessage(true);
+        return false;
+    }
 
     GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id);
-	if(!gInfo)
+    if(!gInfo)
     {
         PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id);
@@ -2313,12 +2322,12 @@
 
     if(m_session)
-	{
-		Player* pl = m_session->GetPlayer();
-		result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
-			pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count));
-	}
-	else
-		result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u",
-		go_id,uint32(count));
+    {
+        Player* pl = m_session->GetPlayer();
+        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
+            pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count));
+    }
+    else
+        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u",
+        go_id,uint32(count));
 
     if (result)
@@ -2334,7 +2343,7 @@
 
             if (m_session)
-				PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid);
-			else
-				PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapid);
+                PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid);
+            else
+                PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapid);
         } while (result->NextRow());
 
@@ -2436,13 +2445,13 @@
 
     uint32 cr_id = atol(cId);
-	if(!cr_id)
-	{
-		PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
-		SetSentErrorMessage(true);
-		return false;
-	}
+    if(!cr_id)
+    {
+        PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
+        SetSentErrorMessage(true);
+        return false;
+    }
 
     CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id);
-	if(!cInfo)
+    if(!cInfo)
     {
         PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
@@ -2468,12 +2477,12 @@
 
     if(m_session)
-	{
-		Player* pl = m_session->GetPlayer();
-		result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
-			pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count));
-	}
-	else
-		result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
-			cr_id,uint32(count));
+    {
+        Player* pl = m_session->GetPlayer();
+        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
+            pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count));
+    }
+    else
+        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
+        cr_id,uint32(count));
 
     if (result)
@@ -2489,7 +2498,7 @@
 
             if  (m_session)
-				PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapid);
-			else
-				PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapid);
+                PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapid);
+            else
+                PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapid);
         } while (result->NextRow());
 
@@ -2537,7 +2546,7 @@
                     {
                         if (m_session)
-							PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str());
-						else
-							PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str());
+                            PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str());
+                        else
+                            PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str());
                         ++counter;
                         continue;
@@ -2554,7 +2563,7 @@
         {
             if (m_session)
-				PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str());
-			else
-				PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str());
+                PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str());
+            else
+                PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str());
             ++counter;
         }
@@ -2590,5 +2599,5 @@
         {
             int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
-			std::string name = set->name[loc];
+            std::string name = set->name[loc];
             if(name.empty())
                 continue;
@@ -2615,7 +2624,7 @@
                 // send item set in "id - [namedlink locale]" format
                 if (m_session)
-					PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]);
-				else
-					PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE,id,name.c_str(),localeNames[loc]);
+                    PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]);
+                else
+                    PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE,id,name.c_str(),localeNames[loc]);
                 ++counter;
             }
@@ -2629,9 +2638,9 @@
 bool ChatHandler::HandleLookupSkillCommand(const char* args)
 {
-	if (!*args)
-        return false;
-
-	// can be NULL in console call
-	Player* target = getSelectedPlayer();
+    if(!*args)
+        return false;
+
+    // can be NULL in console call
+    Player* target = getSelectedPlayer();
 
     std::string namepart = args;
@@ -2676,13 +2685,13 @@
             if(loc < MAX_LOCALE)
             {
-				char const* knownStr = "";
-				if(target && target->HasSkill(id))
-					knownStr = GetTrinityString(LANG_KNOWN);
+                char const* knownStr = "";
+                if(target && target->HasSkill(id))
+                    knownStr = GetTrinityString(LANG_KNOWN);
 
                 // send skill in "id - [namedlink locale]" format
                 if (m_session)
-					PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr);
-				else
-					PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr);
+                    PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr);
+                else
+                    PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr);
 
                 ++counter;
@@ -2697,9 +2706,9 @@
 bool ChatHandler::HandleLookupSpellCommand(const char* args)
 {
-	if (!*args)
-        return false;
-
-	// can be NULL at console call
-	Player* target = getSelectedPlayer();
+    if(!*args)
+        return false;
+
+    // can be NULL at console call
+    Player* target = getSelectedPlayer();
 
     std::string namepart = args;
@@ -2747,7 +2756,7 @@
                 bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL);
 
-                uint32 telentCost = GetTalentSpellCost(id);
-
-                bool talent = (telentCost > 0);
+                uint32 talentCost = GetTalentSpellCost(id);
+
+                bool talent = (talentCost > 0);
                 bool passive = IsPassiveSpell(id);
                 bool active = target && (target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2));
@@ -2755,12 +2764,12 @@
                 // unit32 used to prevent interpreting uint8 as char at output
                 // find rank of learned spell for learning spell, or talent rank
-                uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id);
+                uint32 rank = talentCost ? talentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id);
 
                 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
                 std::ostringstream ss;
                 if (m_session)
-					ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
-				else
-					ss << id << " - " << name;
+                    ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
+                else
+                    ss << id << " - " << name;
 
                 // include rank in link name
@@ -2769,7 +2778,7 @@
 
                 if (m_session)
-					ss << " " << localeNames[loc] << "]|h|r";
-				else
-					ss << " " << localeNames[loc];
+                    ss << " " << localeNames[loc] << "]|h|r";
+                else
+                    ss << " " << localeNames[loc];
 
                 if(talent)
@@ -2797,9 +2806,9 @@
 bool ChatHandler::HandleLookupQuestCommand(const char* args)
 {
-	if (!*args)
-        return false;
-
-	// can be NULL at console call
-	Player* target = getSelectedPlayer();
+    if(!*args)
+        return false;
+
+    // can be NULL at console call
+    Player* target = getSelectedPlayer();
 
     std::string namepart = args;
@@ -2833,24 +2842,23 @@
                         char const* statusStr = "";
 
-						if(target)
+                        if(target)
                         {
                             QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId());
 
-							if(status == QUEST_STATUS_COMPLETE)
-							{
-								if(target->GetQuestRewardStatus(qinfo->GetQuestId()))
-									statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
-								else
-									statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
-							}
-							else if(status == QUEST_STATUS_INCOMPLETE)
-								statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
+                            if(status == QUEST_STATUS_COMPLETE)
+                            {
+                                if(target->GetQuestRewardStatus(qinfo->GetQuestId()))
+                                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
+                                else
+                                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
+                            }
+                            else if(status == QUEST_STATUS_INCOMPLETE)
+                                statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
                         }
-                        
-						if (m_session)
-							PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr);
-						else
-							PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr);
-
+
+                        if (m_session)
+                            PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr);
+                        else
+                            PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr);
                         ++counter;
                         continue;
@@ -2867,24 +2875,24 @@
         {
             char const* statusStr = "";
-            
-			if(target)
+
+            if(target)
             {
                 QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId());
 
-				if(status == QUEST_STATUS_COMPLETE)
-				{
-					if(target->GetQuestRewardStatus(qinfo->GetQuestId()))
-						statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
-					else
-						statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
-				}
-				else if(status == QUEST_STATUS_INCOMPLETE)
-					statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
+                if(status == QUEST_STATUS_COMPLETE)
+                {
+                    if(target->GetQuestRewardStatus(qinfo->GetQuestId()))
+                        statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
+                    else
+                        statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
+                }
+                else if(status == QUEST_STATUS_INCOMPLETE)
+                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
             }
-            
-			if (m_session)
-				PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr);
-			else
-				PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr);
+
+            if (m_session)
+                PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr);
+            else
+                PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr);
 
             ++counter;
@@ -2921,5 +2929,5 @@
 
         int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex();
-		if (loc_idx >= 0)
+        if (loc_idx >= 0)
         {
             CreatureLocale const *cl = objmgr.GetCreatureLocale (id);
@@ -2933,8 +2941,7 @@
                     {
                         if (m_session)
-							PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ());
-						else
-							PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ());
-
+                            PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ());
+                        else
+                            PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ());
                         ++counter;
                         continue;
@@ -2951,7 +2958,7 @@
         {
             if (m_session)
-				PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ());
-			else
-				PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ());
+                PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ());
+            else
+                PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ());
             ++counter;
         }
@@ -2999,7 +3006,7 @@
                     {
                         if (m_session)
-							PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str());
-						else
-							PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str());
+                            PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str());
+                        else
+                            PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str());
                         ++counter;
                         continue;
@@ -3016,7 +3023,7 @@
         {
             if (m_session)
-				PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str());
-			else
-				PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str());
+                PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str());
+            else
+                PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str());
             ++counter;
         }
@@ -3044,13 +3051,13 @@
 
     char *lname = strtok ((char*)args, " ");
-	char *gname = strtok (NULL, "");
+    char *gname = strtok (NULL, "");
 
     if (!lname)
         return false;
-    
-	if (!gname)
+
+    if (!gname)
     {
         SendSysMessage (LANG_INSERT_GUILD_NAME);
-		SetSentErrorMessage (true);
+        SetSentErrorMessage (true);
         return false;
     }
@@ -3059,8 +3066,8 @@
 
     Player* player = ObjectAccessor::Instance ().FindPlayerByName (lname);
-	if (!player)
+    if (!player)
     {
         SendSysMessage (LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage (true);
+        SetSentErrorMessage (true);
         return false;
     }
@@ -3069,17 +3076,17 @@
     {
         SendSysMessage (LANG_PLAYER_IN_GUILD);
-		return true;
-	}
-
-	Guild *guild = new Guild;
-	if (!guild->create (player->GetGUID (),guildname))
-	{
-		delete guild;
-		SendSysMessage (LANG_GUILD_NOT_CREATED);
-		SetSentErrorMessage (true);
-		return false;
-    }
-    
-	objmgr.AddGuild (guild);
+        return true;
+    }
+
+    Guild *guild = new Guild;
+    if (!guild->create (player->GetGUID (),guildname))
+    {
+        delete guild;
+        SendSysMessage (LANG_GUILD_NOT_CREATED);
+        SetSentErrorMessage (true);
+        return false;
+    }
+
+    objmgr.AddGuild (guild);
     return true;
 }
@@ -3097,5 +3104,5 @@
     std::string glName = par2;
     Guild* targetGuild = objmgr.GetGuildByName (glName);
-	if (!targetGuild)
+    if (!targetGuild)
         return false;
 
@@ -3104,5 +3111,5 @@
     {
         SendSysMessage (LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage (true);
+        SetSentErrorMessage (true);
         return false;
     }
@@ -3110,5 +3117,5 @@
     uint64 plGuid = 0;
     if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ()))
-		plGuid = targetPlayer->GetGUID ();
+        plGuid = targetPlayer->GetGUID ();
     else
         plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
@@ -3117,5 +3124,5 @@
         false;
 
-    // players's guild membership checked in AddMember before add
+    // player's guild membership checked in AddMember before add
     if (!targetGuild->AddMember (plGuid,targetGuild->GetLowestRank ()))
         return false;
@@ -3137,5 +3144,5 @@
     {
         SendSysMessage (LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage (true);
+        SetSentErrorMessage (true);
         return false;
     }
@@ -3146,10 +3153,10 @@
     {
         plGuid = targetPlayer->GetGUID ();
-		glId   = targetPlayer->GetGuildId ();
+        glId   = targetPlayer->GetGuildId ();
     }
     else
     {
         plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
-		glId = Player::GetGuildIdFromDB (plGuid);
+        glId = Player::GetGuildIdFromDB (plGuid);
     }
 
@@ -3158,5 +3165,5 @@
 
     Guild* targetGuild = objmgr.GetGuildById (glId);
-	if (!targetGuild)
+    if (!targetGuild)
         return false;
 
@@ -3172,13 +3179,12 @@
 
     char* par1 = strtok ((char*)args, " ");
-	char* par2 = strtok (NULL, " ");
-	if (!par1 || !par2)
-        return false;
-
+    char* par2 = strtok (NULL, " ");
+    if (!par1 || !par2)
+        return false;
     std::string plName = par1;
     if (!normalizePlayerName (plName))
     {
         SendSysMessage (LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage (true);
+        SetSentErrorMessage (true);
         return false;
     }
@@ -3189,10 +3195,10 @@
     {
         plGuid = targetPlayer->GetGUID ();
-		glId   = targetPlayer->GetGuildId ();
+        glId   = targetPlayer->GetGuildId ();
     }
     else
     {
         plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
-		glId = Player::GetGuildIdFromDB (plGuid);
+        glId = Player::GetGuildIdFromDB (plGuid);
     }
 
@@ -3201,9 +3207,9 @@
 
     Guild* targetGuild = objmgr.GetGuildById (glId);
-	if (!targetGuild)
+    if (!targetGuild)
         return false;
 
     uint32 newrank = uint32 (atoi (par2));
-	if (newrank > targetGuild->GetLowestRank ())
+    if (newrank > targetGuild->GetLowestRank ())
         return false;
 
@@ -3219,5 +3225,5 @@
 
     char* par1 = strtok ((char*)args, " ");
-	if (!par1)
+    if (!par1)
         return false;
 
@@ -3225,5 +3231,5 @@
 
     Guild* targetGuild = objmgr.GetGuildByName (gld);
-	if (!targetGuild)
+    if (!targetGuild)
         return false;
 
@@ -3793,5 +3799,5 @@
         return false;
     }
-        
+
     if (strncmp(args, "on", 3) == 0)
         player->SetMovement(MOVE_WATER_WALK);               // ON
@@ -3832,5 +3838,5 @@
             addlevel = atoi(px);
     }
-    // else .levelup - nothing do for prepering
+    // else .levelup - nothing do for preparing
 
     // player
@@ -3902,5 +3908,5 @@
     else
     {
-        // update levle and XP at level, all other will be updated at loading
+        // update level and XP at level, all other will be updated at loading
         Tokens values;
         Player::LoadValuesArrayFromDB(values,chr_guid);
@@ -4939,24 +4945,24 @@
 bool ChatHandler::HandleBanCharacterCommand(const char* args)
 {
-	return HandleBanHelper(BAN_CHARACTER,args);
+    return HandleBanHelper(BAN_CHARACTER,args);
 }
 
 bool ChatHandler::HandleBanIPCommand(const char* args)
 {
-	return HandleBanHelper(BAN_IP,args);
+    return HandleBanHelper(BAN_IP,args);
 }
 
 bool ChatHandler::HandleBanHelper(BanMode mode, const char* args)
 {
-	if(!args)
+    if(!args)
         return false;
 
     char* cnameOrIP = strtok ((char*)args, " ");
-	if (!cnameOrIP)
+    if (!cnameOrIP)
         return false;
 
     std::string nameOrIP = cnameOrIP;
 
-	char* duration = strtok (NULL," ");
+    char* duration = strtok (NULL," ");
     if(!duration || !atoi(duration))
         return false;
@@ -4967,28 +4973,28 @@
 
     switch(mode)
-	{
-		case BAN_ACCOUNT:
-			if(!AccountMgr::normilizeString(nameOrIP))
-			{
-				PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str());
-				SetSentErrorMessage(true);
-				return false;
-			}
-			break;
-		case BAN_CHARACTER:
-			if(!normalizePlayerName(nameOrIP))
-			{
-				SendSysMessage(LANG_PLAYER_NOT_FOUND);
-				SetSentErrorMessage(true);
-				return false;
-			}
-			break;
-		case BAN_IP:
-			if(!IsIPAddress(nameOrIP.c_str()))
-				return false;
-			break;
-	}
-
-	switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : ""))
+    {
+        case BAN_ACCOUNT:
+            if(!AccountMgr::normilizeString(nameOrIP))
+            {
+                PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str());
+                SetSentErrorMessage(true);
+                return false;
+            }
+            break;
+        case BAN_CHARACTER:
+            if(!normalizePlayerName(nameOrIP))
+            {
+                SendSysMessage(LANG_PLAYER_NOT_FOUND);
+                SetSentErrorMessage(true);
+                return false;
+            }
+            break;
+        case BAN_IP:
+            if(!IsIPAddress(nameOrIP.c_str()))
+                return false;
+            break;
+    }
+
+    switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : ""))
     {
         case BAN_SUCCESS:
@@ -5001,19 +5007,18 @@
             return false;
         case BAN_NOTFOUND:
-           switch(mode)
-		   {
-			   default:
-				   PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str());
-				   break;
-			   case BAN_CHARACTER:
-				   PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str());
-				   break;
-			   case BAN_IP:
-				   PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str());
-				   break;
-
-		   }
-		   SetSentErrorMessage(true);
-		   return false;
+            switch(mode)
+            {
+                default:
+                    PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str());
+                    break;
+                case BAN_CHARACTER:
+                    PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str());
+                    break;
+                case BAN_IP:
+                    PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str());
+                    break;
+            }
+            SetSentErrorMessage(true);
+            return false;
     }
 
@@ -5028,10 +5033,10 @@
 bool ChatHandler::HandleUnBanCharacterCommand(const char* args)
 {
-	return HandleUnBanHelper(BAN_CHARACTER,args);
+    return HandleUnBanHelper(BAN_CHARACTER,args);
 }
 
 bool ChatHandler::HandleUnBanIPCommand(const char* args)
 {
-	return HandleUnBanHelper(BAN_IP,args);
+    return HandleUnBanHelper(BAN_IP,args);
 }
 
@@ -5042,20 +5047,21 @@
 
     char* cnameOrIP = strtok ((char*)args, " ");
-	if(!cnameOrIP)
+    if(!cnameOrIP)
         return false;
 
     std::string nameOrIP = cnameOrIP;
+
     switch(mode)
     {
         case BAN_ACCOUNT:
-			if(!AccountMgr::normilizeString(nameOrIP))
+            if(!AccountMgr::normilizeString(nameOrIP))
             {
                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str());
-				SetSentErrorMessage(true);
-				return false;
-			}
-			break;
-		case BAN_CHARACTER:
-			if(!normalizePlayerName(nameOrIP))
+                SetSentErrorMessage(true);
+                return false;
+            }
+            break;
+        case BAN_CHARACTER:
+            if(!normalizePlayerName(nameOrIP))
             {
                 SendSysMessage(LANG_PLAYER_NOT_FOUND);
@@ -5063,44 +5069,44 @@
                 return false;
             }
-			break;
-		case BAN_IP:
-			if(!IsIPAddress(nameOrIP.c_str()))
-				return false;
-			break;
-	}
-
-	if(sWorld.RemoveBanAccount(mode,nameOrIP))
-		PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str());
-	else
-		PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str());
-
-	return true;
+            break;
+        case BAN_IP:
+            if(!IsIPAddress(nameOrIP.c_str()))
+                return false;
+            break;
+    }
+
+    if(sWorld.RemoveBanAccount(mode,nameOrIP))
+        PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str());
+    else
+        PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str());
+
+    return true;
 }
 
 bool ChatHandler::HandleBanInfoAccountCommand(const char* args)
 {
-	if(!args)
-		return false;
-
-	char* cname = strtok((char*)args, "");
-	if(!cname)
-		return false;
-
-	std::string account_name = cname;
-	if(!AccountMgr::normilizeString(account_name))
-	{
-		PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		SetSentErrorMessage(true);
-		return false;
-    }
-    
-	uint32 accountid = accmgr.GetId(account_name);
-	if(!accountid)
+    if(!args)
+        return false;
+
+    char* cname = strtok((char*)args, "");
+    if(!cname)
+        return false;
+
+    std::string account_name = cname;
+    if(!AccountMgr::normilizeString(account_name))
     {
         PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		return true;
-    }
-    
-	return HandleBanInfoHelper(accountid,account_name.c_str());
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    uint32 accountid = accmgr.GetId(account_name);
+    if(!accountid)
+    {
+        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+        return true;
+    }
+
+    return HandleBanInfoHelper(accountid,account_name.c_str());
 }
 
@@ -5111,141 +5117,141 @@
 
     char* cname = strtok ((char*)args, "");
-	if(!cname)
+    if(!cname)
         return false;
 
     std::string name = cname;
-	if(!normalizePlayerName(name))
-	{
-		SendSysMessage(LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage(true);
-		return false;
-	}
+    if(!normalizePlayerName(name))
+    {
+        SendSysMessage(LANG_PLAYER_NOT_FOUND);
+        SetSentErrorMessage(true);
+        return false;
+    }
 
     uint32 accountid = objmgr.GetPlayerAccountIdByPlayerName(name);
-	if(!accountid)
+    if(!accountid)
     {
         SendSysMessage(LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	std::string accountname;
-	if(!accmgr.GetName(accountid,accountname))
-	{
-		PSendSysMessage(LANG_BANINFO_NOCHARACTER);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    std::string accountname;
+    if(!accmgr.GetName(accountid,accountname))
+    {
+        PSendSysMessage(LANG_BANINFO_NOCHARACTER);
         return true;
     }
-    
-	return HandleBanInfoHelper(accountid,accountname.c_str());
+
+    return HandleBanInfoHelper(accountid,accountname.c_str());
 }
 
 bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname)
 {
-	QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid);
-	if(!result)
+    QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid);
+    if(!result)
     {
         PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname);
-		return true;
-    }
-    
-	PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname);
-	do
+        return true;
+    }
+
+    PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname);
+    do
     {
         Field* fields = result->Fetch();
 
-		time_t unbandate = time_t(fields[3].GetUInt64());
-		bool active = false;
-		if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) )
-			active = true;
-		bool permanent = (fields[1].GetUInt64() == (uint64)0);
-		std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true);
-		PSendSysMessage(LANG_BANINFO_HISTORYENTRY,
-			fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString());
-	}while (result->NextRow());
-
-	delete result;
-	return true;
+        time_t unbandate = time_t(fields[3].GetUInt64());
+        bool active = false;
+        if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) )
+            active = true;
+        bool permanent = (fields[1].GetUInt64() == (uint64)0);
+        std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true);
+        PSendSysMessage(LANG_BANINFO_HISTORYENTRY,
+            fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString());
+    }while (result->NextRow());
+
+    delete result;
+    return true;
 }
 
 bool ChatHandler::HandleBanInfoIPCommand(const char* args)
 {
-	if(!args)
-		return false;
-
-	char* cIP = strtok ((char*)args, "");
-	if(!cIP)
-		return false;
-
-	if (!IsIPAddress(cIP))
-		return false;
-
-	std::string IP = cIP;
-
-	loginDatabase.escape_string(IP);
-	QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str());
-	if(!result)
-	{
-		PSendSysMessage(LANG_BANINFO_NOIP);
-		return true;
-    }
-    
-	Field *fields = result->Fetch();
-	bool permanent = !fields[6].GetUInt64();
-	PSendSysMessage(LANG_BANINFO_IPENTRY,
-		fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(),
-		permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString());
-	delete result;
-	return true;
+    if(!args)
+        return false;
+
+    char* cIP = strtok ((char*)args, "");
+    if(!cIP)
+        return false;
+
+    if (!IsIPAddress(cIP))
+        return false;
+
+    std::string IP = cIP;
+
+    loginDatabase.escape_string(IP);
+    QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str());
+    if(!result)
+    {
+        PSendSysMessage(LANG_BANINFO_NOIP);
+        return true;
+    }
+
+    Field *fields = result->Fetch();
+    bool permanent = !fields[6].GetUInt64();
+    PSendSysMessage(LANG_BANINFO_IPENTRY,
+        fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(),
+        permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString());
+    delete result;
+    return true;
 }
 
 bool ChatHandler::HandleBanListCharacterCommand(const char* args)
 {
-	loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
-
-	char* cFilter = strtok ((char*)args, " ");
-	if(!cFilter)
-        return false;
-
-	std::string filter = cFilter;
-	loginDatabase.escape_string(filter);
-	QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str());
-	if (!result)
-	{
-		PSendSysMessage(LANG_BANLIST_NOCHARACTER);
-		return true;
-	}
-
-	return HandleBanListHelper(result);
+    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
+
+    char* cFilter = strtok ((char*)args, " ");
+    if(!cFilter)
+        return false;
+
+    std::string filter = cFilter;
+    loginDatabase.escape_string(filter);
+    QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str());
+    if (!result)
+    {
+        PSendSysMessage(LANG_BANLIST_NOCHARACTER);
+        return true;
+    }
+
+    return HandleBanListHelper(result);
 }
 
 bool ChatHandler::HandleBanListAccountCommand(const char* args)
 {
-	loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
-
-	char* cFilter = strtok((char*)args, " ");
-	std::string filter = cFilter ? cFilter : "";
-	loginDatabase.escape_string(filter);
-
-	QueryResult* result;
-
-	if(filter.empty())
-	{
-		 result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned"
-			 " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
-	}
-	else
-	{
-		result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned"
-			" WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id",
-			filter.c_str());
-	}
-
-	if (!result)
-	{
-		PSendSysMessage(LANG_BANLIST_NOACCOUNT);
-		return true;
-	}
-
-	return HandleBanListHelper(result);
+    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
+
+    char* cFilter = strtok((char*)args, " ");
+    std::string filter = cFilter ? cFilter : "";
+    loginDatabase.escape_string(filter);
+
+    QueryResult* result;
+
+    if(filter.empty())
+    {
+        result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned"
+            " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
+    }
+    else
+    {
+        result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned"
+            " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id",
+            filter.c_str());
+    }
+
+    if (!result)
+    {
+        PSendSysMessage(LANG_BANLIST_NOACCOUNT);
+        return true;
+    }
+
+    return HandleBanListHelper(result);
 }
 
@@ -5253,146 +5259,147 @@
 {
     PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT);
-    
-	// Chat short output
-	if(m_session)
+
+    // Chat short output
+    if(m_session)
     {
         do
-		{
-			Field* fields = result->Fetch();
-			uint32 accountid = fields[0].GetUInt32();
-
-			QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid);
-			if(banresult)
-			{
-				Field* fields2 = banresult->Fetch();
-				PSendSysMessage("%s",fields2[0].GetString());
-				delete banresult;
-			}
-		} while (result->NextRow());
-	}
-	// Console wide output
-	else
-	{
-		SendSysMessage(LANG_BANLIST_ACCOUNTS);
-		SendSysMessage("===============================================================================");
-		SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER);
-		do
-		{
-			SendSysMessage("-------------------------------------------------------------------------------");
-			Field *fields = result->Fetch();
-			uint32 account_id = fields[0].GetUInt32 ();
-
-			std::string account_name;
-
-			// "account" case, name can be get in same quary
-			if(result->GetFieldCount() > 1)
-				account_name = fields[1].GetCppString();
-			// "character" case, name need extract from another DB
-			else
-				accmgr.GetName (account_id,account_name);
-
-			// No SQL injection. id is uint32.
-			QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id);
-			if (banInfo)
-			{
-				Field *fields2 = banInfo->Fetch();
-				do
-				{
-					time_t t_ban = fields2[0].GetUInt64();
-					tm* aTm_ban = localtime(&t_ban);
-
-					if (fields2[0].GetUInt64() == fields2[1].GetUInt64())
-					{
-						PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|",
-							account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
-							fields2[2].GetString(),fields2[3].GetString());
-					}
-					else
-					{
-						time_t t_unban = fields2[1].GetUInt64();
-						tm* aTm_unban = localtime(&t_unban);
-						PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
-							account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
-							aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min,
-							fields2[2].GetString(),fields2[3].GetString());
-					}
-				}while ( banInfo->NextRow() );
-				delete banInfo;
-			}
-		}while( result->NextRow() );
-		SendSysMessage("===============================================================================");
-	}
-
-	delete result;
-	return true;
+        {
+            Field* fields = result->Fetch();
+            uint32 accountid = fields[0].GetUInt32();
+
+            QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid);
+            if(banresult)
+            {
+                Field* fields2 = banresult->Fetch();
+                PSendSysMessage("%s",fields2[0].GetString());
+                delete banresult;
+            }
+        } while (result->NextRow());
+    }
+    // Console wide output
+    else
+    {
+        SendSysMessage(LANG_BANLIST_ACCOUNTS);
+        SendSysMessage("===============================================================================");
+        SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER);
+        do
+        {
+            SendSysMessage("-------------------------------------------------------------------------------");
+            Field *fields = result->Fetch();
+            uint32 account_id = fields[0].GetUInt32 ();
+
+            std::string account_name;
+
+            // "account" case, name can be get in same query
+            if(result->GetFieldCount() > 1)
+                account_name = fields[1].GetCppString();
+            // "character" case, name need extract from another DB
+            else
+                accmgr.GetName (account_id,account_name);
+
+            // No SQL injection. id is uint32.
+            QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id);
+            if (banInfo)
+            {
+                Field *fields2 = banInfo->Fetch();
+                do
+                {
+                    time_t t_ban = fields2[0].GetUInt64();
+                    tm* aTm_ban = localtime(&t_ban);
+
+                    if (fields2[0].GetUInt64() == fields2[1].GetUInt64())
+                    {
+                        PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|",
+                            account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
+                            fields2[2].GetString(),fields2[3].GetString());
+                    }
+                    else
+                    {
+                        time_t t_unban = fields2[1].GetUInt64();
+                        tm* aTm_unban = localtime(&t_unban);
+                        PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
+                            account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
+                            aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min,
+                            fields2[2].GetString(),fields2[3].GetString());
+                    }
+                }while ( banInfo->NextRow() );
+                delete banInfo;
+            }
+        }while( result->NextRow() );
+        SendSysMessage("===============================================================================");
+    }
+
+    delete result;
+    return true;
 }
 
 bool ChatHandler::HandleBanListIPCommand(const char* args)
 {
-	loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
-
-	char* cFilter = strtok((char*)args, " ");
-	std::string filter = cFilter ? cFilter : "";
-	loginDatabase.escape_string(filter);
-
-	QueryResult* result;
-
-	if(filter.empty())
-	{
-		result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
-			" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
-			" ORDER BY unbandate" );
-	}
-	else
-	{
-		result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
-			" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")
-			" ORDER BY unbandate",filter.c_str() );
-	}
-
-	if(!result)
-	{
-		PSendSysMessage(LANG_BANLIST_NOIP);
-		return true;
-	}
-
-	PSendSysMessage(LANG_BANLIST_MATCHINGIP);
-	// Chat short output
-	if(m_session)
-	{
-		do
-		{
-			Field* fields = result->Fetch();
-			PSendSysMessage("%s",fields[0].GetString());
-		}while (result->NextRow());
-	}
-	// Console wide output
-	else
-	{
-		SendSysMessage(LANG_BANLIST_IPS);SendSysMessage("===============================================================================");
-		SendSysMessage(LANG_BANLIST_IPS_HEADER);
-		do
+    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
+
+    char* cFilter = strtok((char*)args, " ");
+    std::string filter = cFilter ? cFilter : "";
+    loginDatabase.escape_string(filter);
+
+    QueryResult* result;
+
+    if(filter.empty())
+    {
+        result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
+            " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
+            " ORDER BY unbandate" );
+    }
+    else
+    {
+        result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
+            " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")
+            " ORDER BY unbandate",filter.c_str() );
+    }
+
+    if(!result)
+    {
+        PSendSysMessage(LANG_BANLIST_NOIP);
+        return true;
+    }
+
+    PSendSysMessage(LANG_BANLIST_MATCHINGIP);
+    // Chat short output
+    if(m_session)
+    {
+        do
+        {
+            Field* fields = result->Fetch();
+            PSendSysMessage("%s",fields[0].GetString());
+        } while (result->NextRow());
+    }
+    // Console wide output
+    else
+    {
+        SendSysMessage(LANG_BANLIST_IPS);
+        SendSysMessage("===============================================================================");
+        SendSysMessage(LANG_BANLIST_IPS_HEADER);
+        do
         {
             SendSysMessage("-------------------------------------------------------------------------------");
-			Field *fields = result->Fetch();
-			time_t t_ban = fields[1].GetUInt64();
-			tm* aTm_ban = localtime(&t_ban);
-			if ( fields[1].GetUInt64() == fields[2].GetUInt64() )
-			{
-				PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|",
-					fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
-					fields[3].GetString(), fields[4].GetString());
-			}
-			else
-			{
-				time_t t_unban = fields[2].GetUInt64();
-				tm* aTm_unban = localtime(&t_unban);
-				PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
-					fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
-					aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min,
-					fields[3].GetString(), fields[4].GetString());
-			}
-		}while( result->NextRow() );
-		SendSysMessage("===============================================================================");
+            Field *fields = result->Fetch();
+            time_t t_ban = fields[1].GetUInt64();
+            tm* aTm_ban = localtime(&t_ban);
+            if ( fields[1].GetUInt64() == fields[2].GetUInt64() )
+            {
+                PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|",
+                    fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
+                    fields[3].GetString(), fields[4].GetString());
+            }
+            else
+            {
+                time_t t_unban = fields[2].GetUInt64();
+                tm* aTm_unban = localtime(&t_unban);
+                PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
+                    fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min,
+                    aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min,
+                    fields[3].GetString(), fields[4].GetString());
+            }
+        }while( result->NextRow() );
+        SendSysMessage("===============================================================================");
     }
 
@@ -5403,13 +5410,21 @@
 bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
 {
+    Player* pl = m_session->GetPlayer();
+
+    // accept only explicitly selected target (not implicitly self targeting case)
     Unit* target = getSelectedUnit();
-
-    if(target && target->GetTypeId() == TYPEID_UNIT && target->isDead())
-    {
-        ((Creature*)target)->Respawn();
+    if(pl->GetSelection() && target)
+    {
+        if(target->GetTypeId()!=TYPEID_UNIT)
+        {
+            SendSysMessage(LANG_SELECT_CREATURE);
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        if(target->isDead())
+            ((Creature*)target)->Respawn();
         return true;
     }
-
-    Player* pl = m_session->GetPlayer();
 
     CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY()));
@@ -5456,22 +5471,22 @@
 bool ChatHandler::HandleLoadPDumpCommand(const char *args)
 {
-    if (!args)
+    if(!args)
         return false;
 
     char * file = strtok((char*)args, " ");
-	if(!file)
-		return false;
-
-	char * account = strtok(NULL, " ");
-	if(!account)
-		return false;
-
-	std::string account_name = account;
-	if(!AccountMgr::normilizeString(account_name))
-	{
-		PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		SetSentErrorMessage(true);
-        return false;
-	}
+    if(!file)
+        return false;
+
+    char * account = strtok(NULL, " ");
+    if(!account)
+        return false;
+
+    std::string account_name = account;
+    if(!AccountMgr::normilizeString(account_name))
+    {
+        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+        SetSentErrorMessage(true);
+        return false;
+    }
 
     uint32 account_id = accmgr.GetId(account_name);
@@ -5482,39 +5497,39 @@
         {
             PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-			SetSentErrorMessage(true);
-			return false;
+            SetSentErrorMessage(true);
+            return false;
         }
-	}
-
-	if(!accmgr.GetName(account_id,account_name))
-	{
-		PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	char* guid_str = NULL;
-	char* name_str = strtok(NULL, " ");
-
-	std::string name;
-	if(name_str)
-	{
-		name = name_str;
-		// normalize the name if specified and check if it exists
-		if(!normalizePlayerName(name))
-		{
-			PSendSysMessage(LANG_INVALID_CHARACTER_NAME);
-			SetSentErrorMessage(true);
-			return false;
-		}
-
-		if(!ObjectMgr::IsValidName(name,true))
-		{
-			PSendSysMessage(LANG_INVALID_CHARACTER_NAME);
-			SetSentErrorMessage(true);
+    }
+
+    if(!accmgr.GetName(account_id,account_name))
+    {
+        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    char* guid_str = NULL;
+    char* name_str = strtok(NULL, " ");
+
+    std::string name;
+    if(name_str)
+    {
+        name = name_str;
+        // normalize the name if specified and check if it exists
+        if(!normalizePlayerName(name))
+        {
+            PSendSysMessage(LANG_INVALID_CHARACTER_NAME);
+            SetSentErrorMessage(true);
             return false;
-		}
-
-		guid_str = strtok(NULL, " ");
+        }
+
+        if(!ObjectMgr::IsValidName(name,true))
+        {
+            PSendSysMessage(LANG_INVALID_CHARACTER_NAME);
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        guid_str = strtok(NULL, " ");
     }
 
@@ -5522,43 +5537,43 @@
 
     if(guid_str)
-	{
-		guid = atoi(guid_str);
-		if(!guid)
-		{
-			PSendSysMessage(LANG_INVALID_CHARACTER_GUID);
-			SetSentErrorMessage(true);
-			return false;
-		}
-		
-		if(objmgr.GetPlayerAccountIdByGUID(guid))
-		{
-			PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid);
-			SetSentErrorMessage(true);
-			return false;
-		}
-	}
-
-	switch(PlayerDumpReader().LoadDump(file, account_id, name, guid))
-	{
-		case DUMP_SUCCESS:
-			PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
-			break;
-		case DUMP_FILE_OPEN_ERROR:
-			PSendSysMessage(LANG_FILE_OPEN_FAIL,file);
-			SetSentErrorMessage(true);
-			return false;
-		case DUMP_FILE_BROKEN:
-			PSendSysMessage(LANG_DUMP_BROKEN,file);
-			SetSentErrorMessage(true);
-			return false;
-		case DUMP_TOO_MANY_CHARS:
-			PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id);
-			SetSentErrorMessage(true);
-			return false;
-		default:
-			PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
-			SetSentErrorMessage(true);
-			return false;
-	}
+    {
+        guid = atoi(guid_str);
+        if(!guid)
+        {
+            PSendSysMessage(LANG_INVALID_CHARACTER_GUID);
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        if(objmgr.GetPlayerAccountIdByGUID(guid))
+        {
+            PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid);
+            SetSentErrorMessage(true);
+            return false;
+        }
+    }
+
+    switch(PlayerDumpReader().LoadDump(file, account_id, name, guid))
+    {
+        case DUMP_SUCCESS:
+            PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
+            break;
+        case DUMP_FILE_OPEN_ERROR:
+            PSendSysMessage(LANG_FILE_OPEN_FAIL,file);
+            SetSentErrorMessage(true);
+            return false;
+        case DUMP_FILE_BROKEN:
+            PSendSysMessage(LANG_DUMP_BROKEN,file);
+            SetSentErrorMessage(true);
+            return false;
+        case DUMP_TOO_MANY_CHARS:
+            PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id);
+            SetSentErrorMessage(true);
+            return false;
+        default:
+            PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
+            SetSentErrorMessage(true);
+            return false;
+    }
 
     return true;
@@ -5605,24 +5620,24 @@
 
     if(!objmgr.GetPlayerAccountIdByGUID(guid))
-	{
-		PSendSysMessage(LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	switch(PlayerDumpWriter().WriteDump(file, guid))
-	{
-		case DUMP_SUCCESS:
-			PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
-			break;
-		case DUMP_FILE_OPEN_ERROR:
-			PSendSysMessage(LANG_FILE_OPEN_FAIL,file);
-			SetSentErrorMessage(true);
-			return false;
-		default:
-			PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
-			SetSentErrorMessage(true);
-			return false;
-	}
+    {
+        PSendSysMessage(LANG_PLAYER_NOT_FOUND);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    switch(PlayerDumpWriter().WriteDump(file, guid))
+    {
+        case DUMP_SUCCESS:
+            PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
+            break;
+        case DUMP_FILE_OPEN_ERROR:
+            PSendSysMessage(LANG_FILE_OPEN_FAIL,file);
+            SetSentErrorMessage(true);
+            return false;
+        default:
+            PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
+            SetSentErrorMessage(true);
+            return false;
+    }
 
     return true;
@@ -5831,5 +5846,5 @@
     caster->SendMessageToSet(&data,true);
 
-    caster->CastSpell(m_session->GetPlayer(),spell,false);
+    caster->CastSpell(m_session->GetPlayer(),spell,triggered);
 
     return true;
@@ -5840,5 +5855,4 @@
     if(!*args)
         return false;
-
 
     // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
@@ -5923,5 +5937,5 @@
     caster->SendMessageToSet(&data,true);
 
-    caster->CastSpell(caster->getVictim(),spell,false);
+    caster->CastSpell(caster->getVictim(),spell,triggered);
 
     return true;
@@ -6111,26 +6125,26 @@
 bool ChatHandler::HandleGMListFullCommand(const char* /*args*/)
 {
-	///- Get the accounts with GM Level >0
-	QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
-	if(result)
-	{
-		SendSysMessage(LANG_GMLIST);
-		SendSysMessage("========================");
-		SendSysMessage(LANG_GMLIST_HEADER);
-		SendSysMessage("========================");
-
-		///- Circle through them. Display username and GM level
-		do
-		{
-			Field *fields = result->Fetch();
-			PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString());
-		} while( result->NextRow() );
-
-		PSendSysMessage("========================");
-		delete result;
-	}
-	else
-		PSendSysMessage(LANG_GMLIST_EMPTY);
-	return true;
+    ///- Get the accounts with GM Level >0
+    QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
+    if(result)
+    {
+        SendSysMessage(LANG_GMLIST);
+        SendSysMessage("========================");
+        SendSysMessage(LANG_GMLIST_HEADER);
+        SendSysMessage("========================");
+
+        ///- Circle through them. Display username and GM level
+        do
+        {
+            Field *fields = result->Fetch();
+            PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString());
+        }while( result->NextRow() );
+
+        PSendSysMessage("========================");
+        delete result;
+    }
+    else
+        PSendSysMessage(LANG_GMLIST_EMPTY);
+    return true;
 }
 
@@ -6138,7 +6152,7 @@
 bool ChatHandler::HandleServerSetMotdCommand(const char* args)
 {
-	sWorld.SetMotd(args);
-	PSendSysMessage(LANG_MOTD_NEW, args);
-	return true;
+    sWorld.SetMotd(args);
+    PSendSysMessage(LANG_MOTD_NEW, args);
+    return true;
 }
 
@@ -6146,52 +6160,52 @@
 bool ChatHandler::HandleAccountSetAddonCommand(const char* args)
 {
-	///- Get the command line arguments
-	char *szAcc = strtok((char*)args," ");
-	char *szExp = strtok(NULL," ");
-
-	if(!szAcc)
-		return false;
-
-	std::string account_name;
-	uint32 account_id;
-
-	if(!szExp)
-	{
-		Player* player = getSelectedPlayer();
-		if(!player)
-			return false;
-
-		account_id = player->GetSession()->GetAccountId();
-		accmgr.GetName(account_id,account_name);
-		szExp = szAcc;
-	}
-	else
-	{
-		///- Convert Account name to Upper Format
-		account_name = szAcc;
-		if(!AccountMgr::normilizeString(account_name))
-		{
-			PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-			SetSentErrorMessage(true);
-			return false;
-		}
-
-		account_id = accmgr.GetId(account_name);
-		if(!account_id)
-		{
-			PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
-			SetSentErrorMessage(true);
-			return false;
-		}
-	}
-
-	int lev=atoi(szExp);                                    //get int anyway (0 if error)
-	if(lev < 0)
-		return false;
-
-	// No SQL injection
-	loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id);
-	PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev);
-	return true;
+    ///- Get the command line arguments
+    char *szAcc = strtok((char*)args," ");
+    char *szExp = strtok(NULL," ");
+
+    if(!szAcc)
+        return false;
+
+    std::string account_name;
+    uint32 account_id;
+
+    if(!szExp)
+    {
+        Player* player = getSelectedPlayer();
+        if(!player)
+            return false;
+
+        account_id = player->GetSession()->GetAccountId();
+        accmgr.GetName(account_id,account_name);
+        szExp = szAcc;
+    }
+    else
+    {
+        ///- Convert Account name to Upper Format
+        account_name = szAcc;
+        if(!AccountMgr::normilizeString(account_name))
+        {
+            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        account_id = accmgr.GetId(account_name);
+        if(!account_id)
+        {
+            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
+            SetSentErrorMessage(true);
+            return false;
+        }
+    }
+
+    int lev=atoi(szExp);                                    //get int anyway (0 if error)
+    if(lev < 0)
+        return false;
+
+    // No SQL injection
+    loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id);
+    PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev);
+    return true;
 }
 
@@ -6199,125 +6213,125 @@
 bool ChatHandler::HandleSendMessageCommand(const char* args)
 {
-	///- Get the command line arguments
-	char* name_str = strtok((char*)args, " ");
-	char* msg_str = strtok(NULL, "");
-
-	if(!name_str || !msg_str)
-		return false;
-
-	std::string name = name_str;
-
-	if(!normalizePlayerName(name))
-		return false;
-
-	///- Find the player and check that he is not logging out.
-	Player *rPlayer = objmgr.GetPlayer(name.c_str());
-	if(!rPlayer)
-	{
-		SendSysMessage(LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	if(rPlayer->GetSession()->isLogingOut())
-	{
-		SendSysMessage(LANG_PLAYER_NOT_FOUND);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	///- Send the message
-	//Use SendAreaTriggerMessage for fastest delivery.
-	rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str);
-	rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
-
-	//Confirmation message
-	PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str);
-	return true;
+    ///- Get the command line arguments
+    char* name_str = strtok((char*)args, " ");
+    char* msg_str = strtok(NULL, "");
+
+    if(!name_str || !msg_str)
+        return false;
+
+    std::string name = name_str;
+
+    if(!normalizePlayerName(name))
+        return false;
+
+    ///- Find the player and check that he is not logging out.
+    Player *rPlayer = objmgr.GetPlayer(name.c_str());
+    if(!rPlayer)
+    {
+        SendSysMessage(LANG_PLAYER_NOT_FOUND);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    if(rPlayer->GetSession()->isLogingOut())
+    {
+        SendSysMessage(LANG_PLAYER_NOT_FOUND);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    ///- Send the message
+    //Use SendAreaTriggerMessage for fastest delivery.
+    rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str);
+    rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
+
+    //Confirmation message
+    PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str);
+    return true;
 }
 
 bool ChatHandler::HandlePlayAllCommand(const char* args)
 {
-	if(!*args)
-		return false;
-
-	uint32 soundId = atoi((char*)args);
-
-	if(!sSoundEntriesStore.LookupEntry(soundId))
-	{
-		PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	WorldPacket data(SMSG_PLAY_SOUND, 4);
-	data << uint32(soundId) << m_session->GetPlayer()->GetGUID();
-	sWorld.SendGlobalMessage(&data);
-
-	PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
-	return true;
+    if(!*args)
+        return false;
+
+    uint32 soundId = atoi((char*)args);
+
+    if(!sSoundEntriesStore.LookupEntry(soundId))
+    {
+        PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    WorldPacket data(SMSG_PLAY_SOUND, 4);
+    data << uint32(soundId) << m_session->GetPlayer()->GetGUID();
+    sWorld.SendGlobalMessage(&data);
+
+    PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
+    return true;
 }
 
 bool ChatHandler::HandleModifyGenderCommand(const char *args)
 {
-	if(!*args)	return false;
-	Player *player = getSelectedPlayer();
-
-	if(!player)
-	{
-		PSendSysMessage(LANG_NO_PLAYER);
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	std::string gender = (char*)args;
-	uint32 displayId = player->GetNativeDisplayId();
-
-	if(gender == "male") // MALE
-	{
-		if(player->getGender() == GENDER_MALE)
-		{
-			PSendSysMessage("%s is already male", player->GetName());
-			SetSentErrorMessage(true);
-			return false;
-		}
-
-		// Set gender
-		player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE);
-		// Change display ID
-		player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
-		player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
-
-		ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!");
-		PSendSysMessage("Gender changed for %s", player->GetName());
-		return true;
-	}
-	else if(gender == "female") // FEMALE
-	{
-		if(player->getGender() == GENDER_FEMALE)
-		{
-			PSendSysMessage("%s is already female", player->GetName());
-			SetSentErrorMessage(true);
-			return false;
-		}
-
-		// Set gender
-		player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE);
-		// Change display ID
-		player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
-		player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
-
-		ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!");
-		PSendSysMessage("Gender changed for %s", player->GetName());
-		return true;
-	}
-	else
-	{
-		PSendSysMessage("You must use male or female as gender.");
-		SetSentErrorMessage(true);
-		return false;
-	}
-
-	return true;
+    if(!*args)	return false;
+    Player *player = getSelectedPlayer();
+
+    if(!player)
+    {
+        PSendSysMessage(LANG_NO_PLAYER);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    std::string gender = (char*)args;
+    uint32 displayId = player->GetNativeDisplayId();
+
+    if(gender == "male") // MALE
+    {
+        if(player->getGender() == GENDER_MALE)
+        {
+            PSendSysMessage("%s is already male", player->GetName());
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        // Set gender
+        player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE);
+        // Change display ID
+        player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
+        player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
+
+        ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!");
+        PSendSysMessage("Gender changed for %s", player->GetName());
+        return true;
+    }
+    else if(gender == "female") // FEMALE
+    {
+        if(player->getGender() == GENDER_FEMALE)
+        {
+            PSendSysMessage("%s is already female", player->GetName());
+            SetSentErrorMessage(true);
+            return false;
+        }
+
+        // Set gender
+        player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE);
+        // Change display ID
+        player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
+        player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
+
+        ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!");
+        PSendSysMessage("Gender changed for %s", player->GetName());
+        return true;
+    }
+    else
+    {
+        PSendSysMessage("You must use male or female as gender.");
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    return true;
 }
 
@@ -6332,6 +6346,6 @@
         if (player) //prevent crash with creature as target
         {   
-           name = player->GetName();
-           normalizePlayerName(name);
+            name = player->GetName();
+            normalizePlayerName(name);
         }
     }
@@ -6342,5 +6356,5 @@
         player = objmgr.GetPlayer(name.c_str()); //get player by name
     }
-    
+
     if (!player)
     {
@@ -6364,5 +6378,5 @@
         player->CombatStop();
         if(player->IsNonMeleeSpellCasted(true))
-        player->InterruptNonMeleeSpells(true);
+            player->InterruptNonMeleeSpells(true);
         player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         player->SetUInt32Value(PLAYER_DUEL_TEAM, 1);
@@ -6376,5 +6390,5 @@
                 // not let dismiss dead pet
                 if(pet && pet->isAlive())
-                player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT);
+                    player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT);
             }
         }
@@ -6397,5 +6411,5 @@
                     Aura *Aur = CreateAura(spellInfo, i, NULL, player);
                     player->AddAura(Aur);
-               }
+                }
             }
         }
@@ -6417,5 +6431,5 @@
         if (player) //prevent crash with creature as target
         {   
-           name = player->GetName();
+            name = player->GetName();
         }
     }
@@ -6485,7 +6499,7 @@
     //Header of the names
     PSendSysMessage(LANG_COMMAND_LIST_FREEZE);
-    
+
     //Output of the results
-	do
+    do
     {
         Field *fields = result->Fetch();
