Commit graph

4906 commits

Author SHA1 Message Date
Kp cc248602fd Track headlights in d_level_unique_light_state 2019-04-13 18:00:07 +00:00
Kp f69ba8ae82 Remove obsolete draw_vclip_object parameter lighted
It is always 0.
2019-04-13 18:00:07 +00:00
Kp 063bf29225 Enable -Wimplicit-fallthrough=5; fix resulting breaks
This enables using -Wimplicit-fallthrough with ccache+distcc, which
strip the fallthrough comments, but do not strip the attribute
annotationns.
2019-04-04 04:29:03 +00:00
Kp 9bed4f6d78 Fix bogus borders due to fill_n length/value transposition
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/415>
Fixes: 7bcbaae230 ("Tighten protection against grs_bitmap bm_data confusion")
2019-03-29 02:34:53 +00:00
Kp cd261a8135 Simplify handicap handling 2019-03-29 02:34:53 +00:00
Kp 87125c5053 Fix Descent 1 laser color
Descent 1 mangles colors during `g3_init_polygon_model`, so this must
not be called on polygons not designed for mangling.  Rearrange the
logic to allow Descent 1 to verify that polygon models are well-formed
without using the functions that mangle the colors.

Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/416>
2019-03-20 03:57:15 +00:00
Kp 3a6bfb8dd6 Reduce use of vcobjptr in newdemo 2019-03-16 04:35:32 +00:00
Kp 31859ff128 Fix Win32 build
Windows std::ptrdiff_t is `int` instead of `long` as it should be.
Expand the values out to `long` (which is the same size as `int` on
Win32!) before printing them.  This fixes format string warnings.

Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=857&pid=12555#pid12555>
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
2019-03-16 04:35:31 +00:00
Kp de53747452 Tighten test for color division by zero 2019-03-12 04:01:08 +00:00
Kp 3aed2a1719 Move Num_robot_centers to d_level_shared_robotcenter_state 2019-03-12 04:01:07 +00:00
Kp 73772f54b2 Open advanced sub-menus as submenus
Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/121>
2019-03-10 18:48:40 +00:00
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 42a2e3ab0b Avoid crash loading polymodels with invalid subcalls
Truncate the model at the first error.  This allows the level to load,
but makes some or all of the model invisible.
2019-03-06 05:03:48 +00:00
Kp 8f2bec3fde Remove bogus assertion in wall_hit_process
Fixes: 8764cad457 ("Use `unsigned` in more prototypes")
2019-03-06 05:03:48 +00:00
Kp 106de25617 Cache visited_segment_bitarray_t reference in apply_light_to_segment 2019-03-03 00:31:09 +00:00
Kp c992155ff1 Remove useless texture writeback in validate_segment_side 2019-03-03 00:31:09 +00:00
Kp 8764cad457 Use unsigned in more prototypes 2019-03-03 00:31:09 +00:00
Kp 3edef3c64b Move robot_create out of line
It is not used enough to justify its presence in a header.
2019-03-03 00:31:09 +00:00
Kp 699030606e Move Effects to d_level_unique_effects_clip_state 2019-03-03 00:31:09 +00:00
Kp 5b503c22a6 Move Escort_last_path_created to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 7e61451792 Move Last_time_buddy_gave_hint to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp 7577a3e408 Move Escort_special_goal to d_unique_buddy_state 2019-03-03 00:31:09 +00:00
Kp bd1cce0cc3 Move Buddy_sorry_time to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp ee584f1f37 Move Last_buddy_polish_path_tick to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp b34e7bae24 Move Buddy_gave_hint_count to d_unique_buddy_state
Fix original bug that buddy was limited to 5 hints per program run, not
5 per boss as it probably should have been.

Due to savegame format limitations, this still is not right.  Reloading
the game should restore Buddy_gave_hint_count to its value at save time,
but will not.
2019-03-03 00:31:08 +00:00
Kp 58d59da9d2 Move Escort_goal_object to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp c3cead4319 Move Escort_goal_index to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp c02bee26d6 Move Buddy_allowed_to_talk to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 420464549b Move Buddy_objnum to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 1008ab397e Move Objects to d_level_unique_object_state 2019-03-03 00:31:08 +00:00
Kp a36eb1d52c Only use update_laser_weapon_info for quad laser change
Regular laser level changes are already tracked and handled separately.
2019-03-03 00:31:08 +00:00
Kp 5d99ec361d Simplify copy_defaults_to_robot
Write the shields once at the end.
2019-03-03 00:31:07 +00:00
Kp fec16daca4 Generate unique starfield per level 2019-02-02 18:36:39 +00:00
Kp 7bcbaae230 Tighten protection against grs_bitmap bm_data confusion
Bitmaps based on grs_main_bitmap own their data.  Bitmaps based on
grs_bitmap do not.  Adjust prototypes to prevent initializing a
grs_main_bitmap with data it will not own.
2019-02-02 18:36:39 +00:00
Kp 8dcf4f99e0 Suppress cooperative start report if not multiplayer coop
The value is only correct when the game is cooperative multiplayer.
Hide it when it would be incorrect.
2019-02-02 18:36:39 +00:00
Kp 92fdacfb60 Simplify do_cheat_menu
Reduce redundant player object lookups.
2019-02-02 18:36:39 +00:00
Kp ad6b857cf2 Move most laser_info fields to dcx 2019-02-02 18:36:39 +00:00
Kp 1037b2c296 Flip sense of boss_intersects_wall
This saves a boolean negation passing the result up.
2019-02-02 18:36:39 +00:00
Kp 12403a78f7 Pass vcvertptr to sphere_intersects_wall 2019-02-02 18:36:39 +00:00
Kp ffb5e8821c Flatten use of sphere_intersects_wall 2019-02-02 18:36:39 +00:00
Kp d7e85e0cff Move Boss_gate_segs, Boss_teleport_segs to d_level_shared_boss_state 2019-02-02 18:36:39 +00:00
Kp 05244122bd Tighten input for set_segment_depths 2019-02-02 18:36:39 +00:00
Kp 20ecff4e4b Coerce RELEASE CT_SLEW to CT_NONE
Release builds should never have an object in CT_SLEW state.  If they
do, they abort the program.  This is an extreme reaction.  Change the
logic to report the problem, then coerce the type to CT_NONE and try to
resume operation.
2019-02-02 18:36:39 +00:00
Kp 84fa2cde4a Move Num_fuelcenters to d_level_unique_fuelcenter_state 2019-02-02 18:36:39 +00:00
Kp 943e0a8b5f Move Station to d_level_unique_fuelcenter_state 2019-02-02 18:36:39 +00:00
Kp 919580eaa9 Move RobotCenters to d_level_shared_robotcenter_state 2019-02-02 18:36:39 +00:00
Kp 7558795edd Fix sharepath confusion when building both targets
Processing sharepath in SConf is incorrect, because targets can share a
build directory (and therefore an SConf run), but not share a sharepath.
Move sharepath handling out of SConf.  Move DXX_USE_SHAREPATH handling
from CGameArg to GameArg, since one game can be built with a sharepath
while the other is built without.
2019-01-20 05:36:56 +00:00
Kp 0b319e2736 Print an error to the console when saving a game fails 2019-01-20 05:36:55 +00:00
Kp f8cafd2e65 Pass context to switch functions 2019-01-01 04:54:35 +00:00
Kp cd243ad844 Flatten some uses of trigger_wall_op 2019-01-01 04:54:35 +00:00
Kp e864542862 Work around broken clang -Wuninitialized warning
clang warns for using an uninitialized array during the
member-initialization-list, before the union constructor would have done
nothing.  clang permits using the still-uninitialized array in the
constructor body, after the union constructor has done nothing.
The same code is generated both before and after this commit, but the
old code produces a warning and the new code is silent.

```
similar/main/physics.cpp:282:5: error: field 'a' is uninitialized when used here [-Werror,-Wuninitialized]
        e(a.begin())
```
2019-01-01 04:54:35 +00:00
Kp 0080a8b7c7 Remove unused object_intersects_wall 2019-01-01 04:54:35 +00:00
Kp 0d107b3ab6 Fix gcc-4.9 build of similar/main/wall.cpp
gcc-4.9 rejects defining a class with a reference member and no
constructor, even though the use of the class uses a
brace-initialization expression to set the reference at construction
time.

Fixes: fa654324ad ("Pass context to wall.cpp:cwframe, cw_removal_predicate")
2018-12-31 04:46:16 +00:00
Kp a02ad8b164 Move Robot_joints to d_level_shared_robot_joint_state 2018-12-30 00:43:59 +00:00
Kp 1e549a02d4 Move Num_tmaps to d_level_unique_tmap_info_state 2018-12-30 00:43:59 +00:00
Kp 1f18db3c39 Move TmapInfo to d_level_unique_tmap_info_state 2018-12-30 00:43:59 +00:00
Kp ad8c80b0c4 Unify D1/D2 set_sound_sources eclip lookup 2018-12-30 00:43:59 +00:00
Kp 12c06e59aa Move N_robot_types into LevelSharedRobotInfoState 2018-12-30 00:43:59 +00:00
Kp e84a65edc6 Move Robot_info into LevelSharedRobotInfoState 2018-12-30 00:43:59 +00:00
Kp 03fe3a6696 Move Polygon_models into LevelSharedPolygonModelState 2018-12-30 00:43:59 +00:00
Kp 027cdaf568 Add debug log when sharepath is not used 2018-12-30 00:43:58 +00:00
Kp df0692bbea Move morph_objects into LevelUniqueMorphObjectState 2018-12-30 00:43:58 +00:00
Kp 4c7555216a Move Dynamic_light into LevelUniqueLightState 2018-12-30 00:43:58 +00:00
Kp 69c02efe1d Simplify g3s_codes 2018-12-30 00:43:58 +00:00
Kp 6ee28c3fe0 Move Triggers to d_level_unique_trigger_state 2018-12-30 00:43:58 +00:00
Kp bc78afc3a2 Remove write-only D1 trigger::link_num 2018-12-30 00:43:58 +00:00
Kp 4b125af449 Move ActiveDoors to d_level_unique_active_door_state 2018-12-30 00:43:58 +00:00
Kp 865bad8607 Move CloakingWalls to d_level_unique_cloaking_wall_state 2018-12-30 00:43:58 +00:00
Kp 9be3c8e2e8 Move Walls into d_level_unique_wall_state 2018-12-30 00:43:58 +00:00
Kp ac476be19b Pass wall &to blast_blastable_wall 2018-12-30 00:43:58 +00:00
Kp b3cd7588ef Move Delta_lights into d_level_shared_destructible_light_state 2018-12-30 00:43:58 +00:00
Kp 46644b4e91 Move Dl_indices into d_level_shared_destructible_light_state 2018-12-30 00:43:58 +00:00
Kp b08dac2971 Simplify handling warning function 2018-12-30 00:43:58 +00:00
Kp 25baa1fbba Remove visited2
It is debug-only, and has never triggered.
2018-12-30 00:43:58 +00:00
Kp 040de5b10e Rename ObjectState to LevelUniqueObjectState for consistency 2018-12-30 00:43:57 +00:00
Kp e7e4970ba5 Move Vertex_active out of global scope 2018-12-30 00:43:57 +00:00
Kp 1a5844e218 Move Vertices out of global scope 2018-12-30 00:43:57 +00:00
Kp 696551a966 Drop editor-specific object fixups
If these are needed, they need to be done at edit time, not when the
game starts.
2018-12-30 00:43:57 +00:00
Kp 5873ccb71e Pass vcvertptr as context 2018-12-30 00:43:57 +00:00
Kp 317c56d683 Expand Highest_vertex_index inline
This will make future conversions easier.
2018-12-30 00:43:57 +00:00
Kp 65225680c1 Move Num_vertices into d_level_shared_vertex_state 2018-12-30 00:43:57 +00:00
Kp f87c503618 Move Viewer_eye to local scope 2018-12-30 00:43:57 +00:00
Kp 045afc2c56 Prefer const shared_segment & over vcsegptr_t 2018-12-30 00:43:57 +00:00
Kp 2f537133e8 Use vcobjidx_t for fvi ignore_obj_list
Enforce that callers provide vcobjidx_t, instead of permitting any type
compatible with objnum_t.
2018-12-30 00:43:57 +00:00
Kp aa9e6da297 Pass Dl_indices as context 2018-12-30 00:43:57 +00:00
Kp 25ecf31816 Pass context to bng_process_segment 2018-12-30 00:43:57 +00:00
Kp 7ffe09dd46 Pass context to wall_close_door_ref 2018-12-30 00:43:57 +00:00
Kp a9a9d1f26a Move WALL_IS_DOORWAY out of line
Writing it inline causes wall.h to depend on segment.h.
2018-12-30 00:43:57 +00:00
Kp fa654324ad Pass context to wall.cpp:cwframe, cw_removal_predicate 2018-12-30 00:43:57 +00:00
Kp 992f35feb8 Expand Num_walls to Walls.get_count()
This will simplify propagating use of Walls.
2018-12-13 02:31:39 +00:00
Kp 9745236c7e Expand Num_triggers to Triggers.get_count()
This will simplify propagating use of Triggers.
2018-12-13 02:31:39 +00:00
Kp e8fdf2b669 Pass context to wall update functions 2018-12-13 02:31:38 +00:00
Kp d550cfe680 Remove struct side 2018-12-13 02:31:38 +00:00
Kp a54c323e45 Remove v16_segment definition
Support for v16_segment was declared broken in 6d0d68d188.  No one
objected.  Remove the definition to simplify future work.
2018-12-13 02:31:38 +00:00
Kp 706a704c6d Move unique_side to unique_segment 2018-12-13 02:31:38 +00:00
Kp 1d550ec0df Fix check_header_includes=1 build 2018-12-13 02:31:38 +00:00
Kp a705104e84 Check PHYSFS_init return value
PHYSFS_init is not guaranteed to succeed.  Using PHYSFS functions after
PHYSFS_init fails is likely to fail badly.  On Windows, failure may take
the form of a crash in ntdll.  Avoid this by exiting gracefully.
2018-12-08 23:36:18 +00:00
Kp d83972dfbb Hide game window when advancing a dead player to the next level
Commit 88b5e616a9 ("Replace calls to
window_set_visible in DoPlayerDead() with stop/start_time()") switched
from hiding the game window to only stopping time, and that only if
hiding the window would have stopped time.  In multiplayer, this allows
time to continue running.  This introduced a crash if the player dies
during the mine countdown.  When the player dies, the game checks if the
reactor has been destroyed.  If so, the game immediately advances to the
next level.  That advance will try to draw the game window if it is
visible.  When the window is drawn, if time is not stopped, then game
logic runs.  Some of that logic is not prepared to deal with the
inconsistent state present when a new level is only partially loaded.
That inconsistent state then causes a crash.  Call stack:

    #11 slew_frame () at similar/main/slew.cpp:152
    #12 in d2x::object_move_one () at similar/main/object.cpp:1758
    #13 in d2x::object_move_all () at similar/main/object.cpp:1956
    #14 in d2x::GameProcessFrame () at similar/main/game.cpp:1848
    #15 d2x::game_handler () at similar/main/game.cpp:1615
    #16 in dcx::window_send_event () at common/include/window.h:116
    #17 dcx::event_process () at common/arch/sdl/event.cpp:176
    #18 in newmenu_do2 () at similar/main/newmenu.cpp:498
    #19 in newmenu_do2<dcx::unused_newmenu_userdata_t> () at common/main/newmenu.h:184
    #20 newmenu_do<dcx::unused_newmenu_userdata_t const> () at common/main/newmenu.h:190
    #21 newmenu_do<1ul, dcx::unused_newmenu_userdata_t const> () at common/main/newmenu.h:196
    #22 net_udp_wait_for_requests () at similar/main/net_udp.cpp:4563
    #23 net_udp_level_sync () at similar/main/net_udp.cpp:4607
    #24 in multi_level_sync () at similar/main/multi.cpp:3458
    #25 in d2x::StartNewLevelSub () at similar/main/gameseq.cpp:1803
    #26 in d2x::StartNewLevel () at similar/main/gameseq.cpp:2018
    #27 in d2x::AdvanceLevel () at similar/main/gameseq.cpp:1648
    #28 in d2x::DoPlayerDead () at similar/main/gameseq.cpp:1721

The root cause of this is the layering violation:
- Killing the player can have the side effect of advancing the level
- Advancing the level can have the side effect of calling multiplayer code while the level data is in an inconsistent state
- Calling multiplayer code can cause the event system to redraw the game
- Redrawing the game can cause game logic to run

Hack around this by restoring the logic that hides the game window, so
that the window is not redrawn and the game logic is not run.  This does
not fix the layering problem, but prevents crashing affected users.  To
avoid undoing the feature from the breaking commit, hide the window only
when advancing to a new level, rather than unconditionally.  A player
advancing to a new level already lacks the move-at-cold-start capability
even on successfully escaping the mine, so no functionality is lost with
this change.  Players who are dead and do not advance to a new level
retain that capability.

Fixes: 88b5e616a9 ("Replace calls to window_set_visible in DoPlayerDead() with stop/start_time()")
Reported-by: Ninjared <https://forum.dxx-rebirth.com/showthread.php?tid=1097>
2018-12-08 19:16:01 +00:00
Kp 5a64ee5132 Add experimental support for larger cooperative games
- Raise the player limit to 8.
- Remove the logic that forces player counts up/down when switching
  between cooperative and deathmatch game modes.
- Add heuristics to add start positions for the extra players, since
  standard maps will not have the required number of starts.
2018-12-03 04:25:11 +00:00
Kp 35d91d389a Raise player life count storage from uint8_t to uint16_t
Reported-by: Buff Skeleton <https://forum.dxx-rebirth.com/showthread.php?tid=1096>
2018-12-01 01:58:37 +00:00