Commit graph

98 commits

Author SHA1 Message Date
obligaron
54d63e2edd Change AnimationInfo.pCelSprite to const 2021-07-12 07:40:38 -07:00
ephphatha
e25d287ba9 Move SetObjMapRange to a member function
Due to the way this function is used it was easiest to also change ObjIndex to return a reference to the object instead of the index. Also added an explicit conversion from Size to Displacement to make one of the uses slightly cleaner to express.
2021-07-10 19:11:30 -07:00
ephphatha
b680e3fef1 Align end comment markers for doxygen comments
Including a bunch from previous PRs (since I was responsible for the broken formatting for most 😓)
2021-07-09 18:00:15 +02:00
Anders Jenbo
2ca6e37c46 Clean up sub folders using clang-tidy/Android Studio 2021-07-08 03:30:25 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
ephphatha
3520dc4201 Update numeric literals to use appropriate suffix
Mainly things like .F for floats instead of doubles in float context.
2021-07-05 08:52:05 -07:00
Gleb Mazovetskiy
55464eec78 Fix -Wmissing-braces
Fixes warnings such as this one:

```
../../../../../../Source/engine/render/text_render.hpp:83:33: warning: suggest braces around initialization of subobject [-Wmissing-braces]
        return DrawString(out, text, { position.x, position.y, out.w() - position.x, 0 }, flags, spacing, lineHeight, drawTextCursor);
                                       ^~~~~~~~~~~~~~~~~~~~~~
```
2021-07-03 19:08:45 -07:00
Anders Jenbo
a7c7fa0030 Fully apply clang-tidy/format to all files 2021-07-03 16:41:43 -07:00
Gleb Mazovetskiy
cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
Gleb Mazovetskiy
3faeb5628a Fix Rectangle::Contains bounds check 2021-07-03 09:09:48 +01:00
ephphatha
6008ea91c1 Address C4244 warnings in MSVC
Making Displacement and Point operator*(float) use explicit casts because rounding is desirable.
2021-07-01 09:34:42 -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
0441ffc2f4 ♻️ Move 'fromDirection' from 'Point' type to 'Displacement' type 2021-06-28 20:37:44 -07:00
Juliano Leal Goncalves
7f89420559 Add 'Displacement' type to represent coordinate deltas 2021-06-28 20:37:44 -07:00
Anders Jenbo
0f2ad469ea ♻️Clean up variable initialization 2021-06-27 14:58:51 -07:00
Anders Jenbo
8e07ef8fe5 Clang-tidy: misc-unused-parameters 2021-06-27 17:34:32 +02:00
Juliano Leal Goncalves
d93e1fdf07 Add 'Contains' function for 'Rectangle'
This will be useful for various bound checks throughout the code.
2021-06-27 16:37:20 +02:00
ephphatha
921c7af8c6 Expand comments for vanilla RNG functions
And put them in the header 😂
2021-06-27 04:14:18 -07:00
ephphatha
357f6f1dc3 Move RNG functions to their own header/source files 2021-06-27 03:09:41 -07:00
obligaron
3a9cc631c7 Rename DelayLen -> TicksPerFrame
Rename DelayCounter -> TickCounterOfCurrentFrame
2021-06-27 01:26:49 -07:00
obligaron
3ba4bac5e2 Harmonize DelayLen for Player and Monster (was 1-based on monseter (>= DelayLen) and 0-based on player (> DelayLen). Now both are 1-based (>= DelayLen) 2021-06-27 01:26:49 -07:00
Anders Jenbo
fa54499aeb Clang-tidy: readability-uppercase-literal-suffix
Strip suffixes
2021-06-27 03:17:36 +02:00
Anders Jenbo
ec8d7bebe2 Clang-tidy: modernize-use-auto 2021-06-27 01:18:31 +02:00
obligaron
d4bda3c13e ADL: correct comment typo 2021-06-26 13:30:36 -07:00
obligaron
801207a8ac ADL: Handle incorrect TicksSinceSequenceStarted better 2021-06-26 13:30:36 -07:00
Anders Jenbo
2bdb6caa07
Cleanup majority of remaning implicit bool conversions (#2234) 2021-06-26 21:05:45 +02:00
Andrew James
ff145b422d
Refactor plrctrls functions to use Point and Direction types (#2155)
* Refactor GetRotaryDistance to use Point instead of int x/y params

* Refactor HSExists to use Point instead of int x/y params

* Refactor IsPathBlocked to take typed params (Point, Direction)

The caller was already passing in a Direction value so this matches usage better. I also pulled the Direction to Point helper function up so it is available as a static class member, this allows replacing the use of the Offset array in plrctrls.cpp.

When adding a Direction to a point (and not scaling it first) I avoid explicitly creating a Point object since the operator+ overload will do that conversion implicitly.

* Replace Offsets array with Point::fromDirection

* Refactor GetDistanceRanged to use Point

I've added ExactDistance as a member function of Point to match ApproxDistance instead of only having it defined in GetDistanceRanged, it seemed more appropriate to be part of the class. Also removed temporary variables from callers of GetDistanceRanged as they were mainly used as a convenience for avoiding repetition when passing values into this function.

* Refactor GetDistance to use Point
2021-06-26 17:56:06 +02:00
obligaron
fb23521288 Introduce AnimationInfo.IsPetrified to handle Stone Curse Spell 2021-06-25 11:52:12 -07:00
obligaron
a4cacfbcbe Enable ADL for Monsters 2021-06-25 11:52:12 -07:00
Anders Jenbo
2417d3d333 🔥 Remove unused code 2021-06-25 13:22:08 +02:00
Anders Jenbo
af254601d6 ♻️ Apply clang-tidy to engine 2021-06-25 13:22:08 +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
Gleb Mazovetskiy
8a9618aea2 ♻️ Clean up cel_header.hpp
1. Rename `CelGetFrameStart` to `CelGetFrame`, in line with the other 2
   functions with the same name and load the `uint32_t` safely.
2. Remove redundant `FrameHeader`, simply use `LoadLE16`.
3. Document all the functions.
2021-06-23 11:27:56 +01:00
Gleb Mazovetskiy
14218080b6 🚚 engine.h: Extract CelGetFrame and friends 2021-06-21 02:34:28 -07:00
Gleb Mazovetskiy
1bc9c3973f 🚚 engine.h: Extract Rectangle 2021-06-21 02:34:28 -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
Gleb Mazovetskiy
dcf3397139 🚚 engine.h: Extract ActorPosition 2021-06-21 01:36:20 -07:00
Gleb Mazovetskiy
f9f301b054 🚚 engine.h: Extract Point, Direction, clamp
`engine.h` is getting quite bloated. Moves this code to their own files.
2021-06-21 01:36:20 -07:00
ephphatha
b478d8295c Remove dead code, FreeText() is never called
Given the program already lets the destructors get called naturally there's no need to explicitly call this function. Even if it was desirable to re-init the font data the old instances will be destroyed when the new instance is assigned to the optional.
2021-06-19 08:47:47 -07:00
qndel
6931c438d3
fix typo (#2150) 2021-06-13 20:15:23 +02:00
Chance4us
608c231f46
Draw black drop shadow for automap (#2090) 2021-05-31 16:09:55 +02:00
Kalebe Alves
118efe8e6d
Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
Kalebe Alves
0461529176 Move byte from engine.h 2021-05-27 16:04:27 +02:00
qndel
b1d74d2791
alt highlighting (#2060) 2021-05-25 23:47:29 +02:00
obligaron
61ba5009ac Convert to CelSprite 2021-05-24 20:12:43 +02:00
Anders Jenbo
6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Gleb Mazovetskiy
b76f7656f3 🧹 LoadArt: BYTE -> uint8_t
The change in include order necessitated a couple of other minor
cleanups, one in stubs.h and one in sdl2_to_1_2_backports.h
2021-05-23 18:45:01 +02:00
qndel
69b903743a fix typos 2021-05-23 05:52:52 +02:00