Core/Commands: Fix some codestyle for a312cd4ba1

This commit is contained in:
Vincent-Michael committed 2012-06-21 18:49:26 +02:00
1 parent c22988e14f
commit 3368e888a1
2 files changed
+252 -240

No files matched your search

+74 -76
View File
@@ -48,7 +48,7 @@ public:
{ "customize", SEC_GAMEMASTER, true, &HandleCharacterCustomizeCommand, "", NULL },
{ "changefaction", SEC_GAMEMASTER, true, &HandleCharacterChangeFactionCommand, "", NULL },
{ "changerace", SEC_GAMEMASTER, true, &HandleCharacterChangeRaceCommand, "", NULL },
{ "deleted", SEC_GAMEMASTER, true, NULL, "", characterDeletedCommandTable},
{ "deleted", SEC_GAMEMASTER, true, NULL, "", characterDeletedCommandTable},
{ "erase", SEC_CONSOLE, true, &HandleCharacterEraseCommand, "", NULL },
{ "level", SEC_ADMINISTRATOR, true, &HandleCharacterLevelCommand, "", NULL },
{ "rename", SEC_GAMEMASTER, true, &HandleCharacterRenameCommand, "", NULL },
@@ -59,17 +59,16 @@ public:
static ChatCommand commandTable[] =
{
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
{ NULL, 0, false, NULL, "", NULL }
};
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
// Stores informations about a deleted character
struct DeletedInfo
{
uint32 lowguid; ///< the low GUID from the character
uint32 lowGuid; ///< the low GUID from the character
std::string name; ///< the character name
uint32 accountId; ///< the account id
std::string accountName; ///< the account name
@@ -95,9 +94,7 @@ public:
if (isNumeric(searchString.c_str()))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
stmt->setUInt32(0, uint32(atoi(searchString.c_str())));
result = CharacterDatabase.Query(stmt);
}
// search by name
@@ -105,42 +102,38 @@ public:
{
if (!normalizePlayerName(searchString))
return false;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
stmt->setString(0, searchString);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
stmt->setString(0, searchString);
result = CharacterDatabase.Query(stmt);
}
}
else
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO);
result = CharacterDatabase.Query(stmt);
}
if (result)
{
do
{
Field* fields = result->Fetch();
DeletedInfo info;
info.lowguid = fields[0].GetUInt32();
info.lowGuid = fields[0].GetUInt32();
info.name = fields[1].GetString();
info.accountId = fields[2].GetUInt32();
// account name will be empty for not existed account
AccountMgr::GetName(info.accountId, info.accountName);
info.deleteDate = time_t(fields[3].GetUInt32());
info.deleteDate = time_t(fields[3].GetUInt32());
foundList.push_back(info);
} while (result->NextRow());
}
while (result->NextRow());
}
return true;
}
@@ -162,21 +155,21 @@ public:
handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_HEADER);
handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR);
}
for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
{
std::string dateStr = TimeToTimestampStr(itr->deleteDate);
if (!handler->GetSession())
handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE,
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
else
handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CHAT,
itr->lowguid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "<Not existed>" : itr->accountName.c_str(),
itr->accountId, dateStr.c_str());
}
if (!handler->GetSession())
handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR);
}
@@ -195,36 +188,34 @@ public:
{
if (delInfo.accountName.empty()) // account not exist
{
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
return;
}
// check character count
uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
if (charcount >= 10)
{
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
return;
}
if (sObjectMgr->GetPlayerGUIDByName(delInfo.name))
{
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId);
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
return;
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
stmt->setString(0, delInfo.name);
stmt->setUInt32(1, delInfo.accountId);
stmt->setUInt32(2, delInfo.lowguid);
stmt->setUInt32(2, delInfo.lowGuid);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
stmt->setUInt32(0, delInfo.lowguid);
stmt->setUInt32(0, delInfo.lowGuid);
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
sWorld->AddCharacterNameData(delInfo.lowguid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8());
sWorld->AddCharacterNameData(delInfo.lowGuid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8());
}
static bool HandleCharacterTitlesCommand(ChatHandler* handler, char const* args)
@@ -265,6 +256,7 @@ public:
handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name.c_str(), localeNames[loc], knownStr, activeStr);
}
}
return true;
}
@@ -294,11 +286,13 @@ public:
std::string oldNameLink = handler->playerLink(targetName);
handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
stmt->setUInt32(1, GUID_LOPART(targetGuid));
CharacterDatabase.Execute(stmt);
}
return true;
}
@@ -318,12 +312,12 @@ public:
}
Player* target;
uint64 target_guid;
std::string target_name;
if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
return false;
uint64 targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
return false;
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid);
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(targetGuid);
int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
if (newlevel < 1)
@@ -332,10 +326,10 @@ public:
if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
newlevel = STRONG_MAX_LEVEL;
handler->HandleCharacterLevel(target, target_guid, oldlevel, newlevel);
handler->HandleCharacterLevel(target, targetGuid, oldlevel, newlevel);
if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including player == NULL
{
std::string nameLink = handler->playerLink(target_name);
std::string nameLink = handler->playerLink(targetName);
handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel);
}
@@ -438,7 +432,7 @@ public:
FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
{
const FactionState& faction = itr->second;
FactionState const& faction = itr->second;
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
@@ -463,9 +457,10 @@ public:
ss << handler->GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
if (faction.Flags & FACTION_FLAG_INACTIVE)
ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
handler->SendSysMessage(ss.str().c_str());
}
return true;
}
@@ -493,6 +488,7 @@ public:
}
HandleCharacterDeletedListHelper(foundList, handler);
return true;
}
@@ -593,7 +589,7 @@ public:
// Call the appropriate function to delete them (current account for deleted characters is 0)
for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
Player::DeleteFromDB(itr->lowguid, 0, false, true);
Player::DeleteFromDB(itr->lowGuid, 0, false, true);
return true;
}
@@ -609,17 +605,17 @@ public:
*
* @param args the search string which either contains a player GUID or a part fo the character-name
*/
static bool HandleCharacterDeletedOldCommand(ChatHandler* handler, char const* args)
static bool HandleCharacterDeletedOldCommand(ChatHandler* /*handler*/, char const* args)
{
int32 keepDays = sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS);
char* px = strtok((char*)args, " ");
if (px)
char* daysStr = strtok((char*)args, " ");
if (daysStr)
{
if (!isNumeric(px))
if (!isNumeric(daysStr))
return false;
keepDays = atoi(px);
keepDays = atoi(daysStr);
if (keepDays < 0)
return false;
}
@@ -627,7 +623,8 @@ public:
else if (keepDays <= 0)
return false;
Player::DeleteOldCharacters((uint32)keepDays);
Player::DeleteOldCharacters(uint32(keepDays));
return true;
}
@@ -636,41 +633,42 @@ public:
if (!*args)
return false;
char *character_name_str = strtok((char*)args, " ");
if (!character_name_str)
char* characterName_str = strtok((char*)args, " ");
if (!characterName_str)
return false;
std::string character_name = character_name_str;
if (!normalizePlayerName(character_name))
std::string characterName = characterName_str;
if (!normalizePlayerName(characterName))
return false;
uint64 character_guid;
uint32 account_id;
uint64 characterGuid;
uint32 accountId;
Player* player = sObjectAccessor->FindPlayerByName(character_name.c_str());
Player* player = sObjectAccessor->FindPlayerByName(characterName.c_str());
if (player)
{
character_guid = player->GetGUID();
account_id = player->GetSession()->GetAccountId();
characterGuid = player->GetGUID();
accountId = player->GetSession()->GetAccountId();
player->GetSession()->KickPlayer();
}
else
{
character_guid = sObjectMgr->GetPlayerGUIDByName(character_name);
if (!character_guid)
characterGuid = sObjectMgr->GetPlayerGUIDByName(characterName);
if (!characterGuid)
{
handler->PSendSysMessage(LANG_NO_PLAYER, character_name.c_str());
handler->PSendSysMessage(LANG_NO_PLAYER, characterName.c_str());
handler->SetSentErrorMessage(true);
return false;
}
account_id = sObjectMgr->GetPlayerAccountIdByGUID(character_guid);
accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid);
}
std::string account_name;
AccountMgr::GetName (account_id, account_name);
std::string accountName;
AccountMgr::GetName(accountId, accountName);
Player::DeleteFromDB(characterGuid, accountId, true, true);
handler->PSendSysMessage(LANG_CHARACTER_DELETED, characterName.c_str(), GUID_LOPART(characterGuid), accountName.c_str(), accountId);
Player::DeleteFromDB(character_guid, account_id, true, true);
handler->PSendSysMessage(LANG_CHARACTER_DELETED, character_name.c_str(), GUID_LOPART(character_guid), account_name.c_str(), account_id);
return true;
}
};
@@ -678,4 +676,4 @@ public:
void AddSC_character_commandscript()
{
new character_commandscript();
}
}