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

@@ -120,7 +120,7 @@ public:
if (isNumeric(searchString.c_str()))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
stmt->setUInt32(0, *Acore::StringTo<uint32>(searchString));
stmt->SetData(0, *Acore::StringTo<uint32>(searchString));
result = CharacterDatabase.Query(stmt);
}
// search by name
@@ -130,7 +130,7 @@ public:
return false;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
stmt->setString(0, searchString);
stmt->SetData(0, searchString);
result = CharacterDatabase.Query(stmt);
}
}
@@ -148,13 +148,13 @@ public:
DeletedInfo info;
info.lowGuid = fields[0].GetUInt32();
info.name = fields[1].GetString();
info.accountId = fields[2].GetUInt32();
info.lowGuid = fields[0].Get<uint32>();
info.name = fields[1].Get<std::string>();
info.accountId = fields[2].Get<uint32>();
// account name will be empty for nonexisting account
AccountMgr::GetName(info.accountId, info.accountName);
info.deleteDate = time_t(fields[3].GetUInt32());
info.deleteDate = time_t(fields[3].Get<uint32>());
foundList.push_back(info);
} while (result->NextRow());
}
@@ -232,16 +232,16 @@ public:
}
auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
stmt->setString(0, delInfo.name);
stmt->setUInt32(1, delInfo.accountId);
stmt->setUInt32(2, delInfo.lowGuid);
stmt->SetData(0, delInfo.name);
stmt->SetData(1, delInfo.accountId);
stmt->SetData(2, delInfo.lowGuid);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
stmt->setUInt32(0, delInfo.lowGuid);
stmt->SetData(0, delInfo.lowGuid);
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
{
sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].Get<uint8>(), (*result)[0].Get<uint8>(), (*result)[1].Get<uint8>(), (*result)[3].Get<uint8>());
}
}
@@ -267,8 +267,8 @@ public:
{
// Update level and reset XP, everything else will be updated at login
auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
stmt->setUInt8(0, uint8(newLevel));
stmt->setUInt32(1, playerGuid.GetCounter());
stmt->SetData(0, uint8(newLevel));
stmt->SetData(1, playerGuid.GetCounter());
CharacterDatabase.Execute(stmt);
sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel);
@@ -363,7 +363,7 @@ public:
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
stmt->setString(0, newName);
stmt->SetData(0, newName);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
@@ -374,7 +374,7 @@ public:
// Remove declined name from db
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
stmt->setUInt32(0, player->GetGUID().GetCounter());
stmt->SetData(0, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
if (Player* target = player->GetConnectedPlayer())
@@ -387,8 +387,8 @@ public:
else
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID);
stmt->setString(0, newName);
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, newName);
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -412,8 +412,8 @@ public:
handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_RENAME));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
}
@@ -467,8 +467,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -491,8 +491,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_CHANGE_FACTION));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -515,8 +515,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_CHANGE_RACE));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}