166 Commits
Author SHA1 Message Date
Gleb Mazovetskiy 62d067b653 Remove utils/stdcompat/abs.hpp 2023-08-14 01:54:29 +01:00
obligaron 578ce01432 Introduce Towner/Player/Object/Item/Monster::currentSprite/getRenderingOffset 2023-08-12 17:47:31 +02:00
Anders Jenbo 2f908277a8 Apply pre calculated lighting for quest levels 2023-04-24 17:20:17 +02:00
Anders Jenbo ec9d1b5550 Rename _oLight to applyLighting 2023-04-19 19:41:10 +02:00
obligaron 55bf5348c4 Multiplayer: Prevent trapped doors to fire twice 2023-02-27 05:03:57 +01:00
obligaron cd89372512 Introduce Object::name() 2023-02-26 04:40:31 +01:00
Anders Jenbo f9c785335f Correct default bookMessage 2022-12-08 05:41:44 +01:00
obligaron 610e80f098 Sync break crux 2022-11-14 06:58:56 +01:00
Gleb Mazovetskiy 759ca7f055 WorldTileRectangle/Size
Adds a custom sized type for the world tile rectagle.

This allows us to better express intent.
It also allows us to make certain globals smaller, e.g. `THEME_LOC`.
2022-10-16 03:53:26 +01:00
ephphatha ea3ecbd619 Use _item_indexes type where appropriate 2022-10-11 18:51:13 +02:00
Gleb Mazovetskiy 7154ec15af Object: Reorder to save 16 bytes (104->88) 2022-10-11 10:17:01 +01:00
ephphatha 8132d6a033 Take object by reference in OperateObject 2022-08-07 02:46:24 +02:00
Anders Jenbo 2d9531f692 Remove redundant check for distance when operating doors
IsPlayerAdjacentToObject() is checked before calling OperateObject().
Previously teleFlag would ignore sendmsg which was likely a bug causing
the event to fire multiple times.
2022-08-04 01:37:03 +02:00
Anders Jenbo 7c9111ddb0 Correct casing for isDoor() 2022-08-04 01:37:03 +02:00
staphen 748bb1f84d Split delta trap operation from realtime trap operation 2022-08-03 07:39:25 +02:00
Gleb Mazovetskiy 961866e1c4 CLX: A new graphics format
The format is almost identical to CL2, except it uses the frame header
to store frame width and height instead of 5 32-line offsets.

This means we always have access to frame dimensions, so we can use it
as an on-disk format for our graphics as well.

Additionally, we may be able to optimize the rendering even more
in the future now that we have guaranteed knowledge of frame dimensions.
2022-08-03 02:38:55 +02:00
Anders Jenbo b9aa2959a6 Split deleta sync from operate door 2022-08-01 12:09:26 +02:00
Anders Jenbo 5f3acebe5e Merge operate door functions 2022-08-01 12:09:26 +02:00
Anders Jenbo e83c55d444 Clean up object references 2022-07-31 06:19:20 +02:00
ephphatha 0ce76a3f13 Add Object lookup method to mimic map::at() 2022-07-28 12:47:13 +02:00
ephphatha cdcccef47a Return pointer from AddObject
This allows removing the immediate lookup for call sites which need further initialisation.
2022-07-28 12:47:13 +02:00
Andrew James 24c57bf6c6 Simplify MonsterOperateDoor (#5100) 2022-07-23 13:14:47 +02:00
ephphatha 4a8f375011 Use position for operate object network commands
Only one remaining use of Object::getId for caching the target of a command requiring the player to path to an object.
2022-07-22 17:46:53 +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 b00ae287b8 Minimize propegation of global Players index 2022-07-03 06:10:42 +02:00
Anders Jenbo 4c62905381 Deduplicate OperateLever 2022-06-27 10:17:22 +02:00
Anders Jenbo 21fd0fb686 Split delta sync from realtime sync 2022-06-27 10:17:22 +02:00
Anders Jenbo 6c6999235f Add debug command for testing custom levels 2022-05-14 09:11:42 +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
Gleb Mazovetskiy f4bce38875 Use uint16_t for sprite widths 2022-03-06 04:49:13 +01:00
ephphatha 13c54102e0 Combine Add*Door functions
There's a bit of common code, but most of the initialisation logic relies on globals or other functions defined in objects.cpp so it's not really appropriate to move these wholesale into a member of the Object class.
2021-12-30 10:26:46 +01:00
ephphatha 279fbe32b3 Tidy up checks for missile collision with objects/tiles
This was repeated in multiple places with essentially identical logic. Can expose the existing missiles.cpp function to capture the use in scrollrt.cpp
2021-12-28 16:01:37 +01:00
ephphatha 77a783098d Use ObjectAtPosition when checking if an item can be dropped
This extracts some of the common object logic from ItemSpaceOk and CanPut, these functions are almost identical except for the way players and monsters are checked...
2021-12-28 16:01:37 +01:00
ephphathaandAnders Jenbo a0019d289d Use Point based object lookups in themes.cpp
Move bookstand lookup inside coinflip if statement, minimises the scope of that pointer.

Co-authored-by: Anders Jenbo <[email protected]>
2021-12-28 16:01:37 +01:00
ephphatha 379d6e87b3 Move ObjectAtPosition to objects.cpp and make it return a pointer
All set maps initialise objects as expected so dObject has the correct ID already, no need to iterate over all active objects. Also by returning a pointer we can use this function to test if an object exists at the target position.

While on msvc int8_t is typedefed to signed char we might as well match the expected data type for the dObject array
2021-12-28 16:01:37 +01:00
Gleb Mazovetskiy 076b0c0c05 Overhaul tests
1. Adds a `libdevilution_so` target when tests are enabled.
2. Each test file is now a separate binary target linked against `libdevilutionx_so` (can now run tests in parallel).
3. Tests are now defined in a separate `test/CMakeLists.txt` file.
4. Building the tests is now controlled by the standard `BUILD_TESTING` option (defined by CTest).
5. Tests are now built by default.
6. On CI, test errors are now reported.

Also:

* `.clang-format`: Enable SortIncludes in tests
* `path_test.cpp`: Fix -Wsign-compare
2021-12-16 20:26:51 +00: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
Andrew James 8104432db4 Use object reference (and self-id lookup) for BreakBarrel 2021-11-08 00:51:16 +01:00
Andrew James 021c7a652f Add helpers for checking object type (#3357)
* Add helper to test if an object is a trap source
* Add helper to test if an object is a barrel
* Add helper to test if an object is a crucifix
* Add helpers to check if an object is a chest (and statuses)
* Add helpers to check if an object is a (basic) shrine
2021-11-06 18:32:52 +01:00
Andrew James 7dcc6d15f7 Update some quest object activation functions to use references (#3356)
- rename with a hopefully more descriptive name
2021-11-01 15:48:54 +01:00
ephphatha d2940e8f7f Update GetObjectStr to take a const Object&
Brings it in line with GetItemStr
2021-11-01 12:44:46 +01:00
ephphatha 6d545868d2 Move objectIsDisabled to a member function
While it does reference a global configuration option it's mainly concerned with the properties of the object itself, so makes sense to be a member of the object class.
2021-10-31 14:21:57 +01:00
ephphatha e98b80c992 Remove declaration of private/anonymous function
Never used outside objects.cpp so it was rightly moved into the anonymous namespace, but the header was not updated at the time.
2021-10-29 14:16:17 +02:00
Juliano Leal Goncalves ef74b6f92d 🚚 Rename 'ObjectStruct' to 'Object' 2021-09-02 05:45:44 +02:00
Juliano Leal Goncalves 20db8d1a11 🚚 Rename 'MonsterStruct' to 'Monster' 2021-09-01 22:26:37 +02:00
Anders Jenbo 069249f318 🚚 Move local function to anonymous namespace i-p 2021-07-19 05:44:20 +02:00
ephphatha 7de18d27cf Extract door object type test to ObjectStruct method
This removes the direct reference to _object_id values in path.cpp, that enum is now only used in objects.h/cpp
2021-07-17 17:35:58 +02:00
Anders Jenbo 77b72da276 ♻️Use monster by reference when possible 2021-07-14 20:22:35 -07:00
Anders Jenbo ef6275caac Clean up private function names 2021-07-12 17:59:22 -07:00