mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 21:56:22 +00:00
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:
@@ -95,23 +95,23 @@ void Corpse::SaveToDB()
|
||||
DeleteFromDB(trans);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
|
||||
stmt->setUInt32(0, GetOwnerGUID().GetCounter()); // guid
|
||||
stmt->setFloat (1, GetPositionX()); // posX
|
||||
stmt->setFloat (2, GetPositionY()); // posY
|
||||
stmt->setFloat (3, GetPositionZ()); // posZ
|
||||
stmt->setFloat (4, GetOrientation()); // orientation
|
||||
stmt->setUInt16(5, GetMapId()); // mapId
|
||||
stmt->setUInt32(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
|
||||
stmt->setString(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
|
||||
stmt->setUInt32(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
|
||||
stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
|
||||
stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
|
||||
stmt->setUInt8 (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
|
||||
stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
|
||||
stmt->setUInt32(13, uint32(m_time)); // time
|
||||
stmt->setUInt8 (14, GetType()); // corpseType
|
||||
stmt->setUInt32(15, GetInstanceId()); // instanceId
|
||||
stmt->setUInt32(16, GetPhaseMask()); // phaseMask
|
||||
stmt->SetData(0, GetOwnerGUID().GetCounter()); // guid
|
||||
stmt->SetData (1, GetPositionX()); // posX
|
||||
stmt->SetData (2, GetPositionY()); // posY
|
||||
stmt->SetData (3, GetPositionZ()); // posZ
|
||||
stmt->SetData (4, GetOrientation()); // orientation
|
||||
stmt->SetData(5, GetMapId()); // mapId
|
||||
stmt->SetData(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
|
||||
stmt->SetData(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
|
||||
stmt->SetData(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
|
||||
stmt->SetData(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
|
||||
stmt->SetData(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
|
||||
stmt->SetData (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
|
||||
stmt->SetData (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
|
||||
stmt->SetData(13, uint32(m_time)); // time
|
||||
stmt->SetData (14, GetType()); // corpseType
|
||||
stmt->SetData(15, GetInstanceId()); // instanceId
|
||||
stmt->SetData(16, GetPhaseMask()); // phaseMask
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
@@ -125,44 +125,44 @@ void Corpse::DeleteFromDB(CharacterDatabaseTransaction trans)
|
||||
void Corpse::DeleteFromDB(ObjectGuid const ownerGuid, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
|
||||
stmt->setUInt32(0, ownerGuid.GetCounter());
|
||||
stmt->SetData(0, ownerGuid.GetCounter());
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
|
||||
{
|
||||
ObjectGuid::LowType ownerGuid = fields[16].GetUInt32();
|
||||
ObjectGuid::LowType ownerGuid = fields[16].Get<uint32>();
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
float posX = fields[0].GetFloat();
|
||||
float posY = fields[1].GetFloat();
|
||||
float posZ = fields[2].GetFloat();
|
||||
float o = fields[3].GetFloat();
|
||||
uint32 mapId = fields[4].GetUInt16();
|
||||
float posX = fields[0].Get<float>();
|
||||
float posY = fields[1].Get<float>();
|
||||
float posZ = fields[2].Get<float>();
|
||||
float o = fields[3].Get<float>();
|
||||
uint32 mapId = fields[4].Get<uint16>();
|
||||
|
||||
Object::_Create(guid, 0, HighGuid::Corpse);
|
||||
|
||||
SetObjectScale(1.0f);
|
||||
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].Get<uint32>());
|
||||
|
||||
if (!_LoadIntoDataField(fields[6].GetString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END))
|
||||
if (!_LoadIntoDataField(fields[6].Get<std::string>(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END))
|
||||
{
|
||||
LOG_ERROR("entities.player", "Corpse ({}, owner: {}) is not created, given equipment info is not valid ('{}')",
|
||||
GetGUID().ToString(), GetOwnerGUID().ToString(), fields[6].GetString());
|
||||
GetGUID().ToString(), GetOwnerGUID().ToString(), fields[6].Get<std::string>());
|
||||
}
|
||||
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt8());
|
||||
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt8());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].Get<uint8>());
|
||||
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].Get<uint8>());
|
||||
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(ownerGuid));
|
||||
|
||||
m_time = time_t(fields[12].GetUInt32());
|
||||
m_time = time_t(fields[12].Get<uint32>());
|
||||
|
||||
uint32 instanceId = fields[14].GetUInt32();
|
||||
uint32 phaseMask = fields[15].GetUInt32();
|
||||
uint32 instanceId = fields[14].Get<uint32>();
|
||||
uint32 phaseMask = fields[15].Get<uint32>();
|
||||
|
||||
// place
|
||||
SetLocationInstanceId(instanceId);
|
||||
|
||||
Reference in New Issue
Block a user