feat(DBLayer): add support new db api

feat(DBLayer): add support new db api
This commit is contained in:
Kitzunu
2022-02-05 00:38:22 +01:00
committed by GitHub
2 changed files with 14 additions and 14 deletions

View File

@@ -45,7 +45,7 @@ void Transmogrification::LoadPlayerSets(ObjectGuid pGUID)
presetByName[pGUID].clear(); 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) if (result)
{ {
do do
@@ -79,7 +79,7 @@ void Transmogrification::LoadPlayerSets(ObjectGuid pGUID)
else // should be deleted on startup, so this never runs (shouldnt..) else // should be deleted on startup, so this never runs (shouldnt..)
{ {
presetById[pGUID].erase(PresetID); 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()); } while (result->NextRow());
} }
@@ -287,7 +287,7 @@ void Transmogrification::SetFakeEntry(Player* player, uint32 newEntry, uint8 /*s
ObjectGuid itemGUID = itemTransmogrified->GetGUID(); ObjectGuid itemGUID = itemTransmogrified->GetGUID();
entryMap[player->GetGUID()][itemGUID] = newEntry; entryMap[player->GetGUID()][itemGUID] = newEntry;
dataMap[itemGUID] = player->GetGUID(); 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); UpdateItem(player, itemTransmogrified);
} }
@@ -297,7 +297,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid
// slot of the transmogrified item // slot of the transmogrified item
if (slot >= EQUIPMENT_SLOT_END) 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; return LANG_ERR_TRANSMOG_INVALID_SLOT;
} }
@@ -308,7 +308,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid
itemTransmogrifier = player->GetItemByGuid(itemGUID); itemTransmogrifier = player->GetItemByGuid(itemGUID);
if (!itemTransmogrifier) 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; 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); Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (!itemTransmogrified) 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; return LANG_ERR_TRANSMOG_MISSING_DEST_ITEM;
} }
@@ -330,7 +330,7 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, ObjectGuid
{ {
if (!CanTransmogrifyItemWithItem(player, itemTransmogrified->GetTemplate(), itemTransmogrifier->GetTemplate())) 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; return LANG_ERR_TRANSMOG_INVALID_ITEMS;
} }
@@ -682,9 +682,9 @@ void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, Chara
dataMap.erase(itemGUID); dataMap.erase(itemGUID);
} }
if (trans) if (trans)
(*trans)->PAppend("DELETE FROM custom_transmogrification WHERE GUID = %u", itemLowGuid); (*trans)->Append("DELETE FROM custom_transmogrification WHERE GUID = {}", itemLowGuid);
else 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 bool Transmogrification::GetEnableTransmogInfo() const

View File

@@ -178,7 +178,7 @@ public:
return true; return true;
} }
// action = presetID // 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()][action].clear();
sT->presetById[player->GetGUID()].erase(action); sT->presetById[player->GetGUID()].erase(action);
sT->presetByName[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->presetById[player->GetGUID()][presetID][it->first] = it->second;
} }
sT->presetByName[player->GetGUID()][presetID] = name; // Make sure code doesnt mess up SQL! 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) if (cost)
player->ModifyMoney(-cost); player->ModifyMoney(-cost);
break; break;
@@ -405,7 +405,7 @@ public:
{ {
ObjectGuid playerGUID = player->GetGUID(); ObjectGuid playerGUID = player->GetGUID();
sT->entryMap.erase(playerGUID); 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) if (result)
{ {
do do
@@ -419,8 +419,8 @@ public:
} }
else else
{ {
//sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: %u, itemGUID: %u, playerGUID: %u) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow()); //sLog->outError(LOG_FILTER_SQL, "Item entry (Entry: {}, itemGUID: {}, playerGUID: {}) does not exist, ignoring.", fakeEntry, GUID_LOPART(itemGUID), player->GetGUIDLow());
// CharacterDatabase.PExecute("DELETE FROM custom_transmogrification WHERE FakeEntry = %u", fakeEntry); // CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE FakeEntry = {}", fakeEntry);
} }
} while (result->NextRow()); } while (result->NextRow());