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

[Rules] Update logic checks everywhere for FVNoDropFlag. #2179

Merged
merged 8 commits into from
Jul 30, 2022
21 changes: 19 additions & 2 deletions common/emu_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/

#include "emu_constants.h"
#include "languages.h"
#include "data_verification.h"
#include "bodytypes.h"
#include "data_verification.h"
#include "eqemu_logsys.h"
#include "eqemu_logsys_log_aliases.h"
#include "languages.h"
#include "rulesys.h"

int16 EQ::invtype::GetInvTypeSize(int16 inv_type) {
static const int16 local_array[] = {
Expand Down Expand Up @@ -432,3 +435,17 @@ std::string EQ::constants::GetSpawnAnimationName(uint8 animation_id)

return std::string();
}

bool EQ::inventory::CanTradeNoDropItem(const int16 admin_status)
{
const int no_drop_flag = RuleI(World, FVNoDropFlag);
const int no_drop_min_admin_status = RuleI(Character, MinStatusForNoDropExemptions);
switch (no_drop_flag) {
case FVNoDropFlagRule::Disabled: return false;
case FVNoDropFlagRule::Enabled: return true;
case FVNoDropFlagRule::AdminOnly: return admin_status >= no_drop_min_admin_status;
default:
LogWarning("Invalid value {0} set for FVNoDropFlag", no_drop_flag);
return false;
}
}
2 changes: 2 additions & 0 deletions common/emu_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace EQ
using RoF2::INULL;

namespace inventory {

bool CanTradeNoDropItem(int16 admin_status);

} /*inventory*/

Expand Down
7 changes: 7 additions & 0 deletions common/eq_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,4 +1009,11 @@ enum StartZoneIndex {
SharVahl
};

enum FVNoDropFlagRule
{
Disabled = 0,
Enabled = 1,
AdminOnly = 2
};

#endif /*COMMON_EQ_CONSTANTS_H*/
2 changes: 1 addition & 1 deletion world/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void Client::SendLogServer()
if(RuleB(World, IsGMPetitionWindowEnabled))
l->enable_petition_wnd = 1;

if((RuleI(World, FVNoDropFlag) == 1 || RuleI(World, FVNoDropFlag) == 2) && GetAdmin() > RuleI(Character, MinStatusForNoDropExemptions))
if(EQ::inventory::CanTradeNoDropItem(GetAdmin()))
l->enable_FV = 1;

QueuePacket(outapp);
Expand Down
5 changes: 2 additions & 3 deletions zone/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ void Client::DropItem(int16 slot_id, bool recurse)
LogInventory("[{}] (char_id: [{}]) Attempting to drop item from slot [{}] on the ground",
GetCleanName(), CharacterID(), slot_id);

if(GetInv().CheckNoDrop(slot_id, recurse) && RuleI(World, FVNoDropFlag) == 0 ||
RuleI(Character, MinStatusForNoDropExemptions) < Admin() && RuleI(World, FVNoDropFlag) == 2)
if(GetInv().CheckNoDrop(slot_id, recurse) && !EQ::inventory::CanTradeNoDropItem(Admin()))
{
auto invalid_drop = m_inv.GetItem(slot_id);
if (!invalid_drop) {
Expand Down Expand Up @@ -1963,7 +1962,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
if (((with && with->IsClient() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) ||
(dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END))
&& GetInv().CheckNoDrop(src_slot_id)
&& RuleI(World, FVNoDropFlag) == 0 || RuleI(Character, MinStatusForNoDropExemptions) < Admin() && RuleI(World, FVNoDropFlag) == 2) {
&& !EQ::inventory::CanTradeNoDropItem(Admin())) {
Quintinon marked this conversation as resolved.
Show resolved Hide resolved
auto ndh_inst = m_inv[src_slot_id];
std::string ndh_item_data;
if (ndh_inst == nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions zone/trading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
LogTrading("Giving container [{}] ([{}]) in slot [{}] to [{}]", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName());

// TODO: need to check bag items/augments for no drop..everything for attuned...
if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) {
if (inst->GetItem()->NoDrop != 0 || EQ::inventory::CanTradeNoDropItem(Admin()) || other == this) {
int16 free_slot = other->GetInv().FindFreeSlotForTradeItem(inst);

if (free_slot != INVALID_INDEX) {
Expand Down Expand Up @@ -717,7 +717,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
LogTrading("Giving item [{}] ([{}]) in slot [{}] to [{}]", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName());

// TODO: need to check bag items/augments for no drop..everything for attuned...
if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) {
if (inst->GetItem()->NoDrop != 0 || EQ::inventory::CanTradeNoDropItem(Admin()) || other == this) {
int16 free_slot = other->GetInv().FindFreeSlotForTradeItem(inst);

if (free_slot != INVALID_INDEX) {
Expand Down