Skip to content

feat(quests): a quest isn't completed while its rewards don't fit - #1491

Merged
sven-n merged 2 commits into
MUnique:masterfrom
Mosch0512:feat/quest-reward-space
Nov 22, 2026
Merged

sven-n merged 2 commits into
MUnique:masterfrom
Mosch0512:feat/quest-reward-space

Conversation

@Mosch0512

@Mosch0512 Mosch0512 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

Part of #1475 (part A, the second of three PRs; the first one, #1487, is merged).

QuestCompletionAction completes a quest even when its rewards don't fit: an item reward which finds no space in the inventory is dropped at the player's feet, where anyone can take it after the owner time, and a money reward over the money limit is lost. The Season 6 client already knows the answer for this case: its quest completion response (F6 0D) carries a result byte, 0 = not completed, 1 = completed, 2 = zen limit reached, 3 = inventory full. For 2 and 3 it shows its message and disables the button to complete the quest (ReceiveQuestCompleteResult in MuMain's WSclient.cpp). OpenMU modelled the byte as a boolean and only ever sent true.

What

  • Quest completion: the quest isn't completed while the item rewards don't fit into the inventory, counting the space of the handed in items as free (they are removed before the rewards are added), or while the money rewards would exceed the money limit. Nothing is taken, the quest stays active.
  • Hand-in: each item is handed in for one requirement only, and the requirements of a level pick first; before, two requirements of the same item (e.g. any level and +3) took the same item, which was destroyed twice while the player kept another one. Equipped items aren't handed in anymore (the inventory lists them first, so a quest could take the staff from the hand). A quest whose item reward has no item isn't completed and is logged as an error; before, adding the reward threw after the items were taken. A required item without item doesn't throw in the debug log anymore (this happened before this PR too); the requirement just isn't met.
  • Packet: the field IsQuestCompleted of QuestCompletionResponse (F6 0D) becomes Result, an enum QuestCompletionResult with the values the client reads. The generated code and tests are generated again. The markdown page of the packet (docs/Packets/C1-F6-0D-QuestCompletionResponse_by-server.md) is a generated file, but I edited it by hand, in the format of the generator (like the enum of C1-F6-0B), because it's generated with npx xslt3 and Node.js isn't installed here. I didn't check that regenerating gives exactly the same text.
  • Compatibility of F6 0D: it's an original packet (no suffix), which CODING_RULES says must be tested with the original 1.04d client. I didn't test it with that client, so the maintainer should check the refusal case with the original Season 6 client (1.04d) before merging. On the wire it stays compatible: the field is the same byte at the same index, Completed = 1 and NotCompleted = 0 are the old true and false, and only a refusal sends the new values 2 and 3, which the MuMain handler shows as messages.
  • View: IQuestCompletionResponsePlugIn gets QuestCompletionRefusedAsync(quest, refusal) with a QuestCompletionRefusal (InventoryFull, ZenLimitReached); the remote view sends result 3 or 2. The legacy quests (group 0, C1 A2) have no such result, so the player gets a message instead ("Inventory is full", or the new QuestZenLimitReached in English, German, Portuguese and Spanish); in the Season 6 data they have no item or money rewards (all 338 item and 9 money rewards belong to the newer quests). QuestCompletionRefusedAsync has a default implementation, so view plug-ins of other assemblies keep working.
  • Reusable check: IStorage.CanAddItems(items, removedItems) tells if items would fit into a storage, including its extensions, after other items were removed, without changing it. It places them in the order of CheckInvSpace, like AddItemAsync does: an item which fits into the storage takes its place there, the others go to the extensions. Only the removed items which the storage holds free their cells. FitsAfterRemoval (from fix(illusion-temple): review fixes of the ticket crafting and update (follow-up to #1473) #1536) is CanAddItems for one item now, and both use the existing FindPlace and SetUsedSlots. An extension which isn't a Storage, e.g. of a plug-in, is asked whether it takes all the remaining items; when it doesn't, it's assumed to take none. CanAddItems has a default implementation for storages of other assemblies: it checks a single item with FitsAfterRemoval and refuses more than one item, because it can't tell whether they fit together. Refusing too much is safe, accepting too much would drop a reward. An item without definition is refused by both, without an exception.
  • Docs: the page "Waiting items" (docs-website/docs/server-features/waiting-items.md) gets a section "Quest rewards": a quest isn't completed while its rewards don't fit, nothing is taken, the messages of both clients, and that a reward which still doesn't fit is dropped, not added to the waiting items.

Not changed:

  • When the server refuses for other reasons (items or kills missing, or a quest with an item reward without item), it still sends nothing. The client does nothing on result 0 either, so answering it wouldn't change anything there. The broken reward is a data error, which is logged as an error.
  • When the inventory is full in the end anyway (e.g. a plug-in storage which says yes), the reward is still dropped at the player's feet. A follow-up could put it into the waiting-items list of feat(items): an item which finds no place when its storage is loaded waits for space in the inventory #1487 instead of the floor.

Testing

  • dotnet build and dotnet test --no-build with -p:ci=true, rebased on master (45678e3):
    • MUnique.OpenMU.Tests: 3423 passed, 0 failed, 3 skipped
    • MUnique.OpenMU.Persistence.Initialization.Tests: 982 passed, 0 failed, 12 skipped
    • MUnique.OpenMU.Network.Packets.Tests: 721 passed, 0 failed
    • MUnique.OpenMU.Web.Tests: 786 passed, 16 failed. TranslationCoverageTests pass, so QuestZenLimitReached is in the Spanish messages too. The 16 failures are network analyzer tests which expect English texts and get the German ones of my Windows culture; they pass with DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1.
  • New QuestRewardSpaceTest: CanAddItems with an empty storage, items which don't fit together, removed items which make room (also in an extension, and not when another storage holds them), extensions, an extension which isn't a Storage, also one with the default implementation, which takes one item but not two; the default implementation with one item, with two items and with an item without definition; two requirements of the same item hand in different items, and one item doesn't meet two requirements; an equipped item isn't handed in; a quest with an item reward without item isn't completed; a required item without item isn't met and doesn't throw; a quest completed when the reward fits into the place of the handed in item, which the reward takes; refused with a full inventory (nothing taken, quest still active and not finished, refusal sent); refused when the money reward would exceed the limit.
  • New QuestCompletionResponseRemoteViewTests: a refusal is sent as F6 0D with result 3 or 2; a legacy refusal sends only the blue message with the localized reason ("Inventory is full" or the Zen limit text), and no quest response. These tests need the new refusal method and packet field, so they can't run without the change.
  • In game, before the review fixes, on a local all-in-one (this branch merged with feat(items): an item which finds no place when its storage is loaded waits for space in the inventory #1487) and the Season 6 client of sven-n/MuMain: the character quest2Dw with "Clearing a Path to Icarus (Dark Wizard)" active (60/60 kills, reward Jewel of Chaos) and a full inventory. Clicking OK at the Shadow Phantom Soldier: the client shows "Inventory is full." and disables the button; the quest stays active. After freeing one cell: "Jewel of Chaos Obtained", the jewel is in the freed cell and the quest window closes. The zen limit was only tested by the unit test. The review fixes since then (hand-in, extensions, messages) weren't tested in game yet; that's still open.

Found while testing: #1489 (merchant store items which no longer fit) and #1490 (the quest window shows item rewards as "Item: x 0").

@codacy-production

codacy-production Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 47 complexity

Metric Results
Complexity 47

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sven-n sven-n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a careful change. Refusing to complete a quest whose rewards don't fit, with nothing taken, is clearly better than dropping or losing the reward. The fixed hand-in (one item per requirement, no equipped items) and IStorage.CanAddItems with its default implementation look good.

Two things before it can be merged:

  1. Spanish message: #1578 (Spanish player messages) was merged in the meantime, and TranslationCoverageTests now requires every PlayerMessage key in PlayerMessage.es.resx. With this PR it fails:

    PlayerMessagesAreCompleteAndMatchNeutralPlaceholders("es")  -> missing "QuestZenLimitReached"
    

    Please merge master and add QuestZenLimitReached to src/GameLogic/Properties/PlayerMessage.es.resx.

  2. Original packet F6 0D: as you wrote, the field becomes a result enum, and the values 2 and 3 are new for the original client. Rule 2 asks that a change to an original packet is tested with the original client (1.04d here). On the wire it's compatible (same byte, 0/1 unchanged), but please either test the refusal case with the original Season 6 client, or state that the maintainer should check it before merging. I don't want to merge this untested.

Everything else passes: I built it on current master and ran the tests (all except the slow initialization tests), and the only failure was the missing Spanish entry.


Generated by Claude Code

@Mosch0512
Mosch0512 force-pushed the feat/quest-reward-space branch from a32f156 to f2ffefa Compare November 20, 2026 22:37
@Mosch0512

Copy link
Copy Markdown
Contributor Author

@sven-n ready

@sven-n sven-n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the Spanish message (f2ffefa4). Two things remain:

  1. #1548 was merged in the meantime, so this conflicts again in the PlayerMessage resources (.resx, .de, .pt, Designer.cs). Please rebase, keep both sides' entries, and add only the new designer block.
  2. The point about the original packet F6 0D is still open: the result values 2 and 3 are new for the original Season 6 client, and rule 2 asks for a test with it. Have you been able to try the refusal with the original 1.04d client? If not, please say so in the description, so @sven-n can check it before merging.

Generated by Claude Code

A quest isn't completed while its item rewards don't fit into the inventory, counting the place of the handed in items as free, or while its money rewards would exceed the Zen limit. Nothing is taken and the quest stays active. The quest completion response (F6 0D) gets its result enum, so the Season 6 client shows its message for a full inventory (3) or the Zen limit (2); the legacy quests get a blue message.

Each item is handed in for one requirement only, and equipped items aren't handed in. IStorage.CanAddItems checks if items fit into a storage after other items are removed, without changing it.
@Mosch0512
Mosch0512 force-pushed the feat/quest-reward-space branch from f2ffefa to 15deb2f Compare November 21, 2026 01:08
@sven-n
sven-n merged commit e56a467 into MUnique:master Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants