fix(missions): a mission is only turned in when its rewards fit, as the client

LWOMissionComponent::MissionWindowOK (0x00d501f0) turns a mission in only
when CanReceiveAllRewards (msgCanReceiveAllRewards 0x00d17e20,
sub_00d17750) passes for the reward the player picked: the reward items
(the repeat ones once completed, each at least 1) must fit after the items
the tasks take (a gather task's target unless it keeps them, one of a
delivery task's target) with the first completion's bag rewards added.
The fit is LWOInventoryComponent_Common::CheckCanAddItems (0x00d53de0):
turned in items leave first (an item of 1 settles the whole count), a
unique item fails while one is held outside the buyback, then each item
tops up stacks of its LOT (stack size 0 is no limit, LookupItemInfo
0x00c1c190) and takes free slots.

MissionDialogueOK now refuses a turn-in that does not pass, which the
client never sends. The client's max currency part is not checked: the
server writes no cm, so the client has no limit either.
InventoryComponent::GetDefaultInventorySize is split out of GetInventory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-02 15:47:35 -05:00
parent 2fe489d518
commit c42a7ba387
7 changed files with 401 additions and 19 deletions

View File

@@ -126,6 +126,9 @@ public:
*/
Inventory* GetInventory(eInventoryType type);
// The size an inventory starts with when the server makes it
static uint32_t GetDefaultInventorySize(eInventoryType type);
/**
* Returns all the inventories this entity has, indexed by type
* @return all the inventories this entity has, indexed by type
@@ -255,6 +258,18 @@ public:
*/
bool HasSpaceForLoot(const Loot::Return& loot);
/**
* Whether all of these items would fit, as the client works it out before turning in a mission
* (LWOInventoryComponent_Common::CheckCanAddItems 0x00d53de0): the items to turn in are taken out first, the bag
* sizes grow by sizeIncrease, a unique item fails while one is held outside the buyback, then each item tops up
* stacks of its LOT and takes free slots. Nothing changes.
* @param items LOTs and counts to add
* @param itemsToTurnIn LOTs and counts taken from any inventory first
* @param sizeIncrease extra slots per inventory
*/
bool CanAddItems(const std::vector<std::pair<LOT, uint32_t>>& items, const std::vector<std::pair<LOT, uint32_t>>& itemsToTurnIn,
const std::map<eInventoryType, uint32_t>& sizeIncrease) const;
/**
* Equips an item in the specified slot
* @param location the location to store the item (e.g. chest, left hand, etc.)