Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro
Commits
480e2f1a
Commit
480e2f1a
authored
Dec 11, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default member initializer to all packet
parent
a01ce2f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
gframe/network.h
gframe/network.h
+32
-32
No files found.
gframe/network.h
View file @
480e2f1a
...
@@ -36,86 +36,86 @@ check_trivially_copyable(HostInfo);
...
@@ -36,86 +36,86 @@ check_trivially_copyable(HostInfo);
static_assert
(
sizeof
(
HostInfo
)
==
20
,
"size mismatch: HostInfo"
);
static_assert
(
sizeof
(
HostInfo
)
==
20
,
"size mismatch: HostInfo"
);
struct
HostPacket
{
struct
HostPacket
{
uint16_t
identifier
;
uint16_t
identifier
{}
;
uint16_t
version
;
uint16_t
version
{}
;
uint16_t
port
;
uint16_t
port
{}
;
// byte padding[2]
// byte padding[2]
uint32_t
ipaddr
;
uint32_t
ipaddr
{}
;
uint16_t
name
[
20
];
uint16_t
name
[
20
]
{}
;
HostInfo
host
;
HostInfo
host
;
};
};
check_trivially_copyable
(
HostPacket
);
check_trivially_copyable
(
HostPacket
);
static_assert
(
sizeof
(
HostPacket
)
==
72
,
"size mismatch: HostPacket"
);
static_assert
(
sizeof
(
HostPacket
)
==
72
,
"size mismatch: HostPacket"
);
struct
HostRequest
{
struct
HostRequest
{
uint16_t
identifier
;
uint16_t
identifier
{}
;
};
};
check_trivially_copyable
(
HostRequest
);
check_trivially_copyable
(
HostRequest
);
static_assert
(
sizeof
(
HostRequest
)
==
2
,
"size mismatch: HostRequest"
);
static_assert
(
sizeof
(
HostRequest
)
==
2
,
"size mismatch: HostRequest"
);
struct
CTOS_HandResult
{
struct
CTOS_HandResult
{
unsigned
char
res
;
unsigned
char
res
{}
;
};
};
check_trivially_copyable
(
CTOS_HandResult
);
check_trivially_copyable
(
CTOS_HandResult
);
static_assert
(
sizeof
(
CTOS_HandResult
)
==
1
,
"size mismatch: CTOS_HandResult"
);
static_assert
(
sizeof
(
CTOS_HandResult
)
==
1
,
"size mismatch: CTOS_HandResult"
);
struct
CTOS_TPResult
{
struct
CTOS_TPResult
{
unsigned
char
res
;
unsigned
char
res
{}
;
};
};
check_trivially_copyable
(
CTOS_TPResult
);
check_trivially_copyable
(
CTOS_TPResult
);
static_assert
(
sizeof
(
CTOS_TPResult
)
==
1
,
"size mismatch: CTOS_TPResult"
);
static_assert
(
sizeof
(
CTOS_TPResult
)
==
1
,
"size mismatch: CTOS_TPResult"
);
struct
CTOS_PlayerInfo
{
struct
CTOS_PlayerInfo
{
uint16_t
name
[
20
];
uint16_t
name
[
20
]
{}
;
};
};
check_trivially_copyable
(
CTOS_PlayerInfo
);
check_trivially_copyable
(
CTOS_PlayerInfo
);
static_assert
(
sizeof
(
CTOS_PlayerInfo
)
==
40
,
"size mismatch: CTOS_PlayerInfo"
);
static_assert
(
sizeof
(
CTOS_PlayerInfo
)
==
40
,
"size mismatch: CTOS_PlayerInfo"
);
struct
CTOS_CreateGame
{
struct
CTOS_CreateGame
{
HostInfo
info
;
HostInfo
info
;
uint16_t
name
[
20
];
uint16_t
name
[
20
]
{}
;
uint16_t
pass
[
20
];
uint16_t
pass
[
20
]
{}
;
};
};
check_trivially_copyable
(
CTOS_CreateGame
);
check_trivially_copyable
(
CTOS_CreateGame
);
static_assert
(
sizeof
(
CTOS_CreateGame
)
==
100
,
"size mismatch: CTOS_CreateGame"
);
static_assert
(
sizeof
(
CTOS_CreateGame
)
==
100
,
"size mismatch: CTOS_CreateGame"
);
struct
CTOS_JoinGame
{
struct
CTOS_JoinGame
{
uint16_t
version
;
uint16_t
version
{}
;
// byte padding[2]
// byte padding[2]
uint32_t
gameid
;
uint32_t
gameid
{}
;
uint16_t
pass
[
20
];
uint16_t
pass
[
20
]
{}
;
};
};
check_trivially_copyable
(
CTOS_JoinGame
);
check_trivially_copyable
(
CTOS_JoinGame
);
static_assert
(
sizeof
(
CTOS_JoinGame
)
==
48
,
"size mismatch: CTOS_JoinGame"
);
static_assert
(
sizeof
(
CTOS_JoinGame
)
==
48
,
"size mismatch: CTOS_JoinGame"
);
struct
CTOS_Kick
{
struct
CTOS_Kick
{
unsigned
char
pos
;
unsigned
char
pos
{}
;
};
};
check_trivially_copyable
(
CTOS_Kick
);
check_trivially_copyable
(
CTOS_Kick
);
static_assert
(
sizeof
(
CTOS_Kick
)
==
1
,
"size mismatch: CTOS_Kick"
);
static_assert
(
sizeof
(
CTOS_Kick
)
==
1
,
"size mismatch: CTOS_Kick"
);
// STOC
// STOC
struct
STOC_ErrorMsg
{
struct
STOC_ErrorMsg
{
unsigned
char
msg
;
unsigned
char
msg
{}
;
// byte padding[3]
// byte padding[3]
uint32_t
code
;
uint32_t
code
{}
;
};
};
check_trivially_copyable
(
STOC_ErrorMsg
);
check_trivially_copyable
(
STOC_ErrorMsg
);
static_assert
(
sizeof
(
STOC_ErrorMsg
)
==
8
,
"size mismatch: STOC_ErrorMsg"
);
static_assert
(
sizeof
(
STOC_ErrorMsg
)
==
8
,
"size mismatch: STOC_ErrorMsg"
);
struct
STOC_HandResult
{
struct
STOC_HandResult
{
unsigned
char
res1
;
unsigned
char
res1
{}
;
unsigned
char
res2
;
unsigned
char
res2
{}
;
};
};
check_trivially_copyable
(
STOC_HandResult
);
check_trivially_copyable
(
STOC_HandResult
);
static_assert
(
sizeof
(
STOC_HandResult
)
==
2
,
"size mismatch: STOC_HandResult"
);
static_assert
(
sizeof
(
STOC_HandResult
)
==
2
,
"size mismatch: STOC_HandResult"
);
// reserved for STOC_CREATE_GAME
// reserved for STOC_CREATE_GAME
struct
STOC_CreateGame
{
struct
STOC_CreateGame
{
uint32_t
gameid
;
uint32_t
gameid
{}
;
};
};
check_trivially_copyable
(
STOC_CreateGame
);
check_trivially_copyable
(
STOC_CreateGame
);
static_assert
(
sizeof
(
STOC_CreateGame
)
==
4
,
"size mismatch: STOC_CreateGame"
);
static_assert
(
sizeof
(
STOC_CreateGame
)
==
4
,
"size mismatch: STOC_CreateGame"
);
...
@@ -127,23 +127,23 @@ check_trivially_copyable(STOC_JoinGame);
...
@@ -127,23 +127,23 @@ check_trivially_copyable(STOC_JoinGame);
static_assert
(
sizeof
(
STOC_JoinGame
)
==
20
,
"size mismatch: STOC_JoinGame"
);
static_assert
(
sizeof
(
STOC_JoinGame
)
==
20
,
"size mismatch: STOC_JoinGame"
);
struct
STOC_TypeChange
{
struct
STOC_TypeChange
{
unsigned
char
type
;
unsigned
char
type
{}
;
};
};
check_trivially_copyable
(
STOC_TypeChange
);
check_trivially_copyable
(
STOC_TypeChange
);
static_assert
(
sizeof
(
STOC_TypeChange
)
==
1
,
"size mismatch: STOC_TypeChange"
);
static_assert
(
sizeof
(
STOC_TypeChange
)
==
1
,
"size mismatch: STOC_TypeChange"
);
// reserved for STOC_LEAVE_GAME
// reserved for STOC_LEAVE_GAME
struct
STOC_ExitGame
{
struct
STOC_ExitGame
{
unsigned
char
pos
;
unsigned
char
pos
{}
;
};
};
check_trivially_copyable
(
STOC_ExitGame
);
check_trivially_copyable
(
STOC_ExitGame
);
static_assert
(
sizeof
(
STOC_ExitGame
)
==
1
,
"size mismatch: STOC_ExitGame"
);
static_assert
(
sizeof
(
STOC_ExitGame
)
==
1
,
"size mismatch: STOC_ExitGame"
);
struct
STOC_TimeLimit
{
struct
STOC_TimeLimit
{
unsigned
char
player
;
unsigned
char
player
{}
;
// byte padding[1]
// byte padding[1]
uint16_t
left_time
;
uint16_t
left_time
{}
;
};
};
check_trivially_copyable
(
STOC_TimeLimit
);
check_trivially_copyable
(
STOC_TimeLimit
);
static_assert
(
sizeof
(
STOC_TimeLimit
)
==
4
,
"size mismatch: STOC_TimeLimit"
);
static_assert
(
sizeof
(
STOC_TimeLimit
)
==
4
,
"size mismatch: STOC_TimeLimit"
);
...
@@ -158,8 +158,8 @@ constexpr int LEN_CHAT_MSG = 256;
...
@@ -158,8 +158,8 @@ constexpr int LEN_CHAT_MSG = 256;
constexpr
int
SIZE_STOC_CHAT
=
(
LEN_CHAT_PLAYER
+
LEN_CHAT_MSG
)
*
sizeof
(
uint16_t
);
constexpr
int
SIZE_STOC_CHAT
=
(
LEN_CHAT_PLAYER
+
LEN_CHAT_MSG
)
*
sizeof
(
uint16_t
);
struct
STOC_HS_PlayerEnter
{
struct
STOC_HS_PlayerEnter
{
uint16_t
name
[
20
];
uint16_t
name
[
20
]
{}
;
unsigned
char
pos
;
unsigned
char
pos
{}
;
// byte padding[1]
// byte padding[1]
};
};
check_trivially_copyable
(
STOC_HS_PlayerEnter
);
check_trivially_copyable
(
STOC_HS_PlayerEnter
);
...
@@ -168,13 +168,13 @@ constexpr int STOC_HS_PlayerEnter_size = 41; //workwround
...
@@ -168,13 +168,13 @@ constexpr int STOC_HS_PlayerEnter_size = 41; //workwround
struct
STOC_HS_PlayerChange
{
struct
STOC_HS_PlayerChange
{
//pos<<4 | state
//pos<<4 | state
unsigned
char
status
;
unsigned
char
status
{}
;
};
};
check_trivially_copyable
(
STOC_HS_PlayerChange
);
check_trivially_copyable
(
STOC_HS_PlayerChange
);
static_assert
(
sizeof
(
STOC_HS_PlayerChange
)
==
1
,
"size mismatch: STOC_HS_PlayerChange"
);
static_assert
(
sizeof
(
STOC_HS_PlayerChange
)
==
1
,
"size mismatch: STOC_HS_PlayerChange"
);
struct
STOC_HS_WatchChange
{
struct
STOC_HS_WatchChange
{
uint16_t
watch_count
;
uint16_t
watch_count
{}
;
};
};
check_trivially_copyable
(
STOC_HS_WatchChange
);
check_trivially_copyable
(
STOC_HS_WatchChange
);
static_assert
(
sizeof
(
STOC_HS_WatchChange
)
==
2
,
"size mismatch: STOC_HS_WatchChange"
);
static_assert
(
sizeof
(
STOC_HS_WatchChange
)
==
2
,
"size mismatch: STOC_HS_WatchChange"
);
...
@@ -183,10 +183,10 @@ class DuelMode;
...
@@ -183,10 +183,10 @@ class DuelMode;
struct
DuelPlayer
{
struct
DuelPlayer
{
unsigned
short
name
[
20
]{};
unsigned
short
name
[
20
]{};
DuelMode
*
game
{
nullptr
};
DuelMode
*
game
{};
unsigned
char
type
{
0
};
unsigned
char
type
{};
unsigned
char
state
{
0
};
unsigned
char
state
{};
bufferevent
*
bev
{
0
};
bufferevent
*
bev
{};
};
};
inline
bool
check_msg_size
(
int
size
)
{
inline
bool
check_msg_size
(
int
size
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment