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

File diff suppressed because it is too large Load Diff

View File

@@ -75,13 +75,13 @@ void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o,
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION);
stmt->setFloat(0, x);
stmt->setFloat(1, y);
stmt->setFloat(2, z);
stmt->setFloat(3, o);
stmt->setUInt16(4, uint16(mapid));
stmt->setUInt16(5, uint16(zone));
stmt->setUInt32(6, guid.GetCounter());
stmt->SetData(0, x);
stmt->SetData(1, y);
stmt->SetData(2, z);
stmt->SetData(3, o);
stmt->SetData(4, uint16(mapid));
stmt->SetData(5, uint16(zone));
stmt->SetData(6, guid.GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -90,13 +90,13 @@ void Player::SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGui
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION);
stmt->setFloat(0, loc.GetPositionX());
stmt->setFloat(1, loc.GetPositionY());
stmt->setFloat(2, loc.GetPositionZ());
stmt->setFloat(3, loc.GetOrientation());
stmt->setUInt16(4, uint16(loc.GetMapId()));
stmt->setUInt16(5, zoneId);
stmt->setUInt32(6, guid.GetCounter());
stmt->SetData(0, loc.GetPositionX());
stmt->SetData(1, loc.GetPositionY());
stmt->SetData(2, loc.GetPositionZ());
stmt->SetData(3, loc.GetOrientation());
stmt->SetData(4, uint16(loc.GetMapId()));
stmt->SetData(5, zoneId);
stmt->SetData(6, guid.GetCounter());
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}
@@ -104,13 +104,13 @@ void Player::SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGui
void Player::Customize(CharacterCustomizeInfo const* customizeInfo, CharacterDatabaseTransaction trans)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GENDER_AND_APPEARANCE);
stmt->setUInt8(0, customizeInfo->Gender);
stmt->setUInt8(1, customizeInfo->Skin);
stmt->setUInt8(2, customizeInfo->Face);
stmt->setUInt8(3, customizeInfo->HairStyle);
stmt->setUInt8(4, customizeInfo->HairColor);
stmt->setUInt8(5, customizeInfo->FacialHair);
stmt->setUInt32(6, customizeInfo->Guid.GetCounter());
stmt->SetData(0, customizeInfo->Gender);
stmt->SetData(1, customizeInfo->Skin);
stmt->SetData(2, customizeInfo->Face);
stmt->SetData(3, customizeInfo->HairStyle);
stmt->SetData(4, customizeInfo->HairColor);
stmt->SetData(5, customizeInfo->FacialHair);
stmt->SetData(6, customizeInfo->Guid.GetCounter());
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}

View File

@@ -578,10 +578,10 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
{
// prepare Quest Tracker datas
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_QUEST_TRACK);
stmt->setUInt32(0, quest_id);
stmt->setUInt32(1, GetGUID().GetCounter());
stmt->setString(2, GitRevision::GetHash());
stmt->setString(3, GitRevision::GetDate());
stmt->SetData(0, quest_id);
stmt->SetData(1, GetGUID().GetCounter());
stmt->SetData(2, GitRevision::GetHash());
stmt->SetData(3, GitRevision::GetDate());
// add to Quest Tracker
CharacterDatabase.Execute(stmt);
@@ -623,8 +623,8 @@ void Player::CompleteQuest(uint32 quest_id)
{
// prepare Quest Tracker datas
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME);
stmt->setUInt32(0, quest_id);
stmt->setUInt32(1, GetGUID().GetCounter());
stmt->SetData(0, quest_id);
stmt->SetData(1, GetGUID().GetCounter());
// add to Quest Tracker
CharacterDatabase.Execute(stmt);

View File

@@ -38,8 +38,8 @@ void Player::_LoadCharacterSettings(PreparedQueryResult result)
{
Field* fields = result->Fetch();
std::string source = fields[0].GetString();;
std::string data = fields[1].GetString();
std::string source = fields[0].Get<std::string>();;
std::string data = fields[1].Get<std::string>();
std::vector<std::string_view> tokens = Acore::Tokenize(data, ' ', false);
@@ -98,9 +98,9 @@ void Player::_SavePlayerSettings(CharacterDatabaseTransaction trans)
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_SETTINGS);
stmt->setUInt32(0, GetGUID().GetCounter());
stmt->setString(1, itr.first);
stmt->setString(2, data.str());
stmt->SetData(0, GetGUID().GetCounter());
stmt->SetData(1, itr.first);
stmt->SetData(2, data.str());
trans->Append(stmt);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -133,10 +133,10 @@ void Player::Update(uint32 p_time)
GetSession()->m_muteTime = 0;
LoginDatabasePreparedStatement* stmt =
LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
stmt->setInt64(0, 0); // Set the mute time to 0
stmt->setString(1, "");
stmt->setString(2, "");
stmt->setUInt32(3, GetSession()->GetAccountId());
stmt->SetData(0, 0); // Set the mute time to 0
stmt->SetData(1, "");
stmt->SetData(2, "");
stmt->SetData(3, GetSession()->GetAccountId());
LoginDatabase.Execute(stmt);
}
@@ -439,28 +439,28 @@ void Player::UpdateNextMailTimeAndUnreads()
// Get the next delivery time
CharacterDatabasePreparedStatement* stmtNextDeliveryTime =
CharacterDatabase.GetPreparedStatement(CHAR_SEL_NEXT_MAIL_DELIVERYTIME);
stmtNextDeliveryTime->setUInt32(0, GetGUID().GetCounter());
stmtNextDeliveryTime->setUInt32(1, uint32(cTime));
stmtNextDeliveryTime->SetData(0, GetGUID().GetCounter());
stmtNextDeliveryTime->SetData(1, uint32(cTime));
PreparedQueryResult resultNextDeliveryTime =
CharacterDatabase.Query(stmtNextDeliveryTime);
if (resultNextDeliveryTime)
{
Field* fields = resultNextDeliveryTime->Fetch();
m_nextMailDelivereTime = time_t(fields[0].GetUInt32());
m_nextMailDelivereTime = time_t(fields[0].Get<uint32>());
}
// Get unread mails count
CharacterDatabasePreparedStatement* stmtUnreadAmount =
CharacterDatabase.GetPreparedStatement(
CHAR_SEL_CHARACTER_MAILCOUNT_UNREAD_SYNCH);
stmtUnreadAmount->setUInt32(0, GetGUID().GetCounter());
stmtUnreadAmount->setUInt32(1, uint32(cTime));
stmtUnreadAmount->SetData(0, GetGUID().GetCounter());
stmtUnreadAmount->SetData(1, uint32(cTime));
PreparedQueryResult resultUnreadAmount =
CharacterDatabase.Query(stmtUnreadAmount);
if (resultUnreadAmount)
{
Field* fields = resultUnreadAmount->Fetch();
unReadMails = uint8(fields[0].GetUInt64());
unReadMails = uint8(fields[0].Get<uint64>());
}
}
@@ -2235,11 +2235,11 @@ void Player::UpdateSpecCount(uint8 count)
itr != m_actionButtons.end(); ++itr)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION);
stmt->setUInt32(0, GetGUID().GetCounter());
stmt->setUInt8(1, 1);
stmt->setUInt8(2, itr->first);
stmt->setUInt32(3, itr->second.GetAction());
stmt->setUInt8(4, uint8(itr->second.GetType()));
stmt->SetData(0, GetGUID().GetCounter());
stmt->SetData(1, 1);
stmt->SetData(2, itr->first);
stmt->SetData(3, itr->second.GetAction());
stmt->SetData(4, uint8(itr->second.GetType()));
trans->Append(stmt);
}
}
@@ -2250,8 +2250,8 @@ void Player::UpdateSpecCount(uint8 count)
stmt = CharacterDatabase.GetPreparedStatement(
CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC);
stmt->setUInt8(0, m_activeSpec);
stmt->setUInt32(1, GetGUID().GetCounter());
stmt->SetData(0, m_activeSpec);
stmt->SetData(1, GetGUID().GetCounter());
trans->Append(stmt);
m_activeSpec = 0;

View File

@@ -50,9 +50,9 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS);
stmt->setUInt8(0, itr->second.Flags);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
stmt->SetData(0, itr->second.Flags);
stmt->SetData(1, GetPlayerGUID().GetCounter());
stmt->SetData(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -62,9 +62,9 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
stmt->setUInt32(1, friendGuid.GetCounter());
stmt->setUInt8(2, flag);
stmt->SetData(0, GetPlayerGUID().GetCounter());
stmt->SetData(1, friendGuid.GetCounter());
stmt->SetData(2, flag);
CharacterDatabase.Execute(stmt);
}
@@ -83,8 +83,8 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SOCIAL);
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
stmt->setUInt32(1, friendGuid.GetCounter());
stmt->SetData(0, GetPlayerGUID().GetCounter());
stmt->SetData(1, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
@@ -94,9 +94,9 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_CHARACTER_SOCIAL_FLAGS);
stmt->setUInt8(0, flag);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
stmt->SetData(0, flag);
stmt->SetData(1, GetPlayerGUID().GetCounter());
stmt->SetData(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -112,9 +112,9 @@ void PlayerSocial::SetFriendNote(ObjectGuid friendGuid, std::string note)
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE);
stmt->setString(0, note);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
stmt->SetData(0, note);
stmt->SetData(1, GetPlayerGUID().GetCounter());
stmt->SetData(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
@@ -328,9 +328,9 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid guid)
{
Field* fields = result->Fetch();
auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32());
auto flags = fields[1].GetUInt8();
auto note = fields[2].GetString();
auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
auto flags = fields[1].Get<uint8>();
auto note = fields[2].Get<std::string>();
social->m_playerSocialMap[friendGuid] = FriendInfo(flags, note);
} while (result->NextRow());