Commit 8b622643 authored by Chen Bill's avatar Chen Bill Committed by GitHub

use uint8_t in network.h (#2646)

parent 18a801c0
......@@ -20,16 +20,16 @@ namespace ygo {
struct HostInfo {
uint32_t lflist{};
unsigned char rule{};
unsigned char mode{};
unsigned char duel_rule{};
unsigned char no_check_deck{};
unsigned char no_shuffle_deck{};
uint8_t rule{};
uint8_t mode{};
uint8_t duel_rule{};
uint8_t no_check_deck{};
uint8_t no_shuffle_deck{};
// byte padding[3]
uint32_t start_lp{};
unsigned char start_hand{};
unsigned char draw_count{};
uint8_t start_hand{};
uint8_t draw_count{};
uint16_t time_limit{};
};
check_trivially_copyable(HostInfo);
......@@ -62,13 +62,13 @@ struct CTOS_DeckData {
check_trivially_copyable(CTOS_DeckData);
struct CTOS_HandResult {
unsigned char res{};
uint8_t res{};
};
check_trivially_copyable(CTOS_HandResult);
static_assert(sizeof(CTOS_HandResult) == 1, "size mismatch: CTOS_HandResult");
struct CTOS_TPResult {
unsigned char res{};
uint8_t res{};
};
check_trivially_copyable(CTOS_TPResult);
static_assert(sizeof(CTOS_TPResult) == 1, "size mismatch: CTOS_TPResult");
......@@ -98,14 +98,14 @@ check_trivially_copyable(CTOS_JoinGame);
static_assert(sizeof(CTOS_JoinGame) == 48, "size mismatch: CTOS_JoinGame");
struct CTOS_Kick {
unsigned char pos{};
uint8_t pos{};
};
check_trivially_copyable(CTOS_Kick);
static_assert(sizeof(CTOS_Kick) == 1, "size mismatch: CTOS_Kick");
// STOC
struct STOC_ErrorMsg {
unsigned char msg{};
uint8_t msg{};
// byte padding[3]
uint32_t code{};
......@@ -114,8 +114,8 @@ check_trivially_copyable(STOC_ErrorMsg);
static_assert(sizeof(STOC_ErrorMsg) == 8, "size mismatch: STOC_ErrorMsg");
struct STOC_HandResult {
unsigned char res1{};
unsigned char res2{};
uint8_t res1{};
uint8_t res2{};
};
check_trivially_copyable(STOC_HandResult);
static_assert(sizeof(STOC_HandResult) == 2, "size mismatch: STOC_HandResult");
......@@ -134,20 +134,20 @@ check_trivially_copyable(STOC_JoinGame);
static_assert(sizeof(STOC_JoinGame) == 20, "size mismatch: STOC_JoinGame");
struct STOC_TypeChange {
unsigned char type{};
uint8_t type{};
};
check_trivially_copyable(STOC_TypeChange);
static_assert(sizeof(STOC_TypeChange) == 1, "size mismatch: STOC_TypeChange");
// reserved for STOC_LEAVE_GAME
struct STOC_ExitGame {
unsigned char pos{};
uint8_t pos{};
};
check_trivially_copyable(STOC_ExitGame);
static_assert(sizeof(STOC_ExitGame) == 1, "size mismatch: STOC_ExitGame");
struct STOC_TimeLimit {
unsigned char player{};
uint8_t player{};
// byte padding[1]
uint16_t left_time{};
......@@ -166,7 +166,7 @@ constexpr int SIZE_STOC_CHAT = (LEN_CHAT_PLAYER + LEN_CHAT_MSG) * sizeof(uint16_
struct STOC_HS_PlayerEnter {
uint16_t name[20]{};
unsigned char pos{};
uint8_t pos{};
// byte padding[1]
};
check_trivially_copyable(STOC_HS_PlayerEnter);
......@@ -175,7 +175,7 @@ constexpr int STOC_HS_PlayerEnter_size = 41; //workwround
struct STOC_HS_PlayerChange {
//pos<<4 | state
unsigned char status{};
uint8_t status{};
};
check_trivially_copyable(STOC_HS_PlayerChange);
static_assert(sizeof(STOC_HS_PlayerChange) == 1, "size mismatch: STOC_HS_PlayerChange");
......@@ -189,10 +189,10 @@ static_assert(sizeof(STOC_HS_WatchChange) == 2, "size mismatch: STOC_HS_WatchCha
class DuelMode;
struct DuelPlayer {
unsigned short name[20]{};
uint16_t name[20]{};
DuelMode* game{};
unsigned char type{};
unsigned char state{};
uint8_t type{};
uint8_t state{};
bufferevent* bev{};
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment