Commit graph

2083 commits

Author SHA1 Message Date
Kp 78d4a36bb4 Explicitly require support for C++11 constructor inheritance
Parts of the code already used the C++11 syntax, so compilers without it
were already unsupported.  Expand the remaining uses to the standard
syntax.
2022-01-09 15:25:42 +00:00
Kp 0f53ce0f06 Factor out get_xrange_direction
clang chokes on use of a `constexpr bool` that is initialized separately
from its definition.  gcc allows this.  Move the value computation into
a constexpr helper function, so that the variable can be defined and
initialized in the same statement.
2022-01-09 15:25:42 +00:00
Kp 6cdc181218 Use enum class for segment_relative_vertnum 2022-01-09 15:25:42 +00:00
Kp 932419ff17 Combine Two_sides_to_edge, Edge_between_sides
These track the same data, but were static and defined separately.
Delete Edge_between_sides and redirect uses to Two_sides_to_edge.
2022-01-09 15:25:42 +00:00
Kp b8a8a61ff8 Simplify multiplayer powerup creation
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-01-09 15:25:42 +00:00
Kp 94cfeede5c Validate control center trigger sides on load 2022-01-09 15:25:42 +00:00
Kp 078a9affa0 Make MAX_SIDES_PER_SEGMENT an iterable range
Iterating over it returns each side number in turn.  This allows
converting many loops of the form:

```
	for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```

to the compact form:

```
	for (const auto i : MAX_SIDES_PER_SEGMENT)
```

The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
2022-01-09 15:25:42 +00:00
Kp 3004dd16e5 Convert some bare integers to sidenum_t 2022-01-09 15:25:42 +00:00
Kp d6b4106d36 Tighten index handling for Ai_transition_table
Avoid undefined accesses when a robot has an invalid awareness type.
2022-01-08 17:48:09 +00:00
Kp 648bbac0b1 Convert ai_local::achieved_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp d1ac265c2c Convert ai_local::goal_state to ai_static_state 2022-01-08 17:48:09 +00:00
Kp 37f3c10dd4 Convert ai_static::CURRENT_STATE to ai_static_state 2022-01-08 17:48:09 +00:00
Kp c3937f391f Convert ai_static::GOAL_STATE to enum 2022-01-08 17:48:09 +00:00
Kp 9fdf6005df Convert ai_static::GOALSIDE to sidenum_t 2022-01-08 17:48:09 +00:00
Kp c6d98df9fb Move CURRENT_GUN out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 5128b84122 Move CURRENT_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 39e9673f54 Move GOAL_STATE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp c10855939b Move PATH_DIR out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 1f00d716de Move SUBMODE/SUB_FLAGS out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp db90f0df62 Move GOALSIDE out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp ae44e0226e Move CLOAKED out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp db7b528177 Move SKIP_AI_COUNT out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 197ed13d42 Move REMOTE_OWNER out of ai_static::flags 2022-01-08 17:48:09 +00:00
Kp 7015e3e93c Move REMOTE_SLOT_NUM out of ai_static::flags
Some flags merit a type other than int8_t.  Begin moving flags out to
distinct variables with their own type.

Add static_assert checks that the ABI relevant structures do not change.
2022-01-08 17:48:09 +00:00
Kp b4341e69a5 Remove unnecessary definitions of get_static_size
These exist only to be declared, and never called.
2022-01-07 04:26:22 +00:00
Kp 941190ff32 Explicitly default d_fname copy constructor
clang warns that an implicit copy constructor is deprecated in the
presence of an explicitly defaulted copy-assignment operator.

Add an explicitly defaulted default constructor too, since the
explicitly defaulted copy constructor suppresses generation of an
implicit default constructor, and the default constructor is needed.
2022-01-07 04:26:22 +00:00
Kp 223c59c5d4 Inline out object_number_array
Its main purpose is to pre-initialize the underlying std::array.  This
can be done without a separate type.
2022-01-07 04:26:22 +00:00
Kp f84783b95d Use enum class for dlindexnum_t 2022-01-07 04:26:22 +00:00
Kp 2fbddf7a5a Use enum class for tmapinfo_flags 2021-11-01 03:37:20 +00:00
Kp 795b0e9111 Use enum class for station_number 2021-11-01 03:37:20 +00:00
Kp 3e02f99bcd Use enum class for materialization_center_number 2021-11-01 03:37:20 +00:00
Kp eea806bcc9 Pass underlying index_type through zip()
If std::common_type<range::index_type>... finds a common index_type
among all the zipped ranges, pass that common type through as
zip<...>::index_type.  Otherwise, set zip<...>::index_type to void.

This allows enumerate(zip(...))) to report a better index_type.
2021-11-01 03:37:20 +00:00
Kp 29b619db99 Pass random generator to pick_random_point_in_seg 2021-11-01 03:37:20 +00:00
Kp 3da988708e Change Side_opposite value_type to sidenum_t 2021-11-01 03:37:20 +00:00
Kp 6467929025 Consolidate Side_to_verts and Side_to_verts_int
They have been the same variable since
a8c3a7f10b ("Alias Side_to_verts to
Side_to_verts_int").
2021-11-01 03:37:20 +00:00
Kp 9fc7a14777 Fix LTO build of Descent 2
enum game_mode_flags must be visible in common code, which does not
define DXX_BUILD_DESCENT_II.  To avoid One Definition Rule errors,
game_mode_flags must have the same definition in all files.
Fortunately, the DXX_BUILD_DESCENT_II definition is a superset of the
common definition, so the preprocessor guards can be replaced with
advisory comments.

Fixes: 2b718da343 ("Use enum class for Game_mode, Newdemo_game_mode")
2021-11-01 03:37:20 +00:00
Kp 3862edfb6c Use enum class for segment_special 2021-11-01 03:37:19 +00:00
Kp 12a0f8e8e0 Use enum class for wall_state 2021-11-01 03:37:19 +00:00
Kp 76e2f2c6d9 Use enum class for wall_flags 2021-11-01 03:37:19 +00:00
Kp f64ed06a9d Use enum class for wall flag constants 2021-11-01 03:37:19 +00:00
Kp a6f2db2502 Use enum class for player ranking 2021-11-01 03:37:19 +00:00
Kp 8ddfbd17e0 Use enum class for show_kill_list_mode 2021-11-01 03:37:19 +00:00
Kp d22632ac48 Use enum class for msgsend_state 2021-11-01 03:37:19 +00:00
Kp 7cb34fda0c Use enum class for network_game_type 2021-11-01 03:37:19 +00:00
Kp eb7cedc35d Expand macro Current_mission_longname 2021-11-01 03:37:19 +00:00
Kp e69b7bd730 Expand macro Briefing_text_filename 2021-11-01 03:37:19 +00:00
Kp bcc8118dd5 Expand macro Ending_text_filename 2021-11-01 03:37:19 +00:00
Kp 3d878ce04d Expand macro Last_level 2021-11-01 03:37:19 +00:00
Kp e36c4a17ab Expand macro Last_secret_level 2021-11-01 03:37:19 +00:00
Kp 692c09bb7e Expand macro N_secret_levels 2021-11-01 03:37:19 +00:00
Kp 013ef0ded7 Expand macro Secret_level_table 2021-11-01 03:37:19 +00:00
Kp d10406c107 Expand macro Level_names 2021-11-01 03:37:19 +00:00
Kp 72cdb9b0cc Expand macro Secret_level_names 2021-11-01 03:37:19 +00:00
Kp c64d97307c Pass level counts to allocate_levels
Avoid reading them from a global.
2021-11-01 03:37:19 +00:00
Kp 0c34a48418 Move Last_level_path_created to LevelUniqueObjectState.Level_path_created
Change it from the level number on which the path was created to a
true/false flag.  The previous logic only tested whether the number was
equal to the current level number.

This also fixes a bug where the action was not available on the first
secret level, since that level is `-1`, and the value was set to `-1` to
indicate that it should be enabled.
2021-11-01 03:37:19 +00:00
Kp 0fcaa76fd1 Move Next_level_num to local scope
It does not need to be a global.  For each function that uses it, it is
assigned earlier in that same function.
2021-11-01 03:37:19 +00:00
Kp 1a44112907 Remove objnum_local_to_remote wrapper
Always use the form that returns both fields.
2021-11-01 03:37:19 +00:00
Kp 1a08ecc8c6 Remove window subfunction types
These were type safety mechanisms, which are obsolete now that all
window handlers are implemented through virtual function dispatch.
2021-10-13 02:37:51 +00:00
Kp 192988b004 Use enum class for weapon_info::persistent 2021-09-19 10:53:48 +00:00
Kp 21c530a3e2 Use enumerated_array for difficulty-level-specific arrays 2021-09-19 10:53:48 +00:00
Kp 7fc8c736b3 Pass Powerup_info to multi_prep_level_objects, filter_objects_from_level 2021-09-19 10:53:48 +00:00
Kp 4e75f8a933 Pass canvas to scores_view_menu 2021-09-19 10:53:48 +00:00
Kp 855697bf5d Make font scaling constructors explicit 2021-09-19 10:53:48 +00:00
Kp e618851449 Pass canvas to savegame_chooser_newmenu 2021-09-19 10:53:48 +00:00
Kp 07c52f14f9 Save parent canvas in listbox_layout 2021-09-12 16:20:52 +00:00
Kp 8d67bcddb0 Record parent canvas in newmenu
Use it to avoid resetting to the screen canvas when preparing the
layout.
2021-09-12 16:20:52 +00:00
Kp bb29e6fca8 Propagate canvas through more layers 2021-09-12 16:20:52 +00:00
Kp e7aa9855e0 Compute menu border widths from screen canvas instead of screen
In practice, this should be the same result.  However, this allows the
flexibility to use a canvas other than the screen.
2021-09-12 16:20:52 +00:00
Kp 21241471c6 Return string width/height from gr_get_string_size
Use structured bindings to capture the values on return, so that they
can be declared as `const` if they are immutable after initial
computation.
2021-09-12 16:20:52 +00:00
Kp 2fef4cddec Pass canvas to do_cockpit_window_view 2021-09-12 16:20:52 +00:00
Kp bd6612a86b Pass canvas to render_gauges 2021-09-12 16:20:52 +00:00
Kp 4b60205b2f Propagate up show_boxed_message RenderFlag
It is always constant.  Explicitly propagate its effects into callers,
then remove the argument.
2021-09-12 16:20:52 +00:00
Kp df6777c632 Expand game_init_render_buffers inline
It is a single function, to add 2 arguments.  Using a wrapper obfuscates
the logic.
2021-09-12 16:20:52 +00:00
Kp 98f2578293 Pass Game_mode as a parameter to gauges functions
Avoid reloading it from the global.
2021-09-12 16:20:52 +00:00
Kp 2b718da343 Use enum class for Game_mode, Newdemo_game_mode 2021-09-12 16:20:52 +00:00
Kp 7f51fa3ac5 Use enum class for VR StereoFormat 2021-09-12 16:20:52 +00:00
Kp 233f31893b Only prepare pause time if it will be shown
Demo playback does not show time data, so there is no need to format it
when it will be hidden.
2021-09-12 16:20:52 +00:00
Kp 211f4ea274 Use window_rendered_data constructor to initialize time 2021-09-12 16:20:52 +00:00
Kp 2afe2f428f Remove write-only member window_rendered_data::viewer 2021-09-12 16:20:52 +00:00
Kp 8eabce8f27 Disallow direct construction of grs_canvas
Require use of grs_main_canvas or grs_subcanvas instead.
2021-09-04 12:17:14 +00:00
Kp 1c90863d63 Move grs_main_bitmap earlier in the header 2021-09-04 12:17:14 +00:00
Kp 44a50b6206 Make enumerate() index by array's index_type 2021-09-04 12:17:14 +00:00
Kp 983ad86e4b Use enum class for trigger number 2021-09-04 12:17:14 +00:00
Kp c58d26a791 Use trgnum_t more consistently 2021-09-04 12:17:14 +00:00
Kp 6dcd89d494 Try harder to pick distant segments for thief/powerup respawn 2021-09-04 12:17:14 +00:00
Kp 40c22d0663 Move render_frame helper inline
Most call sites had the correct lifetime already, and those that did not
can easily gain it with an extra block scope.
2021-08-26 03:13:45 +00:00
Kp d748e7bbfc Add support for xrange steps other than +1
Prior to this, an xrange always started at the begin term and
incremented by 1 per step until it reached the end term.  There was no
support for a step size other than 1.  Add support for custom step size.
It is the caller's responsibility to pick a step size that will
eventually lead to (iter != end) evaluating to false.
2021-08-26 03:13:45 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp b2968c55da Improve error reporting for read_sndfile
Move error reporting down into read_sndfile, so that individual failure
paths can have specific error messages.
2021-07-25 23:00:56 +00:00
Kp a7cbf60922 Return error code from PHYSFSRWOPS_openRead*
This improves error reporting for movies.
2021-07-25 23:00:56 +00:00
Kp e0008cceb3 Use enum class for sound angle parameter 2021-06-28 03:37:51 +00:00
Kp 13e29c64f3 In debug builds, initialize newmenu_item type,text to poison values
This improves the chance that an unset value will abort rather than
displaying strange results.  Release builds are unchanged.
2021-06-28 03:37:51 +00:00
Kp 9c08b233a5 Move collision functions into namespaces 2021-06-28 03:37:51 +00:00
Kp e1aac6949a Replace __attribute_warn_unused_result with C++17 [[nodiscard]]
This eliminates a configure test, and may help readers understand the
annotation more readily.
2021-06-28 03:37:51 +00:00
Kp 704f8f662d Allow rvalue reference as input to enumerated_iterator 2021-06-28 03:37:50 +00:00
Kp 028f4f8a56 Use structured bindings to access enumerated ranges 2021-06-28 03:37:50 +00:00
Kp 7b12aac1bb Transpose returned values for enumerate() of non-tuple
Match the order used for tuple.
2021-06-28 03:37:50 +00:00
Kp 212400d140 Convert nm_messagebox_str to use messagebox_newmenu 2021-06-28 03:37:50 +00:00
Kp 9044a19d78 Fold passive_messagebox_item into passive_messagebox 2021-06-28 03:37:50 +00:00
Kp 4c34875c84 Remove unused subfunction_handler
Previous commits eliminated all uses of it.  Remove the unused stubs.
2021-06-28 03:37:50 +00:00