From b2087c8d08a68bc86bf4790bd4d9d972577c12e8 Mon Sep 17 00:00:00 2001 From: Winfidonarleyan Date: Wed, 2 Feb 2022 06:41:31 +0700 Subject: [PATCH] feat(DBLayer): add support new db api --- src/Transmogrification.cpp | 18 +++++++++--------- src/transmog_scripts.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Transmogrification.cpp b/src/Transmogrification.cpp index d8e68c3..7de5658 100644 --- a/src/Transmogrification.cpp +++ b/src/Transmogrification.cpp @@ -45,7 +45,7 @@ void Transmogrification::LoadPlayerSets(ObjectGuid pGUID) presetByName[pGUID].clear(); - QueryResult result = CharacterDatabase.PQuery("SELECT `PresetID`, `SetName`, `SetData` FROM `custom_transmogrification_sets` WHERE Owner = %u", pGUID.GetCounter()); + QueryResult result = CharacterDatabase.Query("SELECT `PresetID`, `SetName`, `SetData` FROM `custom_transmogrification_sets` WHERE Owner = {}", pGUID.GetCounter()); if (result) { do @@ -79,7 +79,7 @@ void Transmogrification::LoadPlayerSets(ObjectGuid pGUID) else // should be deleted on startup, so this never runs (shouldnt..) { presetById[pGUID].erase(PresetID); - CharacterDatabase.PExecute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = %u AND PresetID = %u", pGUID.GetCounter(), PresetID); + CharacterDatabase.Execute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = {} AND PresetID = {}", pGUID.GetCounter(), PresetID); } } while (result->NextRow()); } @@ -287,7 +287,7 @@ void Transmogrification::SetFakeEntry(Player* player, uint32 newEntry, uint8 /*s ObjectGuid itemGUID = itemTransmogrified->GetGUID(); entryMap[player->GetGUID()][itemGUID] = newEntry; dataMap[itemGUID] = player->GetGUID(); - CharacterDatabase.PExecute("REPLACE INTO custom_transmogrification (GUID, FakeEntry, Owner) VALUES (%u, %u, %u)", itemGUID.GetCounter(), newEntry, player->GetGUID().GetCounter()); + CharacterDatabase.Execute("REPLACE INTO custom_transmogrification (GUID, FakeEntry, Owner) VALUES ({}, {}, {})", itemGUID.GetCounter(), newEntry, player->GetGUID().GetCounter()); UpdateItem(player, itemTransmogrified); } @@ -297,7 +297,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid // slot of the transmogrified item if (slot >= EQUIPMENT_SLOT_END) { - // TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an item (lowguid: %u) with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID), slot); + // TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: {}, name: {}) tried to transmogrify an item (lowguid: {}) with a wrong slot ({}) when transmogrifying items.", player->GetGUIDLow(), player->GetName(), GUID_LOPART(itemGUID), slot); return LANG_ERR_TRANSMOG_INVALID_SLOT; } @@ -308,7 +308,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid itemTransmogrifier = player->GetItemByGuid(itemGUID); if (!itemTransmogrifier) { - //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (lowguid: %u).", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID)); + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: {}, name: {}) tried to transmogrify with an invalid item (lowguid: {}).", player->GetGUIDLow(), player->GetName(), GUID_LOPART(itemGUID)); return LANG_ERR_TRANSMOG_MISSING_SRC_ITEM; } } @@ -317,7 +317,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); if (!itemTransmogrified) { - //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName().c_str(), slot); + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: {}, name: {}) tried to transmogrify an invalid item in a valid slot (slot: {}).", player->GetGUIDLow(), player->GetName(), slot); return LANG_ERR_TRANSMOG_MISSING_DEST_ITEM; } @@ -330,7 +330,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid { if (!CanTransmogrifyItemWithItem(player, itemTransmogrified->GetTemplate(), itemTransmogrifier->GetTemplate())) { - //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); + //TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: {}, name: {}) failed CanTransmogrifyItemWithItem ({} with {}).", player->GetGUIDLow(), player->GetName(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry()); return LANG_ERR_TRANSMOG_INVALID_ITEMS; } @@ -682,9 +682,9 @@ void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, Chara dataMap.erase(itemGUID); } if (trans) - (*trans)->PAppend("DELETE FROM custom_transmogrification WHERE GUID = %u", itemLowGuid); + (*trans)->Append("DELETE FROM custom_transmogrification WHERE GUID = {}", itemLowGuid); else - CharacterDatabase.PExecute("DELETE FROM custom_transmogrification WHERE GUID = %u", itemGUID.GetCounter()); + CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE GUID = {}", itemGUID.GetCounter()); } bool Transmogrification::GetEnableTransmogInfo() const diff --git a/src/transmog_scripts.cpp b/src/transmog_scripts.cpp index 4ebb0cf..bc3ff3a 100644 --- a/src/transmog_scripts.cpp +++ b/src/transmog_scripts.cpp @@ -178,7 +178,7 @@ public: return true; } // action = presetID - CharacterDatabase.PExecute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = %u AND PresetID = %u", player->GetGUID().GetCounter(), action); + CharacterDatabase.Execute("DELETE FROM `custom_transmogrification_sets` WHERE Owner = {} AND PresetID = {}", player->GetGUID().GetCounter(), action); sT->presetById[player->GetGUID()][action].clear(); sT->presetById[player->GetGUID()].erase(action); sT->presetByName[player->GetGUID()].erase(action); @@ -309,7 +309,7 @@ public: sT->presetById[player->GetGUID()][presetID][it->first] = it->second; } sT->presetByName[player->GetGUID()][presetID] = name; // Make sure code doesnt mess up SQL! - CharacterDatabase.PExecute("REPLACE INTO `custom_transmogrification_sets` (`Owner`, `PresetID`, `SetName`, `SetData`) VALUES (%u, %u, \"%s\", \"%s\")", player->GetGUID().GetCounter(), uint32(presetID), name.c_str(), ss.str().c_str()); + CharacterDatabase.Execute("REPLACE INTO `custom_transmogrification_sets` (`Owner`, `PresetID`, `SetName`, `SetData`) VALUES ({}, {}, \"{}\", \"{}\")", player->GetGUID().GetCounter(), uint32(presetID), name, ss.str()); if (cost) player->ModifyMoney(-cost); break; @@ -405,7 +405,7 @@ public: { ObjectGuid playerGUID = player->GetGUID(); sT->entryMap.erase(playerGUID); - QueryResult result = CharacterDatabase.PQuery("SELECT GUID, FakeEntry FROM custom_transmogrification WHERE Owner = %u", player->GetGUID().GetCounter()); + QueryResult result = CharacterDatabase.Query("SELECT GUID, FakeEntry FROM custom_transmogrification WHERE Owner = {}", player->GetGUID().GetCounter()); if (result) { do @@ -419,8 +419,8 @@ public: } else { - //sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: %u, itemGUID: %u, playerGUID: %u) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow()); - // CharacterDatabase.PExecute("DELETE FROM custom_transmogrification WHERE FakeEntry = %u", fakeEntry); + //sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: {}, itemGUID: {}, playerGUID: {}) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow()); + // CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE FakeEntry = {}", fakeEntry); } } while (result->NextRow());