Compare commits

...

13 Commits

Author SHA1 Message Date
Akkadius 2d61cd2b9a [Release] 22.21.1 2023-07-18 20:50:56 -05:00
Vayle b06505b80a [Cleanup] Remove arbitrary teleport blocking in Tutorial and Load zones (#3506) 2023-07-18 20:56:21 -04:00
Chris Miles 4c2f9a4423 [Databuckets] Fix issue with expired databuckets not being expired and returned properly (#3504) 2023-07-18 17:18:36 -05:00
Alex King fb3159b657 [Bug Fix] #set title_suffix Argument Position (#3505)
# Notes
- Off by one on argument index.
2023-07-18 18:02:25 -04:00
Michael 8ebf5bbb78 [Bug] Show Petition and Show Petition_Info fix (#3503)
Where Statement was using incorrect field name.
2023-07-18 17:15:21 -04:00
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
29 changed files with 472 additions and 305 deletions
+46
View File
@@ -1,3 +1,49 @@
## [22.21.1] - 07/18/2023
### Bug
* Show Petition and Show Petition_Info fix ([#3503](https://github.com/EQEmu/Server/pull/3503)) @fryguy503 2023-07-18
### Code
* Remove arbitrary teleport blocking in Tutorial and Load zones ([#3506](https://github.com/EQEmu/Server/pull/3506)) @Valorith 2023-07-19
### Databuckets
* Fix issue with expired databuckets not being expired and returned properly ([#3504](https://github.com/EQEmu/Server/pull/3504)) @Akkadius 2023-07-18
### Fixes
* #set title_suffix Argument Position ([#3505](https://github.com/EQEmu/Server/pull/3505)) @Kinglykrab 2023-07-18
## [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
### Bots
+27 -6
View File
@@ -4768,14 +4768,14 @@ UNIQUE KEY `name` (`name`)
.match = "",
.sql = R"(
ALTER TABLE `raid_members`
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 `note` VARCHAR(64) DEFAULT("") NOT NULL AFTER `is_assister`;
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 `note` VARCHAR(64) DEFAULT '' NOT NULL AFTER `is_assister`;
ALTER TABLE `raid_details`
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_3` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `marked_npc_2`;
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_3` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `marked_npc_2`;
)",
},
ManifestEntry{
@@ -4804,6 +4804,27 @@ UNIQUE KEY `name` (`name`)
PRIMARY KEY (`id`),
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 value;
uint32_t expires;
int64_t character_id;
int64_t npc_id;
int64_t bot_id;
};
static std::string PrimaryKey()
@@ -38,6 +41,9 @@ public:
"`key`",
"value",
"expires",
"character_id",
"npc_id",
"bot_id",
};
}
@@ -48,6 +54,9 @@ public:
"`key`",
"value",
"expires",
"character_id",
"npc_id",
"bot_id",
};
}
@@ -88,10 +97,13 @@ public:
{
DataBuckets e{};
e.id = 0;
e.key_ = "";
e.value = "";
e.expires = 0;
e.id = 0;
e.key_ = "";
e.value = "";
e.expires = 0;
e.character_id = 0;
e.npc_id = 0;
e.bot_id = 0;
return e;
}
@@ -128,10 +140,13 @@ public:
if (results.RowCount() == 1) {
DataBuckets e{};
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
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;
}
@@ -168,6 +183,9 @@ public:
v.push_back(columns[1] + " = '" + Strings::Escape(e.key_) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'");
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(
fmt::format(
@@ -193,6 +211,9 @@ public:
v.push_back("'" + Strings::Escape(e.key_) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'");
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(
fmt::format(
@@ -226,6 +247,9 @@ public:
v.push_back("'" + Strings::Escape(e.key_) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'");
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) + ")");
}
@@ -259,10 +283,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets e{};
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
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);
}
@@ -287,10 +314,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets e{};
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.id = strtoull(row[0], nullptr, 10);
e.key_ = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
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);
}
+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_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old 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(Chat)
+2 -2
View File
@@ -25,7 +25,7 @@
// Build variables
// 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.1-dev" // always append -dev to the current version for custom-builds
#define LOGIN_VERSION "0.8.0"
#define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__
@@ -42,7 +42,7 @@
* 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
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "eqemu-server",
"version": "22.20.0",
"version": "22.21.1",
"repository": {
"type": "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;
if (!bucket_name.empty()) {
const auto full_name = fmt::format(
"{}-{}",
GetBucketKey(),
bucket_name
);
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
if (IsOfClientBot()) {
bucket_value = DataBucket::CheckBucketKey(this, full_name);
bucket_value = DataBucket::CheckBucketKey(this, k);
}
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)
{
if (!bucket_name.empty() && !bucket_value.empty()) {
auto full_name = fmt::format(
"{}-{}",
GetBucketKey(),
bucket_name
);
// try to fetch from bot first
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
auto player_value = DataBucket::CheckBucketKey(this, full_name);
auto player_value = DataBucket::CheckBucketKey(this, k);
if (player_value.empty() && GetBotOwner()) {
full_name = fmt::format(
"{}-{}",
GetBotOwner()->GetBucketKey(),
bucket_name
);
// fetch from owner
k = GetBotOwner()->GetScopedBucketKeys();
player_value = DataBucket::CheckBucketKey(GetBotOwner(), full_name);
player_value = DataBucket::CheckBucketKey(GetBotOwner(), k);
if (player_value.empty()) {
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)
{
if (rule_value) {
if (!rule_value) {
bot_owner->Message(Chat::White, "Bot command %s is not enabled on this server.", command);
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)
{
if (helper_command_disabled(c, RuleB(Bots, AllowPickpocketCommand), "pickpocket")) {
return;
}
if (helper_command_alias_fail(c, "bot_command_pickpocket", sep->arg[0], "pickpocket")) {
return;
}
@@ -10032,7 +10036,9 @@ void bot_command_pickpocket(Client *c, const Seperator *sep)
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_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");
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));
+4 -6
View File
@@ -853,13 +853,11 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
auto bucket_name = ml.bucket_name;
auto const& bucket_value = ml.bucket_value;
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()) {
continue;
}
+162 -158
View File
@@ -1,173 +1,126 @@
#include "data_bucket.h"
#include "zonedb.h"
#include "mob.h"
#include <ctime>
#include <cctype>
#include "../common/repositories/data_buckets_repository.h"
/**
* Persists data via bucket_name as key
* @param bucket_key
* @param bucket_value
* @param expires_time
*/
void DataBucket::SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time) {
uint64 bucket_id = DataBucket::DoesBucketExist(bucket_key);
void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
{
auto k = DataBucketKey{
.key = bucket_key,
.value = bucket_value,
.expires = expires_time,
.character_id = 0,
.npc_id = 0,
.bot_id = 0
};
std::string query;
DataBucket::SetData(k);
}
void DataBucket::SetData(const DataBucketKey &k)
{
auto b = DataBucketsRepository::NewEntity();
auto r = GetData(k);
// if we have an entry, use it
if (r.id > 0) {
b = r;
}
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;
if (!expires_time.empty()) {
if (isalpha(expires_time[0]) || isalpha(expires_time[expires_time.length() - 1])) {
expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(expires_time);
} else {
expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(expires_time);
if (!k.expires.empty()) {
expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(k.expires);
if (isalpha(k.expires[0]) || isalpha(k.expires[k.expires.length() - 1])) {
expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(k.expires);
}
}
if (bucket_id > 0) {
std::string update_expired_time;
if (expires_time_unix > 0) {
update_expired_time = StringFormat(", `expires` = %lld ", expires_time_unix);
}
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
);
b.expires = expires_time_unix;
b.value = k.value;
DataBucketsRepository::UpdateOne(database, b);
}
else {
query = StringFormat(
"INSERT INTO `data_buckets` (`key`, `value`, `expires`) VALUES ('%s', '%s', '%lld')",
Strings::Escape(bucket_key).c_str(),
Strings::Escape(bucket_value).c_str(),
expires_time_unix
);
b.expires = expires_time_unix;
b.key_ = k.key;
b.value = k.value;
DataBucketsRepository::InsertOne(database, b);
}
database.QueryDatabase(query);
}
/**
* Retrieves data via bucket_name as key
* @param bucket_key
* @return
*/
std::string DataBucket::GetData(const std::string& bucket_key) {
std::string query = StringFormat(
"SELECT `value` 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);
if (!results.Success()) {
return std::string();
}
if (results.RowCount() != 1)
return std::string();
auto row = results.begin();
return std::string(row[0]);
}
/**
* Retrieves data expires time via bucket_name as key
* @param bucket_key
* @return
*/
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);
if (!results.Success()) {
return std::string();
}
if (results.RowCount() != 1)
return std::string();
auto row = results.begin();
return std::string(row[0]);
}
std::string DataBucket::GetDataRemaining(const std::string& bucket_key) {
if (DataBucket::GetDataExpires(bucket_key).empty()) {
return "0";
}
std::string query = fmt::format(
"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)
std::string DataBucket::GetData(const std::string &bucket_key)
{
auto l = BaseDataBucketsRepository::GetWhere(
DataBucketKey k = {};
k.key = bucket_key;
return GetData(k).value;
}
DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k)
{
auto r = DataBucketsRepository::GetWhere(
database,
fmt::format(
"`key` LIKE '{}-%'",
Strings::Escape(mob->GetBucketKey())
"{} `key` = '{}' LIMIT 1",
DataBucket::GetScopedDbFilters(k),
k.key
)
);
if (r.empty()) {
return {};
}
// if the entry has expired, delete it
if (r[0].expires > 0 && r[0].expires < (long long) std::time(nullptr)) {
DeleteData(k);
return {};
}
return r[0];
}
std::string DataBucket::GetDataExpires(const std::string &bucket_key)
{
DataBucketKey k = {};
k.key = bucket_key;
return GetDataExpires(k);
}
std::string DataBucket::GetDataRemaining(const std::string &bucket_key)
{
DataBucketKey k = {};
k.key = bucket_key;
return GetDataRemaining(k);
}
bool DataBucket::DeleteData(const std::string &bucket_key)
{
DataBucketKey r = {};
r.key = bucket_key;
return DeleteData(r);
}
bool DataBucket::GetDataBuckets(Mob *mob)
{
DataBucketKey k = mob->GetScopedBucketKeys();
auto l = BaseDataBucketsRepository::GetWhere(
database,
fmt::format(
"{} (`expires` > {} OR `expires` = 0)",
DataBucket::GetScopedDbFilters(k),
(long long) std::time(nullptr)
)
);
@@ -179,10 +132,10 @@ bool DataBucket::GetDataBuckets(Mob* mob)
DataBucketCache d;
for (const auto& e : l) {
d.bucket_id = e.id;
d.bucket_key = e.key_;
d.bucket_value = e.value;
for (const auto &e: l) {
d.bucket_id = e.id;
d.bucket_key = e.key_;
d.bucket_value = e.value;
d.bucket_expires = e.expires;
mob->m_data_bucket_cache.emplace_back(d);
@@ -191,11 +144,11 @@ bool DataBucket::GetDataBuckets(Mob* mob)
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;
for (const auto &d : mob->m_data_bucket_cache) {
if (d.bucket_key == full_name) {
std::string bucket_value;
for (const auto &d: mob->m_data_bucket_cache) {
if (d.bucket_key == k.key) {
bucket_value = d.bucket_value;
break;
}
@@ -203,3 +156,54 @@ std::string DataBucket::CheckBucketKey(const Mob* mob, std::string_view full_nam
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 = GetData(k);
if (r.id == 0) {
return {};
}
return fmt::format("{}", r.expires);
}
std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
{
auto r = GetData(k);
if (r.id == 0) {
return "0";
}
return fmt::format("{}", r.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 "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 {
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 bool DeleteData(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 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 uint64 DoesBucketExist(const std::string& bucket_key);
static bool GetDataBuckets(Mob* mob);
// scoped bucket methods
static void SetData(const DataBucketKey& k);
static bool DeleteData(const DataBucketKey& k);
static DataBucketsRepository::DataBuckets 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
+6 -20
View File
@@ -1273,27 +1273,13 @@ uint8 Client::GetCharMaxLevelFromQGlobal() {
uint8 Client::GetCharMaxLevelFromBucket()
{
auto new_bucket_name = fmt::format(
"{}-CharMaxLevel",
GetBucketKey()
);
DataBucketKey k = GetScopedBucketKeys();
k.key = "CharMaxLevel";
auto bucket_value = DataBucket::GetData(new_bucket_name);
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 (Strings::IsNumber(bucket_value)) {
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
auto b = DataBucket::GetData(k);
if (!b.value.empty()) {
if (Strings::IsNumber(b.value)) {
return static_cast<uint8>(Strings::ToUnsignedInt(b.value));
}
}
+2 -2
View File
@@ -10,8 +10,8 @@ void SetTitleSuffix(Client *c, const Seperator *sep)
return;
}
const bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string suffix = is_remove ? "" : sep->argplus[1];
const bool is_remove = !strcasecmp(sep->argplus[2], "-1");
std::string suffix = is_remove ? "" : sep->argplus[2];
auto t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
+1 -1
View File
@@ -44,7 +44,7 @@ void ShowPetition(Client *c, const Seperator *sep)
const uint32 petition_id = Strings::ToUnsignedInt(sep->arg[2]);
const auto& l = PetitionsRepository::GetWhere(database, fmt::format("petition_id = {}", petition_id));
const auto& l = PetitionsRepository::GetWhere(database, fmt::format("petid = {}", petition_id));
if (l.empty()) {
c->Message(
Chat::White,
+1 -1
View File
@@ -49,7 +49,7 @@ void ShowPetitionInfo(Client *c, const Seperator *sep)
const uint32 petition_id = Strings::ToUnsignedInt(sep->arg[2]);
const auto& l = PetitionsRepository::GetWhere(database, fmt::format("petition_id = {}", petition_id));
const auto& l = PetitionsRepository::GetWhere(database, fmt::format("petid = {}", petition_id));
if (l.empty()) {
c->Message(
Chat::White,
+7
View File
@@ -3092,6 +3092,12 @@ std::string Lua_Client::GetRaceAbbreviation()
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() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@@ -3536,6 +3542,7 @@ luabind::scope lua_register_client() {
.def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption)
.def("SetItemCooldown", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetItemCooldown)
.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("SetPEQZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::SetPEQZoneFlag)
.def("SetPVP", (void(Lua_Client::*)(bool))&Lua_Client::SetPVP)
+1
View File
@@ -473,6 +473,7 @@ public:
uint32 GetEXPForLevel(uint16 check_level);
std::string GetClassAbbreviation();
std::string GetRaceAbbreviation();
void SetLDoNPoints(uint32 theme_id, uint32 points);
void ApplySpell(int spell_id);
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()
{
Lua_Safe_Call_String();
return self->GetBucketKey();
return {};
}
std::string Lua_Mob::GetBucketRemaining(std::string bucket_name)
+54 -31
View File
@@ -8049,54 +8049,63 @@ void Mob::SetCanOpenDoors(bool can_open)
m_can_open_doors = can_open;
}
void Mob::DeleteBucket(std::string bucket_name) {
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
DataBucket::DeleteData(full_bucket_name);
void Mob::DeleteBucket(std::string bucket_name)
{
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
DataBucket::DeleteData(k);
}
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);
if (!bucket_value.empty()) {
return bucket_value;
std::string Mob::GetBucket(std::string bucket_name)
{
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
auto b = DataBucket::GetData(k);
if (!b.value.empty()) {
return b.value;
}
return std::string();
return {};
}
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);
std::string Mob::GetBucketExpires(std::string bucket_name)
{
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
std::string bucket_expiration = DataBucket::GetDataExpires(k);
if (!bucket_expiration.empty()) {
return bucket_expiration;
}
return std::string();
return {};
}
std::string Mob::GetBucketKey() {
if (IsClient()) {
return fmt::format("character-{}", CastToClient()->CharacterID());
} else if (IsNPC()) {
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)
{
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
std::string Mob::GetBucketRemaining(std::string bucket_name) {
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
std::string bucket_remaining = DataBucket::GetDataRemaining(full_bucket_name);
std::string bucket_remaining = DataBucket::GetDataRemaining(k);
if (!bucket_remaining.empty() && Strings::ToInt(bucket_remaining) > 0) {
return bucket_remaining;
} else if (Strings::ToInt(bucket_remaining) == 0) {
}
else if (Strings::ToInt(bucket_remaining) == 0) {
return "0";
}
return std::string();
return {};
}
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);
void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration)
{
DataBucketKey k = GetScopedBucketKeys();
k.key = bucket_name;
k.expires = expiration;
k.value = bucket_value;
DataBucket::SetData(k);
}
std::string Mob::GetMobDescription()
@@ -8329,3 +8338,17 @@ std::string Mob::GetClassPlural()
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
};
class DataBucketKey;
class Mob : public Entity {
public:
enum CLIENT_CONN_STATUS { CLIENT_CONNECTING, CLIENT_CONNECTED, CLIENT_LINKDEAD,
@@ -1413,7 +1414,6 @@ public:
void DeleteBucket(std::string bucket_name);
std::string GetBucket(std::string bucket_name);
std::string GetBucketExpires(std::string bucket_name);
std::string GetBucketKey();
std::string GetBucketRemaining(std::string bucket_name);
void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration = "");
@@ -1443,6 +1443,8 @@ public:
void CalcHeroicBonuses(StatBonuses* newbon);
DataBucketKey GetScopedBucketKeys();
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);
static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
+9 -6
View File
@@ -1071,12 +1071,15 @@ void Mob::AI_Process() {
if (engaged) {
if (IsNPC() && m_z_clip_check_timer.Check()) {
auto t = GetTarget();
if (t) {
float self_z = GetZ() - GetZOffset();
float target_z = t->GetPosition().z - t->GetZOffset();
if (DistanceNoZ(GetPosition(), t->GetPosition()) < 75 &&
std::abs(self_z - target_z) >= 25 && !CheckLosFN(t)) {
bool is_moving = IsMoving() && !(IsRooted() || IsStunned() || IsMezzed());
auto t = GetTarget();
if (is_moving && t) {
float self_z = GetZ() - GetZOffset();
float target_z = t->GetPosition().z - t->GetZOffset();
bool can_path_to = CastToNPC()->CanPathTo(t->GetX(), t->GetY(), t->GetZ());
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());
GMMove(t->GetPosition().x, t->GetPosition().y, new_z + GetZOffset(), t->GetPosition().w, false);
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_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};
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);
can_path = true;
break;
@@ -3942,3 +3947,24 @@ void NPC::SetTaunting(bool 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();
bool CanPathTo(float x, float y, float z);
protected:
void HandleRoambox();
+6
View File
@@ -2947,6 +2947,11 @@ std::string Perl_Client_GetRaceAbbreviation(Client* self)
return GetPlayerRaceAbbreviation(self->GetBaseRace());
}
void Perl_Client_SetLDoNPoints(Client* self, uint32 theme_id, uint32 points)
{
self->SetLDoNPoints(theme_id, points);
}
void perl_register_client()
{
perl::interpreter perl(PERL_GET_THX);
@@ -3394,6 +3399,7 @@ void perl_register_client()
package.add("SetInvulnerableEnvironmentDamage", &Perl_Client_SetInvulnerableEnvironmentDamage);
package.add("SetItemCooldown", &Perl_Client_SetItemCooldown);
package.add("SetLanguageSkill", &Perl_Client_SetLanguageSkill);
package.add("SetLDoNPoints", &Perl_Client_SetLDoNPoints);
package.add("SetMaterial", &Perl_Client_SetMaterial);
package.add("SetPEQZoneFlag", &Perl_Client_SetPEQZoneFlag);
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
{
return self->GetBucketKey();
return {};
}
std::string Perl_Mob_GetBucketRemaining(Mob* self, std::string bucket_name) // @categories Script Utility
+8 -24
View File
@@ -714,19 +714,6 @@ bool Mob::DoCastingChecksZoneRestrictions(bool check_on_casting, int32 spell_id)
return false;
}
}
/*
Zones where you can not gate.
*/
if (IsClient() &&
(zone->GetZoneID() == Zones::TUTORIAL || zone->GetZoneID() == Zones::LOAD) &&
CastToClient()->Admin() < AccountStatus::QuestTroupe) {
if (IsEffectInSpell(spell_id, SE_Gate) ||
IsEffectInSpell(spell_id, SE_Translocate) ||
IsEffectInSpell(spell_id, SE_Teleport)) {
Message(Chat::White, "The Gods brought you here, only they can send you away.");
return false;
}
}
}
return true;
@@ -5877,20 +5864,17 @@ 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.
}
auto new_bucket_name = fmt::format(
"{}-{}",
GetBucketKey(),
spell_bucket_name
);
DataBucketKey k = GetScopedBucketKeys();
k.key = spell_bucket_name;
auto bucket_value = DataBucket::GetData(new_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)) {
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 (bucket_value == spell_bucket_value) {
if (b.value == spell_bucket_value) {
return true; // If value is equal to spell bucket value, allow scribing.
}
}
@@ -5902,7 +5886,7 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) {
spell_bucket_name
);
bucket_value = DataBucket::GetData(old_bucket_name);
auto 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)) {
+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);
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;
}
// 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 (RuleB(Map, MobZVisualDebug)) {