Commit graph

3356 commits

Author SHA1 Message Date
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 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 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
Kp 0bba26fde5 Move ini.pop_back() into ReadIniArgs
Both callers of ReadIniArgs need the string removed afterward.  Prior to
8fb9a0f, only the parser for `-ini` needed the string removed.  The
caller for the automatic ini file ended and destroyed the container.  As
of 8fb9a0f, the container persists.  Leaving the string in the container
causes a bad error message if the command line is rejected.

It is bad form to have ReadIniArgs pop, but the caller push.  However,
the two callers use different signatures for emplace_back(), so unifying
the push would require calling a suboptimal emplace_back.  Choose the
lesser evil of unbalanced push/pop.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/198>
2016-05-31 00:42:56 +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 604778248d Fix -Wshadow warning in get_chunks_state
get_chunks_state has a member named `data` and its constructor took a
parameter named `data`.  This is unambiguous in the language, but causes
a warning from gcc's -Wshadow when building with WORDS_NEED_ALIGNMENT.
Rename the parameter to eliminate the warning.

Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/pull/196>
2016-05-29 17:46:32 +00: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