diff options
| author | leak <leak@bitmx.net> | 2012-03-25 16:22:24 +0200 |
|---|---|---|
| committer | leak <leak@bitmx.net> | 2012-03-25 16:25:06 +0200 |
| commit | c6cbe4c77c5fcd4d296f31d471b4806ebe3d099d (patch) | |
| tree | e36e04784374d754c85a06fec5a1e259593fccbb /src/server/game/Entities/GameObject | |
| parent | 56fac5e1afc0596c32dc349d5bc0218fd8a0b13d (diff) | |
Core/DBLayer: Convert PAppend() queries to prepared statements No.1
Diffstat (limited to 'src/server/game/Entities/GameObject')
| -rwxr-xr-x | src/server/game/Entities/GameObject/GameObject.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 1cd8fa17183..910e9c86b42 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -686,29 +686,34 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) data.spawnMask = spawnMask; data.artKit = GetGoArtKit(); - // update in DB - std::ostringstream ss; - ss << "INSERT INTO gameobject VALUES (" - << m_DBTableGuid << ',' - << GetEntry() << ',' - << mapid << ',' - << uint32(spawnMask) << ',' // cast to prevent save as symbol - << uint16(GetPhaseMask()) << ',' // prevent out of range error - << GetPositionX() << ',' - << GetPositionY() << ',' - << GetPositionZ() << ',' - << GetOrientation() << ',' - << GetFloatValue(GAMEOBJECT_PARENTROTATION) << ',' - << GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ',' - << GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ',' - << GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ',' - << m_respawnDelayTime << ',' - << uint32(GetGoAnimProgress()) << ',' - << uint32(GetGoState()) << ')'; - + // Update in DB SQLTransaction trans = WorldDatabase.BeginTransaction(); - trans->PAppend("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid); - trans->Append(ss.str().c_str()); + + uint8 index = 0; + + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT); + stmt->setUInt32(0, m_DBTableGuid); + trans->Append(stmt); + + stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT); + stmt->setUInt32(index++, m_DBTableGuid); + stmt->setUInt32(index++, GetEntry()); + stmt->setUInt16(index++, uint16(mapid)); + stmt->setUInt8(index++, spawnMask); + stmt->setUInt16(index++, uint16(GetPhaseMask())); + stmt->setFloat(index++, GetPositionX()); + stmt->setFloat(index++, GetPositionY()); + stmt->setFloat(index++, GetPositionZ()); + stmt->setFloat(index++, GetOrientation()); + stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION)); + stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+1)); + stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+2)); + stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+3)); + stmt->setInt32(index++, int32(m_respawnDelayTime)); + stmt->setUInt8(index++, GetGoAnimProgress()); + stmt->setUInt8(index++, uint8(GetGoState())); + trans->Append(stmt); + WorldDatabase.CommitTransaction(trans); } |
