mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-07 21:32:26 +00:00
[Character] Convert Clear/Delete/Get/Update of Character Item Recast to Repositories (#3857)
* [Character] Convert Clear/Delete/Get/Update of Character Item Recast to Repositories - Convert `ClearOldRecastTimestamps`, `DeleteItemRecast`, `GetItemRecastTimeStamp`, `GetItemRecastTimestamps`, and `UpdateItemRecast` to repositories. * Update shareddb.cpp * Update shareddb.cpp * Update zonedb.cpp
This commit is contained in:
parent
0ea825e9a4
commit
a724e92638
@ -6,7 +6,7 @@
|
|||||||
* Any modifications to base repositories are to be made by the generator only
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
*
|
*
|
||||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
* @docs https://docs.eqemu.io/developer/repositories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
#ifndef EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
||||||
@ -16,11 +16,12 @@
|
|||||||
#include "../../strings.h"
|
#include "../../strings.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
class BaseCharacterItemRecastRepository {
|
class BaseCharacterItemRecastRepository {
|
||||||
public:
|
public:
|
||||||
struct CharacterItemRecast {
|
struct CharacterItemRecast {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint16_t recast_type;
|
uint32_t recast_type;
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,8 +113,9 @@ public:
|
|||||||
{
|
{
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} WHERE id = {} LIMIT 1",
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
BaseSelect(),
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
character_item_recast_id
|
character_item_recast_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -123,7 +125,7 @@ public:
|
|||||||
CharacterItemRecast e{};
|
CharacterItemRecast e{};
|
||||||
|
|
||||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
e.recast_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
|
e.recast_type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
@ -251,7 +253,7 @@ public:
|
|||||||
CharacterItemRecast e{};
|
CharacterItemRecast e{};
|
||||||
|
|
||||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
e.recast_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
|
e.recast_type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
@ -278,7 +280,7 @@ public:
|
|||||||
CharacterItemRecast e{};
|
CharacterItemRecast e{};
|
||||||
|
|
||||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
e.recast_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
|
e.recast_type = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
e.timestamp = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
@ -338,6 +340,66 @@ public:
|
|||||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string BaseReplace()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"REPLACE INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ReplaceOne(
|
||||||
|
Database& db,
|
||||||
|
const CharacterItemRecast &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.recast_type));
|
||||||
|
v.push_back(std::to_string(e.timestamp));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseReplace(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ReplaceMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<CharacterItemRecast> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.recast_type));
|
||||||
|
v.push_back(std::to_string(e.timestamp));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseReplace(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
#endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
#include "repositories/starting_items_repository.h"
|
#include "repositories/starting_items_repository.h"
|
||||||
#include "path_manager.h"
|
#include "path_manager.h"
|
||||||
#include "repositories/loottable_repository.h"
|
#include "repositories/loottable_repository.h"
|
||||||
|
#include "repositories/character_item_recast_repository.h"
|
||||||
|
|
||||||
namespace ItemField
|
namespace ItemField
|
||||||
{
|
{
|
||||||
@ -882,34 +883,49 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQ::InventoryPr
|
|||||||
std::map<uint32, uint32> SharedDatabase::GetItemRecastTimestamps(uint32 char_id)
|
std::map<uint32, uint32> SharedDatabase::GetItemRecastTimestamps(uint32 char_id)
|
||||||
{
|
{
|
||||||
std::map<uint32, uint32> timers;
|
std::map<uint32, uint32> timers;
|
||||||
const std::string query = StringFormat("SELECT recast_type,timestamp FROM character_item_recast WHERE id=%u", char_id);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
if (!results.Success() || results.RowCount() == 0)
|
|
||||||
return timers;
|
|
||||||
|
|
||||||
for (auto& row = results.begin(); row != results.end(); ++row)
|
const auto& l = CharacterItemRecastRepository::GetWhere(
|
||||||
timers[Strings::ToUnsignedInt(row[0])] = Strings::ToUnsignedInt(row[1]);
|
*this,
|
||||||
return timers; // RVO or move assigned
|
fmt::format(
|
||||||
|
"`id` = {}",
|
||||||
|
char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (l.empty()) {
|
||||||
|
return timers;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& e : l) {
|
||||||
|
timers[e.recast_type] = e.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return timers;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SharedDatabase::GetItemRecastTimestamp(uint32 char_id, uint32 recast_type)
|
uint32 SharedDatabase::GetItemRecastTimestamp(uint32 char_id, uint32 recast_type)
|
||||||
{
|
{
|
||||||
const std::string query = StringFormat("SELECT timestamp FROM character_item_recast WHERE id=%u AND recast_type=%u",
|
const auto& l = CharacterItemRecastRepository::GetWhere(
|
||||||
char_id, recast_type);
|
*this,
|
||||||
auto results = QueryDatabase(query);
|
fmt::format(
|
||||||
if (!results.Success() || results.RowCount() == 0)
|
"`id` = {} AND `recast_type` = {}",
|
||||||
return 0;
|
char_id,
|
||||||
|
recast_type
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
auto& row = results.begin();
|
return l.empty() ? 0 : l[0].timestamp;
|
||||||
return Strings::ToUnsignedInt(row[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedDatabase::ClearOldRecastTimestamps(uint32 char_id)
|
void SharedDatabase::ClearOldRecastTimestamps(uint32 char_id)
|
||||||
{
|
{
|
||||||
// This actually isn't strictly live-like. Live your recast timestamps are forever
|
CharacterItemRecastRepository::DeleteWhere(
|
||||||
const std::string query =
|
*this,
|
||||||
StringFormat("DELETE FROM character_item_recast WHERE id = %u and timestamp < UNIX_TIMESTAMP()", char_id);
|
fmt::format(
|
||||||
QueryDatabase(query);
|
"`id` = {} AND `timestamp` < UNIX_TIMESTAMP()",
|
||||||
|
char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id)
|
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id)
|
||||||
|
|||||||
156
zone/spells.cpp
156
zone/spells.cpp
@ -6504,10 +6504,13 @@ void Client::SendItemRecastTimer(int32 recast_type, uint32 recast_delay, bool in
|
|||||||
|
|
||||||
if (recast_delay) {
|
if (recast_delay) {
|
||||||
auto outapp = new EQApplicationPacket(OP_ItemRecastDelay, sizeof(ItemRecastDelay_Struct));
|
auto outapp = new EQApplicationPacket(OP_ItemRecastDelay, sizeof(ItemRecastDelay_Struct));
|
||||||
ItemRecastDelay_Struct *ird = (ItemRecastDelay_Struct *)outapp->pBuffer;
|
|
||||||
ird->recast_delay = recast_delay;
|
auto ird = (ItemRecastDelay_Struct *) outapp->pBuffer;
|
||||||
ird->recast_type = static_cast<uint32>(recast_type);
|
|
||||||
|
ird->recast_delay = recast_delay;
|
||||||
|
ird->recast_type = static_cast<uint32>(recast_type);
|
||||||
ird->ignore_casting_requirement = in_ignore_casting_requirement; //True allows reset of item cast timers
|
ird->ignore_casting_requirement = in_ignore_casting_requirement; //True allows reset of item cast timers
|
||||||
|
|
||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
@ -6515,150 +6518,157 @@ void Client::SendItemRecastTimer(int32 recast_type, uint32 recast_delay, bool in
|
|||||||
|
|
||||||
void Client::SetItemRecastTimer(int32 spell_id, uint32 inventory_slot)
|
void Client::SetItemRecastTimer(int32 spell_id, uint32 inventory_slot)
|
||||||
{
|
{
|
||||||
EQ::ItemInstance *item = CastToClient()->GetInv().GetItem(inventory_slot);
|
auto item = CastToClient()->GetInv().GetItem(inventory_slot);
|
||||||
|
|
||||||
int recast_delay = 0;
|
|
||||||
int recast_type = 0;
|
|
||||||
bool from_augment = false;
|
|
||||||
int item_casting = 0;
|
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
item_casting = item->GetItem()->ID;
|
|
||||||
|
|
||||||
//Check primary item.
|
uint32 recast_delay = 0;
|
||||||
if (item->GetItem()->RecastDelay > 0) {
|
int recast_type = 0;
|
||||||
|
uint32 item_id = item->GetItem()->ID;
|
||||||
|
bool from_augment = false;
|
||||||
|
|
||||||
|
if (item->GetItem()->RecastDelay > 0) { // Check item
|
||||||
recast_type = item->GetItem()->RecastType;
|
recast_type = item->GetItem()->RecastType;
|
||||||
recast_delay = item->GetItem()->RecastDelay;
|
recast_delay = item->GetItem()->RecastDelay;
|
||||||
}
|
} else { // Check augments
|
||||||
//Check augmenent
|
|
||||||
else{
|
|
||||||
for (int r = EQ::invaug::SOCKET_BEGIN; r <= EQ::invaug::SOCKET_END; r++) {
|
for (int r = EQ::invaug::SOCKET_BEGIN; r <= EQ::invaug::SOCKET_END; r++) {
|
||||||
const EQ::ItemInstance* aug_i = item->GetAugment(r);
|
const auto aug = item->GetAugment(r);
|
||||||
|
|
||||||
if (!aug_i) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const EQ::ItemData* aug = aug_i->GetItem();
|
|
||||||
if (!aug) {
|
if (!aug) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aug->Click.Effect == spell_id) {
|
const auto aug_data = aug->GetItem();
|
||||||
recast_delay = aug_i->GetItem()->RecastDelay;
|
if (!aug_data) {
|
||||||
recast_type = aug_i->GetItem()->RecastType;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aug_data->Click.Effect == spell_id) {
|
||||||
|
recast_delay = aug->GetItem()->RecastDelay;
|
||||||
|
recast_type = aug->GetItem()->RecastType;
|
||||||
from_augment = true;
|
from_augment = true;
|
||||||
item_casting = aug_i->GetItem()->ID;
|
item_id = aug->GetItem()->ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//must use SPA 415 with focus (SPA 310) to reduce item recast
|
//must use SPA 415 with focus (SPA 310) to reduce item recast
|
||||||
int reduction = GetFocusEffect(focusReduceRecastTime, spell_id);
|
int reduction = GetFocusEffect(focusReduceRecastTime, spell_id);
|
||||||
if (reduction) {
|
if (reduction) {
|
||||||
recast_delay -= reduction;
|
recast_delay -= reduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
recast_delay = std::max(recast_delay, 0);
|
recast_delay = std::max(recast_delay, static_cast<uint32>(0));
|
||||||
|
|
||||||
if (recast_delay > 0) {
|
if (recast_delay > 0) {
|
||||||
|
|
||||||
if (recast_type != RECAST_TYPE_UNLINKED_ITEM) {
|
if (recast_type != RECAST_TYPE_UNLINKED_ITEM) {
|
||||||
GetPTimers().Start((pTimerItemStart + recast_type), static_cast<uint32>(recast_delay));
|
GetPTimers().Start((pTimerItemStart + recast_type), recast_delay);
|
||||||
database.UpdateItemRecast(
|
database.UpdateItemRecast(
|
||||||
CharacterID(),
|
CharacterID(),
|
||||||
recast_type,
|
recast_type,
|
||||||
GetPTimers().Get(pTimerItemStart + recast_type)->GetReadyTimestamp()
|
GetPTimers().Get(pTimerItemStart + recast_type)->GetReadyTimestamp()
|
||||||
);
|
);
|
||||||
} else if (recast_type == RECAST_TYPE_UNLINKED_ITEM) {
|
} else if (recast_type == RECAST_TYPE_UNLINKED_ITEM) {
|
||||||
GetPTimers().Start((pTimerNegativeItemReuse * item_casting), static_cast<uint32>(recast_delay));
|
GetPTimers().Start((pTimerNegativeItemReuse * item_id), recast_delay);
|
||||||
database.UpdateItemRecast(
|
database.UpdateItemRecast(
|
||||||
CharacterID(),
|
CharacterID(),
|
||||||
item_casting,
|
item_id,
|
||||||
GetPTimers().Get(pTimerNegativeItemReuse * item_casting)->GetReadyTimestamp()
|
GetPTimers().Get(pTimerNegativeItemReuse * item_id)->GetReadyTimestamp()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from_augment) {
|
if (!from_augment) {
|
||||||
SendItemRecastTimer(recast_type, static_cast<uint32>(recast_delay));
|
SendItemRecastTimer(recast_type, recast_delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::DeleteItemRecastTimer(uint32 item_id)
|
void Client::DeleteItemRecastTimer(uint32 item_id)
|
||||||
{
|
{
|
||||||
const auto* d = database.GetItem(item_id);
|
const auto item = database.GetItem(item_id);
|
||||||
|
|
||||||
if (!d) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto recast_type = d->RecastType != RECAST_TYPE_UNLINKED_ITEM ? d->RecastType : item_id;
|
const auto recast_type = (
|
||||||
const int timer_id = d->RecastType != RECAST_TYPE_UNLINKED_ITEM ? (pTimerItemStart + recast_type) : (pTimerNegativeItemReuse * item_id);
|
item->RecastType != RECAST_TYPE_UNLINKED_ITEM ?
|
||||||
|
item->RecastType :
|
||||||
|
item_id
|
||||||
|
);
|
||||||
|
|
||||||
database.DeleteItemRecast(CharacterID(), recast_type);
|
const int timer_id = (
|
||||||
GetPTimers().Clear(&database, timer_id);
|
item->RecastType != RECAST_TYPE_UNLINKED_ITEM ?
|
||||||
|
(pTimerItemStart + recast_type) :
|
||||||
|
(pTimerNegativeItemReuse * item_id)
|
||||||
|
);
|
||||||
|
|
||||||
if (recast_type != RECAST_TYPE_UNLINKED_ITEM) {
|
database.DeleteItemRecast(CharacterID(), recast_type);
|
||||||
SendItemRecastTimer(recast_type, 1, true);
|
GetPTimers().Clear(&database, timer_id);
|
||||||
}
|
|
||||||
|
if (recast_type != RECAST_TYPE_UNLINKED_ITEM) {
|
||||||
|
SendItemRecastTimer(recast_type, 1, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::HasItemRecastTimer(int32 spell_id, uint32 inventory_slot)
|
bool Client::HasItemRecastTimer(int32 spell_id, uint32 inventory_slot)
|
||||||
{
|
{
|
||||||
EQ::ItemInstance *item = CastToClient()->GetInv().GetItem(inventory_slot);
|
auto item = CastToClient()->GetInv().GetItem(inventory_slot);
|
||||||
|
|
||||||
int recast_delay = 0;
|
if (!item || !item->GetItem()) {
|
||||||
int recast_type = 0;
|
|
||||||
int item_id = 0;
|
|
||||||
bool from_augment = false;
|
|
||||||
|
|
||||||
if (!item) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item->GetItem()) {
|
uint32 recast_delay = 0;
|
||||||
return false;
|
int recast_type = 0;
|
||||||
}
|
uint32 item_id = 0;
|
||||||
|
bool from_augment = false;
|
||||||
|
|
||||||
//Check primary item.
|
if (item->GetItem()->RecastDelay > 0) { // Check item
|
||||||
if (item->GetItem()->RecastDelay > 0) {
|
recast_type = item->GetItem()->RecastType;
|
||||||
recast_type = item->GetItem()->RecastType;
|
|
||||||
recast_delay = item->GetItem()->RecastDelay;
|
recast_delay = item->GetItem()->RecastDelay;
|
||||||
item_id = item->GetItem()->ID;
|
item_id = item->GetItem()->ID;
|
||||||
}
|
} else { // Check augments
|
||||||
//Check augmenent
|
|
||||||
else {
|
|
||||||
for (int r = EQ::invaug::SOCKET_BEGIN; r <= EQ::invaug::SOCKET_END; r++) {
|
for (int r = EQ::invaug::SOCKET_BEGIN; r <= EQ::invaug::SOCKET_END; r++) {
|
||||||
const EQ::ItemInstance* aug_i = item->GetAugment(r);
|
const auto aug = item->GetAugment(r);
|
||||||
|
|
||||||
if (!aug_i) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const EQ::ItemData* aug = aug_i->GetItem();
|
|
||||||
if (!aug) {
|
if (!aug) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aug->Click.Effect == spell_id) {
|
const auto aug_data = aug->GetItem();
|
||||||
if (aug_i->GetItem() && aug_i->GetItem()->RecastDelay > 0) {
|
if (!aug_data) {
|
||||||
recast_delay = aug_i->GetItem()->RecastDelay;
|
continue;
|
||||||
recast_type = aug_i->GetItem()->RecastType;
|
}
|
||||||
item_id = aug_i->GetItem()->ID;
|
|
||||||
|
if (aug_data->Click.Effect == spell_id) {
|
||||||
|
if (aug->GetItem() && aug->GetItem()->RecastDelay > 0) {
|
||||||
|
recast_delay = aug->GetItem()->RecastDelay;
|
||||||
|
recast_type = aug->GetItem()->RecastType;
|
||||||
|
item_id = aug->GetItem()->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//do not check if item has no recast delay.
|
|
||||||
if (!recast_delay) {
|
if (!recast_delay) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//if time is not expired, then it exists and therefore we have a recast on this item.
|
|
||||||
if (recast_type != RECAST_TYPE_UNLINKED_ITEM && !CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + recast_type), false)) {
|
if (
|
||||||
|
recast_type != RECAST_TYPE_UNLINKED_ITEM &&
|
||||||
|
!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + recast_type), false)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if (recast_type == RECAST_TYPE_UNLINKED_ITEM && !CastToClient()->GetPTimers().Expired(&database, (pTimerNegativeItemReuse * item_id), false)) {
|
} else if (
|
||||||
|
recast_type == RECAST_TYPE_UNLINKED_ITEM &&
|
||||||
|
!CastToClient()->GetPTimers().Expired(&database, (pTimerNegativeItemReuse * item_id), false)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include "../common/repositories/character_alternate_abilities_repository.h"
|
#include "../common/repositories/character_alternate_abilities_repository.h"
|
||||||
#include "../common/repositories/character_auras_repository.h"
|
#include "../common/repositories/character_auras_repository.h"
|
||||||
#include "../common/repositories/character_alt_currency_repository.h"
|
#include "../common/repositories/character_alt_currency_repository.h"
|
||||||
|
#include "../common/repositories/character_item_recast_repository.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -3279,23 +3280,26 @@ void ZoneDatabase::RemoveTempFactions(Client *client) {
|
|||||||
|
|
||||||
void ZoneDatabase::UpdateItemRecast(uint32 character_id, uint32 recast_type, uint32 timestamp)
|
void ZoneDatabase::UpdateItemRecast(uint32 character_id, uint32 recast_type, uint32 timestamp)
|
||||||
{
|
{
|
||||||
const auto query = fmt::format(
|
CharacterItemRecastRepository::ReplaceOne(
|
||||||
"REPLACE INTO character_item_recast (id, recast_type, timestamp) VALUES ({}, {}, {})",
|
*this,
|
||||||
character_id,
|
CharacterItemRecastRepository::CharacterItemRecast{
|
||||||
recast_type,
|
.id = character_id,
|
||||||
timestamp
|
.recast_type = recast_type,
|
||||||
|
.timestamp = timestamp,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
QueryDatabase(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::DeleteItemRecast(uint32 character_id, uint32 recast_type)
|
void ZoneDatabase::DeleteItemRecast(uint32 character_id, uint32 recast_type)
|
||||||
{
|
{
|
||||||
const auto query = fmt::format(
|
CharacterItemRecastRepository::DeleteWhere(
|
||||||
"DELETE FROM character_item_recast WHERE id = {} AND recast_type = {}",
|
*this,
|
||||||
character_id,
|
fmt::format(
|
||||||
recast_type
|
"`id` = {} AND `recast_type` = {}",
|
||||||
|
character_id,
|
||||||
|
recast_type
|
||||||
|
)
|
||||||
);
|
);
|
||||||
QueryDatabase(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::LoadPetInfo(Client *client)
|
void ZoneDatabase::LoadPetInfo(Client *client)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user