diff --git a/protocol.h b/protocol.h
index a20c773d16fbe0751ac5fcb6b6f9da3c4f05b233..a96d6932a6728f0eb5d6cb7b6cc95e45abafa63e 100644 (file)
--- a/protocol.h
+++ b/protocol.h
#include <stdbool.h>
#include <string.h>
#include <stdbool.h>
#include <string.h>
-#define DEFAULT_PORT 29386
-#define PROTOCOL_VERSION 1
+#define PROTOCOL_PORT 29386
+#define PROTOCOL_VERSION 3
#define PROTOCOL_F8FRAC (1 << 7)
#define PACKED __attribute__((__packed__))
#define PROTOCOL_F8FRAC (1 << 7)
#define PACKED __attribute__((__packed__))
SV_SBUL = 131,
} MessageType;
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;
typedef struct PACKED ClInfo {
uint8_t type;
} ClKill;
typedef struct PACKED ClDoes {
} ClKill;
typedef struct PACKED ClDoes {
- uint8_t type;
- uint8_t code;
+ uint8_t type;
+ DoesBits code;
} ClDoes;
typedef struct PACKED SvInfo {
} ClDoes;
typedef struct PACKED SvInfo {
uint8_t live;
uint8_t x, y, r;
uint8_t vx, vy, vr;
uint8_t live;
uint8_t x, y, r;
uint8_t vx, vy, vr;
+ uint8_t shoot;
} SvSplr;
typedef struct PACKED SvSbul {
} SvSplr;
typedef struct PACKED SvSbul {
};
}
};
}
-static inline ProtocolMessage cl_does(DoesCode code) {
+static inline ProtocolMessage cl_does(DoesBits code) {
return (ProtocolMessage) (ClMessage) (ClDoes) {
.type = CL_DOES,
.code = code,
return (ProtocolMessage) (ClMessage) (ClDoes) {
.type = CL_DOES,
.code = code,
return (ProtocolMessage) (SvMessage) m;
}
return (ProtocolMessage) (SvMessage) m;
}
-static inline ProtocolMessage sv_splr(int clid, bool live, float x, float y, float r, float vx, float vy, float vr) {
+static inline ProtocolMessage sv_splr(int clid, bool live, float x, float y, float r, float vx, float vy, float vr, int shoot) {
return (ProtocolMessage) (SvMessage) (SvSplr) {
return (ProtocolMessage) (SvMessage) (SvSplr) {
- .type = SV_SPLR,
- .clid = clid,
- .live = live,
- .x = f2b(x),
- .y = f2b(y),
- .r = f2b(r),
+ .type = SV_SPLR,
+ .clid = clid,
+ .live = live,
+ .x = f2b(x),
+ .y = f2b(y),
+ .r = f2b(r),
.vx = f2b(vx),
.vy = f2b(vy),
.vr = f2b(vr),
.vx = f2b(vx),
.vy = f2b(vy),
.vr = f2b(vr),
+ .shoot = shoot,
};
}
};
}