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

@@ -70,15 +70,15 @@ void CalendarMgr::LoadFromDB()
{
Field* fields = result->Fetch();
uint64 eventId = fields[0].GetUInt64();
ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32());
std::string title = fields[2].GetString();
std::string description = fields[3].GetString();
CalendarEventType type = CalendarEventType(fields[4].GetUInt8());
int32 dungeonId = fields[5].GetInt32();
uint32 eventTime = fields[6].GetUInt32();
uint32 flags = fields[7].GetUInt32();
uint32 timezoneTime = fields[8].GetUInt32();
uint64 eventId = fields[0].Get<uint64>();
ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>());
std::string title = fields[2].Get<std::string>();
std::string description = fields[3].Get<std::string>();
CalendarEventType type = CalendarEventType(fields[4].Get<uint8>());
int32 dungeonId = fields[5].Get<int32>();
uint32 eventTime = fields[6].Get<uint32>();
uint32 flags = fields[7].Get<uint32>();
uint32 timezoneTime = fields[8].Get<uint32>();
uint32 guildId = 0;
if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES)
@@ -103,14 +103,14 @@ void CalendarMgr::LoadFromDB()
{
Field* fields = result->Fetch();
uint64 inviteId = fields[0].GetUInt64();
uint64 eventId = fields[1].GetUInt64();
ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32());
CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8());
uint32 statusTime = fields[5].GetUInt32();
CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8());
std::string text = fields[7].GetString();
uint64 inviteId = fields[0].Get<uint64>();
uint64 eventId = fields[1].Get<uint64>();
ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].Get<uint32>());
CalendarInviteStatus status = CalendarInviteStatus(fields[4].Get<uint8>());
uint32 statusTime = fields[5].Get<uint32>();
CalendarModerationRank rank = CalendarModerationRank(fields[6].Get<uint8>());
std::string text = fields[7].Get<std::string>();
CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(statusTime), status, rank, text);
_invites[eventId].push_back(invite);
@@ -186,7 +186,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover)
{
CalendarInvite* invite = eventInvites[i];
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
stmt->setUInt64(0, invite->GetInviteId());
stmt->SetData(0, invite->GetInviteId());
trans->Append(stmt);
// guild events only? check invite status here?
@@ -200,7 +200,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover)
_invites.erase(calendarEvent->GetEventId());
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT);
stmt->setUInt64(0, calendarEvent->GetEventId());
stmt->SetData(0, calendarEvent->GetEventId());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
@@ -226,7 +226,7 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*rem
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
stmt->setUInt64(0, (*itr)->GetInviteId());
stmt->SetData(0, (*itr)->GetInviteId());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
@@ -247,29 +247,29 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*rem
void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT);
stmt->setUInt64(0, calendarEvent->GetEventId());
stmt->setUInt32(1, calendarEvent->GetCreatorGUID().GetCounter());
stmt->setString(2, calendarEvent->GetTitle());
stmt->setString(3, calendarEvent->GetDescription());
stmt->setUInt8(4, calendarEvent->GetType());
stmt->setInt32(5, calendarEvent->GetDungeonId());
stmt->setUInt32(6, uint32(calendarEvent->GetEventTime()));
stmt->setUInt32(7, calendarEvent->GetFlags());
stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct?
stmt->SetData(0, calendarEvent->GetEventId());
stmt->SetData(1, calendarEvent->GetCreatorGUID().GetCounter());
stmt->SetData(2, calendarEvent->GetTitle());
stmt->SetData(3, calendarEvent->GetDescription());
stmt->SetData(4, calendarEvent->GetType());
stmt->SetData(5, calendarEvent->GetDungeonId());
stmt->SetData(6, uint32(calendarEvent->GetEventTime()));
stmt->SetData(7, calendarEvent->GetFlags());
stmt->SetData(8, calendarEvent->GetTimeZoneTime()); // correct?
CharacterDatabase.Execute(stmt);
}
void CalendarMgr::UpdateInvite(CalendarInvite* invite, CharacterDatabaseTransaction trans)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE);
stmt->setUInt64(0, invite->GetInviteId());
stmt->setUInt64(1, invite->GetEventId());
stmt->setUInt32(2, invite->GetInviteeGUID().GetCounter());
stmt->setUInt32(3, invite->GetSenderGUID().GetCounter());
stmt->setUInt8(4, invite->GetStatus());
stmt->setUInt32(5, uint32(invite->GetStatusTime()));
stmt->setUInt8(6, invite->GetRank());
stmt->setString(7, invite->GetText());
stmt->SetData(0, invite->GetInviteId());
stmt->SetData(1, invite->GetEventId());
stmt->SetData(2, invite->GetInviteeGUID().GetCounter());
stmt->SetData(3, invite->GetSenderGUID().GetCounter());
stmt->SetData(4, invite->GetStatus());
stmt->SetData(5, uint32(invite->GetStatusTime()));
stmt->SetData(6, invite->GetRank());
stmt->SetData(7, invite->GetText());
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}