feat(Core/DBLayer): replace char const* to std::string_view (#10211)

* feat(Core/DBLayer): replace `char const*` to `std::string_view`

* CString

* 1

* chore(Core/Misc): code cleanup

* cl

* db fix

* fmt style sql

* to fmt

* py

* del old

* 1

* 2

* 3

* 1

* 1
This commit is contained in:
Kargatum
2022-02-05 06:37:11 +07:00
committed by GitHub
parent d6ead1d1e0
commit de13bf426e
140 changed files with 5055 additions and 4882 deletions

View File

@@ -312,8 +312,8 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, CharacterDatabas
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
stmt->setUInt32(0, auction->bidder.GetCounter());
stmt->setUInt32(1, pItem->GetGUID().GetCounter());
stmt->SetData(0, auction->bidder.GetCounter());
stmt->SetData(1, pItem->GetGUID().GetCounter());
trans->Append(stmt);
if (bidder)
@@ -394,8 +394,8 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, Character
owner_name = gpd_owner->Name;
owner_level = gpd_owner->Level;
}
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"profit: %ug, bidder: %s %u lvl (guid: %u), seller: %s %u lvl (guid: %u), item %u (%u)\", NOW(), %u)",
gpd->AccountId, auction->bidder.GetCounter(), gpd->Name.c_str(), bidder ? bidder->GetSession()->GetRemoteAddress().c_str() : "", owner_accId, owner_name.c_str(), auction->bid, (profit / GOLD), gpd->Name.c_str(), gpd->Level, auction->bidder.GetCounter(), owner_name.c_str(), owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount, 2);
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"profit: {}g, bidder: {} {} lvl (guid: {}), seller: {} {} lvl (guid: {}), item {} ({})\", NOW(), {})",
gpd->AccountId, auction->bidder.GetCounter(), gpd->Name, bidder ? bidder->GetSession()->GetRemoteAddress() : "", owner_accId, owner_name, auction->bid, (profit / GOLD), gpd->Name, gpd->Level, auction->bidder.GetCounter(), owner_name, owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount, 2);
}
}
}
@@ -504,8 +504,8 @@ void AuctionHouseMgr::LoadAuctionItems()
{
Field* fields = result->Fetch();
ObjectGuid::LowType item_guid = fields[11].GetUInt32();
uint32 item_template = fields[12].GetUInt32();
ObjectGuid::LowType item_guid = fields[11].Get<uint32>();
uint32 item_template = fields[12].Get<uint32>();
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template);
if (!proto)
@@ -971,40 +971,40 @@ uint32 AuctionEntry::GetAuctionOutBid() const
void AuctionEntry::DeleteFromDB(CharacterDatabaseTransaction trans) const
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_AUCTION);
stmt->setUInt32(0, Id);
stmt->SetData(0, Id);
trans->Append(stmt);
}
void AuctionEntry::SaveToDB(CharacterDatabaseTransaction trans) const
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION);
stmt->setUInt32(0, Id);
stmt->setUInt8(1, houseId);
stmt->setUInt32(2, item_guid.GetCounter());
stmt->setUInt32(3, owner.GetCounter());
stmt->setUInt32 (4, buyout);
stmt->setUInt32(5, uint32(expire_time));
stmt->setUInt32(6, bidder.GetCounter());
stmt->setUInt32 (7, bid);
stmt->setUInt32 (8, startbid);
stmt->setUInt32 (9, deposit);
stmt->SetData(0, Id);
stmt->SetData(1, houseId);
stmt->SetData(2, item_guid.GetCounter());
stmt->SetData(3, owner.GetCounter());
stmt->SetData (4, buyout);
stmt->SetData(5, uint32(expire_time));
stmt->SetData(6, bidder.GetCounter());
stmt->SetData (7, bid);
stmt->SetData (8, startbid);
stmt->SetData (9, deposit);
trans->Append(stmt);
}
bool AuctionEntry::LoadFromDB(Field* fields)
{
Id = fields[0].GetUInt32();
houseId = fields[1].GetUInt8();
item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].GetUInt32());
item_template = fields[3].GetUInt32();
itemCount = fields[4].GetUInt32();
owner = ObjectGuid::Create<HighGuid::Player>(fields[5].GetUInt32());
buyout = fields[6].GetUInt32();
expire_time = fields[7].GetUInt32();
bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].GetUInt32());
bid = fields[9].GetUInt32();
startbid = fields[10].GetUInt32();
deposit = fields[11].GetUInt32();
Id = fields[0].Get<uint32>();
houseId = fields[1].Get<uint8>();
item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].Get<uint32>());
item_template = fields[3].Get<uint32>();
itemCount = fields[4].Get<uint32>();
owner = ObjectGuid::Create<HighGuid::Player>(fields[5].Get<uint32>());
buyout = fields[6].Get<uint32>();
expire_time = fields[7].Get<uint32>();
bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].Get<uint32>());
bid = fields[9].Get<uint32>();
startbid = fields[10].Get<uint32>();
deposit = fields[11].Get<uint32>();
auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntryFromHouse(houseId);
if (!auctionHouseEntry)