Skip to content

refactor(items): the stand-in of an equipment slot without effect is read-only - #1186

Merged
Mosch0512 merged 1 commit into
Mutizens:mainfrom
pllanosclaria:refactor/const-effective-equipment
Nov 25, 2026
Merged

Mosch0512 merged 1 commit into
Mutizens:mainfrom
pllanosclaria:refactor/const-effective-equipment

Conversation

@pllanosclaria

Copy link
Copy Markdown
Contributor

Summary

Point 1 of #1184, from the review of #1150.

CHARACTER_MACHINE::GetEffectiveEquipment gave one writable member item, m_NoEffectEquipment, for every empty or expired slot, and emptied it again at every call. Nothing wrote through it, but CalculateDamage holds Right, Left, Amulet and both rings at once, so a later change which wrote to one of them would have shown up in the others and vanished at the next call.

  • GetEffectiveEquipment(int slot) const returns const ITEM*: the slot's item, or one static const ITEM with Type -1. m_NoEffectEquipment is gone.
  • The code which reads it takes const ITEM*: the local item pointers of the Calculate* functions, CSItemOption, the socket bonuses, the Kanturu entry, and the helpers they pass the items to: PlusSpecial, PlusSpecialPercentOfSlot, AreItemOptionsActive, IsRequireEquipItem, ItemDefense, ItemMagicDefense, ItemWalkSpeed, GetEquipedBowType(ITEM*), SkillWarrior, SkillElf, CastWarriorSkill, and the two Kanturu checks. None of them changed an item, so the compiler accepted all of them as they are.

No behaviour changes. clang-format reindents the declarations of SkillCast.h, because two of them changed inside the namespace block.

Related issues

Refs #1184 (point 1; points 2 and 3 are #1185). Together with #1185 it closes #1184.

Screenshots or videos

Nothing visible changes: it's a refactor.

Testing

  • Built on Linux x64 Release.
  • Automated tests: test_expired_rental_equipment (the accessor gives the slot's item, or the read-only empty one for an empty slot and an expired rental, and the stats leave the expired rental out) and the whole ctest suite pass (3426). The static checks of the pre-push hook pass, clang-format 21.1.8 on the changed lines is clean, and the changed files compile with clang and -Werror=switch.
  • Not tested in game: nothing a player can see changes, and the tests above cover the accessor.
  • Not tested on Windows and macOS, only built there by CI.

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.

…read-only

GetEffectiveEquipment returned one writable member item for every empty or
expired slot and emptied it again at every call, so a change which wrote to it
through one pointer would have shown up in the others (CalculateDamage holds
five of them at once) and vanished at the next call.

It returns const ITEM* now, pointing at one static read-only item with Type -1,
and is const itself. The stat code and the helpers it hands the items to take
const ITEM*; none of them changed an item. No behaviour changes.

Refs Mutizens#1184
@Mosch0512
Mosch0512 merged commit b0d35a7 into Mutizens:main Nov 25, 2026
7 checks passed
@pllanosclaria
pllanosclaria deleted the refactor/const-effective-equipment branch November 25, 2026 22:56
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.

Follow-ups of #1150: the stand-in item of GetEffectiveEquipment, a refused jewel, the jewel sound

2 participants