Use pragma pack in sw/src/network.h instead of the locally defined

PACKED macro. This is more consistent with the current Duke3D codebase,
and further fixes build with older versions of MinGW GCC, in which
attribute packed is broken without specifying -mno-ms-bitfields.
This commit is contained in:
NY00123 2020-04-14 22:59:45 +03:00 committed by Christoph Oelckers
parent ff49bc2209
commit 3913a05713

View file

@ -52,27 +52,16 @@ BEGIN_SW_NS
#define SYNC_TEST TRUE #define SYNC_TEST TRUE
#define MAXSYNCBYTES 16 #define MAXSYNCBYTES 16
#ifdef __GNUC__ #pragma pack(push,1)
# define PACKED __attribute__ ((packed))
#else
# define PACKED
# ifdef _MSC_VER
# pragma pack(1)
# endif
# ifdef __WATCOMC__
# pragma pack(push,1);
# endif
#endif
// Slave->Master: PlayerIndex = who to send the packet to (-1 = all) // Slave->Master: PlayerIndex = who to send the packet to (-1 = all)
// Master->Slave: PlayerIndex = who sent the packet originally // Master->Slave: PlayerIndex = who sent the packet originally
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
uint8_t PlayerIndex; uint8_t PlayerIndex;
} PACKET_PROXY,*PACKET_PROXYp; } PACKET_PROXY,*PACKET_PROXYp;
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
uint8_t FirstPlayerIndex; uint8_t FirstPlayerIndex;
@ -89,7 +78,7 @@ typedef struct PACKED
SWBOOL Nuke; SWBOOL Nuke;
} PACKET_NEW_GAME,*PACKET_NEW_GAMEp; } PACKET_NEW_GAME,*PACKET_NEW_GAMEp;
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
SWBOOL AutoRun; SWBOOL AutoRun;
@ -97,31 +86,24 @@ typedef struct PACKED
char PlayerName[32]; char PlayerName[32];
} PACKET_OPTIONS,*PACKET_OPTIONSp; } PACKET_OPTIONS,*PACKET_OPTIONSp;
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
char PlayerName[32]; char PlayerName[32];
} PACKET_NAME_CHANGE,*PACKET_NAME_CHANGEp; } PACKET_NAME_CHANGE,*PACKET_NAME_CHANGEp;
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
uint8_t RTSnum; uint8_t RTSnum;
} PACKET_RTS,*PACKET_RTSp; } PACKET_RTS,*PACKET_RTSp;
typedef struct PACKED typedef struct
{ {
uint8_t PacketType; // first byte is always packet type uint8_t PacketType; // first byte is always packet type
int Version; int Version;
} PACKET_VERSION,*PACKET_VERSIONp; } PACKET_VERSION,*PACKET_VERSIONp;
#pragma pack(pop)
#undef PACKED
#ifdef _MSC_VER
# pragma pack()
#endif
#ifdef __WATCOMC__
# pragma pack(pop);
#endif
extern uint8_t syncstat[MAXSYNCBYTES]; extern uint8_t syncstat[MAXSYNCBYTES];
extern SWBOOL PredictionOn; extern SWBOOL PredictionOn;