mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-27 08:17:16 +00:00
[Databuckets] Implement Cache in World
This commit is contained in:
@@ -167,6 +167,30 @@ public:
|
|||||||
|
|
||||||
return zone_player_counts;
|
return zone_player_counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<uint32_t> GetCharacterIDsByAccountID(
|
||||||
|
Database& db,
|
||||||
|
uint32_t account_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<uint32_t> character_ids;
|
||||||
|
|
||||||
|
auto query = fmt::format(
|
||||||
|
"SELECT id FROM character_data WHERE account_id = {} AND deleted_at IS NULL",
|
||||||
|
account_id
|
||||||
|
);
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(query);
|
||||||
|
if (results.Success()) {
|
||||||
|
for (auto row : results) {
|
||||||
|
if (row[0]) {
|
||||||
|
character_ids.push_back(static_cast<uint32_t>(std::stoul(row[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return character_ids;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "../common/shareddb.h"
|
#include "../common/shareddb.h"
|
||||||
#include "../common/opcodemgr.h"
|
#include "../common/opcodemgr.h"
|
||||||
#include "../common/data_verification.h"
|
#include "../common/data_verification.h"
|
||||||
|
#include "../common/data_bucket.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "worlddb.h"
|
#include "worlddb.h"
|
||||||
@@ -135,6 +136,8 @@ Client::Client(EQStreamInterface* ieqs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client::~Client() {
|
Client::~Client() {
|
||||||
|
ClearDataBucketsCache();
|
||||||
|
|
||||||
if (RunLoops && cle && zone_id == 0)
|
if (RunLoops && cle && zone_id == 0)
|
||||||
cle->SetOnline(CLE_Status::Offline);
|
cle->SetOnline(CLE_Status::Offline);
|
||||||
|
|
||||||
@@ -477,6 +480,8 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
|
|||||||
LogClientLogin("Checking authentication id [{}]", id);
|
LogClientLogin("Checking authentication id [{}]", id);
|
||||||
|
|
||||||
if ((cle = client_list.CheckAuth(id, password))) {
|
if ((cle = client_list.CheckAuth(id, password))) {
|
||||||
|
LoadDataBucketsCache();
|
||||||
|
|
||||||
LogClientLogin("Checking authentication id [{}] passed", id);
|
LogClientLogin("Checking authentication id [{}] passed", id);
|
||||||
if (!is_player_zoning) {
|
if (!is_player_zoning) {
|
||||||
// Track who is in and who is out of the game
|
// Track who is in and who is out of the game
|
||||||
@@ -2518,3 +2523,19 @@ void Client::SendUnsupportedClientPacket(const std::string& message)
|
|||||||
|
|
||||||
QueuePacket(&packet);
|
QueuePacket(&packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::LoadDataBucketsCache()
|
||||||
|
{
|
||||||
|
DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Account, {GetAccountID()});
|
||||||
|
const auto ids = CharacterDataRepository::GetCharacterIDsByAccountID(database, GetAccountID());
|
||||||
|
DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Client, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Client::ClearDataBucketsCache()
|
||||||
|
{
|
||||||
|
DataBucket::DeleteFromCache(GetAccountID(), DataBucketLoadType::Account);
|
||||||
|
auto ids = CharacterDataRepository::GetCharacterIDsByAccountID(database, GetAccountID());
|
||||||
|
for (const auto& id : ids) {
|
||||||
|
DataBucket::DeleteFromCache(id, DataBucketLoadType::Client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ private:
|
|||||||
bool CanTradeFVNoDropItem();
|
bool CanTradeFVNoDropItem();
|
||||||
void RecordPossibleHack(const std::string& message);
|
void RecordPossibleHack(const std::string& message);
|
||||||
void SendUnsupportedClientPacket(const std::string& message);
|
void SendUnsupportedClientPacket(const std::string& message);
|
||||||
|
|
||||||
|
void LoadDataBucketsCache();
|
||||||
|
void ClearDataBucketsCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CheckCharCreateInfoSoF(CharCreate_Struct *cc);
|
bool CheckCharCreateInfoSoF(CharCreate_Struct *cc);
|
||||||
|
|||||||
Reference in New Issue
Block a user