Compare commits

..

8 Commits

Author SHA1 Message Date
Akkadius d2aae4d79c [Release] 22.21.0 2023-07-18 02:54:20 -05:00
Chris Miles f9dc9da42b [Pathing] Improvements to roambox logic, pathing (#3502)
* [Roambox] Improvements to roambox logic

* Update npc.cpp

* Update npc.cpp

* More pathing fixes
2023-07-18 02:52:04 -05:00
Chris Miles 3f3bbe98b5 [Data Buckets] Implement scoped data buckets (#3498)
* [Data Buckets] Implement scoped data buckets

* Update database_update_manifest.cpp

* Update data_bucket.cpp

* Update data_bucket.cpp

* Update data_bucket.cpp

* Update data_bucket.h

* Update database_update_manifest.cpp

* Add GetScopedDbFilters references

* Scope transfer
2023-07-16 14:52:28 -04:00
Chris Miles 59537ae977 [Z Clipping] Don't issue zclip adjustments when NPC is not moving (#3499) 2023-07-16 14:52:17 -04:00
Alex King ee45a28efe [Quest API] Add SetLDoNPoints() to Perl/Lua (#3496)
# Perl
- Add `$client->SetLDoNPoints(theme_id, points)`.

# Lua
- Add `client:SetLDoNPoints(theme_id, points)`.

# Notes
- Allows operators to directly set LDoN Points.
2023-07-15 21:46:49 -05:00
Jonathan Sider 70ce81fb0a [Bug Fix] Fix rule check and add rule for pickpocket command (#3492)
* Fix bugs in skills

-Add rule for allowing pickpocket
-Fix method that is supposed to check rule
-Changed Z axis range for pickpocket (was failing on giants)

* Add zoffset to account for taller models
2023-07-15 21:46:26 -05:00
Akkadius e06d28ad20 [Release] 22.20.1 2023-07-15 13:30:36 -05:00
Mitch Freeman d57489781c [Database] Fix database manifest entry for #3443
Updates the syntax for mariadb 10.1
2023-07-15 13:29:34 -05:00
26 changed files with 462 additions and 278 deletions
+28
View File
@@ -1,3 +1,31 @@
## [22.21.0] - 07/18/2023
### Data Buckets
* Implement scoped data buckets ([#3498](https://github.com/EQEmu/Server/pull/3498)) @Akkadius 2023-07-16
### Fixes
* Fix rule check and add rule for pickpocket command ([#3492](https://github.com/EQEmu/Server/pull/3492)) @tuday2 2023-07-16
### Pathing
* Improvements to roambox logic, pathing ([#3502](https://github.com/EQEmu/Server/pull/3502)) @Akkadius 2023-07-18
### Quest API
* Add SetLDoNPoints() to Perl/Lua ([#3496](https://github.com/EQEmu/Server/pull/3496)) @Kinglykrab 2023-07-16
### Z Clipping
* Don't issue zclip adjustments when NPC is not moving ([#3499](https://github.com/EQEmu/Server/pull/3499)) @Akkadius 2023-07-16
## [22.20.1] - 07/15/2023
### Database
* Fix database manifest entry for #3443 @neckkola 2023-07-15
## [22.20.0] - 07/15/2023 ## [22.20.0] - 07/15/2023
### Bots ### Bots
+27 -6
View File
@@ -4768,14 +4768,14 @@ UNIQUE KEY `name` (`name`)
.match = "", .match = "",
.sql = R"( .sql = R"(
ALTER TABLE `raid_members` ALTER TABLE `raid_members`
ADD COLUMN `is_marker` TINYINT UNSIGNED DEFAULT(0) NOT NULL AFTER `islooter`, ADD COLUMN `is_marker` TINYINT UNSIGNED DEFAULT 0 NOT NULL AFTER `islooter`,
ADD COLUMN `is_assister` TINYINT UNSIGNED DEFAULT(0) NOT NULL AFTER `is_marker`, ADD COLUMN `is_assister` TINYINT UNSIGNED DEFAULT 0 NOT NULL AFTER `is_marker`,
ADD COLUMN `note` VARCHAR(64) DEFAULT("") NOT NULL AFTER `is_assister`; ADD COLUMN `note` VARCHAR(64) DEFAULT '' NOT NULL AFTER `is_assister`;
ALTER TABLE `raid_details` ALTER TABLE `raid_details`
ADD COLUMN `marked_npc_1` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `motd`, ADD COLUMN `marked_npc_1` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `motd`,
ADD COLUMN `marked_npc_2` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `marked_npc_1`, ADD COLUMN `marked_npc_2` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `marked_npc_1`,
ADD COLUMN `marked_npc_3` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `marked_npc_2`; ADD COLUMN `marked_npc_3` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `marked_npc_2`;
)", )",
}, },
ManifestEntry{ ManifestEntry{
@@ -4804,6 +4804,27 @@ UNIQUE KEY `name` (`name`)
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE INDEX `command`(`parent_command`, `sub_command`) UNIQUE INDEX `command`(`parent_command`, `sub_command`)
) )
)"
},
ManifestEntry{
.version = 9233,
.description = "2023_07_16_scoped_data_buckets.sql",
.check = "SHOW COLUMNS FROM `data_buckets` LIKE 'character_id'",
.condition = "empty",
.match = "",
.sql = R"(
ALTER TABLE `data_buckets`
ADD COLUMN `character_id` bigint(11) NOT NULL DEFAULT 0 AFTER `expires`,
ADD COLUMN `npc_id` bigint(11) NOT NULL DEFAULT 0 AFTER `character_id`,
ADD COLUMN `bot_id` bigint(11) NOT NULL DEFAULT 0 AFTER `npc_id`,
DROP INDEX `key_index`,
ADD UNIQUE INDEX `keys`(`key`,`character_id`,`npc_id`,`bot_id`);
UPDATE data_buckets SET character_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'character-%';
UPDATE data_buckets SET npc_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'npc-%';
UPDATE data_buckets SET bot_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'bot-%';
)" )"
}, },
@@ -24,6 +24,9 @@ public:
std::string key_; std::string key_;
std::string value; std::string value;
uint32_t expires; uint32_t expires;
int64_t character_id;
int64_t npc_id;
int64_t bot_id;
}; };
static std::string PrimaryKey() static std::string PrimaryKey()
@@ -38,6 +41,9 @@ public:
"`key`", "`key`",
"value", "value",
"expires", "expires",
"character_id",
"npc_id",
"bot_id",
}; };
} }
@@ -48,6 +54,9 @@ public:
"`key`", "`key`",
"value", "value",
"expires", "expires",
"character_id",
"npc_id",
"bot_id",
}; };
} }
@@ -92,6 +101,9 @@ public:
e.key_ = ""; e.key_ = "";
e.value = ""; e.value = "";
e.expires = 0; e.expires = 0;
e.character_id = 0;
e.npc_id = 0;
e.bot_id = 0;
return e; return e;
} }
@@ -132,6 +144,9 @@ public:
e.key_ = row[1] ? row[1] : ""; e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : ""; e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.character_id = strtoll(row[4], nullptr, 10);
e.npc_id = strtoll(row[5], nullptr, 10);
e.bot_id = strtoll(row[6], nullptr, 10);
return e; return e;
} }
@@ -168,6 +183,9 @@ public:
v.push_back(columns[1] + " = '" + Strings::Escape(e.key_) + "'"); v.push_back(columns[1] + " = '" + Strings::Escape(e.key_) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'"); v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.expires)); v.push_back(columns[3] + " = " + std::to_string(e.expires));
v.push_back(columns[4] + " = " + std::to_string(e.character_id));
v.push_back(columns[5] + " = " + std::to_string(e.npc_id));
v.push_back(columns[6] + " = " + std::to_string(e.bot_id));
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@@ -193,6 +211,9 @@ public:
v.push_back("'" + Strings::Escape(e.key_) + "'"); v.push_back("'" + Strings::Escape(e.key_) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'"); v.push_back("'" + Strings::Escape(e.value) + "'");
v.push_back(std::to_string(e.expires)); v.push_back(std::to_string(e.expires));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.bot_id));
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@@ -226,6 +247,9 @@ public:
v.push_back("'" + Strings::Escape(e.key_) + "'"); v.push_back("'" + Strings::Escape(e.key_) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'"); v.push_back("'" + Strings::Escape(e.value) + "'");
v.push_back(std::to_string(e.expires)); v.push_back(std::to_string(e.expires));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.bot_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
} }
@@ -263,6 +287,9 @@ public:
e.key_ = row[1] ? row[1] : ""; e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : ""; e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.character_id = strtoll(row[4], nullptr, 10);
e.npc_id = strtoll(row[5], nullptr, 10);
e.bot_id = strtoll(row[6], nullptr, 10);
all_entries.push_back(e); all_entries.push_back(e);
} }
@@ -291,6 +318,9 @@ public:
e.key_ = row[1] ? row[1] : ""; e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : ""; e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.character_id = strtoll(row[4], nullptr, 10);
e.npc_id = strtoll(row[5], nullptr, 10);
e.bot_id = strtoll(row[6], nullptr, 10);
all_entries.push_back(e); all_entries.push_back(e);
} }
+1
View File
@@ -637,6 +637,7 @@ RULE_BOOL(Bots, OldRaceRezEffects, false, "Older clients had ID 757 for races wi
RULE_BOOL(Bots, ResurrectionSickness, true, "Use Resurrection Sickness based on Resurrection spell cast, set to false to disable Resurrection Sickness.") RULE_BOOL(Bots, ResurrectionSickness, true, "Use Resurrection Sickness based on Resurrection spell cast, set to false to disable Resurrection Sickness.")
RULE_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old Resurrection Sickness Spell") RULE_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old Resurrection Sickness Spell")
RULE_INT(Bots, ResurrectionSicknessSpell, 756, "756 is Default Resurrection Sickness Spell") RULE_INT(Bots, ResurrectionSicknessSpell, 756, "756 is Default Resurrection Sickness Spell")
RULE_BOOL(Bots, AllowPickpocketCommand, true, "Allows the use of the bot command 'pickpocket'")
RULE_CATEGORY_END() RULE_CATEGORY_END()
RULE_CATEGORY(Chat) RULE_CATEGORY(Chat)
+2 -2
View File
@@ -25,7 +25,7 @@
// Build variables // Build variables
// these get injected during the build pipeline // these get injected during the build pipeline
#define CURRENT_VERSION "22.20.0-dev" // always append -dev to the current version for custom-builds #define CURRENT_VERSION "22.21.0-dev" // always append -dev to the current version for custom-builds
#define LOGIN_VERSION "0.8.0" #define LOGIN_VERSION "0.8.0"
#define COMPILE_DATE __DATE__ #define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__ #define COMPILE_TIME __TIME__
@@ -42,7 +42,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/ */
#define CURRENT_BINARY_DATABASE_VERSION 9232 #define CURRENT_BINARY_DATABASE_VERSION 9233
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9039 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9039
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "eqemu-server", "name": "eqemu-server",
"version": "22.20.0", "version": "22.21.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/EQEmu/Server.git" "url": "https://github.com/EQEmu/Server.git"
+3 -7
View File
@@ -6033,14 +6033,10 @@ float Mob::CheckHeroicBonusesDataBuckets(std::string bucket_name)
{ {
std::string bucket_value; std::string bucket_value;
if (!bucket_name.empty()) { if (!bucket_name.empty()) {
const auto full_name = fmt::format( DataBucketKey k = GetScopedBucketKeys();
"{}-{}", k.key = bucket_name;
GetBucketKey(),
bucket_name
);
if (IsOfClientBot()) { if (IsOfClientBot()) {
bucket_value = DataBucket::CheckBucketKey(this, full_name); bucket_value = DataBucket::CheckBucketKey(this, k);
} }
if (bucket_value.empty() || !Strings::IsNumber(bucket_value)) { if (bucket_value.empty() || !Strings::IsNumber(bucket_value)) {
+7 -12
View File
@@ -8193,21 +8193,16 @@ void Bot::OwnerMessage(const std::string& message)
bool Bot::CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison) bool Bot::CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison)
{ {
if (!bucket_name.empty() && !bucket_value.empty()) { if (!bucket_name.empty() && !bucket_value.empty()) {
auto full_name = fmt::format( // try to fetch from bot first
"{}-{}", DataBucketKey k = GetScopedBucketKeys();
GetBucketKey(), k.key = bucket_name;
bucket_name
);
auto player_value = DataBucket::CheckBucketKey(this, full_name); auto player_value = DataBucket::CheckBucketKey(this, k);
if (player_value.empty() && GetBotOwner()) { if (player_value.empty() && GetBotOwner()) {
full_name = fmt::format( // fetch from owner
"{}-{}", k = GetBotOwner()->GetScopedBucketKeys();
GetBotOwner()->GetBucketKey(),
bucket_name
);
player_value = DataBucket::CheckBucketKey(GetBotOwner(), full_name); player_value = DataBucket::CheckBucketKey(GetBotOwner(), k);
if (player_value.empty()) { if (player_value.empty()) {
return false; return false;
} }
+8 -2
View File
@@ -9170,7 +9170,7 @@ bool helper_cast_standard_spell(Bot* casting_bot, Mob* target_mob, int spell_id,
bool helper_command_disabled(Client* bot_owner, bool rule_value, const char* command) bool helper_command_disabled(Client* bot_owner, bool rule_value, const char* command)
{ {
if (rule_value) { if (!rule_value) {
bot_owner->Message(Chat::White, "Bot command %s is not enabled on this server.", command); bot_owner->Message(Chat::White, "Bot command %s is not enabled on this server.", command);
return true; return true;
} }
@@ -9999,6 +9999,10 @@ void bot_command_caster_range(Client* c, const Seperator* sep)
void bot_command_pickpocket(Client *c, const Seperator *sep) void bot_command_pickpocket(Client *c, const Seperator *sep)
{ {
if (helper_command_disabled(c, RuleB(Bots, AllowPickpocketCommand), "pickpocket")) {
return;
}
if (helper_command_alias_fail(c, "bot_command_pickpocket", sep->arg[0], "pickpocket")) { if (helper_command_alias_fail(c, "bot_command_pickpocket", sep->arg[0], "pickpocket")) {
return; return;
} }
@@ -10032,7 +10036,9 @@ void bot_command_pickpocket(Client *c, const Seperator *sep)
glm::vec4 mob_distance = (c->GetPosition() - target_mob->GetPosition()); glm::vec4 mob_distance = (c->GetPosition() - target_mob->GetPosition());
float mob_xy_distance = ((mob_distance.x * mob_distance.x) + (mob_distance.y * mob_distance.y)); float mob_xy_distance = ((mob_distance.x * mob_distance.x) + (mob_distance.y * mob_distance.y));
float mob_z_distance = (mob_distance.z * mob_distance.z); float mob_z_distance = (mob_distance.z * mob_distance.z);
if (mob_z_distance >= 25 || mob_xy_distance > 250) { float z_offset_diff = target_mob->GetZOffset() - c->GetZOffset();
if (mob_z_distance >= (35-z_offset_diff) || mob_xy_distance > 250) {
c->Message(Chat::White, "You must be closer to an enemy to use this command"); c->Message(Chat::White, "You must be closer to an enemy to use this command");
return; return;
} }
+7 -1
View File
@@ -1558,7 +1558,13 @@ void Client::SetLDoNPoints(uint32 theme_id, uint32 points)
} }
} }
m_pp.ldon_points_available += points; m_pp.ldon_points_available = (
m_pp.ldon_points_guk +
m_pp.ldon_points_mir +
m_pp.ldon_points_mmc +
m_pp.ldon_points_ruj +
m_pp.ldon_points_tak
);
auto outapp = new EQApplicationPacket(OP_AdventurePointsUpdate, sizeof(AdventurePoints_Update_Struct)); auto outapp = new EQApplicationPacket(OP_AdventurePointsUpdate, sizeof(AdventurePoints_Update_Struct));
+4 -6
View File
@@ -853,13 +853,11 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
auto bucket_name = ml.bucket_name; auto bucket_name = ml.bucket_name;
auto const& bucket_value = ml.bucket_value; auto const& bucket_value = ml.bucket_value;
if (!bucket_name.empty() && !bucket_value.empty()) { if (!bucket_name.empty() && !bucket_value.empty()) {
auto full_name = fmt::format(
"{}-{}",
GetBucketKey(),
bucket_name
);
auto const& player_value = DataBucket::CheckBucketKey(this, full_name); DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
auto const& player_value = DataBucket::CheckBucketKey(this, k);
if (player_value.empty()) { if (player_value.empty()) {
continue; continue;
} }
+161 -135
View File
@@ -1,173 +1,130 @@
#include "data_bucket.h" #include "data_bucket.h"
#include "zonedb.h" #include "zonedb.h"
#include "mob.h"
#include <ctime> #include <ctime>
#include <cctype> #include <cctype>
#include "../common/repositories/data_buckets_repository.h"
/** void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
* Persists data via bucket_name as key {
* @param bucket_key auto k = DataBucketKey{
* @param bucket_value .key = bucket_key,
* @param expires_time .value = bucket_value,
*/ .expires = expires_time,
void DataBucket::SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time) { .character_id = 0,
uint64 bucket_id = DataBucket::DoesBucketExist(bucket_key); .npc_id = 0,
.bot_id = 0
};
std::string query; DataBucket::SetData(k);
}
void DataBucket::SetData(const DataBucketKey &k)
{
auto r = DataBucketsRepository::GetWhere(
database,
fmt::format(
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
DataBucket::GetScopedDbFilters(k),
Strings::Escape(k.key),
(long long) std::time(nullptr)
)
);
// if we have an entry, use it
auto b = DataBucketsRepository::NewEntity();
if (!r.empty()) {
b = r[0];
}
if (k.character_id > 0) {
b.character_id = k.character_id;
} else if (k.npc_id > 0) {
b.npc_id = k.npc_id;
} else if (k.bot_id > 0) {
b.bot_id = k.bot_id;
}
uint64 bucket_id = b.id;
long long expires_time_unix = 0; long long expires_time_unix = 0;
if (!expires_time.empty()) { if (!k.expires.empty()) {
if (isalpha(expires_time[0]) || isalpha(expires_time[expires_time.length() - 1])) { expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(k.expires);
expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(expires_time); if (isalpha(k.expires[0]) || isalpha(k.expires[k.expires.length() - 1])) {
} else { expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(k.expires);
expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(expires_time);
} }
} }
if (bucket_id > 0) { if (bucket_id > 0) {
std::string update_expired_time; b.expires = expires_time_unix;
if (expires_time_unix > 0) { b.value = k.value;
update_expired_time = StringFormat(", `expires` = %lld ", expires_time_unix); DataBucketsRepository::UpdateOne(database, b);
}
query = StringFormat(
"UPDATE `data_buckets` SET `value` = '%s' %s WHERE `id` = %i",
Strings::Escape(bucket_value).c_str(),
Strings::Escape(update_expired_time).c_str(),
bucket_id
);
} }
else { else {
query = StringFormat( b.expires = expires_time_unix;
"INSERT INTO `data_buckets` (`key`, `value`, `expires`) VALUES ('%s', '%s', '%lld')", b.key_ = k.key;
Strings::Escape(bucket_key).c_str(), b.value = k.value;
Strings::Escape(bucket_value).c_str(), DataBucketsRepository::InsertOne(database, b);
expires_time_unix }
);
} }
database.QueryDatabase(query); std::string DataBucket::GetData(const std::string &bucket_key)
{
DataBucketKey k = {};
k.key = bucket_key;
return GetData(k);
} }
/** std::string DataBucket::GetData(const DataBucketKey &k)
* Retrieves data via bucket_name as key {
* @param bucket_key auto r = DataBucketsRepository::GetWhere(
* @return database,
*/ fmt::format(
std::string DataBucket::GetData(const std::string& bucket_key) { "{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
std::string query = StringFormat( DataBucket::GetScopedDbFilters(k),
"SELECT `value` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1", k.key,
bucket_key.c_str(),
(long long) std::time(nullptr) (long long) std::time(nullptr)
)
); );
auto results = database.QueryDatabase(query); if (r.empty()) {
if (!results.Success()) { return {};
return std::string();
} }
if (results.RowCount() != 1) return r[0].value;
return std::string();
auto row = results.begin();
return std::string(row[0]);
} }
/** std::string DataBucket::GetDataExpires(const std::string &bucket_key)
* Retrieves data expires time via bucket_name as key {
* @param bucket_key DataBucketKey k = {};
* @return k.key = bucket_key;
*/
std::string DataBucket::GetDataExpires(const std::string& bucket_key) {
std::string query = StringFormat(
"SELECT `expires` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
bucket_key.c_str(),
(long long) std::time(nullptr)
);
auto results = database.QueryDatabase(query); return GetDataExpires(k);
if (!results.Success()) {
return std::string();
} }
if (results.RowCount() != 1) std::string DataBucket::GetDataRemaining(const std::string &bucket_key)
return std::string(); {
DataBucketKey k = {};
auto row = results.begin(); k.key = bucket_key;
return GetDataRemaining(k);
return std::string(row[0]);
} }
std::string DataBucket::GetDataRemaining(const std::string& bucket_key) { bool DataBucket::DeleteData(const std::string &bucket_key)
if (DataBucket::GetDataExpires(bucket_key).empty()) { {
return "0"; DataBucketKey r = {};
} r.key = bucket_key;
std::string query = fmt::format( return DeleteData(r);
"SELECT (`expires` - UNIX_TIMESTAMP()) AS `remaining` from `data_buckets` WHERE `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
bucket_key.c_str(),
(long long) std::time(nullptr)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return std::string();
}
if (results.RowCount() != 1)
return std::string();
auto row = results.begin();
return std::string(row[0]);
}
/**
* Checks for bucket existence by bucket_name key
* @param bucket_key
* @return
*/
uint64 DataBucket::DoesBucketExist(const std::string& bucket_key) {
std::string query = StringFormat(
"SELECT `id` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
Strings::Escape(bucket_key).c_str(),
(long long) std::time(nullptr)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return 0;
}
auto row = results.begin();
if (results.RowCount() != 1)
return 0;
return Strings::ToUnsignedBigInt(row[0]);
}
/**
* Deletes data bucket by key
* @param bucket_key
* @return
*/
bool DataBucket::DeleteData(const std::string& bucket_key) {
std::string query = StringFormat(
"DELETE FROM `data_buckets` WHERE `key` = '%s'",
Strings::Escape(bucket_key).c_str()
);
auto results = database.QueryDatabase(query);
return results.Success();
} }
bool DataBucket::GetDataBuckets(Mob *mob) bool DataBucket::GetDataBuckets(Mob *mob)
{ {
DataBucketKey k = mob->GetScopedBucketKeys();
auto l = BaseDataBucketsRepository::GetWhere( auto l = BaseDataBucketsRepository::GetWhere(
database, database,
fmt::format( fmt::format(
"`key` LIKE '{}-%'", "{} (`expires` > {} OR `expires` = 0)",
Strings::Escape(mob->GetBucketKey()) DataBucket::GetScopedDbFilters(k),
(long long) std::time(nullptr)
) )
); );
@@ -191,11 +148,11 @@ bool DataBucket::GetDataBuckets(Mob* mob)
return true; return true;
} }
std::string DataBucket::CheckBucketKey(const Mob* mob, std::string_view full_name) std::string DataBucket::CheckBucketKey(const Mob *mob, const DataBucketKey &k)
{ {
std::string bucket_value; std::string bucket_value;
for (const auto &d: mob->m_data_bucket_cache) { for (const auto &d: mob->m_data_bucket_cache) {
if (d.bucket_key == full_name) { if (d.bucket_key == k.key) {
bucket_value = d.bucket_value; bucket_value = d.bucket_value;
break; break;
} }
@@ -203,3 +160,72 @@ std::string DataBucket::CheckBucketKey(const Mob* mob, std::string_view full_nam
return bucket_value; return bucket_value;
} }
bool DataBucket::DeleteData(const DataBucketKey &k)
{
return DataBucketsRepository::DeleteWhere(
database,
fmt::format(
"{} `key` = '{}'",
DataBucket::GetScopedDbFilters(k),
k.key
)
);
}
std::string DataBucket::GetDataExpires(const DataBucketKey &k)
{
auto r = DataBucketsRepository::GetWhere(
database,
fmt::format(
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
DataBucket::GetScopedDbFilters(k),
k.key,
(long long) std::time(nullptr)
)
);
if (r.empty()) {
return {};
}
return fmt::format("{}", r[0].expires);
}
std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
{
auto r = DataBucketsRepository::GetWhere(
database,
fmt::format(
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
DataBucket::GetScopedDbFilters(k),
k.key,
(long long) std::time(nullptr)
)
);
if (r.empty()) {
return "0";
}
return fmt::format("{}", r[0].expires - (long long) std::time(nullptr));
}
std::string DataBucket::GetScopedDbFilters(const DataBucketKey &k)
{
std::vector<std::string> query = {};
if (k.character_id > 0) {
query.emplace_back(fmt::format("character_id = {}", k.character_id));
}
else if (k.npc_id > 0) {
query.emplace_back(fmt::format("npc_id = {}", k.npc_id));
}
else if (k.bot_id > 0) {
query.emplace_back(fmt::format("bot_id = {}", k.bot_id));
}
return fmt::format(
"{} {}",
Strings::Join(query, " AND "),
!query.empty() ? "AND" : ""
);
}
+21 -4
View File
@@ -10,18 +10,35 @@
#include "../common/repositories/data_buckets_repository.h" #include "../common/repositories/data_buckets_repository.h"
#include "mob.h" #include "mob.h"
struct DataBucketKey {
std::string key;
std::string value;
std::string expires;
int64_t character_id;
int64_t npc_id;
int64_t bot_id;
};
class DataBucket { class DataBucket {
public: public:
// non-scoped bucket methods (for global buckets)
static void SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time = ""); static void SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time = "");
static bool DeleteData(const std::string& bucket_key); static bool DeleteData(const std::string& bucket_key);
static std::string GetData(const std::string& bucket_key); static std::string GetData(const std::string& bucket_key);
static std::string GetDataExpires(const std::string& bucket_key); static std::string GetDataExpires(const std::string& bucket_key);
static std::string GetDataRemaining(const std::string& bucket_key); static std::string GetDataRemaining(const std::string& bucket_key);
static bool GetDataBuckets(Mob* mob);
static std::string CheckBucketKey(const Mob* mob, std::string_view full_name);
private: static bool GetDataBuckets(Mob* mob);
static uint64 DoesBucketExist(const std::string& bucket_key);
// scoped bucket methods
static void SetData(const DataBucketKey& k);
static bool DeleteData(const DataBucketKey& k);
static std::string GetData(const DataBucketKey& k);
static std::string GetDataExpires(const DataBucketKey& k);
static std::string GetDataRemaining(const DataBucketKey& k);
static std::string CheckBucketKey(const Mob* mob, const DataBucketKey& k);
static std::string GetScopedDbFilters(const DataBucketKey& k);
}; };
#endif //EQEMU_DATABUCKET_H #endif //EQEMU_DATABUCKET_H
+3 -17
View File
@@ -1273,24 +1273,10 @@ uint8 Client::GetCharMaxLevelFromQGlobal() {
uint8 Client::GetCharMaxLevelFromBucket() uint8 Client::GetCharMaxLevelFromBucket()
{ {
auto new_bucket_name = fmt::format( DataBucketKey k = GetScopedBucketKeys();
"{}-CharMaxLevel", k.key = "CharMaxLevel";
GetBucketKey()
);
auto bucket_value = DataBucket::GetData(new_bucket_name); auto bucket_value = DataBucket::GetData(k);
if (!bucket_value.empty()) {
if (Strings::IsNumber(bucket_value)) {
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
}
}
auto old_bucket_name = fmt::format(
"{}-CharMaxLevel",
CharacterID()
);
bucket_value = DataBucket::GetData(old_bucket_name);
if (!bucket_value.empty()) { if (!bucket_value.empty()) {
if (Strings::IsNumber(bucket_value)) { if (Strings::IsNumber(bucket_value)) {
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value)); return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
+7
View File
@@ -3092,6 +3092,12 @@ std::string Lua_Client::GetRaceAbbreviation()
return GetPlayerRaceAbbreviation(self->GetBaseRace()); return GetPlayerRaceAbbreviation(self->GetBaseRace());
} }
void Lua_Client::SetLDoNPoints(uint32 theme_id, uint32 points)
{
Lua_Safe_Call_Void();
self->SetLDoNPoints(theme_id, points);
}
luabind::scope lua_register_client() { luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client") return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>()) .def(luabind::constructor<>())
@@ -3536,6 +3542,7 @@ luabind::scope lua_register_client() {
.def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption) .def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption)
.def("SetItemCooldown", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetItemCooldown) .def("SetItemCooldown", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetItemCooldown)
.def("SetLanguageSkill", (void(Lua_Client::*)(int,int))&Lua_Client::SetLanguageSkill) .def("SetLanguageSkill", (void(Lua_Client::*)(int,int))&Lua_Client::SetLanguageSkill)
.def("SetLDoNPoints", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetLDoNPoints)
.def("SetMaterial", (void(Lua_Client::*)(int,uint32))&Lua_Client::SetMaterial) .def("SetMaterial", (void(Lua_Client::*)(int,uint32))&Lua_Client::SetMaterial)
.def("SetPEQZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::SetPEQZoneFlag) .def("SetPEQZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::SetPEQZoneFlag)
.def("SetPVP", (void(Lua_Client::*)(bool))&Lua_Client::SetPVP) .def("SetPVP", (void(Lua_Client::*)(bool))&Lua_Client::SetPVP)
+1
View File
@@ -473,6 +473,7 @@ public:
uint32 GetEXPForLevel(uint16 check_level); uint32 GetEXPForLevel(uint16 check_level);
std::string GetClassAbbreviation(); std::string GetClassAbbreviation();
std::string GetRaceAbbreviation(); std::string GetRaceAbbreviation();
void SetLDoNPoints(uint32 theme_id, uint32 points);
void ApplySpell(int spell_id); void ApplySpell(int spell_id);
void ApplySpell(int spell_id, int duration); void ApplySpell(int spell_id, int duration);
+1 -1
View File
@@ -2353,7 +2353,7 @@ std::string Lua_Mob::GetBucketExpires(std::string bucket_name)
std::string Lua_Mob::GetBucketKey() std::string Lua_Mob::GetBucketKey()
{ {
Lua_Safe_Call_String(); Lua_Safe_Call_String();
return self->GetBucketKey(); return {};
} }
std::string Lua_Mob::GetBucketRemaining(std::string bucket_name) std::string Lua_Mob::GetBucketRemaining(std::string bucket_name)
+52 -29
View File
@@ -8049,54 +8049,63 @@ void Mob::SetCanOpenDoors(bool can_open)
m_can_open_doors = can_open; m_can_open_doors = can_open;
} }
void Mob::DeleteBucket(std::string bucket_name) { void Mob::DeleteBucket(std::string bucket_name)
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); {
DataBucket::DeleteData(full_bucket_name); DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
DataBucket::DeleteData(k);
} }
std::string Mob::GetBucket(std::string bucket_name) { std::string Mob::GetBucket(std::string bucket_name)
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); {
std::string bucket_value = DataBucket::GetData(full_bucket_name); DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
std::string bucket_value = DataBucket::GetData(k);
if (!bucket_value.empty()) { if (!bucket_value.empty()) {
return bucket_value; return bucket_value;
} }
return std::string(); return {};
} }
std::string Mob::GetBucketExpires(std::string bucket_name) { std::string Mob::GetBucketExpires(std::string bucket_name)
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); {
std::string bucket_expiration = DataBucket::GetDataExpires(full_bucket_name); DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
std::string bucket_expiration = DataBucket::GetDataExpires(k);
if (!bucket_expiration.empty()) { if (!bucket_expiration.empty()) {
return bucket_expiration; return bucket_expiration;
} }
return std::string();
return {};
} }
std::string Mob::GetBucketKey() { std::string Mob::GetBucketRemaining(std::string bucket_name)
if (IsClient()) { {
return fmt::format("character-{}", CastToClient()->CharacterID()); DataBucketKey k = GetScopedBucketKeys();
} else if (IsNPC()) { k.key = bucket_name;
return fmt::format("npc-{}", GetNPCTypeID());
} else if (IsBot()) {
return fmt::format("bot-{}", CastToBot()->GetBotID());
}
return std::string();
}
std::string Mob::GetBucketRemaining(std::string bucket_name) { std::string bucket_remaining = DataBucket::GetDataRemaining(k);
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
std::string bucket_remaining = DataBucket::GetDataRemaining(full_bucket_name);
if (!bucket_remaining.empty() && Strings::ToInt(bucket_remaining) > 0) { if (!bucket_remaining.empty() && Strings::ToInt(bucket_remaining) > 0) {
return bucket_remaining; return bucket_remaining;
} else if (Strings::ToInt(bucket_remaining) == 0) { }
else if (Strings::ToInt(bucket_remaining) == 0) {
return "0"; return "0";
} }
return std::string();
return {};
} }
void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration) { void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration)
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); {
DataBucket::SetData(full_bucket_name, bucket_value, expiration); DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
k.expires = expiration;
k.value = bucket_value;
DataBucket::SetData(k);
} }
std::string Mob::GetMobDescription() std::string Mob::GetMobDescription()
@@ -8329,3 +8338,17 @@ std::string Mob::GetClassPlural()
return "Classes"; return "Classes";
} }
} }
DataBucketKey Mob::GetScopedBucketKeys()
{
DataBucketKey k = {};
if (IsClient()) {
k.character_id = CastToClient()->CharacterID();
} else if (IsNPC()) {
k.npc_id = GetNPCTypeID();
} else if (IsBot()) {
k.bot_id = CastToBot()->GetBotID();
}
return k;
}
+3 -1
View File
@@ -69,6 +69,7 @@ enum class eSpecialAttacks : int {
ChaoticStab ChaoticStab
}; };
class DataBucketKey;
class Mob : public Entity { class Mob : public Entity {
public: public:
enum CLIENT_CONN_STATUS { CLIENT_CONNECTING, CLIENT_CONNECTED, CLIENT_LINKDEAD, enum CLIENT_CONN_STATUS { CLIENT_CONNECTING, CLIENT_CONNECTED, CLIENT_LINKDEAD,
@@ -1413,7 +1414,6 @@ public:
void DeleteBucket(std::string bucket_name); void DeleteBucket(std::string bucket_name);
std::string GetBucket(std::string bucket_name); std::string GetBucket(std::string bucket_name);
std::string GetBucketExpires(std::string bucket_name); std::string GetBucketExpires(std::string bucket_name);
std::string GetBucketKey();
std::string GetBucketRemaining(std::string bucket_name); std::string GetBucketRemaining(std::string bucket_name);
void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration = ""); void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration = "");
@@ -1443,6 +1443,8 @@ public:
void CalcHeroicBonuses(StatBonuses* newbon); void CalcHeroicBonuses(StatBonuses* newbon);
DataBucketKey GetScopedBucketKeys();
protected: protected:
void CommonDamage(Mob* other, int64 &damage, const uint16 spell_id, const EQ::skills::SkillType attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic, eSpecialAttacks specal = eSpecialAttacks::None); void CommonDamage(Mob* other, int64 &damage, const uint16 spell_id, const EQ::skills::SkillType attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic, eSpecialAttacks specal = eSpecialAttacks::None);
static uint16 GetProcID(uint16 spell_id, uint8 effect_index); static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
+6 -3
View File
@@ -1071,12 +1071,15 @@ void Mob::AI_Process() {
if (engaged) { if (engaged) {
if (IsNPC() && m_z_clip_check_timer.Check()) { if (IsNPC() && m_z_clip_check_timer.Check()) {
bool is_moving = IsMoving() && !(IsRooted() || IsStunned() || IsMezzed());
auto t = GetTarget(); auto t = GetTarget();
if (t) { if (is_moving && t) {
float self_z = GetZ() - GetZOffset(); float self_z = GetZ() - GetZOffset();
float target_z = t->GetPosition().z - t->GetZOffset(); float target_z = t->GetPosition().z - t->GetZOffset();
if (DistanceNoZ(GetPosition(), t->GetPosition()) < 75 && bool can_path_to = CastToNPC()->CanPathTo(t->GetX(), t->GetY(), t->GetZ());
std::abs(self_z - target_z) >= 25 && !CheckLosFN(t)) { bool within_distance = DistanceNoZ(GetPosition(), t->GetPosition()) < 75;
bool within_z_distance = std::abs(self_z - target_z) >= 25;
if (within_distance && within_z_distance && !can_path_to) {
float new_z = FindDestGroundZ(t->GetPosition()); float new_z = FindDestGroundZ(t->GetPosition());
GMMove(t->GetPosition().x, t->GetPosition().y, new_z + GetZOffset(), t->GetPosition().w, false); GMMove(t->GetPosition().x, t->GetPosition().y, new_z + GetZOffset(), t->GetPosition().w, false);
FaceTarget(t); FaceTarget(t);
+27 -1
View File
@@ -3825,9 +3825,14 @@ void NPC::HandleRoambox()
auto requested_y = EQ::Clamp((GetY() + move_y), m_roambox.min_y, m_roambox.max_y); auto requested_y = EQ::Clamp((GetY() + move_y), m_roambox.min_y, m_roambox.max_y);
auto requested_z = GetGroundZ(requested_x, requested_y); auto requested_z = GetGroundZ(requested_x, requested_y);
if (std::abs(requested_z - GetZ()) > 100) {
LogNPCRoamBox("[{}] | Failed to find reasonable ground [{}]", GetCleanName(), i);
continue;
}
std::vector<float> heights = {0, 250, -250}; std::vector<float> heights = {0, 250, -250};
for (auto &h: heights) { for (auto &h: heights) {
if (CheckLosFN(requested_x, requested_y, requested_z + h, GetSize())) { if (CanPathTo(requested_x, requested_y, requested_z + h)) {
LogNPCRoamBox("[{}] Found line of sight to path attempt [{}] at height [{}]", GetCleanName(), i, h); LogNPCRoamBox("[{}] Found line of sight to path attempt [{}] at height [{}]", GetCleanName(), i, h);
can_path = true; can_path = true;
break; break;
@@ -3942,3 +3947,24 @@ void NPC::SetTaunting(bool is_taunting) {
GetOwner()->CastToClient()->SetPetCommandState(PET_BUTTON_TAUNT, is_taunting); GetOwner()->CastToClient()->SetPetCommandState(PET_BUTTON_TAUNT, is_taunting);
} }
} }
bool NPC::CanPathTo(float x, float y, float z)
{
PathfinderOptions opts;
opts.smooth_path = true;
opts.step_size = RuleR(Pathing, NavmeshStepSize);
opts.offset = GetZOffset();
opts.flags = PathingNotDisabled ^ PathingZoneLine;
bool partial = false;
bool stuck = false;
auto route = zone->pathing->FindPath(
glm::vec3(GetX(), GetY(), GetZ()),
glm::vec3(x, y, z),
partial,
stuck,
opts
);
return !route.empty();
}
+2
View File
@@ -541,6 +541,8 @@ public:
static LootDropEntries_Struct NewLootDropEntry(); static LootDropEntries_Struct NewLootDropEntry();
bool CanPathTo(float x, float y, float z);
protected: protected:
void HandleRoambox(); void HandleRoambox();
+6
View File
@@ -2947,6 +2947,11 @@ std::string Perl_Client_GetRaceAbbreviation(Client* self)
return GetPlayerRaceAbbreviation(self->GetBaseRace()); return GetPlayerRaceAbbreviation(self->GetBaseRace());
} }
void Perl_Client_SetLDoNPoints(Client* self, uint32 theme_id, uint32 points)
{
self->SetLDoNPoints(theme_id, points);
}
void perl_register_client() void perl_register_client()
{ {
perl::interpreter perl(PERL_GET_THX); perl::interpreter perl(PERL_GET_THX);
@@ -3394,6 +3399,7 @@ void perl_register_client()
package.add("SetInvulnerableEnvironmentDamage", &Perl_Client_SetInvulnerableEnvironmentDamage); package.add("SetInvulnerableEnvironmentDamage", &Perl_Client_SetInvulnerableEnvironmentDamage);
package.add("SetItemCooldown", &Perl_Client_SetItemCooldown); package.add("SetItemCooldown", &Perl_Client_SetItemCooldown);
package.add("SetLanguageSkill", &Perl_Client_SetLanguageSkill); package.add("SetLanguageSkill", &Perl_Client_SetLanguageSkill);
package.add("SetLDoNPoints", &Perl_Client_SetLDoNPoints);
package.add("SetMaterial", &Perl_Client_SetMaterial); package.add("SetMaterial", &Perl_Client_SetMaterial);
package.add("SetPEQZoneFlag", &Perl_Client_SetPEQZoneFlag); package.add("SetPEQZoneFlag", &Perl_Client_SetPEQZoneFlag);
package.add("SetPVP", &Perl_Client_SetPVP); package.add("SetPVP", &Perl_Client_SetPVP);
+1 -1
View File
@@ -2420,7 +2420,7 @@ std::string Perl_Mob_GetBucketExpires(Mob* self, std::string bucket_name) // @ca
std::string Perl_Mob_GetBucketKey(Mob* self) // @categories Script Utility std::string Perl_Mob_GetBucketKey(Mob* self) // @categories Script Utility
{ {
return self->GetBucketKey(); return {};
} }
std::string Perl_Mob_GetBucketRemaining(Mob* self, std::string bucket_name) // @categories Script Utility std::string Perl_Mob_GetBucketRemaining(Mob* self, std::string bucket_name) // @categories Script Utility
+3 -6
View File
@@ -5877,13 +5877,10 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) {
return true; // If the entry in the spell_buckets table has nothing set for the qglobal name, allow scribing. return true; // If the entry in the spell_buckets table has nothing set for the qglobal name, allow scribing.
} }
auto new_bucket_name = fmt::format( DataBucketKey k = GetScopedBucketKeys();
"{}-{}", k.key = spell_bucket_name;
GetBucketKey(),
spell_bucket_name
);
auto bucket_value = DataBucket::GetData(new_bucket_name); auto bucket_value = DataBucket::GetData(k);
if (!bucket_value.empty()) { if (!bucket_value.empty()) {
if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) { if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) {
if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) { if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) {
+8 -1
View File
@@ -846,8 +846,15 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
glm::vec3 current_loc(m_Position); glm::vec3 current_loc(m_Position);
float new_z = GetFixedZ(current_loc, z_find_offset); float new_z = GetFixedZ(current_loc, z_find_offset);
if (new_z == m_Position.z) // reject z if it is too far from the current z
if (std::abs(new_z - m_Position.z) > 100) {
return; return;
}
// reject if it's the same as the current z
if (new_z == m_Position.z) {
return;
}
if ((new_z > -2000) && new_z != BEST_Z_INVALID) { if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
if (RuleB(Map, MobZVisualDebug)) { if (RuleB(Map, MobZVisualDebug)) {