Core/Commands: Fix some codestyle for a312cd4ba1
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,83 +37,83 @@ public:
|
||||
{
|
||||
static ChatCommand serverIdleRestartCommandTable[] =
|
||||
{
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerIdleRestartCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerIdleRestartCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand serverIdleShutdownCommandTable[] =
|
||||
{
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerIdleShutDownCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerIdleShutDownCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand serverRestartCommandTable[] =
|
||||
{
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerRestartCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerRestartCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand serverShutdownCommandTable[] =
|
||||
{
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerShutDownCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{
|
||||
{ "cancel", SEC_ADMINISTRATOR, true, &HandleServerShutDownCancelCommand, "", NULL },
|
||||
{ "" , SEC_ADMINISTRATOR, true, &HandleServerShutDownCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand serverSetCommandTable[] =
|
||||
{
|
||||
{ "difftime", SEC_CONSOLE, true, &HandleServerSetDiffTimeCommand, "", NULL },
|
||||
{ "loglevel", SEC_CONSOLE, true, &HandleServerSetLogLevelCommand, "", NULL },
|
||||
{ "logfilelevel", SEC_CONSOLE, true, &HandleServerSetLogFileLevelCommand, "", NULL },
|
||||
{ "motd", SEC_ADMINISTRATOR, true, &HandleServerSetMotdCommand, "", NULL },
|
||||
{ "closed", SEC_ADMINISTRATOR, true, &HandleServerSetClosedCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "difftime", SEC_CONSOLE, true, &HandleServerSetDiffTimeCommand, "", NULL },
|
||||
{ "loglevel", SEC_CONSOLE, true, &HandleServerSetLogLevelCommand, "", NULL },
|
||||
{ "logfilelevel", SEC_CONSOLE, true, &HandleServerSetLogFileLevelCommand, "", NULL },
|
||||
{ "motd", SEC_ADMINISTRATOR, true, &HandleServerSetMotdCommand, "", NULL },
|
||||
{ "closed", SEC_ADMINISTRATOR, true, &HandleServerSetClosedCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand serverCommandTable[] =
|
||||
{
|
||||
{ "corpses", SEC_GAMEMASTER, true, &HandleServerCorpsesCommand, "", NULL },
|
||||
{ "exit", SEC_CONSOLE, true, &HandleServerExitCommand, "", NULL },
|
||||
{ "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable },
|
||||
{ "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverIdleShutdownCommandTable },
|
||||
{ "info", SEC_PLAYER, true, &HandleServerInfoCommand, "", NULL },
|
||||
{ "motd", SEC_PLAYER, true, &HandleServerMotdCommand, "", NULL },
|
||||
{ "plimit", SEC_ADMINISTRATOR, true, &HandleServerPLimitCommand, "", NULL },
|
||||
{ "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable },
|
||||
{ "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable },
|
||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable },
|
||||
{ "togglequerylog", SEC_CONSOLE, true, &HandleServerToggleQueryLogging, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "corpses", SEC_GAMEMASTER, true, &HandleServerCorpsesCommand, "", NULL },
|
||||
{ "exit", SEC_CONSOLE, true, &HandleServerExitCommand, "", NULL },
|
||||
{ "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable },
|
||||
{ "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverIdleShutdownCommandTable },
|
||||
{ "info", SEC_PLAYER, true, &HandleServerInfoCommand, "", NULL },
|
||||
{ "motd", SEC_PLAYER, true, &HandleServerMotdCommand, "", NULL },
|
||||
{ "plimit", SEC_ADMINISTRATOR, true, &HandleServerPLimitCommand, "", NULL },
|
||||
{ "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable },
|
||||
{ "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable },
|
||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable },
|
||||
{ "togglequerylog", SEC_CONSOLE, true, &HandleServerToggleQueryLogging, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
// Triggering corpses expire check in world
|
||||
static bool HandleServerCorpsesCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerCorpsesCommand(ChatHandler* /*handler*/, char const* /*args*/)
|
||||
{
|
||||
sObjectAccessor->RemoveOldCorpses();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerInfoCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerInfoCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
uint32 playersNum = sWorld->GetPlayerCount();
|
||||
uint32 maxPlayersNum = sWorld->GetMaxPlayerCount();
|
||||
uint32 activeClientsNum = sWorld->GetActiveSessionCount();
|
||||
uint32 queuedClientsNum = sWorld->GetQueuedSessionCount();
|
||||
uint32 maxActiveClientsNum = sWorld->GetMaxActiveSessionCount();
|
||||
uint32 maxQueuedClientsNum = sWorld->GetMaxQueuedSessionCount();
|
||||
std::string uptime = secsToTimeString(sWorld->GetUptime());
|
||||
uint32 updateTime = sWorld->GetUpdateTime();
|
||||
uint32 playersNum = sWorld->GetPlayerCount();
|
||||
uint32 maxPlayersNum = sWorld->GetMaxPlayerCount();
|
||||
uint32 activeClientsNum = sWorld->GetActiveSessionCount();
|
||||
uint32 queuedClientsNum = sWorld->GetQueuedSessionCount();
|
||||
uint32 maxActiveClientsNum = sWorld->GetMaxActiveSessionCount();
|
||||
uint32 maxQueuedClientsNum = sWorld->GetMaxQueuedSessionCount();
|
||||
std::string uptime = secsToTimeString(sWorld->GetUptime());
|
||||
uint32 updateTime = sWorld->GetUpdateTime();
|
||||
|
||||
handler->SendSysMessage(_FULLVERSION);
|
||||
handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
// Display the 'Message of the day' for the realm
|
||||
static bool HandleServerMotdCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerMotdCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_MOTD_CURRENT, sWorld->GetMotd());
|
||||
return true;
|
||||
@@ -137,199 +137,212 @@ public:
|
||||
{
|
||||
if (*args)
|
||||
{
|
||||
char* param = strtok((char*)args, " ");
|
||||
if (!param)
|
||||
char* paramStr = strtok((char*)args, " ");
|
||||
if (!paramStr)
|
||||
return false;
|
||||
|
||||
int l = strlen(param);
|
||||
int32 limit = strlen(paramStr);
|
||||
|
||||
if (strncmp(param, "player", l) == 0)
|
||||
if (strncmp(paramStr, "player", limit) == 0)
|
||||
sWorld->SetPlayerSecurityLimit(SEC_PLAYER);
|
||||
else if (strncmp(param, "moderator", l) == 0)
|
||||
else if (strncmp(paramStr, "moderator", limit) == 0)
|
||||
sWorld->SetPlayerSecurityLimit(SEC_MODERATOR);
|
||||
else if (strncmp(param, "gamemaster", l) == 0)
|
||||
else if (strncmp(paramStr, "gamemaster", limit) == 0)
|
||||
sWorld->SetPlayerSecurityLimit(SEC_GAMEMASTER);
|
||||
else if (strncmp(param, "administrator", l) == 0)
|
||||
else if (strncmp(paramStr, "administrator", limit) == 0)
|
||||
sWorld->SetPlayerSecurityLimit(SEC_ADMINISTRATOR);
|
||||
else if (strncmp(param, "reset", l) == 0)
|
||||
else if (strncmp(paramStr, "reset", limit) == 0)
|
||||
{
|
||||
sWorld->SetPlayerAmountLimit(ConfigMgr::GetIntDefault("PlayerLimit", 100));
|
||||
sWorld->LoadDBAllowedSecurityLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
int val = atoi(param);
|
||||
if (val < 0)
|
||||
sWorld->SetPlayerSecurityLimit(AccountTypes(uint32(-val)));
|
||||
int32 value = atoi(paramStr);
|
||||
if (value < 0)
|
||||
sWorld->SetPlayerSecurityLimit(AccountTypes(-value));
|
||||
else
|
||||
sWorld->SetPlayerAmountLimit(uint32(val));
|
||||
}
|
||||
sWorld->SetPlayerAmountLimit(uint32(value));
|
||||
}
|
||||
}
|
||||
|
||||
uint32 pLimit = sWorld->GetPlayerAmountLimit();
|
||||
uint32 playerAmountLimit = sWorld->GetPlayerAmountLimit();
|
||||
AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
|
||||
char const* secName = "";
|
||||
switch (allowedAccountType)
|
||||
{
|
||||
case SEC_PLAYER: secName = "Player"; break;
|
||||
case SEC_MODERATOR: secName = "Moderator"; break;
|
||||
case SEC_GAMEMASTER: secName = "Gamemaster"; break;
|
||||
case SEC_ADMINISTRATOR: secName = "Administrator"; break;
|
||||
default: secName = "<unknown>"; break;
|
||||
case SEC_PLAYER:
|
||||
secName = "Player";
|
||||
break;
|
||||
case SEC_MODERATOR:
|
||||
secName = "Moderator";
|
||||
break;
|
||||
case SEC_GAMEMASTER:
|
||||
secName = "Gamemaster";
|
||||
break;
|
||||
case SEC_ADMINISTRATOR:
|
||||
secName = "Administrator";
|
||||
break;
|
||||
default:
|
||||
secName = "<unknown>";
|
||||
break;
|
||||
}
|
||||
handler->PSendSysMessage("Player limits: amount %u, min. security level %s.", pLimit, secName);
|
||||
handler->PSendSysMessage("Player limits: amount %u, min. security level %s.", playerAmountLimit, secName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerShutDownCancelCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerShutDownCancelCommand(ChatHandler* /*handler*/, char const* /*args*/)
|
||||
{
|
||||
sWorld->ShutdownCancel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerShutDownCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerShutDownCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
char* time_str = strtok ((char*) args, " ");
|
||||
char* exitcode_str = strtok (NULL, "");
|
||||
char* timeStr = strtok((char*) args, " ");
|
||||
char* exitCodeStr = strtok(NULL, "");
|
||||
|
||||
int32 time = atoi (time_str);
|
||||
int32 time = atoi(timeStr);
|
||||
|
||||
// Prevent interpret wrong arg value as 0 secs shutdown time
|
||||
if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
|
||||
return false;
|
||||
if ((time == 0 && (timeStr[0] != '0' || timeStr[1] != '\0')) || time < 0)
|
||||
return false;
|
||||
|
||||
if (exitcode_str)
|
||||
if (exitCodeStr)
|
||||
{
|
||||
int32 exitcode = atoi(exitcode_str);
|
||||
int32 exitCode = atoi(exitCodeStr);
|
||||
|
||||
// Handle atoi() errors
|
||||
if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
|
||||
return false;
|
||||
// Handle atoi() errors
|
||||
if (exitCode == 0 && (exitCodeStr[0] != '0' || exitCodeStr[1] != '\0'))
|
||||
return false;
|
||||
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitcode < 0 || exitcode > 125)
|
||||
return false;
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitCode < 0 || exitCode > 125)
|
||||
return false;
|
||||
|
||||
sWorld->ShutdownServ(time, 0, exitcode);
|
||||
sWorld->ShutdownServ(time, 0, exitCode);
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, 0, SHUTDOWN_EXIT_CODE);
|
||||
sWorld->ShutdownServ(time, 0, SHUTDOWN_EXIT_CODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerRestartCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerRestartCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* time_str = strtok ((char*) args, " ");
|
||||
char* exitcode_str = strtok (NULL, "");
|
||||
char* timeStr = strtok((char*) args, " ");
|
||||
char* exitCodeStr = strtok(NULL, "");
|
||||
|
||||
int32 time = atoi (time_str);
|
||||
int32 time = atoi(timeStr);
|
||||
|
||||
// Prevent interpret wrong arg value as 0 secs shutdown time
|
||||
if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
|
||||
if ((time == 0 && (timeStr[0] != '0' || timeStr[1] != '\0')) || time < 0)
|
||||
return false;
|
||||
|
||||
if (exitcode_str)
|
||||
if (exitCodeStr)
|
||||
{
|
||||
int32 exitcode = atoi (exitcode_str);
|
||||
int32 exitCode = atoi(exitCodeStr);
|
||||
|
||||
// Handle atoi() errors
|
||||
if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
|
||||
return false;
|
||||
// Handle atoi() errors
|
||||
if (exitCode == 0 && (exitCodeStr[0] != '0' || exitCodeStr[1] != '\0'))
|
||||
return false;
|
||||
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitcode < 0 || exitcode > 125)
|
||||
return false;
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitCode < 0 || exitCode > 125)
|
||||
return false;
|
||||
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, exitcode);
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, exitCode);
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerIdleRestartCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerIdleRestartCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* time_str = strtok ((char*) args, " ");
|
||||
char* exitcode_str = strtok (NULL, "");
|
||||
char* timeStr = strtok((char*) args, " ");
|
||||
char* exitCodeStr = strtok(NULL, "");
|
||||
|
||||
int32 time = atoi (time_str);
|
||||
int32 time = atoi(timeStr);
|
||||
|
||||
// Prevent interpret wrong arg value as 0 secs shutdown time
|
||||
if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
|
||||
if ((time == 0 && (timeStr[0] != '0' || timeStr[1] != '\0')) || time < 0)
|
||||
return false;
|
||||
|
||||
if (exitcode_str)
|
||||
if (exitCodeStr)
|
||||
{
|
||||
int32 exitcode = atoi (exitcode_str);
|
||||
int32 exitCode = atoi(exitCodeStr);
|
||||
|
||||
// Handle atoi() errors
|
||||
if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
|
||||
return false;
|
||||
// Handle atoi() errors
|
||||
if (exitCode == 0 && (exitCodeStr[0] != '0' || exitCodeStr[1] != '\0'))
|
||||
return false;
|
||||
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitcode < 0 || exitcode > 125)
|
||||
return false;
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitCode < 0 || exitCode > 125)
|
||||
return false;
|
||||
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, exitCode);
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
|
||||
return true;
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerIdleShutDownCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerIdleShutDownCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* time_str = strtok ((char*) args, " ");
|
||||
char* exitcode_str = strtok (NULL, "");
|
||||
char* timeStr = strtok((char*) args, " ");
|
||||
char* exitCodeStr = strtok(NULL, "");
|
||||
|
||||
int32 time = atoi (time_str);
|
||||
int32 time = atoi(timeStr);
|
||||
|
||||
// Prevent interpret wrong arg value as 0 secs shutdown time
|
||||
if ((time == 0 && (time_str[0] != '0' || time_str[1] != '\0')) || time < 0)
|
||||
if ((time == 0 && (timeStr[0] != '0' || timeStr[1] != '\0')) || time < 0)
|
||||
return false;
|
||||
|
||||
if (exitcode_str)
|
||||
if (exitCodeStr)
|
||||
{
|
||||
int32 exitcode = atoi (exitcode_str);
|
||||
int32 exitCode = atoi(exitCodeStr);
|
||||
|
||||
// Handle atoi() errors
|
||||
if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
|
||||
return false;
|
||||
// Handle atoi() errors
|
||||
if (exitCode == 0 && (exitCodeStr[0] != '0' || exitCodeStr[1] != '\0'))
|
||||
return false;
|
||||
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitcode < 0 || exitcode > 125)
|
||||
return false;
|
||||
// Exit code should be in range of 0-125, 126-255 is used
|
||||
// in many shells for their own return codes and code > 255
|
||||
// is not supported in many others
|
||||
if (exitCode < 0 || exitCode > 125)
|
||||
return false;
|
||||
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, exitcode);
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, exitCode);
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Exit the realm
|
||||
static bool HandleServerExitCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerExitCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_EXIT);
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
@@ -349,15 +362,15 @@ public:
|
||||
{
|
||||
if (strncmp(args, "on", 3) == 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_WORLD_CLOSED);
|
||||
sWorld->SetClosed(true);
|
||||
return true;
|
||||
handler->SendSysMessage(LANG_WORLD_CLOSED);
|
||||
sWorld->SetClosed(true);
|
||||
return true;
|
||||
}
|
||||
else if (strncmp(args, "off", 4) == 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_WORLD_OPENED);
|
||||
sWorld->SetClosed(false);
|
||||
return true;
|
||||
handler->SendSysMessage(LANG_WORLD_OPENED);
|
||||
sWorld->SetClosed(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->SendSysMessage(LANG_USE_BOL);
|
||||
@@ -366,61 +379,62 @@ public:
|
||||
}
|
||||
|
||||
// Set the level of logging
|
||||
static bool HandleServerSetLogFileLevelCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerSetLogFileLevelCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *NewLevel = strtok((char*)args, " ");
|
||||
if (!NewLevel)
|
||||
char* newLevel = strtok((char*)args, " ");
|
||||
if (!newLevel)
|
||||
return false;
|
||||
|
||||
sLog->SetLogFileLevel(NewLevel);
|
||||
return true;
|
||||
sLog->SetLogFileLevel(newLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set the level of logging
|
||||
static bool HandleServerSetLogLevelCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerSetLogLevelCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *NewLevel = strtok((char*)args, " ");
|
||||
if (!NewLevel)
|
||||
char* newLevel = strtok((char*)args, " ");
|
||||
if (!newLevel)
|
||||
return false;
|
||||
|
||||
sLog->SetLogLevel(NewLevel);
|
||||
return true;
|
||||
sLog->SetLogLevel(newLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
// set diff time record interval
|
||||
static bool HandleServerSetDiffTimeCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleServerSetDiffTimeCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *NewTimeStr = strtok((char*)args, " ");
|
||||
if (!NewTimeStr)
|
||||
char* newTimeStr = strtok((char*)args, " ");
|
||||
if (!newTimeStr)
|
||||
return false;
|
||||
|
||||
int32 NewTime =atoi(NewTimeStr);
|
||||
if (NewTime < 0)
|
||||
int32 newTime = atoi(newTimeStr);
|
||||
if (newTime < 0)
|
||||
return false;
|
||||
|
||||
sWorld->SetRecordDiffInterval(NewTime);
|
||||
printf( "Record diff every %u ms\n", NewTime);
|
||||
return true;
|
||||
sWorld->SetRecordDiffInterval(newTime);
|
||||
printf("Record diff every %u ms\n", newTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// toggle sql driver query logging
|
||||
static bool HandleServerToggleQueryLogging(ChatHandler* handler,const char* args )
|
||||
static bool HandleServerToggleQueryLogging(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
sLog->SetSQLDriverQueryLogging(!sLog->GetSQLDriverQueryLogging());
|
||||
|
||||
if (sLog->GetSQLDriverQueryLogging())
|
||||
handler->PSendSysMessage(LANG_SQLDRIVER_QUERY_LOGGING_ENABLED);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_SQLDRIVER_QUERY_LOGGING_DISABLED);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -428,4 +442,4 @@ public:
|
||||
void AddSC_server_commandscript()
|
||||
{
|
||||
new server_commandscript();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user