Commit Graph

12491 Commits

Author SHA1 Message Date
Kp 5c900ca7a7 Remove obsolete MENU_DETAIL_TEXT
This is unused since 44bbb66101.
2023-07-08 18:26:21 +00:00
Kp a7df75a028 Expand NET_DUMP_STRINGS inline
It is only used in one place, so expand it there.
2023-07-08 18:26:21 +00:00
Kp c81fa4073b Throw exception on texture list exhaustion 2023-07-02 22:17:42 +00:00
Kp c0a8c2f0e5 Use f-strings to generate -Werror parameters 2023-07-02 22:17:42 +00:00
Kp 9876a56988 Prefer list initialization in serial.h 2023-07-01 20:31:25 +00:00
Kp 812383de2e Use enum class for con_state 2023-07-01 20:31:25 +00:00
James Le Cuirot ad9452d51b
Fix building without OpenGL
One issue was just a missing header. The other issue was unconditional
inclusion of an OpenGL header.
2023-06-27 08:43:55 +01:00
James Le Cuirot e9daf03769
Skip SDL OpenGL build check when the SDL2 wrapper is detected
The wrapper does not define SDL_VIDEO_OPENGL in SDL_config.h. This
appears to be deliberate, although it's not entirely clear why.

    /* Don't define most of the SDL backends, under the assumption checking for these against the headers won't work anyhow.
       The exception is the X11 backend; you need its define to know if you can use its syswm interface. */

We could check SDL2's SDL_config.h instead, but that seems awkward to
pull off.

Closes: https://github.com/dxx-rebirth/dxx-rebirth/issues/689
2023-06-25 15:32:00 +01:00
Kp 111f6f2f0d Remove obsolete d2x-rebirth/iff/archive/ programs
These were never converted to C++ and cannot be built directly from
SConstruct.  Two of them were broken by a global search&replace in
398596c468 (May 2016), and never reported.
Aside from other global transformations, they have not been touched
since unification moved them to this path in
7cda97cc74 (February 2013).  Based on
their content, these are all test programs specific to the game's
graphics files.

iff15bpp.c depends on an undefined type BITMAP15, which seemingly was never
defined in the project's git history.  The only reference to it is in the
addition of iff15bpp.c in 9bd1ba7c47
(January 2001).

Likewise, iff8bpp.c depends on an undefined type BITMAP8, which was never
defined and only occurs in 9bd1ba7c47.

ifftest.c depends on an external function `rle_span`, which does not declare a
return type, and therefore triggers a warning for declaring data with no type.

iffmike.c depends on a modifier `huge` which is not recognized in gcc.
By its usage, it was likely used on DOS systems with limited memory, to
enable a special memory mode.

ifftestv.c declares a function without a return type, which triggers a warning
in C99.
2023-06-17 23:13:42 +00:00
Kp 8870f071aa Use std::array for Current_pigfile 2023-06-17 23:13:42 +00:00
Kp 93dd82f6c3 Pass std::span to piggy_init_pigfile 2023-06-17 23:13:42 +00:00
Kp 688f118b2b Use Python f-strings for generate-kconfig-udlr.py formatting 2023-06-17 23:13:42 +00:00
Kp 3ddc737558 Prevent narrowing in movie data copying
Use list initialization to disallow narrowing conversions.
2023-06-11 21:35:16 +00:00
Kp 94aab4537f Use ranges::subrange instead of custom make_range 2023-06-11 21:35:16 +00:00
Kp 365d001cc6 Pass bitmap context in check_trans_wall 2023-06-11 21:35:16 +00:00
Kp ae9fbbadef Use std::clamp instead of min+max 2023-06-11 21:35:16 +00:00
Kp fc78ff0612 Pass buddy to maybe_buddy_fire_smart 2023-06-04 19:52:58 +00:00
Kp c515c4394a Pass buddy to maybe_buddy_fire_mega 2023-06-04 19:52:58 +00:00
Kp 3b297cf04c Pass buddy object to exists_fuelcen_in_mine 2023-06-04 19:52:58 +00:00
Kp f92e5e900e Recover from invalid control_center_triggers.num_links
Use of `partial_range` will trap invalid counts, but will throw an
exception and terminate the program.  Change the logic to log a
diagnostic and clamp the count to the maximum legal value, so that users
can play the level.  The level may still be impossible to complete, if
the triggers within the valid range do not open an exit door.  However,
level authors always have the ability to get that wrong, so the logic
with recovery is better than the logic without it.

Also, add a new diagnostic for invalid side in a control center trigger,
and a new diagnostic for invalid segment in a control center trigger.
For the latter, add a special case to reduce the severity when playing
`Descent 2: Vertigo`, since there is a known bad trigger in a Vertigo
level, and users cannot fix it.
2023-06-03 23:13:26 +00:00
Kp 606790f1c5 Inline read-only Do_dynamic_light 2023-05-27 13:19:31 +00:00
Kp 03cedbb4cc Remove default-zero for `physfsrwops_seek` variable pos
This default-zero allowed the bug introduced in
68b47307b4 (and fixed in
4c371734b5) not to generate a compiler
warning for `-Wuninitialized`, since it was initialized to `0`.
However, `0` is not a correct starting value for this variable.  Remove
the initialization and require every code path to assign a meaningful
value.

Switch to use `std::in_range` to validate that no truncation occurs, and
trust that the compiler will optimize this out when the type passed to
`std::in_range` can represent all values that the argument can
represent.
2023-05-27 13:19:31 +00:00
Kp 695e8b9ba1 Use memcpy for font filename
Prefer memcpy with a predetermined length, rather than strncpy, which
could leave the buffer without a terminator.  No current callers could
cause the lack of a terminator, but gcc-13 warns about it, so rearrange
the code to fix the warning.
2023-05-20 16:37:26 +00:00
Kp 3330b17cdb Use enum class for gamefont_conf::font_index 2023-05-20 16:37:26 +00:00
Kp c6e14fa74f Use std::array for font filenames 2023-05-20 16:37:26 +00:00
Kp bd050d73b2 Shrink a_gamefont_conf::name
Callers always load a DOS 8.3 filename into name, so shrink it from
64 characters to 16 characters.
2023-05-20 16:37:26 +00:00
Kp 03e12fedd4 Test for overzealous -Wdangling-reference
gcc-13 was released with -Wextra implying -Wdangling-reference, but
-Wdangling-reference as released warns on cases that are safe.  Add a
configure test to detect when the compiler warns incorrectly, and
disable the warning in those cases.  When a future compiler emits fewer
false positives, the suppression of the warning should stop.

Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/718>
2023-05-20 16:37:26 +00:00
Kp 686fa1ba21 Simplify segment_object_range_t construction 2023-05-20 16:37:26 +00:00
Kp 5ca2f59619 Validate last_hitobj on game load
Testing for `object_none` is insufficient.  Games saved before the fix
for 14cdf1b352 may have a `last_hitobj` of
`0x1ff`, which triggers an exception when constructing `icobjidx_t`.
Treat any invalid object index as `object_none`.

Reported-by: Quix0r <https://github.com/dxx-rebirth/dxx-rebirth/issues/716>
2023-05-15 23:52:18 +00:00
Kp b4e3d67725 Recompute guidebot index on game load
The index of the guidebot is set by loading the level data, and this is
usually sufficient.  However, if the user kills the guidebot, then uses
cheats to create a new one, the new guidebot will often have a different
index than the original guidebot.  If such a game is saved and then
reloaded, then after the reload, the computed guidebot index will be
reverted to the index of the original dead guidebot.  This causes
various problems, including potentially a crash.  Recompute the guidebot
index after loading the objects from the save file, so that it matches
the live guidebot.

Reported-by: GitInMotion <https://github.com/dxx-rebirth/dxx-rebirth/issues/713>
2023-05-14 18:41:36 +00:00
Kp c21c317441 Reset Buddy_objnum when buddy is deleted
Various code assumes that Buddy_objnum maintains the invariants:
- If the guidebot exists, Buddy_objnum must refer to it.
- If no guidebot exists, Buddy_objnum must be object_none.

This was not enforced, so if the guidebot is killed, Buddy_objnum can
continue to refer to its last index.  That can cause spurious errors
later.  For example, when the player enters an energy center, if the
guidebot is dead and the guidebot's last goal was "Find energy center",
then the console reports:

```
BUG: buddy is object 28, but that object is type 255.
```

Fix that by clearing the guidebot index when the guidebot is killed.
2023-05-14 18:41:36 +00:00
Kp 397d582031 Use NSDMI for zero-initialized Mission members
Prefer non-static data member initializers over leaving the member
undefined in the constructor and relying on the caller to zero the
member afterward.
2023-05-14 18:41:36 +00:00
Kp da39846514 Remove unnecessary pointer in savegame_newmenu_items
The pointer is only used by the constructor, so there is no need to
store it in the object.

Rework the allocation of the trailing storage to avoid the use of
placement new on a uint8_t[].
2023-05-14 18:41:36 +00:00
Kp 26d8c2881e Move compress_objects into `#if DXX_USE_EDITOR`
This is only called in the editor build, so exclude it from being built
in the non-editor build.
2023-05-14 18:41:36 +00:00
Kp c0c4ee7049 Inline obj_link into compress_objects
This is only called in one place, so manually inline it to keep the
logic together.
2023-05-14 18:41:36 +00:00
Kp 796c387ee4 Use enum class for Mission::anarchy_only_flag 2023-05-14 18:41:36 +00:00
Kp 3c9c855779 Use enum class for descent_hog_size 2023-05-14 18:41:36 +00:00
Kp 8eec1dc810 Eliminate unnecessary string copy in PHYSFSX_addRelToSearchPath
Pass a mutable buffer from the caller, and allow
PHYSFSX_addRelToSearchPath to adjust the capitalization in that buffer,
rather than creating a copy in a stack local.  This can slightly affect
status messages that use the name, but otherwise should have no effect
on the game.
2023-05-13 15:02:55 +00:00
Kp 6a794c6b63 Use memcpy to update string in locateOneElement 2023-05-13 15:02:55 +00:00
Kp 64569e102b Move search_result_t into locateOneElement local scope 2023-05-13 15:02:55 +00:00
Kp e7d73e8493 Use RAII to manage SDL_LockAudio state 2023-05-13 15:02:55 +00:00
Kp f2e65abbdb Move d2 movie code into namespace d2x 2023-05-06 19:26:19 +00:00
Kp 1053cb532b Use std::span for MovieFileRead 2023-05-06 19:26:19 +00:00
Kp 53a9ce8823 Use enum class for MVE_sndInit argument 2023-05-06 19:26:19 +00:00
Kp 4bdc31a729 Simplify movie stream ownership
Store an owned pointer in MVEFILE instead of storing an unowned pointer
there and requiring the caller to keep the owned pointer alive for the
lifetime of the MVEFILE.
2023-05-06 19:26:19 +00:00
Kp bb87582a8a Return MVESTREAM from MVE_rmPrepMovie 2023-05-06 19:26:19 +00:00
Kp f39c5e3318 Simplify `RotateRobot` movie reset
On entry, `pMovie` is not `nullptr`, so `MVE_rmPrepMovie` will call
`mve_reset` and return success.  Inline that path into `RotateRobot`.
2023-05-06 19:26:19 +00:00
Kp 4d0a67ac14 Remove unused MVESTREAM context 2023-05-06 19:26:19 +00:00
Kp 8750b9ae20 Move mvelib timer_created into MVESTREAM 2023-05-06 19:26:19 +00:00
Kp ab56701774 Remove unused arguments to handle_mve_segment_videodata 2023-05-06 19:26:19 +00:00