Commit graph

3788 commits

Author SHA1 Message Date
Kp 76acfdd38f Convert main menu to inherit from newmenu 2020-12-19 16:13:26 +00:00
Kp 8e65573c56 Eliminate move construction of newmenu_layout
Construct one in place, update it, and then use it to initialize the
rest of the newmenu.
2020-12-19 16:13:26 +00:00
Kp c68dddd372 Move various definitions into namespaces 2020-12-19 16:13:26 +00:00
Kp b1b2300c7d Use enum class for wall_key 2020-12-19 16:13:26 +00:00
Kp 47c33cbd55 Use enum class for WALL_IS_DOORWAY_FLAG
This reduces the size of the debug information substantially.
2020-12-19 16:13:26 +00:00
Kp efcd9b91ce Use enum class for WALL_IS_DOORWAY_sresult_t
This generates the same code, but shrinks the debug information.
2020-12-19 16:13:26 +00:00
Kp 56122687d1 Delegate newmenu subfunction handling into virtual function 2020-12-19 16:13:26 +00:00
Kp d4cf9943c5 Make newmenu subfunction const 2020-12-19 16:13:26 +00:00
Kp 1032462988 Make newmenu max_displayable const 2020-12-19 16:13:26 +00:00
Kp de5c300724 Make newmenu_layout::all_text const 2020-12-19 16:13:26 +00:00
Kp 530f396b2e Make newmenu::tiny_mode_flag, tabs_flag, max_on_menu const 2020-12-19 16:13:26 +00:00
Kp 200952c3d9 Add type-specific tag wrappers for newmenu calls
Make the compiler check that title, subtitle, and filename are passed in
the right places.
2020-12-19 16:13:26 +00:00
Kp 53566b7673 Move struct newmenu to newmenu.h 2020-12-19 16:13:26 +00:00
Kp 5c7fc7d143 Remove unused UI_DIALOG d_callback
Every user now uses inheritance and a virtual function override.  Make
callback_handler pure virtual, delete its body, and then delete the
member variables that existed only for use in that body.  Remove the
constructor parameters that initialized those variables, and update all
derived classes accordingly.
2020-12-19 16:13:26 +00:00
Kp 2709676f8d Rename ui_create_dialog to window_create
The requirement to call send_creation_events from outside the
constructor makes the presence of a helper function convenient.  Rename
ui_create_dialog to window_create, and move it to window.h.
2020-12-19 16:13:26 +00:00
Kp bace343437 Fix gcc-11 warning -Wmaybe-uninitialized on input array
For gcc bug #10138 [1], gcc-11 gained a new way to show a
-Wmaybe-uninitialized warning.  When an uninitialized array is passed by
`const T *` to a function, gcc-11 assumes the array is an input to the
function, and warns accordingly.  This is often useful, but is incorrect
for the Rebirth partial_range code.  In this code, the pointer is only
passed so that the eventual exception can print the memory address of
the affected array.  The called function does not dereference the
pointer, and so cannot be influenced by any uninitialized values in the
underlying array.

Change the report function to take the array address in a `uintptr_t`,
and cast it back for printing.  This silences the gcc-11 warning, while
preserving the previous semantics in the code.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10138
2020-12-14 00:04:41 +00:00
Kp 017c4ce933 Restore buffering on PCX loads
Commit 3114874713 delegated PCX loading to
SDL_image, and as an incidental change, switched to using an unbuffered
PHYSFS file.  On Linux, this has no perceptible difference in
performance.  On Windows, the unbuffered accesses cause enough of a
performance problem for users to notice and report an issue.  Add a new
helper to create an SDL_RWops around a buffered file, and use that for
PCX loading.

Fixes: 3114874713 ("Delegate PCX loading to SDL_image")
Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/549>
Reported-by: aybe <https://github.com/dxx-rebirth/dxx-rebirth/issues/555>
Analyzed-by: arbruijn <https://github.com/dxx-rebirth/dxx-rebirth/issues/555#issuecomment-735442076>
2020-11-30 05:12:00 +00:00
Kp 9694df2063 Fix leak of PHYSFS handle if SDL_AllocRW fails
Previously, if SDL_AllocRW failed, then the handle would not be saved
into an SDL_RWops (since that object was not created), but it would also
not be closed immediately.
2020-11-30 05:12:00 +00:00
Kp 0f022f4b10 Fix clang build
clang warns if all of:
- type T is deleted by a pointer T*
- T has a non-virtual destructor
- T has a virtual function
- T is not final

Fix the build by making the relevant types T final, since nothing
inherited from them.
2020-11-30 05:12:00 +00:00
Edward E d7999c9fad Fix truncation of callback pointer on Windows
Previously fixed ec709efaa3,
but reverted 8a4ac70541
2020-10-29 03:40:19 +00:00
Kp a028ea14ae Restore format(printf) attribute for powerup_basic
Kreeblah reports that clang now warns for powerup.cpp due to a missing
__attribute_format_printf.  This was incorrectly dropped in
ffb653c0b8.  gcc did not warn, but clang
now warns.  Add back the attribute.

Fixes: ffb653c0b8 ("Pass control_info & to various functions")
Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/pull/547>
2020-10-27 04:27:55 +00:00
Kp ddcf8c1798 Remove support for show_order_form
The original way to order the full version is defunct.  Remove the code
that showed that page.
2020-10-22 02:26:17 +00:00
Kp 52e4d6f103 Remove printf checking on vnm_messagebox_aN
It is always invoked with format arguments.
2020-10-22 02:26:17 +00:00
Kp ae657007fe Remove send_creation_events parameter
It is always nullptr.
2020-10-22 02:26:16 +00:00
Kp 2869566866 Remove unused ui_create_dialog parameter createdata
It is always nullptr.  Remove the parameter and pass nullptr where the
parameter was used.
2020-10-22 02:26:16 +00:00
Kp e7cd8bedec Remove obsolete embed_window_pointer_t 2020-10-22 02:26:16 +00:00
Kp 8ec63edcd2 Remove obsolete window_create/callback_window
All users have been converted to inherit and use virtual functions
instead of a callback function.
2020-10-22 02:26:16 +00:00
Kp d2c5b4d64a Make listbox inherit from window 2020-10-22 02:26:16 +00:00
Kp 09531047b9 Use uint8_t for allow_abort_flag
It is only ever 0 or 1.
2020-10-22 02:26:16 +00:00
Kp 295619e633 SDL2: explicitly ignore unwanted key repeats 2020-10-12 03:28:26 +00:00
Kp 9a29ea0e1c Fold check_partial_range into its sole caller 2020-10-12 03:28:26 +00:00
Kp ffb653c0b8 Pass control_info & to various functions
Switch from a direct global reference to passing control_info& as a
parameter.
2020-10-12 03:28:26 +00:00
Kp 4d3eeb903e Make MENU's window to inherit from window
Due to ordering constraints, this is not merged into MENU, but is
instead kept as a distinct sub-type that is pointed at by MENU.  MENU
sets the window's position based on parsing of the menu definition file,
but the parser expects to store window position data into MENU before
creating the window.  If menubar_window were merged into MENU, the
parser would need a temporary, and all callers that create the window
would need to consult that temporary.
2020-10-12 03:28:26 +00:00
Kp 07eb412244 Make menubar.cpp Menu[] an array of MENU*, not MENU 2020-10-12 03:28:26 +00:00
Kp a8f6ef9faf Set embedded window pointer to nullptr on construction 2020-10-12 03:28:26 +00:00
Kp 6ffa495bf4 Split out special handling for creating menubar
All callers request either the menubar or something else, but never
conditionally request one or the other.  Split the special handling that
picks a different handler based on which element the caller requested.
2020-10-12 03:28:26 +00:00
Kp 7e73ee2c78 Pass newmenu& to newmenu_create_structure 2020-10-12 03:28:26 +00:00
Kp 2ccfcb64d8 Use named enum for newmenu TinyMode 2020-10-12 03:28:26 +00:00
Kp 96f5428378 Use named enum for newmenu TabsFlag 2020-10-12 03:28:26 +00:00
Kp f8185494ad Pass UI_DIALOG& to ui_add_gadget_icon 2020-10-12 03:28:26 +00:00
Kp 4f572bbe23 Pass UI_DIALOG& to ui_add_gadget_userbox 2020-10-12 03:28:26 +00:00
Kp 95598a34e3 Pass UI_DIALOG& to ui_add_gadget_inputbox 2020-10-12 03:28:26 +00:00
Kp 466f431c91 Pass UI_DIALOG& to ui_add_gadget_checkbox 2020-10-12 03:28:26 +00:00
Kp 3b7a34b066 Pass UI_DIALOG& to ui_draw_scrollbar 2020-10-12 03:28:26 +00:00
Kp 028f0c4cda Remove unused function ui_draw_frame 2020-10-12 03:28:26 +00:00
Kp c5afd0eb55 Pass UI_DIALOG& to ui_draw_icon 2020-10-12 03:28:26 +00:00
Kp 9e9429fe58 Pass UI_DIALOG& to ui_draw_userbox 2020-10-12 03:28:26 +00:00
Kp b45e696574 Pass UI_DIALOG& to ui_draw_checkbox 2020-10-12 03:28:26 +00:00
Kp 380d30f943 Pass UI_DIALOG& to ui_draw_radio 2020-10-12 03:28:26 +00:00
Kp 506f24ed04 Pass UI_GADGET_RADIO& to ui_radio_set_value 2020-10-12 03:28:26 +00:00
Kp f531c7d43e Pass UI_DIALOG& to ui_add_gadget_radio 2020-10-12 03:28:26 +00:00
Kp ff039c0c90 Pass UI_DIALOG& to ui_add_gadget_scrollbar 2020-10-12 03:28:26 +00:00
Kp 1d7f2e2ab5 Replace ui_gadget_do with virtual function dispatch 2020-10-12 03:28:26 +00:00
Kp d78d16b82f Pass UI_DIALOG& to ui_draw_inputbox 2020-10-12 03:28:26 +00:00
Kp a399fa7b58 Rename ui_icon_do to UI_GADGET_ICON::event_handler 2020-10-12 03:28:26 +00:00
Kp ca0894c3ab Rename ui_userbox_do to UI_GADGET_USERBOX::event_handler 2020-10-12 03:28:26 +00:00
Kp 6c89583ca0 Rename ui_inputbox_do to UI_GADGET_INPUTBOX::event_handler 2020-10-12 03:28:26 +00:00
Kp be157822d8 Rename ui_checkbox_do to UI_GADGET_CHECKBOX::event_handler 2020-10-12 03:28:26 +00:00
Kp 9280187833 Rename ui_radio_do to UI_GADGET_RADIO::event_handler 2020-10-12 03:28:26 +00:00
Kp 43c30bd6b3 Rename ui_scrollbar_do to UI_GADGET_SCROLLBAR::event_handler 2020-10-12 03:28:26 +00:00
Kp 8a4879a7e7 Rename ui_listbox_do to UI_GADGET_LISTBOX::event_handler 2020-10-12 03:28:26 +00:00
Kp 422ee41626 Rename ui_button_do to UI_GADGET_BUTTON::event_handler 2020-10-12 03:28:26 +00:00
Kp 26cb111bc0 Pass UI_DIALOG& to ui_mouse_on_gadget 2020-10-12 03:28:26 +00:00
Kp a21d89ea6c Pass UI_DIALOG& to ui_draw_button 2020-10-12 03:28:26 +00:00
Kp a563b5edf7 Pass UI_DIALOG& to ui_add_gadget_button 2020-10-12 03:28:26 +00:00
Kp dd2a60de69 Pass UI_DIALOG& to ui_dialog_set_current_canvas 2020-10-12 03:28:26 +00:00
Kp 6dce3f90c2 Pass UI_DIALOG& to ui_close_dialog 2020-10-12 03:28:26 +00:00
Kp 564f699002 Pass UI_DIALOG& to ui_gadget_get_next, ui_gadget_get_prev 2020-10-12 03:28:26 +00:00
Kp b6a7f63e5d Pass UI_DIALOG& to ui_gadget_calc_keys 2020-10-12 03:28:26 +00:00
Kp d7bff3daf3 Pass UI_DIALOG& to ui_dialog_do_gadgets 2020-10-12 03:28:25 +00:00
Kp f79e0343d9 Pass UI_DIALOG& to ui_gadget_send_event 2020-10-12 03:28:25 +00:00
Kp 6ff47e2a18 Pass UI_DIALOG& to ui_add_gadget_listbox 2020-10-12 03:28:25 +00:00
Kp 33beedc9fd Pass UI_DIALOG& to ui_draw_listbox 2020-10-12 03:28:25 +00:00
Kp b30d60a521 Pass UI_DIALOG& to ui_gadget_add 2020-10-12 03:28:25 +00:00
Kp b19e0698a1 Simplify out ui_dialog_get_window
UI_DIALOG now extends window, so the conversion is implicit.
2020-10-12 03:28:25 +00:00
Kp 8547c918c2 Make ui_file_browser inherit from UI_DIALOG 2020-10-12 03:28:25 +00:00
Kp 563ac19708 Make menu.cpp menu inherit from UI_DIALOG 2020-10-12 03:28:25 +00:00
Kp c1ce3a2938 Pass explicit nullptr for ui_create_dialog createdata 2020-10-12 03:28:25 +00:00
Kp 1864f2dfdf Remove unnecessary UI menu member button 2020-10-12 03:28:25 +00:00
Kp 46dc19f539 Make messagebox inherit from UI_DIALOG 2020-10-12 03:28:25 +00:00
Kp 7fb4f7b396 Use std::array for editor mine filename 2020-10-12 03:28:25 +00:00
Kp a6abf76d0a Use enum class for index into ObjBitmaps 2020-10-07 03:59:14 +00:00
Kp 24497fa085 Use enum class for bmread mode selector 2020-10-07 03:59:14 +00:00
Kp c482d01be5 Move some fvi types to namespaces 2020-10-01 03:25:27 +00:00
Kp b136994551 Move valptridx<segment> to dcx
segment is now dcx, so move the valptridx wrapper.
2020-10-01 03:25:27 +00:00
Kp e6126b800f Reorder endlevel definitions to split by dcx/dsx 2020-10-01 03:25:27 +00:00
Kp 1fc8663eff Improve ui_add_gadget_inputbox length handling
Fix potential buffer overflow if `length` (now `length_of_initial_text`)
is less than the `strlen` computed length of text.

Rename variables to clarify usage.

Eliminate the unnecessary use of `strlen`.
2020-09-28 03:32:15 +00:00
Kp 88ab83c354 Remove write-only field UI_GADGET_INPUTBOX::slength 2020-09-28 03:32:15 +00:00
Kp 9a5e968646 Use std::unique_ptr for UI_GADGET_INPUTBOX::text 2020-09-28 03:32:15 +00:00
Kp 59ca93f219 Simplify copy+uppercase pattern in editor code
Change d_strupr to both copy and uppercase, instead of using strcpy to
copy and then a separate phase to rewrite the text as uppercase.
2020-09-28 03:32:15 +00:00
Kp a6b8012b5d Make editor_dialog inherit from UI_DIALOG 2020-09-21 03:18:12 +00:00
Kp e4442a1b05 Remove code for ORTHO_VIEWS
Support for ORTHO_VIEWS has been broken since commit
db514a5ded in December 2004.

`git blame HEAD -L872,+4 -- similar/editor/meddraw.cpp`:
```
db514a5ded main/editor/meddraw.c (Bradley Bell 2004-12-19 13:54:27 +0000 872) 			}
db514a5ded main/editor/meddraw.c (Bradley Bell 2004-12-19 13:54:27 +0000 873) 		} else
db514a5ded main/editor/meddraw.c (Bradley Bell 2004-12-19 13:54:27 +0000 874) #if ORTHO_VIEWS
db514a5ded main/editor/meddraw.c (Bradley Bell 2004-12-19 13:54:27 +0000 875) 		 else if ( screen_canvas == TopViewBox->canvas )
```

When ORTHO_VIEWS is true, this code expands to `} else else if (...)`; a
double-else is not legal, so the code cannot have been compiled with
ORTHO_VIEWS enabled.  All 4 of the relevant lines date to db514a5ded,
which itself is an import of files from the D1X editor.
2020-09-21 03:18:12 +00:00
Kp cd620e5f8c Make trigger_dialog inherit from UI_DIALOG 2020-09-21 03:18:12 +00:00
Kp 09966079c4 Make centers_dialog inherit from UI_DIALOG 2020-09-21 03:18:12 +00:00
Kp b97f581d56 Make hostage_dialog inherit from UI_DIALOG 2020-09-21 03:18:12 +00:00
Kp 5cdd562244 Move UI_DIALOG callback handling to virtual function 2020-09-21 03:18:12 +00:00
Kp 8760387188 Make UI_DIALOG inherit from window 2020-09-21 03:18:12 +00:00
Kp 3c1c270643 Make info_dialog_window inherit from window 2020-09-21 03:18:12 +00:00
Kp e068c685f4 Make scores_menu inherit from window 2020-09-21 03:18:12 +00:00
Kp 08701ca190 Store kmatrix_result in a uint8_t size enum 2020-09-21 03:18:12 +00:00
Kp b9f3e8a40a Remove unused UI_DIALOG fields 2020-09-21 03:18:12 +00:00
Kp d056daa162 Remove obsolete UI_DIALOG constructor, macros 2020-09-21 03:18:12 +00:00
Kp a069daae41 Remove unused DF_BORDER 2020-09-21 03:18:12 +00:00
Kp b3c3066a38 Fix no-joystick build
When joystick support is not present, `event_joystick_get_button` is not
declared in joy.h.

Fixes: c24864b180 ("make menus controllable with joystick")
2020-09-11 03:08:02 +00:00
Kp 3ee3ac7b7a Delete multi_do_death
It is not needed.  Deathmatch players never lose their keys, so there is
no need to reapply them.
2020-09-11 03:08:02 +00:00
Kp 6a9444e5d6 Move some multiplayer functions into namespaces 2020-09-11 03:08:02 +00:00
Kp 61f186bc18 Use enum class for texture1_value 2020-09-11 03:08:02 +00:00
Kp 39cb42b878 Push partial_range construction to newmenu callers
In some cases, callers know the length of the range and can apply better
checks than the called code.
2020-09-11 03:08:02 +00:00
Kp e31d030caf Use zip for nm_messagebox_str 2020-09-11 03:08:02 +00:00
Kp 7de81a7293 Move Afterburner_charge to dsx 2020-09-11 03:08:02 +00:00
Kp 18282d5b66 Move some menu code into namespaces 2020-09-11 03:08:02 +00:00
Kp 0f2c1cdd45 Make game window inherit from dcx::window 2020-08-28 00:18:45 +00:00
Kp b79eff0e5c Deduplicate fades[]
Two identical copies were defined in different places.  Use the global
one for both consumers.
2020-08-28 00:18:45 +00:00
Kp 955c7d9542 Make console window inherit from dcx::window 2020-08-28 00:18:45 +00:00
Kp cdca112f0a Pass LevelUniqueAutomapState to automap_clear_visited 2020-08-28 00:18:45 +00:00
Kp ef8c0e7527 Make kmatrix window inherit from dcx::window 2020-08-28 00:18:45 +00:00
Kp 1d3e546848 Inline window_get_canvas
The helper returns a reference to a mutable canvas, so there is no
isolation provided by using the helper.
2020-08-28 00:18:45 +00:00
Kp 0f89331924 Inline window_set_modal 2020-08-28 00:18:45 +00:00
Kp 97315725fa Move get_multi_endlevel_poll2 into dsx 2020-08-28 00:18:45 +00:00
Kp 53f75c3c72 Use enum class for kmatrix network flag 2020-08-28 00:18:45 +00:00
Kp 5b45fd3bae Add compile-time check that zip() will not exceed static sizes
This is necessarily incomplete since it can only check ranges that have
a compile-time static size.  However, it catches some simple mistakes,
and imposes no runtime cost, so it is still useful.
2020-08-28 00:18:45 +00:00
Kp 6d3dce4e16 Use enum class for tmap_num2
Define separate enum values for rotation data in both the high bits,
where it is usually kept, and the low bits, where it is sometimes used
for math or comparisons.

Define an enum value to represent the composite of the index and the
rotation, since the composite is not suitable for use as an array
subscript.  Add helper functions to extract the component pieces.
2020-08-24 01:31:28 +00:00
Kp da66b1d9b8 Move d1_tmap_num_unique to piggy.cpp
It is only used in one file.  Move it there and make it static.
2020-08-24 01:31:28 +00:00
Kp ab44115aa4 Move N_robot_joints to d_level_shared_robot_joint_state 2020-08-24 01:31:28 +00:00
Kp c96671f763 Move Pof_names to d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp dca3c6cdca Move savegame POF names to stack
They are only used while loading a savegame file.  There is no need for
them to be global.
2020-08-24 01:31:28 +00:00
Kp 636978db4b Move Marker_model_num to d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp 9c3fc7523c Make extra_bitmap_num static
Modify read_extra_bitmap_d1_pig to take the bitmap-to-write as a
parameter, instead of computing it from extra_bitmap_num.
2020-08-24 01:31:28 +00:00
Kp faf37e3c14 Always allocate D2-sized sound array
This makes other code simpler, and the extra elements will simply be
ignored in D1.
2020-08-24 01:31:28 +00:00
Kp 514c63efad Expose both MAX_SOUNDS in both games 2020-08-24 01:31:28 +00:00
Kp dd035a8f2f Move some piggy code into namespace dsx 2020-08-24 01:31:28 +00:00
Kp b29f19da51 Use enum class for GameBitmapOffset
Values in GameBitmapOffset are only intended for use indexing within the
game's PIG file.  Give them a specific type to reflect that.
2020-08-24 01:31:28 +00:00
Kp 8a1bc7f318 Move Exit_models_loaded into d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp 0eaabdb2fb Move N_polygon_models into d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp de4efc4f46 Qualify more uses of shared_segment members 2020-08-24 01:31:28 +00:00
Kp 2b8522f8ad Convert uses of vcsegptr_t to shared_segment& where possible 2020-08-24 01:31:28 +00:00
Kp 2e398c02c7 Convert uses of vmsegptr_t to shared_segment& where possible 2020-08-24 01:31:28 +00:00
Kp ce7c9946e8 Inherit base_bytebuffer_t constructor instead of delegating to it
This may encourage the compiler to generate better code, and should
never generate worse code.
2020-08-24 01:31:28 +00:00
Kp 8e81726ac5 Use enum class for laser_level
Remove stored_laser_level, which existed primarily to enforce type
separate.  `enum class` can do that without the need for a separate
class type.
2020-08-24 01:31:28 +00:00
Kp 038c6aef4d Move d_level_unique_object_state to a separate header
This is required to untangle the cross-inclusion of object.h and
morph.h.
2020-08-10 03:45:14 +00:00
Kp 8cf9ab8222 Access unique_segment::static_light directly
segment inherits unique_segment, so unique_segment members can be
referenced from an instance of segment.  Eventually, segment will be
removed.  Adjust references to go through unique_segment to support this
change.
2020-08-10 03:45:13 +00:00
Kp 7ad8d8c28b Rename object::movement_type to movement_source
gcc and clang disagree about how to disambiguate when an identifier is
both a typename and a member.  Avoid the disagreement by renaming the
member.
2020-08-10 03:45:13 +00:00
Kp 5245b1c4a3 Rename object::control_type to control_source
gcc and clang disagree about how to disambiguate when an identifier is
both a typename and a member.  Avoid the disagreement by renaming the
member.

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/532>
2020-08-10 03:45:13 +00:00
Kp 637efae03a Use enum class for gauges window indexing 2020-08-10 03:45:13 +00:00
Kp 1c42f69ff2 Use enum class for object_signature_t 2020-08-10 03:45:13 +00:00
Kp 38cddb0289 Use enum class for object movement_type 2020-08-10 03:45:13 +00:00
Kp 9e2543ecbf Use enum class for object control_type 2020-08-06 03:47:56 +00:00
Kp 4ef247e494 Use enum class for collision_result values 2020-08-06 03:47:56 +00:00
Kp 9b90a790f9 Add forward-declaration header for enumerated_array 2020-08-06 03:47:56 +00:00
Kp 111b655b09 Remove GM_GAME_OVER
Various sites assign GM_GAME_OVER to Game_mode, but no sites test for
it.  Its only value would be to clear out other flags, but that can be
done by clearing Game_mode.
2020-08-06 03:47:56 +00:00
Kreeblah 81a93441c0
Fixed macOS compilation 2020-08-02 16:03:19 -07:00
Kp 8d3f47d646 Fix hoard orb handling on player death
Descent tracked hoard orbs by borrowing the player's proximity bomb
slot.  Commit 829e95b6f8 moved proximity
bomb tracking to its own slot, but failed to update the player
death/deres logic accordingly.  This caused multiple inconsistencies
when a player was killed in hoard mode:

- The killed player saw the orb drop as expected.
- The killed player _also_ kept the orb in inventory after respawn,
  because the counter was not reset.
- Other players saw no orb drop.

Fix the inappropriate retention by resetting the orb count in
init_player_stats_new_ship.  Fix the inappropriate failure to drop by
adding a new unconditional field to the player death/deres message.  In
hoard games, use it to pass the orb count.  In other games, ignore it.

Fixes: 829e95b6f8 ("Separate hoard/proximity tracking")
Reported-by: snytek <https://github.com/dxx-rebirth/dxx-rebirth/issues/526>
2020-08-01 18:29:01 +00:00
Kp ec6a78c481 Use enum class for marker index types 2020-07-22 03:11:18 +00:00
Kp d738f6c21e Change enum side_type to enum class side_type 2020-07-16 02:31:04 +00:00
Kp 8d2ee6f14d Replace enumerate helper function with class template argument deduction 2020-07-16 02:31:04 +00:00
Kp daf06acfbe Replace zip helper function with class template argument deduction 2020-07-16 02:31:04 +00:00
Kp 48bfabee99 Use std::disjunction to simplify any_ephemeral_range 2020-07-16 02:31:04 +00:00
Kp 9081b2f071 Rename xrange_extent to xrange
This is handled separately to split out the churn of the renaming from
the logic changes that made this possible.
2020-07-16 02:31:04 +00:00
Kp 92ec624e47 Replace xrange helper function with class template argument deduction 2020-07-16 02:31:04 +00:00
Kp 250713d932 Use if constexpr to simplify xrange_extent::init_begin
Switch from tag-based overload dispatching to use `if constexpr`.
2020-07-16 02:31:04 +00:00
Kp 34a5d3797d Use enum class for gr_blend 2020-07-16 02:31:04 +00:00
Kp 6285878c4c Add color_palette_index type alias, to note palette-related uint8_t 2020-07-16 02:31:04 +00:00
Kp 8cc7be4986 Use std::bitset to track used colors
This reduces memory usage over using std::array<bool> for the same
number of bits.
2020-07-16 02:31:04 +00:00
Kp 6af56a27f2 Remove outdated joystick preprocessor guards
Testing for buttons||hats||axes is equivalent to testing for
joysticks!=0, since SConstruct forces joysticks=0 when
buttons == 0 && hats == 0 && axes == 0.  Remove tests of
buttons||hats||axes when those occur inside a test for joysticks!=0.
2020-07-16 02:31:04 +00:00
Kp 5735175999 Merge 'refs/pull/516/head' into master 2020-07-09 02:47:18 +00:00
Kp 738e4a740e Remove TRIGGER_FLAG::ON; it is write-only
The game clears it in various cases, but never tests for it.  Remove it.
2020-07-07 04:09:44 +00:00
Kp 569802e00f Convert kconfig array lookups to require correct enumerated type
This ensures that an array is indexed by the appropriate type.  Indexing
a mouse array with a joystick index is undefined behavior, and with this
change, such undefined behavior is now a compilation error.
2020-07-05 23:34:33 +00:00
Kp 9b9642dcac Only enable joystick axis->button bridge if both axes!=0 and buttons!=0
If axes!=0 and buttons==0 and hats==0, then the build fails because some
button-related functionality is missing.  Move the joystick axis->button
bridge into a conditional to exclude it in this case.

Fixes: 74ef8b02e6 ("Added axis buttons")
2020-07-05 23:34:33 +00:00
Kp 7e36beb30c Move polymodel alignment code to interp.cpp
This makes the alignment data structure `chunk` private to interp.cpp,
and allows most files to ignore whether DXX_WORDS_NEED_ALIGNMENT is
enabled, thus improving the ccache hit rate.
2020-07-05 23:34:33 +00:00
Kp 6e4b63e098 Use C++17 std::size instead of custom lengthof
lengthof was added to provide the size of C arrays.  C++17 std::size is
now available, and can serve the same purpose.  Remove the custom
lengthof.

The generated code is the same in both cases, other than the change in
line numbers caused by removal of the #include directives.
2020-07-05 23:34:32 +00:00
Kp bbcd5f5973 Use C++17 std::size instead of a custom equivalent
The custom version was used before C++17 was enabled.  Now that C++17
std::size is available, switch to it.
2020-07-05 23:34:32 +00:00
Kp 27724704d7 Use deduction guides to remove one layer of serial forwarding 2020-07-05 23:34:32 +00:00
Kp 0a1f2ad55e Tighten type for trigger action values 2020-07-05 23:34:32 +00:00
Kp 7a790f6068 Inline gr_set_fontcolor
It is a trivial function.
2020-07-05 23:34:32 +00:00
Kp b39c7c4ed2 Move ogl_swap_buffers_internal to dcx 2020-07-05 23:34:32 +00:00
Kp 90d7e39980 Move inclusion of platform-appropriate GL headers to a separate file
Some files may need to include platform GL headers, but not process all
the Rebirth-specific GL code.
2020-07-05 23:34:32 +00:00
Kp a98ddfbe9b Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers.  Fix up various resulting breaks,
which look like bugs:

- Descent 2 editor mode could modify trigger::flags, but used
  TRIGGER_FLAG_* values, which specify the actions for a Descent 1
  trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
  TRIGGER_ON.  Since the flags were just set to 0, the mask operation is
  useless.  Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON.  This seems
  to be completely wrong.  Change it to remove
  trigger_behavior_flags::disabled.  Descent 1 has no (working) support
  for disabling triggers, so make trigger_turn_all_ON exclusive to
  Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games.  Descent 1
  never reads TRIGGER_ON.  Descent 2 uses this field for trigger
  behavior flags, and TRIGGER_ON is not a behavior flag.
  - For Descent 1 builds, remove the modification of the field.
  - For Descent 2 builds, change it to clear
    trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
Martin Fiedler aa972c2b93 improved joystick button to keyboard command mapping
Instead of parsing the button name string,
an explicit button-to-key mapping table
is now built and used.

Also fixes a few minor inconsistencies
that were introduced in c24864b1.
2020-06-30 21:18:49 +02:00
Martin Fiedler 853a0c41e1 added joystick binding for showing ingame menu
A new configurable joystick button binding is
introduced that opens the ingame menu, i.e. the
menu that appears when pressing the Escape key.

Fortunately, there was still enough space left
in the button binding maps for both games. The
configuration screen, however, needed to be
extended by a row to make room for the new
binding on d2x.

One known issue: When using an old player
configuration file, the menu button bindings
are initially set to J1 B1, because the unused
slots in DefaultKeySettings used to be
initialized that way. There's not much we can
do about that; the player needs to remove
these bogus assignments by hand. We can (and
do) prevent that from happening again, though,
by initializing new player files with correct
unmapped buttons.
2020-06-29 23:16:04 +02:00
Martin Fiedler c24864b180 make menus controllable with joystick
In most menus, keyboard commands are synthesized
from controller buttons, leveraging the existing
axis-to-button translation.

Menu controls are currently fixed:
- button 0 (A) is confirm (Enter)
- button 1 (B) is cancel (Esc)
- button 2 (X) is switch (Space)
- button 3 (Y) is delete (Delete)
- axes 0 and 1 (main analog pad) maps to cursor keys
- all hats (D-pads) map to cursor keys

Title screens and credits can be confirmed
with any joystick button or axis motion too.
2020-06-28 17:08:26 +02:00
Kp e5cae0f699 Remove unused g3_uninit_polygon_model 2020-06-22 00:36:45 +00:00
Kp e25ecbb10c Increase multiplayer protocol version number
Cross-play between development builds from different commits is never
guaranteed.  Increase the protocol version number to force everyone to
sync up.  Github user D2Lovin reported that mixing users from two
snapshot builds behaved poorly, but went silent when prompted for more
information.  This bump will force users to synchronize, which is a good
idea on principle.

Related: https://github.com/dxx-rebirth/dxx-rebirth/issues/509
2020-06-10 02:25:33 +00:00
Kp 46d72a29c0 Retire compiler-begin.h
This was once a compatibility shim, but compiler support for std::begin
has been required since 5e434cbe95 and no
issues have been reported.  Flatten the include tree by removing this
header and using the STL names directly.
2020-06-10 02:25:32 +00:00
Kp 665713f315 Remove static inline declarations from fwd-partial_range.h
A declaration is useful if it declares an external function.  A static
inline declaration, if not followed by the definition later in the same
translation unit, will not be useful.  Remove such declarations, and
rely on using the definition as a declaration for those files that
actually call partial_range() or similar functions.
2020-06-10 02:25:32 +00:00
Kp fa7d8e2dea Use enum sound_effect for hardcoded sound index numbers 2020-06-10 02:25:32 +00:00
Andreas Müller c8ad243ec3 clipper.cpp: Fix build with gcc10
| common/3d/clipper.cpp:29:14: error: 'out_of_range' is not a member of 'std'

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
2020-06-09 22:23:48 +02:00
Kp 68b47307b4 Remove useless SDL_RWops precision test in SDL2
SDL2 increased the range of the seek type, so truncation is no longer a
concern.
2020-05-31 23:04:25 +00:00
Kp 5c30b467bb Move jukebox_load, jukebox_hook_next to dcx 2020-05-31 23:04:25 +00:00
Kp 81119f0445 Use enum class for LevelMusicPlayOrder 2020-05-31 23:04:25 +00:00
Kp 2e1e142767 Factor out sound_function_table_t where possible
Move it to namespace dcx when this does not cause a dcx->dsx dependency.
2020-05-31 23:04:25 +00:00
Kp b08620292d Fix input handling in automap
The automap code keeps a mostly-private secondary copy of control_info.
The change to reset control_info before the event loop reset the main
copy of control_info for the automap, not the copy that the automap
actually used.  Fix this by passing the desired control_info to relevant
functions instead of always using the global variable Controls.

Fixes: c621a970c6 ("Reset kconfig counters once, before the event loop")
2020-05-28 03:21:22 +00:00
Kp 511a3d6b9c Pump SDL events in batches 2020-05-27 03:07:17 +00:00
Kp ff50824418 Pass SDL events as const T *, not T * 2020-05-27 03:07:17 +00:00
Kp c621a970c6 Reset kconfig counters once, before the event loop 2020-05-27 03:07:17 +00:00
Kp c4c09963ae Use constexpr uint8_t for TRANSPARENCY_COLOR
This encourages std::fill_n to become memset.  When TRANSPARENCY_COLOR
is `#define`'d to 255, it is an integer literal of type `int`.
2020-05-22 02:40:26 +00:00
Kp 7b52b1fe1d Move grs_bitmap::avg_color into #if !DXX_USE_OGL
This field is used in the SDL build for rendering.  In the GL build, its
only purpose is for the editor to write it to a PIG file.  Change that
one use to compute the value as needed.  Move all other references
behind a preprocessor test for !DXX_USE_OGL.  This shrinks the size of
grs_bitmap by 1 pointer, since the compiler added padding after
avg_color up to the size of the next aligned pointer.
2020-05-22 02:40:26 +00:00
Kp c1181b7be5 Move texture_list out of global scope 2020-05-22 02:40:26 +00:00
Kp 3d3db16c6f Move Canvas_width,Canvas_height to local scope 2020-05-22 02:40:26 +00:00
Kp 0b35d8e2ce Factor out std::max in event dispatching 2020-05-22 02:40:26 +00:00
Kp 727bc4b663 Flush events in bulk 2020-05-22 02:40:26 +00:00
Kp fe792055d6 Simplify current_music_t
Inherit unique_ptr instead of embedding it, so that its members can be
exposed via a `using` directive.
2020-05-22 02:40:26 +00:00
Kp 5c88587c01 Encourage std::fill to become memset
gcc has a special case to devolve to memset if both the pointed-at data
and the value to fill are considered a byte.  All uses of
DXX_POISON_MEMORY pass a value that fits in a byte, so change the
signature to be a byte, to encourage gcc to activate the special case.
2020-05-17 23:35:26 +00:00
Kp f413017317 Delegate bald_guy_load PCX to SDL image 2020-05-17 23:35:26 +00:00
Kp 3114874713 Delegate PCX loading to SDL_image
This adds a new dependency, but most systems likely already have
SDL_image installed.  Use of SDL_image can be disabled, but this is
discouraged, because various in-game interfaces assume the use of the
original background.

The old implementation automatically corrected for filename case.  The
new implementation expects that the supplied filename can be passed to
PYHSFS_openRead as-is.  All known uses in-game have been corrected to
satisfy this requirement.  If the new stricter match requirement becomes
a problem, a variant of PHYSFSRWOPS_openRead that adjusts filename case
could be created for use here.

- Update install instructions
- Update ebuild
- Update Arch PKGBUILD
2020-05-17 23:35:26 +00:00
Kp 699c9bc283 Fix check_header_includes=1 build 2020-05-17 23:35:25 +00:00
Kp df9a2bacf1 Handle gcc-10 truncation warnings in net_udp.cpp
gcc-10 warns that the game information text may be truncated, because it
overestimates the maximum possible length of some strings.  Handle the
warning by changing the format string to explicitly truncate these
strings at their maximum legal lengths.
2020-05-17 23:35:25 +00:00
Kp a4f2edfaa9 Move LevelSharedVertexState into d_level_shared_segment_state 2020-05-17 23:35:25 +00:00
Kp f577788665 Use C++17 fold expressions to simplify serialization code 2020-05-17 23:35:25 +00:00
Kp 99a03b21ce Simplify serial:process_buffer self-selection filter
Use std::enable_if, so that the second argument becomes part of the
parameter pack instead of requiring explicit handling.
2020-05-17 23:35:25 +00:00
Kp 72c5221e0b Use if constexpr instead of std::enable_if
This reduces the size of the generated debug information, but produces
the same code.
2020-05-17 23:35:25 +00:00
Kp 6a4a8a62c9 Add unit tests for serialization code 2020-05-17 23:35:25 +00:00
Kp 399aee8d49 Use dedicated type for object render_type
Check conversions.  On invalid input, coerce to RT_NONE and print a
warning.
2020-05-02 21:18:43 +00:00
Kp fa0d57961d Use runtime check for instance_stack overrun
Replace assert with std::array<>::at(), so that an exception will be
thrown if the array bound is exceeded.
2020-05-02 21:18:43 +00:00
Kp 619ac0abff Use structured bindings for enumerate+zip 2020-05-02 21:18:43 +00:00
Kp 755186ada2 Remove use of deprecated std::iterator 2020-05-02 21:18:43 +00:00
Kp 3ce1f2b3ed Require support for C++11 addressof 2020-05-02 21:18:43 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 3170b11997 Modernize typedefs for std::array types
Use `using x = y;` instead of `typedef y x;`.
2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 9cee93abb1 Require support for C++14 std::exchange 2020-05-02 21:18:42 +00:00
Kp ddc25b59b7 Explicitly zero-initialize object structure members
C++17 will require this in order for `object::object()` to be constexpr.
Add it here, before switching over.
2020-05-02 21:18:42 +00:00
Kp 333d619858 Update tool_bundle.py to parse correctly under Python3
mmontag reports that tool_bundle.py cannot be parsed under Python 3.
Fortunately, the errors are all straightforward, so non-OS X systems can
see the errors when the file is imported.  Normally, the file is only
imported when building for darwin, so non-OS X systems do not see the
problem.

- Add parentheses to print() calls.  This is not consistent with the
  rest of the Rebirth output scheme, but is simple to do.
- Adjust the syntax for raising exceptions.

Reported-by: mmontag <https://github.com/dxx-rebirth/dxx-rebirth/issues/503#issuecomment-619463994>
2020-04-26 17:26:23 +00:00
Kp df19889f61 Prefer NSDMI over simple default constructors
This protects against mistakes if more constructors are added, and makes
the code easier to read.
2020-04-26 17:26:23 +00:00
Kp a431f23817 Use enumerated constant for save slot indexes 2020-04-26 17:26:23 +00:00
Kp 0b070880a7 Use C++11 user-defined literals to dispatch valptridx error style
Switch valptridx error style dispatching from using macro pasting to
using C++11 user-defined literals.  This makes the code a bit easier to
read, and removes the need for a C99-conforming preprocessor here, which
should help anyone trying to port to Microsoft Visual Studio.

The new implementation also fixes a limitation of the previous
implementation.  Before, an override that referenced an invalid name
could be silently ignored.  Now, incorrect overrides cause an attempt to
use an undefined instantiation, which fails with a compilation error.
2020-04-26 17:26:23 +00:00
Kp b396445efa Require support for std::index_sequence, std::make_index_sequence
The minimum supported compiler versions now provide a depth-efficient
implementation of std::make_index_sequence, which removes the last
reason to carry a private implementation.  In the case of clang, it
appears to have a special compiler intrinsic used to implement its
std::make_index_sequence.

Switch to the compiler-provided version for both gcc and clang.
2020-04-26 17:26:23 +00:00
Kp 5fa8c06914 Add experimental support for autosaves
Set autosave interval to 10 minutes, unless specified in the player's
configuration file.  Players can change the autosave to 0 minutes to
disable it.
2020-04-19 20:47:07 +00:00
Kp a1b3a86cba Use std::chrono::duration for ThisLevelTime, PlayTimeAllowed
Store PlayTimeAllowed in ticks since it is frequently accessed for logic
tests, but only rarely accessed for display.
2020-04-19 20:47:07 +00:00
Kp d197ba42c3 Fix mouse-selection in listboxes
Commit d355ef4030 removed a seemingly unnecessary modification of the
global variable grd_curcanv->cv_font, after eliminating all local reads
of it.  However, a non-local read, buried in listbox_mouse, depended on
grd_curcanv->cv_font being set to a MEDIUM font.  After that commit,
grd_curcanv->cv_font retained its prior value, which is not a MEDIUM
font.  This caused listbox_mouse to compute an incorrect height of the
lines in the listbox, which manifested as the game choosing the wrong
line when the mouse is clicked in the listbox.

Fix the problem by explicitly using MEDIUM3_FONT, since that was
usually the value left in grd_curcanv->cv_font prior to that commit.  In
some cases, a different MEDIUM font would be left there, but all the
MEDIUM fonts have the same height, so they are interchangeable for this
purpose.

Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/498>
Fixes: d355ef4030 ("Pass font to various drawing functions")
2020-04-04 19:30:23 +00:00
Kp 23ebf27554 Move digi functions to dcx; use bitset for channels 2020-04-04 19:30:22 +00:00
Kp 714c13b3c1 Move WallAnims into d_game_shared_state 2020-04-04 19:30:22 +00:00
Kp a645fd2eba Allocate morph_data vectors dynamically
This greatly reduces the size of morph_data for most uses.
2020-02-26 05:07:34 +00:00
Kp 85a9034137 Move morph_data::morph_deltas into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 73612f6667 Move morph_data::morph_vecs into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 74f8fd0d4d Move morph_data::morph_times into a trailing allocation
Initially, this just makes the code more complicated.  In the end, it
will allow choosing the array size dynamically.
2020-02-26 05:07:34 +00:00
Kp 00df407381 Use a custom allocation for morph_data
This will enable shrinking the morph arrays to allocate only what is
needed.
2020-02-26 05:07:34 +00:00
Kp 27a96d0337 Simplify partial_range check for unsigned offset/length 2020-02-26 05:07:34 +00:00
Kp d4c48d80b5 Fix some failures in check_header_includes=1 builds 2020-02-26 05:07:34 +00:00
Kp 707df7b9de Move some newdemo functions into namespace dsx 2020-02-26 05:07:34 +00:00
Kp fd134851d1 Pass context to morph_start 2020-02-26 05:07:34 +00:00
Kp aaaf212dca Add unit test for zip iterator 2020-02-26 05:07:34 +00:00
Kp 94401b4085 Pass LevelUniqueMorphObjectState to find_morph_data 2020-02-26 05:07:34 +00:00
Kp 40726aa580 Mark xrange as returning unowned storage
It returns integers by value, not by reference.
2020-02-26 05:07:34 +00:00
Kp c088f15384 Use std::fill to overwrite poisoned ranges
gcc can replace std::fill with memset when the code would be a loop
writing byte values.
2020-02-11 04:48:14 +00:00
Kp 3f7149a346 Simplify text decoding 2020-02-11 04:48:14 +00:00
Kp 88087fbbab Move Text_string to dsx 2020-02-11 04:48:14 +00:00
Kp 669c341147 Move d_level_unique_morph_object_state to d_level_unique_object_state 2020-02-01 22:33:31 +00:00
Kp cac5f1da56 Move morph_data into dynamic allocations
This improves poison detection, and eliminates some large static
allocations (MAX_VECS * ((2 * vms_vector) + fix)).
2020-02-01 22:33:31 +00:00