Skip to content

Commit

Permalink
Perl/Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab committed Oct 6, 2024
1 parent 239f55c commit 9cacca5
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 78 deletions.
2 changes: 1 addition & 1 deletion common/database/database_update_manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5760,7 +5760,7 @@ CREATE TABLE `character_evolving_items` (
`char_id` INT(10) UNSIGNED NULL DEFAULT '0',
`item_id` INT(10) UNSIGNED NULL DEFAULT '0',
`activated` TINYINT(1) UNSIGNED NULL DEFAULT '0',
`equiped` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`equipped` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`current_amount` BIGINT(20) NULL DEFAULT '0',
`progression` DOUBLE(22,0) NULL DEFAULT '0',
`final_item_id` INT(10) UNSIGNED NULL DEFAULT '0',
Expand Down
8 changes: 4 additions & 4 deletions common/evolving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ double EvolvingItemsManager::CalculateProgression(const uint64 current_amount, c

void EvolvingItemsManager::DoLootChecks(const uint32 char_id, const uint16 slot_id, const EQ::ItemInstance &inst) const
{
inst.SetEvolveEquiped(false);
inst.SetEvolveEquipped(false);
if (inst.IsEvolving() && slot_id <= EQ::invslot::EQUIPMENT_END && slot_id >= EQ::invslot::EQUIPMENT_BEGIN) {
inst.SetEvolveEquiped(true);
inst.SetEvolveEquipped(true);
}

if (!inst.IsEvolving()) {
Expand All @@ -86,7 +86,7 @@ void EvolvingItemsManager::DoLootChecks(const uint32 char_id, const uint16 slot_

e.char_id = char_id;
e.item_id = inst.GetID();
e.equiped = inst.GetEvolveEquiped();
e.equipped = inst.GetEvolveEquipped();
e.final_item_id = evolving_items_manager.GetFinalItemID(inst);

auto r = CharacterEvolvingItemsRepository::InsertOne(*m_db, e);
Expand All @@ -100,7 +100,7 @@ void EvolvingItemsManager::DoLootChecks(const uint32 char_id, const uint16 slot_
return;
}

CharacterEvolvingItemsRepository::SetEquiped(*m_db, inst.GetEvolveUniqueID(), inst.GetEvolveEquiped());
CharacterEvolvingItemsRepository::SetEquipped(*m_db, inst.GetEvolveUniqueID(), inst.GetEvolveEquipped());
}

uint32 EvolvingItemsManager::GetFinalItemID(const EQ::ItemInstance &inst) const
Expand Down
12 changes: 6 additions & 6 deletions common/inventory_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ bool EQ::InventoryProfile::SwapItem(
return false;
}

source_item_instance->SetEvolveEquiped(false);
source_item_instance->SetEvolveEquipped(false);
if ((destination_slot >= invslot::EQUIPMENT_BEGIN && destination_slot <= invslot::EQUIPMENT_END)) {
auto source_item = source_item_instance->GetItem();
if (!source_item) {
Expand All @@ -365,7 +365,7 @@ bool EQ::InventoryProfile::SwapItem(
return false;
}
if (source_item_instance->IsEvolving() > 0) {
source_item_instance->SetEvolveEquiped(true);
source_item_instance->SetEvolveEquipped(true);
}
}
}
Expand All @@ -376,7 +376,7 @@ bool EQ::InventoryProfile::SwapItem(
return false;
}

destination_item_instance->SetEvolveEquiped(false);
destination_item_instance->SetEvolveEquipped(false);
if ((source_slot >= invslot::EQUIPMENT_BEGIN && source_slot <= invslot::EQUIPMENT_END)) {
auto destination_item = destination_item_instance->GetItem();
if (!destination_item) {
Expand All @@ -396,7 +396,7 @@ bool EQ::InventoryProfile::SwapItem(
return false;
}
if (destination_item_instance->IsEvolving()) {
destination_item_instance->SetEvolveEquiped(true);
destination_item_instance->SetEvolveEquipped(true);
}
}
}
Expand Down Expand Up @@ -1412,7 +1412,7 @@ int16 EQ::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
int16 result = INVALID_INDEX;
int16 parentSlot = INVALID_INDEX;

inst->SetEvolveEquiped(false);
inst->SetEvolveEquipped(false);

if (slot_id == invslot::slotCursor) {
// Replace current item on cursor, if exists
Expand All @@ -1423,7 +1423,7 @@ int16 EQ::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
else if (slot_id >= invslot::EQUIPMENT_BEGIN && slot_id <= invslot::EQUIPMENT_END) {
if ((((uint64)1 << slot_id) & m_lookup->PossessionsBitmask) != 0) {
if (inst->IsEvolving()) {
inst->SetEvolveEquiped(true);
inst->SetEvolveEquipped(true);
}
m_worn[slot_id] = inst;
result = slot_id;
Expand Down
4 changes: 2 additions & 2 deletions common/item_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1962,13 +1962,13 @@ void EQ::ItemInstance::SetTimer(std::string name, uint32 time) const{
m_timers[name] = t;
}

void EQ::ItemInstance::SetEvolveEquiped(const bool in) const
void EQ::ItemInstance::SetEvolveEquipped(const bool in) const
{
if (!IsEvolving()) {
return;
}

m_evolving_details.equiped = in;
m_evolving_details.equipped = in;
if (in && !GetTimers().contains("evolve")) {
SetTimer("evolve", RuleI(EvolvingItems, DelayUponEquipping));
return;
Expand Down
6 changes: 3 additions & 3 deletions common/item_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ namespace EQ
int8 GetEvolveLvl() const { if (GetItem()) { return GetItem()->EvolvingLevel; } return false; }
bool IsEvolving() const { if (GetItem()) { return GetItem()->EvolvingItem; } return false; }
int8 GetMaxEvolveLvl() const { if (GetItem()) { return GetItem()->EvolvingMax; } return false; }
bool GetEvolveActivated() const { return m_evolving_details.activated; }
bool GetEvolveEquiped() const { return m_evolving_details.equiped; }
bool GetEvolveActivated() const { return m_evolving_details.activated ? true : false; }
bool GetEvolveEquipped() const { return m_evolving_details.equipped ? true : false; }
double GetEvolveProgression() const { return m_evolving_details.progression; }
uint64 GetEvolveUniqueID() const { return m_evolving_details.id; }
uint32 GetEvolveCharID() const { return m_evolving_details.char_id; }
Expand All @@ -324,7 +324,7 @@ namespace EQ
uint64 GetEvolveCurrentAmount() const { return m_evolving_details.current_amount; }
uint32 GetEvolveFinalItemID() const { return m_evolving_details.final_item_id; }
uint32 GetAugmentEvolveUniqueID(uint8 augment_index) const;
void SetEvolveEquiped(const bool in) const;
void SetEvolveEquipped(const bool in) const;
void SetEvolveActivated(const bool in) const { m_evolving_details.activated = in; }
void SetEvolveProgression(const double in) const { m_evolving_details.progression = in; }
void SetEvolveUniqueID(const uint64 in) const { m_evolving_details.id = in; }
Expand Down
24 changes: 12 additions & 12 deletions common/repositories/base/base_character_evolving_items_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseCharacterEvolvingItemsRepository {
uint32_t char_id;
uint32_t item_id;
uint8_t activated;
uint8_t equiped;
uint8_t equipped;
int64_t current_amount;
double progression;
uint32_t final_item_id;
Expand All @@ -42,7 +42,7 @@ class BaseCharacterEvolvingItemsRepository {
"char_id",
"item_id",
"activated",
"equiped",
"equipped",
"current_amount",
"progression",
"final_item_id",
Expand All @@ -57,7 +57,7 @@ class BaseCharacterEvolvingItemsRepository {
"char_id",
"item_id",
"activated",
"equiped",
"equipped",
"current_amount",
"progression",
"final_item_id",
Expand Down Expand Up @@ -106,7 +106,7 @@ class BaseCharacterEvolvingItemsRepository {
e.char_id = 0;
e.item_id = 0;
e.activated = 0;
e.equiped = 0;
e.equipped = 0;
e.current_amount = 0;
e.progression = 0;
e.final_item_id = 0;
Expand Down Expand Up @@ -151,7 +151,7 @@ class BaseCharacterEvolvingItemsRepository {
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.activated = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.equiped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.equipped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.current_amount = row[5] ? strtoll(row[5], nullptr, 10) : 0;
e.progression = row[6] ? strtod(row[6], nullptr) : 0;
e.final_item_id = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
Expand Down Expand Up @@ -192,7 +192,7 @@ class BaseCharacterEvolvingItemsRepository {
v.push_back(columns[1] + " = " + std::to_string(e.char_id));
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
v.push_back(columns[3] + " = " + std::to_string(e.activated));
v.push_back(columns[4] + " = " + std::to_string(e.equiped));
v.push_back(columns[4] + " = " + std::to_string(e.equipped));
v.push_back(columns[5] + " = " + std::to_string(e.current_amount));
v.push_back(columns[6] + " = " + std::to_string(e.progression));
v.push_back(columns[7] + " = " + std::to_string(e.final_item_id));
Expand Down Expand Up @@ -222,7 +222,7 @@ class BaseCharacterEvolvingItemsRepository {
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.activated));
v.push_back(std::to_string(e.equiped));
v.push_back(std::to_string(e.equipped));
v.push_back(std::to_string(e.current_amount));
v.push_back(std::to_string(e.progression));
v.push_back(std::to_string(e.final_item_id));
Expand Down Expand Up @@ -260,7 +260,7 @@ class BaseCharacterEvolvingItemsRepository {
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.activated));
v.push_back(std::to_string(e.equiped));
v.push_back(std::to_string(e.equipped));
v.push_back(std::to_string(e.current_amount));
v.push_back(std::to_string(e.progression));
v.push_back(std::to_string(e.final_item_id));
Expand Down Expand Up @@ -302,7 +302,7 @@ class BaseCharacterEvolvingItemsRepository {
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.activated = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.equiped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.equipped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.current_amount = row[5] ? strtoll(row[5], nullptr, 10) : 0;
e.progression = row[6] ? strtod(row[6], nullptr) : 0;
e.final_item_id = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
Expand Down Expand Up @@ -335,7 +335,7 @@ class BaseCharacterEvolvingItemsRepository {
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.activated = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.equiped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.equipped = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.current_amount = row[5] ? strtoll(row[5], nullptr, 10) : 0;
e.progression = row[6] ? strtod(row[6], nullptr) : 0;
e.final_item_id = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
Expand Down Expand Up @@ -418,7 +418,7 @@ class BaseCharacterEvolvingItemsRepository {
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.activated));
v.push_back(std::to_string(e.equiped));
v.push_back(std::to_string(e.equipped));
v.push_back(std::to_string(e.current_amount));
v.push_back(std::to_string(e.progression));
v.push_back(std::to_string(e.final_item_id));
Expand Down Expand Up @@ -449,7 +449,7 @@ class BaseCharacterEvolvingItemsRepository {
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.activated));
v.push_back(std::to_string(e.equiped));
v.push_back(std::to_string(e.equipped));
v.push_back(std::to_string(e.current_amount));
v.push_back(std::to_string(e.progression));
v.push_back(std::to_string(e.final_item_id));
Expand Down
86 changes: 43 additions & 43 deletions common/repositories/character_evolving_items_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,56 @@ class CharacterEvolvingItemsRepository: public BaseCharacterEvolvingItemsReposit

// Custom extended repository methods here

static CharacterEvolvingItems SetCurrentAmountAndProgression(Database &db, const uint64 id, const uint64 amount, const double progression)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}
static CharacterEvolvingItems SetCurrentAmountAndProgression(Database& db, const uint64 id, const uint64 amount, const double progression)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}

e.current_amount = amount;
e.progression = progression;
e.deleted_at = 0;
UpdateOne(db, e);
return e;
}
e.current_amount = amount;
e.progression = progression;
e.deleted_at = 0;
UpdateOne(db, e);
return e;
}

static CharacterEvolvingItems SetEquiped(Database &db, const uint64 id, const bool equiped)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}
static CharacterEvolvingItems SetEquipped(Database& db, const uint64 id, const bool equipped)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}

e.equiped = equiped;
e.deleted_at = 0;
UpdateOne(db, e);
return e;
}
e.equipped = equipped;
e.deleted_at = 0;
UpdateOne(db, e);
return e;
}

static CharacterEvolvingItems SoftDelete(Database &db, const uint64 id)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}
static CharacterEvolvingItems SoftDelete(Database& db, const uint64 id)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return NewEntity();
}

e.deleted_at = time(nullptr);
UpdateOne(db, e);
return e;
}
e.deleted_at = time(nullptr);
UpdateOne(db, e);
return e;
}

static bool UpdateCharID(Database &db, const uint64 id, const uint32 to_char_id)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return false;
}
static bool UpdateCharID(Database& db, const uint64 id, const uint32 to_char_id)
{
auto e = FindOne(db, id);
if (e.id == 0) {
return false;
}

e.char_id = to_char_id;
e.deleted_at = 0;
return UpdateOne(db, e);
}
e.char_id = to_char_id;
e.deleted_at = 0;
return UpdateOne(db, e);
}
};

#endif //EQEMU_CHARACTER_EVOLVING_ITEMS_REPOSITORY_H
8 changes: 4 additions & 4 deletions common/shareddb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ bool SharedDatabase::GetInventory(Client *c)

if (item->EvolvingItem) {
if (slot_id >= EQ::invslot::EQUIPMENT_BEGIN && slot_id <= EQ::invslot::EQUIPMENT_END) {
inst->SetEvolveEquiped(true);
inst->SetEvolveEquipped(true);
}

auto t = std::ranges::find_if(
Expand All @@ -810,7 +810,7 @@ bool SharedDatabase::GetInventory(Client *c)

e.char_id = char_id;
e.item_id = item_id;
e.equiped = inst->GetEvolveEquiped();
e.equipped = inst->GetEvolveEquipped();
e.final_item_id = evolving_items_manager.GetFinalItemID(*inst);

auto r = CharacterEvolvingItemsRepository::InsertOne(*this, e);
Expand All @@ -821,7 +821,7 @@ bool SharedDatabase::GetInventory(Client *c)
inst->SetEvolveCharID(e.char_id);
inst->SetEvolveItemID(e.item_id);
inst->SetEvolveActivated(e.activated);
inst->SetEvolveEquiped(e.equiped);
inst->SetEvolveEquipped(e.equipped);
inst->SetEvolveCurrentAmount(e.current_amount);
inst->CalculateEvolveProgression();
inst->SetEvolveFinalItemID(e.final_item_id);
Expand All @@ -831,7 +831,7 @@ bool SharedDatabase::GetInventory(Client *c)
inst->SetEvolveCharID(t->char_id);
inst->SetEvolveItemID(t->item_id);
inst->SetEvolveActivated(t->activated);
inst->SetEvolveEquiped(t->equiped);
inst->SetEvolveEquipped(t->equipped);
inst->SetEvolveCurrentAmount(t->current_amount);
inst->CalculateEvolveProgression();
inst->SetEvolveFinalItemID(t->final_item_id);
Expand Down
6 changes: 3 additions & 3 deletions zone/gm_commands/evolving_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void command_evolvingitems(Client *c, const Seperator *sep)
);
c->Message(
Chat::Yellow,
fmt::format("{}{}{}", "Equiped", ":", value->GetEvolveEquiped() ? "Yes" : "No").c_str()
fmt::format("{}{}{}", "Equiped", ":", value->GetEvolveEquipped() ? "Yes" : "No").c_str()
);
c->Message(
Chat::Yellow,
Expand Down Expand Up @@ -106,7 +106,7 @@ void command_evolvingitems(Client *c, const Seperator *sep)
);
c->Message(
Chat::Yellow,
fmt::format("{}{}{}", "Equiped", ":", value->GetEvolveEquiped() ? "Yes" : "No").c_str()
fmt::format("{}{}{}", "Equiped", ":", value->GetEvolveEquipped() ? "Yes" : "No").c_str()
);
c->Message(
Chat::Yellow,
Expand Down Expand Up @@ -154,7 +154,7 @@ void command_evolvingitems(Client *c, const Seperator *sep)
);
c->Message(
Chat::Yellow,
fmt::format("{}{}{}", "Equiped", ":", item->GetEvolveEquiped() ? "Yes" : "No").c_str()
fmt::format("{}{}{}", "Equiped", ":", item->GetEvolveEquipped() ? "Yes" : "No").c_str()
);
c->Message(Chat::Yellow, fmt::format("{}{}{:0d}", "Unique ID", ":", item->GetEvolveUniqueID()).c_str());
c->Message(
Expand Down
Loading

0 comments on commit 9cacca5

Please sign in to comment.