Commit graph

2731 commits

Author SHA1 Message Date
Kp a274ea0ee8 Remove useless cast in multi.cpp 2016-07-15 03:43:03 +00:00
Kp 14c7683afa Remove useless cast in gameseq.cpp 2016-07-15 03:43:03 +00:00
Kp 12ff40bd93 Remove useless cast in gamefont 2016-07-15 03:43:02 +00:00
Kp 279dc555dd Propagate digiobj MAX_Q 2016-07-15 03:43:02 +00:00
Kp 3ebf1f009f Reorder digiobj channel clear 2016-07-15 03:43:02 +00:00
Kp 946e7bd4ee Move some digi symbols to dcx 2016-07-15 03:43:02 +00:00
Kp 74299f7e88 Encourage tail call optimizations in digiobj 2016-07-15 03:43:01 +00:00
Kp aa95cbfccc Move set_thrust_from_velocity to dcx 2016-07-15 03:43:01 +00:00
Kp 96f78e1032 Use constexpr for MAX_BITMAP_FILES 2016-07-14 01:59:05 +00:00
Kp 6905b5bd1d Use constexpr for MAX_SOUNDS 2016-07-14 01:59:04 +00:00
Kp dcdff564f4 Fold newdemo_record_primary_ammo in draw_hud 2016-07-14 01:59:04 +00:00
Kp 3894c66b9b Fold do_missile_firing calls to multi_send_fire 2016-07-14 01:59:04 +00:00
Kp ec19c2ba89 Allow player to grab invulnerability powerup when FakingInvul
Previously, if the player was invulnerable, it was impossible to grab an
invulnerability powerup.  Relax this by allowing a spawn-induced fake
invulnerability not to count as invulnerable for this test.  Players
still cannot grab an invulnerability powerup if they are still under the
influence of a prior invulnerability powerup.
2016-07-14 01:59:04 +00:00
Kp ed7376c695 Pass object & to update_item_state::process_powerup 2016-07-14 01:59:04 +00:00
Kp d5a64c4f33 Factor out object count tests
An optimizing compiler should inline these tests.  Moving them out makes
the code easier to read, since the statements can focus on what is
updated, rather than how it is done.
2016-07-14 01:59:04 +00:00
Kp 663d6df312 Use ?: for MultiLevelInv_CountPlayerInventory flag increment 2016-07-14 01:59:03 +00:00
Kp 023ed08c1c Switch to vcobjptr for MultiLevelInv_CountPlayerInventory player
The index is not needed and the player should not be modified by the
scan.
2016-07-14 01:59:03 +00:00
Kp e65b93b750 Cache reference to MultiLevelInv.Current
Modify MultiLevelInv_CountPlayerInventory to ease conversion to a member
function.
2016-07-14 01:59:03 +00:00
Kp 96d9ae4e4a Optimize initial MultiLevelInv clear
Change the clearing of MultiLevelInv during initialization to reduce
wasted stores.  MultiLevelInv has three fields.

Field ::Initial is not accessed by MultiLevelInv_CountLevelPowerups, and
is overwritten immediately afterward, so it does not need to be cleared
first.

Field ::Current is unconditionally cleared by
MultiLevelInv_CountLevelPowerups, so it does not need to be cleared
first.

Field ::RespawnTimer is not accessed by
MultiLevelInv_CountLevelPowerups, but needs to be cleared.  Add a clear
of field .RespawnTimer and remove the clear of the entire structure.
2016-07-14 01:59:03 +00:00
Kp 5af44fa27a Refactor to propagate MultiLevelInv_Count initial
All callers of MultiLevelInv_Count passed a constant value.  Factor
out the top level blocks of MultiLevelInv_Count into helper functions,
then create two new functions corresponding to MultiLevelInv_Count(0)
and MultiLevelInv_Count(1), implemented by calling the appropriate new
helper functions.
2016-07-14 01:59:03 +00:00
Kp 1d568fa56e Move MultiLevelInv_Count for vulcan/gauss to use fallthrough 2016-07-14 01:59:03 +00:00
Kp 05db30a6ff Fix piggy cast when sizeof(size_t) != sizeof(void *) 2016-07-14 01:59:02 +00:00
Kp 39895e5643 Rewrite declarations of ushort * to standard uint16_t * 2016-07-14 01:59:02 +00:00
Kp 59750d3c29 Rewrite declarations of ubyte * to standard uint8_t * 2016-07-14 01:59:02 +00:00
Kp 613a7ecbbb Rewrite parenthesized uses of uint to standard unsigned 2016-07-14 01:59:02 +00:00
Kp 0b6af7fcbe Propagate MAX_OBJ_BITMAPS 2016-07-10 04:11:35 +00:00
Kp ca18195390 Propagate MAX_TEXTURES 2016-07-10 04:11:35 +00:00
Kp 6580c37b6e Propagate MAX_STOLEN_ITEMS 2016-07-10 04:11:34 +00:00
Kp 71ab00beb8 Propagate MAX_BOSS_TELEPORT_SEGS 2016-07-10 04:11:34 +00:00
Kp 1486a5a01b Move Robot_sound_volume to dcx 2016-07-09 17:58:36 +00:00
Kp a63fe62cb3 Add typedef for multi_allow_powerup_text type 2016-07-09 17:58:35 +00:00
Kp 2713baf5d3 Move HUD_MESSAGE_LENGTH to hud.cpp 2016-07-09 17:58:35 +00:00
Kp 7af34fa844 Fold create_n_segment_path calls 2016-07-09 17:58:35 +00:00
Kp be8022ff41 Add typedef for GMNames array 2016-07-09 17:58:35 +00:00
Kp 3779bc25a0 Define Robot_names only if EDITOR 2016-07-09 17:58:34 +00:00
Kp fee76e6ced Define Powerup_names only if EDITOR 2016-07-09 17:58:34 +00:00
Kp 9511ca8aaf Convert simple multi fix casts from C style to static_cast<> 2016-07-07 03:08:13 +00:00
Kp a7c64d6f97 Convert simple int casts from C style to static_cast<> 2016-07-07 03:08:13 +00:00
Kp 1dd60cc5be Rewrite simple fix64 casts from C style to static_cast<>
s/(\(fix\(64\)\?\))\s*\(\w\+\);/static_cast<\1>(\3);/g
2016-07-07 03:08:13 +00:00
Kp 9128ff7c35 Move Next_laser_fire_time to player_info 2016-07-06 01:54:26 +00:00
Kp bd3db75108 Move Next_missile_fire_time to player_info 2016-07-06 01:54:26 +00:00
Kp a554d7e2c4 Move Next_flare_fire_time into player_info 2016-07-06 01:54:25 +00:00
Kp 6251848c5f Move Missile_gun into player_info 2016-07-06 01:54:25 +00:00
Kp 6a9ea1a256 Remove unnecessary index tracking in choose_missile_viewer 2016-07-06 01:54:25 +00:00
Kp a1f67167ce Use static_cast for check_effect_blowup 2016-07-06 01:54:25 +00:00
Kp 3c71aa812e Use static_cast for check_trans_wall 2016-07-06 01:54:25 +00:00
Kp 837b46b9b3 Use static_cast for load_mine_data_compiled fix casts 2016-07-06 01:54:25 +00:00
Kp 262094237f Rewrite simple numeric casts from C style to static_cast<>
s/(\(int\|float\|fix\))\s*(/static_cast<\1>(/g
2016-07-06 01:54:24 +00:00
zico 5d2b2891ad Addition to 32b9202e1f, making clear_missile_viewer() return if Missile_viewer was set to NULL and only trigger WBU_STATIC in that case, preventing static display when cycling through right cockpit window view 2016-07-04 14:31:30 +02:00
Kp 3fe581c84a Cache reference to local player object 2016-07-03 00:54:16 +00:00
Kp 3272caed7d Cache reference to local player energy 2016-07-03 00:54:16 +00:00
Kp 15f2471be0 Cache reference to local player shields 2016-07-03 00:54:16 +00:00
Kp 3b0fccd899 Cache reference to local player secondary ammo 2016-07-03 00:54:15 +00:00
Kp b9804e6e58 Cache reference to local player cloak time 2016-07-03 00:54:15 +00:00
Kp c3e2edaff0 Cache reference to local player invulnerable time 2016-07-03 00:54:15 +00:00
Kp 96b258e958 Cache reference to local player flags 2016-07-03 00:54:15 +00:00
Kp b35a893d9a Rewrite simple pointer casts from C style to reinterpret_cast<>
s/(\s*\(\w\+\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:15 +00:00
Kp efce2e50dc Rewrite simple integer casts from C style to static_cast<>
s/(\s*\(u\?int[[:digit:]]\+_t\s*\)\s*)\s*(/static_cast<\1>(/g
2016-07-03 00:54:15 +00:00
Kp f5aed82d83 Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets int16_t and uint16_t.

s/(\s*\(u\?int16_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:14 +00:00
Kp 19f31eb420 Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets int8_t and uint8_t.

s/(\s*\(u\?int8_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:14 +00:00
Kp 131b06a7b8 Move & into parentheses
s/\()\s*\)&(\([[:alpha:]][[:alnum:].]*\))/\1(\&\2)/g
2016-06-27 04:11:14 +00:00
Kp 3469ff8c34 Change (short*) to (int16_t*)
Uses of `(short*)` usually want exactly a 16-bit signed integer.  Most
platforms provide that as `short`, but that is not guaranteed.

s/(short \(*\+\)\s*)/(int16_t \1)/g
2016-06-27 04:11:13 +00:00
Kp a23df63f1b Change (sbyte *) to (int8_t *)
Use the stdint type instead of a Descent custom type.
2016-06-27 04:11:13 +00:00
Kp 6087660944 Add parentheses around casts of array subscripts to pointer types
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

s/\((\w\+\s*\*\+)\)\s*\(&\w\+\(\[[[:alnum:]+-]*\]\)*[]);]\)/\1(\2)/g
2016-06-27 04:11:13 +00:00
Kp ce5cce0708 Update delayed weapon when updating primary for grant
Grant processing code sets `Primary_weapon` to the user's preferred
weapon, but the delayed autoselect code then changed it back to
something else.  Call select_primary_weapon instead of directly updating
`Primary_weapon`, so that `Delayed_primary` is updated too.

This also fixes a bug where the demo always recorded the player
switching to lasers/concussion, instead of the values that the player
actually received from the grant.

Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/184>
2016-06-25 23:21:36 +00:00
Kp a4967ffceb Move various robot data into namespaces 2016-06-25 23:21:36 +00:00
Kp a3e65f64ea Use range_for for polyobj_find_min_max 2016-06-25 23:21:36 +00:00
Kp 89ddc1b911 Add parentheses around casts of simple array subscripts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\[[^][]*\]\)*\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7\8)\9/g
2016-06-25 23:21:36 +00:00
zico 5c72b57b13 Initialize weapons on new game to prevent spawning with weapons selected in previous game if launching with Granted Weapons 2016-06-20 11:57:31 +02:00
Kp 65f68877aa Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-16 03:56:44 +00:00
zico 320b5aa8f0 Fixed regression from bbda32f78d8f227785fe294b5a9786724611d370: Due to GR_FADE_LEVELS being unsigned if statements in draw_player_ship() broke regarding the cloak fade levels. Fixed by some casts. 2016-06-13 14:43:04 +02:00
zico 64f77636a7 When using rapidfire cheat in Descent 1, only grant weapons if cheat toggles on. Also give Rapidfire HUD msg like in Descent II to make clear the state of the cheat. Additional formatting love for lighting debug key to calm GCC's warnings. 2016-06-13 13:24:38 +02:00
Kp 1b12a3f7ef Add parentheses around target of more complicated casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of some C casts.

This pass attempts to process expressions that involve parenthesized or
bracketed subexpressions, but only if those subexpressions do not
themselves contain parenthesized or bracketed subexpressions.

	(int) f(1);	// changed
	(int) f(g());	// not changed

perl -p -i -e 's/(\(\s*((?:un)?signed|int|char|short|long|float|double|s?size_t|(?:u?int[[:digit:]]+_t))\s*\**\s*\)\s*)([&+-]?)([[:alnum:]_.]+\s*->\s*)*([[:alnum:]_.]+)((?:\s*(?:\[[^][]*\])*|(?:\([^()]*\))*))(\s*([;+>*\/^%,|&<>])|$|(\s*-\s*[^>]))/\1\(\3\4\5\6\)\7/g'
2016-06-12 03:45:37 +00:00
Kp 6fc1730770 Convert piggy cast to reinterpret_cast 2016-06-12 03:45:37 +00:00
Kp bc30ccd216 Rewrite cast of (sbyte) to standard type int8_t
s/(sbyte)\s*\(\w\)/(int8_t) \1/g
2016-06-12 03:45:37 +00:00
Kp 478a48ddc1 Fix vulcan ammo object tests
Object numbers are unsigned short, not signed short.  If anyone ever
raises the object limit high enough, testing for negative values would
blacklist valid objects.

Remove unnecessary test for objnum!=object_none.  If it were none,
constructing `obj` would have failed.
2016-06-12 03:45:37 +00:00
Kp 5b437592b0 Simplify test for vulcan|gauss 2016-06-12 03:45:36 +00:00
zico 84f254e2f2 Another addendum to 3366658a5bd2b30a82949b8b301e97b324ce539d: Don't make ngii static anymore (forgot to change this). 2016-06-06 17:29:21 +02:00
zico 7684ce92e4 Added packet to notify clients about a changed vulcan ammo count in a weapon powerup in case player collects ammo but leaves the gun itself. 2016-06-06 17:26:59 +02:00
zico 416ea963c8 When building D2X, before dropping Vulcan ammo check for presence of Gauss cannon, too. 2016-06-06 15:43:38 +02:00
Kp 9283c2f0c3 Improve Error reporting on texmerge consistency failure 2016-06-05 18:45:21 +00:00
Kp 3918db41ff Factor out common texture merge code 2016-06-05 18:45:20 +00:00
Kp 231223895d Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\*\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp b282bea173 Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp ebebda5f17 Fix piggy casts when sizeof(size_t) is not sizeof(void*) 2016-06-05 01:04:26 +00:00
Kp 7fdce88558 Add parentheses around target of simple casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets.  It also works only on commonly used standard types.

	(int) a->b;	// changed
	(int) a[b];	// not changed

s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
2016-06-05 01:04:25 +00:00
Kp badf0f4f90 Rewrite cast of (uint*) to standard type uint32_t
s/(\s*uint\s*\*\s*)/(uint32_t *)/g
2016-06-05 01:04:25 +00:00
Kp aeebffccc0 Rewrite cast of (ushort*) to standard type uint16_t
s/(\s*ushort\s*\*\s*)/(uint16_t *)/g
2016-06-05 01:04:25 +00:00
Kp b31446340c Rewrite cast of (ubyte*) to standard type uint8_t
s/(\s*ubyte\s*\*\s*)/(uint8_t *)/g
2016-06-05 01:04:25 +00:00
zico 660d18c312 Check for GM_MULTI together with Netgame.InvulAppear in init_player_stats_new_ship(). Otherwise going into Singleplayer after starting a Multiplayer match with this option set can translate this effect into Singleplayer. 2016-05-30 15:00:07 +02:00
zico 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-05-30 14:54:51 +02:00
zico 1856e73ca6 Addition to 3366658a5bd2b30a82949b8b301e97b324ce539d: Changed show_netgame_info and pass netgame as reference and const; removed struct and extern; declared ngii inside show_netgame_info(). 2016-05-30 13:49:06 +02:00
zico a8ed0aaa9c Added breaks in event.cpp to prevent unwanted events if -nomouse and/or -nojoystick is given; Added automap_apply_input() to prevent multiple inputs per frame causing multiple movement applications. 2016-05-30 13:17:42 +02:00
Kp f073e9e377 Fold nm_messagebox call in net_udp_do_join_game 2016-05-28 17:31:27 +00:00
Kp 82a8f6ebb0 Pass bm_mode to gr_init_bitmap 2016-05-28 17:31:27 +00:00
Kp dcc56e6b39 Propagate bm_mode::linear into iff_read_bitmap 2016-05-28 17:31:27 +00:00
Kp c00f918a8e Propagate bm_mode::linear into bald_guy_load 2016-05-28 17:31:26 +00:00
Kp 3fb16c1d7a Propagate bm_mode::linear into pcx_read_bitmap 2016-05-28 17:31:26 +00:00
Kp 398596c468 Use enum for bitmap mode 2016-05-28 17:31:26 +00:00
Kp 7d468491a1 Fix -Wshadow warnings in mission.cpp 2016-05-22 17:49:32 +00:00