Skip to content

feat(items): rented items show their time left and expired state - #1150

Merged
Mosch0512 merged 16 commits into
Mutizens:mainfrom
pllanosclaria:feat/item-expiration
Nov 23, 2026
Merged

Mosch0512 merged 16 commits into
Mutizens:mainfrom
pllanosclaria:feat/item-expiration

Conversation

@pllanosclaria

@pllanosclaria pllanosclaria commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenMU can now sell the time-limited (rented) items of the cash shop: pets, transformation rings, rings and necklaces, small wings (MUnique/OpenMU#1525, server side in MUnique/OpenMU#1548). This PR is the client side.

The client already has the period item system of the original (WithExpiration, IsExpired, the tooltip with the time left, the refusal to equip an expired item), but it got the state only from byte 5 of the original item format. The extended item format which OpenMU sends to this client has no free bit, so the server now marks a time-limited item in the two highest bits of the level byte: 0x40 for an item which expires, 0x80 once it expired. The level is in the low 6 bits; item levels only go up to 15.

  • Item data (ItemMng.cpp): ParseItemData reads both bits into WithExpiration and IsExpired and masks the level with 0x3F. With that the tooltip shows the time left of the date the server sends with D2 12, which the client already handles.
  • Equip by right click (MyInventory.cpp): dragging an expired item onto its slot was already refused ("Can't wear item."), but a right click sent the equip request anyway. The server refuses it, and the client then showed the item in another equipment slot until the next login. CMyInventory::IsEquipable now refuses an expired item, for the drag and the right click alike. (Showing a rejected right-click equip in the wrong slot is an older problem of its own, not changed here.)
  • Expiry while equipped (WSclient.cpp, ReceiveModifyItemExtended): the item update F3 14 ignored the equipment slots, so an equipped item never got its expired state until the next login. It now equips the item again with the new data, which takes the old one off first. An update keeps the item the player holds, unless it was used on another item or it's the updated item, and an expiry plays no sound.
  • No effect (ZzzInfomation.cpp, CSItemOption.cpp, SocketSystem.cpp, ZzzCharacter.cpp, MyInventory.cpp): an expired item has no effect on the server. CHARACTER_MACHINE::GetEffectiveEquipment gives the item of an equipment slot as the game uses it, with an expired rental as an empty slot, and the stats, the item options (sets, excellent, sockets, item skills), the full set check and the drawing of the hero use it. The client doesn't create the pet, mount or Dark Raven of an expired item (an expired pet kept flying and collecting zen, because the zen pickup of a pet is done by the client), and draws the hero as if the slot was empty: without the wings, the weapon or the armor piece, without the mane of a Wizard's Ring +3. GameLogic::Items::IsExpiredRental is the one check for an expired rental.
  • End of a rented item (WSclient.cpp, ZzzInventory.cpp, Tooltip.json): D2 12 now reaches an item in the inventory extension too, and a rented item without its end (in the Chaos Machine, in another player's shop, or between a move and its D2 12) shows its tooltip without the end instead of none. The new tooltip state hasExpireDate decides the expiration lines.

Compatibility

  • A server which doesn't set the bits: nothing changes, items with level 0–15 have neither bit set.
  • An older client with a server which sets them shows rented items with a wrong level (64 or 128 more). The bits are a proposal; if another layout fits better, both sides change.

Screenshots or videos

Before (main with OpenMU master): a rented pet (or any other time-limited item) can't be bought. The server refuses every cash shop product with a duration, and the client shows "This item is not currently available".

time_limited_items_not_supported

After (this branch with MUnique/OpenMU#1548), on a local server:

  1. Buying a Pet Skeleton for a limited time in the cash shop and using it from the storage:
purchase_time-limited_item_small.mp4
  1. The tooltip of the equipped pet shows its expiration date:
pet_with_expiration_date
  1. After the expiration was set to the past in the admin panel, the pet is shown as expired and has no effect, although it's still equipped:
expired_pet_info
  1. The message the player gets when the item expires:
expired_pet_msg

Testing

  • Built on Linux x64 Release.
  • In game, on a local OpenMU server with feat(items): items which expire, to sell the time-limited cash shop products MUnique/OpenMU#1548 (Season 6 data): bought a 1-day and a 7-day Pet Panda and a Pet Skeleton; the tooltip shows the expiration day; the pet works while it's valid.
  • In game, expired item (expiration set in the admin panel): shown as expired; refused by drag ("Can't wear item.") and by right click; sold to the NPC for its price (1000 zen); consistent after a relog.
  • In game, expiry while equipped: the message, the pet disappears and stops collecting zen, the wings disappear and the hero walks instead of flying, without a relog. Another player sees the same.
  • The right-click equip and the missing update of an equipped item (F3 14) were found in game with the first commit of this branch, before they were fixed. On main, a rented item isn't time-limited for the client at all, so these cases can't happen there.
  • In game, after the review: a Jewel of Bless held while a mounted Pet Skeleton expired stays in the hand; applying a Jewel of Bless to an item still consumes it and raises the item's level; with Small Wings of Satan the defense goes from 1921 to 1947 and back to 1921 when they expire, without a relog; a rented item in the inventory extension shows its end, an expired one "Expired Item"; a rented Skeleton Transformation Ring which expires while it's worn turns the hero back right at the expiry message, and an expired magic ring's stats go back too.
  • Automated tests: a doctest case for ParseItemData with the new bits (period, expired, masked level); test_expired_rental_equipment (the expired-rental check, GetEffectiveEquipment, an expired wing left out of the walk speed); the tooltip tests (a rented item without its end keeps its tooltip, the new state). The whole ctest suite passes (3154 tests), the static checks of the pre-push hook pass, and clang-format 21.1.8 on the changed lines is clean.
  • No doctest for the held item, the right click and the inventory extension: they need the inventory windows, so they're tested in game.
  • Not tested on Windows and macOS, only built there by CI.
  • Not tested with the original 1.04d client, which isn't part of this repository.

Deliberate exception to the data-driven rule: the Wizard's Ring +3 mane in CreateEquippingEffect stays a hard-coded case. This PR only adds the expiry check to it; moving it into data is a bigger step.

Known, not changed: SetCharacterClass stops the hero on every equipment change, so an expiry while walking stops the hero on the client while the server finishes the walk. It does the same when the player equips something by hand.

Related issues

MUnique/OpenMU#1525, MUnique/OpenMU#1548

Checklist

  • I have read and followed docs/CODING_RULES.md and docs/PULL_REQUESTS.md; deliberate exceptions are named above with the reason.
  • Visible changes have before and after screenshots or videos (or nothing visible changes).
  • The Testing section lists what was tested and what was not.
  • I have built the project locally (see docs/build/README.md).
  • Changes are focused on one concern; the diff is as small as it reasonably can be.

OpenMU marks a time-limited (rented) item in the two highest bits of the level
byte of its extended item data: 0x40 for an item which expires, 0x80 once it
expired. The level is in the low 6 bits. ParseItemData reads them into
WithExpiration and IsExpired, so the client treats the item as a period item,
like with the bits 0x02 and 0x04 of byte 5 in the original item format: the
tooltip shows the time left of the expiration date which D2 12 sets, and an
expired item is shown as such and can't be equipped.
Dragging an expired period item onto its slot is refused by the client with
"Can't wear item.", but a right click sent the equip request anyway. The server
refuses it, and the client then showed the item in another equipment slot until
the next login. The right click now refuses an expired item the same way.
When a rented pet expired while it was equipped, it kept flying next to the
hero and collecting zen until the next login. The client ignored the item update
(F3 14) for the equipment slots, so the equipped pet never got its expired state.
It now equips the item again with the new data, which takes the pet off first.

The pet or mount of an expired rented item isn't created anymore, so it doesn't
appear (and collect zen) after the login either.
Not only an expired pet: an expired rented item in any equipment slot has no
effect, so the hero is drawn as if the slot was empty, e.g. without the wings,
the weapon or the armor piece, and without the mane of a Wizard's Ring +3. The
expiration of an equipped item recreates the hero's parts with the new state.
@Mosch0512

Copy link
Copy Markdown
Collaborator

based on pr rules pls add screenshots or video for comparison

thx a lot :D <3

@pllanosclaria

Copy link
Copy Markdown
Contributor Author

Thanks, I've added a video and screenshots of the result to the description: buying a rented pet, its expiration date in the tooltip, the expired pet, and the message when it expires.

Two notes about the rule, meant constructively:

  • This PR was opened before the rule existed: it was created at 00:05 UTC on November 18, and docs: add PR rules (screenshots or videos, testing notes, coding rules) #1151 was merged an hour later. That's why the description didn't have the section.
  • I'd suggest making screenshots and videos optional, or required only when the change is mainly visual (UI, rendering, effects). Most of this PR is in the item data flags and the protocol, which a screenshot can't show; what shows the change are the tests and the steps in the Testing section. Other changes, like the respawn of the monsters of a whole map, have no screenshot or video which proves anything either. A strict rule adds work for every contributor, while for changes like these it doesn't give the reviewers anything to check. A clear Testing section, which the template already asks for, covers them better.

@Mosch0512 Mosch0512 self-assigned this Nov 20, 2026

@Mosch0512 Mosch0512 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: changes requested. Three required items, all reachable in game as soon as MUnique/OpenMU#1548 is live:

  1. An expiry deletes the item the player is dragging (inline on WSclient.cpp).
  2. The character stats still count expired equipment (inline on ZzzCharacter.cpp).
  3. A rented item in the inventory extension loses its whole tooltip (below, ReceivePeriodItemList).

Thanks for this, the period item system finally works with OpenMU, and the testing list and the videos make the change easy to follow. The bit layout looks fine to me; since it's still a proposal on MUnique/OpenMU#1548, it would be good to merge both sides with the same layout.

Required: the expiry date never reaches an item in the inventory extension. ReceivePeriodItemList (D2 12, WSclient.cpp around line 13172) stores the date for equipment slots and, through FindMainInventoryItem, for the main inventory only. For a slot of the inventory extension (or the own personal shop) it finds nothing and returns. That was harmless before, because bPeriodItem was never set with OpenMU. With this PR it is, and BuildItemTooltipText (ZzzInventory.cpp:1804) shows no tooltip at all for a period item that isn't expired and has no date: a rented ring moved into the extension shows nothing when hovered, not even its name. UI::Inventory::FindPlayerItem covers both parts of the inventory.

Non-blocking: a rented item without a date has no tooltip anywhere else either. The server sets the new bit in every serialization, but sends D2 12 only for items in the inventory. A rented item in the Chaos Machine window, in another player's personal shop (where personalShopSellableWhileRented allows it), or for a moment between a move and its D2 12 hides its whole tooltip because of the same check at ZzzInventory.cpp:1804. Showing the tooltip without the time left in that case would be safer than hiding it.

Non-blocking: an expiry plays the jewel sound. After the update ReceiveModifyItemExtended picks the sound from Items[itemindex].Item.Type, but Items is the list of items on the ground, so the slot index points at an unrelated drop. An expiry, now a normal event, plays SOUND_JEWEL01 (or the Kundun sound if that ground item happens to be a Lost Map). The lookup is old, but it should probably use the item that was just inserted, or play nothing for an expiry.

Non-blocking: an expired Dark Raven still gets its pet. CMyInventory::EquipItem calls CreatePetDarkSpirit(Hero) and sends the Dark Horse/Raven pet info requests before CreateEquippingEffect checks the expiry, so an expired raven would keep following the hero. OpenMU's cash shop can sell any item with a duration, so it isn't impossible.

Non-blocking: rule 1 of the coding rules. CreateEquippingEffect (about 85 lines) changes without an extracted part; pulling the pet and mount creation into its own function would give the expiry check one place too.

Non-blocking: tests. Only the byte decoding has a test. A doctest for IsShownEquipment and one for the right-click path with an expired item would keep these working through the coming looks-in-data work on SetCharacterClass. The in-game list doesn't mention a rented transformation ring expiring while it's worn, which the summary says the shop sells: does the hero's model go back without a relog?

bool shouldResyncInventory = false;
if (IsPlayerInventorySlot(itemindex))
shouldResyncInventory = !UI::Inventory::InsertItem(itemindex, itemData);
else if (itemindex >= 0 && itemindex < MAX_EQUIPMENT_INDEX)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Required. At the top of this function, every F3 14 calls DiscardPickedItem() when the player holds an item. That fit when F3 14 only answered the player's own jewel upgrade, but now the server sends it on its own when a rental runs out. If a pet expires while the player drags a Jewel of Bless to the vault, the jewel is deleted on the client; the server still has it in its old slot and nothing asks for a resync, so it stays invisible until a relog. The discard should only happen when the update is for the held item (or the held item should be put back with RestorePickedItem()).

A second, smaller effect of this branch: the re-equip goes through SetCharacterClass twice (unequip, then equip), and it calls SetPlayerStop each time, so an expiry while walking stops the hero mid-path on the client while the server finishes the walk. Non-blocking, but worth a look while you're here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 488294fde. The held item is now discarded only if the update ends it: it was used on another item (ApplyJewels marks it, and the update of the target answers the use), or it's the updated item itself. Any other held item stays in the hand. EnableUse couldn't tell these cases apart, because OpenMU sends the delete of the consumed jewel, which resets it, before the update of the target.

Tested in game: a Jewel of Bless held while a mounted Pet Skeleton expired stays in the hand after the expiry message, and applying a Jewel of Bless to an item still consumes it and raises the item's level.

About SetPlayerStop: SetCharacterClass stops the hero on every equipment change, also when the player equips something by hand while walking, so it isn't specific to the re-equip path. I left it as it is, because changing it would affect every equipment change.

// so the hero looks as if the slot was empty.
bool IsShownEquipment(const ITEM& item)
{
return item.Type != -1 && !(item.bPeriodItem && item.bExpiredPeriod);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Required. The hero is drawn without the expired item, but CharacterMachine->CalculateAll() at the end of SetCharacterClass still counts it: an expired wing keeps its damage, magic and defense bonuses (ZzzInfomation.cpp:1734 and following) and its walk speed (CalculateWalkSpeed), so the character window shows numbers the server no longer applies. Only the rings and the helper in CharacterInfoWindow.cpp check for expiry today.

A suggestion for how: right now each place that reads the equipment needs its own expiry check (drawing here, pets and the ring's mane in CreateEquippingEffect, equipping in two places), and the stats, the full-set check and EquipItem's raven are missed. One accessor that treats an expired slot as empty for gameplay (for example on CharacterMachine), used by the drawing, the effects and CalculateAll, would cover all of them with one rule and one test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done as you suggested, in f01b59aba. CHARACTER_MACHINE::GetEffectiveEquipment(slot) gives the item of a slot as the game uses it: an expired rental counts as an empty slot (an item with Type -1, never nullptr). The stat functions of CalculateAll, the CSItemOption loops (item skills, add-state and set options), the socket bonuses, FullSetOf and the drawing (IsShownEquipment) all use it, so they follow one rule. Equipment stays as it is for what the inventory shows.

Tested in game: with Small Wings of Satan the defense goes from 1921 to 1947, and back to 1921 when they expire, without a relog. The damage increase of the small wings doesn't show in the character window even while they're valid: they have no options in the client data, and the client never counted that increase. That's existing behaviour.

bool CInventoryActionController::TryEquipItem(CInventoryCtrl* targetControl, ITEM* pItem, int iSrcIndex) const
{
// An expired rented item can't be worn, like when it's dragged onto its slot.
if (pItem->bPeriodItem && pItem->bExpiredPeriod)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. Two things here. The check runs before the function checks that the item has an equipment slot, so right-clicking an expired item that can't be worn at all now says "Can't wear item." and skips TryDropItem, which ran before. And it's the same check and message as in CMyInventory::EquipmentWindowProcess for dragging. Moving it into CMyInventory::IsEquipable covers both paths (which already call it) and any later one, and keeps the order of this function as it was.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved into CMyInventory::IsEquipable (f01b59aba), so the drag and the right click follow the same check, and TryEquipItem is back to its old order: an item which can't be worn reaches TryDropItem again. The right click now refuses an expired item silently, like any other item it can't equip. The drag keeps the original client's "Can't wear item.".

Comment thread src/source/UI/Inventory/MyInventory.cpp Outdated
OBJECT* pHeroObject = &Hero->Object;
if (false == gMapManager.InChaosCastle())
// An expired rented pet or mount has no effect, so it doesn't accompany the hero (and doesn't collect zen).
const bool isExpired = pItem->bPeriodItem && pItem->bExpiredPeriod;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. bPeriodItem && bExpiredPeriod is now written out in three new places, next to five existing ones (ItemTooltipValues, ShopRestrictions, ItemCategories, EquipmentWindowProcess). Rule 4 of the coding rules asks not to duplicate; a GameLogic::Items::IsExpiredRental(const ITEM&) next to the rental rules would be the one place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GameLogic::Items::IsExpiredRental (9cb651d09) is used in the new places, and also by the accessor, IsHighValueItem, the tooltip values and the drag check. I left the older checks in ShopRestrictions, ItemEnduranceInfo and CharacterInfoWindow as they are, to keep the diff focused.

Comment thread src/source/UI/Inventory/MyInventory.cpp Outdated
if (Hero->EtcPart <= 0 || Hero->EtcPart > 3)
{
if (pItem->Type == ITEM_WIZARDS_RING && pItem->Level == 3)
if (pItem->Type == ITEM_WIZARDS_RING && pItem->Level == 3 && !isExpired)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. This touches a hard-coded case for one item. The coding rules for areas that are already data-driven say a touched special case moves into data with the change. That would be a bigger step than this PR needs, so it's fine to name it as a deliberate exception in the description instead (the checklist currently says the rules were followed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I named it in the description as a deliberate exception: moving the Wizard's Ring mane into data is a bigger step than this PR.

GameLogic::Items::IsExpiredRental replaces the bPeriodItem && bExpiredPeriod
pair, so the rule an expired rental follows has one place (coding rule 4).
The hero was drawn without an expired item, but the stats still counted it: an
expired wing kept its damage, defense and walk speed in the character window,
while the server no longer applies them.

CHARACTER_MACHINE::GetEffectiveEquipment gives the item of an equipment slot as
the game uses it: an expired rental counts as an empty slot. The stat
calculation, the item options (sets, excellent, socket bonuses, item skills),
the full set check and the drawing of the hero use it, so they follow one rule.

The pet and mount creation moves out of CreateEquippingEffect into
CreatePetOrMount, with the expiry checked once, and EquipItem no longer creates
the Dark Raven of an expired rental. IsEquipable refuses an expired item for the
drag and the right click alike; TryEquipItem is back to its old order, so an
item which can't be worn reaches TryDropItem again.
…r holds

Every item update (F3 14) discarded the held item. That fit when the update only
answered a jewel the player applied, but OpenMU also sends it when a rented item
expires: a Jewel of Bless held at that moment was deleted on the client and
stayed invisible until a relog.

The held item is now discarded only if the update ends it: it was used on
another item (the update of the target answers the use), or it's the updated
item itself. Any other held item stays in the hand.
The end of a rented item (D2 12) was only stored for the equipment and the main
inventory; FindPlayerItem covers the extension too. Before, a rented item there
had no end, and its tooltip didn't show at all.
A rented item which isn't expired and has no end hid its whole tooltip. The
server sends the end a moment after the item, and only for the inventory, so a
rented item in the Chaos Machine, in another player's shop, or between a move
and its D2 12 showed nothing when hovered, not even its name.

The tooltip is shown without the end instead: the new tooltip state
hasExpireDate decides the two expiration lines of Tooltip.json.
After an item update, the sound was picked from Items[index], the items on the
ground, so the slot index pointed at an unrelated drop: an expiry played the
jewel sound, or the Kundun sound. The sound now comes from the updated item, and
an equipped item, which only the server updates (a rental expired), plays none.
@pllanosclaria

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. Everything is addressed in the six new commits, tested in game against MUnique/OpenMU#1548:

  • Held item (488294fde): see the inline reply.
  • Stats (f01b59aba): see the inline reply.
  • Inventory extension (2e4fcbcdd): ReceivePeriodItemList uses FindPlayerItem. A rented item in the extension shows its end in the tooltip.
  • Tooltip without a date (3ecec44b5): the tooltip is shown without the end instead of hiding it. A new tooltip state hasExpireDate decides the two expiration lines in Tooltip.json (documented in docs/item-data.md).
  • Jewel sound (16fb9809c): the sound now comes from the updated item, and an equipped item, which only the server updates, plays none.
  • Dark Raven (f01b59aba): EquipItem doesn't create the raven of an expired rental.
  • Rule 1 (f01b59aba): the pet and mount creation moved out of CreateEquippingEffect into CreatePetOrMount, with the expiry checked once.
  • Tests: test_expired_rental_equipment covers the helper, GetEffectiveEquipment and an expired wing in the stats. IsShownEquipment is now a one-line wrapper of the accessor, so the accessor test covers it. The right click goes through IsEquipable now, but I didn't add a doctest for it, because it needs the inventory window; it's in the in-game list.
  • Transformation ring: tested in game. When a rented Skeleton Transformation Ring expires while it's worn, the hero's model goes back right when the expiry message shows, without a relog. The stats of an expired ring go back too.

I've updated the Testing section and named the Wizard's Ring case as a deliberate exception in the description.

Conflict in ApplyJewel, which main refactored: main's version is kept, and the
held jewel is still marked as used on the target item.
NeedsAllTooltipValues didn't name the new state, which fails the builds with
-Wswitch as an error (macOS). The state comes with the basic values.

@Mosch0512 Mosch0512 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: changes requested, one item. Everything from the first round is fixed or answered, thanks a lot for the quick and careful work, and for the replies on each point. GetEffectiveEquipment turned out nicely, and I agree with leaving SetPlayerStop and the Wizard's Ring as they are.

Required: some checks of the client still see an expired item. A few places outside the stats read CharacterMachine->Equipment directly, so an expired rented item still counts there:

  • CKanturu2ndEnterNpc::ValidateEquipmentForEntry (KanturuEvent.cpp:500): an expired transformation ring still makes the NPC refuse the entry with the transformation-ring popup (g_ChangeRingMgr->CheckMoveMap), although the ring has no effect anymore and the hero's model is back. The wing and Uniria checks there read the raw slots too.
  • The Icarus check of the move list (ZzzInterface.cpp:2793, HasFlightEquipment with the raw helper and wing): after a rented wing expires, the client still lets the player pick Icarus, and only the server refuses. The Uniria/Atlans check right above (line 2788) reads the raw helper as well.
  • hasDarkHorse (ZzzInterface.cpp:1380) and the weapon skills in SkillExecution.cpp:376 (SkillWarrior(c, &CharacterMachine->Equipment[i])).

Before this PR no item was ever expired with OpenMU, so these couldn't go wrong; now they can. Reading these slots through GetEffectiveEquipment would fix them. If you'd rather keep some for later, naming them in the description is fine too.

The notes inline are all non-blocking.

}
else
{
PlayBuffer(SOUND_JEWEL01);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. This covers an expiry of a worn item, but OpenMU sends the same F3 14 when a rented item expires in the bag. Then FindPlayerItem finds it and the jewel sound still plays, although nothing was upgraded. Playing the sound only when the update answers the player's own action would cover both, for example by reading the held item's IsUsedOnItem() before DiscardPickedItemUpdatedBy, or by skipping it when the new item is an expired rental.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 93efb04e4: PlayModifiedItemSound plays nothing when the updated item is an expired rental. Tested in game: a rented Small Wings of Satan which expired in the bag plays no sound, and applying a Jewel of Bless still plays it.

}

SendRequestUse(iSourceIndex, targetIndex);
pPickedItem->MarkUsedOnItem();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. SendRequestUse returns without sending anything while EnableUse counts down or when IsCanUseItem() is false (vault or trade open), but the jewel is marked as used anyway. It stays in the hand marked, and the next unrelated F3 14, for example an expiry, discards it while the server still has it. That's the vanishing item from the first round, in a much narrower case: dropping two jewels quickly, then an expiry before the second one is put back. Letting SendRequestUse return whether it sent, and marking only then, would close it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4598307c6: SendRequestUse returns whether it sent the request, and ApplyJewel marks the jewel only then. Applying a Jewel of Bless still consumes it and raises the item's level.

Master_Level_Data.lNext_MasterLevel_Experince = (iData_Master - (int64_t)3892250000) / (int64_t)2;
}

ITEM* CHARACTER_MACHINE::GetEffectiveEquipment(int slot)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. Every empty or expired slot gets the same m_NoEffectEquipment, as a writable pointer, and each call resets it. Nothing writes through it today, but CalculateDamage holds Right, Left, Amulet and both rings at once, so a later change that writes to one of them would show up in the others and vanish at the next call. Returning const ITEM* and pointing at one static const ITEM with Type -1 would rule that out, and the getter would no longer change the object, so it could be const too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that a static const ITEM would rule that out. It means const ITEM* through the stat code, though: PlusSpecial, PlusSpecialPercentOfSlot, ItemDefense, ItemMagicDefense, ItemWalkSpeed, CalcDurabilityPercent, the CSItemOption and socket loops and FullSetOf all take or hold an ITEM* today. That grows this PR well beyond the expiry, so I'd do it in a follow-up of its own, if that's fine with you. Nothing writes through it in this PR.

{
ITEM* pItem = UI::Inventory::FindMainInventoryItem(Data->wItemSlotIndex);
// The main inventory or its extension.
ITEM* pItem = UI::Inventory::FindPlayerItem(Data->wItemSlotIndex);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. The player's own personal shop is still missing: its slots (IsMyShopSlot) are part of the inventory storage OpenMU sends D2 12 for, but FindPlayerItem only covers the main inventory and the extension. A rented item in the own shop (where personalShopSellableWhileRented allows it) shows no end date. Looking it up in g_pMyShopInventory, as UI::Inventory::InsertItem does, would cover it. Since the tooltip now shows anyway, this is only the missing date.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With OpenMU a rented item can't get into the own personal shop: the server refuses to move a time-limited item into the personal store, valid or expired, and refuses to sell one from there (#1548). So no rented item is in the shop slots that D2 12 could be about. If another server allows it, looking it up in g_pMyShopInventory would be the way, as you say.

mu::ui::window::CInventoryCtrl::DeletePickedItem();
}

void DiscardPickedItemUpdatedBy(int index)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. This rule fixed the Required item of the first round, but only the in-game run covers it. It only looks at the held item's source storage, its slot and the new flag, so a doctest with a CPickedItem could pin it: an unrelated held item stays, the updated item itself and a jewel marked as used are discarded. That would catch a later change to GetSourceLinealPos or GetSourceStorageType that quietly breaks the match.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in 3532661a2. A CPickedItem can't be made in a test without the inventory windows, because it takes its size and position from the grid and the pointer. So the rule moved into a function of its own, IsHeldItemEndedByUpdate, which DiscardPickedItemUpdatedBy uses, and test_held_item_update pins it: an unrelated held item stays (also with the same slot number in another storage), and the updated item itself and a jewel used on another item are ended.

…ted item

Some checks still read the equipment directly, so an expired rental counted
there: an expired transformation ring made the Kanturu NPC refuse the entry,
expired wings still allowed Icarus in the move list (only the server refused),
and the Dark Horse and Dark Raven checks and the weapon skills of warriors and
elves saw the expired item. They read the slots through GetEffectiveEquipment
now, like the stats.
OpenMU sends the same item update when a rented item expires in the bag, and the
jewel sound played although nothing was upgraded.
…sent

SendRequestUse sends nothing while another use waits for its answer or the vault
or a trade is open, but the jewel was marked as used anyway, so the next
unrelated item update discarded it while the server still had it. It now returns
whether it sent the request, and the jewel is marked only then.
The rule of DiscardPickedItemUpdatedBy is a function of its own, so a test pins
it: an unrelated held item stays, the updated item itself and a jewel used on
another item are ended.
@pllanosclaria

Copy link
Copy Markdown
Contributor Author

Thanks again. The required item is fixed in 777f9ca68: the Kanturu entry check, the Atlans and Icarus checks of the move list, hasDarkHorse and the weapon skills read the slots through GetEffectiveEquipment now. I also changed two places with the same problem: hasDarkRaven, and the elf's weapon skills (SkillElf) in the same loop as SkillWarrior.

Tested in game: after a rented Small Wings of Satan expires while it's worn, warping to Icarus is refused, also right after the expiry message, while the character holds no other flying item.

The inline notes:

  • Sound of an expiry in the bag: fixed (93efb04e4).
  • Jewel marked although nothing was sent: fixed (4598307c6).
  • Doctest for the held-item rule: added (3532661a2).
  • static const empty item: I'd leave it for a follow-up (see the inline reply).
  • Own personal shop: OpenMU doesn't let a rented item into it (see the inline reply).

Everything is built on Linux and passes the whole ctest suite (3274), the static checks, and clang-format 21.1.8 on the changed lines. I also checked the changed files with clang and -Werror=switch, like the macOS build.

@Mosch0512 Mosch0512 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: approved, ready to merge. Round 2's Required item is fixed: the Kanturu entry, the Icarus and Atlans checks of the move list, hasDarkHorse and the weapon skills now read through GetEffectiveEquipment, and thanks for catching hasDarkRaven and the elf skills in the same go, and for testing the Icarus case in game. The bag sound, the jewel marked only when the request was sent, and the held-item rule as its own function with a test are all in, and your answers on the stand-in item and the personal shop make sense to me.

The red CI isn't from this PR: the only failing test is main's tests/data/test_buffs.cpp:354 ("Buffs: an unknown field is a warning, and the entry is kept"), which fails the same way on main and is fixed by #1183.

Three small notes, all Non-blocking:

Non-blocking: the stand-in item as a follow-up. Fine with me to keep GetEffectiveEquipment returning the shared writable m_NoEffectEquipment for now, since const ITEM* would change every stat helper. Could you open an issue for it, so the follow-up doesn't get lost?

The other two are inline.

bool IsHeldItemEndedByUpdate(STORAGE_TYPE source, int sourcePos, bool usedOnItem, int updatedIndex)
{
const bool isUpdatedItem = source == STORAGE_TYPE::INVENTORY && sourcePos == updatedIndex;
return usedOnItem || isUpdatedItem;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. One narrow case is left from the first round: when the server refuses the jewel (for example Bless on an item that's already at its limit), OpenMU answers with ItemConsumptionFailed (C1 26 FD), not F3 14. The jewel stays in the hand, still marked used, and the next unrelated F3 14, say a rental expiring, discards it while the server still has it. Remembering the target slot in MarkUsedOnItem and matching it against updatedIndex here, or clearing the mark when 0x26 FD arrives, would close it. A second case in test_held_item_update.cpp could pin it.

{
pPickedItem->MarkUsedOnItem();
}
PlayBuffer(SOUND_GET_ITEM01);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking. This was already so before the PR: the sound plays even when SendRequestUse sent nothing (cooldown, vault or trade open). Now that the if is right above it, moving the line inside it would make the sound match what happened.

@Mosch0512
Mosch0512 merged commit 141b8a0 into Mutizens:main Nov 23, 2026
17 of 21 checks passed
@pllanosclaria

Copy link
Copy Markdown
Contributor Author

Verdict: approved, ready to merge. Round 2's Required item is fixed: the Kanturu entry, the Icarus and Atlans checks of the move list, hasDarkHorse and the weapon skills now read through GetEffectiveEquipment, and thanks for catching hasDarkRaven and the elf skills in the same go, and for testing the Icarus case in game. The bag sound, the jewel marked only when the request was sent, and the held-item rule as its own function with a test are all in, and your answers on the stand-in item and the personal shop make sense to me.

The red CI isn't from this PR: the only failing test is main's tests/data/test_buffs.cpp:354 ("Buffs: an unknown field is a warning, and the entry is kept"), which fails the same way on main and is fixed by #1183.

Three small notes, all Non-blocking:

Non-blocking: the stand-in item as a follow-up. Fine with me to keep GetEffectiveEquipment returning the shared writable m_NoEffectEquipment for now, since const ITEM* would change every stat helper. Could you open an issue for it, so the follow-up doesn't get lost?

The other two are inline.

Thanks a lot for the reviews, the kind words and the merge, @Mosch0512! The two rounds made the client side much more solid.

I'll open an issue with the three follow-ups, so none of them gets lost:

  1. The stand-in item of GetEffectiveEquipment: one static const ITEM, and const ITEM* through the stat helpers.
  2. A jewel which the server refuses (C1 26 FD) stays marked as used: MarkUsedOnItem remembers the target slot, and only the update of that slot ends the jewel, with a second case in test_held_item_update.cpp.
  3. The sound of applying a jewel plays even when SendRequestUse sent nothing.

Then two PRs, one concern each: the held jewel (2 and 3), and the const stand-in (1).

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