aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-05-21 09:41:13 +0200
committerSpp <spp@jorge.gr>2013-05-21 09:41:13 +0200
commit1b6fb2b6959f504d9e33d2326691cf43a04690d2 (patch)
tree31671ddd62612c27e1e821408956b9a8ff52a0ab /src/server/scripts/Commands
parent82dc639882d2d51a8bde9bcd47b773be435a5a12 (diff)
parent243c325ca4323feb4f7f80c0ecd3873c78cbf887 (diff)
Merge branch 'master' into 4.3.4 [NOTE: There are parts of code marked as "REVIEW - MERGE" That needs some review)
Conflicts: src/server/game/DataStores/DBCStores.cpp src/server/game/DataStores/DBCStores.h src/server/game/DataStores/DBCfmt.h src/server/game/Entities/Unit/Unit.cpp src/server/game/Entities/Unit/Unit.h src/server/game/Handlers/AuctionHouseHandler.cpp src/server/game/Handlers/GroupHandler.cpp src/server/game/Movement/Spline/MovementTypedefs.h src/server/game/Spells/Auras/SpellAuraEffects.cpp src/server/game/Spells/SpellInfo.cpp src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp src/server/scripts/Spells/spell_generic.cpp
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp60
-rw-r--r--src/server/scripts/Commands/cs_character.cpp121
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp3
-rw-r--r--src/server/scripts/Commands/cs_guild.cpp50
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp8
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp12
-rw-r--r--src/server/scripts/Commands/cs_ticket.cpp4
7 files changed, 229 insertions, 29 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 3953beab3da..cf2816c985e 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -42,13 +42,19 @@ public:
{ "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
+ static ChatCommand accountLockCommandTable[] =
+ {
+ { "country", SEC_PLAYER, true, &HandleAccountLockCountryCommand, "", NULL },
+ { "ip", SEC_PLAYER, true, &HandleAccountLockIpCommand, "", NULL },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL },
+ };
static ChatCommand accountCommandTable[] =
{
{ "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "", NULL },
{ "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "", NULL },
{ "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "", NULL },
{ "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "", NULL },
- { "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "", NULL },
+ { "lock", SEC_PLAYER, false, NULL, "", accountLockCommandTable },
{ "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable },
{ "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "", NULL },
{ "", SEC_PLAYER, false, &HandleAccountCommand, "", NULL },
@@ -245,7 +251,57 @@ public:
return true;
}
- static bool HandleAccountLockCommand(ChatHandler* handler, char const* args)
+ static bool HandleAccountLockCountryCommand(ChatHandler* handler, char const* args)
+ {
+ if (!*args)
+ {
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ std::string param = (char*)args;
+
+ if (!param.empty())
+ {
+ if (param == "on")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
+ uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
+ EndianConvertReverse(ip);
+ stmt->setUInt32(0, ip);
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
+ if (result)
+ {
+ Field* fields = result->Fetch();
+ std::string country = fields[0].GetString();
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, country);
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
+ }
+ else
+ {
+ handler->PSendSysMessage("[IP2NATION] Table empty");
+ sLog->outDebug(LOG_FILTER_AUTHSERVER, "[IP2NATION] Table empty");
+ }
+ }
+ else if (param == "off")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, "00");
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
+ }
+ return true;
+ }
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ static bool HandleAccountLockIpCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 1ed00f32b87..727aa55597f 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -308,28 +308,121 @@ public:
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
- if (target)
+ char const* newNameStr = strtok(NULL, " ");
+
+ if (newNameStr)
{
- // check online security
- if (handler->HasLowerSecurity(target, 0))
+ std::string playerOldName;
+ std::string newName = newNameStr;
+
+ if (target)
+ {
+ // check online security
+ if (handler->HasLowerSecurity(target, 0))
+ return false;
+
+ playerOldName = target->GetName();
+ }
+ else
+ {
+ // check offline security
+ if (handler->HasLowerSecurity(NULL, targetGuid))
+ return false;
+
+ sObjectMgr->GetPlayerNameByGUID(targetGuid, playerOldName);
+ }
+
+ if (!normalizePlayerName(newName))
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (ObjectMgr::CheckPlayerName(newName, true) != CHAR_NAME_SUCCESS)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (WorldSession* session = handler->GetSession())
+ {
+ if (!session->HasPermission(RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(newName))
+ {
+ handler->SendSysMessage(LANG_RESERVED_NAME);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
+ stmt->setString(0, newName);
+ PreparedQueryResult result = CharacterDatabase.Query(stmt);
+ if (result)
+ {
+ handler->PSendSysMessage(LANG_RENAME_PLAYER_ALREADY_EXISTS, newName.c_str());
+ handler->SetSentErrorMessage(true);
return false;
+ }
+
+ // Remove declined name from db
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
+ stmt->setUInt32(0, targetGuid);
+ CharacterDatabase.Execute(stmt);
+
+ if (target)
+ {
+ target->SetName(newName);
+
+ if (WorldSession* session = target->GetSession())
+ session->KickPlayer();
+ }
+ else
+ {
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID);
+ stmt->setString(0, newName);
+ stmt->setUInt32(1, GUID_LOPART(targetGuid));
+ CharacterDatabase.Execute(stmt);
+ }
+
+ sWorld->UpdateCharacterNameData(targetGuid, newName);
- handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str());
- target->SetAtLoginFlag(AT_LOGIN_RENAME);
+ handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
+
+ if (WorldSession* session = handler->GetSession())
+ {
+ if (Player* player = session->GetPlayer())
+ 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(), sObjectMgr->GetPlayerAccountIdByGUID(targetGuid));
+ }
+ else
+ sLog->outCommand(0, "CONSOLE forced rename '%s' to '%s' (GUID: %u)", playerOldName.c_str(), newName.c_str(), GUID_LOPART(targetGuid));
}
else
{
- // check offline security
- if (handler->HasLowerSecurity(NULL, targetGuid))
- return false;
+ if (target)
+ {
+ // check online security
+ if (handler->HasLowerSecurity(target, 0))
+ return false;
- std::string oldNameLink = handler->playerLink(targetName);
- handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
+ handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str());
+ target->SetAtLoginFlag(AT_LOGIN_RENAME);
+ }
+ else
+ {
+ // check offline security
+ if (handler->HasLowerSecurity(NULL, targetGuid))
+ return false;
- 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);
+ 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;
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 3bdd0fbe132..414f673463f 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -592,7 +592,8 @@ public:
entry = object->GetEntry();
else
entry = atoi((char*)args);
- }
+ } else
+ entry = atoi((char*)args);
GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp
index 05f4e2bde67..ffaf1360ad5 100644
--- a/src/server/scripts/Commands/cs_guild.cpp
+++ b/src/server/scripts/Commands/cs_guild.cpp
@@ -44,6 +44,7 @@ public:
{ "invite", SEC_GAMEMASTER, true, &HandleGuildInviteCommand, "", NULL },
{ "uninvite", SEC_GAMEMASTER, true, &HandleGuildUninviteCommand, "", NULL },
{ "rank", SEC_GAMEMASTER, true, &HandleGuildRankCommand, "", NULL },
+ { "rename", SEC_GAMEMASTER, true, &HandleGuildRenameCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
@@ -193,6 +194,55 @@ public:
uint8 newRank = uint8(atoi(rankStr));
return targetGuild->ChangeMemberRank(targetGuid, newRank);
}
+
+ static bool HandleGuildRenameCommand(ChatHandler* handler, char const* _args)
+ {
+ if (!*_args)
+ return false;
+
+ char *args = (char *)_args;
+
+ char const* oldGuildStr = handler->extractQuotedArg(args);
+ if (!oldGuildStr)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ char const* newGuildStr = handler->extractQuotedArg(strtok(NULL, ""));
+ if (!newGuildStr)
+ {
+ handler->SendSysMessage(LANG_INSERT_GUILD_NAME);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ Guild* guild = sGuildMgr->GetGuildByName(oldGuildStr);
+ if (!guild)
+ {
+ handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, oldGuildStr);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (sGuildMgr->GetGuildByName(newGuildStr))
+ {
+ handler->PSendSysMessage(LANG_GUILD_RENAME_ALREADY_EXISTS, newGuildStr);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (!guild->SetName(newGuildStr))
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ handler->PSendSysMessage(LANG_GUILD_RENAME_DONE, oldGuildStr, newGuildStr);
+ return true;
+ }
};
void AddSC_guild_commandscript()
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 8357b0ec090..a953fe56e7e 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1586,13 +1586,9 @@ public:
EndianConvertReverse(ip);
#endif
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
-
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY);
stmt->setUInt32(0, ip);
-
- PreparedQueryResult result2 = WorldDatabase.Query(stmt);
-
- if (result2)
+ if (PreparedQueryResult result2 = LoginDatabase.Query(stmt))
{
Field* fields2 = result2->Fetch();
lastIp.append(" (");
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index 79cd0deb75e..55b6edbadbe 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -95,14 +95,14 @@ public:
path.SetUseStraightPath(useStraightPath);
bool result = path.CalculatePath(x, y, z);
- PointsArray const& pointPath = path.GetPath();
+ Movement::PointsArray const& pointPath = path.GetPath();
handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str());
handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : "SmoothPath");
- handler->PSendSysMessage("Result: %s - Length: "SIZEFMTD" - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType());
+ handler->PSendSysMessage("Result: %s - Length: " SIZEFMTD " - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType());
- Vector3 start = path.GetStartPosition();
- Vector3 end = path.GetEndPosition();
- Vector3 actualEnd = path.GetActualEndPosition();
+ G3D::Vector3 const &start = path.GetStartPosition();
+ G3D::Vector3 const &end = path.GetEndPosition();
+ G3D::Vector3 const &actualEnd = path.GetActualEndPosition();
handler->PSendSysMessage("StartPosition (%.3f, %.3f, %.3f)", start.x, start.y, start.z);
handler->PSendSysMessage("EndPosition (%.3f, %.3f, %.3f)", end.x, end.y, end.z);
@@ -264,7 +264,7 @@ public:
if (!creatureList.empty())
{
- handler->PSendSysMessage("Found "SIZEFMTD" Creatures.", creatureList.size());
+ handler->PSendSysMessage("Found " SIZEFMTD " Creatures.", creatureList.size());
uint32 paths = 0;
uint32 uStartTime = getMSTime();
diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp
index 95cbf70e1f8..0795b2ab90c 100644
--- a/src/server/scripts/Commands/cs_ticket.cpp
+++ b/src/server/scripts/Commands/cs_ticket.cpp
@@ -235,6 +235,10 @@ public:
if (player->IsInWorld())
ticket->SendResponse(player->GetSession());
+ SQLTransaction trans = SQLTransaction(NULL);
+ ticket->SetCompleted();
+ ticket->SaveToDB(trans);
+
sTicketMgr->UpdateLastChange();
return true;
}