Commit Graph
389 Commits
Author SHA1 Message Date
Mikołaj Piróg dda0b96ea5 Remove #defines in player.h and add constexpr where applicable (#4896)
* Change defines to constexpr int in player.h

* Add const or constexpr to player.h/cpp where applicable

* Update tests with changed names of player constatns

* remove unecessary variable
2022-07-05 17:25:23 +02:00
k-bar 26de74f4a2 AnimationInfo class correct style (#4870)
* AnimationInfo class correct case-style for private members

clang-tidy warnings:
readability-identifier-naming    invalid case style for private member

* AnimationInfo class correct case-style for members

clang-tidy warnings:
readability-identifier-naming    invalid case style for member

* AnimationInfo class correct case-style for methods

clang-tidy warnings:
readability-identifier-naming    invalid case style for method

* AnimationInfo class use nodiscard

clang-tidy warnings:
modernize-use-nodiscard    function  should be marked [[nodiscard]]
2022-07-03 16:55:37 +02:00
Gleb Mazovetskiy 6949a6f418 Monster: Remove MType/MData pointers
These pointers are redundant, replaces them with methods.
2022-07-03 13:21:11 +01:00
obligaron a6132a1aa8 Ensure that no overflow happens when loading (invalid) data 2022-07-03 10:20:42 +01:00
Andrew James ace09d5f45 Address int-arithmetic-overflow in loadsave.cpp (#4853) 2022-07-02 02:48:18 +02:00
Mikołaj Piróg 7cab074aa5 Correct members' names in monster.h (#4850)
* Fix case in AnimStruct
* Rename CMonster members
2022-07-01 23:34:32 +02:00
Gleb Mazovetskiy 3178dd5158 Replace most uses of sprintf with fmt (#4837) 2022-07-01 17:02:56 +02:00
k-bar c2432d23e8 Berserk light fix 2022-06-30 21:01:29 +02:00
Anders Jenbo d82f2ebc9e Pass players by reference instead of an index 2022-06-28 00:30:00 +02:00
Anders Jenbo 0d27761ac2 Make _oAnimFlag a boolean 2022-06-27 20:21:10 +02:00
obligaron ceb08d783f Introduce Player::plrIsOnSetLevel 2022-06-18 17:05:30 +02:00
obligaron d0c14fe92f Introduce Player::setlevel 2022-06-18 17:05:30 +02:00
obligaron 19749420b5 Introduce Player::isOnActiveLevel 2022-06-18 17:05:30 +02:00
obligaron 7afe7d2a70 Save Methods in loadsave gets MpqWriter passed 2022-06-16 09:43:34 +02:00
Gleb Mazovetskiy 779ccaca17 Overhaul translation fetching
1. Do not modify the map after loading. Instead, return string views
   (guaranteed to be null-terminated) from look up functions and return
   the key directly if not found.
2. Use an `unorded_map` instead of `map` where available (C++20).
   Saves a bit of RAM (~50 KiB) and improves lookup performance.
2022-06-14 12:46:36 +01:00
Anders Jenbo 1203514383 Clean up use of currlevel 2022-06-07 21:35:01 +02:00
staphen a2fe3a981e Fix issues with ears due to translation 2022-06-06 07:26:43 +02:00
Anders Jenbo 54cd839cf6 Clean up drlg tests 2022-06-05 16:43:06 +02:00
Andrew James 1047e408bd Simplify logic of UpdateMissilePos using helpers from 4620 (#4621) 2022-05-31 06:58:47 +02:00
qndel 354e329644 Players[MyPlayerId] -> MyPlayer 2022-05-31 05:35:52 +02:00
Anders Jenbo 0645d9b2a1 Correct missing hellfire level mapping in leveltype
Hellfire never added the 2 new dungion types, instead it makes
additional checks on currlevel. This is confusing and mess, so cleaned
it up.
2022-05-10 15:16:38 +02:00
ephphatha 64a2c41b2c Set clang-tidy config for MethodCase option
Previously this was falling back to FunctionCase, leading to inconsistent casing of class methods throughout the codebase. Applied to Item as an example.
2022-04-20 13:50:57 +02:00
DakkJaniels dad46e1905 Item special effect enum (#4129) 2022-04-19 15:44:46 +02:00
ephphatha 7e7798fd2b Add function to mark an item as empty 2022-04-18 19:25:55 +02:00
Gleb Mazovetskiy a66ca44695 Zero-based frame indexing
Index frames starting at 0 instead of 1.
2022-04-14 04:39:26 +01:00
ephphatha eb45b3708b Only save stash pages containing items
Viewing a stash page results in an entry being created in the stashGrids map. If the player flicks through the entire stash without actually storing an item they end up with ~20kb of unnecessary data in the stash file when they next save.
2022-04-04 18:58:35 +02:00
Drakker 3039b760e1 Added more Quickspell hotkeys for a total of 16. Saving will write the number of configured quickspell slots at the beginning of the hotkeys file. The loader will check the size, if its bigger than older saves should be it will load the header and read the hotkeys, otherwise it will load 4 quickspells for compatibility. 2022-04-02 20:19:46 +02:00
Andrew James 028c5945b8 Add helpers to change stash pages (#4287) 2022-04-02 10:54:25 +02:00
ephphatha 2b47f3abcc Address type conversion warnings in loadsave.cpp
Most of this was centred around stash pages being saved/loaded as unsigned values but stored as signed values. Consistently used unsigned since it matches the intended usage.
2022-03-30 13:16:32 +02:00
Anders Jenbo 1409e604f5 Reduce string conversions 2022-03-20 11:04:15 +01:00
Anders Jenbo a48f89007d Implement stash 2022-03-18 06:01:53 +01:00
Gleb Mazovetskiy f4bce38875 Use uint16_t for sprite widths 2022-03-06 04:49:13 +01:00
Gleb Mazovetskiy 7fede6c4cb Clean up owned/unowned CelSprite ambiguity
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.
2022-03-06 04:49:13 +01:00
DakkJaniels 7bc19ee91a add enum for the spell flags. Adjust code to use them. 2022-03-06 02:09:19 +01:00
ephphatha 9a2002e200 Get rid of RemoveEmptyLevelItems
This was a cleanup function to handle converting saves between Hellfire <-> Diablo, mainly when a hellfire specific item was dropped and should be removed from a Diablo game. This had an off by one with the way it iterated backwards over the active items list which meant it always called DeleteItem at least once (since it uses an invalid item past the end of the active items range). DeleteItem then always decremented the ActiveItems count. When saving the game after converting the items we then end up with a dropped items array containing an index to an item that is no longer considered active.

However the code in LoadDroppedItems already checks that the conversion was successful before considering it active, so this function doesn't need to be called. Instead we can just save if we converted game mode.
2022-02-08 12:10:42 +01:00
Gleb Mazovetskiy 7c07e9a3e1 loadsave.cpp: Fix -Wsign-compare and -Wnarrowing 2022-01-30 14:56:04 +01:00
Anders Jenbo a19d3ad6a2 Fix typo of availableMissiles 2022-01-27 05:08:32 +01:00
ephphatha 32d397eb2a Add max_size checks when adding missiles to allow for limited size containers
This doesn't handle failed allocations (e.g. if the platform runs out of memory) but makes it easier to use a fixed size container on limited memory devices.
2022-01-23 05:02:57 +01:00
ephphatha d3c42544a6 Address warnings/dead code 2022-01-23 05:02:57 +01:00
obligaron c68eeb25cc Add additional missiles to save game 2022-01-20 23:12:48 +01:00
obligaron 234a053863 Change Missiles Array to std::list 2022-01-20 23:12:48 +01:00
ephphatha 14aeeaa24d Don't count invalid items as active items 2022-01-03 11:59:43 +01:00
ephphatha 5fa0dfbc28 Skip loading item locations from file
It's safer and easier to rebuild this as we load each item.
2022-01-03 11:59:43 +01:00
obligaron 419fe7b7ec Change Keymapper to OptionCategory/OptionEntry 2021-12-23 00:26:12 +01:00
obligaron b2750c99e7 Call SyncPortals() only once for a level load 2021-12-13 01:19:14 +01:00
Gleb MazovetskiyandAnders Jenbo 7e1fea6f76 clang-format all files in {Source,test}/
Also includes a few manual tweaks to comments and newlines for better results.

Co-authored-by: Anders Jenbo <[email protected]>
2021-11-24 23:44:12 +01:00
ephphatha b8b220311a Remove AvailableItems, no longer required 2021-11-23 19:08:41 +01:00
ephphatha 18658f6a42 Remove duplicate argument to DeleteItem 2021-11-23 19:08:41 +01:00
ephphatha f60cc3bfd9 Update calls to DeleteItem to use ActiveItems inline
This highlights how all (except one) call sites duplicate the i argument. With the exception of the use in msg.cpp this can be treated as a offset into activeItems and doesn't care about the real index.
2021-11-23 19:08:41 +01:00
ephphatha 55a52b82c2 Use unsigned types for Items array indexes consistently
Actual type used varied based on context, this addresses some type conversion warnings.
2021-11-23 19:08:41 +01:00