mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-03 03:50:40 +00:00
Build Improvements (#5033)
* Start rewrite, add vcpkg * Simple vcpkg manifest, will almost certainly need tweaking * Remove cmake ext we wont be using anymore * Update vcpkg to no longer be from 2022, update cmake lists (wip) * Add finds to the toplevel cmakelists * WIP, luabind and perlbind build. Common only partially builds. * Fix common build. * shared_memory compiles * client files compile * Tests and more cmake version updates * World, had to swap out zlib-ng for now because it wasn't playing nicely along side the zlib install. May revisit. * UCS compiles now too! * queryserv and eqlaunch * loginserver works * Zone works but is messy, tomorrow futher cleanup! * Cleanup main file * remove old zlibng, remove perlwrap, remove hc * More cleanup * vcpkg baseline set for CI * Remove pkg-config, it's the suggested way to use luajit with vcpkg but it causes issues with CI and might be a pain point for windows users * Actually add file * Set perlbind include dir * Perl link got lost * PERL_SET_INTERP causes an issue on newer versions of perl on windows because a symbol is not properly exported in their API, change the lines so it's basically what it used to be * Remove static unix linking, we dont do automated released anymore and this was tightly coupled to that. Can explore this again if we decide to change that. * Remove unused submodules, set cmake policy for boost * Fix some cereal includes * Improve some boilerplate, I'd still like to do better about getting linker stuff set. * Going through and cleaning up the build. * Fix world, separate out data_buckets. * add fixes for other servers * fix zone * Fix client files, loginserver and tests * Newer versions of libmariadb default to tls forced on, return to the default of not forcing that. auto_login were breaking on linux builds loginserver wasn't setting proper openssl compile flag * Move set out of a giant cpp file include. * Convert show * convert find * Add uuid to unix builds * Remove some cpp includes. * Restructure to remove more things. * change db update manifest to header change build yml * Move world CLI include cpps to cmake. * Move zone cli out of source and into cmake * Sidecar stuff wont directly include cpp files now too. * Fix uuid-dev missing on linux runner * Reorg common cmake file * Some cleanup * Fix libsodium support (oops). Fix perl support (more oops) * Change doc --------- Co-authored-by: KimLS <KimLS@peqtgc.com>
This commit is contained in:
+32
-42
@@ -9,17 +9,7 @@ using json = nlohmann::json;
|
||||
const std::string NESTED_KEY_DELIMITER = ".";
|
||||
std::vector<DataBucketsRepository::DataBuckets> g_data_bucket_cache = {};
|
||||
|
||||
#if defined(ZONE)
|
||||
#include "../zone/zonedb.h"
|
||||
extern ZoneDatabase database;
|
||||
#elif defined(WORLD)
|
||||
#include "../world/worlddb.h"
|
||||
extern WorldDatabase database;
|
||||
#else
|
||||
#error "You must define either ZONE or WORLD"
|
||||
#endif
|
||||
|
||||
void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||
void DataBucket::SetData(SharedDatabase* database, const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||
{
|
||||
auto k = DataBucketKey{
|
||||
.key = bucket_key,
|
||||
@@ -27,10 +17,10 @@ void DataBucket::SetData(const std::string &bucket_key, const std::string &bucke
|
||||
.expires = expires_time,
|
||||
};
|
||||
|
||||
DataBucket::SetData(k);
|
||||
DataBucket::SetData(database, k);
|
||||
}
|
||||
|
||||
void DataBucket::SetData(const DataBucketKey &k_)
|
||||
void DataBucket::SetData(SharedDatabase *database, const DataBucketKey &k_)
|
||||
{
|
||||
DataBucketKey k = k_; // copy the key so we can modify it
|
||||
bool is_nested = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||
@@ -39,7 +29,7 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
|
||||
auto b = DataBucketsRepository::NewEntity();
|
||||
auto r = GetData(k, true);
|
||||
auto r = GetData(database, k, true);
|
||||
// if we have an entry, use it
|
||||
if (r.id > 0) {
|
||||
b = r;
|
||||
@@ -149,10 +139,10 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
}
|
||||
|
||||
DataBucketsRepository::UpdateOne(database, b);
|
||||
DataBucketsRepository::UpdateOne(*database, b);
|
||||
}
|
||||
else {
|
||||
b = DataBucketsRepository::InsertOne(database, b);
|
||||
b = DataBucketsRepository::InsertOne(*database, b);
|
||||
|
||||
// add to cache if it doesn't exist
|
||||
if (CanCache(k) && !ExistsInCache(b)) {
|
||||
@@ -162,9 +152,9 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
}
|
||||
}
|
||||
|
||||
std::string DataBucket::GetData(const std::string &bucket_key)
|
||||
std::string DataBucket::GetData(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetData(DataBucketKey{.key = bucket_key}).value;
|
||||
return GetData(database, DataBucketKey{.key = bucket_key}).value;
|
||||
}
|
||||
|
||||
DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||
@@ -214,7 +204,7 @@ DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||
// if the bucket doesn't exist, it will be added to the cache as a miss
|
||||
// if ignore_misses_cache is true, the bucket will not be added to the cache as a miss
|
||||
// the only place we should be ignoring the misses cache is on the initial read during SetData
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_, bool ignore_misses_cache)
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(SharedDatabase* database, const DataBucketKey &k_, bool ignore_misses_cache)
|
||||
{
|
||||
DataBucketKey k = k_; // Copy the key so we can modify it
|
||||
|
||||
@@ -244,7 +234,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
if (CheckBucketMatch(e, k)) {
|
||||
if (e.expires > 0 && e.expires < std::time(nullptr)) {
|
||||
LogDataBuckets("Attempted to read expired key [{}] removing from cache", e.key_);
|
||||
DeleteData(k);
|
||||
DeleteData(database, k);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
@@ -261,7 +251,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
|
||||
// Fetch the value from the database
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
" {} `key` = '{}' LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
@@ -310,7 +300,7 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
|
||||
// If the entry has expired, delete it
|
||||
if (bucket.expires > 0 && bucket.expires < static_cast<long long>(std::time(nullptr))) {
|
||||
DeleteData(k);
|
||||
DeleteData(database, k);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
@@ -337,22 +327,22 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
return bucket;
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const std::string &bucket_key)
|
||||
std::string DataBucket::GetDataExpires(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetDataExpires(DataBucketKey{.key = bucket_key});
|
||||
return GetDataExpires(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const std::string &bucket_key)
|
||||
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return GetDataRemaining(DataBucketKey{.key = bucket_key});
|
||||
return GetDataRemaining(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const std::string &bucket_key)
|
||||
bool DataBucket::DeleteData(SharedDatabase* database, const std::string &bucket_key)
|
||||
{
|
||||
return DeleteData(DataBucketKey{.key = bucket_key});
|
||||
return DeleteData(database, DataBucketKey{.key = bucket_key});
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
bool DataBucket::DeleteData(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
bool is_nested_key = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||
|
||||
@@ -374,7 +364,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
|
||||
// Regular key deletion, no nesting involved
|
||||
return DataBucketsRepository::DeleteWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), k.key)
|
||||
);
|
||||
}
|
||||
@@ -384,7 +374,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
DataBucketKey top_level_k = k;
|
||||
top_level_k.key = top_level_key;
|
||||
|
||||
auto r = GetData(top_level_k);
|
||||
auto r = GetData(database, top_level_k);
|
||||
if (r.id == 0 || r.value.empty() || !Strings::IsValidJson(r.value)) {
|
||||
LogDataBuckets("Attempted to delete nested key [{}] but parent key [{}] does not exist or is invalid JSON", k.key, top_level_key);
|
||||
return false;
|
||||
@@ -444,14 +434,14 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
}
|
||||
|
||||
return DataBucketsRepository::DeleteWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), top_level_key)
|
||||
);
|
||||
}
|
||||
|
||||
// Otherwise, update the existing JSON without the deleted key
|
||||
r.value = json_value.dump();
|
||||
DataBucketsRepository::UpdateOne(database, r);
|
||||
DataBucketsRepository::UpdateOne(*database, r);
|
||||
|
||||
// Update cache
|
||||
if (CanCache(k)) {
|
||||
@@ -466,7 +456,7 @@ bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
std::string DataBucket::GetDataExpires(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
LogDataBuckets(
|
||||
"Getting bucket expiration key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}]",
|
||||
@@ -477,7 +467,7 @@ std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
k.npc_id
|
||||
);
|
||||
|
||||
auto r = GetData(k);
|
||||
auto r = GetData(database, k);
|
||||
if (r.id == 0) {
|
||||
return {};
|
||||
}
|
||||
@@ -485,7 +475,7 @@ std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
return std::to_string(r.expires);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
|
||||
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const DataBucketKey &k)
|
||||
{
|
||||
LogDataBuckets(
|
||||
"Getting bucket remaining key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}] bot_id [{}] zone_id [{}] instance_id [{}]",
|
||||
@@ -499,7 +489,7 @@ std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
|
||||
k.instance_id
|
||||
);
|
||||
|
||||
auto r = GetData(k);
|
||||
auto r = GetData(database, k);
|
||||
if (r.id == 0) {
|
||||
return "0";
|
||||
}
|
||||
@@ -565,10 +555,10 @@ bool DataBucket::CheckBucketMatch(const DataBucketsRepository::DataBuckets &dbe,
|
||||
);
|
||||
}
|
||||
|
||||
void DataBucket::LoadZoneCache(uint16 zone_id, uint16 instance_id)
|
||||
void DataBucket::LoadZoneCache(SharedDatabase* database, uint16 zone_id, uint16 instance_id)
|
||||
{
|
||||
const auto &l = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
"zone_id = {} AND instance_id = {} AND (`expires` > {} OR `expires` = 0)",
|
||||
zone_id,
|
||||
@@ -608,7 +598,7 @@ void DataBucket::LoadZoneCache(uint16 zone_id, uint16 instance_id)
|
||||
);
|
||||
}
|
||||
|
||||
void DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Type t, std::vector<uint32> ids)
|
||||
void DataBucket::BulkLoadEntitiesToCache(SharedDatabase* database, DataBucketLoadType::Type t, std::vector<uint32> ids)
|
||||
{
|
||||
if (ids.empty()) {
|
||||
return;
|
||||
@@ -653,7 +643,7 @@ void DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Type t, std::vector
|
||||
}
|
||||
|
||||
const auto &l = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
*database,
|
||||
fmt::format(
|
||||
"{} IN ({}) AND (`expires` > {} OR `expires` = 0)",
|
||||
column,
|
||||
@@ -843,4 +833,4 @@ bool DataBucket::CanCache(const DataBucketKey &key)
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user