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
This commit is contained in:
Kp 2016-06-25 23:21:36 +00:00
parent 5c72b57b13
commit 89ddc1b911
9 changed files with 51 additions and 51 deletions

View file

@ -235,7 +235,7 @@ void c_tmap_scanline_lin()
if (!Transparency_on) {
for (int x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
//edited 05/18/99 Matt Mueller - changed from 0xff00 to 0x7f00 to fix glitches
*dest++ = gr_fade_table[ (l&(0x7f00)) + (uint32_t) pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ] ];
*dest++ = gr_fade_table[ (l&(0x7f00)) + (uint32_t) (pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ]) ];
//end edit -MM
l += dldx;
u += dudx;
@ -396,7 +396,7 @@ static void c_fp_tmap_scanline_per()
if (++index >= SWIDTH*SHEIGHT) return;
*dest++ =
gr_fade_table[static_cast<int>(fabs(l))][
(uint32_t) pixptr[((static_cast<int>(v * rec_z)) & (64 * 63)) + ((static_cast<int>(u * rec_z)) & 63)]];
(uint32_t) (pixptr[((static_cast<int>(v * rec_z)) & (64 * 63)) + ((static_cast<int>(u * rec_z)) & 63)])];
l += dldx;
u += dudx;
v += dvdx;
@ -570,7 +570,7 @@ static void c_tmap_scanline_per()
{
if (++index >= SWIDTH*SHEIGHT) return;
//edited 05/18/99 Matt Mueller - changed from 0xff00 to 0x7f00 to fix glitches
*dest++ = fadeTableLocalCopy[(l>>8)&0x7f][(uint32_t) pixPtrLocalCopy[ ( (v/z)&(64*63) ) + ((u/z)&63) ] ];
*dest++ = fadeTableLocalCopy[(l>>8)&0x7f][(uint32_t) (pixPtrLocalCopy[ ( (v/z)&(64*63) ) + ((u/z)&63) ]) ];
//end edit -MM
l += dldx;
u += dudx;
@ -668,7 +668,7 @@ void c_tmap_scanline_per()
if (!Transparency_on) {
for (int x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
//edited 05/18/99 Matt Mueller - changed from 0xff00 to 0x7f00 to fix glitches
*dest++ = gr_fade_table[ (l&(0x7f00)) + (uint32_t) pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ] ];
*dest++ = gr_fade_table[ (l&(0x7f00)) + (uint32_t) (pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ]) ];
//end edit -MM
l += dldx;
u += dudx;

View file

@ -888,7 +888,7 @@ int rotate_segment_new(const vms_angvec &pbh)
int child_save;
int current_group_save;
if (!IS_CHILD(Cursegp->children[(int) Side_opposite[Curside]]))
if (!IS_CHILD(Cursegp->children[(int) (Side_opposite[Curside])]))
// -- I don't understand this, MK, 01/25/94: if (Cursegp->children[Curside] != group_seg-Segments)
{
editor_status("Error -- unable to rotate group, Cursegp:Side_opposite[Curside] cannot be free.");

View file

@ -231,7 +231,7 @@ static int segsize_common(int dimension, fix amount)
int s;
for (s=0; s<MAX_SIDES_PER_SEGMENT; s++)
propagated[s]++;
propagated[(int) Side_opposite[i]]--;
propagated[(int) (Side_opposite[i])]--;
med_propagate_tmaps_to_segments(vsegptridx(c), Cursegp, 1);
}
}

View file

@ -809,7 +809,7 @@ static int med_attach_segment_rotated(const vsegptridx_t destseg, const vsegptr_
// Set the vertex indices for the four vertices forming the front of the new side
for (v=0; v<4; v++)
nsp->verts[v] = destseg->verts[(int) dvp[v]];
nsp->verts[v] = destseg->verts[(int) (dvp[v])];
// The other 4 vertices must be created.
// Their coordinates are determined by the 4 welded vertices and the vector from front
@ -1228,11 +1228,11 @@ int med_form_joint(const vsegptridx_t seg1, int side1, const vsegptridx_t seg2,
// Make a copy of the list of vertices in seg2 which will be deleted and set the
// associated vertex number, so that all occurrences of the vertices can be replaced.
for (v=0; v<4; v++)
lost_vertices[v] = seg2->verts[(int) vp2[v]];
lost_vertices[v] = seg2->verts[(int) (vp2[v])];
// Now, for each vertex in lost_vertices, determine which vertex it maps to.
for (v=0; v<4; v++)
remap_vertices[3 - ((v + bfi) % 4)] = seg1->verts[(int) vp1[v]];
remap_vertices[3 - ((v + bfi) % 4)] = seg1->verts[(int) (vp1[v])];
// Now, in all segments, replace all occurrences of vertices in lost_vertices with remap_vertices
@ -1300,7 +1300,7 @@ int med_form_bridge_segment(const vsegptridx_t seg1, int side1, const vsegptridx
{
auto &sv = Side_to_verts[side2];
for (v=0; v<4; v++)
bs->verts[(3-v)+4] = seg2->verts[(int) sv[v]];
bs->verts[(3-v)+4] = seg2->verts[(int) (sv[v])];
}
// Copy vertices from seg1 into first 4 vertices of bridge segment.
@ -1309,7 +1309,7 @@ int med_form_bridge_segment(const vsegptridx_t seg1, int side1, const vsegptridx
{
auto &sv = Side_to_verts[side1];
for (v=0; v<4; v++)
bs->verts[(v + bfi) % 4] = seg1->verts[(int) sv[v]];
bs->verts[(v + bfi) % 4] = seg1->verts[(int) (sv[v])];
}
// Form connections to children, first initialize all to unconnected.
@ -1335,7 +1335,7 @@ int med_form_bridge_segment(const vsegptridx_t seg1, int side1, const vsegptridx
seg1->children[side1] = segment_none;
seg2->children[side2] = segment_none;
bs->children[AttachSide] = segment_none;
bs->children[(int) Side_opposite[AttachSide]] = segment_none;
bs->children[(int) (Side_opposite[AttachSide])] = segment_none;
if (med_delete_segment(bs)) {
Int3();
}

View file

@ -637,7 +637,7 @@ static void get_side_ids(const vsegptr_t base_seg, const vsegptr_t con_seg, int
if (side != base_side) {
auto &base_vp = Side_to_verts[side];
for (v0=0; v0<4; v0++)
if (((base_seg->verts[(int) base_vp[v0]] == abs_id1) && (base_seg->verts[(int) base_vp[(v0+1) % 4]] == abs_id2)) || ((base_seg->verts[(int) base_vp[v0]] == abs_id2) && (base_seg->verts[(int)base_vp[ (v0+1) % 4]] == abs_id1))) {
if (((base_seg->verts[(int) (base_vp[v0])] == abs_id1) && (base_seg->verts[(int) (base_vp[(v0+1) % 4])] == abs_id2)) || ((base_seg->verts[(int) (base_vp[v0])] == abs_id2) && (base_seg->verts[(int)(base_vp[ (v0+1) % 4])] == abs_id1))) {
Assert(*base_common_side == -1); // This means two different sides shared the same edge with base_side == impossible!
*base_common_side = side;
}
@ -652,7 +652,7 @@ static void get_side_ids(const vsegptr_t base_seg, const vsegptr_t con_seg, int
if (side != con_side) {
auto &con_vp = Side_to_verts[side];
for (v0=0; v0<4; v0++)
if (((con_seg->verts[(int) con_vp[(v0 + 1) % 4]] == abs_id1) && (con_seg->verts[(int) con_vp[v0]] == abs_id2)) || ((con_seg->verts[(int) con_vp[(v0 + 1) % 4]] == abs_id2) && (con_seg->verts[(int) con_vp[v0]] == abs_id1))) {
if (((con_seg->verts[(int) (con_vp[(v0 + 1) % 4])] == abs_id1) && (con_seg->verts[(int) (con_vp[v0])] == abs_id2)) || ((con_seg->verts[(int) (con_vp[(v0 + 1) % 4])] == abs_id2) && (con_seg->verts[(int) (con_vp[v0])] == abs_id1))) {
Assert(*con_common_side == -1); // This means two different sides shared the same edge with con_side == impossible!
*con_common_side = side;
}
@ -825,8 +825,8 @@ static void propagate_tmaps_to_segment_sides(const vsegptridx_t base_seg, int ba
// Do for each edge on connecting face.
for (v=0; v<4; v++) {
abs_id1 = base_seg->verts[(int) base_vp[v]];
abs_id2 = base_seg->verts[(int) base_vp[(v+1) % 4]];
abs_id1 = base_seg->verts[(int) (base_vp[v])];
abs_id2 = base_seg->verts[(int) (base_vp[(v+1) % 4])];
propagate_tmaps_to_segment_side(base_seg, base_side, con_seg, con_side, abs_id1, abs_id2, uv_only_flag);
}

View file

@ -1163,8 +1163,8 @@ static int check_for_degenerate_side(const vcsegptr_t sp, int sidenum)
//vm_vec_sub(&vec2, &Vertices[sp->verts[vp[2]]], &Vertices[sp->verts[vp[1]]]);
//vm_vec_normalize(&vec1);
//vm_vec_normalize(&vec2);
vm_vec_normalized_dir(vec1, Vertices[sp->verts[(int) vp[1]]], Vertices[sp->verts[(int) vp[0]]]);
vm_vec_normalized_dir(vec2, Vertices[sp->verts[(int) vp[2]]], Vertices[sp->verts[(int) vp[1]]]);
vm_vec_normalized_dir(vec1, Vertices[sp->verts[(int) (vp[1])]], Vertices[sp->verts[(int) (vp[0])]]);
vm_vec_normalized_dir(vec2, Vertices[sp->verts[(int) (vp[2])]], Vertices[sp->verts[(int) (vp[1])]]);
const auto cross0 = vm_vec_cross(vec1, vec2);
dot = vm_vec_dot(vec_to_center, cross0);
@ -1175,8 +1175,8 @@ static int check_for_degenerate_side(const vcsegptr_t sp, int sidenum)
//vm_vec_sub(&vec2, &Vertices[sp->verts[vp[3]]], &Vertices[sp->verts[vp[2]]]);
//vm_vec_normalize(&vec1);
//vm_vec_normalize(&vec2);
vm_vec_normalized_dir(vec1, Vertices[sp->verts[(int) vp[2]]], Vertices[sp->verts[(int) vp[1]]]);
vm_vec_normalized_dir(vec2, Vertices[sp->verts[(int) vp[3]]], Vertices[sp->verts[(int) vp[2]]]);
vm_vec_normalized_dir(vec1, Vertices[sp->verts[(int) (vp[2])]], Vertices[sp->verts[(int) (vp[1])]]);
vm_vec_normalized_dir(vec2, Vertices[sp->verts[(int) (vp[3])]], Vertices[sp->verts[(int) (vp[2])]]);
const auto cross1 = vm_vec_cross(vec1, vec2);
dot = vm_vec_dot(vec_to_center, cross1);

View file

@ -1709,8 +1709,8 @@ static void multi_do_message(const uint8_t *const cbuf)
const auto color = get_player_or_team_color(buf[1]);
char xrgb = BM_XRGB(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b);
digi_play_sample(SOUND_HUD_MESSAGE, F1_0);
HUD_init_message(HM_MULTI, "%c%c%s:%c%c %s", CC_COLOR, xrgb, static_cast<const char *>(Players[(int)buf[1]].callsign), CC_COLOR, BM_XRGB(0, 31, 0), msgstart);
multi_sending_message[(int)buf[1]] = msgsend_none;
HUD_init_message(HM_MULTI, "%c%c%s:%c%c %s", CC_COLOR, xrgb, static_cast<const char *>(Players[(int)(buf[1])].callsign), CC_COLOR, BM_XRGB(0, 31, 0), msgstart);
multi_sending_message[(int)(buf[1])] = msgsend_none;
}
namespace dsx {
@ -1942,17 +1942,17 @@ static void multi_do_escape(const ubyte *buf)
if (buf[2] == 0)
{
HUD_init_message(HM_MULTI, "%s %s", static_cast<const char *>(Players[(int)buf[1]].callsign), TXT_HAS_ESCAPED);
HUD_init_message(HM_MULTI, "%s %s", static_cast<const char *>(Players[(int)(buf[1])].callsign), TXT_HAS_ESCAPED);
if (Game_mode & GM_NETWORK)
Players[(int)buf[1]].connected = CONNECT_ESCAPE_TUNNEL;
Players[(int)(buf[1])].connected = CONNECT_ESCAPE_TUNNEL;
if (!multi_goto_secret)
multi_goto_secret = 2;
}
else if (buf[2] == 1)
{
HUD_init_message(HM_MULTI, "%s %s", static_cast<const char *>(Players[(int)buf[1]].callsign), TXT_HAS_FOUND_SECRET);
HUD_init_message(HM_MULTI, "%s %s", static_cast<const char *>(Players[(int)(buf[1])].callsign), TXT_HAS_FOUND_SECRET);
if (Game_mode & GM_NETWORK)
Players[(int)buf[1]].connected = CONNECT_FOUND_SECRET;
Players[(int)(buf[1])].connected = CONNECT_FOUND_SECRET;
if (!multi_goto_secret)
multi_goto_secret = 1;
}
@ -2085,7 +2085,7 @@ static multi_do_quit(const ubyte *buf)
if (!(Game_mode & GM_NETWORK))
return;
multi_disconnect_player((int)buf[1]);
multi_disconnect_player((int)(buf[1]));
}
namespace dsx {
@ -4775,7 +4775,7 @@ void multi_restore_game(ubyte slot, uint id)
static void multi_do_msgsend_state(const ubyte *buf)
{
multi_sending_message[(int)buf[1]] = (msgsend_state_t)buf[2];
multi_sending_message[(int)(buf[1])] = (msgsend_state_t)buf[2];
}
void multi_send_msgsend_state(msgsend_state_t state)

View file

@ -1009,7 +1009,7 @@ void newdemo_record_start_demo()
}
if (Game_mode & GM_MULTI) {
nd_write_byte((int8_t) N_players);
nd_write_byte((int8_t) (N_players));
range_for (auto &i, partial_const_range(Players, N_players)) {
nd_write_string(static_cast<const char *>(i.callsign));
nd_write_byte(i.connected);
@ -1048,8 +1048,8 @@ void newdemo_record_start_demo()
nd_record_v_player_shields = (sbyte)(f2ir(get_local_player_shields()));
nd_write_byte((sbyte)(f2ir(get_local_player_shields())));
nd_write_int(nd_record_v_player_flags = get_local_player_flags().get_player_flags()); // be sure players flags are set
nd_write_byte((int8_t) Primary_weapon);
nd_write_byte((int8_t) Secondary_weapon);
nd_write_byte((int8_t) (Primary_weapon));
nd_write_byte((int8_t) (Secondary_weapon));
nd_record_v_start_frame = nd_record_v_frame_number = 0;
#if defined(DXX_BUILD_DESCENT_II)
nd_record_v_player_afterburner = 0;
@ -1278,7 +1278,7 @@ void newdemo_record_player_energy(int energy)
pause_game_world_time p;
nd_write_byte( ND_EVENT_PLAYER_ENERGY );
nd_write_byte(static_cast<int8_t>(exchange(nd_record_v_player_energy, energy)));
nd_write_byte((int8_t) energy);
nd_write_byte((int8_t) (energy));
}
#if defined(DXX_BUILD_DESCENT_II)
@ -1300,7 +1300,7 @@ void newdemo_record_player_shields(int shield)
pause_game_world_time p;
nd_write_byte( ND_EVENT_PLAYER_SHIELD );
nd_write_byte(static_cast<int8_t>(exchange(nd_record_v_player_shields, shield)));
nd_write_byte((int8_t) shield);
nd_write_byte((int8_t) (shield));
}
void newdemo_record_player_flags(uint flags)
@ -1328,7 +1328,7 @@ void newdemo_record_effect_blowup(segnum_t segment, int side, const vms_vector &
pause_game_world_time p;
nd_write_byte (ND_EVENT_EFFECT_BLOWUP);
nd_write_short(segment);
nd_write_byte((int8_t) side);
nd_write_byte((int8_t) (side));
nd_write_vector(pnt);
}
@ -1391,28 +1391,28 @@ void newdemo_record_multi_cloak(int pnum)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_CLOAK);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
}
void newdemo_record_multi_decloak(int pnum)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_DECLOAK);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
}
void newdemo_record_multi_death(int pnum)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_DEATH);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
}
void newdemo_record_multi_kill(int pnum, sbyte kill)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_KILL);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
nd_write_byte(kill);
}
@ -1420,8 +1420,8 @@ void newdemo_record_multi_connect(int pnum, int new_player, const char *new_call
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_CONNECT);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) new_player);
nd_write_byte((int8_t) (pnum));
nd_write_byte((int8_t) (new_player));
if (!new_player) {
nd_write_string(static_cast<const char *>(Players[pnum].callsign));
nd_write_int(Players[pnum].net_killed_total);
@ -1434,14 +1434,14 @@ void newdemo_record_multi_reconnect(int pnum)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_RECONNECT);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
}
void newdemo_record_multi_disconnect(int pnum)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_DISCONNECT);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
}
void newdemo_record_player_score(int score)
@ -1455,7 +1455,7 @@ void newdemo_record_multi_score(int pnum, int score)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_MULTI_SCORE);
nd_write_byte((int8_t) pnum);
nd_write_byte((int8_t) (pnum));
nd_write_int(score - Players[pnum].score); // called before score is changed!!!!
}
@ -1484,7 +1484,7 @@ void newdemo_record_door_opening(segnum_t segnum, int side)
pause_game_world_time p;
nd_write_byte(ND_EVENT_DOOR_OPENING);
nd_write_short(segnum);
nd_write_byte((int8_t) side);
nd_write_byte((int8_t) (side));
}
void newdemo_record_laser_level(sbyte old_level, sbyte new_level)
@ -1518,8 +1518,8 @@ void newdemo_set_new_level(int level_num)
{
pause_game_world_time p;
nd_write_byte(ND_EVENT_NEW_LEVEL);
nd_write_byte((int8_t) level_num);
nd_write_byte((int8_t) Current_level_num);
nd_write_byte((int8_t) (level_num));
nd_write_byte((int8_t) (Current_level_num));
#if defined(DXX_BUILD_DESCENT_II)
if (nd_record_v_juststarted==1)
{
@ -3688,8 +3688,8 @@ static void newdemo_write_end()
nd_write_byte((sbyte)(f2ir(get_local_player_energy())));
nd_write_byte((sbyte)(f2ir(get_local_player_shields())));
nd_write_int(get_local_player_flags().get_player_flags()); // be sure players flags are set
nd_write_byte((int8_t) Primary_weapon);
nd_write_byte((int8_t) Secondary_weapon);
nd_write_byte((int8_t) (Primary_weapon));
nd_write_byte((int8_t) (Secondary_weapon));
byte_count += 8;
for (int i = 0; i < MAX_PRIMARY_WEAPONS; i++)
@ -3704,7 +3704,7 @@ static void newdemo_write_end()
byte_count++;
if (Game_mode & GM_MULTI) {
nd_write_byte((int8_t) N_players);
nd_write_byte((int8_t) (N_players));
byte_count++;
range_for (auto &i, partial_const_range(Players, N_players)) {
nd_write_string(static_cast<const char *>(i.callsign));

View file

@ -88,7 +88,7 @@ static int pof_read_int(ubyte *bufp)
{
int i;
i = *((int *) &bufp[Pof_addr]);
i = *((int *) (&bufp[Pof_addr]));
Pof_addr += 4;
return INTEL_INT(i);
@ -120,7 +120,7 @@ static short pof_read_short(ubyte *bufp)
{
short s;
s = *((short *) &bufp[Pof_addr]);
s = *((short *) (&bufp[Pof_addr]));
Pof_addr += 2;
return INTEL_SHORT(s);
// if (PHYSFS_read(f,&s,sizeof(s),1) != 1)