186 Commits
Author SHA1 Message Date
Gleb Mazovetskiy c361e764cc FixedPoint: Follow C integer promotion rules
Also allow implicit widening conversion.
Narrowing conversion still explicit.
2026-10-11 21:55:08 +01:00
Gleb MazovetskiyandClaude Sonnet 5 92927ca913 Migrate ClassAttributes, player HP/mana, item HP/mana bonuses, and monster HP to Fixed10_6/Fixed26_6
Replaces ParseFixed6/parseFixed6/readFixed6/readDecimal's raw-int
plumbing with the new FixedPoint type, then propagates strongly-typed
fixed-point fields through everywhere that consumed them: player
_pHitPoints/_pMana (and their base/max variants), ClassAttributes'
percentage/multiplier fields, Item::_iPLHP/_iPLMana, and
Monster::hitPoints/maxHitPoints. Eliminates manual <<6/>>6 bit-shifting
at nearly every call site in favor of fromInt/fromRaw/whole() and the
new fixed-point arithmetic operators, while preserving raw() only at
genuine serialization/network wire-format boundaries.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-10-11 21:55:08 +01:00
Developer Guilliman bd1ee963f7 Extract additional player class attributes to attributes.tsv files 2026-09-26 09:45:42 +00:00
Eric Robinson e6032a69a8 Split control.cpp (#8347) 2025-12-13 08:32:02 +00:00
Eric Robinson 37daef5de3 Fix Resurrect Illegal Player State/Crash (#8349) 2025-12-11 20:12:40 -05:00
Eric Robinson 7e8173e6ff Add Player hasNoLife helper (#8302) 2025-12-03 05:12:42 +00:00
Anders Jenbo 1c76897f2c Apply simple const rules using clang-tidy 2025-08-16 01:21:36 +02:00
Anders Jenbo 7b2de562c2 Extract more Hellfire into data 2025-07-21 00:42:33 +02:00
Gleb Mazovetskiy b76feb2be3 Extract game mode out of init.cpp
Untangles some dependencies
2025-01-09 11:02:19 +00:00
KPhoenix b0cb1b92ed Bugfix: Corruption item power 2024-09-18 00:52:39 +02:00
obligaron f445bb4ef8 Change CastSpell to Player reference 2023-12-02 12:57:34 +01:00
obligaron 79a43dc1de Introduce AddMissile overloads specific for player and monster 2023-11-26 13:36:28 +01:00
obligaron b810c808f5 Msg: Change OnXYZ to get a Player reference instead of a player index 2023-11-12 22:17:59 +01:00
Gleb Mazovetskiy 62e9aa0448 MissilePosition: Use WorldTilePosition
Reduces struct size and makes the types of coordinates more obvious.
2023-08-29 20:00:54 +01:00
ephphatha da76e131e4 Add getter/setter for character levels to ensure _pNextExper stays synced 2023-08-24 05:46:44 +02:00
ephphatha d92d152576 Use unsigned type for character levels 2023-08-24 05:46:44 +02:00
Anders Jenbo 5a12f7b0d5 Always spawn players in a valid location 2023-04-29 15:34:41 -04:00
obligaron b87711bc08 Reintroduce Player::spellFrom to seperate teleport cursor from queued spell 2023-04-17 03:22:50 +02:00
Gleb Mazovetskiy ebcd6b222d Optimize SpellData size: 40 bytes -> 24 2023-02-10 10:51:06 +00:00
Gleb Mazovetskiy b61dac853b Add GetSpellData(SpellID) 2023-02-05 12:12:48 +00:00
KPhoenix d813f13700 enum spell_id -> enum class SpellID 2023-02-05 10:24:58 +00:00
Eric Robinson ef3a57b7d9 enum spell_type -> enum class SpellType (#5674) 2023-01-28 22:25:37 +01:00
Eric Robinson 3642904a4c Fix Resurrect Crash (#5718) 2023-01-23 23:20:52 +01:00
c99f7cf644 Floating numbers (#5639)
Co-authored-by: qndel <[email protected]>
Co-authored-by: Stephen C. Wills <[email protected]>
2023-01-22 07:20:10 +01:00
KPhoenix 8db521727d enum missile_id -> enum class MissileID
Changes `enum missile_id` to `enum class MissileID`
2023-01-18 17:17:25 +00:00
Gleb Mazovetskiy 680ab5ec40 Overhaul backbuffer state handling
When rendering directly to the output buffer, we need to maintain the
state of what has been drawn and what needs redrawing per-buffer.

We previously tried to do it implicitly by checking `SDL_DOUBLEBUF` and
other flags. The previous implementation was broken in several
ways, resulting in rendering issues on devices that support 8-bit output
directly.

Changes this mechanism to explicitly maintain buffer state per output
buffer. The new mechanism doesn't require knowledge of the number of
buffers, and thus also works correctly with triple-buffering.

Fixes #5447
2022-11-01 02:43:24 +00:00
staphen 702fedbc54 Remove ConsumeSpell() from AddMissile() functions 2022-10-23 10:10:57 +02:00
Gleb Mazovetskiy 188dc79f6e Make Players a vector 2022-08-26 13:22:04 +09:00
obligaron 439a9926e5 Clean up spell usage function names
Rename UseMana -> ConsumeSpell
Rename RemoveCurrentSpellScroll -> ConsumeScroll and remove unused return value
Rename UseStaffCharge -> ConsumeStaffCharge
Rename UseScroll -> CanUseScroll
2022-08-02 03:05:46 +02:00
obligaron 279e92e69c Checks conditions for spell again, cause initial check was done when spell was queued 2022-08-02 03:05:46 +02:00
obligaron 1cfd1ca99d Fix double casting bug - use separated info for casted and queued spells 2022-08-02 03:05:46 +02:00
Anders Jenbo 56915974d6 Minimize passing of player indexes 2022-07-18 11:15:50 +02:00
Anders Jenbo d1189388f5 Use user by reference 2022-07-17 18:41:05 +02:00
Anders Jenbo 3d08f951d6 Clean up use of miniwin 2022-07-10 21:13:39 +02:00
Anders Jenbo 2d21fc372e Remove more miniwin code 2022-07-10 21:13:39 +02:00
Anders Jenbo 6a8fd04067 Use player by references (#4938) 2022-07-10 11:40:04 +02:00
staphen cab75ded6b Check both SPL_NULL and SPL_INVALID to determine spell validity 2022-07-09 04:04:22 +02:00
Gleb Mazovetskiy 17f8cdddc4 Clean up GetSpellLevel
Remove the buggy `GetSpellLevel` implementation and use
`Player#GetSpellLevel` throughout instead.
2022-07-03 13:40:53 +01:00
Anders Jenbo ab55877adc Take player by reference in UseMana 2022-07-03 08:03:02 +02:00
Anders Jenbo b00ae287b8 Minimize propegation of global Players index 2022-07-03 06:10:42 +02:00
obligaron 19749420b5 Introduce Player::isOnActiveLevel 2022-06-18 17:05:30 +02:00
Vladimir Olteanu 4d6ff58c22 Reduce reliance on bool done for control flow (part 1 of x) (#4720) 2022-06-17 13:13:39 +02:00
staphen b363d5d962 Fix order of loop conditions when adding spell missiles 2022-06-15 05:54:24 +02:00
Gleb Mazovetskiy 628406a44c Refactor inventory/belt item presence and removal
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.
2022-06-05 13:30:26 +02:00
qndel 354e329644 Players[MyPlayerId] -> MyPlayer 2022-05-31 05:35:52 +02:00
DakkJaniels 313cdb853c GetManaAmount - fix usage of pMaxManaBase
I don't think this ever comes up because no spells have an sManaCost of 255, however _pMaxManaBase is stored as fixed point, so it should be shifted before use.

But to be honest, I'm not even sure what it is trying to do here. Was sManaCost == 255 supposed to indicate that it was going to use all the player's mana? Why was it cast to a BYTE before using it? Did they intend to limit the manage usage to 255 and just screwed up? I originally saw this logic in Devilution, and found it because the Middle Earth mod had a slight change here, where it used pMana (maybe because they thought it was intended to be a spell that used all the player's mana?) Also, I saw that in 1.07, Ghidra saw `ma` as a byte, not an int as written in Devilution - I wonder if that's where the cast came from? In the ME Mod version, it sees `ma` as an int.
2022-04-16 05:06:28 +02:00
staphen e6182709d1 Allow casting Town Portal, Teleport, and Guardian scrolls from inventory 2022-04-03 23:37:00 +02:00
ephphatha 92fcdda3a7 Refactor OnHealOther to operate on Player references 2022-03-30 00:49:56 +02:00
ephphatha 25c2123849 Change cursor after acknowledging attempt to cast spell
This matches the behaviour of other targeted spells, however the mana is wasted because it is spent when readying the spell.
2022-03-30 00:49:56 +02:00
qndel be0b79f9f5 Add IsWallSpell helper 2021-12-07 12:00:52 +01:00