Commit graph

8863 commits

Author SHA1 Message Date
Chris Taylor 7845446e97 Disable window_exists function
This function is problematic in that another window could open with the same pointer value, causing a false positive to be returned.
2016-10-28 17:01:02 +08:00
Chris Taylor a62ca93498 Use a tracking variable for newmenu_do2 (and simpler) polling loop
Add 'track' method to dcx::window, which takes a bool and will set it to 'false' when the window closes. Use for newmenu_do2 and simpler newmenu_do's, since there's the possibility of another window without its own polling loop opening on top - meaning window_event_result::deleted would be returned for that window, not the one we're polling on.
2016-10-28 16:49:53 +08:00
Chris Taylor 54dbe586ee Check for window_event_result::deleted for do_briefing_screens 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:45:40 +08:00
Chris Taylor f1548e075e Check for window_event_result::deleted for show_title_screen 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:40:50 +08:00
Chris Taylor abd6d4a052 Check for window_event_result::deleted for RunMovie 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:37:38 +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 b2513ab9a0 Check for window_event_result::deleted for kmatrix_view 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:27:45 +08:00
Chris Taylor 1c8ad24da3 Check for window_event_result::deleted for ui_get_filename 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:25:25 +08:00
Chris Taylor 7f7047063a Check for window_event_result::deleted for credits 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:23:36 +08:00
Chris Taylor 21b0a7a48d Pass the most significant window_event_result to the caller of event_process
This will allow checking for window_event_result::deleted, instead of relying on window_exists, which could return a false positive if a new window was allocated with the same pointer value as the deleted one.
2016-10-28 14:43:20 +08:00
Chris Taylor e442bc6df5 Move window_event_result definition to event.h
The whole event system will need to know about window_event_result, because every event function will return one.
2016-10-28 13:32:24 +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 917f079f02 Check for window_event_result::deleted in ui_dialog_do_gadgets
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 08:40:50 +08:00
Chris Taylor 57585171de Check for window_event_result::deleted in event_process drawing 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 08:35:40 +08:00
Chris Taylor 9fbd86b0ce Check for window_event_result::deleted in event_send
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 08:27:02 +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 7b83123010 Pass window_event_result from a dialog handler all the way to the event system
In particular, window_event_result::deleted so the event system doesn't have to rely on the somewhat problematic window_exists. If a gadget is manipulated, it still returns at least window_event_result::handled so all the other gadgets in all the other windows don't have to be checked (that weren't already checked).
2016-10-27 19:42:48 +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 18062bf812 Make browser_handler (editor file opening dialog) return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:38:20 +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 9d7b7dc160 Make hostage_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:31:26 +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 66de1a1823 Make sure if a UI_DIALOG handler returns window_event_result::close or window_event_result::deleted, it will be passed onto window_send_event 2016-10-27 17:12:17 +08:00
Chris Taylor 787dbbbf72 Make window_send_event return window_event_result::deleted if window successfully closed
This will be used to inform the event system in future, in removing calls to window_exists. This applies to if the handler returns a window_event_result::close (which is and should be instead of the handler calling window_close itself, at least in most cases).
2016-10-27 16:51:21 +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