Commit graph

178 commits

Author SHA1 Message Date
Kp 9898d136f1 Fix fortification crash loading missions with long filenames
The highest-level tracking code assumed filenames would always fit in a
char[9].  This was true on DOS, but has not been true in Rebirth for
many years.  Builds without fortification caused silent memory
corruption in this case.

Refuse to create highest-level entries if they would cause corruption.
Log a diagnostic telling the user that this happened.
2019-03-09 23:39:16 +00:00
Kp f491059ed7 Enable building with SDL2
This commit enables Rebirth to build with SDL2, but the result is not
perfect.

- SDL2 removed some sticky key support.  Rebirth may behave differently
  now in this area.
- SDL2 removed some key-repeat related support.  Rebirth may behave
  differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
  the desktop instead of by changing the desktop resolution.  Rebirth
  uses this, and it mostly works.
  - Resizing while in the automap does not notify the automap code, so
    the view is wrong until the player switches out of automap mode and
    back in.
- SDL2 changed how to enumerate available resolutions.  Since
  fitting the window to the desktop is generally more useful than
  fitting the desktop to the window, I chose to drop support for
  enumerating resolutions instead of porting to the new API.  Users can
  now enter an arbitrary window dimension and Rebirth will make an
  attempt to use it.
  - It might be useful to cap the window dimension at the desktop
    dimension, but that is not done yet.
  - Entering fullscreen mode through the Controls->Graphics submenu
    failed to notify the relevant subsystems, causing the rendered
    content not to rescale.  For now, compile out the option to toggle
    full screen through that menu.  Toggling through Alt+Enter works
    properly.

Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all.  The remaining issues can be
resolved in future work.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-28 23:22:58 +00:00
Kp d355ef4030 Pass font to various drawing functions 2018-05-19 23:21:42 +00:00
Kp fda1eb851e Pass fonts to LINE_SPACING 2018-05-19 23:21:42 +00:00
Kp 08446f0ab6 Pass font to gr_string,gr_printf 2018-05-19 23:21:42 +00:00
Kp e63bbe8c52 Set d_event type at construction 2018-05-12 18:24:19 +00:00
Kp 6ab28cb8cb Use enum for Difficulty_level 2018-05-12 18:24:19 +00:00
Kp 5c2408faaa In SDL2 mode, exclude test for SDL1-only feature (Redbook) 2018-03-03 18:47:23 +00:00
Kp 8376504a34 Fix menu.cpp build failure for sdlmixer=0
When sdlmixer=0, opt_sm_mtype1 is not defined, but was used.  Preprocess
out the use.
2017-11-25 01:56:51 +00:00
Kp 49c0cdae2e Simplify calls to gr_set_default_canvas
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.

git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
2017-11-05 20:49:08 +00:00
Kp a24490033f Allow players to remove thief at level start
Commit f4b21088a0 ("Track vulcan ammo explicitly") fixed an original
retail bug that prevented the thief from stealing energy weapons,
because the thief could only steal weapons for which the player had ammo
and energy weapons never have ammo.  This went unremarked for several
years, until a recent report of the new semantics as a game-breaking
regression because the thief is now "ridiculously potent".

Address this report, as well as an intermittently raised issue from
various users over time, by adding two new knobs to both the single
player "Gameplay" menu and the multiplayer setup screen: "Remove Thief
at level start" and "Prevent Thief Stealing Energy Weapons".

"Remove Thief" deletes the thief object during level load.  It has no
impact on save games, and changing it after entering a level has no
effect on any thief already in the level.

"Prevent Thief Stealing" is checked at the moment of theft and, when
enabled, prevents stealing primary weapons other than Vulcan/Gauss.
This can be changed at will in single player and is immediately
effective.  In multiplayer, this option can only be changed by the game
host in the pre-game setup.

For both knobs, there is one pair of checkboxes to control this as a
player preference, which applies in single player games.  There is a
second pair of checkboxes in the multiplayer setup, which applies only
to multiplayer games.  Therefore, in multiplayer, the host chooses thief
settings and all clients use the host's choice.  The host may configure
the thief differently in multiplayer from how the host plays in single
player.

For users who wanted to remove the thief, no specific tally has been
kept for who requested it or when.  Now that the code is being updated,
this is thrown in as an easy addition.

Reported-by: MegaDescent <http://forum.dxx-rebirth.com/showthread.php?tid=980> (for the thief stealing energy weapons as a game-breaking regression)
2017-08-26 19:47:52 +00:00
Kp 4cf4ce38b0 Cache player references 2017-08-13 20:38:31 +00:00
Kp 988d16c51f Clean up resolution input error handling
Revert to the user's chosen resolution, not to 0x0, which would then be
coerced to the minimum resolution.  When the text says revert, it should
revert, not just pick a size.

Change the "OK" label to say "Revert to NxM" for the resolution it is
reverting to.

Tighten input validation so that a blank width or blank height produce
the correct error message, rather than being coerced to 0, then
rejecting 0 as too small.
2017-07-26 03:15:59 +00:00
Kp 1a1e669bc6 Pass vms_angvec &to draw_model_picture 2017-04-30 16:25:16 +00:00
Kp 71fdb5b8f0 Cache canvas in polygon_models_viewer_handler 2017-04-08 16:48:18 +00:00
Kp d5ed019014 Add experimental MP-aware mouselook 2017-03-25 19:34:02 +00:00
Kp 1a7659897a Pass canvas to draw_model_picture 2017-02-19 19:33:44 +00:00
Kp 6b8f08142f Pass canvas to LINE_SPACING
Macro LINE_SPACING previously used global grd_curcanv implicitly.
Change it to take a canvas argument.  Change all callers to pass
grd_curcanv, so that usage is explicit.
2017-02-11 21:42:42 +00:00
Kp 5a86bcaeb6 Cache canvas in draw_copyright 2017-02-11 21:42:38 +00:00
Kp 6f81d13c41 Pass canvas to gr_set_curfont 2017-02-11 21:42:38 +00:00
Kp ae33aaafc1 Pass canvas to gr_set_fontcolor 2017-02-11 21:42:32 +00:00
Kp 0dcae721d9 Make canvas an explicit argument to gr_printf
Previously, a macro implied *grd_curcanv as the canvas.  Pass the canvas
explicitly so that callers can choose the canvas to use.
2017-02-11 21:42:32 +00:00
Kp 5da784dbed Pass canvas to gr_{,u}string 2017-01-08 22:32:00 +00:00
Kp 22e364e030 Pass canvas to gr_clear_canvas 2017-01-01 00:45:45 +00:00
Kp 08d0aa9b59 Pass canvas to gr_bitmap 2016-12-29 03:27:13 +00:00
Kp 99f5cfbb10 Pass canvas to ogl_ubitmapm_cs 2016-12-29 03:27:12 +00:00
Kp 85338cba5e Fix memory corruption starting multiplayer game
Various points in the game code call `hide_menus()`, then later use
`show_menus()` to reverse the effect.  If the forcibly hidden window is
deleted before `show_menus()` is called, the attempt to show it would
write to freed memory.  Add a hook to forget those windows when they are
deleted, so that `show_menus()` does not try to make them visible later.
2016-11-19 18:09:26 +00:00
Chris Taylor 143ed30fee Merging in unification/master, resolving conflict in similar/main/kmatrix.cpp 2016-11-06 14:20:18 +08:00
Kp 5f6d60bb7c Fix menu.cpp build when max_joysticks=0
menu.cpp always needs SDL.h, but included it only as a side effect of
joy.h including SDL.h.  joy.h only includes SDL.h when max_joysticks!=0.

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/258>
2016-11-05 21:22:43 +00:00
Chris Taylor 7ac820248c Use new event_process_all() for event loops that check for window_event_result::deleted (which is most of them) 2016-10-29 20:06:01 +08:00
Chris Taylor 49ce8dbb99 Check for window_event_result::deleted for gamebitmaps_viewer polling loop
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 15:30:58 +08:00
Chris Taylor 731777476f Check for window_event_result::deleted for polygon_models_viewer polling loop
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 15:29:14 +08:00
Chris Taylor e44013ebcf Kill window_exists call in show_menus
Hidden windows don't receive events, so the only way to close is outside its handler, which there should be no cases of here. The function window_exists could return a false positive if a new window was created with the same pointer value as a deleted one. Will later disable window_exists function.
2016-10-28 08:58:47 +08:00
Chris Taylor 48e9061960 Make the listbox handlers return a window_event_result
Make the listbox handlers and all sub-handlers (when_selected callbacks) return a window_event_result. Makes code more readable and removes one use of window_close, making it easier to inform event system if a window closes in future.
2016-10-27 15:22:41 +08:00
Kp 01f2932824 Pass grs_canvas &to window_create 2016-10-15 00:53:20 +00:00
Chris Taylor bc1c9ebd97 Merge branch 'unification/master' into allow_dialog_subclass
Conflicts:
	common/arch/sdl/window.cpp - Remove unused EVENT_WINDOW_CLOSED and w_callback local var
	common/ui/dialog.cpp - Remove unused EVENT_WINDOW_CLOSED
2016-10-10 14:40:11 +08:00
Kp 2d8928958d Fix some use_udp=0 build breaks
The build is still broken for use_udp=0.
2016-10-08 23:24:22 +00:00
Chris Taylor 60ac1eaad3 Replace delete dcx::window kludge with a better solution
Replace delete dcx::window kludge with a better solution: instead of requiring every handler to delete the window, add a window_event_result::deleted, which gets returned if the window was deleted by the handler, so window_close knows not to attempt to delete it again.
2016-10-04 14:05:44 +08:00
Chris Taylor d4b85de49b Remove redundant checks for nullptr before deleting dcx::window instances in response to feedback. 2016-10-03 11:21:11 +08:00
kreatordxx b87fcad332 Merge pull request #230 from dxx-rebirth/allow_window_subclasses_2
Allow window subclasses
2016-10-03 10:36:26 +08:00
Kp 0abb7278da Move FPSIndicator to CCfg 2016-10-02 19:35:33 +00:00
Kp 797554f80a Move Multisample to CCfg 2016-10-02 19:35:33 +00:00
Chris Taylor 87617e8ac9 Allow dcx::window struct to be subclassed - step 3
Allow dcx::window struct to be subclassed step 3. This step adds the window destructor and both requires and implements the window to be deleted by the event handler/client in all cases.
2016-10-02 17:49:19 +08:00
Kp d0c3f03d54 Remove unnecessary nullptr test on nonnull parameter in select_file_recursive2
gcc-6 warns about this test because the caller is not permitted to pass
nullptr here, so the test is unnecessary.
2016-09-26 00:50:09 +00:00
Kp 7d38a9f0be Rename MAX_AXES_PER_JOYSTICK to DXX_MAX_AXES_PER_JOYSTICK
Rename symbol MAX_AXES_PER_JOYSTICK to DXX_MAX_AXES_PER_JOYSTICK to show
that it is a DXX symbol, not one inherited from a library.

git grep -lzw MAX_AXES_PER_JOYSTICK -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_AXES_PER_JOYSTICK\>/DXX_&/g'
2016-09-25 04:52:49 +00:00
Kp f24e9f836c Rename MAX_JOYSTICKS to DXX_MAX_JOYSTICKS
Rename symbol MAX_JOYSTICKS to DXX_MAX_JOYSTICKS to show that it is a DXX
symbol, not one inherited from a library.

git grep -lzw MAX_JOYSTICKS -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_JOYSTICKS\>/DXX_&/g'
2016-09-25 04:52:48 +00:00
Kp 62b58e9890 Move OGL to dxxsconf.h; rename to DXX_USE_OGL
Rename symbol OGL to DXX_USE_OGL to show that it is a DXX
symbol, not one inherited from a library.  Move it to dxxsconf.h to
shorten the command line.

This is a mostly automated transform, but the changes to SConstruct were
manual.

git grep -lzw OGL -- '*.h' '*.cpp' | xargs -0 sed -i -e 's/\(\s*#\s*if\)def\s*OGL/\1 DXX_USE_OGL/' -e 's/\(\s*#\s*if\)ndef OGL/\1 !DXX_USE_OGL/' -e 's/\(\s*#\s*if !\?\)defined(OGL)/\1DXX_USE_OGL/'
2016-09-24 18:06:11 +00:00
Kp 6a3ded191f Move EDITOR to dxxsconf.h; rename to DXX_USE_EDITOR
Rename symbol EDITOR to DXX_USE_EDITOR to show that it is a DXX
symbol, not one inherited from a library.  Move it to dxxsconf.h to
shorten the command line.

This is a mostly automated transform, but the changes to SConstruct were
manual.

git grep -wl EDITOR -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(EDITOR\)\>/#if DXX_USE_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(EDITOR\))/#\1if \2DXX_USE_\3/' -e 's/^\s*#ifndef \(EDITOR\)\>/#if !DXX_USE_\1/'
2016-09-11 18:49:16 +00:00
Kp 435aa5a020 Move USE_UDP to dxxsconf.h; rename to DXX_USE_UDP
Rename symbol USE_UDP to DXX_USE_UDP to show that it is a DXX
symbol, not one inherited from a library.  Move it to dxxsconf.h to
shorten the command line.

This is a mostly automated transform, but the changes to SConstruct were
manual.

git grep -l USE_UDP -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(USE_UDP\)$/#if DXX_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(USE_UDP\))/#\1if \2DXX_\3/'
2016-09-11 18:49:15 +00:00
Kp 7c8c2b5aa4 Move USE_TRACKER to dxxsconf.h; rename to DXX_USE_TRACKER
Rename symbol USE_TRACKER to DXX_USE_TRACKER to show that it is a DXX
symbol, not one inherited from a library.  Move it to dxxsconf.h to
shorten the command line.

This is a mostly automated transform, but the changes to SConstruct were
manual.

git grep -l USE_TRACKER -- '*.h' '*.cpp' | xargs sed -i -e 's/^#ifdef \(USE_TRACKER\)$/#if DXX_\1/' -e 's/#\(el\)\?if \(.*\)defined(\(USE_TRACKER\))/#\1if \2DXX_\3/'
2016-09-11 18:49:15 +00:00