mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/DBLayer: Convert PExecute() queries to prepared statements No. 4
This commit is contained in:
@@ -254,12 +254,12 @@ public:
|
||||
wait = 0;
|
||||
|
||||
// Update movement type
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
|
||||
|
||||
stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE));
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
if (creature && creature->GetWaypointPath())
|
||||
{
|
||||
@@ -499,7 +499,12 @@ public:
|
||||
|
||||
creature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags);
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, creature->GetEntry());
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_NPCFLAG);
|
||||
|
||||
stmt->setUInt32(0, npcFlags);
|
||||
stmt->setUInt32(1, creature->GetEntry());
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->SendSysMessage(LANG_VALUE_SAVED_REJOIN);
|
||||
|
||||
@@ -645,7 +650,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_POSITION);
|
||||
|
||||
stmt->setFloat(0, x);
|
||||
stmt->setFloat(1, y);
|
||||
stmt->setFloat(2, z);
|
||||
stmt->setFloat(3, o);
|
||||
stmt->setUInt32(4, lowguid);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATUREMOVED);
|
||||
return true;
|
||||
}
|
||||
@@ -892,10 +906,10 @@ public:
|
||||
mtype = RANDOM_MOTION_TYPE;
|
||||
|
||||
Creature* creature = handler->getSelectedCreature();
|
||||
uint32 u_guidlow = 0;
|
||||
uint32 guidLow = 0;
|
||||
|
||||
if (creature)
|
||||
u_guidlow = creature->GetDBTableGUIDLow();
|
||||
guidLow = creature->GetDBTableGUIDLow();
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -908,7 +922,14 @@ public:
|
||||
creature->Respawn();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u", option, mtype, u_guidlow);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_DISTANCE);
|
||||
|
||||
stmt->setFloat(0, option);
|
||||
stmt->setUInt8(1, uint8(mtype));
|
||||
stmt->setUInt32(2, guidLow);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST, option);
|
||||
return true;
|
||||
}
|
||||
@@ -924,9 +945,9 @@ public:
|
||||
if (!stime)
|
||||
return false;
|
||||
|
||||
int i_stime = atoi((char*)stime);
|
||||
int spawnTime = atoi((char*)stime);
|
||||
|
||||
if (i_stime < 0)
|
||||
if (spawnTime < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -934,16 +955,22 @@ public:
|
||||
}
|
||||
|
||||
Creature* creature = handler->getSelectedCreature();
|
||||
uint32 u_guidlow = 0;
|
||||
uint32 guidLow = 0;
|
||||
|
||||
if (creature)
|
||||
u_guidlow = creature->GetDBTableGUIDLow();
|
||||
guidLow = creature->GetDBTableGUIDLow();
|
||||
else
|
||||
return false;
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u", i_stime, u_guidlow);
|
||||
creature->SetRespawnDelay((uint32)i_stime);
|
||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, i_stime);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS);
|
||||
|
||||
stmt->setUInt32(0, uint32(spawnTime));
|
||||
stmt->setUInt32(1, guidLow);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
creature->SetRespawnDelay((uint32)spawnTime);
|
||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1206,8 +1233,15 @@ public:
|
||||
CreatureGroupMap[lowguid] = group_member;
|
||||
creature->SearchFormation();
|
||||
|
||||
WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u', '%u', '%f', '%f', '%u')",
|
||||
leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
|
||||
|
||||
stmt->setUInt32(0, leaderGUID);
|
||||
stmt->setUInt32(1, lowguid);
|
||||
stmt->setFloat(2, group_member->follow_dist);
|
||||
stmt->setFloat(3, group_member->follow_angle);
|
||||
stmt->setUInt32(4, uint32(group_member->groupAI));
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID);
|
||||
|
||||
|
||||
@@ -117,8 +117,15 @@ public:
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
//Map* map = player->GetMap();
|
||||
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u', '%u', '%f', '%f', '%f')",
|
||||
pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);
|
||||
|
||||
stmt->setUInt32(0, pathid);
|
||||
stmt->setUInt32(1, point + 1);
|
||||
stmt->setFloat(2, player->GetPositionX());
|
||||
stmt->setFloat(3, player->GetPositionY());
|
||||
stmt->setFloat(4, player->GetPositionZ());
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1, "|r|cff00ff00 created. ");
|
||||
return true;
|
||||
@@ -136,7 +143,7 @@ public:
|
||||
path_number = strtok((char*)args, " ");
|
||||
|
||||
uint32 pathid = 0;
|
||||
uint32 guidlow = 0;
|
||||
uint32 guidLow = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
// Did player provide a path_id?
|
||||
@@ -165,15 +172,34 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
guidlow = target->GetDBTableGUIDLow();
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'", guidlow);
|
||||
guidLow = target->GetDBTableGUIDLow();
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'", guidLow);
|
||||
|
||||
PreparedStatement* stmt;
|
||||
|
||||
if (result)
|
||||
WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow);
|
||||
else
|
||||
WorldDatabase.PExecute("INSERT INTO creature_addon(guid, path_id) VALUES ('%u', '%u')", guidlow, pathid);
|
||||
{
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ADDON_PATH);
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow);
|
||||
stmt->setUInt32(0, pathid);
|
||||
stmt->setUInt32(1, guidLow);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_ADDON);
|
||||
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->setUInt32(1, pathid);
|
||||
}
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
|
||||
|
||||
stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE));
|
||||
stmt->setUInt32(1, guidLow);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
target->LoadPath(pathid);
|
||||
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
|
||||
@@ -208,15 +234,27 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 guidlow = target->GetDBTableGUIDLow();
|
||||
uint32 guildLow = target->GetDBTableGUIDLow();
|
||||
|
||||
if (target->GetCreatureAddon())
|
||||
{
|
||||
if (target->GetCreatureAddon()->path_id != 0)
|
||||
{
|
||||
WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", guidlow);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
|
||||
|
||||
stmt->setUInt32(0, guildLow);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
target->UpdateWaypointID(0);
|
||||
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
|
||||
|
||||
stmt->setUInt8(0, uint8(IDLE_MOTION_TYPE));
|
||||
stmt->setUInt32(1, guildLow);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
target->LoadPath(0);
|
||||
target->SetDefaultMovementType(IDLE_MOTION_TYPE);
|
||||
target->GetMotionMaster()->MoveTargetedHome();
|
||||
@@ -254,7 +292,12 @@ public:
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id);
|
||||
}
|
||||
else
|
||||
@@ -264,7 +307,13 @@ public:
|
||||
{
|
||||
QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts");
|
||||
id = result->Fetch()->GetUInt32();
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
|
||||
|
||||
stmt->setUInt32(0, id + 1);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: |r|cff00ffff", id+1);
|
||||
}
|
||||
|
||||
@@ -322,7 +371,12 @@ public:
|
||||
|
||||
if (result)
|
||||
{
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_SCRIPT);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: Waypoint script removed: ", id);
|
||||
}
|
||||
else
|
||||
@@ -379,8 +433,15 @@ public:
|
||||
{
|
||||
uint32 newid = atoi(arg_3);
|
||||
handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'",
|
||||
newid, id); return true;
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID);
|
||||
|
||||
stmt->setUInt32(0, newid);
|
||||
stmt->setUInt32(1, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -394,36 +455,56 @@ public:
|
||||
|
||||
if (arg_str_2 == "posx")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'",
|
||||
(float)(atof(arg_3)), id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_X);
|
||||
|
||||
stmt->setFloat(0, float(atof(arg_3)));
|
||||
stmt->setUInt32(1, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "posy")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'",
|
||||
(float)(atof(arg_3)), id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Y);
|
||||
|
||||
stmt->setFloat(0, float(atof(arg_3)));
|
||||
stmt->setUInt32(1, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "posz")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'",
|
||||
(float)(atof(arg_3)), id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Z);
|
||||
|
||||
stmt->setFloat(0, float(atof(arg_3)));
|
||||
stmt->setUInt32(1, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "orientation")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'",
|
||||
(float)(atof(arg_3)), id);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_O);
|
||||
|
||||
stmt->setFloat(0, float(atof(arg_3)));
|
||||
stmt->setUInt32(1, id);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "dataint")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'",
|
||||
arg_2, atoi(arg_3), id);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
@@ -431,8 +512,7 @@ public:
|
||||
{
|
||||
std::string arg_str_3 = arg_3;
|
||||
WorldDatabase.EscapeString(arg_str_3);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'",
|
||||
arg_2, arg_str_3.c_str(), id);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", arg_2, arg_str_3.c_str(), id); // Query can't be a prepared statement
|
||||
}
|
||||
}
|
||||
handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated.");
|
||||
@@ -540,10 +620,19 @@ public:
|
||||
wpCreature->AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'",
|
||||
pathid, point);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'",
|
||||
pathid, point);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
|
||||
|
||||
stmt->setUInt32(0, pathid);
|
||||
stmt->setUInt32(1, point);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT);
|
||||
|
||||
stmt->setUInt32(0, pathid);
|
||||
stmt->setUInt32(1, point);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_REMOVED);
|
||||
return true;
|
||||
@@ -588,8 +677,15 @@ public:
|
||||
//sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f', position_y = '%f', position_z = '%f' where id = '%u' AND point='%u'",
|
||||
chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);
|
||||
|
||||
stmt->setFloat(0, chr->GetPositionX());
|
||||
stmt->setFloat(1, chr->GetPositionY());
|
||||
stmt->setFloat(2, chr->GetPositionZ());
|
||||
stmt->setUInt32(3, pathid);
|
||||
stmt->setUInt32(4, point);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
|
||||
}
|
||||
@@ -601,16 +697,14 @@ public:
|
||||
if (text == 0)
|
||||
{
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'",
|
||||
show_str, pathid, point);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement
|
||||
}
|
||||
else
|
||||
{
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
std::string text2 = text;
|
||||
WorldDatabase.EscapeString(text2);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'",
|
||||
show_str, text2.c_str(), pathid, point);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
|
||||
@@ -735,7 +829,12 @@ public:
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
|
||||
|
||||
stmt->setUInt32(0, wpguid);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -777,8 +876,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// set "wpguid" column to the visual waypoint
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
|
||||
// Set "wpguid" column to the visual waypoint
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
|
||||
|
||||
stmt->setInt32(0, int32(wpCreature->GetGUIDLow()));
|
||||
stmt->setUInt32(1, pathid);
|
||||
stmt->setUInt32(2, point);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
@@ -920,7 +1025,12 @@ public:
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
|
||||
|
||||
stmt->setUInt32(0, guid);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -931,7 +1041,9 @@ public:
|
||||
}
|
||||
while (result->NextRow());
|
||||
// set "wpguid" column to "empty" - no visual waypoint spawned
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'");
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WOLRD_UPD_ALL_WAYPOINT_DATA_WPGUID);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
//WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");
|
||||
|
||||
if (hasError)
|
||||
|
||||
@@ -38,4 +38,26 @@ void WorldDatabaseConnection::DoPrepareStatements()
|
||||
PREPARE_STATEMENT(WORLD_DEL_NPC_VENDOR, "DELETE FROM npc_vendor WHERE entry = ? AND item = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_MOVEMENT_TYPE, "UPDATE creature SET MovementType = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_FACTION, "UPDATE creature_template SET faction_A = ?, faction_H = ? WHERE entry = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_NPCFLAG, "UPDATE creature_template SET npcflag = ? WHERE entry = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_POSITION, "UPDATE creature SET position_x = ?, position_y = ?, position_z = ?, orientation = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_SPAWN_DISTANCE, "UPDATE creature SET spawndist = ?, MovementType = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_SPAWN_TIME_SECS, "UPDATE creature SET spawntimesecs = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_INS_CREATURE_FORMATION, "INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_INS_WAYPOINT_DATA, "INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_DEL_WAYPOINT_DATA, "DELETE FROM waypoint_data WHERE id = ? AND point = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_DATA_POINT, "UPDATE waypoint_data SET point = point - 1 WHERE id = ? AND point > ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_DATA_POSITION, "UPDATE waypoint_data SET position_x = ?, position_y = ?, position_z = ? where id = ? AND point = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WOLRD_UPD_ALL_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = 0", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_INS_CREATURE_ADDON, "INSERT INTO creature_addon(guid, path_id) VALUES (?, ?)", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_CREATURE_ADDON_PATH, "UPDATE creature_addon SET path_id = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_DEL_CREATURE_ADDON, "DELETE FROM creature_addon WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_INS_WAYPOINT_SCRIPT, "INSERT INTO waypoint_scripts (guid) VALUES (?)", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_DEL_WAYPOINT_SCRIPT, "DELETE FROM waypoint_scripts WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_SCRIPT_ID, "UPDATE waypoint_scripts SET id = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_SCRIPT_X, "UPDATE waypoint_scripts SET x = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_SCRIPT_Y, "UPDATE waypoint_scripts SET y = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_SCRIPT_Z, "UPDATE waypoint_scripts SET z = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_UPD_WAYPOINT_SCRIPT_O, "UPDATE waypoint_scripts SET o = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PREPARE_STATEMENT(WORLD_DEL_CREATURE, "DELETE FROM creature WHERE guid = ?", CONNECTION_ASYNC);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,28 @@ enum WorldDatabaseStatements
|
||||
WORLD_DEL_NPC_VENDOR,
|
||||
WORLD_UPD_CREATURE_MOVEMENT_TYPE,
|
||||
WORLD_UPD_CREATURE_FACTION,
|
||||
WORLD_UPD_CREATURE_NPCFLAG,
|
||||
WORLD_UPD_CREATURE_POSITION,
|
||||
WORLD_UPD_CREATURE_SPAWN_DISTANCE,
|
||||
WORLD_UPD_CREATURE_SPAWN_TIME_SECS,
|
||||
WORLD_INS_CREATURE_FORMATION,
|
||||
WORLD_INS_WAYPOINT_DATA,
|
||||
WORLD_DEL_WAYPOINT_DATA,
|
||||
WORLD_UPD_WAYPOINT_DATA_POINT,
|
||||
WORLD_UPD_WAYPOINT_DATA_POSITION,
|
||||
WORLD_UPD_WAYPOINT_DATA_WPGUID,
|
||||
WOLRD_UPD_ALL_WAYPOINT_DATA_WPGUID,
|
||||
WORLD_UPD_CREATURE_ADDON_PATH,
|
||||
WORLD_INS_CREATURE_ADDON,
|
||||
WORLD_DEL_CREATURE_ADDON,
|
||||
WORLD_INS_WAYPOINT_SCRIPT,
|
||||
WORLD_DEL_WAYPOINT_SCRIPT,
|
||||
WORLD_UPD_WAYPOINT_SCRIPT_ID,
|
||||
WORLD_UPD_WAYPOINT_SCRIPT_X,
|
||||
WORLD_UPD_WAYPOINT_SCRIPT_Y,
|
||||
WORLD_UPD_WAYPOINT_SCRIPT_Z,
|
||||
WORLD_UPD_WAYPOINT_SCRIPT_O,
|
||||
WORLD_DEL_CREATURE,
|
||||
|
||||
MAX_WORLDDATABASE_STATEMENTS,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user