Show
Ignore:
Timestamp:
11/19/08 13:44:16 (17 years ago)
Author:
yumileroy
Message:

[svn] Merge from mangos:
b44eac552a0f9d4f298398d4cb07d2cd1462ad41 Use .respawn only for selected creature (if any) Tue Oct 28 08:34:35 2008
91988e44158fe5a7611d34612bc192aa7988de06 Fixed crash at using .account set gmlevel with wrong args.

Original author: megamage
Date: 2008-11-06 16:51:46-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Level3.cpp

    r177 r184  
    11/* 
    2  * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 
    3  * 
    4  * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 
    5  * 
    6  * This program is free software; you can redistribute it and/or modify 
    7  * it under the terms of the GNU General Public License as published by 
    8  * the Free Software Foundation; either version 2 of the License, or 
    9  * (at your option) any later version. 
    10  * 
    11  * This program is distributed in the hope that it will be useful, 
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    14  * GNU General Public License for more details. 
    15  * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    19  */ 
     2* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 
     3* 
     4* Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 
     5* 
     6* This program is free software; you can redistribute it and/or modify 
     7* it under the terms of the GNU General Public License as published by 
     8* the Free Software Foundation; either version 2 of the License, or 
     9* (at your option) any later version. 
     10* 
     11* This program is distributed in the hope that it will be useful, 
     12* but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     14* GNU General Public License for more details. 
     15* 
     16* You should have received a copy of the GNU General Public License 
     17* along with this program; if not, write to the Free Software 
     18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     19*/ 
    2020 
    2121#include "Common.h" 
     
    164164} 
    165165 
    166 bool ChatHandler::HandleReloadAllLocalesCommand(const char* args) 
     166bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/) 
    167167{ 
    168168    HandleReloadLocalesCreatureCommand("a"); 
     
    175175} 
    176176 
    177 bool ChatHandler::HandleReloadConfigCommand(const char* arg) 
     177bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/) 
    178178{ 
    179179    sLog.outString( "Re-Loading config settings..." ); 
     
    435435    sLog.outString( "Re-Loading Spell Elixir types..." ); 
    436436    spellmgr.LoadSpellElixirs(); 
    437     SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded."); 
     437    SendGlobalSysMessage("DB table `spell_elixir` (spell elixir types) reloaded."); 
    438438    return true; 
    439439} 
     
    698698        return false; 
    699699 
     700    /// must be NULL if targeted syntax and must be not nULL if not targeted 
    700701    char* arg2 = strtok(NULL, " "); 
    701702 
     
    704705    uint32 targetSecurity = 0; 
    705706 
    706         /// only target player different from self allowed (if targetPlayer!=NULL then not console) 
     707    /// only target player different from self allowed (if targetPlayer!=NULL then not console) 
    707708    Player* targetPlayer = getSelectedPlayer(); 
    708709    if(targetPlayer && m_session->GetPlayer()!=targetPlayer) 
    709710    { 
    710711        /// wrong command syntax or unexpected targeting 
    711                 if(arg2) 
    712                         return false; 
     712        if(arg2) 
     713            return false; 
     714 
     715        /// security level expected in arg2 after this if. 
     716        arg2 = arg1; 
    713717 
    714718        targetAccountId = targetPlayer->GetSession()->GetAccountId(); 
    715719        targetSecurity = targetPlayer->GetSession()->GetSecurity(); 
    716720        if(!accmgr.GetName(targetAccountId,targetAccountName)) 
    717                 { 
    718                         PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); 
    719                         SetSentErrorMessage(true); 
    720                         return false; 
    721                 } 
    722     } 
    723     else 
    724     { 
    725         targetAccountName = arg1; 
    726         if(!AccountMgr::normilizeString(targetAccountName)) 
    727721        { 
    728722            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); 
     
    730724            return false; 
    731725        } 
     726    } 
     727    else 
     728    { 
     729        /// wrong command syntax (second arg expected) 
     730        if(!arg2) 
     731            return false; 
     732 
     733        targetAccountName = arg1; 
     734        if(!AccountMgr::normilizeString(targetAccountName)) 
     735        { 
     736            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); 
     737            SetSentErrorMessage(true); 
     738            return false; 
     739        } 
    732740 
    733741        targetAccountId = accmgr.GetId(targetAccountName); 
    734                 targetSecurity = accmgr.GetSecurity(targetAccountId); 
     742        targetSecurity = accmgr.GetSecurity(targetAccountId); 
    735743    } 
    736744 
     
    744752 
    745753    /// m_session==NULL only for console 
    746         uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; 
    747  
    748         /// can set security level only for target with less security and to less security that we have 
    749         /// This is also reject self apply in fact 
    750         if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity ) 
     754    uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; 
     755 
     756    /// can set security level only for target with less security and to less security that we have 
     757    /// This is also reject self apply in fact 
     758    if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity ) 
    751759    { 
    752760        SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); 
     
    770778bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) 
    771779{ 
    772         if(!*args) 
    773                 return false; 
    774  
    775         ///- Get the command line arguments 
    776         char *szAccount = strtok ((char*)args," "); 
    777         char *szPassword1 =  strtok (NULL," "); 
    778         char *szPassword2 =  strtok (NULL," "); 
    779  
    780         if (!szAccount||!szPassword1 || !szPassword2) 
    781                 return false; 
    782  
    783         std::string account_name = szAccount; 
    784         if(!AccountMgr::normilizeString(account_name)) 
    785         { 
    786                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    787                 SetSentErrorMessage(true); 
    788                 return false; 
    789         } 
    790  
    791         uint32 targetAccountId = accmgr.GetId(account_name); 
    792         if (!targetAccountId) 
    793         { 
    794                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    795                 SetSentErrorMessage(true); 
    796                 return false; 
    797         } 
    798  
    799         uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); 
    800  
    801         /// m_session==NULL only for console 
    802         uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; 
    803  
    804         /// can set password only for target with less security 
    805         /// This is also reject self apply in fact 
    806         if (targetSecurity >= plSecurity) 
    807         { 
    808                 SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); 
    809                 SetSentErrorMessage (true); 
    810                 return false; 
    811         } 
    812  
    813         if (strcmp(szPassword1,szPassword2)) 
    814         { 
    815                 SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); 
    816                 SetSentErrorMessage (true); 
    817                 return false; 
    818         } 
    819  
    820         AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1); 
    821  
    822         switch(result) 
    823         { 
    824                 case AOR_OK: 
    825                         SendSysMessage(LANG_COMMAND_PASSWORD); 
    826                         break; 
    827                 case AOR_NAME_NOT_EXIST: 
    828                         PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    829                         SetSentErrorMessage(true); 
    830                         return false; 
    831                 case AOR_PASS_TOO_LONG: 
    832                         SendSysMessage(LANG_PASSWORD_TOO_LONG); 
    833                         SetSentErrorMessage(true); 
    834                         return false; 
    835                 default: 
    836                         SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); 
    837                         SetSentErrorMessage(true); 
    838                         return false; 
    839         } 
    840  
    841         return true; 
     780    if(!*args) 
     781        return false; 
     782 
     783    ///- Get the command line arguments 
     784    char *szAccount = strtok ((char*)args," "); 
     785    char *szPassword1 =  strtok (NULL," "); 
     786    char *szPassword2 =  strtok (NULL," "); 
     787 
     788    if (!szAccount||!szPassword1 || !szPassword2) 
     789        return false; 
     790 
     791    std::string account_name = szAccount; 
     792    if(!AccountMgr::normilizeString(account_name)) 
     793    { 
     794        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     795        SetSentErrorMessage(true); 
     796        return false; 
     797    } 
     798 
     799    uint32 targetAccountId = accmgr.GetId(account_name); 
     800    if (!targetAccountId) 
     801    { 
     802        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     803        SetSentErrorMessage(true); 
     804        return false; 
     805    } 
     806 
     807    uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); 
     808 
     809    /// m_session==NULL only for console 
     810    uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; 
     811 
     812    /// can set password only for target with less security 
     813    /// This is also reject self apply in fact 
     814    if (targetSecurity >= plSecurity) 
     815    { 
     816        SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); 
     817        SetSentErrorMessage (true); 
     818        return false; 
     819    } 
     820 
     821    if (strcmp(szPassword1,szPassword2)) 
     822    { 
     823        SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); 
     824        SetSentErrorMessage (true); 
     825        return false; 
     826    } 
     827 
     828    AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1); 
     829 
     830    switch(result) 
     831    { 
     832        case AOR_OK: 
     833            SendSysMessage(LANG_COMMAND_PASSWORD); 
     834            break; 
     835        case AOR_NAME_NOT_EXIST: 
     836            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     837            SetSentErrorMessage(true); 
     838            return false; 
     839        case AOR_PASS_TOO_LONG: 
     840            SendSysMessage(LANG_PASSWORD_TOO_LONG); 
     841            SetSentErrorMessage(true); 
     842            return false; 
     843        default: 
     844            SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); 
     845            SetSentErrorMessage(true); 
     846            return false; 
     847    } 
     848 
     849    return true; 
    842850} 
    843851 
     
    935943    if (!*args) 
    936944        return false; 
    937  
    938945 
    939946    // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r 
     
    14121419        "5916", 
    14131420        "6634", 
    1414         //"6718", phasing stealth, annoing for learn all case. 
     1421        //"6718", phasing stealth, annoying for learn all case. 
    14151422        "6719", 
    14161423        "8822", 
     
    17721779        } 
    17731780 
    1774         if(!spellid)                                        // ??? none spells in telent 
     1781        if(!spellid)                                        // ??? none spells in talent 
    17751782            continue; 
    17761783 
     
    20202027            { 
    20212028                Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true); 
     2029 
    20222030                // remove binding (let GM give it to another player later) 
    20232031                if (pl==plTarget) 
    20242032                    item->SetBinding( false ); 
    20252033 
    2026             pl->SendNewItem(item,1,false,true); 
    2027             if (pl!=plTarget) 
    2028                 plTarget->SendNewItem(item,1,true,false); 
     2034                pl->SendNewItem(item,1,false,true); 
     2035                if (pl!=plTarget) 
     2036                    plTarget->SendNewItem(item,1,true,false); 
    20292037            } 
    20302038            else 
     
    20432051        return false; 
    20442052    } 
     2053 
    20452054    return true; 
    20462055} 
     
    20562065 
    20572066    uint32 item_id = atol(cId); 
    2058         if(!item_id) 
    2059         { 
    2060                 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); 
    2061                 SetSentErrorMessage(true); 
    2062                 return false; 
    2063         } 
    2064  
    2065         ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_id); 
     2067    if(!item_id) 
     2068    { 
     2069        PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); 
     2070        SetSentErrorMessage(true); 
     2071        return false; 
     2072    } 
     2073 
     2074    ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_id); 
    20662075    if(!itemProto) 
    20672076    { 
     
    20892098 
    20902099    result=CharacterDatabase.PQuery( 
    2091     //          0        1             2             3        4                  5 
     2100        //          0        1             2             3        4                  5 
    20922101        "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " 
    20932102        "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " 
     
    21432152    { 
    21442153        result=CharacterDatabase.PQuery( 
    2145         //          0                     1            2              3               4            5               6 
     2154            //          0                     1            2              3               4            5               6 
    21462155            "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " 
    21472156            "FROM mail,mail_items,characters as char_s,characters as char_r " 
     
    21932202    { 
    21942203        result=CharacterDatabase.PQuery( 
    2195         //           0                      1                       2                   3 
     2204            //           0                      1                       2                   3 
    21962205            "SELECT  auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name " 
    21972206            "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u", 
     
    22202229 
    22212230    // guild bank case 
    2222         uint32 guild_count = 0; 
    2223         result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); 
    2224         if(result) 
    2225         { 
    2226                 guild_count = (*result)[0].GetUInt32(); 
    2227                 delete result; 
    2228         } 
    2229  
    2230         result=CharacterDatabase.PQuery( 
    2231                 //      0             1           2 
    2232                 "SELECT gi.item_guid, gi.guildid, guild.name " 
    2233                 "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", 
    2234                 item_id,uint32(count)); 
    2235  
    2236         if(result) 
    2237         { 
    2238                 do 
    2239                 { 
    2240                         Field *fields = result->Fetch(); 
    2241                         uint32 item_guid = fields[0].GetUInt32(); 
    2242                         uint32 guild_guid = fields[1].GetUInt32(); 
    2243                         std::string guild_name = fields[2].GetCppString(); 
    2244  
    2245                         char const* item_pos = "[in guild bank]"; 
    2246  
    2247                         PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); 
    2248                 } while (result->NextRow()); 
    2249  
    2250                 int64 res_count = result->GetRowCount(); 
    2251  
    2252                 delete result; 
    2253  
    2254                 if(count > res_count) 
    2255                         count-=res_count; 
    2256                 else if(count) 
    2257                         count = 0; 
    2258         } 
    2259  
    2260         if(inv_count+mail_count+auc_count+guild_count == 0) 
     2231    uint32 guild_count = 0; 
     2232    result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); 
     2233    if(result) 
     2234    { 
     2235        guild_count = (*result)[0].GetUInt32(); 
     2236        delete result; 
     2237    } 
     2238 
     2239    result=CharacterDatabase.PQuery( 
     2240        //      0             1           2 
     2241        "SELECT gi.item_guid, gi.guildid, guild.name " 
     2242        "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", 
     2243        item_id,uint32(count)); 
     2244 
     2245    if(result) 
     2246    { 
     2247        do 
     2248        { 
     2249            Field *fields = result->Fetch(); 
     2250            uint32 item_guid = fields[0].GetUInt32(); 
     2251            uint32 guild_guid = fields[1].GetUInt32(); 
     2252            std::string guild_name = fields[2].GetCppString(); 
     2253 
     2254            char const* item_pos = "[in guild bank]"; 
     2255 
     2256            PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); 
     2257        } while (result->NextRow()); 
     2258 
     2259        int64 res_count = result->GetRowCount(); 
     2260 
     2261        delete result; 
     2262 
     2263        if(count > res_count) 
     2264            count-=res_count; 
     2265        else if(count) 
     2266            count = 0; 
     2267    } 
     2268 
     2269    if(inv_count+mail_count+auc_count+guild_count == 0) 
    22612270    { 
    22622271        SendSysMessage(LANG_COMMAND_NOITEMFOUND); 
     
    22812290 
    22822291    uint32 go_id = atol(cId); 
    2283         if(!go_id) 
    2284         { 
    2285                 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); 
    2286                 SetSentErrorMessage(true); 
    2287                 return false; 
    2288         } 
     2292    if(!go_id) 
     2293    { 
     2294        PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); 
     2295        SetSentErrorMessage(true); 
     2296        return false; 
     2297    } 
    22892298 
    22902299    GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id); 
    2291         if(!gInfo) 
     2300    if(!gInfo) 
    22922301    { 
    22932302        PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); 
     
    23132322 
    23142323    if(m_session) 
    2315         { 
    2316                 Player* pl = m_session->GetPlayer(); 
    2317                 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", 
    2318                         pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); 
    2319         } 
    2320         else 
    2321                 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", 
    2322                 go_id,uint32(count)); 
     2324    { 
     2325        Player* pl = m_session->GetPlayer(); 
     2326        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", 
     2327            pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); 
     2328    } 
     2329    else 
     2330        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", 
     2331        go_id,uint32(count)); 
    23232332 
    23242333    if (result) 
     
    23342343 
    23352344            if (m_session) 
    2336                                 PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid); 
    2337                         else 
    2338                                 PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapid); 
     2345                PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid); 
     2346            else 
     2347                PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapid); 
    23392348        } while (result->NextRow()); 
    23402349 
     
    24362445 
    24372446    uint32 cr_id = atol(cId); 
    2438         if(!cr_id) 
    2439         { 
    2440                 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); 
    2441                 SetSentErrorMessage(true); 
    2442                 return false; 
    2443         } 
     2447    if(!cr_id) 
     2448    { 
     2449        PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); 
     2450        SetSentErrorMessage(true); 
     2451        return false; 
     2452    } 
    24442453 
    24452454    CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id); 
    2446         if(!cInfo) 
     2455    if(!cInfo) 
    24472456    { 
    24482457        PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); 
     
    24682477 
    24692478    if(m_session) 
    2470         { 
    2471                 Player* pl = m_session->GetPlayer(); 
    2472                 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", 
    2473                         pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); 
    2474         } 
    2475         else 
    2476                 result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", 
    2477                         cr_id,uint32(count)); 
     2479    { 
     2480        Player* pl = m_session->GetPlayer(); 
     2481        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", 
     2482            pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); 
     2483    } 
     2484    else 
     2485        result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", 
     2486        cr_id,uint32(count)); 
    24782487 
    24792488    if (result) 
     
    24892498 
    24902499            if  (m_session) 
    2491                                 PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapid); 
    2492                         else 
    2493                                 PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapid); 
     2500                PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapid); 
     2501            else 
     2502                PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapid); 
    24942503        } while (result->NextRow()); 
    24952504 
     
    25372546                    { 
    25382547                        if (m_session) 
    2539                                                         PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); 
    2540                                                 else 
    2541                                                         PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); 
     2548                            PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); 
     2549                        else 
     2550                            PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); 
    25422551                        ++counter; 
    25432552                        continue; 
     
    25542563        { 
    25552564            if (m_session) 
    2556                                 PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); 
    2557                         else 
    2558                                 PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); 
     2565                PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); 
     2566            else 
     2567                PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); 
    25592568            ++counter; 
    25602569        } 
     
    25902599        { 
    25912600            int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); 
    2592                         std::string name = set->name[loc]; 
     2601            std::string name = set->name[loc]; 
    25932602            if(name.empty()) 
    25942603                continue; 
     
    26152624                // send item set in "id - [namedlink locale]" format 
    26162625                if (m_session) 
    2617                                         PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]); 
    2618                                 else 
    2619                                         PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE,id,name.c_str(),localeNames[loc]); 
     2626                    PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]); 
     2627                else 
     2628                    PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE,id,name.c_str(),localeNames[loc]); 
    26202629                ++counter; 
    26212630            } 
     
    26292638bool ChatHandler::HandleLookupSkillCommand(const char* args) 
    26302639{ 
    2631         if (!*args) 
    2632         return false; 
    2633  
    2634         // can be NULL in console call 
    2635         Player* target = getSelectedPlayer(); 
     2640    if(!*args) 
     2641        return false; 
     2642 
     2643    // can be NULL in console call 
     2644    Player* target = getSelectedPlayer(); 
    26362645 
    26372646    std::string namepart = args; 
     
    26762685            if(loc < MAX_LOCALE) 
    26772686            { 
    2678                                 char const* knownStr = ""; 
    2679                                 if(target && target->HasSkill(id)) 
    2680                                         knownStr = GetTrinityString(LANG_KNOWN); 
     2687                char const* knownStr = ""; 
     2688                if(target && target->HasSkill(id)) 
     2689                    knownStr = GetTrinityString(LANG_KNOWN); 
    26812690 
    26822691                // send skill in "id - [namedlink locale]" format 
    26832692                if (m_session) 
    2684                                         PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr); 
    2685                                 else 
    2686                                         PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr); 
     2693                    PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr); 
     2694                else 
     2695                    PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr); 
    26872696 
    26882697                ++counter; 
     
    26972706bool ChatHandler::HandleLookupSpellCommand(const char* args) 
    26982707{ 
    2699         if (!*args) 
    2700         return false; 
    2701  
    2702         // can be NULL at console call 
    2703         Player* target = getSelectedPlayer(); 
     2708    if(!*args) 
     2709        return false; 
     2710 
     2711    // can be NULL at console call 
     2712    Player* target = getSelectedPlayer(); 
    27042713 
    27052714    std::string namepart = args; 
     
    27472756                bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); 
    27482757 
    2749                 uint32 telentCost = GetTalentSpellCost(id); 
    2750  
    2751                 bool talent = (telentCost > 0); 
     2758                uint32 talentCost = GetTalentSpellCost(id); 
     2759 
     2760                bool talent = (talentCost > 0); 
    27522761                bool passive = IsPassiveSpell(id); 
    27532762                bool active = target && (target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2)); 
     
    27552764                // unit32 used to prevent interpreting uint8 as char at output 
    27562765                // find rank of learned spell for learning spell, or talent rank 
    2757                 uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); 
     2766                uint32 rank = talentCost ? talentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); 
    27582767 
    27592768                // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format 
    27602769                std::ostringstream ss; 
    27612770                if (m_session) 
    2762                                         ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; 
    2763                                 else 
    2764                                         ss << id << " - " << name; 
     2771                    ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; 
     2772                else 
     2773                    ss << id << " - " << name; 
    27652774 
    27662775                // include rank in link name 
     
    27692778 
    27702779                if (m_session) 
    2771                                         ss << " " << localeNames[loc] << "]|h|r"; 
    2772                                 else 
    2773                                         ss << " " << localeNames[loc]; 
     2780                    ss << " " << localeNames[loc] << "]|h|r"; 
     2781                else 
     2782                    ss << " " << localeNames[loc]; 
    27742783 
    27752784                if(talent) 
     
    27972806bool ChatHandler::HandleLookupQuestCommand(const char* args) 
    27982807{ 
    2799         if (!*args) 
    2800         return false; 
    2801  
    2802         // can be NULL at console call 
    2803         Player* target = getSelectedPlayer(); 
     2808    if(!*args) 
     2809        return false; 
     2810 
     2811    // can be NULL at console call 
     2812    Player* target = getSelectedPlayer(); 
    28042813 
    28052814    std::string namepart = args; 
     
    28332842                        char const* statusStr = ""; 
    28342843 
    2835                                                 if(target) 
     2844                        if(target) 
    28362845                        { 
    28372846                            QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); 
    28382847 
    2839                                                         if(status == QUEST_STATUS_COMPLETE) 
    2840                                                         { 
    2841                                                                 if(target->GetQuestRewardStatus(qinfo->GetQuestId())) 
    2842                                                                         statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); 
    2843                                                                 else 
    2844                                                                         statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); 
    2845                                                         } 
    2846                                                         else if(status == QUEST_STATUS_INCOMPLETE) 
    2847                                                                 statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); 
     2848                            if(status == QUEST_STATUS_COMPLETE) 
     2849                            { 
     2850                                if(target->GetQuestRewardStatus(qinfo->GetQuestId())) 
     2851                                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); 
     2852                                else 
     2853                                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); 
     2854                            } 
     2855                            else if(status == QUEST_STATUS_INCOMPLETE) 
     2856                                statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); 
    28482857                        } 
    2849                          
    2850                                                 if (m_session) 
    2851                                                         PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); 
    2852                                                 else 
    2853                                                         PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); 
    2854  
     2858 
     2859                        if (m_session) 
     2860                            PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); 
     2861                        else 
     2862                            PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); 
    28552863                        ++counter; 
    28562864                        continue; 
     
    28672875        { 
    28682876            char const* statusStr = ""; 
    2869              
    2870                         if(target) 
     2877 
     2878            if(target) 
    28712879            { 
    28722880                QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); 
    28732881 
    2874                                 if(status == QUEST_STATUS_COMPLETE) 
    2875                                 { 
    2876                                         if(target->GetQuestRewardStatus(qinfo->GetQuestId())) 
    2877                                                 statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); 
    2878                                         else 
    2879                                                 statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); 
    2880                                 } 
    2881                                 else if(status == QUEST_STATUS_INCOMPLETE) 
    2882                                         statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); 
     2882                if(status == QUEST_STATUS_COMPLETE) 
     2883                { 
     2884                    if(target->GetQuestRewardStatus(qinfo->GetQuestId())) 
     2885                        statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); 
     2886                    else 
     2887                        statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); 
     2888                } 
     2889                else if(status == QUEST_STATUS_INCOMPLETE) 
     2890                    statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); 
    28832891            } 
    2884              
    2885                         if (m_session) 
    2886                                 PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); 
    2887                         else 
    2888                                 PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); 
     2892 
     2893            if (m_session) 
     2894                PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); 
     2895            else 
     2896                PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); 
    28892897 
    28902898            ++counter; 
     
    29212929 
    29222930        int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex(); 
    2923                 if (loc_idx >= 0) 
     2931        if (loc_idx >= 0) 
    29242932        { 
    29252933            CreatureLocale const *cl = objmgr.GetCreatureLocale (id); 
     
    29332941                    { 
    29342942                        if (m_session) 
    2935                                                         PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); 
    2936                                                 else 
    2937                                                         PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); 
    2938  
     2943                            PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); 
     2944                        else 
     2945                            PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); 
    29392946                        ++counter; 
    29402947                        continue; 
     
    29512958        { 
    29522959            if (m_session) 
    2953                                 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); 
    2954                         else 
    2955                                 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); 
     2960                PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); 
     2961            else 
     2962                PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); 
    29562963            ++counter; 
    29572964        } 
     
    29993006                    { 
    30003007                        if (m_session) 
    3001                                                         PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); 
    3002                                                 else 
    3003                                                         PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); 
     3008                            PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); 
     3009                        else 
     3010                            PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); 
    30043011                        ++counter; 
    30053012                        continue; 
     
    30163023        { 
    30173024            if (m_session) 
    3018                                 PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); 
    3019                         else 
    3020                                 PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); 
     3025                PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); 
     3026            else 
     3027                PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); 
    30213028            ++counter; 
    30223029        } 
     
    30443051 
    30453052    char *lname = strtok ((char*)args, " "); 
    3046         char *gname = strtok (NULL, ""); 
     3053    char *gname = strtok (NULL, ""); 
    30473054 
    30483055    if (!lname) 
    30493056        return false; 
    3050      
    3051         if (!gname) 
     3057 
     3058    if (!gname) 
    30523059    { 
    30533060        SendSysMessage (LANG_INSERT_GUILD_NAME); 
    3054                 SetSentErrorMessage (true); 
     3061        SetSentErrorMessage (true); 
    30553062        return false; 
    30563063    } 
     
    30593066 
    30603067    Player* player = ObjectAccessor::Instance ().FindPlayerByName (lname); 
    3061         if (!player) 
     3068    if (!player) 
    30623069    { 
    30633070        SendSysMessage (LANG_PLAYER_NOT_FOUND); 
    3064                 SetSentErrorMessage (true); 
     3071        SetSentErrorMessage (true); 
    30653072        return false; 
    30663073    } 
     
    30693076    { 
    30703077        SendSysMessage (LANG_PLAYER_IN_GUILD); 
    3071                 return true; 
    3072         } 
    3073  
    3074         Guild *guild = new Guild; 
    3075         if (!guild->create (player->GetGUID (),guildname)) 
    3076         { 
    3077                 delete guild; 
    3078                 SendSysMessage (LANG_GUILD_NOT_CREATED); 
    3079                 SetSentErrorMessage (true); 
    3080                 return false; 
    3081     } 
    3082      
    3083         objmgr.AddGuild (guild); 
     3078        return true; 
     3079    } 
     3080 
     3081    Guild *guild = new Guild; 
     3082    if (!guild->create (player->GetGUID (),guildname)) 
     3083    { 
     3084        delete guild; 
     3085        SendSysMessage (LANG_GUILD_NOT_CREATED); 
     3086        SetSentErrorMessage (true); 
     3087        return false; 
     3088    } 
     3089 
     3090    objmgr.AddGuild (guild); 
    30843091    return true; 
    30853092} 
     
    30973104    std::string glName = par2; 
    30983105    Guild* targetGuild = objmgr.GetGuildByName (glName); 
    3099         if (!targetGuild) 
     3106    if (!targetGuild) 
    31003107        return false; 
    31013108 
     
    31043111    { 
    31053112        SendSysMessage (LANG_PLAYER_NOT_FOUND); 
    3106                 SetSentErrorMessage (true); 
     3113        SetSentErrorMessage (true); 
    31073114        return false; 
    31083115    } 
     
    31103117    uint64 plGuid = 0; 
    31113118    if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ())) 
    3112                 plGuid = targetPlayer->GetGUID (); 
     3119        plGuid = targetPlayer->GetGUID (); 
    31133120    else 
    31143121        plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); 
     
    31173124        false; 
    31183125 
    3119     // players's guild membership checked in AddMember before add 
     3126    // player's guild membership checked in AddMember before add 
    31203127    if (!targetGuild->AddMember (plGuid,targetGuild->GetLowestRank ())) 
    31213128        return false; 
     
    31373144    { 
    31383145        SendSysMessage (LANG_PLAYER_NOT_FOUND); 
    3139                 SetSentErrorMessage (true); 
     3146        SetSentErrorMessage (true); 
    31403147        return false; 
    31413148    } 
     
    31463153    { 
    31473154        plGuid = targetPlayer->GetGUID (); 
    3148                 glId   = targetPlayer->GetGuildId (); 
     3155        glId   = targetPlayer->GetGuildId (); 
    31493156    } 
    31503157    else 
    31513158    { 
    31523159        plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); 
    3153                 glId = Player::GetGuildIdFromDB (plGuid); 
     3160        glId = Player::GetGuildIdFromDB (plGuid); 
    31543161    } 
    31553162 
     
    31583165 
    31593166    Guild* targetGuild = objmgr.GetGuildById (glId); 
    3160         if (!targetGuild) 
     3167    if (!targetGuild) 
    31613168        return false; 
    31623169 
     
    31723179 
    31733180    char* par1 = strtok ((char*)args, " "); 
    3174         char* par2 = strtok (NULL, " "); 
    3175         if (!par1 || !par2) 
    3176         return false; 
    3177  
     3181    char* par2 = strtok (NULL, " "); 
     3182    if (!par1 || !par2) 
     3183        return false; 
    31783184    std::string plName = par1; 
    31793185    if (!normalizePlayerName (plName)) 
    31803186    { 
    31813187        SendSysMessage (LANG_PLAYER_NOT_FOUND); 
    3182                 SetSentErrorMessage (true); 
     3188        SetSentErrorMessage (true); 
    31833189        return false; 
    31843190    } 
     
    31893195    { 
    31903196        plGuid = targetPlayer->GetGUID (); 
    3191                 glId   = targetPlayer->GetGuildId (); 
     3197        glId   = targetPlayer->GetGuildId (); 
    31923198    } 
    31933199    else 
    31943200    { 
    31953201        plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); 
    3196                 glId = Player::GetGuildIdFromDB (plGuid); 
     3202        glId = Player::GetGuildIdFromDB (plGuid); 
    31973203    } 
    31983204 
     
    32013207 
    32023208    Guild* targetGuild = objmgr.GetGuildById (glId); 
    3203         if (!targetGuild) 
     3209    if (!targetGuild) 
    32043210        return false; 
    32053211 
    32063212    uint32 newrank = uint32 (atoi (par2)); 
    3207         if (newrank > targetGuild->GetLowestRank ()) 
     3213    if (newrank > targetGuild->GetLowestRank ()) 
    32083214        return false; 
    32093215 
     
    32193225 
    32203226    char* par1 = strtok ((char*)args, " "); 
    3221         if (!par1) 
     3227    if (!par1) 
    32223228        return false; 
    32233229 
     
    32253231 
    32263232    Guild* targetGuild = objmgr.GetGuildByName (gld); 
    3227         if (!targetGuild) 
     3233    if (!targetGuild) 
    32283234        return false; 
    32293235 
     
    37933799        return false; 
    37943800    } 
    3795          
     3801 
    37963802    if (strncmp(args, "on", 3) == 0) 
    37973803        player->SetMovement(MOVE_WATER_WALK);               // ON 
     
    38323838            addlevel = atoi(px); 
    38333839    } 
    3834     // else .levelup - nothing do for prepering 
     3840    // else .levelup - nothing do for preparing 
    38353841 
    38363842    // player 
     
    39023908    else 
    39033909    { 
    3904         // update levle and XP at level, all other will be updated at loading 
     3910        // update level and XP at level, all other will be updated at loading 
    39053911        Tokens values; 
    39063912        Player::LoadValuesArrayFromDB(values,chr_guid); 
     
    49394945bool ChatHandler::HandleBanCharacterCommand(const char* args) 
    49404946{ 
    4941         return HandleBanHelper(BAN_CHARACTER,args); 
     4947    return HandleBanHelper(BAN_CHARACTER,args); 
    49424948} 
    49434949 
    49444950bool ChatHandler::HandleBanIPCommand(const char* args) 
    49454951{ 
    4946         return HandleBanHelper(BAN_IP,args); 
     4952    return HandleBanHelper(BAN_IP,args); 
    49474953} 
    49484954 
    49494955bool ChatHandler::HandleBanHelper(BanMode mode, const char* args) 
    49504956{ 
    4951         if(!args) 
     4957    if(!args) 
    49524958        return false; 
    49534959 
    49544960    char* cnameOrIP = strtok ((char*)args, " "); 
    4955         if (!cnameOrIP) 
     4961    if (!cnameOrIP) 
    49564962        return false; 
    49574963 
    49584964    std::string nameOrIP = cnameOrIP; 
    49594965 
    4960         char* duration = strtok (NULL," "); 
     4966    char* duration = strtok (NULL," "); 
    49614967    if(!duration || !atoi(duration)) 
    49624968        return false; 
     
    49674973 
    49684974    switch(mode) 
    4969         { 
    4970                 case BAN_ACCOUNT: 
    4971                         if(!AccountMgr::normilizeString(nameOrIP)) 
    4972                         { 
    4973                                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); 
    4974                                 SetSentErrorMessage(true); 
    4975                                 return false; 
    4976                         } 
    4977                         break; 
    4978                 case BAN_CHARACTER: 
    4979                         if(!normalizePlayerName(nameOrIP)) 
    4980                         { 
    4981                                 SendSysMessage(LANG_PLAYER_NOT_FOUND); 
    4982                                 SetSentErrorMessage(true); 
    4983                                 return false; 
    4984                         } 
    4985                         break; 
    4986                 case BAN_IP: 
    4987                         if(!IsIPAddress(nameOrIP.c_str())) 
    4988                                 return false; 
    4989                         break; 
    4990         } 
    4991  
    4992         switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : "")) 
     4975    { 
     4976        case BAN_ACCOUNT: 
     4977            if(!AccountMgr::normilizeString(nameOrIP)) 
     4978            { 
     4979                PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); 
     4980                SetSentErrorMessage(true); 
     4981                return false; 
     4982            } 
     4983            break; 
     4984        case BAN_CHARACTER: 
     4985            if(!normalizePlayerName(nameOrIP)) 
     4986            { 
     4987                SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     4988                SetSentErrorMessage(true); 
     4989                return false; 
     4990            } 
     4991            break; 
     4992        case BAN_IP: 
     4993            if(!IsIPAddress(nameOrIP.c_str())) 
     4994                return false; 
     4995            break; 
     4996    } 
     4997 
     4998    switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : "")) 
    49934999    { 
    49945000        case BAN_SUCCESS: 
     
    50015007            return false; 
    50025008        case BAN_NOTFOUND: 
    5003            switch(mode) 
    5004                    { 
    5005                            default: 
    5006                                    PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str()); 
    5007                                    break; 
    5008                            case BAN_CHARACTER: 
    5009                                    PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str()); 
    5010                                    break; 
    5011                            case BAN_IP: 
    5012                                    PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str()); 
    5013                                    break; 
    5014  
    5015                    } 
    5016                    SetSentErrorMessage(true); 
    5017                    return false; 
     5009            switch(mode) 
     5010            { 
     5011                default: 
     5012                    PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str()); 
     5013                    break; 
     5014                case BAN_CHARACTER: 
     5015                    PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str()); 
     5016                    break; 
     5017                case BAN_IP: 
     5018                    PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str()); 
     5019                    break; 
     5020            } 
     5021            SetSentErrorMessage(true); 
     5022            return false; 
    50185023    } 
    50195024 
     
    50285033bool ChatHandler::HandleUnBanCharacterCommand(const char* args) 
    50295034{ 
    5030         return HandleUnBanHelper(BAN_CHARACTER,args); 
     5035    return HandleUnBanHelper(BAN_CHARACTER,args); 
    50315036} 
    50325037 
    50335038bool ChatHandler::HandleUnBanIPCommand(const char* args) 
    50345039{ 
    5035         return HandleUnBanHelper(BAN_IP,args); 
     5040    return HandleUnBanHelper(BAN_IP,args); 
    50365041} 
    50375042 
     
    50425047 
    50435048    char* cnameOrIP = strtok ((char*)args, " "); 
    5044         if(!cnameOrIP) 
     5049    if(!cnameOrIP) 
    50455050        return false; 
    50465051 
    50475052    std::string nameOrIP = cnameOrIP; 
     5053 
    50485054    switch(mode) 
    50495055    { 
    50505056        case BAN_ACCOUNT: 
    5051                         if(!AccountMgr::normilizeString(nameOrIP)) 
     5057            if(!AccountMgr::normilizeString(nameOrIP)) 
    50525058            { 
    50535059                PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); 
    5054                                 SetSentErrorMessage(true); 
    5055                                 return false; 
    5056                         } 
    5057                         break; 
    5058                 case BAN_CHARACTER: 
    5059                         if(!normalizePlayerName(nameOrIP)) 
     5060                SetSentErrorMessage(true); 
     5061                return false; 
     5062            } 
     5063            break; 
     5064        case BAN_CHARACTER: 
     5065            if(!normalizePlayerName(nameOrIP)) 
    50605066            { 
    50615067                SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     
    50635069                return false; 
    50645070            } 
    5065                         break; 
    5066                 case BAN_IP: 
    5067                         if(!IsIPAddress(nameOrIP.c_str())) 
    5068                                 return false; 
    5069                         break; 
    5070         } 
    5071  
    5072         if(sWorld.RemoveBanAccount(mode,nameOrIP)) 
    5073                 PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str()); 
    5074         else 
    5075                 PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str()); 
    5076  
    5077         return true; 
     5071            break; 
     5072        case BAN_IP: 
     5073            if(!IsIPAddress(nameOrIP.c_str())) 
     5074                return false; 
     5075            break; 
     5076    } 
     5077 
     5078    if(sWorld.RemoveBanAccount(mode,nameOrIP)) 
     5079        PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str()); 
     5080    else 
     5081        PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str()); 
     5082 
     5083    return true; 
    50785084} 
    50795085 
    50805086bool ChatHandler::HandleBanInfoAccountCommand(const char* args) 
    50815087{ 
    5082         if(!args) 
    5083                 return false; 
    5084  
    5085         char* cname = strtok((char*)args, ""); 
    5086         if(!cname) 
    5087                 return false; 
    5088  
    5089         std::string account_name = cname; 
    5090         if(!AccountMgr::normilizeString(account_name)) 
    5091         { 
    5092                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    5093                 SetSentErrorMessage(true); 
    5094                 return false; 
    5095     } 
    5096      
    5097         uint32 accountid = accmgr.GetId(account_name); 
    5098         if(!accountid) 
     5088    if(!args) 
     5089        return false; 
     5090 
     5091    char* cname = strtok((char*)args, ""); 
     5092    if(!cname) 
     5093        return false; 
     5094 
     5095    std::string account_name = cname; 
     5096    if(!AccountMgr::normilizeString(account_name)) 
    50995097    { 
    51005098        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    5101                 return true; 
    5102     } 
    5103      
    5104         return HandleBanInfoHelper(accountid,account_name.c_str()); 
     5099        SetSentErrorMessage(true); 
     5100        return false; 
     5101    } 
     5102 
     5103    uint32 accountid = accmgr.GetId(account_name); 
     5104    if(!accountid) 
     5105    { 
     5106        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     5107        return true; 
     5108    } 
     5109 
     5110    return HandleBanInfoHelper(accountid,account_name.c_str()); 
    51055111} 
    51065112 
     
    51115117 
    51125118    char* cname = strtok ((char*)args, ""); 
    5113         if(!cname) 
     5119    if(!cname) 
    51145120        return false; 
    51155121 
    51165122    std::string name = cname; 
    5117         if(!normalizePlayerName(name)) 
    5118         { 
    5119                 SendSysMessage(LANG_PLAYER_NOT_FOUND); 
    5120                 SetSentErrorMessage(true); 
    5121                 return false; 
    5122         } 
     5123    if(!normalizePlayerName(name)) 
     5124    { 
     5125        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     5126        SetSentErrorMessage(true); 
     5127        return false; 
     5128    } 
    51235129 
    51245130    uint32 accountid = objmgr.GetPlayerAccountIdByPlayerName(name); 
    5125         if(!accountid) 
     5131    if(!accountid) 
    51265132    { 
    51275133        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
    5128                 SetSentErrorMessage(true); 
    5129                 return false; 
    5130         } 
    5131  
    5132         std::string accountname; 
    5133         if(!accmgr.GetName(accountid,accountname)) 
    5134         { 
    5135                 PSendSysMessage(LANG_BANINFO_NOCHARACTER); 
     5134        SetSentErrorMessage(true); 
     5135        return false; 
     5136    } 
     5137 
     5138    std::string accountname; 
     5139    if(!accmgr.GetName(accountid,accountname)) 
     5140    { 
     5141        PSendSysMessage(LANG_BANINFO_NOCHARACTER); 
    51365142        return true; 
    51375143    } 
    5138      
    5139         return HandleBanInfoHelper(accountid,accountname.c_str()); 
     5144 
     5145    return HandleBanInfoHelper(accountid,accountname.c_str()); 
    51405146} 
    51415147 
    51425148bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) 
    51435149{ 
    5144         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); 
    5145         if(!result) 
     5150    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); 
     5151    if(!result) 
    51465152    { 
    51475153        PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname); 
    5148                 return true; 
    5149     } 
    5150      
    5151         PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname); 
    5152         do 
     5154        return true; 
     5155    } 
     5156 
     5157    PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname); 
     5158    do 
    51535159    { 
    51545160        Field* fields = result->Fetch(); 
    51555161 
    5156                 time_t unbandate = time_t(fields[3].GetUInt64()); 
    5157                 bool active = false; 
    5158                 if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) 
    5159                         active = true; 
    5160                 bool permanent = (fields[1].GetUInt64() == (uint64)0); 
    5161                 std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); 
    5162                 PSendSysMessage(LANG_BANINFO_HISTORYENTRY, 
    5163                         fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); 
    5164         }while (result->NextRow()); 
    5165  
    5166         delete result; 
    5167         return true; 
     5162        time_t unbandate = time_t(fields[3].GetUInt64()); 
     5163        bool active = false; 
     5164        if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) 
     5165            active = true; 
     5166        bool permanent = (fields[1].GetUInt64() == (uint64)0); 
     5167        std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); 
     5168        PSendSysMessage(LANG_BANINFO_HISTORYENTRY, 
     5169            fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); 
     5170    }while (result->NextRow()); 
     5171 
     5172    delete result; 
     5173    return true; 
    51685174} 
    51695175 
    51705176bool ChatHandler::HandleBanInfoIPCommand(const char* args) 
    51715177{ 
    5172         if(!args) 
    5173                 return false; 
    5174  
    5175         char* cIP = strtok ((char*)args, ""); 
    5176         if(!cIP) 
    5177                 return false; 
    5178  
    5179         if (!IsIPAddress(cIP)) 
    5180                 return false; 
    5181  
    5182         std::string IP = cIP; 
    5183  
    5184         loginDatabase.escape_string(IP); 
    5185         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()); 
    5186         if(!result) 
    5187         { 
    5188                 PSendSysMessage(LANG_BANINFO_NOIP); 
    5189                 return true; 
    5190     } 
    5191      
    5192         Field *fields = result->Fetch(); 
    5193         bool permanent = !fields[6].GetUInt64(); 
    5194         PSendSysMessage(LANG_BANINFO_IPENTRY, 
    5195                 fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), 
    5196                 permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); 
    5197         delete result; 
    5198         return true; 
     5178    if(!args) 
     5179        return false; 
     5180 
     5181    char* cIP = strtok ((char*)args, ""); 
     5182    if(!cIP) 
     5183        return false; 
     5184 
     5185    if (!IsIPAddress(cIP)) 
     5186        return false; 
     5187 
     5188    std::string IP = cIP; 
     5189 
     5190    loginDatabase.escape_string(IP); 
     5191    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()); 
     5192    if(!result) 
     5193    { 
     5194        PSendSysMessage(LANG_BANINFO_NOIP); 
     5195        return true; 
     5196    } 
     5197 
     5198    Field *fields = result->Fetch(); 
     5199    bool permanent = !fields[6].GetUInt64(); 
     5200    PSendSysMessage(LANG_BANINFO_IPENTRY, 
     5201        fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), 
     5202        permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); 
     5203    delete result; 
     5204    return true; 
    51995205} 
    52005206 
    52015207bool ChatHandler::HandleBanListCharacterCommand(const char* args) 
    52025208{ 
    5203         loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
    5204  
    5205         char* cFilter = strtok ((char*)args, " "); 
    5206         if(!cFilter) 
    5207         return false; 
    5208  
    5209         std::string filter = cFilter; 
    5210         loginDatabase.escape_string(filter); 
    5211         QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str()); 
    5212         if (!result) 
    5213         { 
    5214                 PSendSysMessage(LANG_BANLIST_NOCHARACTER); 
    5215                 return true; 
    5216         } 
    5217  
    5218         return HandleBanListHelper(result); 
     5209    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
     5210 
     5211    char* cFilter = strtok ((char*)args, " "); 
     5212    if(!cFilter) 
     5213        return false; 
     5214 
     5215    std::string filter = cFilter; 
     5216    loginDatabase.escape_string(filter); 
     5217    QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str()); 
     5218    if (!result) 
     5219    { 
     5220        PSendSysMessage(LANG_BANLIST_NOCHARACTER); 
     5221        return true; 
     5222    } 
     5223 
     5224    return HandleBanListHelper(result); 
    52195225} 
    52205226 
    52215227bool ChatHandler::HandleBanListAccountCommand(const char* args) 
    52225228{ 
    5223         loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
    5224  
    5225         char* cFilter = strtok((char*)args, " "); 
    5226         std::string filter = cFilter ? cFilter : ""; 
    5227         loginDatabase.escape_string(filter); 
    5228  
    5229         QueryResult* result; 
    5230  
    5231         if(filter.empty()) 
    5232         { 
    5233                 result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" 
    5234                         " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); 
    5235         } 
    5236         else 
    5237         { 
    5238                 result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" 
    5239                         " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", 
    5240                         filter.c_str()); 
    5241         } 
    5242  
    5243         if (!result) 
    5244         { 
    5245                 PSendSysMessage(LANG_BANLIST_NOACCOUNT); 
    5246                 return true; 
    5247         } 
    5248  
    5249         return HandleBanListHelper(result); 
     5229    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
     5230 
     5231    char* cFilter = strtok((char*)args, " "); 
     5232    std::string filter = cFilter ? cFilter : ""; 
     5233    loginDatabase.escape_string(filter); 
     5234 
     5235    QueryResult* result; 
     5236 
     5237    if(filter.empty()) 
     5238    { 
     5239        result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" 
     5240            " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); 
     5241    } 
     5242    else 
     5243    { 
     5244        result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" 
     5245            " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", 
     5246            filter.c_str()); 
     5247    } 
     5248 
     5249    if (!result) 
     5250    { 
     5251        PSendSysMessage(LANG_BANLIST_NOACCOUNT); 
     5252        return true; 
     5253    } 
     5254 
     5255    return HandleBanListHelper(result); 
    52505256} 
    52515257 
     
    52535259{ 
    52545260    PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); 
    5255      
    5256         // Chat short output 
    5257         if(m_session) 
     5261 
     5262    // Chat short output 
     5263    if(m_session) 
    52585264    { 
    52595265        do 
    5260                 { 
    5261                         Field* fields = result->Fetch(); 
    5262                         uint32 accountid = fields[0].GetUInt32(); 
    5263  
    5264                         QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); 
    5265                         if(banresult) 
    5266                         { 
    5267                                 Field* fields2 = banresult->Fetch(); 
    5268                                 PSendSysMessage("%s",fields2[0].GetString()); 
    5269                                 delete banresult; 
    5270                         } 
    5271                 } while (result->NextRow()); 
    5272         } 
    5273         // Console wide output 
    5274         else 
    5275         { 
    5276                 SendSysMessage(LANG_BANLIST_ACCOUNTS); 
    5277                 SendSysMessage("==============================================================================="); 
    5278                 SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER); 
    5279                 do 
    5280                 { 
    5281                         SendSysMessage("-------------------------------------------------------------------------------"); 
    5282                         Field *fields = result->Fetch(); 
    5283                         uint32 account_id = fields[0].GetUInt32 (); 
    5284  
    5285                         std::string account_name; 
    5286  
    5287                         // "account" case, name can be get in same quary 
    5288                         if(result->GetFieldCount() > 1) 
    5289                                 account_name = fields[1].GetCppString(); 
    5290                         // "character" case, name need extract from another DB 
    5291                         else 
    5292                                 accmgr.GetName (account_id,account_name); 
    5293  
    5294                         // No SQL injection. id is uint32. 
    5295                         QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); 
    5296                         if (banInfo) 
    5297                         { 
    5298                                 Field *fields2 = banInfo->Fetch(); 
    5299                                 do 
    5300                                 { 
    5301                                         time_t t_ban = fields2[0].GetUInt64(); 
    5302                                         tm* aTm_ban = localtime(&t_ban); 
    5303  
    5304                                         if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) 
    5305                                         { 
    5306                                                 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|", 
    5307                                                         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, 
    5308                                                         fields2[2].GetString(),fields2[3].GetString()); 
    5309                                         } 
    5310                                         else 
    5311                                         { 
    5312                                                 time_t t_unban = fields2[1].GetUInt64(); 
    5313                                                 tm* aTm_unban = localtime(&t_unban); 
    5314                                                 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", 
    5315                                                         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, 
    5316                                                         aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, 
    5317                                                         fields2[2].GetString(),fields2[3].GetString()); 
    5318                                         } 
    5319                                 }while ( banInfo->NextRow() ); 
    5320                                 delete banInfo; 
    5321                         } 
    5322                 }while( result->NextRow() ); 
    5323                 SendSysMessage("==============================================================================="); 
    5324         } 
    5325  
    5326         delete result; 
    5327         return true; 
     5266        { 
     5267            Field* fields = result->Fetch(); 
     5268            uint32 accountid = fields[0].GetUInt32(); 
     5269 
     5270            QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); 
     5271            if(banresult) 
     5272            { 
     5273                Field* fields2 = banresult->Fetch(); 
     5274                PSendSysMessage("%s",fields2[0].GetString()); 
     5275                delete banresult; 
     5276            } 
     5277        } while (result->NextRow()); 
     5278    } 
     5279    // Console wide output 
     5280    else 
     5281    { 
     5282        SendSysMessage(LANG_BANLIST_ACCOUNTS); 
     5283        SendSysMessage("==============================================================================="); 
     5284        SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER); 
     5285        do 
     5286        { 
     5287            SendSysMessage("-------------------------------------------------------------------------------"); 
     5288            Field *fields = result->Fetch(); 
     5289            uint32 account_id = fields[0].GetUInt32 (); 
     5290 
     5291            std::string account_name; 
     5292 
     5293            // "account" case, name can be get in same query 
     5294            if(result->GetFieldCount() > 1) 
     5295                account_name = fields[1].GetCppString(); 
     5296            // "character" case, name need extract from another DB 
     5297            else 
     5298                accmgr.GetName (account_id,account_name); 
     5299 
     5300            // No SQL injection. id is uint32. 
     5301            QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); 
     5302            if (banInfo) 
     5303            { 
     5304                Field *fields2 = banInfo->Fetch(); 
     5305                do 
     5306                { 
     5307                    time_t t_ban = fields2[0].GetUInt64(); 
     5308                    tm* aTm_ban = localtime(&t_ban); 
     5309 
     5310                    if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) 
     5311                    { 
     5312                        PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|", 
     5313                            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, 
     5314                            fields2[2].GetString(),fields2[3].GetString()); 
     5315                    } 
     5316                    else 
     5317                    { 
     5318                        time_t t_unban = fields2[1].GetUInt64(); 
     5319                        tm* aTm_unban = localtime(&t_unban); 
     5320                        PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", 
     5321                            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, 
     5322                            aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, 
     5323                            fields2[2].GetString(),fields2[3].GetString()); 
     5324                    } 
     5325                }while ( banInfo->NextRow() ); 
     5326                delete banInfo; 
     5327            } 
     5328        }while( result->NextRow() ); 
     5329        SendSysMessage("==============================================================================="); 
     5330    } 
     5331 
     5332    delete result; 
     5333    return true; 
    53285334} 
    53295335 
    53305336bool ChatHandler::HandleBanListIPCommand(const char* args) 
    53315337{ 
    5332         loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
    5333  
    5334         char* cFilter = strtok((char*)args, " "); 
    5335         std::string filter = cFilter ? cFilter : ""; 
    5336         loginDatabase.escape_string(filter); 
    5337  
    5338         QueryResult* result; 
    5339  
    5340         if(filter.empty()) 
    5341         { 
    5342                 result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" 
    5343                         " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" 
    5344                         " ORDER BY unbandate" ); 
    5345         } 
    5346         else 
    5347         { 
    5348                 result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" 
    5349                         " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") 
    5350                         " ORDER BY unbandate",filter.c_str() ); 
    5351         } 
    5352  
    5353         if(!result) 
    5354         { 
    5355                 PSendSysMessage(LANG_BANLIST_NOIP); 
    5356                 return true; 
    5357         } 
    5358  
    5359         PSendSysMessage(LANG_BANLIST_MATCHINGIP); 
    5360         // Chat short output 
    5361         if(m_session) 
    5362         { 
    5363                 do 
    5364                 { 
    5365                         Field* fields = result->Fetch(); 
    5366                         PSendSysMessage("%s",fields[0].GetString()); 
    5367                 }while (result->NextRow()); 
    5368         } 
    5369         // Console wide output 
    5370         else 
    5371         { 
    5372                 SendSysMessage(LANG_BANLIST_IPS);SendSysMessage("==============================================================================="); 
    5373                 SendSysMessage(LANG_BANLIST_IPS_HEADER); 
    5374                 do 
     5338    loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); 
     5339 
     5340    char* cFilter = strtok((char*)args, " "); 
     5341    std::string filter = cFilter ? cFilter : ""; 
     5342    loginDatabase.escape_string(filter); 
     5343 
     5344    QueryResult* result; 
     5345 
     5346    if(filter.empty()) 
     5347    { 
     5348        result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" 
     5349            " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" 
     5350            " ORDER BY unbandate" ); 
     5351    } 
     5352    else 
     5353    { 
     5354        result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" 
     5355            " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") 
     5356            " ORDER BY unbandate",filter.c_str() ); 
     5357    } 
     5358 
     5359    if(!result) 
     5360    { 
     5361        PSendSysMessage(LANG_BANLIST_NOIP); 
     5362        return true; 
     5363    } 
     5364 
     5365    PSendSysMessage(LANG_BANLIST_MATCHINGIP); 
     5366    // Chat short output 
     5367    if(m_session) 
     5368    { 
     5369        do 
     5370        { 
     5371            Field* fields = result->Fetch(); 
     5372            PSendSysMessage("%s",fields[0].GetString()); 
     5373        } while (result->NextRow()); 
     5374    } 
     5375    // Console wide output 
     5376    else 
     5377    { 
     5378        SendSysMessage(LANG_BANLIST_IPS); 
     5379        SendSysMessage("==============================================================================="); 
     5380        SendSysMessage(LANG_BANLIST_IPS_HEADER); 
     5381        do 
    53755382        { 
    53765383            SendSysMessage("-------------------------------------------------------------------------------"); 
    5377                         Field *fields = result->Fetch(); 
    5378                         time_t t_ban = fields[1].GetUInt64(); 
    5379                         tm* aTm_ban = localtime(&t_ban); 
    5380                         if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) 
    5381                         { 
    5382                                 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|", 
    5383                                         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, 
    5384                                         fields[3].GetString(), fields[4].GetString()); 
    5385                         } 
    5386                         else 
    5387                         { 
    5388                                 time_t t_unban = fields[2].GetUInt64(); 
    5389                                 tm* aTm_unban = localtime(&t_unban); 
    5390                                 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", 
    5391                                         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, 
    5392                                         aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, 
    5393                                         fields[3].GetString(), fields[4].GetString()); 
    5394                         } 
    5395                 }while( result->NextRow() ); 
    5396                 SendSysMessage("==============================================================================="); 
     5384            Field *fields = result->Fetch(); 
     5385            time_t t_ban = fields[1].GetUInt64(); 
     5386            tm* aTm_ban = localtime(&t_ban); 
     5387            if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) 
     5388            { 
     5389                PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|   permanent  |%-15.15s|%-15.15s|", 
     5390                    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, 
     5391                    fields[3].GetString(), fields[4].GetString()); 
     5392            } 
     5393            else 
     5394            { 
     5395                time_t t_unban = fields[2].GetUInt64(); 
     5396                tm* aTm_unban = localtime(&t_unban); 
     5397                PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", 
     5398                    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, 
     5399                    aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, 
     5400                    fields[3].GetString(), fields[4].GetString()); 
     5401            } 
     5402        }while( result->NextRow() ); 
     5403        SendSysMessage("==============================================================================="); 
    53975404    } 
    53985405 
     
    54035410bool ChatHandler::HandleRespawnCommand(const char* /*args*/) 
    54045411{ 
     5412    Player* pl = m_session->GetPlayer(); 
     5413 
     5414    // accept only explicitly selected target (not implicitly self targeting case) 
    54055415    Unit* target = getSelectedUnit(); 
    5406  
    5407     if(target && target->GetTypeId() == TYPEID_UNIT && target->isDead()) 
    5408     { 
    5409         ((Creature*)target)->Respawn(); 
     5416    if(pl->GetSelection() && target) 
     5417    { 
     5418        if(target->GetTypeId()!=TYPEID_UNIT) 
     5419        { 
     5420            SendSysMessage(LANG_SELECT_CREATURE); 
     5421            SetSentErrorMessage(true); 
     5422            return false; 
     5423        } 
     5424 
     5425        if(target->isDead()) 
     5426            ((Creature*)target)->Respawn(); 
    54105427        return true; 
    54115428    } 
    5412  
    5413     Player* pl = m_session->GetPlayer(); 
    54145429 
    54155430    CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); 
     
    54565471bool ChatHandler::HandleLoadPDumpCommand(const char *args) 
    54575472{ 
    5458     if (!args) 
     5473    if(!args) 
    54595474        return false; 
    54605475 
    54615476    char * file = strtok((char*)args, " "); 
    5462         if(!file) 
    5463                 return false; 
    5464  
    5465         char * account = strtok(NULL, " "); 
    5466         if(!account) 
    5467                 return false; 
    5468  
    5469         std::string account_name = account; 
    5470         if(!AccountMgr::normilizeString(account_name)) 
    5471         { 
    5472                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    5473                 SetSentErrorMessage(true); 
    5474         return false; 
    5475         } 
     5477    if(!file) 
     5478        return false; 
     5479 
     5480    char * account = strtok(NULL, " "); 
     5481    if(!account) 
     5482        return false; 
     5483 
     5484    std::string account_name = account; 
     5485    if(!AccountMgr::normilizeString(account_name)) 
     5486    { 
     5487        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     5488        SetSentErrorMessage(true); 
     5489        return false; 
     5490    } 
    54765491 
    54775492    uint32 account_id = accmgr.GetId(account_name); 
     
    54825497        { 
    54835498            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    5484                         SetSentErrorMessage(true); 
    5485                         return false; 
     5499            SetSentErrorMessage(true); 
     5500            return false; 
    54865501        } 
    5487         } 
    5488  
    5489         if(!accmgr.GetName(account_id,account_name)) 
    5490         { 
    5491                 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    5492                 SetSentErrorMessage(true); 
    5493                 return false; 
    5494         } 
    5495  
    5496         char* guid_str = NULL; 
    5497         char* name_str = strtok(NULL, " "); 
    5498  
    5499         std::string name; 
    5500         if(name_str) 
    5501         { 
    5502                 name = name_str; 
    5503                 // normalize the name if specified and check if it exists 
    5504                 if(!normalizePlayerName(name)) 
    5505                 { 
    5506                         PSendSysMessage(LANG_INVALID_CHARACTER_NAME); 
    5507                         SetSentErrorMessage(true); 
    5508                         return false; 
    5509                 } 
    5510  
    5511                 if(!ObjectMgr::IsValidName(name,true)) 
    5512                 { 
    5513                         PSendSysMessage(LANG_INVALID_CHARACTER_NAME); 
    5514                         SetSentErrorMessage(true); 
     5502    } 
     5503 
     5504    if(!accmgr.GetName(account_id,account_name)) 
     5505    { 
     5506        PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     5507        SetSentErrorMessage(true); 
     5508        return false; 
     5509    } 
     5510 
     5511    char* guid_str = NULL; 
     5512    char* name_str = strtok(NULL, " "); 
     5513 
     5514    std::string name; 
     5515    if(name_str) 
     5516    { 
     5517        name = name_str; 
     5518        // normalize the name if specified and check if it exists 
     5519        if(!normalizePlayerName(name)) 
     5520        { 
     5521            PSendSysMessage(LANG_INVALID_CHARACTER_NAME); 
     5522            SetSentErrorMessage(true); 
    55155523            return false; 
    5516                 } 
    5517  
    5518                 guid_str = strtok(NULL, " "); 
     5524        } 
     5525 
     5526        if(!ObjectMgr::IsValidName(name,true)) 
     5527        { 
     5528            PSendSysMessage(LANG_INVALID_CHARACTER_NAME); 
     5529            SetSentErrorMessage(true); 
     5530            return false; 
     5531        } 
     5532 
     5533        guid_str = strtok(NULL, " "); 
    55195534    } 
    55205535 
     
    55225537 
    55235538    if(guid_str) 
    5524         { 
    5525                 guid = atoi(guid_str); 
    5526                 if(!guid) 
    5527                 { 
    5528                         PSendSysMessage(LANG_INVALID_CHARACTER_GUID); 
    5529                         SetSentErrorMessage(true); 
    5530                         return false; 
    5531                 } 
    5532                  
    5533                 if(objmgr.GetPlayerAccountIdByGUID(guid)) 
    5534                 { 
    5535                         PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid); 
    5536                         SetSentErrorMessage(true); 
    5537                         return false; 
    5538                 } 
    5539         } 
    5540  
    5541         switch(PlayerDumpReader().LoadDump(file, account_id, name, guid)) 
    5542         { 
    5543                 case DUMP_SUCCESS: 
    5544                         PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); 
    5545                         break; 
    5546                 case DUMP_FILE_OPEN_ERROR: 
    5547                         PSendSysMessage(LANG_FILE_OPEN_FAIL,file); 
    5548                         SetSentErrorMessage(true); 
    5549                         return false; 
    5550                 case DUMP_FILE_BROKEN: 
    5551                         PSendSysMessage(LANG_DUMP_BROKEN,file); 
    5552                         SetSentErrorMessage(true); 
    5553                         return false; 
    5554                 case DUMP_TOO_MANY_CHARS: 
    5555                         PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); 
    5556                         SetSentErrorMessage(true); 
    5557                         return false; 
    5558                 default: 
    5559                         PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); 
    5560                         SetSentErrorMessage(true); 
    5561                         return false; 
    5562         } 
     5539    { 
     5540        guid = atoi(guid_str); 
     5541        if(!guid) 
     5542        { 
     5543            PSendSysMessage(LANG_INVALID_CHARACTER_GUID); 
     5544            SetSentErrorMessage(true); 
     5545            return false; 
     5546        } 
     5547 
     5548        if(objmgr.GetPlayerAccountIdByGUID(guid)) 
     5549        { 
     5550            PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid); 
     5551            SetSentErrorMessage(true); 
     5552            return false; 
     5553        } 
     5554    } 
     5555 
     5556    switch(PlayerDumpReader().LoadDump(file, account_id, name, guid)) 
     5557    { 
     5558        case DUMP_SUCCESS: 
     5559            PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); 
     5560            break; 
     5561        case DUMP_FILE_OPEN_ERROR: 
     5562            PSendSysMessage(LANG_FILE_OPEN_FAIL,file); 
     5563            SetSentErrorMessage(true); 
     5564            return false; 
     5565        case DUMP_FILE_BROKEN: 
     5566            PSendSysMessage(LANG_DUMP_BROKEN,file); 
     5567            SetSentErrorMessage(true); 
     5568            return false; 
     5569        case DUMP_TOO_MANY_CHARS: 
     5570            PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); 
     5571            SetSentErrorMessage(true); 
     5572            return false; 
     5573        default: 
     5574            PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); 
     5575            SetSentErrorMessage(true); 
     5576            return false; 
     5577    } 
    55635578 
    55645579    return true; 
     
    56055620 
    56065621    if(!objmgr.GetPlayerAccountIdByGUID(guid)) 
    5607         { 
    5608                 PSendSysMessage(LANG_PLAYER_NOT_FOUND); 
    5609                 SetSentErrorMessage(true); 
    5610                 return false; 
    5611         } 
    5612  
    5613         switch(PlayerDumpWriter().WriteDump(file, guid)) 
    5614         { 
    5615                 case DUMP_SUCCESS: 
    5616                         PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); 
    5617                         break; 
    5618                 case DUMP_FILE_OPEN_ERROR: 
    5619                         PSendSysMessage(LANG_FILE_OPEN_FAIL,file); 
    5620                         SetSentErrorMessage(true); 
    5621                         return false; 
    5622                 default: 
    5623                         PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); 
    5624                         SetSentErrorMessage(true); 
    5625                         return false; 
    5626         } 
     5622    { 
     5623        PSendSysMessage(LANG_PLAYER_NOT_FOUND); 
     5624        SetSentErrorMessage(true); 
     5625        return false; 
     5626    } 
     5627 
     5628    switch(PlayerDumpWriter().WriteDump(file, guid)) 
     5629    { 
     5630        case DUMP_SUCCESS: 
     5631            PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); 
     5632            break; 
     5633        case DUMP_FILE_OPEN_ERROR: 
     5634            PSendSysMessage(LANG_FILE_OPEN_FAIL,file); 
     5635            SetSentErrorMessage(true); 
     5636            return false; 
     5637        default: 
     5638            PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); 
     5639            SetSentErrorMessage(true); 
     5640            return false; 
     5641    } 
    56275642 
    56285643    return true; 
     
    58315846    caster->SendMessageToSet(&data,true); 
    58325847 
    5833     caster->CastSpell(m_session->GetPlayer(),spell,false); 
     5848    caster->CastSpell(m_session->GetPlayer(),spell,triggered); 
    58345849 
    58355850    return true; 
     
    58405855    if(!*args) 
    58415856        return false; 
    5842  
    58435857 
    58445858    // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form 
     
    59235937    caster->SendMessageToSet(&data,true); 
    59245938 
    5925     caster->CastSpell(caster->getVictim(),spell,false); 
     5939    caster->CastSpell(caster->getVictim(),spell,triggered); 
    59265940 
    59275941    return true; 
     
    61116125bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) 
    61126126{ 
    6113         ///- Get the accounts with GM Level >0 
    6114         QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); 
    6115         if(result) 
    6116         { 
    6117                 SendSysMessage(LANG_GMLIST); 
    6118                 SendSysMessage("========================"); 
    6119                 SendSysMessage(LANG_GMLIST_HEADER); 
    6120                 SendSysMessage("========================"); 
    6121  
    6122                 ///- Circle through them. Display username and GM level 
    6123                 do 
    6124                 { 
    6125                         Field *fields = result->Fetch(); 
    6126                         PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); 
    6127                 } while( result->NextRow() ); 
    6128  
    6129                 PSendSysMessage("========================"); 
    6130                 delete result; 
    6131         } 
    6132         else 
    6133                 PSendSysMessage(LANG_GMLIST_EMPTY); 
    6134         return true; 
     6127    ///- Get the accounts with GM Level >0 
     6128    QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); 
     6129    if(result) 
     6130    { 
     6131        SendSysMessage(LANG_GMLIST); 
     6132        SendSysMessage("========================"); 
     6133        SendSysMessage(LANG_GMLIST_HEADER); 
     6134        SendSysMessage("========================"); 
     6135 
     6136        ///- Circle through them. Display username and GM level 
     6137        do 
     6138        { 
     6139            Field *fields = result->Fetch(); 
     6140            PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); 
     6141        }while( result->NextRow() ); 
     6142 
     6143        PSendSysMessage("========================"); 
     6144        delete result; 
     6145    } 
     6146    else 
     6147        PSendSysMessage(LANG_GMLIST_EMPTY); 
     6148    return true; 
    61356149} 
    61366150 
     
    61386152bool ChatHandler::HandleServerSetMotdCommand(const char* args) 
    61396153{ 
    6140         sWorld.SetMotd(args); 
    6141         PSendSysMessage(LANG_MOTD_NEW, args); 
    6142         return true; 
     6154    sWorld.SetMotd(args); 
     6155    PSendSysMessage(LANG_MOTD_NEW, args); 
     6156    return true; 
    61436157} 
    61446158 
     
    61466160bool ChatHandler::HandleAccountSetAddonCommand(const char* args) 
    61476161{ 
    6148         ///- Get the command line arguments 
    6149         char *szAcc = strtok((char*)args," "); 
    6150         char *szExp = strtok(NULL," "); 
    6151  
    6152         if(!szAcc) 
    6153                 return false; 
    6154  
    6155         std::string account_name; 
    6156         uint32 account_id; 
    6157  
    6158         if(!szExp) 
    6159         { 
    6160                 Player* player = getSelectedPlayer(); 
    6161                 if(!player) 
    6162                         return false; 
    6163  
    6164                 account_id = player->GetSession()->GetAccountId(); 
    6165                 accmgr.GetName(account_id,account_name); 
    6166                 szExp = szAcc; 
    6167         } 
    6168         else 
    6169         { 
    6170                 ///- Convert Account name to Upper Format 
    6171                 account_name = szAcc; 
    6172                 if(!AccountMgr::normilizeString(account_name)) 
    6173                 { 
    6174                         PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    6175                         SetSentErrorMessage(true); 
    6176                         return false; 
    6177                 } 
    6178  
    6179                 account_id = accmgr.GetId(account_name); 
    6180                 if(!account_id) 
    6181                 { 
    6182                         PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
    6183                         SetSentErrorMessage(true); 
    6184                         return false; 
    6185                 } 
    6186         } 
    6187  
    6188         int lev=atoi(szExp);                                    //get int anyway (0 if error) 
    6189         if(lev < 0) 
    6190                 return false; 
    6191  
    6192         // No SQL injection 
    6193         loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); 
    6194         PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); 
    6195         return true; 
     6162    ///- Get the command line arguments 
     6163    char *szAcc = strtok((char*)args," "); 
     6164    char *szExp = strtok(NULL," "); 
     6165 
     6166    if(!szAcc) 
     6167        return false; 
     6168 
     6169    std::string account_name; 
     6170    uint32 account_id; 
     6171 
     6172    if(!szExp) 
     6173    { 
     6174        Player* player = getSelectedPlayer(); 
     6175        if(!player) 
     6176            return false; 
     6177 
     6178        account_id = player->GetSession()->GetAccountId(); 
     6179        accmgr.GetName(account_id,account_name); 
     6180        szExp = szAcc; 
     6181    } 
     6182    else 
     6183    { 
     6184        ///- Convert Account name to Upper Format 
     6185        account_name = szAcc; 
     6186        if(!AccountMgr::normilizeString(account_name)) 
     6187        { 
     6188            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     6189            SetSentErrorMessage(true); 
     6190            return false; 
     6191        } 
     6192 
     6193        account_id = accmgr.GetId(account_name); 
     6194        if(!account_id) 
     6195        { 
     6196            PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); 
     6197            SetSentErrorMessage(true); 
     6198            return false; 
     6199        } 
     6200    } 
     6201 
     6202    int lev=atoi(szExp);                                    //get int anyway (0 if error) 
     6203    if(lev < 0) 
     6204        return false; 
     6205 
     6206    // No SQL injection 
     6207    loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); 
     6208    PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); 
     6209    return true; 
    61966210} 
    61976211 
     
    61996213bool ChatHandler::HandleSendMessageCommand(const char* args) 
    62006214{ 
    6201         ///- Get the command line arguments 
    6202         char* name_str = strtok((char*)args, " "); 
    6203         char* msg_str = strtok(NULL, ""); 
    6204  
    6205         if(!name_str || !msg_str) 
    6206                 return false; 
    6207  
    6208         std::string name = name_str; 
    6209  
    6210         if(!normalizePlayerName(name)) 
    6211                 return false; 
    6212  
    6213         ///- Find the player and check that he is not logging out. 
    6214         Player *rPlayer = objmgr.GetPlayer(name.c_str()); 
    6215         if(!rPlayer) 
    6216         { 
    6217                 SendSysMessage(LANG_PLAYER_NOT_FOUND); 
    6218                 SetSentErrorMessage(true); 
    6219                 return false; 
    6220         } 
    6221  
    6222         if(rPlayer->GetSession()->isLogingOut()) 
    6223         { 
    6224                 SendSysMessage(LANG_PLAYER_NOT_FOUND); 
    6225                 SetSentErrorMessage(true); 
    6226                 return false; 
    6227         } 
    6228  
    6229         ///- Send the message 
    6230         //Use SendAreaTriggerMessage for fastest delivery. 
    6231         rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str); 
    6232         rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); 
    6233  
    6234         //Confirmation message 
    6235         PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str); 
    6236         return true; 
     6215    ///- Get the command line arguments 
     6216    char* name_str = strtok((char*)args, " "); 
     6217    char* msg_str = strtok(NULL, ""); 
     6218 
     6219    if(!name_str || !msg_str) 
     6220        return false; 
     6221 
     6222    std::string name = name_str; 
     6223 
     6224    if(!normalizePlayerName(name)) 
     6225        return false; 
     6226 
     6227    ///- Find the player and check that he is not logging out. 
     6228    Player *rPlayer = objmgr.GetPlayer(name.c_str()); 
     6229    if(!rPlayer) 
     6230    { 
     6231        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     6232        SetSentErrorMessage(true); 
     6233        return false; 
     6234    } 
     6235 
     6236    if(rPlayer->GetSession()->isLogingOut()) 
     6237    { 
     6238        SendSysMessage(LANG_PLAYER_NOT_FOUND); 
     6239        SetSentErrorMessage(true); 
     6240        return false; 
     6241    } 
     6242 
     6243    ///- Send the message 
     6244    //Use SendAreaTriggerMessage for fastest delivery. 
     6245    rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str); 
     6246    rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); 
     6247 
     6248    //Confirmation message 
     6249    PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str); 
     6250    return true; 
    62376251} 
    62386252 
    62396253bool ChatHandler::HandlePlayAllCommand(const char* args) 
    62406254{ 
    6241         if(!*args) 
    6242                 return false; 
    6243  
    6244         uint32 soundId = atoi((char*)args); 
    6245  
    6246         if(!sSoundEntriesStore.LookupEntry(soundId)) 
    6247         { 
    6248                 PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); 
    6249                 SetSentErrorMessage(true); 
    6250                 return false; 
    6251         } 
    6252  
    6253         WorldPacket data(SMSG_PLAY_SOUND, 4); 
    6254         data << uint32(soundId) << m_session->GetPlayer()->GetGUID(); 
    6255         sWorld.SendGlobalMessage(&data); 
    6256  
    6257         PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); 
    6258         return true; 
     6255    if(!*args) 
     6256        return false; 
     6257 
     6258    uint32 soundId = atoi((char*)args); 
     6259 
     6260    if(!sSoundEntriesStore.LookupEntry(soundId)) 
     6261    { 
     6262        PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); 
     6263        SetSentErrorMessage(true); 
     6264        return false; 
     6265    } 
     6266 
     6267    WorldPacket data(SMSG_PLAY_SOUND, 4); 
     6268    data << uint32(soundId) << m_session->GetPlayer()->GetGUID(); 
     6269    sWorld.SendGlobalMessage(&data); 
     6270 
     6271    PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); 
     6272    return true; 
    62596273} 
    62606274 
    62616275bool ChatHandler::HandleModifyGenderCommand(const char *args) 
    62626276{ 
    6263         if(!*args)      return false; 
    6264         Player *player = getSelectedPlayer(); 
    6265  
    6266         if(!player) 
    6267         { 
    6268                 PSendSysMessage(LANG_NO_PLAYER); 
    6269                 SetSentErrorMessage(true); 
    6270                 return false; 
    6271         } 
    6272  
    6273         std::string gender = (char*)args; 
    6274         uint32 displayId = player->GetNativeDisplayId(); 
    6275  
    6276         if(gender == "male") // MALE 
    6277         { 
    6278                 if(player->getGender() == GENDER_MALE) 
    6279                 { 
    6280                         PSendSysMessage("%s is already male", player->GetName()); 
    6281                         SetSentErrorMessage(true); 
    6282                         return false; 
    6283                 } 
    6284  
    6285                 // Set gender 
    6286                 player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); 
    6287                 // Change display ID 
    6288                 player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 
    6289                 player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 
    6290  
    6291                 ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); 
    6292                 PSendSysMessage("Gender changed for %s", player->GetName()); 
    6293                 return true; 
    6294         } 
    6295         else if(gender == "female") // FEMALE 
    6296         { 
    6297                 if(player->getGender() == GENDER_FEMALE) 
    6298                 { 
    6299                         PSendSysMessage("%s is already female", player->GetName()); 
    6300                         SetSentErrorMessage(true); 
    6301                         return false; 
    6302                 } 
    6303  
    6304                 // Set gender 
    6305                 player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); 
    6306                 // Change display ID 
    6307                 player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 
    6308                 player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 
    6309  
    6310                 ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); 
    6311                 PSendSysMessage("Gender changed for %s", player->GetName()); 
    6312                 return true; 
    6313         } 
    6314         else 
    6315         { 
    6316                 PSendSysMessage("You must use male or female as gender."); 
    6317                 SetSentErrorMessage(true); 
    6318                 return false; 
    6319         } 
    6320  
    6321         return true; 
     6277    if(!*args)  return false; 
     6278    Player *player = getSelectedPlayer(); 
     6279 
     6280    if(!player) 
     6281    { 
     6282        PSendSysMessage(LANG_NO_PLAYER); 
     6283        SetSentErrorMessage(true); 
     6284        return false; 
     6285    } 
     6286 
     6287    std::string gender = (char*)args; 
     6288    uint32 displayId = player->GetNativeDisplayId(); 
     6289 
     6290    if(gender == "male") // MALE 
     6291    { 
     6292        if(player->getGender() == GENDER_MALE) 
     6293        { 
     6294            PSendSysMessage("%s is already male", player->GetName()); 
     6295            SetSentErrorMessage(true); 
     6296            return false; 
     6297        } 
     6298 
     6299        // Set gender 
     6300        player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); 
     6301        // Change display ID 
     6302        player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 
     6303        player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); 
     6304 
     6305        ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); 
     6306        PSendSysMessage("Gender changed for %s", player->GetName()); 
     6307        return true; 
     6308    } 
     6309    else if(gender == "female") // FEMALE 
     6310    { 
     6311        if(player->getGender() == GENDER_FEMALE) 
     6312        { 
     6313            PSendSysMessage("%s is already female", player->GetName()); 
     6314            SetSentErrorMessage(true); 
     6315            return false; 
     6316        } 
     6317 
     6318        // Set gender 
     6319        player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); 
     6320        // Change display ID 
     6321        player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 
     6322        player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); 
     6323 
     6324        ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); 
     6325        PSendSysMessage("Gender changed for %s", player->GetName()); 
     6326        return true; 
     6327    } 
     6328    else 
     6329    { 
     6330        PSendSysMessage("You must use male or female as gender."); 
     6331        SetSentErrorMessage(true); 
     6332        return false; 
     6333    } 
     6334 
     6335    return true; 
    63226336} 
    63236337 
     
    63326346        if (player) //prevent crash with creature as target 
    63336347        {    
    6334            name = player->GetName(); 
    6335            normalizePlayerName(name); 
     6348            name = player->GetName(); 
     6349            normalizePlayerName(name); 
    63366350        } 
    63376351    } 
     
    63426356        player = objmgr.GetPlayer(name.c_str()); //get player by name 
    63436357    } 
    6344      
     6358 
    63456359    if (!player) 
    63466360    { 
     
    63646378        player->CombatStop(); 
    63656379        if(player->IsNonMeleeSpellCasted(true)) 
    6366         player->InterruptNonMeleeSpells(true); 
     6380            player->InterruptNonMeleeSpells(true); 
    63676381        player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
    63686382        player->SetUInt32Value(PLAYER_DUEL_TEAM, 1); 
     
    63766390                // not let dismiss dead pet 
    63776391                if(pet && pet->isAlive()) 
    6378                 player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); 
     6392                    player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); 
    63796393            } 
    63806394        } 
     
    63976411                    Aura *Aur = CreateAura(spellInfo, i, NULL, player); 
    63986412                    player->AddAura(Aur); 
    6399                } 
     6413                } 
    64006414            } 
    64016415        } 
     
    64176431        if (player) //prevent crash with creature as target 
    64186432        {    
    6419            name = player->GetName(); 
     6433            name = player->GetName(); 
    64206434        } 
    64216435    } 
     
    64856499    //Header of the names 
    64866500    PSendSysMessage(LANG_COMMAND_LIST_FREEZE); 
    6487      
     6501 
    64886502    //Output of the results 
    6489         do 
     6503    do 
    64906504    { 
    64916505        Field *fields = result->Fetch();