mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Feature] Extend Spell Buckets Functionality (#4441)
This commit is contained in:
+10
-54
@@ -78,6 +78,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/events/player_event_logs.h"
|
||||
#include "../common/repositories/character_corpses_repository.h"
|
||||
#include "../common/repositories/spell_buckets_repository.h"
|
||||
|
||||
#include "data_bucket.h"
|
||||
#include "quest_parser_collection.h"
|
||||
@@ -6239,65 +6240,20 @@ bool Client::SpellGlobalCheck(uint16 spell_id, uint32 character_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) {
|
||||
auto query = fmt::format(
|
||||
"SELECT `key`, value FROM spell_buckets WHERE spellid = {}",
|
||||
spell_id
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false; // Query failed, do not allow scribing.
|
||||
bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id)
|
||||
{
|
||||
const auto& e = SpellBucketsRepository::FindOne(database, spell_id);
|
||||
if (!e.spell_id || e.bucket_name.empty() || e.bucket_value.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!results.RowCount()) {
|
||||
return true; // Spell ID isn't listed in the spell_buckets table, allow scribing.
|
||||
}
|
||||
auto k = GetScopedBucketKeys();
|
||||
|
||||
auto row = results.begin();
|
||||
std::string spell_bucket_name = row[0];
|
||||
std::string spell_bucket_value = row[1];
|
||||
k.key = e.bucket_name;
|
||||
|
||||
if (spell_bucket_name.empty()) {
|
||||
return true; // If the entry in the spell_buckets table has nothing set for the qglobal name, allow scribing.
|
||||
}
|
||||
const auto& b = DataBucket::GetData(k);
|
||||
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = spell_bucket_name;
|
||||
|
||||
auto b = DataBucket::GetData(k);
|
||||
if (!b.value.empty()) {
|
||||
if (Strings::IsNumber(b.value) && Strings::IsNumber(spell_bucket_value)) {
|
||||
if (Strings::ToInt(b.value) >= Strings::ToInt(spell_bucket_value)) {
|
||||
return true; // If value is greater than or equal to spell bucket value, allow scribing.
|
||||
}
|
||||
} else {
|
||||
if (b.value == spell_bucket_value) {
|
||||
return true; // If value is equal to spell bucket value, allow scribing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto old_bucket_name = fmt::format(
|
||||
"{}-{}",
|
||||
character_id,
|
||||
spell_bucket_name
|
||||
);
|
||||
|
||||
std::string bucket_value = DataBucket::GetData(old_bucket_name);
|
||||
if (!bucket_value.empty()) {
|
||||
if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) {
|
||||
if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) {
|
||||
return true; // If value is greater than or equal to spell bucket value, allow scribing.
|
||||
}
|
||||
} else {
|
||||
if (bucket_value == spell_bucket_value) {
|
||||
return true; // If value is equal to spell bucket value, allow scribing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return zone->CompareDataBucket(e.bucket_comparison, e.bucket_value, b.value);
|
||||
}
|
||||
|
||||
// TODO get rid of this
|
||||
|
||||
Reference in New Issue
Block a user