Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cleanup] Convert Quest Ornament Methods to Repositories #4048

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 45 additions & 24 deletions zone/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern volatile bool RunLoops;
#include "../common/repositories/character_disciplines_repository.h"
#include "../common/repositories/character_data_repository.h"
#include "../common/repositories/discovered_items_repository.h"
#include "../common/repositories/inventory_repository.h"
#include "../common/repositories/keyring_repository.h"
#include "../common/events/player_events.h"
#include "../common/events/player_event_logs.h"
Expand Down Expand Up @@ -8853,49 +8854,69 @@ void Client::SetEXPEnabled(bool is_exp_enabled)
m_exp_enabled = is_exp_enabled;
}

/**
* @param model_id
*/
void Client::SetPrimaryWeaponOrnamentation(uint32 model_id)
{
auto primary_item = m_inv.GetItem(EQ::invslot::slotPrimary);
if (primary_item) {
database.QueryDatabase(
StringFormat(
"UPDATE `inventory` SET `ornamentidfile` = %i WHERE `charid` = %i AND `slotid` = %i",
model_id,
auto l = InventoryRepository::GetWhere(
database,
fmt::format(
"`charid` = {} AND `slotid` = {}",
character_id,
EQ::invslot::slotPrimary
));
)
);

if (l.empty()) {
return;
}

auto e = l.front();

primary_item->SetOrnamentationIDFile(model_id);
SendItemPacket(EQ::invslot::slotPrimary, primary_item, ItemPacketTrade);
WearChange(EQ::textures::weaponPrimary, static_cast<uint16>(model_id), 0);
e.ornamentidfile = model_id;

Message(Chat::Yellow, "Your primary weapon appearance has been modified");
const int updated = InventoryRepository::UpdateOne(database, e);

if (updated) {
primary_item->SetOrnamentationIDFile(model_id);
SendItemPacket(EQ::invslot::slotPrimary, primary_item, ItemPacketTrade);
WearChange(EQ::textures::weaponPrimary, model_id, 0);

Message(Chat::Yellow, "Your primary weapon appearance has been modified.");
}
}
}

/**
* @param model_id
*/
void Client::SetSecondaryWeaponOrnamentation(uint32 model_id)
{
auto secondary_item = m_inv.GetItem(EQ::invslot::slotSecondary);
if (secondary_item) {
database.QueryDatabase(
StringFormat(
"UPDATE `inventory` SET `ornamentidfile` = %i WHERE `charid` = %i AND `slotid` = %i",
model_id,
auto l = InventoryRepository::GetWhere(
database,
fmt::format(
"`charid` = {} AND `slotid` = {}",
character_id,
EQ::invslot::slotSecondary
));
)
);

if (l.empty()) {
return;
}

auto e = l.front();

secondary_item->SetOrnamentationIDFile(model_id);
SendItemPacket(EQ::invslot::slotSecondary, secondary_item, ItemPacketTrade);
WearChange(EQ::textures::weaponSecondary, static_cast<uint16>(model_id), 0);
e.ornamentidfile = model_id;

Message(Chat::Yellow, "Your secondary weapon appearance has been modified");
const int updated = InventoryRepository::UpdateOne(database, e);

if (updated) {
secondary_item->SetOrnamentationIDFile(model_id);
SendItemPacket(EQ::invslot::slotSecondary, secondary_item, ItemPacketTrade);
WearChange(EQ::textures::weaponSecondary, model_id, 0);

Message(Chat::Yellow, "Your secondary weapon appearance has been modified.");
}
}
}

Expand Down