Repository navigation
refactor(items): the stand-in of an equipment slot without effect is read-only - #1186
Merged
Mosch0512 merged 1 commit intoNov 25, 2026
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Point 1 of #1184, from the review of #1150.
CHARACTER_MACHINE::GetEffectiveEquipmentgave one writable member item,m_NoEffectEquipment, for every empty or expired slot, and emptied it again at every call. Nothing wrote through it, butCalculateDamageholdsRight,Left,Amuletand 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) constreturnsconst ITEM*: the slot's item, or onestatic const ITEMwithType-1.m_NoEffectEquipmentis gone.const ITEM*: the local item pointers of theCalculate*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
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 wholectestsuite 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.Checklist
docs/CODING_RULES.mdanddocs/PULL_REQUESTS.md; deliberate exceptions are named above with the reason.docs/build/README.md).