diff --git a/common/misc/hmp.cpp b/common/misc/hmp.cpp index f48787418..1cfb4a174 100644 --- a/common/misc/hmp.cpp +++ b/common/misc/hmp.cpp @@ -298,12 +298,12 @@ static int fill_buffer(hmp_file *hmp) { i = hmp->pending_size; *(p++) = hmp->pending_event | i; *(p++) = 0; - memcpy((uint8_t *)(p), hmp->pending, i); + memcpy(reinterpret_cast(p), hmp->pending, i); hmp->pending_size -= i; p += (i + 3) / 4; } else { if ((i = get_event(hmp, &ev))) { - mhdr->dwBytesRecorded = ((uint8_t *)(p)) - ((uint8_t *)(mhdr->lpData)); + mhdr->dwBytesRecorded = (reinterpret_cast(p)) - (reinterpret_cast(mhdr->lpData)); return i; } if (ev.datalen) { @@ -320,7 +320,7 @@ static int fill_buffer(hmp_file *hmp) { } } } - mhdr->dwBytesRecorded = ((uint8_t *)(p)) - ((uint8_t *)(mhdr->lpData)); + mhdr->dwBytesRecorded = (reinterpret_cast(p)) - (reinterpret_cast(mhdr->lpData)); return 0; } diff --git a/d2x-rebirth/libmve/decoder8.cpp b/d2x-rebirth/libmve/decoder8.cpp index 78e1e1c6c..eb13fc591 100644 --- a/d2x-rebirth/libmve/decoder8.cpp +++ b/d2x-rebirth/libmve/decoder8.cpp @@ -29,14 +29,14 @@ void decodeFrame8(unsigned char *pFrame, const unsigned char *pMap, int mapRemai for (int i=0; i(g_vBackBuf1)) con_printf(CON_CRITICAL, "danger! pointing out of bounds below after dispatch decoder: %d, %d (1) [%x]", i, j, (*pMap) & 0xf); - else if (pFrame >= ((uint8_t *)(g_vBackBuf1)) + g_width*g_height) + else if (pFrame >= (reinterpret_cast(g_vBackBuf1)) + g_width*g_height) con_printf(CON_CRITICAL, "danger! pointing out of bounds above after dispatch decoder: %d, %d (1) [%x]", i, j, (*pMap) & 0xf); dispatchDecoder(&pFrame, (*pMap) >> 4, &pData, &dataRemain, &i, &j); - if (pFrame < (uint8_t *)(g_vBackBuf1)) + if (pFrame < reinterpret_cast(g_vBackBuf1)) con_printf(CON_CRITICAL, "danger! pointing out of bounds below after dispatch decoder: %d, %d (2) [%x]", i, j, (*pMap) >> 4); - else if (pFrame >= ((uint8_t *)(g_vBackBuf1)) + g_width*g_height) + else if (pFrame >= (reinterpret_cast(g_vBackBuf1)) + g_width*g_height) con_printf(CON_CRITICAL, "danger! pointing out of bounds above after dispatch decoder: %d, %d (2) [%x]", i, j, (*pMap) >> 4); ++pMap; @@ -229,7 +229,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons { case 0x0: /* block is copied from block in current frame */ - copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1))); + copyFrame(*pFrame, *pFrame + (reinterpret_cast(g_vBackBuf2) - reinterpret_cast(g_vBackBuf1))); case 0x1: /* block is unchanged from two frames ago */ *pFrame += 8; @@ -287,7 +287,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons y = -8 + BH */ relClose(*(*pData)++, &x, &y); - copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1)) + x + y*g_width); + copyFrame(*pFrame, *pFrame + (reinterpret_cast(g_vBackBuf2) - reinterpret_cast(g_vBackBuf1)) + x + y*g_width); *pFrame += 8; --*pDataRemain; break; @@ -300,7 +300,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons */ x = (signed char)*(*pData)++; y = (signed char)*(*pData)++; - copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1)) + x + y*g_width); + copyFrame(*pFrame, *pFrame + (reinterpret_cast(g_vBackBuf2) - reinterpret_cast(g_vBackBuf1)) + x + y*g_width); *pFrame += 8; *pDataRemain -= 2; break; diff --git a/d2x-rebirth/libmve/mveplay.cpp b/d2x-rebirth/libmve/mveplay.cpp index ed1833775..9331cb4b5 100644 --- a/d2x-rebirth/libmve/mveplay.cpp +++ b/d2x-rebirth/libmve/mveplay.cpp @@ -629,7 +629,7 @@ static int video_data_handler(unsigned char, unsigned char, const unsigned char if (nFlags & 1) { - temp = (uint8_t *)(g_vBackBuf1); + temp = reinterpret_cast(g_vBackBuf1); g_vBackBuf1 = g_vBackBuf2; g_vBackBuf2 = temp; } diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index a37472c2e..8593b0ead 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -2759,7 +2759,7 @@ void multi_send_kill(const vobjptridx_t objnum) if (killer_objnum != object_none) { - short s = (short)objnum_local_to_remote(killer_objnum, (int8_t *)(&multibuf[count+2])); // do it with variable since INTEL_SHORT won't work on return val from function. + short s = (short)objnum_local_to_remote(killer_objnum, reinterpret_cast(&multibuf[count+2])); // do it with variable since INTEL_SHORT won't work on return val from function. PUT_INTEL_SHORT(multibuf+count, s); } else diff --git a/similar/main/multibot.cpp b/similar/main/multibot.cpp index a9fe2316f..b2ea41fa4 100644 --- a/similar/main/multibot.cpp +++ b/similar/main/multibot.cpp @@ -348,7 +348,7 @@ void multi_send_release_robot(const vobjptridx_t objnum) multi_delete_controlled_robot(objnum); multibuf[1] = Player_num; - s = objnum_local_to_remote(objnum, (int8_t *)(&multibuf[4])); + s = objnum_local_to_remote(objnum, reinterpret_cast(&multibuf[4])); PUT_INTEL_SHORT(multibuf+2, s); multi_send_data(multibuf, 5, 2); @@ -426,7 +426,7 @@ void multi_send_robot_position_sub(const vobjptridx_t objnum, int now) loc += 1; multibuf[loc] = Player_num; loc += 1; - s = objnum_local_to_remote(objnum, (int8_t *)(&multibuf[loc+2])); + s = objnum_local_to_remote(objnum, reinterpret_cast(&multibuf[loc+2])); PUT_INTEL_SHORT(multibuf+loc, s); loc += 3; // 5 quaternionpos qpp{}; @@ -482,7 +482,7 @@ void multi_send_robot_fire(const vobjptridx_t obj, int gun_num, const vms_vector loc += 1; multibuf[loc] = Player_num; loc += 1; - s = objnum_local_to_remote(obj, (int8_t *)(&multibuf[loc+2])); + s = objnum_local_to_remote(obj, reinterpret_cast(&multibuf[loc+2])); PUT_INTEL_SHORT(multibuf+loc, s); loc += 3; multibuf[loc] = gun_num; loc += 1; diff --git a/similar/main/newdemo.cpp b/similar/main/newdemo.cpp index 93e245024..63ad74aff 100644 --- a/similar/main/newdemo.cpp +++ b/similar/main/newdemo.cpp @@ -1669,7 +1669,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose) { if (Newdemo_game_mode & GM_TEAM) { - nd_read_byte((int8_t *)(&Netgame.team_vector)); + nd_read_byte(reinterpret_cast(&Netgame.team_vector)); if (purpose == PURPOSE_REWRITE) nd_write_byte(Netgame.team_vector); } @@ -1686,7 +1686,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose) else { if (Newdemo_game_mode & GM_TEAM) { - nd_read_byte((int8_t *) (&Netgame.team_vector)); + nd_read_byte(reinterpret_cast(&Netgame.team_vector)); nd_read_string(Netgame.team_name[0].buffer()); nd_read_string(Netgame.team_name[1].buffer()); if (purpose == PURPOSE_REWRITE) @@ -1704,7 +1704,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose) N_players = static_cast(c); // changed this to above two lines -- breaks on the mac because of // endian issues - // nd_read_byte((int8_t *)(&N_players)); + // nd_read_byte(reinterpret_cast(&N_players)); if (purpose == PURPOSE_REWRITE) nd_write_byte(N_players); range_for (auto &i, partial_range(Players, N_players)) { @@ -1811,8 +1811,8 @@ static int newdemo_read_demo_start(enum purpose_type purpose) nd_recorded_total = 0; nd_playback_total = 0; - nd_read_byte((int8_t *)(&energy)); - nd_read_byte((int8_t *)(&shield)); + nd_read_byte(reinterpret_cast(&energy)); + nd_read_byte(reinterpret_cast(&shield)); if (purpose == PURPOSE_REWRITE) { nd_write_byte(energy); @@ -1830,8 +1830,8 @@ static int newdemo_read_demo_start(enum purpose_type purpose) if (get_local_player_flags() & PLAYER_FLAGS_INVULNERABLE) get_local_player_invulnerable_time() = GameTime64 - (INVULNERABLE_TIME_MAX / 2); - nd_read_byte((int8_t *)(&Primary_weapon)); - nd_read_byte((int8_t *)(&Secondary_weapon)); + nd_read_byte(reinterpret_cast(&Primary_weapon)); + nd_read_byte(reinterpret_cast(&Secondary_weapon)); if (purpose == PURPOSE_REWRITE) { nd_write_byte(Primary_weapon); @@ -1845,7 +1845,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose) #if defined(DXX_BUILD_DESCENT_I) if (shareware) { - nd_read_byte((int8_t *)(&c)); + nd_read_byte(reinterpret_cast(&c)); if (c != ND_EVENT_NEW_LEVEL) { auto flags = get_local_player_flags().get_player_flags(); energy = shield; @@ -2349,8 +2349,8 @@ static int newdemo_read_frame_information(int rewrite) ubyte old_energy; if (!shareware) - nd_read_byte((int8_t *)(&old_energy)); - nd_read_byte((int8_t *)(&energy)); + nd_read_byte(reinterpret_cast(&old_energy)); + nd_read_byte(reinterpret_cast(&energy)); if (nd_playback_v_bad_read) {done = -1; break; } if (rewrite) @@ -2378,8 +2378,8 @@ static int newdemo_read_frame_information(int rewrite) ubyte afterburner; ubyte old_afterburner; - nd_read_byte((int8_t *)(&old_afterburner)); - nd_read_byte((int8_t *)(&afterburner)); + nd_read_byte(reinterpret_cast(&old_afterburner)); + nd_read_byte(reinterpret_cast(&afterburner)); if (nd_playback_v_bad_read) {done = -1; break; } if (rewrite) { @@ -2403,8 +2403,8 @@ static int newdemo_read_frame_information(int rewrite) ubyte old_shield; if (!shareware) - nd_read_byte((int8_t *)(&old_shield)); - nd_read_byte((int8_t *)(&shield)); + nd_read_byte(reinterpret_cast(&old_shield)); + nd_read_byte(reinterpret_cast(&shield)); if (nd_playback_v_bad_read) {done = -1; break; } if (rewrite) { @@ -2473,8 +2473,8 @@ static int newdemo_read_frame_information(int rewrite) { ubyte weapon_type, weapon_num; - nd_read_byte((int8_t *)(&weapon_type)); - nd_read_byte((int8_t *)(&weapon_num)); + nd_read_byte(reinterpret_cast(&weapon_type)); + nd_read_byte(reinterpret_cast(&weapon_num)); if (rewrite) { nd_write_byte(weapon_type); @@ -2494,9 +2494,9 @@ static int newdemo_read_frame_information(int rewrite) ubyte weapon_type, weapon_num; ubyte old_weapon; - nd_read_byte((int8_t *)(&weapon_type)); - nd_read_byte((int8_t *)(&weapon_num)); - nd_read_byte((int8_t *)(&old_weapon)); + nd_read_byte(reinterpret_cast(&weapon_type)); + nd_read_byte(reinterpret_cast(&weapon_num)); + nd_read_byte(reinterpret_cast(&old_weapon)); if (rewrite) { nd_write_byte(weapon_type); @@ -3269,8 +3269,8 @@ void newdemo_goto_end(int to_rewrite) nd_read_short(&bshort); nd_read_int(&bint); - nd_read_byte((int8_t *)(&energy)); - nd_read_byte((int8_t *)(&shield)); + nd_read_byte(reinterpret_cast(&energy)); + nd_read_byte(reinterpret_cast(&shield)); get_local_player_energy() = i2f(energy); get_local_player_shields() = i2f(shield); int recorded_player_flags; @@ -3281,8 +3281,8 @@ void newdemo_goto_end(int to_rewrite) } if (get_local_player_flags() & PLAYER_FLAGS_INVULNERABLE) get_local_player_invulnerable_time() = GameTime64 - (INVULNERABLE_TIME_MAX / 2); - nd_read_byte((int8_t *)(&Primary_weapon)); - nd_read_byte((int8_t *)(&Secondary_weapon)); + nd_read_byte(reinterpret_cast(&Primary_weapon)); + nd_read_byte(reinterpret_cast(&Secondary_weapon)); for (int i = 0; i < MAX_PRIMARY_WEAPONS; i++) { short s; @@ -3309,7 +3309,7 @@ void newdemo_goto_end(int to_rewrite) N_players = static_cast(c); // see newdemo_read_start_demo for explanation of // why this is commented out - // nd_read_byte((int8_t *)(&N_players)); + // nd_read_byte(reinterpret_cast(&N_players)); range_for (auto &i, partial_range(Players, N_players)) { nd_read_string(i.callsign.buffer()); nd_read_byte(&(i.connected)); diff --git a/similar/main/piggy.cpp b/similar/main/piggy.cpp index d25a28788..68b544179 100644 --- a/similar/main/piggy.cpp +++ b/similar/main/piggy.cpp @@ -1841,7 +1841,7 @@ static void bitmap_read_d1( grs_bitmap *bitmap, /* read into this bitmap */ *next_bitmap += new_size - zsize; } else { Assert( zsize + JUST_IN_CASE >= new_size ); - bitmap->bm_mdata = (uint8_t *) (d_realloc(bitmap->bm_mdata, new_size)); + bitmap->bm_mdata = reinterpret_cast(d_realloc(bitmap->bm_mdata, new_size)); Assert(bitmap->bm_data); } }