Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Achievements/AchievementMgr.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Entities/Vehicle/Vehicle.cpp src/server/game/Handlers/ItemHandler.cpp src/server/game/Handlers/MailHandler.cpp src/server/game/Server/Protocol/Opcodes.cpp src/server/game/Server/Protocol/Opcodes.h src/server/scripts/Commands/cs_misc.cpp
This commit is contained in:
commit
adb78862da
79 files changed
+3922
-1330
No files matched your search
@@ -12,6 +12,7 @@ set(scripts_STAT_SRCS
|
||||
${scripts_STAT_SRCS}
|
||||
Commands/cs_account.cpp
|
||||
Commands/cs_achievement.cpp
|
||||
Commands/cs_arena.cpp
|
||||
Commands/cs_ban.cpp
|
||||
Commands/cs_bf.cpp
|
||||
Commands/cs_cast.cpp
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ScriptData
|
||||
Name: arena_commandscript
|
||||
%Complete: 100
|
||||
Comment: All arena team related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ObjectMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
class arena_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
arena_commandscript() : CommandScript("arena_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand arenaCommandTable[] =
|
||||
{
|
||||
{ "create", SEC_ADMINISTRATOR, true, &HandleArenaCreateCommand, "", NULL },
|
||||
{ "disband", SEC_ADMINISTRATOR, true, &HandleArenaDisbandCommand, "", NULL },
|
||||
{ "rename", SEC_ADMINISTRATOR, true, &HandleArenaRenameCommand, "", NULL },
|
||||
{ "captain", SEC_ADMINISTRATOR, false, &HandleArenaCaptainCommand, "", NULL },
|
||||
{ "info", SEC_GAMEMASTER, true, &HandleArenaInfoCommand, "", NULL },
|
||||
{ "lookup", SEC_GAMEMASTER, false, &HandleArenaLookupCommand, "", NULL },
|
||||
{ NULL, SEC_GAMEMASTER, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "arena", SEC_GAMEMASTER, false, NULL, "", arenaCommandTable },
|
||||
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleArenaCreateCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* target;
|
||||
if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target))
|
||||
return false;
|
||||
|
||||
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
|
||||
if (!tailStr)
|
||||
return false;
|
||||
|
||||
char* name = handler->extractQuotedArg(tailStr);
|
||||
if (!name)
|
||||
return false;
|
||||
char* typeStr = strtok(NULL, "");
|
||||
if (!typeStr)
|
||||
return false;
|
||||
int8 type = atoi(typeStr);
|
||||
if (sArenaTeamMgr->GetArenaTeamByName(name))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == 2 || type == 3 || type == 5 )
|
||||
{
|
||||
if (Player::GetArenaTeamIdFromDB(target->GetGUID(), type) != 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, target->GetName().c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
ArenaTeam* Arena = new ArenaTeam();
|
||||
|
||||
if (!Arena->Create(target->GetGUID(), type, name, 4293102085, 101, 4293253939, 4, 4284049911))
|
||||
{
|
||||
delete Arena;
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sArenaTeamMgr->AddArenaTeam(Arena);
|
||||
handler->PSendSysMessage(LANG_ARENA_CREATE, Arena->GetName().c_str(), Arena->GetId(), Arena->GetType(), Arena->GetCaptain());
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleArenaDisbandCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 teamId = atoi((char*)args);
|
||||
if (!teamId)
|
||||
return false;
|
||||
|
||||
ArenaTeam* Arena = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
|
||||
if (!Arena)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Arena->IsFighting())
|
||||
{
|
||||
handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
std::string name = Arena->GetName();
|
||||
Arena->Disband();
|
||||
if (handler->GetSession())
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] disbanded arena team type: %u [Id: %u].",
|
||||
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), Arena->GetType(), teamId);
|
||||
else
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: disbanded arena team type: %u [Id: %u].", Arena->GetType(), teamId);
|
||||
delete(Arena);
|
||||
handler->PSendSysMessage(LANG_ARENA_DISBAND, name.c_str(), teamId);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleArenaRenameCommand(ChatHandler* handler, char const* _args)
|
||||
{
|
||||
if (!*_args)
|
||||
return false;
|
||||
|
||||
char* args = (char *)_args;
|
||||
|
||||
char const* oldArenaStr = handler->extractQuotedArg(args);
|
||||
if (!oldArenaStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char const* newArenaStr = handler->extractQuotedArg(strtok(NULL, ""));
|
||||
if (!newArenaStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
ArenaTeam* Arena = sArenaTeamMgr->GetArenaTeamByName(oldArenaStr);
|
||||
if (!Arena)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_AREAN_ERROR_NAME_NOT_FOUND, oldArenaStr);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sArenaTeamMgr->GetArenaTeamByName(newArenaStr))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, oldArenaStr);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Arena->IsFighting())
|
||||
{
|
||||
handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arena->SetName(newArenaStr))
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
handler->PSendSysMessage(LANG_ARENA_RENAME, Arena->GetId(), oldArenaStr, newArenaStr);
|
||||
if (handler->GetSession())
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] rename arena team \"%s\"[Id: %u] to \"%s\"",
|
||||
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), oldArenaStr, Arena->GetId(), newArenaStr);
|
||||
else
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: rename arena team \"%s\"[Id: %u] to \"%s\"", oldArenaStr, Arena->GetId(), newArenaStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleArenaCaptainCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* idStr;
|
||||
char* nameStr;
|
||||
handler->extractOptFirstArg((char*)args, &idStr, &nameStr);
|
||||
if (!idStr)
|
||||
return false;
|
||||
|
||||
uint32 teamId = atoi(idStr);
|
||||
if (!teamId)
|
||||
return false;
|
||||
|
||||
Player* target;
|
||||
uint64 targetGuid;
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid))
|
||||
return false;
|
||||
|
||||
ArenaTeam* Arena = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
|
||||
if (!Arena)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!target)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, nameStr);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Arena->IsFighting())
|
||||
{
|
||||
handler->SendSysMessage(LANG_ARENA_ERROR_COMBAT);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arena->IsMember(targetGuid))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_MEMBER, nameStr, Arena->GetName().c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Arena->GetCaptain() == targetGuid)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_CAPTAIN, nameStr, Arena->GetName().c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* oldCaptain = sObjectMgr->GetPlayerByLowGUID(Arena->GetCaptain());
|
||||
Arena->SetCaptain(targetGuid);
|
||||
handler->PSendSysMessage(LANG_ARENA_CAPTAIN, Arena->GetName().c_str(), Arena->GetId(), oldCaptain->GetName().c_str(), target->GetName().c_str());
|
||||
if (handler->GetSession())
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
|
||||
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(), target->GetName().c_str(), target->GetGUIDLow(), Arena->GetName().c_str(), Arena->GetId());
|
||||
else
|
||||
TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Console: promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
|
||||
target->GetName().c_str(), target->GetGUIDLow(), Arena->GetName().c_str(), Arena->GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleArenaInfoCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 teamId = atoi((char*)args);
|
||||
if (!teamId)
|
||||
return false;
|
||||
|
||||
ArenaTeam* Arena = sArenaTeamMgr->GetArenaTeamById(teamId);
|
||||
|
||||
if (!Arena)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_FOUND, teamId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, Arena->GetName().c_str(), Arena->GetId(), Arena->GetRating(), Arena->GetType(), Arena->GetType());
|
||||
for (ArenaTeam::MemberList::iterator itr = Arena->m_membersBegin(); itr != Arena->m_membersEnd(); ++itr)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr->Name.c_str(), GUID_LOPART(itr->Guid), itr->PersonalRating, (Arena->GetCaptain() == itr->Guid ? "- Captain" : ""));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleArenaLookupCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
wstrToLower(wnamepart);
|
||||
|
||||
bool found = false;
|
||||
ArenaTeamMgr::ArenaTeamContainer::const_iterator i = sArenaTeamMgr->GetArenaTeamMapBegin();
|
||||
for (; i != sArenaTeamMgr->GetArenaTeamMapEnd(); ++i)
|
||||
{
|
||||
ArenaTeam* Arena = i->second;
|
||||
|
||||
if (Utf8FitTo(Arena->GetName(), wnamepart))
|
||||
{
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_ARENA_LOOKUP, Arena->GetName().c_str(), Arena->GetId(), Arena->GetType(), Arena->GetType());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
handler->PSendSysMessage(LANG_AREAN_ERROR_NAME_NOT_FOUND, namepart.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_arena_commandscript()
|
||||
{
|
||||
new arena_commandscript();
|
||||
}
|
||||
@@ -1472,37 +1472,124 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
// show info of player
|
||||
|
||||
/**
|
||||
* @name Player command: .pinfo
|
||||
* @date 05/19/2013
|
||||
*
|
||||
* @brief Prints information about a character and it's linked account to the commander
|
||||
*
|
||||
* Non-applying information, e.g. a character that is not in gm mode right now or
|
||||
* that is not banned/muted, is not printed
|
||||
*
|
||||
* This can be done either by giving a name or by targeting someone, else, it'll use the commander
|
||||
*
|
||||
* @param args name Prints information according to the given name to the commander
|
||||
* target Prints information on the target to the commander
|
||||
* none No given args results in printing information on the commander
|
||||
*
|
||||
* @return Several pieces of information about the character and the account
|
||||
**/
|
||||
|
||||
static bool HandlePInfoCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
// Define ALL the player variables!
|
||||
Player* target;
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
|
||||
// To make sure we get a target, we convert our guid to an omniversal...
|
||||
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
|
||||
|
||||
// ... and make sure we get a target, somehow.
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
|
||||
{
|
||||
target = sObjectMgr->GetPlayerByLowGUID(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
}
|
||||
// if not, then return false. Which shouldn't happen, now should it ?
|
||||
else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
uint32 accId = 0;
|
||||
uint32 money = 0;
|
||||
uint32 totalPlayerTime = 0;
|
||||
uint8 level = 0;
|
||||
uint32 latency = 0;
|
||||
uint8 race;
|
||||
uint8 Class;
|
||||
int64 muteTime = 0;
|
||||
int64 banTime = -1;
|
||||
/* The variables we extract for the command. They are
|
||||
* default as "does not exist" to prevent problems
|
||||
* The output is printed in the follow manner:
|
||||
*
|
||||
* Player %s %s (guid: %u) - I. LANG_PINFO_PLAYER
|
||||
* ** GM Mode active, Phase: -1 - II. LANG_PINFO_GM_ACTIVE (if GM)
|
||||
* ** Banned: (Type, Reason, Time, By) - III. LANG_PINFO_BANNED (if banned)
|
||||
* ** Muted: (Time, Reason, By) - IV. LANG_PINFO_MUTED (if muted)
|
||||
* * Account: %s (id: %u), GM Level: %u - V. LANG_PINFO_ACC_ACCOUNT
|
||||
* * Last Login: %u (Failed Logins: %u) - VI. LANG_PINFO_ACC_LASTLOGIN
|
||||
* * Uses OS: %s - Latency: %u ms - Email %s - VII. LANG_PINFO_ACC_OS
|
||||
* * Last IP: %u (Locked: %s) - VIII. LANG_PINFO_ACC_IP
|
||||
* * Level: %u (%u/%u XP (%u XP left) - IX. LANG_PINFO_CHR_LEVEL
|
||||
* * Race: %s %s, Class %s - X. LANG_PINFO_CHR_RACE
|
||||
* * Alive ?: %s - XI. LANG_PINFO_CHR_ALIVE
|
||||
* * Phase: %s - XII. LANG_PINFO_CHR_PHASE (if not GM)
|
||||
* * Money: %ug%us%uc - XIII. LANG_PINFO_CHR_MONEY
|
||||
* * Map: %s, Area: %s - XIV. LANG_PINFO_CHR_MAP
|
||||
* * Guild: %s (Id: %u) - XV. LANG_PINFO_CHR_GUILD (if in guild)
|
||||
* ** Rank: %s - XVI. LANG_PINFO_CHR_GUILD_RANK (if in guild)
|
||||
* ** Note: %s - XVII. LANG_PINFO_CHR_GUILD_NOTE (if in guild and has note)
|
||||
* ** O. Note: %s - XVIII.LANG_PINFO_CHR_GUILD_ONOTE (if in guild and has officer note)
|
||||
* * Played time: %s - XIX. LANG_PINFO_CHR_PLAYEDTIME
|
||||
* * Mails: %u Read/%u Total - XX. LANG_PINFO_CHR_MAILS (if has mails)
|
||||
*
|
||||
* Not all of them can be moved to the top. These should
|
||||
* place the most important ones to the head, though.
|
||||
*
|
||||
* For a cleaner overview, I segment each output in Roman numerals
|
||||
*/
|
||||
|
||||
// Account data print variables
|
||||
std::string userName = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 accId = 0;
|
||||
uint32 lowguid = GUID_LOPART(targetGuid);
|
||||
std::string eMail = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string lastIp = handler->GetTrinityString(LANG_ERROR);
|
||||
uint8 locked = 0;
|
||||
std::string lastLogin = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 failedLogins = 0;
|
||||
uint32 latency = 0;
|
||||
std::string OS = "None";
|
||||
|
||||
// Mute data print variables
|
||||
int64 muteTime = -1;
|
||||
std::string muteReason = "unknown";
|
||||
std::string muteBy = "unknown";
|
||||
|
||||
// Ban data print variables
|
||||
int64 banTime = -1;
|
||||
std::string banType = "None";
|
||||
std::string banReason = "Unknown";
|
||||
std::string bannedBy = "Unknown";
|
||||
|
||||
// Character data print variables
|
||||
uint8 raceid, classid = 0; //RACE_NONE, CLASS_NONE
|
||||
std::string raceStr, classStr = "None";
|
||||
uint8 gender = 0;
|
||||
int8 locale = handler->GetSessionDbcLocale();
|
||||
std::string genderStr = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 totalPlayerTime = 0;
|
||||
uint8 level = 0;
|
||||
std::string alive = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 money = 0;
|
||||
uint32 xp = 0;
|
||||
uint32 xptotal = 0;
|
||||
|
||||
// Position data print
|
||||
uint32 mapId;
|
||||
uint32 areaId;
|
||||
uint32 phase = 0;
|
||||
std::string areaName = "<unknown>";
|
||||
std::string zoneName = "<unknown>";
|
||||
|
||||
// Guild data print is only defined if part of Guild
|
||||
|
||||
// Mail data print is only defined if you have a mail
|
||||
|
||||
// get additional information from Player object
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
@@ -1514,11 +1601,13 @@ public:
|
||||
totalPlayerTime = target->GetTotalPlayedTime();
|
||||
level = target->getLevel();
|
||||
latency = target->GetSession()->GetLatency();
|
||||
race = target->getRace();
|
||||
Class = target->getClass();
|
||||
raceid = target->getRace();
|
||||
classid = target->getClass();
|
||||
muteTime = target->GetSession()->m_muteTime;
|
||||
mapId = target->GetMapId();
|
||||
areaId = target->GetAreaId();
|
||||
alive = target->isAlive() ? "Yes" : "No";
|
||||
gender = target->getGender();
|
||||
phase = target->GetPhaseMask();
|
||||
}
|
||||
// get additional information from DB
|
||||
@@ -1528,8 +1617,9 @@ public:
|
||||
if (handler->HasLowerSecurity(NULL, targetGuid))
|
||||
return false;
|
||||
|
||||
// Query informations from the DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
stmt->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
stmt->setUInt32(0, lowguid);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
@@ -1540,20 +1630,20 @@ public:
|
||||
level = fields[1].GetUInt8();
|
||||
money = fields[2].GetUInt32();
|
||||
accId = fields[3].GetUInt32();
|
||||
race = fields[4].GetUInt8();
|
||||
Class = fields[5].GetUInt8();
|
||||
raceid = fields[4].GetUInt8();
|
||||
classid = fields[5].GetUInt8();
|
||||
mapId = fields[6].GetUInt16();
|
||||
areaId = fields[7].GetUInt16();
|
||||
gender = fields[8].GetUInt8();
|
||||
uint32 health = fields[9].GetUInt32();
|
||||
uint32 playerFlags = fields[10].GetUInt32();
|
||||
if (!health || playerFlags & PLAYER_FLAGS_GHOST)
|
||||
alive = "No";
|
||||
else
|
||||
alive = "Yes";
|
||||
}
|
||||
|
||||
std::string userName = handler->GetTrinityString(LANG_ERROR);
|
||||
std::string eMail = handler->GetTrinityString(LANG_ERROR);
|
||||
std::string muteReason = "";
|
||||
std::string muteBy = "";
|
||||
std::string lastIp = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string lastLogin = handler->GetTrinityString(LANG_ERROR);
|
||||
|
||||
// Query the prepared statement for login data
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
|
||||
stmt->setInt32(0, int32(realmID));
|
||||
stmt->setUInt32(1, accId);
|
||||
@@ -1565,23 +1655,18 @@ public:
|
||||
userName = fields[0].GetString();
|
||||
security = fields[1].GetUInt8();
|
||||
eMail = fields[2].GetString();
|
||||
muteTime = fields[5].GetUInt64();
|
||||
muteReason = fields[6].GetString();
|
||||
muteBy = fields[7].GetString();
|
||||
|
||||
if (eMail.empty())
|
||||
eMail = "-";
|
||||
|
||||
// Only fetch these fields if commander has sufficient rights AND is online (prevent cheating)
|
||||
/// @TODO: Add RBAC for "Can query ip and login data"
|
||||
if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))
|
||||
{
|
||||
lastIp = fields[3].GetString();
|
||||
lastLogin = fields[4].GetString();
|
||||
|
||||
uint32 ip = inet_addr(lastIp.c_str());
|
||||
#if TRINITY_ENDIAN == BIGENDIAN
|
||||
EndianConvertReverse(ip);
|
||||
#endif
|
||||
|
||||
// If ip2nation table is populated, it displays the country
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY);
|
||||
stmt->setUInt32(0, ip);
|
||||
if (PreparedQueryResult result2 = LoginDatabase.Query(stmt))
|
||||
@@ -1592,27 +1677,26 @@ public:
|
||||
lastIp.append(")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastIp = "-";
|
||||
lastLogin = "-";
|
||||
}
|
||||
muteTime = fields[5].GetUInt64();
|
||||
muteReason = fields[6].GetString();
|
||||
muteBy = fields[7].GetString();
|
||||
failedLogins = fields[8].GetUInt32();
|
||||
locked = fields[9].GetUInt8();
|
||||
OS = fields[10].GetString();
|
||||
}
|
||||
|
||||
// Creates a chat link to the character. Returns nameLink
|
||||
std::string nameLink = handler->playerLink(targetName);
|
||||
|
||||
handler->PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : handler->GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGuid), userName.c_str(), accId, eMail.c_str(), security, lastIp.c_str(), lastLogin.c_str(), latency);
|
||||
|
||||
std::string bannedby = "unknown";
|
||||
std::string banreason = "";
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, accId);
|
||||
PreparedQueryResult result2 = LoginDatabase.Query(stmt);
|
||||
// Returns banType, banTime, bannedBy, banreason
|
||||
PreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
stmt2->setUInt32(0, accId);
|
||||
PreparedQueryResult result2 = LoginDatabase.Query(stmt2);
|
||||
if (!result2)
|
||||
{
|
||||
banType = "Character";
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
stmt->setUInt32(0, lowguid);
|
||||
result2 = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
|
||||
@@ -1620,49 +1704,19 @@ public:
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
banTime = int64(fields[1].GetUInt64() ? 0 : fields[0].GetUInt32());
|
||||
bannedby = fields[2].GetString();
|
||||
banreason = fields[3].GetString();
|
||||
bannedBy = fields[2].GetString();
|
||||
banReason = fields[3].GetString();
|
||||
}
|
||||
|
||||
if (muteTime > 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str(), muteBy.c_str(), muteReason.c_str());
|
||||
// Can be used to query data from World database
|
||||
stmt2 = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP);
|
||||
stmt2->setUInt8(0, level);
|
||||
PreparedQueryResult result3 = WorldDatabase.Query(stmt2);
|
||||
|
||||
if (banTime >= 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str());
|
||||
|
||||
std::string raceStr, ClassStr;
|
||||
switch (race)
|
||||
if (result3)
|
||||
{
|
||||
case RACE_HUMAN:
|
||||
raceStr = "Human";
|
||||
break;
|
||||
case RACE_ORC:
|
||||
raceStr = "Orc";
|
||||
break;
|
||||
case RACE_DWARF:
|
||||
raceStr = "Dwarf";
|
||||
break;
|
||||
case RACE_NIGHTELF:
|
||||
raceStr = "Night Elf";
|
||||
break;
|
||||
case RACE_UNDEAD_PLAYER:
|
||||
raceStr = "Undead";
|
||||
break;
|
||||
case RACE_TAUREN:
|
||||
raceStr = "Tauren";
|
||||
break;
|
||||
case RACE_GNOME:
|
||||
raceStr = "Gnome";
|
||||
break;
|
||||
case RACE_TROLL:
|
||||
raceStr = "Troll";
|
||||
break;
|
||||
case RACE_BLOODELF:
|
||||
raceStr = "Blood Elf";
|
||||
break;
|
||||
case RACE_DRAENEI:
|
||||
raceStr = "Draenei";
|
||||
break;
|
||||
Field* fields = result3->Fetch();
|
||||
xptotal = fields[0].GetUInt32();
|
||||
case RACE_GOBLIN:
|
||||
raceStr = "Goblin";
|
||||
break;
|
||||
@@ -1671,52 +1725,68 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Class)
|
||||
// Can be used to query data from Characters database
|
||||
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP);
|
||||
stmt2->setUInt32(0, lowguid);
|
||||
PreparedQueryResult result4 = CharacterDatabase.Query(stmt2);
|
||||
|
||||
if (result4)
|
||||
{
|
||||
case CLASS_WARRIOR:
|
||||
ClassStr = "Warrior";
|
||||
break;
|
||||
case CLASS_PALADIN:
|
||||
ClassStr = "Paladin";
|
||||
break;
|
||||
case CLASS_HUNTER:
|
||||
ClassStr = "Hunter";
|
||||
break;
|
||||
case CLASS_ROGUE:
|
||||
ClassStr = "Rogue";
|
||||
break;
|
||||
case CLASS_PRIEST:
|
||||
ClassStr = "Priest";
|
||||
break;
|
||||
case CLASS_DEATH_KNIGHT:
|
||||
ClassStr = "Death Knight";
|
||||
break;
|
||||
case CLASS_SHAMAN:
|
||||
ClassStr = "Shaman";
|
||||
break;
|
||||
case CLASS_MAGE:
|
||||
ClassStr = "Mage";
|
||||
break;
|
||||
case CLASS_WARLOCK:
|
||||
ClassStr = "Warlock";
|
||||
break;
|
||||
case CLASS_DRUID:
|
||||
ClassStr = "Druid";
|
||||
break;
|
||||
Field* fields = result4->Fetch();
|
||||
xp = fields[0].GetUInt32();
|
||||
}
|
||||
|
||||
std::string timeStr = secsToTimeString(totalPlayerTime, true, true);
|
||||
uint32 gold = money /GOLD;
|
||||
uint32 silv = (money % GOLD) / SILVER;
|
||||
uint32 copp = (money % GOLD) % SILVER;
|
||||
handler->PSendSysMessage(LANG_PINFO_LEVEL, raceStr.c_str(), ClassStr.c_str(), timeStr.c_str(), level, gold, silv, copp);
|
||||
// Initiate output
|
||||
// Output I. LANG_PINFO_PLAYER
|
||||
handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetTrinityString(LANG_OFFLINE), nameLink.c_str(), lowguid);
|
||||
|
||||
// Add map, zone, subzone and phase to output
|
||||
std::string areaName = "<unknown>";
|
||||
std::string zoneName = "";
|
||||
// Output II. LANG_PINFO_GM_ACTIVE
|
||||
if (target && target->isGameMaster())
|
||||
handler->PSendSysMessage(LANG_PINFO_GM_ACTIVE);
|
||||
|
||||
// Output III. LANG_PINFO_BANNED if ban exists and is applied
|
||||
if (banTime >= 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", banReason.c_str(), bannedBy.c_str());
|
||||
|
||||
// Output IV. LANG_PINFO_MUTED if mute is applied
|
||||
if (muteTime > 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_MUTED, secsToTimeString(muteTime - time(NULL), true).c_str(), muteReason.c_str(), muteBy.c_str());
|
||||
|
||||
// Output V. LANG_PINFO_ACC_ACCOUNT
|
||||
handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName.c_str(), accId, security);
|
||||
|
||||
// Output VI. LANG_PINFO_ACC_LASTLOGIN
|
||||
handler->PSendSysMessage(LANG_PINFO_ACC_LASTLOGIN, lastLogin.c_str(), failedLogins);
|
||||
|
||||
// Output VIII. LANG_PINFO_ACC_OS
|
||||
handler->PSendSysMessage(LANG_PINFO_ACC_OS, OS.c_str(), latency, eMail.c_str());
|
||||
|
||||
// Output IX. LANG_PINFO_ACC_IP
|
||||
handler->PSendSysMessage(LANG_PINFO_ACC_IP, lastIp.c_str(), locked ? "Yes" : "No");
|
||||
|
||||
// Output X. LANG_PINFO_CHR_LEVEL
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_LEVEL, level, xp, xptotal, (xptotal - xp));
|
||||
|
||||
// Output XI. LANG_PINFO_CHR_RACE
|
||||
raceStr = GetRaceName(raceid, locale);
|
||||
classStr = GetClassName(classid, locale);
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetTrinityString(LANG_CHARACTER_GENDER_MALE) : handler->GetTrinityString(LANG_CHARACTER_GENDER_FEMALE)), raceStr.c_str(), classStr.c_str());
|
||||
|
||||
// Output XII. LANG_PINFO_CHR_ALIVE
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive.c_str());
|
||||
|
||||
// Output XIII. LANG_PINFO_CHR_PHASE if player is not in GM mode (GM is in every phase)
|
||||
if (target && !target->isGameMaster()) // IsInWorld() returns false on loadingscreen, so it's more
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_PHASE, phase); // precise than just target (safer ?).
|
||||
// However, as we usually just require a target here, we use target instead.
|
||||
// Output XIV. LANG_PINFO_CHR_MONEY
|
||||
uint32 gold = money / GOLD;
|
||||
uint32 silv = (money % GOLD) / SILVER;
|
||||
uint32 copp = (money % GOLD) % SILVER;
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_MONEY, gold, silv, copp);
|
||||
|
||||
// Position data
|
||||
MapEntry const* map = sMapStore.LookupEntry(mapId);
|
||||
|
||||
AreaTableEntry const* area = GetAreaEntryByAreaID(areaId);
|
||||
if (area)
|
||||
{
|
||||
@@ -1728,30 +1798,55 @@ public:
|
||||
}
|
||||
|
||||
if (target)
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->name[locale], (!zoneName.empty() ? zoneName.c_str() : "<Unknown>"), (!areaName.empty() ? areaName.c_str() : "<Unknown>"));
|
||||
|
||||
// Guild Data - an own query, because it may not happen.
|
||||
PreparedStatement* stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED);
|
||||
stmt3->setUInt32(0, lowguid);
|
||||
PreparedQueryResult result5 = CharacterDatabase.Query(stmt3);
|
||||
if (result5)
|
||||
{
|
||||
if (!zoneName.empty())
|
||||
handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name, zoneName.c_str(), areaName.c_str(), phase);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name, areaName.c_str(), "<unknown>", phase);
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name, areaName.c_str());
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED);
|
||||
stmt->setUInt32(0, GUID_LOPART(targetGuid));
|
||||
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
std::string guildName = fields[1].GetString();
|
||||
std::string guildRank = fields[2].GetString();
|
||||
std::string note = fields[3].GetString();
|
||||
Field* fields = result5->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
std::string guildName = fields[1].GetString();
|
||||
std::string guildRank = fields[2].GetString();
|
||||
std::string note = fields[3].GetString();
|
||||
std::string officeNote = fields[4].GetString();
|
||||
|
||||
handler->PSendSysMessage(LANG_PINFO_GUILD_INFO, guildName.c_str(), guildId, guildRank.c_str(), note.c_str(), officeNote.c_str());
|
||||
// Output XVII. - XX.
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId);
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str());
|
||||
// Only output XIX and XX if they are not empty
|
||||
if (!note.empty())
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str());
|
||||
if (!officeNote.empty())
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_ONOTE, officeNote.c_str());
|
||||
}
|
||||
|
||||
// Output XXI. LANG_PINFO_CHR_PLAYEDTIME
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_PLAYEDTIME, (secsToTimeString(totalPlayerTime, true, true)).c_str());
|
||||
|
||||
// Mail Data - an own query, because it may or may not be useful.
|
||||
// SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?"
|
||||
stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS);
|
||||
stmt3->setUInt32(0, lowguid);
|
||||
PreparedQueryResult result6 = CharacterDatabase.Query(stmt3);
|
||||
if (result6)
|
||||
{
|
||||
// Define the variables, so the compiler knows they exist
|
||||
uint32 rmailint = 0;
|
||||
|
||||
// Fetch the fields - readmail is a SUM(x) and given out as char! Thus...
|
||||
Field* fields = result6->Fetch();
|
||||
std::string readmail = fields[0].GetString();
|
||||
uint64 totalmail = fields[1].GetUInt64();
|
||||
|
||||
// ... we have to convert it from Char to int. We can use totalmail as it is
|
||||
rmailint = atol(readmail.c_str());
|
||||
|
||||
// Output XXII. LANG_INFO_CHR_MAILS if at least one mails is given
|
||||
if (totalmail >= 1)
|
||||
handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, rmailint, totalmail);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1789,6 +1884,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// mute player for some times
|
||||
static bool HandleMuteCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
|
||||
@@ -338,7 +338,8 @@ public:
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Exit the realm
|
||||
|
||||
Reference in new issue
Block a user