mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-31 06:12:28 +00:00
[Bug Fix] Fix Item Discovery (#4663)
* [Bug Fix] Fix Item Discovery for Pickups, Evolving, Fishing, and Forage * Push * Caching * Update tradeskills.cpp * Update task_client_state.cpp
This commit is contained in:
parent
9e07d90664
commit
f3a2f97155
@ -4785,18 +4785,32 @@ bool Client::ChangePetName(std::string new_name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::IsDiscovered(uint32 item_id) {
|
bool Client::IsDiscovered(uint32 item_id)
|
||||||
const auto& l = DiscoveredItemsRepository::GetWhere(
|
{
|
||||||
database,
|
if (
|
||||||
fmt::format(
|
std::find(
|
||||||
"item_id = {}",
|
zone->discovered_items.begin(),
|
||||||
|
zone->discovered_items.end(),
|
||||||
item_id
|
item_id
|
||||||
)
|
) != zone->discovered_items.end()
|
||||||
);
|
) {
|
||||||
if (l.empty()) {
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
DiscoveredItemsRepository::GetWhere(
|
||||||
|
database,
|
||||||
|
fmt::format(
|
||||||
|
"`item_id` = {} LIMIT 1",
|
||||||
|
item_id
|
||||||
|
)
|
||||||
|
).empty()
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zone->discovered_items.emplace_back(item_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13562,3 +13576,24 @@ void Client::SendMerchantEnd()
|
|||||||
EQApplicationPacket empty(OP_ShopEndConfirm);
|
EQApplicationPacket empty(OP_ShopEndConfirm);
|
||||||
QueuePacket(&empty);
|
QueuePacket(&empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::CheckItemDiscoverability(uint32 item_id)
|
||||||
|
{
|
||||||
|
if (!RuleB(Character, EnableDiscoveredItems) || IsDiscovered(item_id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetGM()) {
|
||||||
|
const std::string& item_link = database.CreateItemLink(item_id);
|
||||||
|
Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Your GM flag prevents {} from being added to discovered items.",
|
||||||
|
item_link
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscoverItem(item_id);
|
||||||
|
}
|
||||||
|
|||||||
@ -1830,6 +1830,8 @@ public:
|
|||||||
|
|
||||||
void SendMerchantEnd();
|
void SendMerchantEnd();
|
||||||
|
|
||||||
|
void CheckItemDiscoverability(uint32 item_id);
|
||||||
|
|
||||||
Raid *p_raid_instance;
|
Raid *p_raid_instance;
|
||||||
|
|
||||||
inline uint32 GetPotionBeltItemIcon(uint8 slot_id)
|
inline uint32 GetPotionBeltItemIcon(uint8 slot_id)
|
||||||
|
|||||||
@ -260,6 +260,12 @@ bool Client::DoEvolveCheckProgression(const EQ::ItemInstance &inst)
|
|||||||
|
|
||||||
std::unique_ptr<EQ::ItemInstance> const new_inst(database.CreateItem(new_item_id));
|
std::unique_ptr<EQ::ItemInstance> const new_inst(database.CreateItem(new_item_id));
|
||||||
|
|
||||||
|
if (!new_inst) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckItemDiscoverability(new_inst->GetID());
|
||||||
|
|
||||||
PlayerEvent::EvolveItem e{};
|
PlayerEvent::EvolveItem e{};
|
||||||
|
|
||||||
RemoveItemBySerialNumber(inst.GetSerialNumber());
|
RemoveItemBySerialNumber(inst.GetSerialNumber());
|
||||||
|
|||||||
@ -2148,20 +2148,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app)
|
|||||||
if (item->MaxCharges != 0)
|
if (item->MaxCharges != 0)
|
||||||
charges = item->MaxCharges;
|
charges = item->MaxCharges;
|
||||||
|
|
||||||
if (RuleB(Character, EnableDiscoveredItems) && !IsDiscovered(item->ID)) {
|
CheckItemDiscoverability(item->ID);
|
||||||
if (!GetGM()) {
|
|
||||||
DiscoverItem(item->ID);
|
|
||||||
} else {
|
|
||||||
const std::string& item_link = database.CreateItemLink(item->ID);
|
|
||||||
Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Your GM flag prevents {} from being added to discovered items.",
|
|
||||||
item_link
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EQ::ItemInstance *inst = database.CreateItem(item, charges);
|
EQ::ItemInstance *inst = database.CreateItem(item, charges);
|
||||||
if (!AutoPutLootInInventory(*inst, true, true))
|
if (!AutoPutLootInInventory(*inst, true, true))
|
||||||
@ -2708,20 +2695,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
|
|||||||
RecordPlayerEventLog(PlayerEvent::MERCHANT_PURCHASE, e);
|
RecordPlayerEventLog(PlayerEvent::MERCHANT_PURCHASE, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RuleB(Character, EnableDiscoveredItems) && !IsDiscovered(item->ID)) {
|
CheckItemDiscoverability(item->ID);
|
||||||
if (!GetGM()) {
|
|
||||||
DiscoverItem(item->ID);
|
|
||||||
} else {
|
|
||||||
const std::string& item_link = database.CreateItemLink(item->ID);
|
|
||||||
Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Your GM flag prevents {} from being added to discovered items.",
|
|
||||||
item_link
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EQ::ItemInstance *inst = database.CreateItem(item, charges);
|
EQ::ItemInstance *inst = database.CreateItem(item, charges);
|
||||||
if (!AutoPutLootInInventory(*inst, true, true))
|
if (!AutoPutLootInInventory(*inst, true, true))
|
||||||
@ -14200,20 +14174,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
|||||||
parse->EventPlayer(EVENT_MERCHANT_BUY, this, export_string, 0);
|
parse->EventPlayer(EVENT_MERCHANT_BUY, this, export_string, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RuleB(Character, EnableDiscoveredItems) && !IsDiscovered(item_id)) {
|
CheckItemDiscoverability(item_id);
|
||||||
if (!GetGM()) {
|
|
||||||
DiscoverItem(item_id);
|
|
||||||
} else {
|
|
||||||
const std::string& item_link = database.CreateItemLink(item_id);
|
|
||||||
Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Your GM flag prevents {} from being added to discovered items.",
|
|
||||||
item_link
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete(inst);
|
safe_delete(inst);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|||||||
@ -1623,21 +1623,8 @@ void Corpse::LootCorpseItem(Client *c, const EQApplicationPacket *app)
|
|||||||
// safe to ACK now
|
// safe to ACK now
|
||||||
c->QueuePacket(app);
|
c->QueuePacket(app);
|
||||||
|
|
||||||
if (!IsPlayerCorpse()) {
|
if (!IsPlayerCorpse() && c) {
|
||||||
if (RuleB(Character, EnableDiscoveredItems) && c && !c->IsDiscovered(inst->GetItem()->ID)) {
|
c->CheckItemDiscoverability(inst->GetID());
|
||||||
if (!c->GetGM()) {
|
|
||||||
c->DiscoverItem(inst->GetItem()->ID);
|
|
||||||
} else {
|
|
||||||
const std::string& item_link = database.CreateItemLink(inst->GetItem()->ID);
|
|
||||||
c->Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Your GM flag prevents {} from being added to discovered items.",
|
|
||||||
item_link
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zone->adv_data) {
|
if (zone->adv_data) {
|
||||||
|
|||||||
@ -393,6 +393,8 @@ void Client::GoFish(bool guarantee, bool use_bait)
|
|||||||
RecordPlayerEventLog(PlayerEvent::FISH_SUCCESS, e);
|
RecordPlayerEventLog(PlayerEvent::FISH_SUCCESS, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckItemDiscoverability(inst->GetID());
|
||||||
|
|
||||||
if (parse->PlayerHasQuestSub(EVENT_FISH_SUCCESS)) {
|
if (parse->PlayerHasQuestSub(EVENT_FISH_SUCCESS)) {
|
||||||
std::vector<std::any> args = {inst};
|
std::vector<std::any> args = {inst};
|
||||||
parse->EventPlayer(EVENT_FISH_SUCCESS, this, "", inst->GetID(), &args);
|
parse->EventPlayer(EVENT_FISH_SUCCESS, this, "", inst->GetID(), &args);
|
||||||
@ -531,6 +533,8 @@ void Client::ForageItem(bool guarantee) {
|
|||||||
RecordPlayerEventLog(PlayerEvent::FORAGE_SUCCESS, e);
|
RecordPlayerEventLog(PlayerEvent::FORAGE_SUCCESS, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckItemDiscoverability(inst->GetID());
|
||||||
|
|
||||||
if (parse->PlayerHasQuestSub(EVENT_FORAGE_SUCCESS)) {
|
if (parse->PlayerHasQuestSub(EVENT_FORAGE_SUCCESS)) {
|
||||||
std::vector<std::any> args = { inst };
|
std::vector<std::any> args = { inst };
|
||||||
parse->EventPlayer(EVENT_FORAGE_SUCCESS, this, "", inst->GetID(), &args);
|
parse->EventPlayer(EVENT_FORAGE_SUCCESS, this, "", inst->GetID(), &args);
|
||||||
|
|||||||
@ -643,21 +643,7 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
|
|||||||
sender->PutItemInInventory(EQ::invslot::slotCursor, *m_inst, false);
|
sender->PutItemInInventory(EQ::invslot::slotCursor, *m_inst, false);
|
||||||
sender->SendItemPacket(EQ::invslot::slotCursor, m_inst, ItemPacketTrade);
|
sender->SendItemPacket(EQ::invslot::slotCursor, m_inst, ItemPacketTrade);
|
||||||
|
|
||||||
// Could be an undiscovered ground_spawn
|
sender->CheckItemDiscoverability(m_inst->GetID());
|
||||||
if (m_ground_spawn && RuleB(Character, EnableDiscoveredItems) && !sender->IsDiscovered(item->ID)) {
|
|
||||||
if (!sender->GetGM()) {
|
|
||||||
sender->DiscoverItem(item->ID);
|
|
||||||
} else {
|
|
||||||
const std::string& item_link = database.CreateItemLink(item->ID);
|
|
||||||
sender->Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Your GM flag prevents {} from being added to discovered items.",
|
|
||||||
item_link
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_delete) { // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet
|
if (cursor_delete) { // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet
|
||||||
sender->DeleteItemInInventory(EQ::invslot::slotCursor, 1, true);
|
sender->DeleteItemInInventory(EQ::invslot::slotCursor, 1, true);
|
||||||
|
|||||||
@ -1026,6 +1026,7 @@ void ClientTaskState::RewardTask(Client *c, const TaskInformation *ti, ClientTas
|
|||||||
if (item_id > 0) {
|
if (item_id > 0) {
|
||||||
std::unique_ptr<EQ::ItemInstance> inst(database.CreateItem(item_id, charges));
|
std::unique_ptr<EQ::ItemInstance> inst(database.CreateItem(item_id, charges));
|
||||||
if (inst && inst->GetItem()) {
|
if (inst && inst->GetItem()) {
|
||||||
|
c->CheckItemDiscoverability(item_id);
|
||||||
bool stacked = c->TryStacking(inst.get());
|
bool stacked = c->TryStacking(inst.get());
|
||||||
if (!stacked) {
|
if (!stacked) {
|
||||||
int16_t slot = c->GetInv().FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size);
|
int16_t slot = c->GetInv().FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size);
|
||||||
|
|||||||
@ -1149,6 +1149,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
|||||||
|
|
||||||
item = database.GetItem(itr->first);
|
item = database.GetItem(itr->first);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
CheckItemDiscoverability(itr->first);
|
||||||
SummonItem(itr->first, itr->second);
|
SummonItem(itr->first, itr->second);
|
||||||
if (GetGroup()) {
|
if (GetGroup()) {
|
||||||
entity_list.MessageGroup(this, true, Chat::Skills, "%s has successfully fashioned %s!", GetName(), item->Name);
|
entity_list.MessageGroup(this, true, Chat::Skills, "%s has successfully fashioned %s!", GetName(), item->Name);
|
||||||
|
|||||||
@ -241,6 +241,8 @@ public:
|
|||||||
|
|
||||||
std::unordered_map<uint32, EXPModifier> exp_modifiers;
|
std::unordered_map<uint32, EXPModifier> exp_modifiers;
|
||||||
|
|
||||||
|
std::vector<uint32> discovered_items;
|
||||||
|
|
||||||
time_t weather_timer;
|
time_t weather_timer;
|
||||||
Timer spawn2_timer;
|
Timer spawn2_timer;
|
||||||
Timer hot_reload_timer;
|
Timer hot_reload_timer;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user