Commit graph

94 commits

Author SHA1 Message Date
Kp b4e3d67725 Recompute guidebot index on game load
The index of the guidebot is set by loading the level data, and this is
usually sufficient.  However, if the user kills the guidebot, then uses
cheats to create a new one, the new guidebot will often have a different
index than the original guidebot.  If such a game is saved and then
reloaded, then after the reload, the computed guidebot index will be
reverted to the index of the original dead guidebot.  This causes
various problems, including potentially a crash.  Recompute the guidebot
index after loading the objects from the save file, so that it matches
the live guidebot.

Reported-by: GitInMotion <https://github.com/dxx-rebirth/dxx-rebirth/issues/713>
2023-05-14 18:41:36 +00:00
Kp 26d8c2881e Move compress_objects into #if DXX_USE_EDITOR
This is only called in the editor build, so exclude it from being built
in the non-editor build.
2023-05-14 18:41:36 +00:00
Kp e3553586c1 Use enum class for bitmap_index 2022-12-31 16:21:47 +00:00
Kp 6215ef8e06 Pass LevelSharedRobotInfoState to various functions that need it 2022-07-09 13:39:29 +00:00
Kp d6c43f56af Use enum class for gun_num_t 2022-07-09 13:39:29 +00:00
Kp fca59adb53 Split out creating OBJ_WEAPON objects 2022-07-02 18:10:45 +00:00
Kp 9816475706 Pass Object array to object_goto_next_viewer 2022-06-05 17:44:53 +00:00
Kp e180375f97 Pass GameBitmaps to draw_object_blob 2022-06-05 17:44:52 +00:00
Kp 6e2ed26659 Pass object to init_player_object 2022-06-05 17:44:52 +00:00
Kp 9f207daf95 Pass player object to reset_player_object 2022-06-05 17:44:52 +00:00
Kp f79baf722c Move static obj_* functions into anonymous namespace 2022-04-17 22:27:19 +00:00
Kp da49df78f7 Split drop_powerup to return either an object id or a success code
If exactly one object will always be needed, use an overload that
returns the object id.  Otherwise, use an overload that only returns
whether at least one object was created.  This simplifies callers that
always request exactly one object.
2022-02-06 16:12:31 +00:00
Kp d5e520bc7b Fix failure to send robot creation message if one creation fails
If at least two robots would be dropped, and a drop failed, then
object_create_robot_egg would report failure to the caller.  Callers
that check the return code treat any failure as total failure, but that
is not guaranteed to be true.  If the game successfully dropped one
robot and failed when dropping a second, then the caller would receive a
status of failure.

Fix this by returning a status of whether at least one object was
created.
2022-02-06 16:12:31 +00:00
Kp 6cc788e1cd Pass object_base& to object_create_robot_egg 2022-02-05 13:30:56 +00:00
Kp fedb48613c Move object_rw to namespace dsx
It depends on types in dsx.
2022-01-09 15:25:42 +00:00
Kp 38cddb0289 Use enum class for object movement_type 2020-08-10 03:45:13 +00:00
Kp 9e2543ecbf Use enum class for object control_type 2020-08-06 03:47:56 +00:00
Kp 4ef247e494 Use enum class for collision_result values 2020-08-06 03:47:56 +00:00
Kp ec6a78c481 Use enum class for marker index types 2020-07-22 03:11:18 +00:00
Kp 399aee8d49 Use dedicated type for object render_type
Check conversions.  On invalid input, coerce to RT_NONE and print a
warning.
2020-05-02 21:18:43 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 3170b11997 Modernize typedefs for std::array types
Use `using x = y;` instead of `typedef y x;`.
2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 5fa8c06914 Add experimental support for autosaves
Set autosave interval to 10 minutes, unless specified in the player's
configuration file.  Players can change the autosave to 0 minutes to
disable it.
2020-04-19 20:47:07 +00:00
Kp dfae1c7203 Split object_move_all for game/endlevel
endlevel wants to freeze the console player's last in-mine position.
Instead of copying the position out and back, refactor the flow to let
endlevel skip the update of the position.
2019-12-22 05:34:08 +00:00
Kp 30091902af Simplify valptridx types where possible
Switch valptridx::ptr to a reference type.
Switch valptridx::ptridx to a reference type or to ::ptr.

Fix up uses of operator-> accordingly.
2019-12-22 05:34:08 +00:00
Kp 9bafdc9078 Move Death_sequence_aborted to d_game_view_unique_state 2019-08-15 01:34:22 +00:00
Kp 0d9e032c60 Factor out some multi net_destroy_controlcen usage 2019-08-15 01:34:22 +00:00
Kp bfeca84bb8 Change object::signature to be a generation counter
This removes the need to walk all objects when creating a new one, since
each object can have a private generation counter, unaware of other
objects.  For compatibility with demos, mix in the object's index when
writing the signature value.
2019-07-07 22:00:02 +00:00
Kp bfcff2cefe Fix crash loading guidebot with unreachable goal
Remove use of object_guidebot_cannot_reach and instead track the
reachability of the object as a separate flag.  This allows the game to
remember when an object was found, but unreachable.  Previously, it
would store only that some unreachable object was found.  Now, it stores
the index of the unreachable object.  This extra information is not used
yet.

Reported-by: Dainslaif <https://github.com/dxx-rebirth/dxx-rebirth/issues/421>
Fixes: c3cead4319 ("Move Escort_goal_index to d_unique_buddy_state")
2019-05-26 00:44:37 +00:00
Kp cc248602fd Track headlights in d_level_unique_light_state 2019-04-13 18:00:07 +00:00
Kp 8764cad457 Use unsigned in more prototypes 2019-03-03 00:31:09 +00:00
Kp 58d59da9d2 Move Escort_goal_object to d_unique_buddy_state 2019-03-03 00:31:08 +00:00
Kp 040de5b10e Rename ObjectState to LevelUniqueObjectState for consistency 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 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 e9c9943470 Pass context to update_object_seg 2018-10-08 03:58:48 +00:00
Kp 3b168b38fd Make Viewer const object *
Viewing should not change anything.
2018-09-25 03:44:09 +00:00
Kp f7ad4d9b1a Pass segments to find_point_seg 2018-09-19 02:13:30 +00:00
Kp c2944896de Pass vertex factory to create_shortpos_native 2018-09-19 02:13:30 +00:00
Kp c4cb930f8e Pass ObjectState to obj_delete 2018-09-09 01:00:39 +00:00
Kp 30a83eec41 Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
Kp 18af84a0ab Remove __attribute__((packed)) from quaternionpos
Packed structures cannot be passed by reference, may fail on
alignment-strict architectures, and are bad for performance even on
alignment-tolerant architectures.  Using them for anything other than an
abstract layout declaration is a mistake.  Remove
__attribute__((packed)).
2018-03-31 21:53:01 +00:00
Kp ad8fd0f871 Pass valptridx factories to obj_relink 2018-03-12 03:43:46 +00:00
Kp e2b24b37d5 Pass d_level_object_state to reset_objects 2018-03-12 03:43:46 +00:00
Kp 44bba9d2a2 Pass valptridx object factory to obj_link 2018-03-12 03:43:46 +00:00
Kp daf87ac23a Pass valptridx object factory to obj_link_unchecked 2018-03-12 03:43:46 +00:00
Kp 0db5a2104e Pass valptridx factories to obj_unlink 2018-03-12 03:43:46 +00:00
Kp d09478d88c Pass Objects to obj_attach 2018-03-12 03:43:46 +00:00
Kp 0067e33a8c Pass ObjectState to special_reset_objects 2018-03-12 03:43:46 +00:00