forked from frero/hanabi
wip
This commit is contained in:
+24
-9
@@ -154,10 +154,20 @@ send_payload :: proc(sock: net.TCP_Socket, pl: Payload) -> net.Network_Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
send_state_update :: proc(sock: net.TCP_Socket, pl: ^Player_View) -> net.Network_Error {
|
||||
header := Msg_Type.State_Update
|
||||
net.send(sock, mem.ptr_to_bytes(&header)) or_return
|
||||
net.send(sock, mem.ptr_to_bytes(pl)) or_return
|
||||
send_state_update :: proc(sock: net.TCP_Socket, view: ^Player_View) -> net.Network_Error {
|
||||
// header := Msg_Type.State_Update
|
||||
// net.send(sock, mem.ptr_to_bytes(&header)) or_return
|
||||
// net.send(sock, mem.ptr_to_bytes(pl)) or_return
|
||||
// return nil
|
||||
type := Msg_Type.State_Update
|
||||
net.send(sock, mem.ptr_to_bytes(&type)) or_return
|
||||
// everything up to `cards` field ("header")
|
||||
header_size := offset_of(Player_View, cards)
|
||||
header_ptr := raw_data(mem.byte_slice(view, size_of(Player_View)))
|
||||
net.send(sock, header_ptr[:header_size]) or_return
|
||||
// send dynamic `cards` body field
|
||||
body := raw_data(view.cards)[:len(view.cards) * size_of(Card)]
|
||||
net.send(sock, transmute([]byte)body) or_return
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -186,7 +196,15 @@ send_info :: proc(sock: net.TCP_Socket, data: Info_Data) -> net.Network_Error {
|
||||
|
||||
Play_Action :: distinct Card
|
||||
Discard_Action :: distinct Card
|
||||
Hint_Action :: distinct Card
|
||||
Value_Hint :: distinct int
|
||||
Color_Hint :: distinct int
|
||||
Hint_Action :: struct {
|
||||
target_player: int, // global index
|
||||
type: union {
|
||||
Value_Hint,
|
||||
Color_Hint,
|
||||
},
|
||||
}
|
||||
|
||||
Action :: union {
|
||||
Play_Action,
|
||||
@@ -195,10 +213,7 @@ Action :: union {
|
||||
}
|
||||
|
||||
receive_action :: proc(player: net.TCP_Socket) -> Action {
|
||||
unimplemented()
|
||||
}
|
||||
|
||||
validate_action :: proc(action: Action) -> bool {
|
||||
// validates user input and creates correct action
|
||||
unimplemented()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user