diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 15:29:19 +0200 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 15:29:19 +0200 |
commit | ead2881be92d33076c2104dbd75bad3561f26088 (patch) | |
tree | 75ed0217a40a1321ce22ca7b675f4d148ce29161 /include/content.h | |
parent | f19e329254d89ddf6d946410b56975a5c550c3f4 (diff) |
server: implement auth and sending nodes
Diffstat (limited to 'include/content.h')
-rw-r--r-- | include/content.h | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/include/content.h b/include/content.h index ac20e7e..ed8b822 100644 --- a/include/content.h +++ b/include/content.h @@ -5,6 +5,9 @@ #ifndef CONTENT_H #define CONTENT_H +#include <stdint.h> +#include <stdbool.h> + typedef enum { N_VALLEY_FLOWER, N_MOUNTAIN_FLOWER, @@ -14,12 +17,24 @@ typedef enum { N_WATER, N_PLANK, N_PATH, + N_GRASS, + N_SAND, } node_type; typedef struct { uint8_t r, g, b; } color; +static inline uint32_t color_u32(color c) +{ + return ((uint32_t) c.b) | (((uint32_t) c.g) << 8) | (((uint32_t) c.r) << 16); +} + +static inline color u32_color(uint32_t u) +{ + return (color) { (u >> 16) & 0xFF, (u >> 8) & 0xFF, u & 0xFF }; +} + typedef struct { bool present; node_type type; @@ -28,22 +43,36 @@ typedef struct { } node; typedef enum { - MOVE_UP, + MOVE_UP = 0, MOVE_DOWN, MOVE_LEFT, MOVE_RIGHT, } move_dir; -typedef enum { - CPKT_HI, // len motd - CPKT_PLAYERS, // len +typedef uint8_t fail_reason; +#define ser_fail_reason ser_u8 +#define deser_fail_reason deser_u8 + +enum { + FAIL_WRONG_PASS = 0, + FAIL_ALREADY_ONLINE, +}; + +typedef uint16_t pkt_type; +#define ser_pkt_type ser_u16 +#define deser_pkt_type deser_u16 + +enum { + CPKT_HI = 0, // len motd + CPKT_FAIL, // fail_reason + CPKT_PLAYERS, // len [len name id] CPKT_MOVE, // player_id remove x y z CPKT_NODES, // z x y w h [node] -} client_pkt; +}; -typedef enum { - SPKT_HI, // len name len password +enum { + SPKT_HI = 0, // len name len password SPKT_MOVE, // move_dir -} server_pkt; +}; #endif |