X-Git-Url: https://deadsoftware.ru/gitweb?p=netwar.git;a=blobdiff_plain;f=protocol.h;h=68ec54a55aaa9a7c44b2a1af22c74c6c66a71652;hp=a20c773d16fbe0751ac5fcb6b6f9da3c4f05b233;hb=0ce00cd1d7ade8d9f72a4b7f67154e82ed9079b6;hpb=4148d3ff0c0c4b52b0741c38a867a1502600a65f diff --git a/protocol.h b/protocol.h index a20c773..68ec54a 100644 --- a/protocol.h +++ b/protocol.h @@ -5,8 +5,8 @@ #include #include -#define DEFAULT_PORT 29386 -#define PROTOCOL_VERSION 1 +#define PROTOCOL_PORT 29386 +#define PROTOCOL_VERSION 2 #define PROTOCOL_F8FRAC (1 << 7) #define PACKED __attribute__((__packed__)) @@ -24,13 +24,16 @@ typedef enum { SV_SBUL = 131, } MessageType; -typedef enum { - DOES_UP = 0, - DOES_DOWN = 1, - DOES_LEFT = 2, - DOES_RIGHT = 3, - DOES_FIRE = 4, -} DoesCode; +typedef union DoesBits { + uint8_t bits; + struct PACKED { + uint8_t up : 1; + uint8_t down : 1; + uint8_t left : 1; + uint8_t right : 1; + uint8_t fire : 1; + }; +} DoesBits; typedef struct PACKED ClInfo { uint8_t type; @@ -43,8 +46,8 @@ typedef struct PACKED ClKill { } ClKill; typedef struct PACKED ClDoes { - uint8_t type; - uint8_t code; + uint8_t type; + DoesBits code; } ClDoes; typedef struct PACKED SvInfo { @@ -135,7 +138,7 @@ static inline ProtocolMessage cl_kill() { }; } -static inline ProtocolMessage cl_does(DoesCode code) { +static inline ProtocolMessage cl_does(DoesBits code) { return (ProtocolMessage) (ClMessage) (ClDoes) { .type = CL_DOES, .code = code,