From 836aa10f8c0337551d8f24d3718172398e707f67 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 11 Aug 2013 15:17:28 +0000 Subject: [PATCH] Use macro PUT_WEAPON_FLAGS to hide differences in D1X vs D2X D2X uses a bigger field due to added weapons, but the idea is the same in both games. --- d1x-rebirth/main/multi.c | 5 +++-- d2x-rebirth/main/multi.c | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/d1x-rebirth/main/multi.c b/d1x-rebirth/main/multi.c index 662ca7080..5789a7d3d 100644 --- a/d1x-rebirth/main/multi.c +++ b/d1x-rebirth/main/multi.c @@ -2415,8 +2415,9 @@ multi_send_player_explode(char type) multibuf[count++] = type; multibuf[count++] = Player_num; - multibuf[count++] = (char)Players[Player_num].primary_weapon_flags; - multibuf[count++] = (char)Players[Player_num].secondary_weapon_flags; +#define PUT_WEAPON_FLAGS(buf,count,value) (buf[count] = value, ++count) + PUT_WEAPON_FLAGS(multibuf, count, Players[Player_num].primary_weapon_flags); + PUT_WEAPON_FLAGS(multibuf, count, Players[Player_num].secondary_weapon_flags); multibuf[count++] = (char)Players[Player_num].laser_level; multibuf[count++] = (char)Players[Player_num].secondary_ammo[HOMING_INDEX]; multibuf[count++] = (char)Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; diff --git a/d2x-rebirth/main/multi.c b/d2x-rebirth/main/multi.c index fd9f1f25c..fdbf2ad3c 100644 --- a/d2x-rebirth/main/multi.c +++ b/d2x-rebirth/main/multi.c @@ -2555,10 +2555,9 @@ multi_send_player_explode(char type) multibuf[count++] = type; multibuf[count++] = Player_num; - PUT_INTEL_SHORT(multibuf+count, Players[Player_num].primary_weapon_flags); - count += 2; - PUT_INTEL_SHORT(multibuf+count, Players[Player_num].secondary_weapon_flags); - count += 2; +#define PUT_WEAPON_FLAGS(buf,count,value) ((PUT_INTEL_SHORT(buf+count, value)), count+=sizeof(uint16_t)) + PUT_WEAPON_FLAGS(multibuf, count, Players[Player_num].primary_weapon_flags); + PUT_WEAPON_FLAGS(multibuf, count, Players[Player_num].secondary_weapon_flags); multibuf[count++] = (char)Players[Player_num].laser_level; multibuf[count++] = (char)Players[Player_num].secondary_ammo[HOMING_INDEX];