aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/CMakeLists.txt3
-rw-r--r--src/server/scripts/Commands/cs_account.cpp37
-rw-r--r--src/server/scripts/Commands/cs_achievement.cpp2
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp57
-rw-r--r--src/server/scripts/Commands/cs_gm.cpp6
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp16
-rw-r--r--src/server/scripts/Commands/cs_gps.cpp144
-rw-r--r--src/server/scripts/Commands/cs_learn.cpp2
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp90
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp54
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp87
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp196
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp9
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp137
14 files changed, 507 insertions, 333 deletions
diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
index b17350c265d..86fe984e197 100644
--- a/src/server/scripts/Commands/CMakeLists.txt
+++ b/src/server/scripts/Commands/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+# Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
@@ -17,7 +17,6 @@ set(scripts_STAT_SRCS
Commands/cs_gm.cpp
Commands/cs_go.cpp
Commands/cs_gobject.cpp
- Commands/cs_gps.cpp
Commands/cs_honor.cpp
Commands/cs_learn.cpp
Commands/cs_misc.cpp
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 7372c92c4dd..b52102479b5 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -194,8 +194,11 @@ public:
static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/)
{
///- Get the list of accounts ID logged to the realm
- QueryResult resultDB = CharacterDatabase.Query("SELECT name, account, map, zone FROM characters WHERE online > 0");
- if (!resultDB)
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ONLINE);
+
+ PreparedQueryResult result = CharacterDatabase.Query(stmt);
+
+ if (!result)
{
handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY);
return true;
@@ -209,31 +212,28 @@ public:
///- Cycle through accounts
do
{
- Field* fieldsDB = resultDB->Fetch();
+ Field* fieldsDB = result->Fetch();
std::string name = fieldsDB[0].GetString();
uint32 account = fieldsDB[1].GetUInt32();
///- Get the username, last IP and GM level of each account
// No SQL injection. account is uint32.
- QueryResult resultLogin =
- LoginDatabase.PQuery("SELECT a.username, a.last_ip, aa.gmlevel, a.expansion "
- "FROM account a "
- "LEFT JOIN account_access aa "
- "ON (a.id = aa.id) "
- "WHERE a.id = '%u'", account);
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO);
+ stmt->setUInt32(0, account);
+ PreparedQueryResult resultLogin = LoginDatabase.Query(stmt);
if (resultLogin)
{
Field* fieldsLogin = resultLogin->Fetch();
handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE,
fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(),
- fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt32(),
- fieldsLogin[2].GetUInt32());
+ fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(),
+ fieldsLogin[2].GetUInt8());
}
else
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
- } while (resultDB->NextRow());
+ } while (result->NextRow());
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
return true;
@@ -382,7 +382,7 @@ public:
// Let set addon state only for lesser (strong) security level
// or to self account
- if (handler->GetSession() && handler->GetSession()->GetAccountId () != accountId &&
+ if (handler->GetSession() && handler->GetSession()->GetAccountId() != accountId &&
handler->HasLowerSecurityAccount(NULL, accountId, true))
return false;
@@ -469,7 +469,13 @@ public:
// Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
{
- QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm);
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
+
+ stmt->setUInt32(0, targetAccountId);
+ stmt->setUInt8(1, uint8(gm));
+
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
+
if (result)
{
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
@@ -502,11 +508,12 @@ public:
stmt->setUInt32(0, targetAccountId);
stmt->setUInt32(1, realmID);
}
+
LoginDatabase.Execute(stmt);
if (gm != 0)
{
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
stmt->setUInt32(0, targetAccountId);
stmt->setUInt8(1, uint8(gm));
diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp
index f136cba46ab..7667e79ece7 100644
--- a/src/server/scripts/Commands/cs_achievement.cpp
+++ b/src/server/scripts/Commands/cs_achievement.cpp
@@ -67,7 +67,7 @@ public:
return false;
}
- if (AchievementEntry const* achievementEntry = GetAchievementStore()->LookupEntry(achievementId))
+ if (AchievementEntry const* achievementEntry = sAchievementStore.LookupEntry(achievementId))
target->CompletedAchievement(achievementEntry);
return true;
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 4c4869c1c5b..6accc96260b 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -46,7 +46,7 @@ public:
{ "cinematic", SEC_MODERATOR, false, &HandleDebugPlayCinematicCommand, "", NULL },
{ "movie", SEC_MODERATOR, false, &HandleDebugPlayMovieCommand, "", NULL },
{ "sound", SEC_MODERATOR, false, &HandleDebugPlaySoundCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
};
static ChatCommand debugSendCommandTable[] =
{
@@ -61,7 +61,7 @@ public:
{ "sellerror", SEC_ADMINISTRATOR, false, &HandleDebugSendSellErrorCommand, "", NULL },
{ "setphaseshift", SEC_ADMINISTRATOR, false, &HandleDebugSendSetPhaseShiftCommand, "", NULL },
{ "spellfail", SEC_ADMINISTRATOR, false, &HandleDebugSendSpellFailCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
};
static ChatCommand debugCommandTable[] =
{
@@ -89,12 +89,14 @@ public:
{ "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "", NULL },
{ "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "", NULL },
{ "los", SEC_MODERATOR, false, &HandleDebugLoSCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "moveflags", SEC_ADMINISTRATOR, false, &HandleDebugMoveflagsCommand, "", NULL },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable },
- { NULL, 0, false, NULL, "", NULL }
+ { "wpgps", SEC_ADMINISTRATOR, false, &HandleWPGPSCommand, "", NULL },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL }
};
return commandTable;
}
@@ -1197,7 +1199,7 @@ public:
int currentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
currentValue += value;
- handler->GetSession()->GetPlayer()->SetUInt32Value(opcode , (uint32)currentValue);
+ handler->GetSession()->GetPlayer()->SetUInt32Value(opcode, (uint32)currentValue);
handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue);
@@ -1283,6 +1285,51 @@ public:
handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value);
return true;
}
+
+ static bool HandleDebugMoveflagsCommand(ChatHandler* handler, char const* args)
+ {
+ Unit* target = handler->getSelectedUnit();
+ if (!target)
+ target = handler->GetSession()->GetPlayer();
+
+ if (!*args)
+ {
+ //! Display case
+ handler->PSendSysMessage(LANG_MOVEFLAGS_GET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags());
+ }
+ else
+ {
+ char* mask1 = strtok((char*)args, " ");
+ if (!mask1)
+ return false;
+
+ char* mask2 = strtok(NULL, " \n");
+
+ uint32 moveFlags = (uint32)atoi(mask1);
+ target->SetUnitMovementFlags(moveFlags);
+
+ if (mask2)
+ {
+ uint32 moveFlagsExtra = uint32(atoi(mask2));
+ target->SetExtraUnitMovementFlags(moveFlagsExtra);
+ }
+
+ target->SendMovementFlagUpdate();
+ handler->PSendSysMessage(LANG_MOVEFLAGS_SET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags());
+ }
+
+ return true;
+ }
+
+ static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/)
+ {
+ Player* player = handler->GetSession()->GetPlayer();
+
+ sLog->outSQLDev("(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
+
+ handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
+ return true;
+ }
};
void AddSC_debug_commandscript()
diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp
index 0dcb6995cb1..ba5a7f10d7d 100644
--- a/src/server/scripts/Commands/cs_gm.cpp
+++ b/src/server/scripts/Commands/cs_gm.cpp
@@ -153,7 +153,11 @@ public:
static bool HandleGMListFullCommand(ChatHandler* handler, char const* /*args*/)
{
///- Get the accounts with GM Level >0
- QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel >= %u AND (aa.realmid = -1 OR aa.realmid = %u)", SEC_MODERATOR, realmID);
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_GM_ACCOUNTS);
+ stmt->setUInt8(0, uint8(SEC_MODERATOR));
+ stmt->setInt32(1, int32(realmID));
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
+
if (result)
{
handler->SendSysMessage(LANG_GMLIST);
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 74b8272201b..232aad9f21c 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -535,11 +535,17 @@ public:
uint32 count = 0;
Player* player = handler->GetSession()->GetPlayer();
- QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
- "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
- "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
- player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),
- player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), distance * distance);
+
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAMEOBJECT_NEAREST);
+ stmt->setFloat(0, player->GetPositionX());
+ stmt->setFloat(1, player->GetPositionY());
+ stmt->setFloat(2, player->GetPositionZ());
+ stmt->setUInt32(3, player->GetMapId());
+ stmt->setFloat(4, player->GetPositionX());
+ stmt->setFloat(5, player->GetPositionY());
+ stmt->setFloat(6, player->GetPositionZ());
+ stmt->setFloat(7, distance * distance);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
diff --git a/src/server/scripts/Commands/cs_gps.cpp b/src/server/scripts/Commands/cs_gps.cpp
deleted file mode 100644
index 12a5efddf47..00000000000
--- a/src/server/scripts/Commands/cs_gps.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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: gps_commandscript
-%Complete: 100
-Comment: GPS/WPGPS commands
-Category: commandscripts
-EndScriptData */
-
-#include "ObjectAccessor.h"
-#include "ScriptMgr.h"
-#include "Chat.h"
-#include "CellImpl.h"
-
-class gps_commandscript : public CommandScript
-{
-public:
- gps_commandscript() : CommandScript("gps_commandscript") { }
-
- ChatCommand* GetCommands() const
- {
- static ChatCommand commandTable[] =
- {
- { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
- { "wpgps", SEC_ADMINISTRATOR, false, &HandleWPGPSCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- return commandTable;
- }
-
- static bool HandleGPSCommand(ChatHandler* handler, char const* args)
- {
- WorldObject* object = NULL;
- if (*args)
- {
- uint64 guid = handler->extractGuidFromLink((char*)args);
- if (guid)
- object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
-
- if (!object)
- {
- handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
- else
- {
- object = handler->getSelectedUnit();
-
- if (!object)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
- }
-
- CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
- Cell cell(cellCoord);
-
- uint32 zoneId, areaId;
- object->GetZoneAndAreaId(zoneId, areaId);
-
- MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
- AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
- AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
-
- float zoneX = object->GetPositionX();
- float zoneY = object->GetPositionY();
-
- Map2ZoneCoordinates(zoneX, zoneY, zoneId);
-
- Map const* map = object->GetMap();
- float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
- float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
-
- GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
-
- // 63? WHY?
- int gridX = 63 - gridCoord.x_coord;
- int gridY = 63 - gridCoord.y_coord;
-
- uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
- uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
-
- if (haveVMap)
- {
- if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
- handler->PSendSysMessage("You are outdoors");
- else
- handler->PSendSysMessage("You are indoors");
- }
- else
- handler->PSendSysMessage("no VMAP available for area info");
-
- handler->PSendSysMessage(LANG_MAP_POSITION,
- object->GetMapId(), (mapEntry ? mapEntry->name : "<unknown>"),
- zoneId, (zoneEntry ? zoneEntry->area_name : "<unknown>"),
- areaId, (areaEntry ? areaEntry->area_name : "<unknown>"),
- object->GetPhaseMask(),
- object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
- cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
- zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
-
- LiquidData liquidStatus;
- ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
-
- if (status)
- handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.type, status);
-
- return true;
- }
-
- static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/)
- {
- Player* player = handler->GetSession()->GetPlayer();
-
- sLog->outSQLDev("(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
-
- handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
- return true;
- }
-};
-
-void AddSC_gps_commandscript()
-{
- new gps_commandscript();
-}
diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp
index fcabaaa7e5b..ae573577d7e 100644
--- a/src/server/scripts/Commands/cs_learn.cpp
+++ b/src/server/scripts/Commands/cs_learn.cpp
@@ -248,7 +248,7 @@ public:
return false;
}
- CreatureTemplate const* creatureInfo = pet->GetCreatureInfo();
+ CreatureTemplate const* creatureInfo = pet->GetCreatureTemplate();
if (!creatureInfo)
{
handler->SendSysMessage(LANG_WRONG_PET_TYPE);
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 5f0434e5c55..7c431566f52 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -17,6 +17,9 @@
#include "ScriptPCH.h"
#include "Chat.h"
+#include "ObjectAccessor.h"
+#include "ScriptMgr.h"
+#include "CellImpl.h"
class misc_commandscript : public CommandScript
{
@@ -27,7 +30,8 @@ public:
{
static ChatCommand commandTable[] =
{
- { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL },
+ { "dev", SEC_ADMINISTRATOR, false, &HandleDevCommand, "", NULL },
+ { "gps", SEC_ADMINISTRATOR, false, &HandleGPSCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
@@ -64,6 +68,90 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
+
+ static bool HandleGPSCommand(ChatHandler* handler, char const* args)
+ {
+ WorldObject* object = NULL;
+ if (*args)
+ {
+ uint64 guid = handler->extractGuidFromLink((char*)args);
+ if (guid)
+ object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
+
+ if (!object)
+ {
+ handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+ else
+ {
+ object = handler->getSelectedUnit();
+
+ if (!object)
+ {
+ handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+
+ CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
+ Cell cell(cellCoord);
+
+ uint32 zoneId, areaId;
+ object->GetZoneAndAreaId(zoneId, areaId);
+
+ MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
+ AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
+ AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
+
+ float zoneX = object->GetPositionX();
+ float zoneY = object->GetPositionY();
+
+ Map2ZoneCoordinates(zoneX, zoneY, zoneId);
+
+ Map const* map = object->GetMap();
+ float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
+ float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
+
+ GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
+
+ // 63? WHY?
+ int gridX = 63 - gridCoord.x_coord;
+ int gridY = 63 - gridCoord.y_coord;
+
+ uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
+ uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
+
+ if (haveVMap)
+ {
+ if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
+ handler->PSendSysMessage("You are outdoors");
+ else
+ handler->PSendSysMessage("You are indoors");
+ }
+ else
+ handler->PSendSysMessage("no VMAP available for area info");
+
+ handler->PSendSysMessage(LANG_MAP_POSITION,
+ object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ object->GetPhaseMask(),
+ object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
+ cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
+ zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
+
+ LiquidData liquidStatus;
+ ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
+
+ if (status)
+ handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
+
+ return true;
+ }
};
void AddSC_misc_commandscript()
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index 93aa188c071..0de3637586c 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -33,6 +33,16 @@ public:
ChatCommand* GetCommands() const
{
+ static ChatCommand modifyspeedCommandTable[] =
+ {
+ { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL },
+ { "all", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
+ { "walk", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL },
+ { "backwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL },
+ { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL },
+ { "", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
static ChatCommand modifyCommandTable[] =
{
{ "hp", SEC_MODERATOR, false, &HandleModifyHPCommand, "", NULL },
@@ -41,31 +51,28 @@ public:
{ "runicpower", SEC_MODERATOR, false, &HandleModifyRunicPowerCommand, "", NULL },
{ "energy", SEC_MODERATOR, false, &HandleModifyEnergyCommand, "", NULL },
{ "money", SEC_MODERATOR, false, &HandleModifyMoneyCommand, "", NULL },
- { "speed", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL },
- { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL },
{ "scale", SEC_MODERATOR, false, &HandleModifyScaleCommand, "", NULL },
{ "bit", SEC_MODERATOR, false, &HandleModifyBitCommand, "", NULL },
- { "bwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL },
- { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL },
- { "aspeed", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL },
{ "faction", SEC_MODERATOR, false, &HandleModifyFactionCommand, "", NULL },
{ "spell", SEC_MODERATOR, false, &HandleModifySpellCommand, "", NULL },
- { "tp", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL },
+ { "talentpoints", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL },
{ "mount", SEC_MODERATOR, false, &HandleModifyMountCommand, "", NULL },
{ "honor", SEC_MODERATOR, false, &HandleModifyHonorCommand, "", NULL },
- { "rep", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL },
- { "arena", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL },
+ { "reputation", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL },
+ { "arenapoints", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL },
{ "drunk", SEC_MODERATOR, false, &HandleModifyDrunkCommand, "", NULL },
{ "standstate", SEC_GAMEMASTER, false, &HandleModifyStandStateCommand, "", NULL },
- { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL },
{ "phase", SEC_ADMINISTRATOR, false, &HandleModifyPhaseCommand, "", NULL },
{ "gender", SEC_GAMEMASTER, false, &HandleModifyGenderCommand, "", NULL },
{ "collision", SEC_GAMEMASTER, false, &HandleModifyCollisionCommand, "", NULL },
+ { "speed", SEC_MODERATOR, false, NULL, "", modifyspeedCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
- { "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable },
+ { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL },
+ { "demorph", SEC_GAMEMASTER, false, &HandleDeMorphCommand, "", NULL },
+ { "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
@@ -361,7 +368,9 @@ public:
//Edit Player Spell
static bool HandleModifySpellCommand(ChatHandler* handler, const char* args)
{
- if (!*args) return false;
+ if (!*args)
+ return false;
+
char* pspellflatid = strtok((char*)args, " ");
if (!pspellflatid)
return false;
@@ -710,7 +719,7 @@ public:
(ChatHandler(player)).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), Scale);
}
- target->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
+ target->SetObjectScale(Scale);
return true;
}
@@ -1142,10 +1151,10 @@ public:
static bool HandleModifyRepCommand(ChatHandler* handler, const char* args)
{
- if (!*args) return false;
+ if (!*args)
+ return false;
Player* target = handler->getSelectedPlayer();
-
if (!target)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
@@ -1233,7 +1242,7 @@ public:
return false;
}
- target->GetReputationMgr().SetReputation(factionEntry, amount);
+ target->GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false);
handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name, factionId,
handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry));
return true;
@@ -1375,6 +1384,21 @@ public:
return true;
}
+//demorph player or unit
+ static bool HandleDeMorphCommand(ChatHandler* handler, const char* /*args*/)
+ {
+ Unit* target = handler->getSelectedUnit();
+ if (!target)
+ target = handler->GetSession()->GetPlayer();
+
+ // check online security
+ else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0))
+ return false;
+
+ target->DeMorph();
+
+ return true;
+ }
static bool HandleModifyCollisionCommand(ChatHandler* handler, const char* args)
{
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 57932ef56c6..832f7958fc8 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -28,6 +28,7 @@ EndScriptData */
#include "Transport.h"
#include "CreatureGroups.h"
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
+#include "CreatureAI.h"
class npc_commandscript : public CommandScript
{
@@ -73,6 +74,7 @@ public:
{ "phase", SEC_GAMEMASTER, false, &HandleNpcSetPhaseCommand, "", NULL },
{ "spawndist", SEC_GAMEMASTER, false, &HandleNpcSetSpawnDistCommand, "", NULL },
{ "spawntime", SEC_GAMEMASTER, false, &HandleNpcSetSpawnTimeCommand, "", NULL },
+ { "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "", NULL },
//{ TODO: fix or remove these commands
{ "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL },
{ "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL },
@@ -108,6 +110,7 @@ public:
{
if (!*args)
return false;
+
char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
if (!charID)
return false;
@@ -130,12 +133,24 @@ public:
{
uint32 tguid = chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
if (tguid > 0)
- WorldDatabase.PExecute("INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f, %u)", tguid, id, chr->GetTransport()->GetEntry(), chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
+ {
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_TRANSPORT);
+
+ stmt->setInt32(0, int32(tguid));
+ stmt->setInt32(1, int32(id));
+ stmt->setInt32(2, int32(chr->GetTransport()->GetEntry()));
+ stmt->setFloat(3, chr->GetTransOffsetX());
+ stmt->setFloat(4, chr->GetTransOffsetY());
+ stmt->setFloat(5, chr->GetTransOffsetZ());
+ stmt->setFloat(6, chr->GetTransOffsetO());
+
+ WorldDatabase.Execute(stmt);
+ }
return true;
}
- Creature* creature = new Creature;
+ Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
{
delete creature;
@@ -462,7 +477,7 @@ public:
// Faction is set in creature_template - not inside creature
// Update in memory..
- if (CreatureTemplate const* cinfo = creature->GetCreatureInfo())
+ if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
{
const_cast<CreatureTemplate*>(cinfo)->faction_A = factionId;
const_cast<CreatureTemplate*>(cinfo)->faction_H = factionId;
@@ -511,6 +526,39 @@ public:
return true;
}
+ //set data of creature for testing scripting
+ static bool HandleNpcSetDataCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ char* arg1 = strtok((char*)args, " ");
+ char* arg2 = strtok((char*)NULL, "");
+
+ if (!arg1 || !arg2)
+ return false;
+
+ uint32 data_1 = (uint32)atoi(arg1);
+ uint32 data_2 = (uint32)atoi(arg2);
+
+ if (!data_1 || !data_2)
+ return false;
+
+ Creature* creature = handler->getSelectedCreature();
+
+ if (!creature)
+ {
+ handler->SendSysMessage(LANG_SELECT_CREATURE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ creature->AI()->SetData(data_1, data_2);
+ std::string AIorScript = creature->GetAIName() != "" ? "AI type: " + creature->GetAIName() : (creature->GetScriptName() != "" ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
+ handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript.c_str());
+ return true;
+ }
+
//npc follow handling
static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/)
{
@@ -547,7 +595,7 @@ public:
uint32 displayid = target->GetDisplayId();
uint32 nativeid = target->GetNativeDisplayId();
uint32 Entry = target->GetEntry();
- CreatureTemplate const* cInfo = target->GetCreatureInfo();
+ CreatureTemplate const* cInfo = target->GetCreatureTemplate();
int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
if (curRespawnDelay < 0)
@@ -677,9 +725,16 @@ public:
return false;
}
- if (target->GetTransport())
- if (target->GetGUIDTransport())
- WorldDatabase.PExecute("UPDATE creature_transport SET emote=%u WHERE transport_entry=%u AND guid=%u", emote, target->GetTransport()->GetEntry(), target->GetGUIDTransport());
+ if (target->GetTransport() && target->GetGUIDTransport())
+ {
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_TRANSPORT_EMOTE);
+
+ stmt->setInt32(0, int32(emote));
+ stmt->setInt32(1, target->GetTransport()->GetEntry());
+ stmt->setInt32(2, target->GetGUIDTransport());
+
+ WorldDatabase.Execute(stmt);
+ }
target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
@@ -1036,7 +1091,7 @@ public:
}
if (/*creature->GetMotionMaster()->empty() ||*/
- creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != FOLLOW_MOTION_TYPE)
+ creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName());
handler->SetSentErrorMessage(true);
@@ -1131,24 +1186,24 @@ public:
//npc tame handling
static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/)
{
- Creature* creatureTarget = handler->getSelectedCreature ();
- if (!creatureTarget || creatureTarget->isPet ())
+ Creature* creatureTarget = handler->getSelectedCreature();
+ if (!creatureTarget || creatureTarget->isPet())
{
handler->PSendSysMessage (LANG_SELECT_CREATURE);
handler->SetSentErrorMessage (true);
return false;
}
- Player* player = handler->GetSession()->GetPlayer ();
+ Player* player = handler->GetSession()->GetPlayer();
- if (player->GetPetGUID ())
+ if (player->GetPetGUID())
{
handler->SendSysMessage (LANG_YOU_ALREADY_HAVE_PET);
handler->SetSentErrorMessage (true);
return false;
}
- CreatureTemplate const* cInfo = creatureTarget->GetCreatureInfo();
+ CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
if (!cInfo->isTameable (player->CanTameExoticPets()))
{
@@ -1168,8 +1223,8 @@ public:
// place pet before player
float x, y, z;
- player->GetClosePoint (x, y, z, creatureTarget->GetObjectSize (), CONTACT_DISTANCE);
- pet->Relocate (x, y, z, M_PI-player->GetOrientation ());
+ player->GetClosePoint (x, y, z, creatureTarget->GetObjectSize(), CONTACT_DISTANCE);
+ pet->Relocate(x, y, z, M_PI-player->GetOrientation());
// set pet to defensive mode by default (some classes can't control controlled pets in fact).
pet->SetReactState(REACT_DEFENSIVE);
@@ -1229,7 +1284,7 @@ public:
group_member->leaderGUID = leaderGUID;
group_member->groupAI = 0;
- CreatureGroupMap[lowguid] = group_member;
+ sFormationMgr->CreatureGroupMap[lowguid] = group_member;
creature->SearchFormation();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 17c819f2f22..1c119fdef4c 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -37,6 +37,7 @@ EndScriptData */
#include "SkillExtraItems.h"
#include "Chat.h"
#include "WaypointManager.h"
+#include "WardenCheckMgr.h"
class reload_commandscript : public CommandScript
{
@@ -105,6 +106,7 @@ public:
{ "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, &HandleReloadLfgRewardsCommand, "", NULL },
{ "locales_achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL },
{ "locales_creature", SEC_ADMINISTRATOR, true, &HandleReloadLocalesCreatureCommand, "", NULL },
+ { "locales_creature_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesCreatureTextCommand, "", NULL },
{ "locales_gameobject", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGameobjectCommand, "", NULL },
{ "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL },
{ "locales_item", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemCommand, "", NULL },
@@ -151,6 +153,7 @@ public:
{ "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "", NULL },
{ "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL },
{ "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "", NULL },
+ { "warden_action", SEC_ADMINISTRATOR, true, &HandleReloadWardenactionCommand, "", NULL },
{ "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "", NULL },
{ "waypoint_data", SEC_ADMINISTRATOR, true, &HandleReloadWpCommand, "", NULL },
{ "vehicle_accessory", SEC_ADMINISTRATOR, true, &HandleReloadVehicleAccessoryCommand, "", NULL },
@@ -317,6 +320,7 @@ public:
{
HandleReloadLocalesAchievementRewardCommand(handler, "a");
HandleReloadLocalesCreatureCommand(handler, "a");
+ HandleReloadLocalesCreatureTextCommand(handler, "a");
HandleReloadLocalesGameobjectCommand(handler, "a");
HandleReloadLocalesGossipMenuOptionCommand(handler, "a");
HandleReloadLocalesItemCommand(handler, "a");
@@ -409,14 +413,18 @@ public:
for (Tokens::const_iterator itr = entries.begin(); itr != entries.end(); ++itr)
{
uint32 entry = uint32(atoi(*itr));
- QueryResult result = WorldDatabase.PQuery("SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = %u", entry);
+
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE);
+ stmt->setUInt32(0, entry);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
if (!result)
{
handler->PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry);
continue;
}
- CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry);
+ CreatureTemplate* cInfo = const_cast<CreatureTemplate*>(sObjectMgr->GetCreatureTemplate(entry));
if (!cInfo)
{
handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry);
@@ -427,89 +435,88 @@ public:
Field* fields = result->Fetch();
- const_cast<CreatureTemplate*>(cInfo)->DifficultyEntry[0] = fields[0].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->DifficultyEntry[1] = fields[1].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->DifficultyEntry[2] = fields[2].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->KillCredit[0] = fields[3].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->KillCredit[1] = fields[4].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->Modelid1 = fields[5].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->Modelid2 = fields[6].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->Modelid3 = fields[7].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->Modelid4 = fields[8].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->Name = fields[9].GetString();
- const_cast<CreatureTemplate*>(cInfo)->SubName = fields[10].GetString();
- const_cast<CreatureTemplate*>(cInfo)->IconName = fields[11].GetString();
- const_cast<CreatureTemplate*>(cInfo)->GossipMenuId = fields[12].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->minlevel = fields[13].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->maxlevel = fields[14].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->expansion = fields[15].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->faction_A = fields[16].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->faction_H = fields[17].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->npcflag = fields[18].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->speed_walk = fields[19].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->speed_run = fields[20].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->scale = fields[21].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->rank = fields[22].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->mindmg = fields[23].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->maxdmg = fields[24].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->dmgschool = fields[25].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->attackpower = fields[26].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->dmg_multiplier = fields[27].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->baseattacktime = fields[28].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->rangeattacktime = fields[29].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->unit_class = fields[30].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->unit_flags = fields[31].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->dynamicflags = fields[32].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->family = fields[33].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->trainer_type = fields[34].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->trainer_spell = fields[35].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->trainer_class = fields[36].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->trainer_race = fields[37].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->minrangedmg = fields[38].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->maxrangedmg = fields[39].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->rangedattackpower = fields[40].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->type = fields[41].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->type_flags = fields[42].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->lootid = fields[43].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->pickpocketLootId = fields[44].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->SkinLootId = fields[45].GetUInt32();
+ cInfo->DifficultyEntry[0] = fields[0].GetUInt32();
+ cInfo->DifficultyEntry[1] = fields[1].GetUInt32();
+ cInfo->DifficultyEntry[2] = fields[2].GetUInt32();
+ cInfo->KillCredit[0] = fields[3].GetUInt32();
+ cInfo->KillCredit[1] = fields[4].GetUInt32();
+ cInfo->Modelid1 = fields[5].GetUInt32();
+ cInfo->Modelid2 = fields[6].GetUInt32();
+ cInfo->Modelid3 = fields[7].GetUInt32();
+ cInfo->Modelid4 = fields[8].GetUInt32();
+ cInfo->Name = fields[9].GetString();
+ cInfo->SubName = fields[10].GetString();
+ cInfo->IconName = fields[11].GetString();
+ cInfo->GossipMenuId = fields[12].GetUInt32();
+ cInfo->minlevel = fields[13].GetUInt8();
+ cInfo->maxlevel = fields[14].GetUInt8();
+ cInfo->expansion = fields[15].GetUInt16();
+ cInfo->faction_A = fields[16].GetUInt16();
+ cInfo->faction_H = fields[17].GetUInt16();
+ cInfo->npcflag = fields[18].GetUInt32();
+ cInfo->speed_walk = fields[19].GetFloat();
+ cInfo->speed_run = fields[20].GetFloat();
+ cInfo->scale = fields[21].GetFloat();
+ cInfo->rank = fields[22].GetUInt8();
+ cInfo->mindmg = fields[23].GetFloat();
+ cInfo->maxdmg = fields[24].GetFloat();
+ cInfo->dmgschool = fields[25].GetUInt8();
+ cInfo->attackpower = fields[26].GetUInt32();
+ cInfo->dmg_multiplier = fields[27].GetFloat();
+ cInfo->baseattacktime = fields[28].GetUInt32();
+ cInfo->rangeattacktime = fields[29].GetUInt32();
+ cInfo->unit_class = fields[30].GetUInt8();
+ cInfo->unit_flags = fields[31].GetUInt32();
+ cInfo->dynamicflags = fields[32].GetUInt32();
+ cInfo->family = fields[33].GetUInt8();
+ cInfo->trainer_type = fields[34].GetUInt8();
+ cInfo->trainer_spell = fields[35].GetUInt32();
+ cInfo->trainer_class = fields[36].GetUInt8();
+ cInfo->trainer_race = fields[37].GetUInt8();
+ cInfo->minrangedmg = fields[38].GetFloat();
+ cInfo->maxrangedmg = fields[39].GetFloat();
+ cInfo->rangedattackpower = fields[40].GetUInt16();
+ cInfo->type = fields[41].GetUInt8();
+ cInfo->type_flags = fields[42].GetUInt32();
+ cInfo->lootid = fields[43].GetUInt32();
+ cInfo->pickpocketLootId = fields[44].GetUInt32();
+ cInfo->SkinLootId = fields[45].GetUInt32();
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
- {
- const_cast<CreatureTemplate*>(cInfo)->resistance[i] = fields[46 + i -1].GetUInt32();
- }
-
- const_cast<CreatureTemplate*>(cInfo)->spells[0] = fields[52].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[1] = fields[53].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[2] = fields[54].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[3] = fields[55].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[4] = fields[56].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[5] = fields[57].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[6] = fields[58].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->spells[7] = fields[59].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->PetSpellDataId = fields[60].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->VehicleId = fields[61].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->mingold = fields[62].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->maxgold = fields[63].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->AIName = fields[64].GetString();
- const_cast<CreatureTemplate*>(cInfo)->MovementType = fields[65].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->InhabitType = fields[66].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->ModHealth = fields[67].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->ModMana = fields[68].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->ModArmor = fields[69].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->RacialLeader = fields[70].GetBool();
- const_cast<CreatureTemplate*>(cInfo)->questItems[0] = fields[71].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[1] = fields[72].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[2] = fields[73].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[3] = fields[74].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[4] = fields[75].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[5] = fields[76].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->movementId = fields[77].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->RegenHealth = fields[78].GetBool();
- const_cast<CreatureTemplate*>(cInfo)->equipmentId = fields[79].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->MechanicImmuneMask = fields[80].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->flags_extra = fields[81].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->ScriptID = sObjectMgr->GetScriptId(fields[82].GetCString());
+ cInfo->resistance[i] = fields[46 + i -1].GetUInt16();
+
+ cInfo->spells[0] = fields[52].GetUInt32();
+ cInfo->spells[1] = fields[53].GetUInt32();
+ cInfo->spells[2] = fields[54].GetUInt32();
+ cInfo->spells[3] = fields[55].GetUInt32();
+ cInfo->spells[4] = fields[56].GetUInt32();
+ cInfo->spells[5] = fields[57].GetUInt32();
+ cInfo->spells[6] = fields[58].GetUInt32();
+ cInfo->spells[7] = fields[59].GetUInt32();
+ cInfo->PetSpellDataId = fields[60].GetUInt32();
+ cInfo->VehicleId = fields[61].GetUInt32();
+ cInfo->mingold = fields[62].GetUInt32();
+ cInfo->maxgold = fields[63].GetUInt32();
+ cInfo->AIName = fields[64].GetString();
+ cInfo->MovementType = fields[65].GetUInt8();
+ cInfo->InhabitType = fields[66].GetUInt8();
+ cInfo->HoverHeight = fields[67].GetFloat();
+ cInfo->ModHealth = fields[68].GetFloat();
+ cInfo->ModMana = fields[69].GetFloat();
+ cInfo->ModArmor = fields[70].GetFloat();
+ cInfo->RacialLeader = fields[71].GetBool();
+ cInfo->questItems[0] = fields[72].GetUInt32();
+ cInfo->questItems[1] = fields[73].GetUInt32();
+ cInfo->questItems[2] = fields[74].GetUInt32();
+ cInfo->questItems[3] = fields[75].GetUInt32();
+ cInfo->questItems[4] = fields[76].GetUInt32();
+ cInfo->questItems[5] = fields[77].GetUInt32();
+ cInfo->movementId = fields[78].GetUInt32();
+ cInfo->RegenHealth = fields[79].GetBool();
+ cInfo->equipmentId = fields[80].GetUInt32();
+ cInfo->MechanicImmuneMask = fields[81].GetUInt32();
+ cInfo->flags_extra = fields[82].GetUInt32();
+ cInfo->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString());
sObjectMgr->CheckCreatureTemplate(cInfo);
}
@@ -724,6 +731,21 @@ public:
return true;
}
+ static bool HandleReloadWardenactionCommand(ChatHandler* handler, const char* /*args*/)
+ {
+ if (!sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED))
+ {
+ handler->SendSysMessage("Warden system disabled by config - reloading warden_action skipped.");
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ sLog->outString("Re-Loading warden_action Table!");
+ sWardenCheckMgr->LoadWardenOverrides();
+ handler->SendGlobalGMSysMessage("DB table `warden_action` reloaded.");
+ return true;
+ }
+
static bool HandleReloadNpcTrainerCommand(ChatHandler* handler, const char* /*args*/)
{
sLog->outString("Re-Loading `npc_trainer` Table!");
@@ -1154,6 +1176,14 @@ public:
return true;
}
+ static bool HandleReloadLocalesCreatureTextCommand(ChatHandler* handler, const char* /*args*/)
+ {
+ sLog->outString("Re-Loading Locales Creature Texts...");
+ sCreatureTextMgr->LoadCreatureTextLocales();
+ handler->SendGlobalGMSysMessage("DB table `locales_creature_text` reloaded.");
+ return true;
+ }
+
static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler, const char* /*args*/)
{
sLog->outString("Re-Loading Locales Gameobject ... ");
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 5054bd83f32..ca7c3af7fde 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -131,12 +131,15 @@ public:
target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
else
{
- QueryResult resultDB = CharacterDatabase.PQuery("SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = %u", target_guid);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_HOMEBIND);
+ stmt->setUInt32(0, target_guid);
+ PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
+
if (resultDB)
{
Field* fieldsDB = resultDB->Fetch();
- uint32 mapId = fieldsDB[0].GetUInt32();
- uint32 zoneId = fieldsDB[1].GetUInt32();
+ uint32 mapId = fieldsDB[0].GetUInt16();
+ uint32 zoneId = fieldsDB[1].GetUInt16();
float posX = fieldsDB[2].GetFloat();
float posY = fieldsDB[3].GetFloat();
float posZ = fieldsDB[4].GetFloat();
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index 8f5e862555c..99ec263b8f9 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -91,7 +91,10 @@ public:
pathid = target->GetWaypointPath();
else
{
- QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data");
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_MAX_ID);
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
uint32 maxpathid = result->Fetch()->GetInt32();
pathid = maxpathid+1;
handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started.");
@@ -109,7 +112,9 @@ public:
return true;
}
- QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'", pathid);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT);
+ stmt->setUInt32(0, pathid);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
point = (*result)[0].GetUInt32();
@@ -117,7 +122,7 @@ public:
Player* player = handler->GetSession()->GetPlayer();
//Map* map = player->GetMap();
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);
+ stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point + 1);
@@ -173,9 +178,12 @@ public:
}
guidLow = target->GetDBTableGUIDLow();
- QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'", guidLow);
- PreparedStatement* stmt;
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID);
+
+ stmt->setUInt32(0, guidLow);
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
@@ -223,6 +231,7 @@ public:
sWaypointMgr->ReloadPath(id);
return true;
}
+
static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/)
{
@@ -276,7 +285,8 @@ public:
std::string show = show_str;
// Check
- if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false;
+ if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid"))
+ return false;
char* arg_id = strtok(NULL, " ");
uint32 id = 0;
@@ -288,7 +298,9 @@ public:
if (id)
{
- QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
+ stmt->setUInt32(0, id);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -305,10 +317,13 @@ public:
}
else
{
- QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts");
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPTS_MAX_ID);
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
id = result->Fetch()->GetUInt32();
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
+ stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
stmt->setUInt32(0, id + 1);
@@ -334,7 +349,9 @@ public:
float a8, a9, a10, a11;
char const* a7;
- QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID);
+ stmt->setUInt32(0, id);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -367,7 +384,11 @@ public:
{
id = atoi(arg_id);
- QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
+
+ stmt->setUInt32(0, id);
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
@@ -445,7 +466,9 @@ public:
}
else
{
- QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid='%u'", id);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
+ stmt->setUInt32(0, id);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -565,7 +588,9 @@ public:
// User did select a visual waypoint?
// Check the creature
- QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
+ stmt->setUInt32(0, wpGuid);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -576,9 +601,17 @@ public:
// Here we search for all waypoints that only differ in one from 1 thousand
// (0.001) - There is no other way to compare C++ floats with mySQL floats
// See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
- const char* maxDIFF = "0.01";
- result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
- target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
+ std::string maxDiff = "0.01";
+
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_POS);
+ stmt->setFloat(0, target->GetPositionX());
+ stmt->setString(1, maxDiff);
+ stmt->setFloat(2, target->GetPositionY());
+ stmt->setString(3, maxDiff);
+ stmt->setFloat(4, target->GetPositionZ());
+ stmt->setString(5, maxDiff);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
@@ -605,7 +638,7 @@ public:
return false;
}
- if (show == "del" && target)
+ if (show == "del")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
@@ -615,9 +648,12 @@ public:
if (wpGuid != 0)
{
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
- wpCreature->CombatStop();
- wpCreature->DeleteFromDB();
- wpCreature->AddObjectToRemoveList();
+ if (wpCreature)
+ {
+ wpCreature->CombatStop();
+ wpCreature->DeleteFromDB();
+ wpCreature->AddObjectToRemoveList();
+ }
}
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
@@ -638,7 +674,7 @@ public:
return true;
} // del
- if (show == "move" && target)
+ if (show == "move")
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
@@ -652,16 +688,20 @@ public:
// Respawn the owner of the waypoints
if (wpGuid != 0)
{
- wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
- wpCreature->CombatStop();
- wpCreature->DeleteFromDB();
- wpCreature->AddObjectToRemoveList();
+ wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
+ if (wpCreature)
+ {
+ wpCreature->CombatStop();
+ wpCreature->DeleteFromDB();
+ wpCreature->AddObjectToRemoveList();
+ }
// re-create
Creature* wpCreature2 = new Creature;
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
+ wpCreature2 = NULL;
return false;
}
@@ -672,6 +712,7 @@ public:
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
+ wpCreature2 = NULL;
return false;
}
//sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
@@ -755,7 +796,6 @@ public:
}
std::string show = show_str;
- uint32 Maxpoint;
//handler->PSendSysMessage("wpshow - show: %s", show);
@@ -770,7 +810,11 @@ public:
return false;
}
- QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow());
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
+
+ stmt->setUInt32(0, target->GetGUIDLow());
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -802,7 +846,11 @@ public:
if (show == "on")
{
- QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = '%u'", pathid);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID);
+
+ stmt->setUInt32(0, pathid);
+
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -814,7 +862,11 @@ public:
handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid);
// Delete all visuals for this NPC
- QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid);
+ stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID);
+
+ stmt->setUInt32(0, pathid);
+
+ PreparedQueryResult result2 = WorldDatabase.Query(stmt);
if (result2)
{
@@ -897,7 +949,7 @@ public:
if (target)
{
wpCreature->SetDisplayId(target->GetDisplayId());
- wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
+ wpCreature->SetObjectScale(0.5f);
wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point);
}
}
@@ -911,7 +963,10 @@ public:
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
- QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z FROM waypoint_data WHERE point='1' AND id = '%u'", pathid);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
+ stmt->setUInt32(0, pathid);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid);
@@ -948,7 +1003,7 @@ public:
if (target)
{
creature->SetDisplayId(target->GetDisplayId());
- creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
+ creature->SetObjectScale(0.5f);
}
return true;
@@ -958,13 +1013,10 @@ public:
{
handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid);
- QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'", pathid);
- if (result)
- Maxpoint = (*result)[0].GetUInt32();
- else
- Maxpoint = 0;
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID);
+ stmt->setUInt32(0, pathid);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
- result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid);
@@ -1000,7 +1052,7 @@ public:
if (target)
{
creature->SetDisplayId(target->GetDisplayId());
- creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
+ creature->SetObjectScale(0.5f);
}
return true;
@@ -1008,7 +1060,10 @@ public:
if (show == "off")
{
- QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1);
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID);
+ stmt->setUInt32(0, 1);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+
if (!result)
{
handler->SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND);
@@ -1041,7 +1096,7 @@ public:
}
while (result->NextRow());
// set "wpguid" column to "empty" - no visual waypoint spawned
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_ALL_WAYPOINT_DATA_WPGUID);
+ stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID);
WorldDatabase.Execute(stmt);
//WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");