Skip to content

Commit

Permalink
[11081] Beautify some SQL log queries and remove not needed enclose c…
Browse files Browse the repository at this point in the history
…haracter

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Jan 29, 2011
1 parent 56e298a commit a527201
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
// updated in DB
WorldDatabase.BeginTransaction();

WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", m_DBTableGuid);

std::ostringstream ss;
ss << "INSERT INTO creature VALUES ("
Expand Down Expand Up @@ -1359,12 +1359,12 @@ void Creature::DeleteFromDB()
sObjectMgr.DeleteCreatureData(m_DBTableGuid);

WorldDatabase.BeginTransaction();
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", m_DBTableGuid);
WorldDatabase.CommitTransaction();
}

Expand Down
14 changes: 7 additions & 7 deletions src/game/Level2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(char* args)
sWaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0);

// update movement type
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE,lowguid);
if (pCreature)
{
pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
Expand Down Expand Up @@ -2965,7 +2965,7 @@ bool ChatHandler::HandleWpAddCommand(char* args)
target->SaveToDB();
}
else
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE,lowguid);

PSendSysMessage(LANG_WAYPOINT_ADDED, point, lowguid);

Expand Down Expand Up @@ -3574,7 +3574,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
{
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpGuid);
hasError = true;
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", wpGuid);
}
else
{
Expand Down Expand Up @@ -3628,7 +3628,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
wpCreature->SetVisibility(VISIBILITY_OFF);
DEBUG_LOG("DEBUG: UPDATE creature_movement SET wpguid = '%u", wpCreature->GetGUIDLow());
// set "wpguid" column to the visual waypoint
WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), lowguid, point);
WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid=%u WHERE id=%u and point=%u", wpCreature->GetGUIDLow(), lowguid, point);

wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
Expand Down Expand Up @@ -3754,7 +3754,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)

if (show == "off")
{
QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", VISUAL_WAYPOINT);
QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id=%u", VISUAL_WAYPOINT);
if (!result)
{
SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND);
Expand All @@ -3771,7 +3771,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
{
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpGuid);
hasError = true;
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", wpGuid);
}
else
{
Expand All @@ -3780,7 +3780,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
}
}while(result->NextRow());
// set "wpguid" column to "empty" - no visual waypoint spawned
WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");
WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid=0 WHERE wpguid <> 0");

if (hasError)
{
Expand Down
12 changes: 6 additions & 6 deletions src/game/WaypointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ void WaypointManager::AddLastNode(uint32 id, float x, float y, float z, float o,
void WaypointManager::AddAfterNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid)
{
for(uint32 i = GetLastPoint(id, 0); i > point; i--)
WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point+1 WHERE id='%u' AND point='%u'", id, i);
WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point+1 WHERE id=%u AND point=%u", id, i);

_addNode(id, point + 1, x, y, z, o, delay, wpGuid);
}
Expand All @@ -463,7 +463,7 @@ void WaypointManager::_addNode(uint32 id, uint32 point, float x, float y, float
{
if(point == 0) return; // counted from 1 in the DB
WorldDatabase.PExecuteLog("INSERT INTO creature_movement (id,point,position_x,position_y,position_z,orientation,wpguid,waittime) "
"VALUES ('%u','%u','%f', '%f', '%f', '%f', '%u', '%u')",
"VALUES (%u,%u, %f,%f,%f,%f, %u,%u)",
id, point, x, y, z, o, wpGuid, delay);
WaypointPathMap::iterator itr = m_pathMap.find(id);
if(itr == m_pathMap.end())
Expand All @@ -489,16 +489,16 @@ uint32 WaypointManager::GetLastPoint(uint32 id, uint32 default_notfound)
void WaypointManager::DeleteNode(uint32 id, uint32 point)
{
if(point == 0) return; // counted from 1 in the DB
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id='%u' AND point='%u'", id, point);
WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point-1 WHERE id='%u' AND point>'%u'", id, point);
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u AND point=%u", id, point);
WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point-1 WHERE id=%u AND point>%u", id, point);
WaypointPathMap::iterator itr = m_pathMap.find(id);
if(itr != m_pathMap.end() && point <= itr->second.size())
itr->second.erase(itr->second.begin() + (point-1));
}

void WaypointManager::DeletePath(uint32 id)
{
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id='%u'", id);
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", id);
WaypointPathMap::iterator itr = m_pathMap.find(id);
if(itr != m_pathMap.end())
_clearPath(itr->second);
Expand All @@ -511,7 +511,7 @@ void WaypointManager::DeletePath(uint32 id)
void WaypointManager::SetNodePosition(uint32 id, uint32 point, float x, float y, float z)
{
if(point == 0) return; // counted from 1 in the DB
WorldDatabase.PExecuteLog("UPDATE creature_movement SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'", x, y, z, id, point);
WorldDatabase.PExecuteLog("UPDATE creature_movement SET position_x=%f, position_y=%f, position_z=%f WHERE id=%u AND point=%u", x, y, z, id, point);
WaypointPathMap::iterator itr = m_pathMap.find(id);
if(itr != m_pathMap.end() && point <= itr->second.size())
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11080"
#define REVISION_NR "11081"
#endif // __REVISION_NR_H__

4 comments on commit a527201

@Axxus
Copy link

@Axxus Axxus commented on a527201 Jan 29, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautify? IMHO whatever = X is prettier than whatever=x;

@scriptdev2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yes that is indeed a matter of opinion. Bad selection of word really. Maybe we would need a more defined style for the SQL, and update them all according to that.

@Ambal
Copy link
Contributor

@Ambal Ambal commented on a527201 Jan 29, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautification turned into uglification, NoFantasy, except the '%u' format fix which is acceptable.

@NoFantasy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's pretty safe to say there are different opinions :) I'll make a post in the forums so we at least can see if we are able to make a unified style on the SQL (SQL that goes in to the log files was my main concern)

Please sign in to comment.