TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
character_commandscript Class Reference

Classes

struct  DeletedInfo
 

Public Types

typedef std::list< DeletedInfoDeletedInfoList
 

Public Member Functions

 character_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool GetDeletedCharacterInfoList (DeletedInfoList &foundList, std::string searchString)
 
static void HandleCharacterDeletedListHelper (DeletedInfoList const &foundList, ChatHandler *handler)
 
static void HandleCharacterDeletedRestoreHelper (DeletedInfo const &delInfo, ChatHandler *handler)
 
static void HandleCharacterLevel (Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
 
static bool HandleCharacterTitlesCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterRenameCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterLevelCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterCustomizeCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterChangeFactionCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterChangeRaceCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterReputationCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterDeletedListCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterDeletedRestoreCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterDeletedDeleteCommand (ChatHandler *handler, char const *args)
 
static bool HandleCharacterDeletedOldCommand (ChatHandler *, char const *args)
 
static bool HandleCharacterEraseCommand (ChatHandler *handler, char const *args)
 
static bool HandleLevelUpCommand (ChatHandler *handler, char const *args)
 
static bool HandlePDumpLoadCommand (ChatHandler *handler, char const *args)
 
static bool HandlePDumpWriteCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Member Typedef Documentation

Constructor & Destructor Documentation

character_commandscript::character_commandscript ( )
inline
36 : CommandScript("character_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> character_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

39  {
40  static std::vector<ChatCommand> pdumpCommandTable =
41  {
44  };
45  static std::vector<ChatCommand> characterDeletedCommandTable =
46  {
51  };
52 
53  static std::vector<ChatCommand> characterCommandTable =
54  {
58  { "deleted", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED, true, NULL, "", characterDeletedCommandTable },
64  };
65 
66  static std::vector<ChatCommand> commandTable =
67  {
68  { "character", rbac::RBAC_PERM_COMMAND_CHARACTER, true, NULL, "", characterCommandTable },
69  { "levelup", rbac::RBAC_PERM_COMMAND_LEVELUP, false, &HandleLevelUpCommand, "" },
70  { "pdump", rbac::RBAC_PERM_COMMAND_PDUMP, true, NULL, "", pdumpCommandTable },
71  };
72  return commandTable;
73  }
static bool HandleCharacterCustomizeCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:465
static bool HandleCharacterTitlesCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:253
static bool HandleCharacterLevelCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:424
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:194
Definition: RBAC.h:180
static bool HandleCharacterRenameCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:296
static bool HandleCharacterDeletedRestoreCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:631
static bool HandleCharacterReputationCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:549
static bool HandlePDumpWriteCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:951
static bool HandleCharacterDeletedDeleteCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:696
static bool HandleCharacterDeletedOldCommand(ChatHandler *, char const *args)
Definition: cs_character.cpp:733
static bool HandleCharacterDeletedListCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:602
static bool HandlePDumpLoadCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:840
static bool HandleLevelUpCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:800
static bool HandleCharacterEraseCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:756
static bool HandleCharacterChangeRaceCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:520
Definition: RBAC.h:195
static bool HandleCharacterChangeFactionCommand(ChatHandler *handler, char const *args)
Definition: cs_character.cpp:492

+ Here is the call graph for this function:

static bool character_commandscript::GetDeletedCharacterInfoList ( DeletedInfoList foundList,
std::string  searchString 
)
inlinestatic

Collects all GUIDs (and related info) from deleted characters which are still in the database.

Parameters
foundLista reference to an std::list which will be filled with info data
searchStringthe search string which either contains a player GUID or a part fo the character-name
Returns
returns false if there was a problem while selecting the characters (e.g. player name not normalizeable)
95  {
96  PreparedQueryResult result;
97  PreparedStatement* stmt;
98  if (!searchString.empty())
99  {
100  // search by GUID
101  if (isNumeric(searchString.c_str()))
102  {
104  stmt->setUInt64(0, strtoull(searchString.c_str(), nullptr, 10));
105  result = CharacterDatabase.Query(stmt);
106  }
107  // search by name
108  else
109  {
110  if (!normalizePlayerName(searchString))
111  return false;
112 
114  stmt->setString(0, searchString);
115  result = CharacterDatabase.Query(stmt);
116  }
117  }
118  else
119  {
121  result = CharacterDatabase.Query(stmt);
122  }
123 
124  if (result)
125  {
126  do
127  {
128  Field* fields = result->Fetch();
129 
130  DeletedInfo info;
131 
132  info.guid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
133  info.name = fields[1].GetString();
134  info.accountId = fields[2].GetUInt32();
135 
136  // account name will be empty for not existed account
137  AccountMgr::GetName(info.accountId, info.accountName);
138  info.deleteDate = time_t(fields[3].GetUInt32());
139  foundList.push_back(info);
140  }
141  while (result->NextRow());
142  }
143 
144  return true;
145  }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: CharacterDatabase.h:379
Class used to access individual fields of database query result.
Definition: Field.h:56
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: PreparedStatement.h:74
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:303
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
bool isNumeric(wchar_t wchar)
Definition: Util.h:194
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:377
Definition: CharacterDatabase.h:378
std::string GetString() const
Definition: Field.h:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterChangeFactionCommand ( ChatHandler handler,
char const args 
)
inlinestatic
493  {
494  Player* target;
495  ObjectGuid targetGuid;
496  std::string targetName;
497 
498  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
499  return false;
500 
502  stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
503  if (target)
504  {
505  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
506  target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
507  stmt->setUInt64(1, target->GetGUID().GetCounter());
508  }
509  else
510  {
511  std::string oldNameLink = handler->playerLink(targetName);
512  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.ToString().c_str());
513  stmt->setUInt64(1, targetGuid.GetCounter());
514  }
516 
517  return true;
518  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:374
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
virtual std::string GetNameLink() const
Definition: Chat.h:101
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:373
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterChangeRaceCommand ( ChatHandler handler,
char const args 
)
inlinestatic
Todo:
add text into database
Todo:
add text into database
521  {
522  Player* target;
523  ObjectGuid targetGuid;
524  std::string targetName;
525  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
526  return false;
527 
529  stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE));
530  if (target)
531  {
533  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
534  target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
535  stmt->setUInt64(1, target->GetGUID().GetCounter());
536  }
537  else
538  {
539  std::string oldNameLink = handler->playerLink(targetName);
541  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.ToString().c_str());
542  stmt->setUInt64(1, targetGuid.GetCounter());
543  }
545 
546  return true;
547  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:374
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
virtual std::string GetNameLink() const
Definition: Chat.h:101
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:373
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterCustomizeCommand ( ChatHandler handler,
char const args 
)
inlinestatic
466  {
467  Player* target;
468  ObjectGuid targetGuid;
469  std::string targetName;
470  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
471  return false;
472 
474  stmt->setUInt16(0, uint16(AT_LOGIN_CUSTOMIZE));
475  if (target)
476  {
477  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
478  target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
479  stmt->setUInt64(1, target->GetGUID().GetCounter());
480  }
481  else
482  {
483  std::string oldNameLink = handler->playerLink(targetName);
484  stmt->setUInt64(1, targetGuid.GetCounter());
485  handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), targetGuid.ToString().c_str());
486  }
488 
489  return true;
490  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:374
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
virtual std::string GetNameLink() const
Definition: Chat.h:101
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:373
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterDeletedDeleteCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Handles the '.character deleted delete' command, which completely deletes all deleted characters which matches the given search string

See also
Player::GetDeletedCharacterGUIDs
Player::DeleteFromDB
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
Parameters
argsthe search string which either contains a player GUID or a part fo the character-name
697  {
698  // It is required to submit at least one argument
699  if (!*args)
700  return false;
701 
702  DeletedInfoList foundList;
703  if (!GetDeletedCharacterInfoList(foundList, args))
704  return false;
705 
706  if (foundList.empty())
707  {
709  return false;
710  }
711 
713  HandleCharacterDeletedListHelper(foundList, handler);
714 
715  // Call the appropriate function to delete them (current account for deleted characters is 0)
716  for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
717  Player::DeleteFromDB(itr->guid, 0, false, true);
718 
719  return true;
720  }
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition: cs_character.cpp:157
Definition: Language.h:888
std::list< DeletedInfo > DeletedInfoList
Definition: cs_character.cpp:85
Definition: Language.h:890
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString)
Definition: cs_character.cpp:94
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterDeletedListCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Handles the '.character deleted list' command, which shows all deleted characters which matches the given search string

See also
HandleCharacterDeletedListHelper
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
argsthe search string which either contains a player GUID or a part fo the character-name
603  {
604  DeletedInfoList foundList;
605  if (!GetDeletedCharacterInfoList(foundList, args))
606  return false;
607 
608  // if no characters have been found, output a warning
609  if (foundList.empty())
610  {
612  return false;
613  }
614 
615  HandleCharacterDeletedListHelper(foundList, handler);
616 
617  return true;
618  }
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition: cs_character.cpp:157
Definition: Language.h:888
std::list< DeletedInfo > DeletedInfoList
Definition: cs_character.cpp:85
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString)
Definition: cs_character.cpp:94
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void character_commandscript::HandleCharacterDeletedListHelper ( DeletedInfoList const foundList,
ChatHandler handler 
)
inlinestatic

Shows all deleted characters which matches the given search string, expected non empty list

See also
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
foundListcontains a list with all found deleted characters
158  {
159  if (!handler->GetSession())
160  {
164  }
165 
166  for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
167  {
168  std::string dateStr = TimeToTimestampStr(itr->deleteDate);
169 
170  if (!handler->GetSession())
172  itr->guid.ToString().c_str(), itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
173  itr->accountId, dateStr.c_str());
174  else
176  itr->guid.ToString().c_str(), itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
177  itr->accountId, dateStr.c_str());
178  }
179 
180  if (!handler->GetSession())
182  }
Definition: Language.h:885
Definition: Language.h:895
std::string TimeToTimestampStr(time_t t)
Definition: Util.cpp:195
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:887

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterDeletedOldCommand ( ChatHandler ,
char const args 
)
inlinestatic

Handles the '.character deleted old' command, which completely deletes all deleted characters deleted with some days ago

See also
Player::DeleteOldCharacters
Player::DeleteFromDB
HandleCharacterDeletedDeleteCommand
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
Parameters
argsthe search string which either contains a player GUID or a part fo the character-name
734  {
735  int32 keepDays = sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS);
736 
737  char* daysStr = strtok((char*)args, " ");
738  if (daysStr)
739  {
740  if (!isNumeric(daysStr))
741  return false;
742 
743  keepDays = atoi(daysStr);
744  if (keepDays < 0)
745  return false;
746  }
747  // config option value 0 -> disabled and can't be used
748  else if (keepDays <= 0)
749  return false;
750 
751  Player::DeleteOldCharacters(uint32(keepDays));
752 
753  return true;
754  }
Definition: World.h:332
#define sWorld
Definition: World.h:887
int32_t int32
Definition: Define.h:146
bool isNumeric(wchar_t wchar)
Definition: Util.h:194
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterDeletedRestoreCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Handles the '.character deleted restore' command, which restores all deleted characters which matches the given search string

The command automatically calls '.character deleted list' command with the search string to show all restored characters.

See also
HandleCharacterDeletedRestoreHelper
HandleCharacterDeletedListCommand
HandleCharacterDeletedDeleteCommand
Parameters
argsthe search string which either contains a player GUID or a part of the character-name
632  {
633  // It is required to submit at least one argument
634  if (!*args)
635  return false;
636 
637  std::string searchString;
638  std::string newCharName;
639  uint32 newAccount = 0;
640 
641  // GCC by some strange reason fail build code without temporary variable
642  std::istringstream params(args);
643  params >> searchString >> newCharName >> newAccount;
644 
645  DeletedInfoList foundList;
646  if (!GetDeletedCharacterInfoList(foundList, searchString))
647  return false;
648 
649  if (foundList.empty())
650  {
652  return false;
653  }
654 
656  HandleCharacterDeletedListHelper(foundList, handler);
657 
658  if (newCharName.empty())
659  {
660  // Drop not existed account cases
661  for (DeletedInfoList::iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
663  }
664  else if (foundList.size() == 1 && normalizePlayerName(newCharName))
665  {
666  DeletedInfo delInfo = foundList.front();
667 
668  // update name
669  delInfo.name = newCharName;
670 
671  // if new account provided update deleted info
672  if (newAccount && newAccount != delInfo.accountId)
673  {
674  delInfo.accountId = newAccount;
675  AccountMgr::GetName(newAccount, delInfo.accountName);
676  }
677 
678  HandleCharacterDeletedRestoreHelper(delInfo, handler);
679  }
680  else
682 
683  return true;
684  }
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition: cs_character.cpp:157
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:303
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
static void HandleCharacterDeletedRestoreHelper(DeletedInfo const &delInfo, ChatHandler *handler)
Definition: cs_character.cpp:194
Definition: Language.h:888
uint32_t uint32
Definition: Define.h:150
std::list< DeletedInfo > DeletedInfoList
Definition: cs_character.cpp:85
Definition: Language.h:889
Definition: Language.h:891
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString)
Definition: cs_character.cpp:94
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::set< uint32 > params[2]
Definition: DisableMgr.cpp:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void character_commandscript::HandleCharacterDeletedRestoreHelper ( DeletedInfo const delInfo,
ChatHandler handler 
)
inlinestatic

Restore a previously deleted character

See also
HandleCharacterDeletedListHelper
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
delInfothe informations about the character which will be restored
195  {
196  if (delInfo.accountName.empty()) // account not exist
197  {
198  handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId);
199  return;
200  }
201 
202  // check character count
203  uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
204  if (charcount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM))
205  {
206  handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId);
207  return;
208  }
209 
210  if (!ObjectMgr::GetPlayerGUIDByName(delInfo.name).IsEmpty())
211  {
212  handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId);
213  return;
214  }
215 
217  stmt->setString(0, delInfo.name);
218  stmt->setUInt32(1, delInfo.accountId);
219  stmt->setUInt64(2, delInfo.guid.GetCounter());
221 
222  sWorld->UpdateCharacterInfoDeleted(delInfo.guid, false, &delInfo.name);
223  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: Language.h:892
static uint32 GetCharactersCount(uint32 accountId)
Definition: AccountMgr.cpp:368
Definition: Language.h:893
Definition: CharacterDatabase.h:343
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: Language.h:894
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: World.h:231
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterEraseCommand ( ChatHandler handler,
char const args 
)
inlinestatic
757  {
758  if (!*args)
759  return false;
760 
761  char* characterName_str = strtok((char*)args, " ");
762  if (!characterName_str)
763  return false;
764 
765  std::string characterName = characterName_str;
766  if (!normalizePlayerName(characterName))
767  return false;
768 
769  ObjectGuid characterGuid;
770  uint32 accountId;
771 
772  Player* player = ObjectAccessor::FindPlayerByName(characterName);
773  if (player)
774  {
775  characterGuid = player->GetGUID();
776  accountId = player->GetSession()->GetAccountId();
777  player->GetSession()->KickPlayer();
778  }
779  else
780  {
781  characterGuid = ObjectMgr::GetPlayerGUIDByName(characterName);
782  if (!characterGuid)
783  {
784  handler->PSendSysMessage(LANG_NO_PLAYER, characterName.c_str());
785  handler->SetSentErrorMessage(true);
786  return false;
787  }
788  accountId = ObjectMgr::GetPlayerAccountIdByGUID(characterGuid);
789  }
790 
791  std::string accountName;
792  AccountMgr::GetName(accountId, accountName);
793 
794  Player::DeleteFromDB(characterGuid, accountId, true, true);
795  handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), characterGuid.ToString().c_str(), accountName.c_str(), accountId);
796 
797  return true;
798  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:136
Definition: Language.h:878
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:303
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
uint32_t uint32
Definition: Define.h:150
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:220
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void character_commandscript::HandleCharacterLevel ( Player player,
ObjectGuid  playerGuid,
uint32  oldLevel,
uint32  newLevel,
ChatHandler handler 
)
inlinestatic
226  {
227  if (player)
228  {
229  player->GiveLevel(newLevel);
230  player->InitTalentForLevel();
231  player->SetUInt32Value(PLAYER_XP, 0);
232 
233  if (handler->needReportToTarget(player))
234  {
235  if (oldLevel == newLevel)
236  ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str());
237  else if (oldLevel < newLevel)
238  ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel);
239  else // if (oldlevel > newlevel)
240  ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel);
241  }
242  }
243  else
244  {
245  // Update level and reset XP, everything else will be updated at login
247  stmt->setUInt8(0, uint8(newLevel));
248  stmt->setUInt64(1, playerGuid.GetCounter());
250  }
251  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: UpdateFields.h:215
Definition: Language.h:582
Definition: PreparedStatement.h:74
Definition: Language.h:580
virtual std::string GetNameLink() const
Definition: Chat.h:101
Definition: CharacterDatabase.h:345
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
uint8_t uint8
Definition: g3dmath.h:164
Definition: Chat.h:56
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: Language.h:581
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:1056
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterLevelCommand ( ChatHandler handler,
char const args 
)
inlinestatic
425  {
426  char* nameStr;
427  char* levelStr;
428  handler->extractOptFirstArg((char*)args, &nameStr, &levelStr);
429  if (!levelStr)
430  return false;
431 
432  // exception opt second arg: .character level $name
433  if (isalpha(levelStr[0]))
434  {
435  nameStr = levelStr;
436  levelStr = NULL; // current level will used
437  }
438 
439  Player* target;
440  ObjectGuid targetGuid;
441  std::string targetName;
442  if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
443  return false;
444 
445  int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(targetGuid);
446  int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
447 
448  if (newlevel < 1)
449  return false; // invalid level
450 
451  if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
452  newlevel = STRONG_MAX_LEVEL;
453 
454  HandleCharacterLevel(target, targetGuid, oldlevel, newlevel, handler);
455  if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including player == NULL
456  {
457  std::string nameLink = handler->playerLink(targetName);
458  handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel);
459  }
460 
461  return true;
462  }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: DBCEnums.h:54
Player * GetPlayer() const
Definition: WorldSession.h:927
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
int32_t int32
Definition: Define.h:146
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
static void HandleCharacterLevel(Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
Definition: cs_character.cpp:225
void extractOptFirstArg(char *args, char **arg1, char **arg2)
Definition: Chat.cpp:998
Definition: ObjectGuid.h:189
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterRenameCommand ( ChatHandler handler,
char const args 
)
inlinestatic
297  {
298  Player* target;
299  ObjectGuid targetGuid;
300  std::string targetName;
301  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
302  return false;
303 
304  char const* newNameStr = strtok(NULL, " ");
305 
306  if (newNameStr)
307  {
308  std::string playerOldName;
309  std::string newName = newNameStr;
310 
311  if (target)
312  {
313  // check online security
314  if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
315  return false;
316 
317  playerOldName = target->GetName();
318  }
319  else
320  {
321  // check offline security
322  if (handler->HasLowerSecurity(NULL, targetGuid))
323  return false;
324 
325  ObjectMgr::GetPlayerNameByGUID(targetGuid, playerOldName);
326  }
327 
328  if (!normalizePlayerName(newName))
329  {
330  handler->SendSysMessage(LANG_BAD_VALUE);
331  handler->SetSentErrorMessage(true);
332  return false;
333  }
334 
335  if (ObjectMgr::CheckPlayerName(newName, target ? target->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS)
336  {
337  handler->SendSysMessage(LANG_BAD_VALUE);
338  handler->SetSentErrorMessage(true);
339  return false;
340  }
341 
342  if (WorldSession* session = handler->GetSession())
343  {
344  if (!session->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(newName))
345  {
347  handler->SetSentErrorMessage(true);
348  return false;
349  }
350  }
351 
353  stmt->setString(0, newName);
355  if (result)
356  {
357  handler->PSendSysMessage(LANG_RENAME_PLAYER_ALREADY_EXISTS, newName.c_str());
358  handler->SetSentErrorMessage(true);
359  return false;
360  }
361 
362  // Remove declined name from db
364  stmt->setUInt64(0, targetGuid.GetCounter());
366 
367  if (target)
368  {
369  target->SetName(newName);
370 
371  if (WorldSession* session = target->GetSession())
372  session->KickPlayer();
373  }
374  else
375  {
377  stmt->setString(0, newName);
378  stmt->setUInt64(1, targetGuid.GetCounter());
380  }
381 
382  sWorld->UpdateCharacterInfo(targetGuid, newName);
383 
384  handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
385 
386  if (WorldSession* session = handler->GetSession())
387  {
388  if (Player* player = session->GetPlayer())
389  sLog->outCommand(session->GetAccountId(), "GM %s (Account: %u) forced rename %s to player %s (Account: %u)", player->GetName().c_str(), session->GetAccountId(), newName.c_str(), playerOldName.c_str(), ObjectMgr::GetPlayerAccountIdByGUID(targetGuid));
390  }
391  else
392  sLog->outCommand(0, "CONSOLE forced rename '%s' to '%s' (%s)", playerOldName.c_str(), newName.c_str(), targetGuid.ToString().c_str());
393  }
394  else
395  {
396  if (target)
397  {
398  // check online security
399  if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
400  return false;
401 
402  handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str());
403  target->SetAtLoginFlag(AT_LOGIN_RENAME);
404  }
405  else
406  {
407  // check offline security
408  if (handler->HasLowerSecurity(NULL, targetGuid))
409  return false;
410 
411  std::string oldNameLink = handler->playerLink(targetName);
412  handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), targetGuid.ToString().c_str());
413 
415  stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
416  stmt->setUInt64(1, targetGuid.GetCounter());
418  }
419  }
420 
421  return true;
422  }
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
Definition: Language.h:198
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:282
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: CharacterDatabase.h:429
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
#define sLog
Definition: Log.h:154
Definition: SharedDefines.h:4505
#define sWorld
Definition: World.h:887
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:77
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
virtual std::string GetNameLink() const
Definition: Chat.h:101
Definition: CharacterDatabase.h:37
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Language.h:139
static bool GetPlayerNameByGUID(ObjectGuid const &guid, std::string &name)
Definition: ObjectMgr.cpp:2258
Definition: CharacterDatabase.h:155
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Language.h:283
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Player session in the World.
Definition: WorldSession.h:882
Definition: ObjectGuid.h:189
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:121
std::string ToString() const
Definition: ObjectGuid.cpp:99
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:120
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterReputationCommand ( ChatHandler handler,
char const args 
)
inlinestatic
550  {
551  Player* target;
552  if (!handler->extractPlayerTarget((char*)args, &target))
553  return false;
554 
555  LocaleConstant loc = handler->GetSessionDbcLocale();
556 
557  FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
558  for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
559  {
560  FactionState const& faction = itr->second;
561  FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
562  char const* factionName = factionEntry ? factionEntry->Name_lang : "#Not found#";
563  ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
564  std::string rankName = handler->GetTrinityString(ReputationRankStrIndex[rank]);
565  std::ostringstream ss;
566  if (handler->GetSession())
567  ss << faction.ID << " - |cffffffff|Hfaction:" << faction.ID << "|h[" << factionName << ' ' << localeNames[loc] << "]|h|r";
568  else
569  ss << faction.ID << " - " << factionName << ' ' << localeNames[loc];
570 
571  ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
572 
573  if (faction.Flags & FACTION_FLAG_VISIBLE)
574  ss << handler->GetTrinityString(LANG_FACTION_VISIBLE);
575  if (faction.Flags & FACTION_FLAG_AT_WAR)
576  ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
577  if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
579  if (faction.Flags & FACTION_FLAG_HIDDEN)
580  ss << handler->GetTrinityString(LANG_FACTION_HIDDEN);
581  if (faction.Flags & FACTION_FLAG_INVISIBLE_FORCED)
583  if (faction.Flags & FACTION_FLAG_INACTIVE)
584  ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
585 
586  handler->SendSysMessage(ss.str().c_str());
587  }
588 
589  return true;
590  }
Definition: ReputationMgr.h:41
ReputationRank
Definition: SharedDefines.h:211
Definition: ReputationMgr.h:43
uint32 ID
Definition: ReputationMgr.h:51
Definition: Language.h:345
Definition: ReputationMgr.h:39
Definition: Language.h:340
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
Definition: ReputationMgr.h:42
Definition: Language.h:341
LocaleConstant
Definition: Common.h:115
Definition: ReputationMgr.h:40
char * Name_lang
Definition: DBCStructure.h:418
Definition: Language.h:344
static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK]
Definition: ReputationMgr.h:29
Definition: DBCStructure.h:405
TC_COMMON_API char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:21
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
uint8 Flags
Definition: ReputationMgr.h:54
WorldSession * GetSession()
Definition: Chat.h:59
Definition: ReputationMgr.h:38
std::map< RepListID, FactionState > FactionStateList
Definition: ReputationMgr.h:59
Definition: Language.h:343
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: ReputationMgr.h:49
Definition: Language.h:342

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleCharacterTitlesCommand ( ChatHandler handler,
char const args 
)
inlinestatic
254  {
255  if (!*args)
256  return false;
257 
258  Player* target;
259  if (!handler->extractPlayerTarget((char*)args, &target))
260  return false;
261 
262  LocaleConstant loc = handler->GetSessionDbcLocale();
263  char const* targetName = target->GetName().c_str();
264  char const* knownStr = handler->GetTrinityString(LANG_KNOWN);
265 
266  // Search in CharTitles.dbc
267  for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
268  {
269  CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
270 
271  if (titleInfo && target->HasTitle(titleInfo))
272  {
273  std::string name = target->getGender() == GENDER_MALE ? titleInfo->NameMale_lang : titleInfo->NameFemale_lang;
274  if (name.empty())
275  continue;
276 
277  char const* activeStr = target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->MaskID
278  ? handler->GetTrinityString(LANG_ACTIVE)
279  : "";
280 
281  char titleNameStr[80];
282  snprintf(titleNameStr, 80, name.c_str(), targetName);
283 
284  // send title in "id (idx:idx) - [namedlink locale]" format
285  if (handler->GetSession())
286  handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr, localeNames[loc], knownStr, activeStr);
287  else
288  handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, name.c_str(), localeNames[loc], knownStr, activeStr);
289  }
290  }
291 
292  return true;
293  }
Definition: Language.h:377
Definition: DBCStructure.h:162
#define snprintf
Definition: Common.h:76
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint32 MaskID
Definition: DBCStructure.h:168
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesfmt)
Definition: Language.h:378
Definition: SharedDefines.h:93
LocaleConstant
Definition: Common.h:115
uint32_t uint32
Definition: Define.h:150
char * NameMale_lang
Definition: DBCStructure.h:166
TC_COMMON_API char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:21
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
char * NameFemale_lang
Definition: DBCStructure.h:167
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:1062
Definition: UpdateFields.h:203
Definition: Language.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandleLevelUpCommand ( ChatHandler handler,
char const args 
)
inlinestatic
801  {
802  char* nameStr;
803  char* levelStr;
804  handler->extractOptFirstArg((char*)args, &nameStr, &levelStr);
805 
806  // exception opt second arg: .character level $name
807  if (levelStr && isalpha(levelStr[0]))
808  {
809  nameStr = levelStr;
810  levelStr = NULL; // current level will used
811  }
812 
813  Player* target;
814  ObjectGuid targetGuid;
815  std::string targetName;
816  if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
817  return false;
818 
819  int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(targetGuid);
820  int32 addlevel = levelStr ? atoi(levelStr) : 1;
821  int32 newlevel = oldlevel + addlevel;
822 
823  if (newlevel < 1)
824  newlevel = 1;
825 
826  if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
827  newlevel = STRONG_MAX_LEVEL;
828 
829  HandleCharacterLevel(target, targetGuid, oldlevel, newlevel, handler);
830 
831  if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including chr == NULL
832  {
833  std::string nameLink = handler->playerLink(targetName);
834  handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel);
835  }
836 
837  return true;
838  }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: DBCEnums.h:54
Player * GetPlayer() const
Definition: WorldSession.h:927
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
int32_t int32
Definition: Define.h:146
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
static void HandleCharacterLevel(Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
Definition: cs_character.cpp:225
void extractOptFirstArg(char *args, char **arg1, char **arg2)
Definition: Chat.cpp:998
Definition: ObjectGuid.h:189
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
Definition: Language.h:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandlePDumpLoadCommand ( ChatHandler handler,
char const args 
)
inlinestatic
841  {
842  if (!*args)
843  return false;
844 
845  char* fileStr = strtok((char*)args, " ");
846  if (!fileStr)
847  return false;
848 
849  char* accountStr = strtok(NULL, " ");
850  if (!accountStr)
851  return false;
852 
853  std::string accountName = accountStr;
854  if (!Utf8ToUpperOnlyLatin(accountName))
855  {
856  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
857  handler->SetSentErrorMessage(true);
858  return false;
859  }
860 
861  uint32 accountId = AccountMgr::GetId(accountName);
862  if (!accountId)
863  {
864  accountId = atoi(accountStr); // use original string
865  if (!accountId)
866  {
867  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
868  handler->SetSentErrorMessage(true);
869  return false;
870  }
871  }
872 
873  if (!AccountMgr::GetName(accountId, accountName))
874  {
875  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
876  handler->SetSentErrorMessage(true);
877  return false;
878  }
879 
880  char* guidStr = NULL;
881  char* nameStr = strtok(NULL, " ");
882 
883  std::string name;
884  if (nameStr)
885  {
886  name = nameStr;
887  // normalize the name if specified and check if it exists
888  if (!normalizePlayerName(name))
889  {
891  handler->SetSentErrorMessage(true);
892  return false;
893  }
894 
895  if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS)
896  {
898  handler->SetSentErrorMessage(true);
899  return false;
900  }
901 
902  guidStr = strtok(NULL, " ");
903  }
904 
905  ObjectGuid::LowType guid = UI64LIT(0);
906 
907  if (guidStr)
908  {
909  guid = strtoull(guidStr, nullptr, 10);
910  if (!guid)
911  {
913  handler->SetSentErrorMessage(true);
914  return false;
915  }
916 
917  if (ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid::Create<HighGuid::Player>(guid)))
918  {
920  handler->SetSentErrorMessage(true);
921  return false;
922  }
923  }
924 
925  switch (PlayerDumpReader().LoadDump(fileStr, accountId, name, guid))
926  {
927  case DUMP_SUCCESS:
929  break;
931  handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileStr);
932  handler->SetSentErrorMessage(true);
933  return false;
934  case DUMP_FILE_BROKEN:
935  handler->PSendSysMessage(LANG_DUMP_BROKEN, fileStr);
936  handler->SetSentErrorMessage(true);
937  return false;
938  case DUMP_TOO_MANY_CHARS:
939  handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, accountName.c_str(), accountId);
940  handler->SetSentErrorMessage(true);
941  return false;
942  default:
944  handler->SetSentErrorMessage(true);
945  return false;
946  }
947 
948  return true;
949  }
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:917
Definition: Language.h:918
Definition: PlayerDump.h:97
Definition: Language.h:920
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:486
Definition: Language.h:919
Definition: SharedDefines.h:4505
#define sWorld
Definition: World.h:887
Definition: PlayerDump.h:61
uint64 LowType
Definition: ObjectGuid.h:199
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:303
Definition: PlayerDump.h:60
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: Language.h:916
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
Definition: PlayerDump.h:64
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:915
Definition: Language.h:485
Definition: PlayerDump.h:62
Definition: Language.h:412
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool character_commandscript::HandlePDumpWriteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
952  {
953  if (!*args)
954  return false;
955 
956  char* fileStr = strtok((char*)args, " ");
957  char* playerStr = strtok(NULL, " ");
958 
959  if (!fileStr || !playerStr)
960  return false;
961 
962  ObjectGuid guid;
963  // character name can't start from number
964  if (isNumeric(playerStr))
965  guid = ObjectGuid::Create<HighGuid::Player>(strtoull(playerStr, nullptr, 10));
966  else
967  {
968  std::string name = handler->extractPlayerNameFromLink(playerStr);
969  if (name.empty())
970  {
972  handler->SetSentErrorMessage(true);
973  return false;
974  }
975 
976  guid = ObjectMgr::GetPlayerGUIDByName(name);
977  }
978 
980  {
982  handler->SetSentErrorMessage(true);
983  return false;
984  }
985 
986  switch (PlayerDumpWriter().WriteDump(fileStr, guid.GetCounter()))
987  {
988  case DUMP_SUCCESS:
990  break;
992  handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileStr);
993  handler->SetSentErrorMessage(true);
994  return false;
997  handler->SetSentErrorMessage(true);
998  return false;
999  default:
1001  handler->SetSentErrorMessage(true);
1002  return false;
1003  }
1004 
1005  return true;
1006  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:488
Definition: PlayerDump.h:78
std::string extractPlayerNameFromLink(char *text)
Definition: Chat.cpp:931
Definition: PlayerDump.h:61
Definition: PlayerDump.h:60
Definition: Language.h:933
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
Definition: Language.h:915
bool isNumeric(wchar_t wchar)
Definition: Util.h:194
Definition: Language.h:487
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:509
Definition: PlayerDump.h:65
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: