Commit graph

444 commits

Author SHA1 Message Date
Anders Jenbo
903d4bd2e1 Scope all for loops
This caused 7 of the loops to be rewriteen using range by clang-tidy
2021-07-08 08:14:03 -07:00
Anders Jenbo
467b74dc06 Rename object globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
9b8bf92575 Rename quest globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
96bf75b502 Rename player globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
c8870dbd1f Rename item globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
07ad083fda Rename monster globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
bc59218d0d More clang-tidy/Android Studio cleanups 2021-07-04 19:34:37 +02:00
Anders Jenbo
4eabc6024b Apply various cleanups via Android Studio 2021-07-03 18:27:17 -07:00
Gleb Mazovetskiy
cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
Anders Jenbo
50aa3dce0d Fix GCC warning in inv.cpp 2021-07-02 21:01:25 +02:00
qndel
fd3893190f inv cleanup 2021-07-02 05:00:31 -07:00
qndel
a1710ff51e
pass item to CelDrawItem (#2265)
pass item to CelDrawItem
2021-06-29 18:09:54 +02:00
Juliano Leal Goncalves
cbb84199c2 ♻️ Replace Point addition with 'Point + Displacement' 2021-06-28 20:37:44 -07:00
Juliano Leal Goncalves
fd9f2099d0 ♻️ Leverage 'Point' to represent mouse position 2021-06-27 16:37:59 +02:00
Anders Jenbo
790f42d078 Clang-tidy: readability-inconsistent-declaration-parameter-name 2021-06-27 01:06:00 +02:00
Andrew James
60a47caf1b
Refactor Draw* functions to use Rectangle and Point types
Added overload for DrawString taking a Point to avoid creating a rect for callers which only use position. This also documents the way DrawString operates when passed a clipping rectangle with a dimension of 0.
As part of this overload removed the logic for 0 width regions from DrawString. This does change the behaviour of the Rectangle version if called with a rect with width 0, all callers using that behaviour have been updated in this commit.

Using Rectangle/Size allowed simplifying the logic for certain calls where they could use DrawText alignment flags, previously this was manually aligning by calculating dimensions and offsetting the position. This also fixes #2169

Also includes a few instances where a temporary buffer was used to set the text to be drawn with unbounded sprintf calls, replaced those with snprintf as is recommended in modern C applications. Moving to C++ strings would be good in a future refactor.
2021-06-24 01:36:06 +02:00
Anders Jenbo
ee7b32d8f6 Player by reference part 3 2021-06-24 00:53:09 +02:00
Anders Jenbo
e670faac99 🔥 Remove unused code DrawInvMsg 2021-06-23 14:42:19 -07:00
Gleb Mazovetskiy
f98148484f
🐞 Fix inventory manipulation (#2216)
Fixes #2214
Co-authored-by: staphen <staphen@gmail.com>
2021-06-23 08:05:19 +02:00
Gleb Mazovetskiy
5cefb4a365 Fix -Wswitch in UseInvItem
Fixes a giant non-exhaustive switch warning in `UseInvItem`:

```
../Source/inv.cpp: In function ‘bool devilution::UseInvItem(int, int)’:
../Source/inv.cpp:2131:9: warning: enumeration value ‘IDI_GOLD’ not handled in switch [-Wswitch]
 2131 |  switch (item->IDidx) {
      |         ^
../Source/inv.cpp:2131:9: warning: enumeration value ‘IDI_WARRIOR’ not handled in switch [-Wswitch]
../Source/inv.cpp:2131:9: warning: enumeration value ‘IDI_WARRSHLD’ not handled in switch [-Wswitch]
../Source/inv.cpp:2131:9: warning: enumeration value ‘IDI_WARRCLUB’ not handled in switch [-Wswitch]
...
```
2021-06-21 01:37:26 -07:00
Gleb Mazovetskiy
e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
Gleb Mazovetskiy
aa54675d83 🚚 engine.h: Extract Size 2021-06-21 01:36:20 -07:00
Juliano Leal Goncalves
a983792880 ♻️ Replace 'pair<int, int>' with 'Size' in 'GetItemSizeOnSlot' and 'GetInvItemSize' 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
572c3e632e ♻️ Leverage 'Point' in 'InvDrawSlotBack' implementation 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
07a049f667 ♻️ Replace 'INV_SLOT_SIZE_PX' macro with Size-based constexpr 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
0e2d734bbb ♻️ Leverage 'Size' in 'CheckInvPaste' implementation 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
4ab80d25f4 ♻️ Leverage 'Size' in 'AddItemToInvGrid' function 2021-06-20 18:27:45 -07:00
Gleb Mazovetskiy
43bc08bd63 Hardware Cursor: Fall back to software on failure 2021-06-19 12:36:39 +01:00
Gleb Mazovetskiy
523d838bd4 Hardware Cursor: Use item hotpoint
For a hardware item cursor, set the hotpoint to the center
instead of manually setting the cursor position.
2021-06-19 12:36:39 +01:00
Gleb Mazovetskiy
432fdacd81 Clip InvDrawSlotBack draw call 2021-06-16 03:12:54 +02:00
qndel
816b244689 HasItem/RemoveInvItem combo refactor 2021-06-13 05:18:08 +02:00
qndel
0c39656c91 fix reconstructed note 2021-06-13 05:18:08 +02:00
Juliano Leal Goncalves
1328c9ea93 🎨 Make 'Size' fields camelCase 2021-06-12 19:47:52 +02:00
Vladimir Olteanu
512fcdb790 Use WalkingDistance in PutItem 2021-06-02 13:36:17 +02:00
Juliano Leal Goncalves
8622130966 ♻️ Add '==' and '!=' operators to 'Size' struct 2021-05-31 06:13:24 +02:00
Juliano Leal Goncalves
ff3dee8d45 ♻️ Replace poor usages of 'Size' with 'Point's 2021-05-31 06:05:13 +02:00
Juliano Leal Goncalves
abee4fe6fe ♻️ Repurpose the 'InvXY' struct as a new 'Size' struct 2021-05-31 06:05:13 +02:00
Juliano Leal Goncalves
21ecaa225f
♻️ Leverage 'Point' struct on inventory functions (#2094) 2021-05-30 23:44:38 +02:00
Kalebe Alves
118efe8e6d
Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
Gleb Mazovetskiy
dd3ea66fa2 ♻️ Split getTextColor(bool) into 2 functions
This is a bit more readable than using a bool argument.
2021-05-28 13:38:36 +02:00
qndel
2f3cf65b27 cleanup getTextColor 2021-05-26 15:58:14 +02:00
Anders Jenbo
8a7ec56d3a Player by reference part 2
This mostly change player to be by reference instead of by index.
But additionally it does stript checks for gold in the belt, move some
value types to the initialization and short circute a few functiongs.
2021-05-24 21:00:32 +02:00
Anders Jenbo
6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Juliano Leal Goncalves
21fdb0dcd9 ♻️ Replace manual direction displacement logic with 'Point' add operator 2021-05-24 04:46:08 +02:00
Juliano Leal Goncalves
d55cd99dd5 🚚 Rename 'direction' enum to 'Direction' 2021-05-24 04:46:08 +02:00
Juliano Leal Goncalves
15c46b9eb0 💬 Rename HeroSpeech members to improve discoverability 2021-05-23 22:01:47 +02:00
Juliano Leal Goncalves
5350250a76 🚚 Rename speech functions to 'Say' variations 2021-05-23 05:32:34 +02:00
Juliano Leal Goncalves
8c620ce29e ♻️ Extract 'HeroSpeech' enum class for hero sounds instead of using raw ints 2021-05-23 05:32:34 +02:00
Jmgr
0e7ada15fc Apply new format to ngexttext translations 2021-05-21 01:02:45 +02:00