Commit graph

4052 commits

Author SHA1 Message Date
Chris Taylor 479f5ed584 Fix 'format specifies type 'unsigned short' but the argument has type 'unsigned char'' warning
Replace %hu with %hhu for capped in call to con_printf in powerup_cap_state::cap_secondary_ammo.
2017-01-13 12:32:46 +08:00
Chris Taylor 6ecccd3491 Fix 'equality comparison with extraneous parentheses' warning
Remove offending parentheses around call to multi_i_am_master() in net_udp_leave_game().
2017-01-13 12:30:57 +08:00
Kp 5201218e20 Fix D1 build
Commit 4cc801f changed `object_move_one` to return `window_event_result`
instead of `void` and added a default return value at the bottom.
However, it added the value inside a `#if D2` block, so the D1 build now
fails with:

    similar/main/object.cpp: In function 'dcx::window_event_result d1x::object_move_one(d1x::vobjptridx_t)':
    similar/main/object.cpp:1627:7: error: variable 'result' set but not used [-Werror=unused-but-set-variable]
    similar/main/object.cpp:1866:1: error: control reaches end of non-void function [-Werror=return-type]

Move the return statement out of the conditional block to fix both these
errors.

Fixes: 4cc801f42f ("Remove calls to window_close(Game_wind) when game finished or over")
2017-01-13 03:19:19 +00:00
Chris Taylor 0c5a000328 Remove call to window_close(Game_wind) when a network event tells us to end the game
In multi_do_frame(), replace call to window_close(Game_wind) with returning window_event_result::close whenever multi_quit_game is true. Only using this return value where multi_do_frame() is directly called by GameProcessFrame(). multi_quit_game will only be set back to 0 when a new multi game is started.

Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-10 14:10:39 +08:00
Chris Taylor a418f8caec Remove call to window_close(Game_wind) when multiplayer level syncing fails
Replace call to window_close(Game_wind) with returning window_event_result::close to game_handler. Applies to when there is a failure in net_udp_level_sync(). Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-10 13:02:59 +08:00
Chris Taylor 2ecc4c4a07 Remove call to window_close(Game_wind) when stopping demo playback
Replace call to window_close(Game_wind) with returning window_event_result::close to game_handler. Applies to whenever newdemo_stop_playback() is called. Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-09 19:09:34 +08:00
kreatordxx d10896f116 Merge pull request #297 from dxx-rebirth/newdemo_no_space
Fix crash when ran out of disk space when writing demo
2017-01-09 10:05:25 +08:00
kreatordxx f590ec45c6 Merge pull request #298 from dxx-rebirth/no_game_wind_close
Remove calls to window_close(Game_wind)
2017-01-09 09:32:24 +08:00
Chris Taylor 6e2c3c61b1 Format LevelError text better for the case of an exit that is both regular and secret 2017-01-09 09:30:53 +08:00
Chris Taylor 0daf28e787 Small efficiency improvement for a return value in do_endlevel_frame() 2017-01-09 09:26:32 +08:00
Chris Taylor 06968db4bc Fix crash when ran out of disk space when writing demo
Check for nd_record_v_no_space in _newdemo_write.
2017-01-09 09:15:51 +08:00
Kp 0d5d7a01ad Fold PHYSFS_write calls for Automap_visited 2017-01-08 22:32:01 +00:00
Kp 7b08144aee Poison unused exploding walls 2017-01-08 22:32:00 +00:00
Kp d289fec43b Update hitobj_list in multi_object_rw_to_object 2017-01-08 22:32:00 +00:00
Kp 94716dfab5 Scrub OBJ_NONE objects from multiplayer peers 2017-01-08 22:32:00 +00:00
Kp 7fafc22cca Poison multiplayer object_rw without making it unreadable
`struct object_rw` is poisoned prior to initializing and sending it.
However, some fields are legitimately unininitialized (other than their
memset or poison value) at send time.  Add and use a poison variant that
can clear those fields, without marking them unreadable.
2017-01-08 22:32:00 +00:00
Kp 5da784dbed Pass canvas to gr_{,u}string 2017-01-08 22:32:00 +00:00
Kp 1ef6b9d5bc Pass font to gr_get_string_size 2017-01-08 22:31:59 +00:00
Kp 0480ba8030 Pass canvas to gr_string(int,int,const char*,int,int) 2017-01-08 22:31:59 +00:00
Kp 6e8c3b3357 Pass canvas to gr_internal_string_clipped{,_m} 2017-01-08 22:31:59 +00:00
Kp c291873041 Pass canvas to gr_internal_string_clipped_template 2017-01-08 22:31:59 +00:00
Kp 9dbcbc51ce Pass canvas to gr_ustring_mono 2017-01-08 22:31:59 +00:00
Kp 83e86707aa Pass canvas to gr_internal_string0{,m} 2017-01-08 22:31:59 +00:00
Kp f0ee7af1aa Pass canvas to gr_internal_string0_template 2017-01-08 22:31:58 +00:00
Kp f58b66173f Pass canvas to gr_internal_color_string 2017-01-08 22:31:58 +00:00
Kp 8d1bd87b33 Pass canvas to ogl_internal_string 2017-01-08 22:31:58 +00:00
Kp 4b2102f41a Factor out show_framerate x/y for gr_printf 2017-01-08 22:31:58 +00: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