aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp28
-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_reload.cpp154
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp5
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp101
6 files changed, 189 insertions, 121 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 86818e2c931..09c5c6c6007 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,18 +212,15 @@ 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)
{
@@ -233,7 +233,7 @@ public:
else
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
- } while (resultDB->NextRow());
+ } while (result->NextRow());
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
return true;
@@ -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);
diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp
index 9b9d1cfd146..d449b3617f7 100644
--- a/src/server/scripts/Commands/cs_gm.cpp
+++ b/src/server/scripts/Commands/cs_gm.cpp
@@ -156,7 +156,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_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 1520a944f6e..5f192ffceee 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -413,7 +413,11 @@ 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, HoverHeight, 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);
@@ -434,87 +438,87 @@ public:
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();
+ 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();
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)->HoverHeight = fields[67].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->ModHealth = fields[68].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->ModMana = fields[69].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->ModArmor = fields[70].GetFloat();
- const_cast<CreatureTemplate*>(cInfo)->RacialLeader = fields[71].GetBool();
- const_cast<CreatureTemplate*>(cInfo)->questItems[0] = fields[72].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[1] = fields[73].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[2] = fields[74].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[3] = fields[75].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[4] = fields[76].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->questItems[5] = fields[77].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->movementId = fields[78].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->RegenHealth = fields[79].GetBool();
- const_cast<CreatureTemplate*>(cInfo)->equipmentId = fields[80].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)->HoverHeight = fields[67].GetFloat();
+ const_cast<CreatureTemplate*>(cInfo)->ModHealth = fields[68].GetFloat();
+ const_cast<CreatureTemplate*>(cInfo)->ModMana = fields[69].GetFloat();
+ const_cast<CreatureTemplate*>(cInfo)->ModArmor = fields[70].GetFloat();
+ const_cast<CreatureTemplate*>(cInfo)->RacialLeader = fields[71].GetBool();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[0] = fields[72].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[1] = fields[73].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[2] = fields[74].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[3] = fields[75].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[4] = fields[76].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->questItems[5] = fields[77].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->movementId = fields[78].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->RegenHealth = fields[79].GetBool();
+ const_cast<CreatureTemplate*>(cInfo)->equipmentId = fields[80].GetUInt32();
const_cast<CreatureTemplate*>(cInfo)->MechanicImmuneMask = fields[81].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->flags_extra = fields[82].GetUInt32();
- const_cast<CreatureTemplate*>(cInfo)->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString());
+ const_cast<CreatureTemplate*>(cInfo)->flags_extra = fields[82].GetUInt32();
+ const_cast<CreatureTemplate*>(cInfo)->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString());
sObjectMgr->CheckCreatureTemplate(cInfo);
}
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 5054bd83f32..89646c23ea0 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -131,7 +131,10 @@ 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();
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index eb59007b40b..f29dd8a5069 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)
{
@@ -290,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)
{
@@ -307,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);
@@ -336,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)
{
@@ -369,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)
{
@@ -447,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)
{
@@ -567,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)
{
@@ -578,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);
@@ -765,7 +796,6 @@ public:
}
std::string show = show_str;
- uint32 Maxpoint;
//handler->PSendSysMessage("wpshow - show: %s", show);
@@ -780,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)
{
@@ -812,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)
{
@@ -824,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)
{
@@ -921,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);
@@ -968,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);
@@ -1018,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);
@@ -1051,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'");