Commit graph

4026 commits

Author SHA1 Message Date
Chris Taylor 0daf28e787 Small efficiency improvement for a return value in do_endlevel_frame() 2017-01-09 09:26:32 +08:00
Chris Taylor aac4dd6c0e Remove call to newdemo_stop_playback() in newdemo_record_start_frame
This is in a redundant check, as we shouldn't (and don't) call newdemo_record_start_frame if nd_record_v_no_space is true, i.e. we ran out of disk space recording a demo. We want to return window_event_result::close with every call to newdemo_stop_playback() to close the game, as this is safer than calling window_close on the game window within its handler. In this case, it's much simpler (and safe) to just remove it.

Even if newdemo_record_start_frame is called when nd_record_v_no_space is true, we don't want to close the game, just exit the function.
2017-01-08 21:08:50 +08:00
Chris Taylor 4cc801f42f Remove calls to window_close(Game_wind) when game finished or over
Replace calls to window_close(Game_wind) with returning window_event_result::close to game handler. Applies to when DoEndGame() is called, DoGameOver() is called, aborting in the kmatrix screen (multiplayer game) during AdvanceLevel() and playing one demo frame causes playback to stop in GameProcessFrame(). Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-08 21:08:50 +08:00
Chris Taylor b7c41a0d98 Remove calls to window_close(Game_wind) within close_editor
These are redundant. Will remove all cases of window_close(Game_wind) - it's safer for the handler to return window_event_result::close.
2017-01-08 21:03:41 +08:00
Kp f339e60606 Scrub object subtypes on load
Old versions of Rebirth sometimes saved games with bogus object data,
such that `obj->type == OBJ_NONE`, but `obj->movement_type`,
`obj->control_type`, or `obj->render_type` were not their respective
*_NONE constants.  This confused the game loader code such that it would
load invalid data from the `mtype`, `ctype`, or `rtype` unions and use
it without checking.

Try to counter some of this by exiting early if the object has type
OBJ_NONE.
2017-01-07 23:34:18 +00:00
Kp fe04c3fef6 Initialize obsolete fields
Valgrind warns when writing uninitialized data to a file.  The Descent
savegame format requires writing certain fields that are no longer used.
Set those fields to 0 to prevent leaking stack data into the file.
2017-01-01 23:19:21 +00:00
Kp 3fab4bfeb5 Fix uninitialized write of segment light_subtracted
Levels which fit in MAX_SEGMENTS_ORIGINAL read exactly
MAX_SEGMENTS_ORIGINAL segments worth of light_subtracted, even though
fewer segments were defined.  Prepare light_subtracted into a temporary
stack buffer instead of doing byte-at-a-time writes.  Initialize this
stack buffer to 0 when necessary.  Write the buffer once it is fully
prepared.
2017-01-01 00:45:46 +00:00
Kp a7ec4ccd63 Avoid uninitialized reads when saving game
player_info::cloak_time is only defined if the player is cloaked.
player_info::invulnerable_time is only defined if the player is
invulnerable.

In both cases, the game save code tried to read the ::*_time variable
even when it was undefined.  Modify the saving code to check player
flags before reading the associated timer.
2017-01-01 00:45:46 +00:00
Kp fe50c0a20a Factor out point_list setup 2017-01-01 00:45:45 +00:00
Kp 2c7e36ef1e Cache KEY_M vsegptridx 2017-01-01 00:45:45 +00:00
Kp 22e364e030 Pass canvas to gr_clear_canvas 2017-01-01 00:45:45 +00:00
Kp 0905aefa0a Pass canvas to gr_rect 2017-01-01 00:45:45 +00:00
Kp 794dcce327 Pass canvas to gr_urect 2017-01-01 00:45:44 +00:00
Kp 774dedd21d Pass canvas to gr_bm_pixel 2017-01-01 00:45:44 +00:00
Kp 77c22d3a7f Pass canvas to gr_settransblend 2017-01-01 00:45:44 +00:00
Kp c3c4ab8e3e Pass canvas to gr_box 2017-01-01 00:45:44 +00:00
Kp dac1a69f7c Pass canvas to gr_ubox 2017-01-01 00:45:44 +00:00
Kp 1b57e9a5ff Pass canvas to show_fullscr 2017-01-01 00:45:43 +00:00
Kp 250bf58e51 Pass canvas to gr_bitmapm 2017-01-01 00:45:43 +00:00
zico daad12106d Fixed texture malformations of op_tmappoly in g3_draw_morphing_model_state(). 2016-12-30 14:49:40 +01:00
zico 24bd4170f4 Added debug key combo DEL+M to generate a morphing robot in the player segment, rotating through all available bots. Handy for testing purposes. 2016-12-30 14:45:47 +01:00
Kp 3a4eafac03 Add workaround for passive thief bot
zicodxx reports that f7d0c85 made the thief bot passive and timid.
His analysis suggests that the problem is because f7d0c85 changed
find_connected_distance to return vm_distance::maximum_value() in places
where it previously returned magic values that were not maximum (caching
a distance of F1_0*1000 and returning a distance of -1).  Rather than
try to fix the underlying code that relied on these magic values, revert
those return paths to return these unusual values.  Move the unusual
values to named constants in file scope so that they are easier to find
and correlate.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/286>
Analyzed-by: zicodxx

Fixes: f7d0c853ba ("Use special types for distance/magnitude")
2016-12-29 03:27:14 +00:00
Kp 362d526546 Pass canvas to gr_disk 2016-12-29 03:27:13 +00:00
Kp acd309099b Pass canvas to gr_ucircle 2016-12-29 03:27:13 +00:00
Kp 08d0aa9b59 Pass canvas to gr_bitmap 2016-12-29 03:27:13 +00:00
Kp d7cd6d17c3 Pass canvas to gr_ubitmapm 2016-12-29 03:27:13 +00:00
Kp 6ab3b18657 Pass canvas to gr_ubitmap 2016-12-29 03:27:12 +00:00
Kp 99f5cfbb10 Pass canvas to ogl_ubitmapm_cs 2016-12-29 03:27:12 +00:00
Kp 1e1272fcf2 Cache temporaries in show_briefing_bitmap
Avoid recomputing the same width/height expressions.  This saves ~20
instructions and ~100 bytes on x86_64-pc-linux-gnu.
2016-12-29 03:27:11 +00:00
Kp 1fa5aef9ac Pass canvas to gr_line 2016-12-29 03:27:10 +00:00
Kp 7439949595 Pass canvas to gr_uline 2016-12-29 03:27:10 +00:00
Kp ef06aa089a Pass canvas to gr_pixel 2016-12-29 03:27:09 +00:00
Kp 1ed06c91b7 Pass canvas to ogl_ulinec 2016-12-29 03:27:09 +00:00
Kp fee4346dc1 Pass canvas to ogl_urect 2016-12-29 03:27:08 +00:00
Kp 290cb6e7c0 Use array<> for ogl_urect float arrays 2016-12-29 03:27:08 +00:00
Kp 29c912d2da Fid -Wold-style-cast warning in SDL-only code 2016-12-29 03:27:08 +00:00
zico a10d9e0bba Prevent access of potentially uninitialized r.value in nm_trigger_radio_button() 2016-12-28 20:36:00 +01:00
zico 3672bbd1f2 Made show_briefing_bitmap() properly consider HIRESMODE (i.e. Mac data), using scaling logic from show_animated_bitmap(). 2016-12-28 16:28:08 +01:00
zico 03f5cbf3a4 Fixed issue in frame_animation_angle(): Due to deltaang.*a being usually small values and frametime getting smaller with higher FPS, the usual use of fixmul will have scaled_delta_angle result in 0 way too often and long, making the robot animation run circles around itself. So multiply deltaang by DELTA_ANG_SCALE when passed to fixmul. 2016-12-28 15:26:33 +01:00
Kp 879070f814 Fix uninitialized value usage during init_player_stats_new_ship
init_player_stats_new_ship used select_primary_weapon and
select_secondary_weapon to assign the player's weapons.  However, those
functions read the current weapon and jumped according to its value.  A
new ship has no defined value for current weapons, so the jump triggered
an uninitialized value warning from Valgrind.

Add new functions set_primary_weapon, set_secondary_weapon that work
like the previous select_* functions, but always take the path used
for weapons not equal, without checking.  This prevents the warnings
from Valgrind, as well as a theoretical risk of initializing the ship
improperly.
2016-12-25 00:33:25 +00:00
Kp fed011df94 Exclude OBJ_NONE objects from can_collide flags test 2016-12-25 00:33:24 +00:00
Kp 5d752e741d Factor out object_create_explosion_sub collision test
An 11-line if() test is unreadable.  Split it out into a helper.
2016-12-25 00:33:24 +00:00
Kp b05325d0ab Initialize lavafall_hiss_playing for each ship 2016-12-25 00:33:24 +00:00
Kp fa1f8488f0 Use uint8_t for sidenum 2016-12-24 22:44:08 +00:00
Kp e07f5072cb Fix inverted change_light test
An optimization meant to allow change_light to stop early caused it to
stop much too early, so it rarely did any work.  Flip the sense of the
test so it does not stop early.

Fixes: 2bd538f353 ("Sort delta light indices")
2016-12-24 18:12:18 +00:00
Kp 539629c14b Avoid leaking uninitialized bytes to the network 2016-12-24 18:12:17 +00:00
Kp 2ba300be8c Remove bogus demo messages
Demos do not record difficulty level or track hostages correctly.  Do
not show these fields in the demo pause dialog, since they reflect
the state of the player's last played game, not the state of the player
recording the demo.
2016-12-22 05:21:16 +00:00
Kp d085175cbd Scrub invalid primary textures at level load
Past releases, when rendering an invalid primary texture, would
Int3() and then reset the texture to zero.  Commit d767f7c changed the
logic to return without resetting the texture, since the reset seemed to
be unnecessary.  Unfortunately, it is necessary.  Some levels, including
those shipped with the retail game data, specify bogus primary textures
on some surfaces.  After d767f7c, rendering a surface with an invalid
primary texture causes the surface to be invisible, even if it has a
valid secondary texture.

Remove the return statement added in d767f7c.  Extend
validate_segment_side to validate the primary texture on the tested
side.  When an invalid texture is found, reset it and log a diagnostic.
For built-in levels, log at level CON_VERBOSE since players cannot
readily fix the level.  For external levels, log at level CON_URGENT so
that level authors know to fix their level before releasing it.

Fixes: d767f7cd5e ("Pass vcsegptridx to render_face")
2016-12-22 05:21:16 +00:00
Kp 29b9c255fa Remove unnecessary FuelCenter operator- 2016-12-22 05:21:16 +00:00
Kp 10aa2e5106 Move some kconfig symbols into namespace dsx 2016-12-22 05:21:16 +00:00