Commit graph

9623 commits

Author SHA1 Message Date
Kp 62778327a7 Pass cobjptridx to apply_light 2017-01-31 04:25:06 +00:00
Kp 6ac840c52c Fix pch=1 build
PCH mode causes the Valgrind-wrapper header to be included in places
it is not meant to be used, which leads to spurious compiler errors.

PCH mode causes the Valgrind-wrapper __real_* stub functions to see
the physfsx.h PHYSFS macros, which also causes errors.

Fortunately, both cases can be easily fixed.

Add preprocessor guards to the Valgrind-wrapper header to cause it to
compile out when the PCH phase runs.  It has no include guard, so it
will be rescanned with the proper macros when the two consuming files
are built normally.

Modify the Valgrind-wrapper __real_* stub functions to use
the standard macro avoidance trick so that they do not call the
physfsx.h PHYSFS macros.
2017-01-31 04:25:06 +00:00
Kp cdfe7cc308 Merge branch cheats2 into master 2017-01-31 03:57:59 +00:00
Chris Taylor e9b0ca9a83 Don't decrement trigger in remove_trigger_num if it's trigger_none
Fixes a crash when loading a level with redundant triggers and editor enabled, e.g. Passion of Death.
2017-01-30 11:08:58 +08:00
Kp 28489e0770 Merge branch baldguy into master 2017-01-29 21:17:18 +00:00
Kp 59bad96d5f Add back homing weapons cheat for D2
Kreator proposed restoring the Descent 2 cheat that grants homing
capability to all weapons.  This commit implements that proposition,
with some changes to the implementation details.

Based-on-patch-by: Chris Taylor <chris@icculus.org>
Requested-by: Chris Taylor <https://github.com/dxx-rebirth/dxx-rebirth/pull/318>
2017-01-29 21:02:48 +00:00
Kp 32760e8a8f Simplify test for weapon_info::homing_flag 2017-01-29 21:02:38 +00:00
Kp 07200620a1 Simplify test for weapon_info::homing_flag 2017-01-29 20:57:40 +00:00
Kp 9c330da29f Prevent guidebot crash on unattainable goal
Yarn reported that Descent 2: Counterstrike level 9 can place the
guidebot in a situation where

    (Escort_goal_index == object_guidebot_cannot_reach &&
    Escort_special_goal != ESCORT_GOAL_UNSPECIFIED)

If this happens and the player grabs a powerup, then the game crashes
trying to check if the grabbed powerup was of the type that the guidebot
sought.  Since the guidebot was not seeking any object, the answer is
that this is not the sought object.

The design ought not set Escort_goal_index to an invalid object index,
but it does.  Fixing that is too invasive for now.  Add a special case
to prevent this crash.

Reported-by: Yarn <http://www.dxx-rebirth.com/frm/index.php/topic,2158.0.html>
2017-01-29 18:54:52 +00:00
Chris Taylor 000ba37b42 Fix typo with cheat - should be 'ORALGROOVE' not 'ALGROOVE'
No noticeable effect in game, except that just typing 'ALGROOVE' will activate the cheat, which is different to original.
2017-01-29 15:19:02 +08:00
Chris Taylor 877cef9a20 Enable "BALDGUY" cheat for Descent 1
Typing "BALDGUY" after enabling cheats will activate the 'baldguy' easter egg for D1X-Rebirth, which will show next time a briefing is shown featuring Dravis (Mac D1 data only). As with the original, it just plays the 'Cheater!' sound with no HUD message.
2017-01-29 13:05:58 +08:00
Chris Taylor 56125b7e64 Get 'baldguy' cheat to work for Mac Descent 1 data
Pressing ALT-B when in the briefings using Mac Descent 1 data in D1X-Rebirth works again - showing Dravis wearing a silly hat. Before it would exit load_briefing_screen prematurely.
2017-01-29 13:05:57 +08:00
kreatordxx 4c8f467872 Merge pull request #313 from dxx-rebirth/secret_player_loot
Player keeps loot if going between secret level and normal level
2017-01-29 07:56:08 +08:00
Chris Taylor 4fad71ef6d Player keeps omega cannon charge if going between secret and normal level 2017-01-29 07:54:43 +08:00
Chris Taylor 2f4db4a048 Player keeps any keys collected on a secret level even if they die on the secret level 2017-01-29 07:54:43 +08:00
Chris Taylor 4b3a34f943 Player keeps their loot if they went between a secret level and a normal level without dying 2017-01-29 07:54:43 +08:00
Kp a2d03df7aa Prevent treating dying players as weapons
Function `object_create_explosion_sub` is supposed to be given a weapon
and an object on which to explode it.  However, the original game abused
`object_create_explosion_sub` by also calling it from
`object_create_badass_explosion`, which can be called from
`explode_badass_object`, which can be called from
`explode_badass_player`.  Chained together, this lets
`object_create_explosion_sub` check the weapon ID of a dying player,
which is not a valid operation.  This causes a diagnostic from
`get_weapon_id`.  Add an explicit test that the object is a weapon so
that non-weapons do not cause a diagnostic.

Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/302#issuecomment-272048330>
Analyzed-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/302#issuecomment-272710279>
2017-01-28 18:12:21 +00:00
Kp 31da0f769f Fix invalid access reading demos
Commit e36abb25cb fixed one problem with demo access (invalid bits in
the high byte of index values), but created another.  That commit
switched from direct loading of `front_wall_num` to instead load into
`type`, then move the value to `front_wall_num`.  However, `type` is
`sbyte` (an archaic spelling of `int8_t`), so assignments from `type` to
`front_wall_num` were implemented as a sign-extending move, rather than
a zero-extending move.  When the wall number was 0x80 or greater, the
sign-extending move produced an incorrect result, which led to a crash
when valptridx trapped the invalid index.

Fix this by changing the types of all three byte-sized variables to
`uint8_t`.  None of them need to be signed.

Reported-by: Dosgamer <http://www.dxx-rebirth.com/frm/index.php/topic,2151.0.html>
Fixes: e36abb25cb ("Fix invalid access reading demos")
2017-01-28 18:12:21 +00:00
Kp 4881b7c57a Fix harmless type mismatch
`get_weapon_id` must be called only on objects of type `OBJ_WEAPON`.
One path in `multi_compute_kill` could call `get_weapon_id` on an object
that is either a robot or a weapon.  The code tested for a robot, but
only after performing an access that assumed it had a weapon.  Reorder
the tests to prevent the type mismatch diagnostic.

Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/302#issuecomment-275546550>
2017-01-28 18:12:20 +00:00
Kp 8c706a88bd Initialize grs_main_bitmap at construction 2017-01-28 18:12:20 +00:00
Kp fc12995d89 Add options for reduced-size valptridx error reporting 2017-01-28 18:12:20 +00:00
Kp c46a0ce27c Remove some remotely-triggerable fatal exceptions
By design, valptridx will throw an exception on invalid input.  This is
better than silently permitting invalid input to corrupt program state.
Past releases blindly trusted that multiplayer peers would not send
invalid input.  Conversion to the valptridx design eliminated the
undefined behavior when peers send invalid input, but still allowed
multiplayer peers to remotely crash the game by sending invalid inputs.
Add a mechanism to trap invalid inputs and gracefully ignore those
messages.  This may cause game consistency issues, but will not allow
data corruption.
2017-01-28 18:12:20 +00:00
Kp bdc4752e82 Pass vobjptridx to multi_send_drop_flag 2017-01-28 18:12:20 +00:00
kreatordxx 986e8f01a8 Merge pull request #312 from dxx-rebirth/init_ai_object
Move calls to init_ai_object into obj_create and fix robot creation bug with editor
2017-01-23 07:54:09 +08:00
Chris Taylor 30b5ef7c73 Create robot_create function and use it 4x
Contains 2 calls - to obj_create and init_ai_object. For safety reasons and tidiness compared to using obj_create directly. The call to init_ai_object in recreate_thief was already redundant.
2017-01-22 17:56:50 +08:00
Kp 38b33819a5 Workaround Debian Jessie gcc bug
Reported-by: ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/289>
2017-01-21 19:05:44 +00:00
Kp 949d56fdd9 Avoid uninitialized use of object::ctype.ai_info.danger_laser_signature 2017-01-21 19:05:43 +00:00
Kp baa187801b Add special case to make past releases not die on various segnums
All releases to date have a bug where they treat certain segment number
fields as an int, not a segment number.  Storing segment_none (0xffff)
into the save file causes affected releases to crash in various places
because it fails to recognize that this is segment_none.

Current code correctly treats segment_none as a non-segment and works
correctly without this hack.  The hack is only required to get past
releases to work correctly after loading a saved game written by current
code.
2017-01-21 19:05:43 +00:00
Kp e127072f21 Add special case to make past releases not die on MarkerObject
All releases to date have a bug where they treat MarkerObject as an int,
not an object number.  Storing object_none (0xffff) into the save file
causes affected releases to exhibit several problems.  Most obviously,
they crash if the automap is opened, because they try to show
Objects[0xffff] as a marker, but no such object exists.  Additionally,
they refuse to let the player drop a marker because none of the elements
of MarkerObject are -1, so they incorrectly tell the player that all
marker slots are busy.  Finally, they will crash if the guidebot is
killed, because the guidebot death code deletes marker 0xffff because it
fails to recognize that this is object_none.

Current code correctly treats object_none as a non-object and works
correctly without this hack.  The hack is only required to get past
releases to work correctly after loading a saved game written by current
code.

Fixes: 9125ae32cd ("Make objnum unsigned")
2017-01-21 19:05:43 +00:00
Kp 2e6b5e8467 Add special case to make past releases not die on Dead_controlcen_object_num
All releases to date have a bug where they treat
Dead_controlcen_object_num as an int, not an object number.  Storing
object_none (0xffff) into the save file causes affected releases to
crash when treating object_none as a valid object number.

Current code correctly treats object_none as a non-object and works
correctly without this hack.  The hack is only required to get past
releases to survive destroying the reactor after loading a saved game
written by current code.

Fixes: 9125ae32cd ("Make objnum unsigned")
2017-01-21 19:05:43 +00:00
Kp 6da2b446f5 Use range_for in editor/group.cpp 2017-01-21 19:05:42 +00:00
Chris Taylor f2f6af5bf1 Always set hide_segment in init_ai_object
Fixes bug where in the editor, you insert a robot with normal behaviour then play the level - it fails the check on the hide_segment index in init_ai_objects(). This is because hide_segment was written as the poisoned value of 0xfdfd if the behaviour of the robot is AIB_NORMAL - because hide_segment wasn't initialised. Therefore, always setting hide_segment to suppress this exception (it's an inexpensive operation seldom called).
2017-01-21 13:47:27 +08:00
Kp fd2c8df74e Raise MAX_WALLS to 255
Raise D2 MAX_WALLS to 255, since Walls[254] is not special.  Synchronize
D1 MAX_WALLS to D2 MAX_WALLS to fix D1 Level of the World BRDECON.

Requested-by: Ryusei117 <http://www.dxx-rebirth.com/frm/index.php/topic,1760.msg22509.html#msg22509>
2017-01-18 03:06:02 +00:00
Kp 0ac4eb52b2 Merge pull #308 into master
Merge kreatordxx's fixes for flags on guest players.
2017-01-17 02:49:54 +00:00
Kp cc885f17a3 Use init_ai_object for dropped robots
zicodxx reported a problem where poison=overwrite builds caused robots
dropped by other robots not to spawn.  I diagnosed it as a problem
caused by not setting `dying_start_time` and proposed using
`init_ai_object` to set this (and other) fields.  Kreatordxx posted pull
request #311 to implement this for dropped robots.  However, his pull
had the unfortunate side effect of zeroing the dropped robot's velocity.
This change is based on his pull, but with the `init_ai_object` call
moved higher so that the velocity is (unnecessarily) zeroed by
`init_ai_object`, then initialized to `new_velocity` by `drop_powerup`
(as it always was).

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/293>
Patch-inspired-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/pull/311>
2017-01-17 02:38:21 +00:00
Chris Taylor b1b5de4297 Additional safeguard for bug #306
This is where a client in a multiplayer game hitting a wall fails an assert. Initialise obj->mtype.phys_info.flags in multi_reset_player_object() instead of adding flags. (Tested and still works OK without specifying PF_THRUST.)
2017-01-16 15:39:10 +08:00
zico b644ab575c Raised MAX_DELTA_LIGHTS to 32000. 2017-01-15 14:12:03 +01:00
zico 5acbb949de Raised MAX_NUM_FUELCENS and MAX_ROBOT_CENTERS to 128. 2017-01-15 13:43:02 +01:00
Chris Taylor e76c8cf264 Fix bug #306 where a client in a multiplayer game hitting a wall fails an assert
Initialise ConsoleObject->mtype.phys_info.flags in reset_player_object() instead of adding flags. The only place this was initialised properly was when reading the player object from disk.
2017-01-15 18:11:54 +08:00
kreatordxx 5dec6d3975 Merge pull request #307 from dxx-rebirth/multi_gauge_pic
Fix debugger break at draw_weapon_info_sub when multi player dumped
2017-01-15 16:58:58 +08:00
Kp 092d947830 Optimize change_light search
Use std::equal_range to find the upper and lower bounds in a single
binary search, rather than relying on a linear search to find the first
sought element.
2017-01-15 00:03:14 +00:00
Kp 3594e7093f Switch last_hitobj to use array<objnum_t> instead of bitset
This reduces the number of objects that can be tracked concurrently, but
allows MAX_OBJECTS to rise without causing `laser_info` to grow.
2017-01-15 00:03:13 +00:00
Kp 6d3fb34268 Abstract out last_hitobj management 2017-01-15 00:03:13 +00:00
Kp 1b81013a9b Pass active palette to ogl_loadtexture 2017-01-15 00:03:13 +00:00
Kp d908b22fdc Move weapon_id_type to namespace dsx 2017-01-15 00:03:13 +00:00
Kp 764d20d4e1 Make grs_bitmap::bm_flags private 2017-01-15 00:03:13 +00:00
Kp 96cc5a40b8 Remove dead preprocessor guards
Some bitblt code had guards of the form:

	#if A
	xxx
	#if !A
	yyy
	#endif
	zzz
	#endif

If A is true, !A is false, so the inner block can never be included.
Delete it.
2017-01-15 00:03:12 +00:00
Kp f4fffeea49 Make more render state const when possible
Make Render_zoom const in builds where there are no statements that can
change it.

Use vcseg, not vseg, for some segment accesses.
2017-01-15 00:03:12 +00:00
Chris Taylor 8c51aa0b1e Fix debugger break at draw_weapon_info_sub when multi player dumped (bug #303)
Also happened when a client to a multiplayer game dropped out due to some network error. Delay call of multi_leave_game() until responding to EVENT_WINDOW_CLOSE, so the game isn't in an unstable state between handling the network event and the game closing.
2017-01-14 17:49:43 +08:00
Chris Taylor 479f5ed584 Fix 'format specifies type 'unsigned short' but the argument has type 'unsigned char'' warning
Replace %hu with %hhu for capped in call to con_printf in powerup_cap_state::cap_secondary_ammo.
2017-01-13 12:32:46 +08:00