From 035436c63944e66c0f511d0eea9422204559556d Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Mon, 25 Sep 2023 08:53:23 -0400 Subject: [PATCH] ajout errlog --- SQCSim-common/netprotocol.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/SQCSim-common/netprotocol.h b/SQCSim-common/netprotocol.h index 3609de9..a1beb1c 100644 --- a/SQCSim-common/netprotocol.h +++ b/SQCSim-common/netprotocol.h @@ -11,7 +11,7 @@ namespace netprot { ERR, INPUT, OUTPUT, SYNC, TEAMINF, SELFINF, PLAYINF, CHUNKMOD, PLAYERMOD, PICKUPMOD, - GAMEINFO, ENDINFO , CHAT + GAMEINFO, ENDINFO , CHAT, ERRLOG }; typedef struct { // cli -> srv UDP ~frame @@ -31,10 +31,10 @@ namespace netprot { typedef struct { // srv -> cli TCP ~second Timestamp timestamp; - uint64_t sid = 0, - timer = 0; - uint8_t hp = 0; + uint64_t sid = 0; + uint32_t timer = 0; uint16_t ammo = 0; + uint8_t hp = 0; Vector3f position; } Sync; @@ -54,11 +54,11 @@ namespace netprot { uint64_t id = 0, tid = 0; } PlayerInfo; - - typedef struct { + + typedef struct { // cli <-> srv TCP event (before game start)/ once uint64_t seed; - // uint8_t gameType; - // uint8_t time; + uint32_t countdown; + uint8_t gameType; // TOOD: enum. } GameInfo; typedef struct { // cli <-> srv TCP event @@ -68,21 +68,30 @@ namespace netprot { char mess[140]; // Good 'nough for twitr, good 'nough for me. } Chat; + typedef struct { // srv -> cli TCP event + char mess[140]; + bool is_fatal; + } ErrorLog; + inline void Serialize(Input* in, char* buf, uint32_t* buflen); // cli inline void Serialize(Output* out, char* buf, uint32_t* buflen); // srv inline void Serialize(Sync* sync, char* buf, uint32_t* buflen); // srv inline void Serialize(TeamInfo* tinfo, char* buf, uint32_t* buflen); // cli/srv inline void Serialize(SelfInfo* sinfo, char* buf, uint32_t* buflen); // cli/srv inline void Serialize(PlayerInfo* pinfo, char* buf, uint32_t* buflen); // srv + inline void Serialize(GameInfo* ginfo, char* buf, uint32_t* buflen); // cli/srv inline void Serialize(Chat* chat, char* buf, uint32_t* buflen); // cli/srv + inline void Serialize(ErrorLog* errlog, char* buf, uint32_t* buflen); // srv inline void Deserialize(Input* in, char* buf, uint32_t* buflen); // srv inline void Deserialize(Output* out, char* buf, uint32_t* buflen); // cli inline void Deserialize(Sync* sync, char* buf, uint32_t* buflen); // cli inline void Deserialize(TeamInfo* tinfo, char* buf, uint32_t* buflen); // cli/srv inline void Deserialize(SelfInfo* sinfo, char* buf, uint32_t* buflen); // cli/srv - inline void Deserialize(PlayerInfo* spinfoync, char* buf, uint32_t* buflen); // cli + inline void Deserialize(PlayerInfo* pinfo, char* buf, uint32_t* buflen); // cli + inline void Deserialize(GameInfo* ginfo, char* buf, uint32_t* buflen); // cli inline void Deserialize(Chat* chat, char* buf, uint32_t* buflen); // srv/cli + inline void Deserialize(ErrorLog* errlog, char* buf, uint32_t* buflen); // srv inline PacketType getType(char* buf, uint32_t* buflen); // srv/cli }