Commit graph

8397 commits

Author SHA1 Message Date
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 b6fd8572d1 Simplify ui_radio_set_value loop 2016-07-06 01:54:25 +00:00
Kp e92a7aea14 Use C++ static_cast for gadget downcast 2016-07-06 01:54:25 +00:00
Kp 37d6a652c9 Remove useless casts in box.cpp 2016-07-06 01:54:24 +00:00
Kp d32afbdac5 Rewrite simple unsigned int casts from C style to static_cast<>
s/(unsigned int)\s*(/static_cast<uint32_t>(/g
2016-07-06 01:54:24 +00:00
Kp b0a2205a4e Convert various pointer casts to reinterpret_cast 2016-07-06 01:54:24 +00:00
Kp 275355994d Remove useless scanline casts 2016-07-06 01:54:24 +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 a7ceee3c03 Add parentheses around target of simple unsigned char 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.

s/(\s*unsigned\s\+char\s*\(\*\+\)\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(uint8_t \1)(\2\3\4)\5/g
2016-07-03 00:54:14 +00:00
Kp c7953a3df1 Fix Win32 use of static_cast where reinterpret_cast is needed 2016-07-02 02:04:11 +00:00
Kp a24dffad13 Include dsx-ns.h in inferno.h for #define dsx 2016-07-02 02:04:11 +00:00
Kp 492cc5788a Fix -Wshadow error in SDL-only build 2016-07-02 02:04:11 +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
Kp 0cb099c5e4 Add parentheses around casts of simple function calls
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.

Exclude float|double from the second substitution.  Including it
rewrites medmisc.cpp in an incorrect way, and excluding it does not
exclude any valid rewrites.

s/(\(int\|signed\|float\|double\|long\|short\|unsigned\))\s*\(\w\+\s*(\s*\w\+\s*)\)/(\1)(\2)/
s/(\((\(int\|signed\|long\|short\|unsigned\))(\w\+\s*(\s*\w\+\s*))\))/\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 17d71ee0ae Rewrite cast of (uint) to standard type uint32_t
s/(uint)\s*\(\w\)/(uint32_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