Skip to content
This repository
Browse code

Scripts/Commands: Convert character and server commands to commandscript

Closes #6856

Signed-off-by: Nay <dnpd.dd@gmail.com>
  • Loading branch information...
commit a312cd4ba1f47d3dceb774091ec143c90a298cda 1 parent de3f982
Abdullah Hasan authored June 20, 2012 DDuarte committed June 21, 2012
79  src/server/game/Chat/Chat.cpp
@@ -92,29 +92,6 @@ ChatCommand* ChatHandler::getCommandTable()
92 92
         { NULL,             0,                  false, NULL,                                           "", NULL }
93 93
     };
94 94
 
95  
-    static ChatCommand characterDeletedCommandTable[] =
96  
-    {
97  
-        { "delete",         SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleCharacterDeletedDeleteCommand>,   "", NULL },
98  
-        { "list",           SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleCharacterDeletedListCommand>,     "", NULL },
99  
-        { "restore",        SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleCharacterDeletedRestoreCommand>,  "", NULL },
100  
-        { "old",            SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleCharacterDeletedOldCommand>,      "", NULL },
101  
-        { NULL,             0,                  false, NULL,                                                "", NULL }
102  
-    };
103  
-
104  
-    static ChatCommand characterCommandTable[] =
105  
-    {
106  
-        { "customize",      SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterCustomizeCommand>,     "", NULL },
107  
-        { "changefaction",  SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterChangeFactionCommand>, "", NULL },
108  
-        { "changerace",     SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterChangeRaceCommand>,    "", NULL },
109  
-        { "deleted",        SEC_GAMEMASTER,     true,  NULL,                                              "", characterDeletedCommandTable},
110  
-        { "erase",          SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleCharacterEraseCommand>,         "", NULL },
111  
-        { "level",          SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleCharacterLevelCommand>,         "", NULL },
112  
-        { "rename",         SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterRenameCommand>,        "", NULL },
113  
-        { "reputation",     SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterReputationCommand>,    "", NULL },
114  
-        { "titles",         SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleCharacterTitlesCommand>,        "", NULL },
115  
-        { NULL,             0,                  false, NULL,                                              "", NULL }
116  
-    };
117  
-
118 95
     static ChatCommand channelSetCommandTable[] =
119 96
     {
120 97
         { "ownership",      SEC_ADMINISTRATOR,  false,  OldHandler<&ChatHandler::HandleChannelSetOwnership>, "", NULL },
@@ -218,60 +195,6 @@ ChatCommand* ChatHandler::getCommandTable()
218 195
         { NULL,             0,                  false, NULL,                                           "", NULL }
219 196
     };
220 197
 
221  
-    static ChatCommand serverIdleRestartCommandTable[] =
222  
-    {
223  
-        { "cancel",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerShutDownCancelCommand>, "", NULL },
224  
-        { ""   ,            SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerIdleRestartCommand>,   "", NULL },
225  
-        { NULL,             0,                  false, NULL,                                           "", NULL }
226  
-    };
227  
-
228  
-    static ChatCommand serverIdleShutdownCommandTable[] =
229  
-    {
230  
-        { "cancel",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerShutDownCancelCommand>, "", NULL },
231  
-        { ""   ,            SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerIdleShutDownCommand>,  "", NULL },
232  
-        { NULL,             0,                  false, NULL,                                           "", NULL }
233  
-    };
234  
-
235  
-    static ChatCommand serverRestartCommandTable[] =
236  
-    {
237  
-        { "cancel",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerShutDownCancelCommand>, "", NULL },
238  
-        { ""   ,            SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerRestartCommand>,       "", NULL },
239  
-        { NULL,             0,                  false, NULL,                                           "", NULL }
240  
-    };
241  
-
242  
-    static ChatCommand serverShutdownCommandTable[] =
243  
-    {
244  
-        { "cancel",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerShutDownCancelCommand>, "", NULL },
245  
-        { ""   ,            SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerShutDownCommand>,      "", NULL },
246  
-        { NULL,             0,                  false, NULL,                                           "", NULL }
247  
-    };
248  
-
249  
-    static ChatCommand serverSetCommandTable[] =
250  
-    {
251  
-        { "difftime",       SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleServerSetDiffTimeCommand>,   "", NULL },
252  
-        { "loglevel",       SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleServerSetLogLevelCommand>,   "", NULL },
253  
-        { "logfilelevel",   SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleServerSetLogFileLevelCommand>,   "", NULL },
254  
-        { "motd",           SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerSetMotdCommand>,       "", NULL },
255  
-        { "closed",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerSetClosedCommand>,     "", NULL },
256  
-        { NULL,             0,                  false, NULL,                                           "", NULL }
257  
-    };
258  
-
259  
-    static ChatCommand serverCommandTable[] =
260  
-    {
261  
-        { "corpses",        SEC_GAMEMASTER,     true,  OldHandler<&ChatHandler::HandleServerCorpsesCommand>,     "", NULL },
262  
-        { "exit",           SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleServerExitCommand>,        "", NULL },
263  
-        { "idlerestart",    SEC_ADMINISTRATOR,  true,  NULL,                                                     "", serverIdleRestartCommandTable },
264  
-        { "idleshutdown",   SEC_ADMINISTRATOR,  true,  NULL,                                                     "", serverIdleShutdownCommandTable },
265  
-        { "info",           SEC_PLAYER,         true,  OldHandler<&ChatHandler::HandleServerInfoCommand>,        "", NULL },
266  
-        { "motd",           SEC_PLAYER,         true,  OldHandler<&ChatHandler::HandleServerMotdCommand>,        "", NULL },
267  
-        { "plimit",         SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleServerPLimitCommand>,      "", NULL },
268  
-        { "restart",        SEC_ADMINISTRATOR,  true,  NULL,                                                     "", serverRestartCommandTable },
269  
-        { "shutdown",       SEC_ADMINISTRATOR,  true,  NULL,                                                     "", serverShutdownCommandTable },
270  
-        { "set",            SEC_ADMINISTRATOR,  true,  NULL,                                                     "", serverSetCommandTable },
271  
-        { "togglequerylog", SEC_CONSOLE,        true,  OldHandler<&ChatHandler::HandleServerToggleQueryLogging>, "", NULL },
272  
-        { NULL,             0,                  false, NULL,                                                     "", NULL }
273  
-    };
274  
-
275 198
     static ChatCommand unbanCommandTable[] =
276 199
     {
277 200
         { "account",        SEC_ADMINISTRATOR,  true,  OldHandler<&ChatHandler::HandleUnBanAccountCommand>,       "", NULL },
@@ -311,14 +234,12 @@ ChatCommand* ChatHandler::getCommandTable()
311 234
 
312 235
     static ChatCommand commandTable[] =
313 236
     {
314  
-        { "character",      SEC_GAMEMASTER,     true,  NULL,                                           "", characterCommandTable},
315 237
         { "list",           SEC_ADMINISTRATOR,  true,  NULL,                                           "", listCommandTable     },
316 238
         { "lookup",         SEC_ADMINISTRATOR,  true,  NULL,                                           "", lookupCommandTable   },
317 239
         { "pdump",          SEC_ADMINISTRATOR,  true,  NULL,                                           "", pdumpCommandTable    },
318 240
         { "guild",          SEC_ADMINISTRATOR,  true,  NULL,                                           "", guildCommandTable    },
319 241
         { "group",          SEC_ADMINISTRATOR,  false, NULL,                                           "", groupCommandTable    },
320 242
         { "reset",          SEC_ADMINISTRATOR,  true,  NULL,                                           "", resetCommandTable    },
321  
-        { "server",         SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverCommandTable   },
322 243
 
323 244
         { "channel",        SEC_ADMINISTRATOR, true, NULL,                                             "", channelCommandTable  },
324 245
 
59  src/server/game/Chat/Chat.h
@@ -119,10 +119,13 @@ class ChatHandler
119 119
 
120 120
         GameObject* GetNearbyGameObject();
121 121
         GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry);
122  
-        bool HasSentErrorMessage() const { return sentErrorMessage;}
123  
-        void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
124  
-        static bool LoadCommandTable() { return load_command_table;}
125  
-        static void SetLoadCommandTable(bool val){ load_command_table = val;};
  122
+        bool HasSentErrorMessage() const { return sentErrorMessage; }
  123
+        void SetSentErrorMessage(bool val){ sentErrorMessage = val; }
  124
+        static bool LoadCommandTable() { return load_command_table; }
  125
+        static void SetLoadCommandTable(bool val) { load_command_table = val; }
  126
+        
  127
+        // cs_character
  128
+        void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel);
126 129
 
127 130
     protected:
128 131
         explicit ChatHandler() : m_session(NULL) {}      // for CLI subclass
@@ -147,19 +150,6 @@ class ChatHandler
147 150
         bool HandleBanListCharacterCommand(const char* args);
148 151
         bool HandleBanListIPCommand(const char* args);
149 152
 
150  
-        bool HandleCharacterCustomizeCommand(const char* args);
151  
-        bool HandleCharacterChangeFactionCommand(const char* args);
152  
-        bool HandleCharacterChangeRaceCommand(const char * args);
153  
-        bool HandleCharacterDeletedDeleteCommand(const char* args);
154  
-        bool HandleCharacterDeletedListCommand(const char* args);
155  
-        bool HandleCharacterDeletedRestoreCommand(const char* args);
156  
-        bool HandleCharacterDeletedOldCommand(const char* args);
157  
-        bool HandleCharacterEraseCommand(const char* args);
158  
-        bool HandleCharacterLevelCommand(const char* args);
159  
-        bool HandleCharacterRenameCommand(const char* args);
160  
-        bool HandleCharacterReputationCommand(const char* args);
161  
-        bool HandleCharacterTitlesCommand(const char* args);
162  
-
163 153
         bool HandleChannelSetOwnership(const char *args);
164 154
 
165 155
         bool HandlePossessCommand(const char* args);
@@ -212,24 +202,6 @@ class ChatHandler
212 202
         bool HandleSendMessageCommand(const char * args);
213 203
         bool HandleSendMoneyCommand(const char* args);
214 204
 
215  
-        bool HandleServerCorpsesCommand(const char* args);
216  
-        bool HandleServerExitCommand(const char* args);
217  
-        bool HandleServerIdleRestartCommand(const char* args);
218  
-        bool HandleServerIdleShutDownCommand(const char* args);
219  
-        bool HandleServerInfoCommand(const char* args);
220  
-        bool HandleServerMotdCommand(const char* args);
221  
-        bool HandleServerPLimitCommand(const char* args);
222  
-        bool HandleServerRestartCommand(const char* args);
223  
-        bool HandleServerSetLogLevelCommand(const char* args);
224  
-        bool HandleServerSetMotdCommand(const char* args);
225  
-        bool HandleServerShutDownCommand(const char* args);
226  
-        bool HandleServerShutDownCancelCommand(const char* args);
227  
-        bool HandleServerSetClosedCommand(const char* args);
228  
-        bool HandleServerToggleQueryLogging(const char* args);
229  
-
230  
-        bool HandleServerSetLogFileLevelCommand(const char* args);
231  
-        bool HandleServerSetDiffTimeCommand(const char* args);
232  
-
233 205
         bool HandleUnBanAccountCommand(const char* args);
234 206
         bool HandleUnBanAccountByCharCommand(const char* args);
235 207
         bool HandleUnBanCharacterCommand(const char* args);
@@ -342,25 +314,8 @@ class ChatHandler
342 314
         bool HandleBanHelper(BanMode mode, char const* args);
343 315
         bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
344 316
         bool HandleUnBanHelper(BanMode mode, char const* args);
345  
-        void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel);
346 317
         void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id);
347 318
 
348  
-        // Stores informations about a deleted character
349  
-        struct DeletedInfo
350  
-        {
351  
-            uint32      lowguid;                            ///< the low GUID from the character
352  
-            std::string name;                               ///< the character name
353  
-            uint32      accountId;                          ///< the account id
354  
-            std::string accountName;                        ///< the account name
355  
-            time_t      deleteDate;                         ///< the date at which the character has been deleted
356  
-        };
357  
-
358  
-        typedef std::list<DeletedInfo> DeletedInfoList;
359  
-        bool GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::string searchString = "");
360  
-        std::string GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList::const_iterator& itr, DeletedInfoList::const_iterator const& itr_end);
361  
-        void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList);
362  
-        void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo);
363  
-
364 319
     private:
365 320
         bool _HandleGMTicketResponseAppendCommand(const char* args, bool newLine);
366 321
 
30  src/server/game/Chat/Commands/Level0.cpp
@@ -80,29 +80,6 @@ bool ChatHandler::HandleStartCommand(const char* /*args*/)
80 80
     return true;
81 81
 }
82 82
 
83  
-bool ChatHandler::HandleServerInfoCommand(const char* /*args*/)
84  
-{
85  
-    uint32 playersNum = sWorld->GetPlayerCount();
86  
-    uint32 maxPlayersNum = sWorld->GetMaxPlayerCount();
87  
-    uint32 activeClientsNum = sWorld->GetActiveSessionCount();
88  
-    uint32 queuedClientsNum = sWorld->GetQueuedSessionCount();
89  
-    uint32 maxActiveClientsNum = sWorld->GetMaxActiveSessionCount();
90  
-    uint32 maxQueuedClientsNum = sWorld->GetMaxQueuedSessionCount();
91  
-    std::string uptime = secsToTimeString(sWorld->GetUptime());
92  
-    uint32 updateTime = sWorld->GetUpdateTime();
93  
-
94  
-    SendSysMessage(_FULLVERSION);
95  
-    PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
96  
-    PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
97  
-    PSendSysMessage(LANG_UPTIME, uptime.c_str());
98  
-    PSendSysMessage(LANG_UPDATE_DIFF, updateTime);
99  
-    //! Can't use sWorld->ShutdownMsg here in case of console command
100  
-    if (sWorld->IsShuttingDown())
101  
-        PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).c_str());
102  
-
103  
-    return true;
104  
-}
105  
-
106 83
 bool ChatHandler::HandleDismountCommand(const char* /*args*/)
107 84
 {
108 85
     Player* player = m_session->GetPlayer();
@@ -150,10 +127,3 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
150 127
     return true;
151 128
 }
152 129
 
153  
-/// Display the 'Message of the day' for the realm
154  
-bool ChatHandler::HandleServerMotdCommand(const char* /*args*/)
155  
-{
156  
-    PSendSysMessage(LANG_MOTD_CURRENT, sWorld->GetMotd());
157  
-    return true;
158  
-}
159  
-
231  src/server/game/Chat/Commands/Level2.cpp
@@ -456,190 +456,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
456 456
     return true;
457 457
 }
458 458
 
459  
-//rename characters
460  
-bool ChatHandler::HandleCharacterRenameCommand(const char* args)
461  
-{
462  
-    Player* target;
463  
-    uint64 targetGuid;
464  
-    std::string targetName;
465  
-    if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
466  
-        return false;
467  
-
468  
-    if (target)
469  
-    {
470  
-        // check online security
471  
-        if (HasLowerSecurity(target, 0))
472  
-            return false;
473  
-
474  
-        PSendSysMessage(LANG_RENAME_PLAYER, GetNameLink(target).c_str());
475  
-        target->SetAtLoginFlag(AT_LOGIN_RENAME);
476  
-    }
477  
-    else
478  
-    {
479  
-        // check offline security
480  
-        if (HasLowerSecurity(NULL, targetGuid))
481  
-            return false;
482  
-
483  
-        std::string oldNameLink = playerLink(targetName);
484  
-
485  
-        PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
486  
-
487  
-        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
488  
-
489  
-        stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
490  
-        stmt->setUInt32(1, GUID_LOPART(targetGuid));
491  
-
492  
-        CharacterDatabase.Execute(stmt);
493  
-    }
494  
-
495  
-    return true;
496  
-}
497  
-
498  
-// customize characters
499  
-bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
500  
-{
501  
-    Player* target;
502  
-    uint64 targetGuid;
503  
-    std::string targetName;
504  
-    if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
505  
-        return false;
506  
-
507  
-    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
508  
-
509  
-    stmt->setUInt16(0, uint16(AT_LOGIN_CUSTOMIZE));
510  
-
511  
-    if (target)
512  
-    {
513  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
514  
-        target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
515  
-
516  
-        stmt->setUInt32(1, target->GetGUIDLow());
517  
-    }
518  
-    else
519  
-    {
520  
-        std::string oldNameLink = playerLink(targetName);
521  
-
522  
-        stmt->setUInt32(1, GUID_LOPART(targetGuid));
523  
-
524  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
525  
-    }
526  
-
527  
-    CharacterDatabase.Execute(stmt);
528  
-
529  
-    return true;
530  
-}
531  
-
532  
-bool ChatHandler::HandleCharacterChangeFactionCommand(const char* args)
533  
-{
534  
-    Player* target;
535  
-    uint64 targetGuid;
536  
-    std::string targetName;
537  
-
538  
-    if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
539  
-        return false;
540  
-
541  
-    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
542  
-
543  
-    stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
544  
-
545  
-    if (target)
546  
-    {
547  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
548  
-        target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
549  
-
550  
-        stmt->setUInt32(1, target->GetGUIDLow());
551  
-    }
552  
-    else
553  
-    {
554  
-        std::string oldNameLink = playerLink(targetName);
555  
-
556  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
557  
-
558  
-        stmt->setUInt32(1, GUID_LOPART(targetGuid));
559  
-    }
560  
-
561  
-    CharacterDatabase.Execute(stmt);
562  
-
563  
-    return true;
564  
-}
565  
-
566  
-bool ChatHandler::HandleCharacterChangeRaceCommand(const char * args)
567  
-{
568  
-    Player* target;
569  
-    uint64 targetGuid;
570  
-    std::string targetName;
571  
-    if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
572  
-        return false;
573  
-
574  
-    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
575  
-
576  
-    stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE));
577  
-
578  
-    if (target)
579  
-    {
580  
-        // TODO : add text into database
581  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
582  
-        target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
583  
-
584  
-        stmt->setUInt32(1, target->GetGUIDLow());
585  
-    }
586  
-    else
587  
-    {
588  
-        std::string oldNameLink = playerLink(targetName);
589  
-
590  
-        // TODO : add text into database
591  
-        PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
592  
-
593  
-        stmt->setUInt32(1, GUID_LOPART(targetGuid));
594  
-    }
595  
-
596  
-    CharacterDatabase.Execute(stmt);
597  
-
598  
-    return true;
599  
-}
600  
-
601  
-bool ChatHandler::HandleCharacterReputationCommand(const char* args)
602  
-{
603  
-    Player* target;
604  
-    if (!extractPlayerTarget((char*)args, &target))
605  
-        return false;
606  
-
607  
-    LocaleConstant loc = GetSessionDbcLocale();
608  
-
609  
-    FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
610  
-    for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
611  
-    {
612  
-        const FactionState& faction = itr->second;
613  
-        FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
614  
-        char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
615  
-        ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
616  
-        std::string rankName = GetTrinityString(ReputationRankStrIndex[rank]);
617  
-        std::ostringstream ss;
618  
-        if (m_session)
619  
-            ss << faction.ID << " - |cffffffff|Hfaction:" << faction.ID << "|h[" << factionName << ' ' << localeNames[loc] << "]|h|r";
620  
-        else
621  
-            ss << faction.ID << " - " << factionName << ' ' << localeNames[loc];
622  
-
623  
-        ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
624  
-
625  
-        if (faction.Flags & FACTION_FLAG_VISIBLE)
626  
-            ss << GetTrinityString(LANG_FACTION_VISIBLE);
627  
-        if (faction.Flags & FACTION_FLAG_AT_WAR)
628  
-            ss << GetTrinityString(LANG_FACTION_ATWAR);
629  
-        if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
630  
-            ss << GetTrinityString(LANG_FACTION_PEACE_FORCED);
631  
-        if (faction.Flags & FACTION_FLAG_HIDDEN)
632  
-            ss << GetTrinityString(LANG_FACTION_HIDDEN);
633  
-        if (faction.Flags & FACTION_FLAG_INVISIBLE_FORCED)
634  
-            ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
635  
-        if (faction.Flags & FACTION_FLAG_INACTIVE)
636  
-            ss << GetTrinityString(LANG_FACTION_INACTIVE);
637  
-
638  
-        SendSysMessage(ss.str().c_str());
639  
-    }
640  
-    return true;
641  
-}
642  
-
643 459
 bool ChatHandler::HandleLookupEventCommand(const char* args)
644 460
 {
645 461
     if (!*args)
@@ -846,13 +662,6 @@ bool ChatHandler::LookupPlayerSearchCommand(PreparedQueryResult result, int32 li
846 662
     return true;
847 663
 }
848 664
 
849  
-/// Triggering corpses expire check in world
850  
-bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/)
851  
-{
852  
-    sObjectAccessor->RemoveOldCorpses();
853  
-    return true;
854  
-}
855  
-
856 665
 bool ChatHandler::HandleRepairitemsCommand(const char* args)
857 666
 {
858 667
     Player* target;
@@ -1128,43 +937,3 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args)
1128 937
         SendSysMessage(LANG_COMMAND_NOTITLEFOUND);
1129 938
     return true;
1130 939
 }
1131  
-
1132  
-bool ChatHandler::HandleCharacterTitlesCommand(const char* args)
1133  
-{
1134  
-    if (!*args)
1135  
-        return false;
1136  
-
1137  
-    Player* target;
1138  
-    if (!extractPlayerTarget((char*)args, &target))
1139  
-        return false;
1140  
-
1141  
-    LocaleConstant loc = GetSessionDbcLocale();
1142  
-    char const* targetName = target->GetName();
1143  
-    char const* knownStr = GetTrinityString(LANG_KNOWN);
1144  
-
1145  
-    // Search in CharTitles.dbc
1146  
-    for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
1147  
-    {
1148  
-        CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
1149  
-        if (titleInfo && target->HasTitle(titleInfo))
1150  
-        {
1151  
-            std::string name = titleInfo->name[loc];
1152  
-            if (name.empty())
1153  
-                continue;
1154  
-
1155  
-            char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index
1156  
-                ? GetTrinityString(LANG_ACTIVE)
1157  
-                : "";
1158  
-
1159  
-            char titleNameStr[80];
1160  
-            snprintf(titleNameStr, 80, name.c_str(), targetName);
1161  
-
1162  
-            // send title in "id (idx:idx) - [namedlink locale]" format
1163  
-            if (m_session)
1164  
-                PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleNameStr, localeNames[loc], knownStr, activeStr);
1165  
-            else
1166  
-                PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name.c_str(), localeNames[loc], knownStr, activeStr);
1167  
-        }
1168  
-    }
1169  
-    return true;
1170  
-}
266  src/server/game/Chat/Commands/Level3.cpp
@@ -2198,47 +2198,6 @@ void ChatHandler::HandleCharacterLevel(Player* player, uint64 playerGuid, uint32
2198 2198
     }
2199 2199
 }
2200 2200
 
2201  
-bool ChatHandler::HandleCharacterLevelCommand(const char *args)
2202  
-{
2203  
-    char* nameStr;
2204  
-    char* levelStr;
2205  
-    extractOptFirstArg((char*)args, &nameStr, &levelStr);
2206  
-    if (!levelStr)
2207  
-        return false;
2208  
-
2209  
-    // exception opt second arg: .character level $name
2210  
-    if (isalpha(levelStr[0]))
2211  
-    {
2212  
-        nameStr = levelStr;
2213  
-        levelStr = NULL;                                    // current level will used
2214  
-    }
2215  
-
2216  
-    Player* target;
2217  
-    uint64 target_guid;
2218  
-    std::string target_name;
2219  
-    if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
2220  
-        return false;
2221  
-
2222  
-    int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid);
2223  
-    int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
2224  
-
2225  
-    if (newlevel < 1)
2226  
-        return false;                                       // invalid level
2227  
-
2228  
-    if (newlevel > STRONG_MAX_LEVEL)                         // hardcoded maximum level
2229  
-        newlevel = STRONG_MAX_LEVEL;
2230  
-
2231  
-    HandleCharacterLevel(target, target_guid, oldlevel, newlevel);
2232  
-
2233  
-    if (!m_session || m_session->GetPlayer() != target)      // including player == NULL
2234  
-    {
2235  
-        std::string nameLink = playerLink(target_name);
2236  
-        PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel);
2237  
-    }
2238  
-
2239  
-    return true;
2240  
-}
2241  
-
2242 2201
 bool ChatHandler::HandleLevelUpCommand(const char *args)
2243 2202
 {
2244 2203
     char* nameStr;
@@ -2698,152 +2657,6 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
2698 2657
     return true;
2699 2658
 }
2700 2659
 
2701  
-bool ChatHandler::HandleServerShutDownCancelCommand(const char* /*args*/)
2702  
-{
2703  
-    sWorld->ShutdownCancel();
2704  
-    return true;
2705  
-}
2706  
-
2707  
-bool ChatHandler::HandleServerShutDownCommand(const char *args)
2708  
-{
2709  
-    if (!*args)
2710  
-        return false;
2711  
-
2712  
-    char* time_str = strtok ((char*) args, " ");
2713  
-    char* exitcode_str = strtok (NULL, "");
2714  
-
2715  
-    int32 time = atoi (time_str);
2716  
-
2717  
-    ///- Prevent interpret wrong arg value as 0 secs shutdown time
2718  
-    if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
2719  
-        return false;
2720  
-
2721  
-    if (exitcode_str)
2722  
-    {
2723  
-        int32 exitcode = atoi (exitcode_str);
2724  
-
2725  
-        // Handle atoi() errors
2726  
-        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
2727  
-            return false;
2728  
-
2729  
-        // Exit code should be in range of 0-125, 126-255 is used
2730  
-        // in many shells for their own return codes and code > 255
2731  
-        // is not supported in many others
2732  
-        if (exitcode < 0 || exitcode > 125)
2733  
-            return false;
2734  
-
2735  
-        sWorld->ShutdownServ(time, 0, exitcode);
2736  
-    }
2737  
-    else
2738  
-        sWorld->ShutdownServ(time, 0, SHUTDOWN_EXIT_CODE);
2739  
-    return true;
2740  
-}
2741  
-
2742  
-bool ChatHandler::HandleServerRestartCommand(const char *args)
2743  
-{
2744  
-    if (!*args)
2745  
-        return false;
2746  
-
2747  
-    char* time_str = strtok ((char*) args, " ");
2748  
-    char* exitcode_str = strtok (NULL, "");
2749  
-
2750  
-    int32 time = atoi (time_str);
2751  
-
2752  
-    ///- Prevent interpret wrong arg value as 0 secs shutdown time
2753  
-    if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
2754  
-        return false;
2755  
-
2756  
-    if (exitcode_str)
2757  
-    {
2758  
-        int32 exitcode = atoi (exitcode_str);
2759  
-
2760  
-        // Handle atoi() errors
2761  
-        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
2762  
-            return false;
2763  
-
2764  
-        // Exit code should be in range of 0-125, 126-255 is used
2765  
-        // in many shells for their own return codes and code > 255
2766  
-        // is not supported in many others
2767  
-        if (exitcode < 0 || exitcode > 125)
2768  
-            return false;
2769  
-
2770  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, exitcode);
2771  
-    }
2772  
-    else
2773  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
2774  
-    return true;
2775  
-}
2776  
-
2777  
-bool ChatHandler::HandleServerIdleRestartCommand(const char *args)
2778  
-{
2779  
-    if (!*args)
2780  
-        return false;
2781  
-
2782  
-    char* time_str = strtok ((char*) args, " ");
2783  
-    char* exitcode_str = strtok (NULL, "");
2784  
-
2785  
-    int32 time = atoi (time_str);
2786  
-
2787  
-    ///- Prevent interpret wrong arg value as 0 secs shutdown time
2788  
-    if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
2789  
-        return false;
2790  
-
2791  
-    if (exitcode_str)
2792  
-    {
2793  
-        int32 exitcode = atoi (exitcode_str);
2794  
-
2795  
-        // Handle atoi() errors
2796  
-        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
2797  
-            return false;
2798  
-
2799  
-        // Exit code should be in range of 0-125, 126-255 is used
2800  
-        // in many shells for their own return codes and code > 255
2801  
-        // is not supported in many others
2802  
-        if (exitcode < 0 || exitcode > 125)
2803  
-            return false;
2804  
-
2805  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
2806  
-    }
2807  
-    else
2808  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
2809  
-    return true;
2810  
-}
2811  
-
2812  
-bool ChatHandler::HandleServerIdleShutDownCommand(const char *args)
2813  
-{
2814  
-    if (!*args)
2815  
-        return false;
2816  
-
2817  
-    char* time_str = strtok ((char*) args, " ");
2818  
-    char* exitcode_str = strtok (NULL, "");
2819  
-
2820  
-    int32 time = atoi (time_str);
2821  
-
2822  
-    ///- Prevent interpret wrong arg value as 0 secs shutdown time
2823  
-    if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
2824  
-        return false;
2825  
-
2826  
-    if (exitcode_str)
2827  
-    {
2828  
-        int32 exitcode = atoi (exitcode_str);
2829  
-
2830  
-        // Handle atoi() errors
2831  
-        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
2832  
-            return false;
2833  
-
2834  
-        // Exit code should be in range of 0-125, 126-255 is used
2835  
-        // in many shells for their own return codes and code > 255
2836  
-        // is not supported in many others
2837  
-        if (exitcode < 0 || exitcode > 125)
2838  
-            return false;
2839  
-
2840  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, exitcode);
2841  
-    }
2842  
-    else
2843  
-        sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
2844  
-    return true;
2845  
-}
2846  
-
2847 2660
 bool ChatHandler::HandleBanAccountCommand(const char *args)
2848 2661
 {
2849 2662
     return HandleBanHelper(BAN_ACCOUNT, args);
@@ -3764,56 +3577,6 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
3764 3577
     return true;
3765 3578
 }
3766 3579
 
3767  
-bool ChatHandler::HandleServerPLimitCommand(const char *args)
3768  
-{
3769  
-    if (*args)
3770  
-    {
3771  
-        char* param = strtok((char*)args, " ");
3772  
-        if (!param)
3773  
-            return false;
3774  
-
3775  
-        int l = strlen(param);
3776  
-
3777  
-        if (strncmp(param, "player", l) == 0)
3778  
-            sWorld->SetPlayerSecurityLimit(SEC_PLAYER);
3779  
-        else if (strncmp(param, "moderator", l) == 0)
3780  
-            sWorld->SetPlayerSecurityLimit(SEC_MODERATOR);
3781  
-        else if (strncmp(param, "gamemaster", l) == 0)
3782  
-            sWorld->SetPlayerSecurityLimit(SEC_GAMEMASTER);
3783  
-        else if (strncmp(param, "administrator", l) == 0)
3784  
-            sWorld->SetPlayerSecurityLimit(SEC_ADMINISTRATOR);
3785  
-        else if (strncmp(param, "reset", l) == 0)
3786  
-        {
3787  
-            sWorld->SetPlayerAmountLimit(ConfigMgr::GetIntDefault("PlayerLimit", 100));
3788  
-            sWorld->LoadDBAllowedSecurityLevel();
3789  
-        }
3790  
-        else
3791  
-        {
3792  
-            int val = atoi(param);
3793  
-            if (val < 0)
3794  
-                sWorld->SetPlayerSecurityLimit(AccountTypes(uint32(-val)));
3795  
-            else
3796  
-                sWorld->SetPlayerAmountLimit(uint32(val));
3797  
-        }
3798  
-    }
3799  
-
3800  
-    uint32 pLimit = sWorld->GetPlayerAmountLimit();
3801  
-    AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
3802  
-    char const* secName = "";
3803  
-    switch (allowedAccountType)
3804  
-    {
3805  
-        case SEC_PLAYER:        secName = "Player";        break;
3806  
-        case SEC_MODERATOR:     secName = "Moderator";     break;
3807  
-        case SEC_GAMEMASTER:    secName = "Gamemaster";    break;
3808  
-        case SEC_ADMINISTRATOR: secName = "Administrator"; break;
3809  
-        default:                secName = "<unknown>";     break;
3810  
-    }
3811  
-
3812  
-    PSendSysMessage("Player limits: amount %u, min. security level %s.", pLimit, secName);
3813  
-
3814  
-    return true;
3815  
-}
3816  
-
3817 3580
 /*
3818 3581
 ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
3819 3582
 Without this function 3rd party scripting library will get linking errors (unresolved external)
@@ -3840,35 +3603,6 @@ bool ChatHandler::HandleComeToMeCommand(const char *args)
3840 3603
     return true;
3841 3604
 }
3842 3605
 
3843  
-/// Define the 'Message of the day' for the realm
3844  
-bool ChatHandler::HandleServerSetMotdCommand(const char *args)
3845  
-{
3846  
-    sWorld->SetMotd(args);
3847  
-    PSendSysMessage(LANG_MOTD_NEW, args);
3848  
-    return true;
3849  
-}
3850  
-
3851  
-/// Set whether we accept new clients
3852  
-bool ChatHandler::HandleServerSetClosedCommand(const char *args)
3853  
-{
3854  
-    if (strncmp(args, "on", 3) == 0)
3855  
-    {
3856  
-        SendSysMessage(LANG_WORLD_CLOSED);
3857  
-        sWorld->SetClosed(true);
3858  
-        return true;
3859  
-    }
3860  
-    else if (strncmp(args, "off", 4) == 0)
3861  
-    {
3862  
-        SendSysMessage(LANG_WORLD_OPENED);
3863  
-        sWorld->SetClosed(false);
3864  
-        return true;
3865  
-    }
3866  
-
3867  
-    SendSysMessage(LANG_USE_BOL);
3868  
-    SetSentErrorMessage(true);
3869  
-    return false;
3870  
-}
3871  
-
3872 3606
 //Send items by mail
3873 3607
 bool ChatHandler::HandleSendItemsCommand(const char *args)
3874 3608
 {
4  src/server/game/Scripting/ScriptLoader.cpp
@@ -61,8 +61,10 @@ void AddSC_npc_commandscript();
61 61
 void AddSC_quest_commandscript();
62 62
 void AddSC_reload_commandscript();
63 63
 void AddSC_tele_commandscript();
  64
+void AddSC_server_commandscript();
64 65
 void AddSC_titles_commandscript();
65 66
 void AddSC_wp_commandscript();
  67
+void AddSC_character_commandscript();
66 68
 
67 69
 #ifdef SCRIPTS
68 70
 //world
@@ -665,8 +667,10 @@ void AddCommandScripts()
665 667
     AddSC_quest_commandscript();
666 668
     AddSC_reload_commandscript();
667 669
     AddSC_tele_commandscript();
  670
+	AddSC_server_commandscript();
668 671
     AddSC_titles_commandscript();
669 672
     AddSC_wp_commandscript();
  673
+    AddSC_character_commandscript();
670 674
 }
671 675
 
672 676
 void AddWorldScripts()
3  src/server/scripts/Commands/CMakeLists.txt
@@ -27,9 +27,10 @@ set(scripts_STAT_SRCS
27 27
   Commands/cs_quest.cpp
28 28
   Commands/cs_reload.cpp
29 29
   Commands/cs_tele.cpp
  30
+  Commands/cs_server.cpp
30 31
   Commands/cs_titles.cpp
31 32
   Commands/cs_wp.cpp
32  
-#  Commands/cs_character.cpp
  33
+  Commands/cs_character.cpp
33 34
 #  Commands/cs_list.cpp
34 35
 #  Commands/cs_lookup.cpp
35 36
 #  Commands/cs_pdump.cpp
680  src/server/scripts/Commands/cs_character.cpp
... ...
@@ -0,0 +1,680 @@
  1
+/*
  2
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  3
+ *
  4
+ * This program is free software; you can redistribute it and/or modify it
  5
+ * under the terms of the GNU General Public License as published by the
  6
+ * Free Software Foundation; either version 2 of the License, or (at your
  7
+ * option) any later version.
  8
+ *
  9
+ * This program is distributed in the hope that it will be useful, but WITHOUT
  10
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12
+ * more details.
  13
+ *
  14
+ * You should have received a copy of the GNU General Public License along
  15
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
  16
+ */
  17
+
  18
+/* ScriptData
  19
+Name: character_commandscript
  20
+%Complete: 100
  21
+Comment: All character related commands
  22
+Category: commandscripts
  23
+EndScriptData */
  24
+
  25
+#include "ScriptMgr.h"
  26
+#include "Chat.h"
  27
+#include "AccountMgr.h"
  28
+
  29
+class character_commandscript : public CommandScript
  30
+{
  31
+public:
  32
+    character_commandscript() : CommandScript("character_commandscript") { }
  33
+
  34
+    ChatCommand* GetCommands() const
  35
+    {
  36
+        static ChatCommand characterDeletedCommandTable[] =
  37
+        {
  38
+            { "delete",         SEC_CONSOLE,        true,  &HandleCharacterDeletedDeleteCommand,   "", NULL },
  39
+            { "list",           SEC_ADMINISTRATOR,  true,  &HandleCharacterDeletedListCommand,     "", NULL },
  40
+            { "restore",        SEC_ADMINISTRATOR,  true,  &HandleCharacterDeletedRestoreCommand,  "", NULL },
  41
+            { "old",            SEC_CONSOLE,        true,  &HandleCharacterDeletedOldCommand,      "", NULL },
  42
+            { NULL,             0,                  false, NULL,                                   "", NULL }
  43
+        };
  44
+
  45
+        static ChatCommand characterCommandTable[] =
  46
+        {
  47
+            { "customize",      SEC_GAMEMASTER,     true,  &HandleCharacterCustomizeCommand,       "", NULL },
  48
+            { "changefaction",  SEC_GAMEMASTER,     true,  &HandleCharacterChangeFactionCommand,   "", NULL },
  49
+            { "changerace",     SEC_GAMEMASTER,     true,  &HandleCharacterChangeRaceCommand,      "", NULL },
  50
+            { "deleted",        SEC_GAMEMASTER,     true,  NULL,            "", characterDeletedCommandTable},
  51
+            { "erase",          SEC_CONSOLE,        true,  &HandleCharacterEraseCommand,           "", NULL },
  52
+            { "level",          SEC_ADMINISTRATOR,  true,  &HandleCharacterLevelCommand,           "", NULL },
  53
+            { "rename",         SEC_GAMEMASTER,     true,  &HandleCharacterRenameCommand,          "", NULL },
  54
+            { "reputation",     SEC_GAMEMASTER,     true,  &HandleCharacterReputationCommand,      "", NULL },
  55
+            { "titles",         SEC_GAMEMASTER,     true,  &HandleCharacterTitlesCommand,          "", NULL },
  56
+            { NULL,             0,                  false, NULL,                                   "", NULL }
  57
+        };
  58
+
  59
+        static ChatCommand commandTable[] =
  60
+        {
  61
+            { "character",      SEC_GAMEMASTER,     true,  NULL,                    "", characterCommandTable},
  62
+            { NULL,             0,                  false, NULL,                               "", NULL }
  63
+        };
  64
+ 
  65
+        return commandTable;
  66
+    }
  67
+
  68
+    // Stores informations about a deleted character
  69
+    struct DeletedInfo
  70
+    {
  71
+        uint32      lowguid;                            ///< the low GUID from the character
  72
+        std::string name;                               ///< the character name
  73
+        uint32      accountId;                          ///< the account id
  74
+        std::string accountName;                        ///< the account name
  75
+        time_t      deleteDate;                         ///< the date at which the character has been deleted
  76
+    };
  77
+
  78
+    typedef std::list<DeletedInfo> DeletedInfoList;
  79
+
  80
+    /**
  81
+    * Collects all GUIDs (and related info) from deleted characters which are still in the database.
  82
+    *
  83
+    * @param foundList    a reference to an std::list which will be filled with info data
  84
+    * @param searchString the search string which either contains a player GUID or a part fo the character-name
  85
+    * @return             returns false if there was a problem while selecting the characters (e.g. player name not normalizeable)
  86
+    */
  87
+    static bool GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::string searchString)
  88
+    {
  89
+        PreparedQueryResult result;
  90
+        PreparedStatement* stmt;
  91
+        if (!searchString.empty())
  92
+        {
  93
+            // search by GUID
  94
+            if (isNumeric(searchString.c_str()))
  95
+            {
  96
+                stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
  97
+    
  98
+                stmt->setUInt32(0, uint32(atoi(searchString.c_str())));
  99
+    
  100
+                result = CharacterDatabase.Query(stmt);
  101
+            }
  102
+            // search by name
  103
+            else
  104
+            {
  105
+                if (!normalizePlayerName(searchString))
  106
+                    return false;
  107
+    
  108
+                stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
  109
+    
  110
+                stmt->setString(0, searchString);
  111
+    
  112
+                result = CharacterDatabase.Query(stmt);
  113
+            }
  114
+        }
  115
+        else
  116
+        {
  117
+            stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO);
  118
+    
  119
+            result = CharacterDatabase.Query(stmt);
  120
+        }
  121
+    
  122
+        if (result)
  123
+        {
  124
+            do
  125
+            {
  126
+                Field* fields = result->Fetch();
  127
+    
  128
+                DeletedInfo info;
  129
+    
  130
+                info.lowguid    = fields[0].GetUInt32();
  131
+                info.name       = fields[1].GetString();
  132
+                info.accountId  = fields[2].GetUInt32();
  133
+    
  134
+                // account name will be empty for not existed account
  135
+                AccountMgr::GetName(info.accountId, info.accountName);
  136
+    
  137
+                info.deleteDate = time_t(fields[3].GetUInt32());
  138
+    
  139
+                foundList.push_back(info);
  140
+            } while (result->NextRow());
  141
+        }
  142
+    
  143
+        return true;
  144
+    }
  145
+
  146
+    /**
  147
+    * Shows all deleted characters which matches the given search string, expected non empty list
  148
+    *
  149
+    * @see HandleCharacterDeletedListCommand
  150
+    * @see HandleCharacterDeletedRestoreCommand
  151
+    * @see HandleCharacterDeletedDeleteCommand
  152
+    * @see DeletedInfoList
  153
+    *
  154
+    * @param foundList contains a list with all found deleted characters
  155
+    */
  156
+    static void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList, ChatHandler* handler)
  157
+    {
  158
+        if (!handler->GetSession())
  159
+        {
  160
+            handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR);
  161
+            handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_HEADER);
  162
+            handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR);
  163
+        }
  164
+    
  165
+        for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
  166
+        {
  167
+            std::string dateStr = TimeToTimestampStr(itr->deleteDate);
  168
+    
  169
+            if (!handler->GetSession())
  170
+                handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE,
  171
+                    itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
  172
+                    itr->accountId, dateStr.c_str());
  173
+            else
  174
+                handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CHAT,
  175
+                    itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
  176
+                    itr->accountId, dateStr.c_str());
  177
+        }
  178
+    
  179
+        if (!handler->GetSession())
  180
+            handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR);
  181
+    }
  182
+
  183
+    /**
  184
+    * Restore a previously deleted character
  185
+    *
  186
+    * @see HandleCharacterDeletedListHelper
  187
+    * @see HandleCharacterDeletedRestoreCommand
  188
+    * @see HandleCharacterDeletedDeleteCommand
  189
+    * @see DeletedInfoList
  190
+    *
  191
+    * @param delInfo the informations about the character which will be restored
  192
+    */
  193
+    static void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo, ChatHandler* handler)
  194
+    {
  195
+        if (delInfo.accountName.empty())                    // account not exist
  196
+        {
  197
+            handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
  198
+            return;
  199
+        }
  200
+    
  201
+        // check character count
  202
+        uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
  203
+        if (charcount >= 10)
  204
+        {
  205
+            handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
  206
+            return;
  207
+        }
  208
+    
  209
+        if (sObjectMgr->GetPlayerGUIDByName(delInfo.name))
  210
+        {
  211
+            handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
  212
+            return;
  213
+        }
  214
+    
  215
+        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
  216
+    
  217
+        stmt->setString(0, delInfo.name);
  218
+        stmt->setUInt32(1, delInfo.accountId);
  219
+        stmt->setUInt32(2, delInfo.lowguid);
  220
+    
  221
+        CharacterDatabase.Execute(stmt);
  222
+    
  223
+        stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
  224
+        stmt->setUInt32(0, delInfo.lowguid);
  225
+        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
  226
+            sWorld->AddCharacterNameData(delInfo.lowguid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8());
  227
+    }
  228
+
  229
+    static bool HandleCharacterTitlesCommand(ChatHandler* handler, char const* args)
  230
+    {
  231
+        if (!*args)
  232
+            return false;
  233
+
  234
+        Player* target;
  235
+        if (!handler->extractPlayerTarget((char*)args, &target))
  236
+            return false;
  237
+
  238
+        LocaleConstant loc = handler->GetSessionDbcLocale();
  239
+        char const* targetName = target->GetName();
  240
+        char const* knownStr = handler->GetTrinityString(LANG_KNOWN);
  241
+
  242
+        // Search in CharTitles.dbc
  243
+        for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
  244
+        {
  245
+            CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
  246
+
  247
+            if (titleInfo && target->HasTitle(titleInfo))
  248
+            {
  249
+                std::string name = titleInfo->name[loc];
  250
+                if (name.empty())
  251
+                    continue;
  252
+
  253
+                char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index
  254
+                ? handler->GetTrinityString(LANG_ACTIVE)
  255
+                : "";
  256
+
  257
+                char titleNameStr[80];
  258
+                snprintf(titleNameStr, 80, name.c_str(), targetName);
  259
+
  260
+                // send title in "id (idx:idx) - [namedlink locale]" format
  261
+                if (handler->GetSession())
  262
+                    handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleNameStr, localeNames[loc], knownStr, activeStr);
  263
+                else
  264
+                    handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name.c_str(), localeNames[loc], knownStr, activeStr);
  265
+            }
  266
+        }