Skip to content

Commit 169e31f

Browse files
Nyeriahclaude
andauthored
feat(Core/Groups): mail roll-won items when inventory is full (azerothcore#25909)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a5c11d0 commit 169e31f

7 files changed

Lines changed: 66 additions & 6 deletions

File tree

src/server/apps/worldserver/worldserver.conf.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,16 @@ DungeonAccessRequirements.OptionalStringID = 0
33863386

33873387
JoinBGAndLFG.Enable = 0
33883388

3389+
#
3390+
# LFG.MailItemOnFullInventory
3391+
# Description: When a player wins a group roll but their inventory is full, mail
3392+
# the item to them instead of leaving it on the corpse.
3393+
# Default: 0 - Disabled
3394+
# 1 - Only in LFG/RDF groups
3395+
# 2 - In all group types
3396+
3397+
LFG.MailItemOnFullInventory = 0
3398+
33893399
#
33903400
# DungeonFinder.OptionsMask
33913401
# Description: Dungeon and raid finder system.

src/server/game/Entities/Player/Player.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@ class Player : public Unit, public GridObject<Player>
16681668
[[nodiscard]] PlayerMails const& GetMails() const { return m_mail; }
16691669
void SendItemRetrievalMail(uint32 itemEntry, uint32 count); // Item retrieval mails sent by The Postmaster (34337)
16701670
void SendItemRetrievalMail(std::vector<std::pair<uint32, uint32>> mailItems); // Item retrieval mails sent by The Postmaster (34337)
1671+
void SendItemRetrievalMail(Item* item); // As above, but for a pre-created item (preserves randomPropertyId)
16711672

16721673
/*********************************************************/
16731674
/*** MAILED ITEMS SYSTEM ***/

src/server/game/Entities/Player/PlayerMisc.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,16 @@ void Player::SendItemRetrievalMail(std::vector<std::pair<uint32, uint32>> mailIt
508508

509509
CharacterDatabase.CommitTransaction(trans);
510510
}
511+
512+
void Player::SendItemRetrievalMail(Item* item)
513+
{
514+
if (!item)
515+
return;
516+
517+
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
518+
item->SaveToDB(trans);
519+
MailDraft("Recovered Item", "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed.")
520+
.AddItem(item)
521+
.SendMailTo(trans, MailReceiver(this, GetGUID().GetCounter()), MailSender(MAIL_CREATURE, 34337 /* The Postmaster */));
522+
CharacterDatabase.CommitTransaction(trans);
523+
}

src/server/game/Groups/Group.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,9 +1490,22 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
14901490
}
14911491
else
14921492
{
1493-
item->is_blocked = false;
1494-
item->rollWinnerGUID = player->GetGUID();
1495-
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1493+
uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1494+
if (mailOnFull == MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE || (mailOnFull == MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY && isLFGGroup()))
1495+
{
1496+
item->is_looted = true;
1497+
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1498+
roll->getLoot()->unlootedCount--;
1499+
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1500+
if (Item* mailItem = Item::CreateItem(roll->itemid, item->count, player, false, item->randomPropertyId))
1501+
player->SendItemRetrievalMail(mailItem);
1502+
}
1503+
else
1504+
{
1505+
item->is_blocked = false;
1506+
item->rollWinnerGUID = player->GetGUID();
1507+
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1508+
}
14961509
}
14971510
}
14981511
}
@@ -1560,9 +1573,22 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
15601573
}
15611574
else
15621575
{
1563-
item->is_blocked = false;
1564-
item->rollWinnerGUID = player->GetGUID();
1565-
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1576+
uint32 mailOnFull = sWorld->getIntConfig(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY);
1577+
if (mailOnFull == MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE || (mailOnFull == MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY && isLFGGroup()))
1578+
{
1579+
item->is_looted = true;
1580+
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
1581+
roll->getLoot()->unlootedCount--;
1582+
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1583+
if (Item* mailItem = Item::CreateItem(roll->itemid, item->count, player, false, item->randomPropertyId))
1584+
player->SendItemRetrievalMail(mailItem);
1585+
}
1586+
else
1587+
{
1588+
item->is_blocked = false;
1589+
item->rollWinnerGUID = player->GetGUID();
1590+
player->SendEquipError(msg, nullptr, nullptr, roll->itemid);
1591+
}
15661592
}
15671593
}
15681594
else if (rollvote == DISENCHANT)

src/server/game/Groups/Group.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ enum lfgGroupFlags
128128
GROUP_LFG_FLAG_IS_HEROIC = 0x004
129129
};
130130

131+
enum MailItemOnFullInventory
132+
{
133+
MAIL_ITEM_ON_FULL_INVENTORY_DISABLED = 0,
134+
MAIL_ITEM_ON_FULL_INVENTORY_LFG_ONLY = 1,
135+
MAIL_ITEM_ON_FULL_INVENTORY_EVERYWHERE = 2,
136+
};
137+
131138
enum DifficultyPreventionChangeType
132139
{
133140
DIFFICULTY_PREVENTION_CHANGE_NONE = 0,

src/server/game/World/WorldConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ void WorldConfig::BuildConfigCache()
494494

495495
SetConfigValue<bool>(CONFIG_ALLOW_JOIN_BG_AND_LFG, "JoinBGAndLFG.Enable", false);
496496

497+
SetConfigValue<uint32>(CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY, "LFG.MailItemOnFullInventory", 0);
498+
497499
SetConfigValue<bool>(CONFIG_LEAVE_GROUP_ON_LOGOUT, "LeaveGroupOnLogout.Enabled", false);
498500

499501
SetConfigValue<uint32>(CONFIG_RANDOM_ROLL_MAXIMUM, "Group.RandomRollMaximum", 1000000);

src/server/game/World/WorldConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ enum ServerConfigs
375375
CONFIG_LOOT_NEED_BEFORE_GREED_ILVL_RESTRICTION,
376376
CONFIG_LFG_MAX_KICK_COUNT,
377377
CONFIG_LFG_KICK_PREVENTION_TIMER,
378+
CONFIG_LFG_MAIL_ITEM_ON_FULL_INVENTORY,
378379
CONFIG_CHANGE_FACTION_MAX_MONEY,
379380
CONFIG_WATER_BREATH_TIMER,
380381
CONFIG_DAILY_RBG_MIN_LEVEL_AP_REWARD,

0 commit comments

Comments
 (0)