Commit graph

5917 commits

Author SHA1 Message Date
Kp 61c4d53ae6 Pass canvas to con_draw 2022-03-19 22:55:58 +00:00
Kp b3f250f3b6 Fix openable_door_on_near_path for side WLEFT
openable_door_on_near_path should return 0 for no door and any non-zero
value for door-found.  Commit 9fdf6005df changed the logic to return 0
for no door, and the side number value for door-found.  This is wrong,
since WLEFT has integer value 0, so the caller will interpret a return
of door-found, side=WLEFT as no-door-found.

Fixes: 9fdf6005df ("Convert ai_static::GOALSIDE to sidenum_t")
2022-02-27 14:23:53 +00:00
Kp f51755c2e6 Use enum class for MBTN_* constants 2022-02-27 14:23:53 +00:00
Kp 6863dd3581 Reduce lifetime of joy_axis
It is only needed for the duration of kconfig_end_loop.  Move it from
the global Controls to local scope.
2022-02-27 14:23:53 +00:00
Kp 197a9cbd98 Move joystick interpretation to happen after the event loop
If two or more events are delivered in the same loop, the previous
implementation would count joystick motion multiple times.  Fix this by
moving the joystick interpretation to occur once, after all the events
have been processed.
2022-02-27 14:23:53 +00:00
Kp 9464bdf2e4 Use enumerated_array for indexing player input controls 2022-02-27 14:23:53 +00:00
Kp 165d5b892b Rename pitch -> pitch_ud for consistency
Other code uses pitch_ud.  Rename the kconfig pitch to match.
2022-02-27 14:23:53 +00:00
Kp 43bdfac56a Store copy_sensitivity values as std::integral_constant
Lists of these objects are unrolled by a template parameter pack
regardless of whether they are type compatible, so keeping the types
compatible does not improve code size.  Store more precise types in the
structure, and avoid needing to store the constant values into a
structure at runtime.
2022-02-27 14:23:53 +00:00
Kp e7fd31e3a6 Check return value of find_connect_side in more places 2022-02-19 14:52:17 +00:00
Kp 52403f104f Use symbolic sidenum values in Edge_to_sides 2022-02-19 14:52:17 +00:00
Kp 5611319962 Qualify references to sidenum_t members 2022-02-19 14:52:17 +00:00
Kp 68268e9a1f Use sidenum_t in more places 2022-02-19 14:52:17 +00:00
Kp 91c9055c90 Simplify do_endlevel_flythrough computation of next distance 2022-02-19 14:52:17 +00:00
Kp 2fe9a16613 Use dedicated type for mask of segment side numbers 2022-02-19 14:52:17 +00:00
Kp 8c037b7c26 Split player start generation
Move some of the logic to a separate function to enable use of `return`
instead of a `break` from a composite loop.
2022-02-19 14:52:17 +00:00
Kp f2832e6248 Simplify _sockaddr IPv4/IPv6 logic
- Use std::integral_constant instead of a static function that returns
  the value
- Remove unused protocol_family
- Replace the enum with a typedef for the one type that the enum was
  used to define
2022-02-12 18:57:12 +00:00
Kp 8be306efa7 Use enum class for cockpit_mode_t 2022-02-12 18:57:12 +00:00
Kp f9c876572f Use std::move to compact Netgame.players on quit-joining 2022-02-12 18:57:12 +00:00
Kp 8fa4e6aa46 Simplify net_udp_welcome_player test order
Move the test for closed up, to avoid re-testing it.
2022-02-06 16:12:31 +00:00
Kp fe19f78fcd Simplify some uses of Highest_object_index 2022-02-06 16:12:31 +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 04f0507942 Fix memory corruption if spit_powerup fails to drop a weapon
If spit_powerup fails, it returns object_none.  object_none is not a
valid index for use by map_objnum_local_to_remote.
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 4a85b55865 Factor out drop_player_eggs creation of vulcan/gauss weapons 2022-02-06 16:12:31 +00:00
Kp 1a9fba804d Avoid repeated valptridx dereferences in multibot.cpp 2022-02-05 13:30:56 +00:00
Kp 1ad3377a83 Pass context to start_boss_death_sequence 2022-02-05 13:30:56 +00:00
Kp 29d6072f60 Pass context to drop_stolen_items 2022-02-05 13:30:56 +00:00
Kp 60c5fc5dc4 Pass object& to multi_drop_robot_powerups 2022-02-05 13:30:56 +00:00
Kp 6cc788e1cd Pass object_base& to object_create_robot_egg 2022-02-05 13:30:56 +00:00
Kp a0be091cd0 Avoid repeated valptridx dereferences in player_is_visible_from_object 2022-02-05 13:30:56 +00:00
Kp 7abcced9d0 Avoid repeated valptridx dereferences in init_ai_object 2022-02-05 13:30:56 +00:00
Kp ce8339fa5b Avoid repeated valptridx dereferences in ai_follow_path 2022-02-05 13:30:56 +00:00
Kp 9b2eda5bde Avoid repeated valptridx dereferences in create_path 2022-02-05 13:30:56 +00:00
Kp fd33402354 Avoid repeated valptridx dereferences in create_n_segment_path 2022-02-05 13:30:56 +00:00
Kp a418a0c7f9 Avoid repeated valptridx dereferences in create_path_to_station 2022-02-05 13:30:56 +00:00
Kp f7742a6e16 Avoid repeated valptridx dereferences in create_path_to_segment 2022-02-05 13:30:56 +00:00
Kp 13ca2112fd Avoid repeated valptridx dereferences in polish_path 2022-02-05 13:30:56 +00:00
Kp e15ec1e80d Avoid repeated valptridx dereferences in create_path_points 2022-02-05 13:30:56 +00:00
Kp f55aed4b9b Pass object& to ai_door_is_openable 2022-02-05 13:30:56 +00:00
Kp 2440a271da Improve vulcan/gauss pickup rules
- Change D1X to use D2X rules regarding Vulcan cannon pickup.  The D1X
  rules were confusing at best, and seem outright wrong in some ways.
  - When a Vulcan cannon was picked up, it was treated as containing not
    less than VULCAN_WEAPON_AMMO_AMOUNT rounds, regardless of what it
    actually contained.  D2X respected the actual contained count, even
    when running in D1X emulation mode.
  - In D1X single player, if the Vulcan cannon was not picked up, then
    it could be treated as Vulcan ammo.  If at least 1 unit of
    ammunition was added to the player, the entire powerup would be
    consumed, regardless of how much ammunition remained.
  - In D2X single player, if the Vulcan cannon was not picked up, then
    ammunition would be taken from it, but the powerup would only be
    consumed if all its ammunition was taken.
  - In D1X multiplayer, a player who already had a Vulcan cannon could
    not get anything from touching a new cannon, and the cannon would
    not be changed.
  - In D2X multiplayer, a player who already had a Vulcan cannon could
    take ammunition from the cannon, but the cannon could not be drained
    below VULCAN_AMMO_AMOUNT.  If the cannon had VULCAN_AMMO_AMOUNT or
    less, then the player could not take ammunition.  If the cannon had
    more, the player could drain it to that level.
  - Replace all that with a simplified version of the D2X rules:
    - If the player does not have the cannon, the cannon is picked up
      and removed from the mine.  The player takes as much of its
      ammunition as possible.  If the cannon was well stocked, and the
      player was nearly full, some ammunition will be lost.  This is
      unfortunate, but the game has always had this rule, and changing
      it would require dropping one or more Vulcan Ammo packs to
      represent the untaken ammunition.
    - If the player already had that cannon, then the player takes as
      much ammunition as the cannon has, while not exceeding the
      ammunition cap.  Other players, if any, are updated about how much
      ammunition remains in the cannon.  The cannon remains in the mine.
- Backport to D1X the network message for updating the contained
  ammunition in a vulcan cannon.  zico added the basic feature in
  7684ce92, but only applied it to D2X.  With the change to let D1X
  multiplayer take ammunition from the cannon, D1X now needs the same
  feature.
- Remove the special case to delete an empty cannon.  Instead, let the
  cannon remain in the mine without ammunition.  This allows a player in
  single player mode to leave behind a backup cannon, which could be
  useful if the player is killed and wishes to rearm before returning to
  the death site.  Similarly, under the new rule that players in
  multiplayer can drain the cannon down to 0 ammunition, this removal
  allows the cannon to remain behind for someone else to take, rather
  than allowing it to be deleted by a player who already had an instance
  of it.
2022-02-05 13:30:56 +00:00
Kp 39ca785fbe Remove redundant pick_up_vulcan_ammo call
This is only hit if the call just refused to change the player's
ammunition count, and nothing has changed, so it will just refuse again.
2022-02-05 13:30:56 +00:00
Kp f5684ffda4 Reorder pick_up_vulcan_ammo to keep ammo_count const 2022-02-05 13:30:56 +00:00
Kp 4ae6f52ba9 Simplify respawning anarchy powerups
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
2022-02-05 13:30:56 +00:00
Kp 570e373880 Merge branch multi-endgame-discon into master 2022-01-21 03:54:07 +00:00
Arne de Bruijn 7e5b17ff82 Send periodic endlevel packets after last level
Add periodic calls to send_endlevel_packet in kmatrix if
Control_center_destroyed is false.

Needed because after finishing the last level, kmatrix is called from a
different place where Control_center_destroyed is already false.

It looks like this issue was introduced in Rebirth 0.56 with the
split off of the ipx code (febe5d1). That commit removes the call to
multi_endlevel_poll2 from kmatrix_view, which did the same periodic
sends. (Maybe because in D1 Control_center_destroyed was always true
in kmatrix so it was not needed there.)

Reported-by: snytek <#520>
Fixes: febe5d1 ("Abstracting networking protocols")
2022-01-18 17:03:30 +01:00
Kp e306a6fa99 Rework start_wall_cloak to handle clang inlining limit
clang-13 fails to sufficiently inline this construct, causing it to emit
an unnecessary call to check_null_pointer_conversion on a path where
m_ptr is already guaranteed to be non-nullptr.  That call in turn
causes a linker error, since no other site using valptridx<wall> needs
check_null_pointer_conversion instantiated.  Rather than provide the
instantiation, rework the logic to avoid the need for the dead call.
2022-01-15 20:39:10 +00:00
Kp b8ae2c5e55 Remove unused-but-set variables in ogl_texture_stats 2022-01-15 20:39:10 +00:00
Kp 636e1b6d5e Use enumerated_array for unique_side::uvls 2022-01-15 20:39:10 +00:00
Kp a7c9a04c20 Use enumerated_array for shared_segment::children 2022-01-15 20:39:10 +00:00
Kp dc2e86760e Use enumerated_array for Side_opposite 2022-01-15 20:39:10 +00:00