Introduces new functions to check for presence of and remove player items.
These functions do not rely on or expose item indices.
They're implemented as free functions instead of Player methods due to
complicated include dependencies between `player.h`, `inv.h`, and
`inv_iterators.h`. We should probably look into cleaning this up at some
point.
Previously this was falling back to FunctionCase, leading to inconsistent casing of class methods throughout the codebase. Applied to Item as an example.
Used when moving from one persistent variable to another where we want the source variable to be marked empty. Defining as a function instead of move constructor/assignment operator as we only really need to mark the source for xvalues. Detecting that in the constructor/assignment would be needlessly complicated.
This cleans up a bit of code and solves a few edge cases where an item
could be lost, the game be unresponsive, or miss fire an event during
lag cause of the cursor not reflecting the currently held item.
* Move declaration of dItems to items.cpp
This array is never used in dungeon generation, it's closely related to Items so should be kept together. Ideally managing dItems can become responsibility of a container for Items, which will handle adding/removing items from the list and keeping the positions in sync.
* Rename SetPlrHandItem to match purpose/use
* Give more descriptive name to GetPlrHandSeed
This function sets a new seed on a given item struct, not just the held item.
* Don't use HoldItem as a temporary for the players initial inventory
* Take Item by reference in RespawnItem
* Don't use holdItem as a temporary when dropping gold on death
* Update DeadItem to take item by reference, and refer to it consistently
Move code which invalidates the source of dropped items to the caller
Most call sites use a temporary item instance or remove the item from the container, so there's no real point invalidating the item after it's been copied to the drop list.
Update DeadItem to take position instead of player references
Makes `CelSprite` unowned and adds a new `OwnedCelSprite` class for
owned sprites.
This clarifies ownership and makes the code cleaner in a number of
places.
Additionally, because the `CelSprite` class is now tiny (1 less
pointer), we can pass it by-value instead of by-reference, removing a
pointer indirection in the rendering functions.
This fixes a problem related to shrines. When a player with a base Magic or Vitality stat of 0 has their respective stat reduced below 0, they lose Mana/Life, and their stat is corrected to 0 without refunding them the lost Mana/Life. This will prevent stats from being modified to a value less than 0 in the first place.
This is a bugfix for the vanilla 1.06 and earlier Mana Shield logic. In 1.07 Blizzard North "fixed" the Mana Shield logic since the damage reduction would decrease in effectiveness with increased spell level instead of increase. As a fix, they set the damage reduction to a flat value regardless of spell level. Originally, damage reduction started at 1/3 and capped at 1/21 at spell level 7. This fix reverses the order and gives 1/21 damage reduction at spell level 1, and caps at 1/3 damage reduction at spell level 7.
This is very similar to the code used when casting heal other, except for how the amount to heal is chosen. Could potentially reuse it there as well with a bit of work.