Commit graph

3828 commits

Author SHA1 Message Date
Kp c31424dd3b Pass player_info to do_invulnerable_stuff 2016-10-28 03:39:41 +00:00
Kp c8801f73ad Fold piggy_new_pigfile calls to gr_remap_bitmap_good 2016-10-28 03:39:40 +00:00
Kp 1c5718ba11 Fold read_extra_bitmap_iff call to gr_remap_bitmap_good 2016-10-28 03:39:40 +00:00
Kp 902e242194 Remove redundant store in kconfig_read_controls
Adjust the value as a local, then write it back when finished.
2016-10-28 03:39:40 +00: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 c351588bba Remove use of window_exists in newmenu_handler
Replace with a disabled check for window_event_result::deleted, which will be enabled when all newmenu subfunctions return a window_event_result. There are currently no instances of a subfunction closing the window itself (which is preferred).
2016-10-28 08:22:36 +08:00
Chris Taylor bd3078b672 Make wall_dialog_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on. Also remove the 'likely' branch prediction macro from close_wall_window because close_wall_window will only be called outside of the wall dialog's handler (to open a different dialog or close the editor).
2016-10-27 18:07:57 +08:00
Chris Taylor fd3e60be54 Make object_dialog_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:52:50 +08:00
Chris Taylor acc595ba16 Make robot_dialog_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:51:00 +08:00
Chris Taylor 5322ce4a0f Make editor_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:48:23 +08:00
Chris Taylor dc7a288539 Make trigger_dialog_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:34:41 +08:00
Chris Taylor 06632e73e8 Make centers_dialog_handler return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:15:31 +08:00
Chris Taylor 2d587de8dc Make call_default_handler return a window_event_result
Make call_default_handler return a window_event_result to inform the event system in future, particularly if a window was closed.
2016-10-27 16:36:24 +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
Chris Taylor 2613545712 Return window_event_result::deleted if Game_wind closed
Return window_event_result::deleted if Game_wind was closed somewhere in response to an event handled by game_handler, so in future the event code can use that instead of window_exists to avoid tripping up.
2016-10-27 12:24:02 +08:00
Kp 8b62870245 Fix clang build of udp_tracker_reqgames
gcc permits strlen("") in a constexpr context, but clang prohibits it.
Kreator reports that this broke the OS X build.  Use sizeof(), which
produces approximately the same result and works in both compilers.

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/251>
Fixes: 63ca86698e ("Added communication for tracker written by A Future Pilot")
2016-10-26 01:58:05 +00:00
Kp c21e1e22e0 Refactor write_key_text
Kreator reports that clang warns that `i` may be uninitialized in
write_key_text.  This is a valid warning, but gcc does not generate it.
Refactor write_key_text to eliminate the warning and simplify the code.

Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/252>
Fixes: 20776fcfbc ("Use range_for/vcwallptr for write_key_text")
2016-10-26 01:58:04 +00:00
Kp 791af89351 Use return type auto-deduction in socket call wrappers 2016-10-25 01:44:35 +00:00
Kp a3aa3da3d5 Switch socket_array_dispatch_t to match only array<uint8_t, N> 2016-10-25 01:44:35 +00:00
Kp 692dfffe58 Use array<> for net_udp_noloss_validate_mdata buf 2016-10-25 01:44:35 +00:00
Kp d7087cc59d Convert net_udp_send_pdata to array<> 2016-10-23 20:33:14 +00:00
Kp f14cbd1c00 Use minimal size buffer for net_udp_send_endlevel_packet guest buffer 2016-10-23 20:33:14 +00:00
Kp 4b539c0545 Use minimal size buffer for net_udp_send_endlevel_packet host buffer 2016-10-23 20:33:14 +00:00
Kp ffa53eb3c4 Page in textures before caching them
Some custom levels attempt to use texture overrides that reference
textures that are not yet paged in.  It is not legal to access the data
of a paged-out texture, but ogl_loadbmtexture_f attempted to access it
anyway, causing a crash.  Page in the texture before calling
ogl_loadbmtexture_f.  Old versions of the engine would have cached
garbage data when this happened.

Reported-by: kreator <https://github.com/dxx-rebirth/dxx-rebirth/issues/228>
Fixes: 3c20c24ac0 ("Disable piggy_bitmap_page_out_all")
2016-10-23 20:33:14 +00:00
Kp 49ff176e12 Protect RAIIsocket::s 2016-10-23 20:33:14 +00:00
Kp a0d614e6b0 Use clamp_symmetric_value in kconfig_read_controls
Avoid open-coding the test.
2016-10-21 02:16:48 +00:00
Kp a8a41aa2ff Move git version into Python class 2016-10-21 02:16:47 +00:00
Kp ddc16dac8b Use range_for in multi_check_for_killgoal_winner 2016-10-21 02:16:47 +00:00
Kp 5c872830a1 Remove unused message MULTI_KILL 2016-10-21 02:16:47 +00:00
Kp cca7fc7848 Revert high-score cool_saying size
Mako88 reports that e335cdacb3 broke
reading historical high score files.

Code analysis shows that the size of the high score file must match the
size of struct all_scores, but this was not enforced anywhere.  Commit
e335cdacb3 changed the size of struct
all_scores.  Restore it to its previous size, and add a static_assert to
break the build if anyone tries to change it again.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/241>
Fixes: e335cdacb3 ("Reverted 81d7db279b and rather removed the terminator byte from string length in nm_set_item_input(). This also fixes possible 9 character length for pilot callsigns. Had to fix up COOL_SAYING_LEN as it was not considering the termintor but considering the original D2 source, this was a mess to begin with (def = 50, text string = 60, input field len = 45). Made score saying 50 characters as this seems to be the maximum witdth without overlapping.")
2016-10-20 02:11:39 +00:00
Kp 8341c88300 Move move_towards_vector division into helper
Mako88 reports that 2a19da88d4 changed
robot movement.  That commit reordered the operations in a way that
tends to truncate small values prematurely.  Restore the original order
of operations.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/247>
Fixes: 2a19da88d4 ("Pass object_base &to move_towards_vector")
2016-10-20 02:11:39 +00:00
Kp d955eda96f Fix fullscreen checkbox handling
Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/224>
Fixes: 7128141c55 ("Use enum for newmenu item type")
2016-10-18 02:26:30 +00:00
Kp 27d0a79acd Factor out reporting errors caused by bad levels 2016-10-17 03:49:32 +00:00
Kp c006d068d8 Restructure PHYSFSX read helpers into template function 2016-10-17 03:49:31 +00:00
Kp 779738fa80 Add special handling for multi_do_reappear get_ghost_id
multi_do_reappear is overloaded to be used both on ghosts and on live
players.  This causes a diagnostic because the *_id checks expect
exactly one type: either test for ghost or test for player, but not test
for and accept both.  Open code the type check to support both.
2016-10-15 21:17:02 +00:00
Kp e4e74fe09c Pass vcsegptridx to pae_aux 2016-10-15 21:17:02 +00:00
Kp 2d54a0c57d Fix infinite recursion when newmenu_scroll has only one valid item 2016-10-15 17:51:47 +00:00
Kp aae5279bfd Initialize Stuck_objects for D1 2016-10-15 00:53:22 +00:00
Kp f46b5a0210 Pass player_info to hud_show_cloak_invuln 2016-10-15 00:53:22 +00:00
Kp 2d4936b6ef Pass player_info to hud_show_keys 2016-10-15 00:53:22 +00:00
Kp bf11f9f63f Pass player_info to hud_get_primary_weapon_fontcolor 2016-10-15 00:53:21 +00:00
Kp 1a3939469b Pass player_info to hud_show_weapons 2016-10-15 00:53:21 +00:00
Kp 11754d6163 Pass player_info to hud_show_afterburner 2016-10-15 00:53:21 +00:00
Kp 3a52fe0952 Pass player_info to hud_show_energy 2016-10-15 00:53:21 +00:00
Kp 6a885069b0 Remove spurious resets of player::net_killed_total 2016-10-15 00:53:21 +00:00
Kp 01f2932824 Pass grs_canvas &to window_create 2016-10-15 00:53:20 +00:00
Kp ad35460eb0 Pass player_info to add_bonus_points_to_score 2016-10-15 00:53:20 +00:00
Kp 25f5fc231a Pass player_info to add_points_to_score 2016-10-15 00:53:19 +00:00
Kp 248dd5c309 Move player::hostages_rescued_total to player_info 2016-10-15 00:53:19 +00:00
Kp f21abc94cb Move player::hostages_on_board to player_info 2016-10-15 00:53:19 +00:00
Kp e721fc56da Move player::last_score to player_info 2016-10-15 00:53:19 +00:00
Kp ecb91955ae Move player::score to player_info 2016-10-15 00:53:19 +00:00
Kp ea1312beb3 Use trigger_none instead of literal -1 in load_game_data 2016-10-15 00:53:18 +00:00
Kp c1d9c40931 Convert various valptridx accesses to use factory functions 2016-10-15 00:53:18 +00:00
Kp 2393b1e8c9 Use array<> in set_segment_depths 2016-10-15 00:53:18 +00:00
Kp 647991e203 Use range_for in validate_segment_all 2016-10-15 00:53:18 +00:00
Kp 599bf21b7d Remove paranoid debug-only object checks
These have never been observed to trigger.  Memory corruption prevention
is much better than it was when these were written.
2016-10-15 00:53:17 +00:00
Kp 5c83891c8f Remove incomplete wall validation in load_game_data 2016-10-15 00:53:17 +00:00
Kp c2e6f06b86 Use std::move to compact walls 2016-10-15 00:53:17 +00:00
Kp 61a53fb875 Use range_for in ogl_cache_level_textures 2016-10-15 00:53:17 +00:00
Kp 3eceaca1b6 Cache temporaries when processing level mutation hack 2016-10-15 00:53:17 +00:00
Kp 6515308a59 Simplify loop iteration in copy_group_walls 2016-10-15 00:53:17 +00:00
Kp a80ed36f0a Use range_for/vsegptr for wall_restore_all 2016-10-15 00:53:16 +00:00
Kp 4f8f27bdf6 Use range_for/vctrgptridx for write_trigger_text 2016-10-15 00:53:16 +00:00
Kp 4597ecf1f0 Use range_for/vcwallptridx for write_wall_text 2016-10-15 00:53:16 +00:00
Kp 20776fcfbc Use range_for/vcwallptr for write_key_text 2016-10-15 00:53:16 +00:00
Kp ba77e645fa Use range_for to iterate segment checksum 2016-10-15 00:53:16 +00:00
Kp 24b97e7058 Fold fspacx/fspacy calls 2016-10-15 00:53:16 +00:00
Kp f97639204e Fold kmatrix fontcolor lookup 2016-10-15 00:53:16 +00:00
Kp e05603b0d7 Fold kconfig_draw gr_string label calls 2016-10-15 00:53:15 +00:00
Kp 94202ff782 Fold D1 draw_automap calls to gr_string 2016-10-15 00:53:15 +00:00
Kp 88c73c010a Preserve type information on font-scaled floats 2016-10-15 00:53:15 +00:00
Kp 21f8aec44d Remove unnecessary gr_set_fontcolor in kmatrix_draw_coop_names 2016-10-15 00:53:15 +00:00
Kp 71b87bceee Factor out kmatrix_redraw_coop calls to gr_find_closest_color 2016-10-15 00:53:15 +00:00
Kp 5873889b8b Factor out common parts of add_points_to_score 2016-10-15 00:53:15 +00:00
Kp f84de25e6b Expand kmatrix_draw_coop_item inline
kmatrix_draw_coop_item computes various values that are always the same
for every iteration of the calling loop.  Expand it inline in its one
caller so that the caller can cache those values.
2016-10-15 00:53:14 +00:00
Kp 8327d85c76 Remove unused get_multi_endlevel_poll1
The only caller for get_multi_endlevel_poll1 was DoEndLevelScoreGlitz,
which only called it on an unreachable path.  That path is now gone, so
remove get_multi_endlevel_poll1.
2016-10-15 00:53:14 +00:00
Kp e4e1799b57 Propagate DoEndLevelScoreGlitz argument network
All callers pass 0.  Remove the argument and update the logic that
tested it.
2016-10-15 00:53:14 +00:00
Kp fa620d5011 Make DoEndLevelScoreGlitz static 2016-10-15 00:53:14 +00:00
Kp 1d563a9e03 Fix memory corruption during tracker initialization
Commit 63ca866 reduced the number of elements in UDP_Socket[] from (2 +
tracker) to (2), but added a write to UDP_Socket[2], which is now out of
bounds.  Fortunately, UDP_Socket[2] is never read.  Remove the
initialization of it.

Fixes: 63ca86698e ("Added communication for tracker written by A Future Pilot")
2016-10-15 00:53:14 +00:00
Kp deeb7def6e Reuse zeroed *_rw structure during save 2016-10-13 03:14:11 +00:00
Kp 7a18f60a94 Replace nd_read_short casts with an overload for uint16_t
Casting the type of the input overrides useful compiler checks.  Remove
all such casts and add an overload for uint16_t.
2016-10-12 02:16:29 +00:00
Kp 675fff5fec Replace nd_read_byte casts with an overload for uint8_t
Casting the type of the input overrides useful compiler checks.  Remove
all such casts and add an overload for uint8_t.
2016-10-12 02:16:29 +00:00
zico 63ca86698e Added communication for tracker written by A Future Pilot 2016-10-10 18:19:56 +02:00
zico 407805be42 Restored proper scaling of Min_trackable_dot by adding new function get_scaled_min_trackable_dot(). This was previously a fixed defintion based on Descent 1's result of Min_trackable_dot's scaling if FrameTime < F1_0/16 which did not properly reflect the intended result of Descent 2 nor did it properly align to different FrameTime/HOMING_TURN_RATE settings. get_scaled_min_trackable_dot() will scale the result accordingly for whatever fixed or variable time setting is given and respecting each game's individual scaling. 2016-10-10 15:37:25 +02:00
zico 9cab9e58c6 Fixed regression from e0785251c4 making the homing indicator go haywire if built without NEWHOMER defined 2016-10-10 14:23:45 +02: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 1af65071d7 Remove unused EVENT_WINDOW_CLOSED
Every callee that recognized EVENT_WINDOW_CLOSED did so only to
explicitly ignore it.  Remove the code to send it and all sites that
ignored it.
2016-10-10 00:25:15 +00:00
Kp b02375bfbd Rename WORDS_NEED_ALIGNMENT to DXX_WORDS_NEED_ALIGNMENT
Rename symbol WORDS_NEED_ALIGNMENT to DXX_WORDS_NEED_ALIGNMENT to show that it is a DXX
symbol, not one inherited from a library.

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

git grep -wl WORDS_NEED_ALIGNMENT -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(WORDS_NEED_ALIGNMENT\)\>/#if DXX_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(WORDS_NEED_ALIGNMENT\))/#\1if \2DXX_\3/' -e 's/^\s*#ifndef \(WORDS_NEED_ALIGNMENT\)\>/#if !DXX_\1/'
2016-10-09 17:35:03 +00:00
Kp 3cc73ee69d Fix similar/3d/interp.cpp useless+old-style casts in DXX_WORDS_BIGENDIAN path 2016-10-09 17:35:02 +00:00
Kp 8ebe98df6b Fix test for DXX_USE_UDP, DXX_USE_TRACKER
Fixes: 435aa5a020 ("Move USE_UDP to dxxsconf.h; rename to DXX_USE_UDP")
Fixes: 7c8c2b5aa4 ("Move USE_TRACKER to dxxsconf.h; rename to DXX_USE_TRACKER")
2016-10-08 23:24:22 +00: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
Kp 65de22e4be Replace Int3 with con_printf(CON_URGENT) when loading bogus trigger 2016-10-08 23:24:22 +00:00
Kp af09257e2d Blank out most of object_rw when saving OBJ_NONE objects 2016-10-08 23:24:21 +00:00
Kp 5114b8f8b6 Fix object corruption loading save game
Saved games dump robot ai_local state for all objects, regardless of
whether the object is a robot.  Loading a game restored all ai_local
values, regardless of whether the object was a robot on restore.  This
caused memory corruption in objects that were not robots when the
`ctype.`_T_ for that object was large enough to overlap
`ctype.ai_info.ail`.

Fix this by loading the ai_local into a junk buffer when the object is
not a robot.  It would be better to skip over the bogus ai_local
entirely, but the structure of ai_local_read_swap makes that difficult.
Use the easy fix for now.
2016-10-08 23:24:21 +00:00
Kp 03dbc96103 Switch DXX_HAVE_POISON to 0/1 instead of undef/defined 2016-10-08 23:24:21 +00:00
Kp 1d09ca32ad Remove spurious 'u' after DXX_PRI_size_type uses 2016-10-08 18:02:34 +00:00
Kp d6f48dbd91 Prevent crash when level specifies invalid wall number
Kreator reports that "Pyramids of Luxoran" crashes due to a valptridx
sanity check.  The level incorrectly attempts to open a wall on a
segment/side which has no wall.

Add an error check and a con_printf suggesting that the level author
needs to fix the invalid trigger.
2016-10-08 18:02:34 +00:00
Kp 31d2b5cfb2 Use correct get_*_id function for collide_robot_and_weapon 2016-10-07 02:08:56 +00:00
Kp 635b3f54e3 Downgrade matcen diagnostic from exception to con_printf(CON_URGENT)
Kreator reports that a level from back when Descent was new fails the
test for bogus matcen triggers.  This level cannot be played when that
test throws an exception, so downgrade the exception to a CON_URGENT
message.  This will hopefully deter level authors from creating any new
levels with this problem, but will allow users to play existing levels.
2016-10-06 02:08:07 +00:00