shurcool / ex0 Goto Github PK
View Code? Open in Web Editor NEWUnfinished multiplayer tactical 2D shooter indie game.
Home Page: https://dmitri.shuralyov.com/projects/eX0/eX0-go-client/
License: MIT License
Unfinished multiplayer tactical 2D shooter indie game.
Home Page: https://dmitri.shuralyov.com/projects/eX0/eX0-go-client/
License: MIT License
I'd like to know how to make my networked game smooth as butter ;)
https://shurcool.wordpress.com/2011/07/25/how-to-make-your-networked-game-smooth-as-butter/
Here's a panic that happened, causing the server to crash.
...
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
12411.588: Pl#0 ("Unnamed Player") joined team team Red at logic time 167.77/168 [server].
tcp conn ended with: conn prob
panic: runtime error: index out of range
goroutine 118 [running]:
main.(*server).processUDPPacket(0xc420074280, 0x84eba0, 0xc42040e2c0, 0xc4203ea3f0, 0x0, 0xc4203ea3f0, 0x0, 0x0)
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:296 +0xbb7
main.(*server).handleUDP(0xc420074280, 0xc4203ea3f0)
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:214 +0xbb
created by main.(*server).listenAndHandleTCPWebSocket.func1
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:165 +0x13e
It was on this line:
Line 296 in 9c721ba
Needs investigation and fix.
(A guess is that the client disconnected at a bad time, just before the UDP packet arrived, and the c.PlayerID
might've already been removed from s.logic.playersState
.)
Here's the full log in case more context is needed.
Started server.
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
8.671: Pl#0 ("Unnamed Player") joined team team Red at logic time 173.42/174 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
6698.009: Pl#0 ("Unnamed Player") joined team team Red at logic time 72.18/73 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
7164.806: Pl#1 ("Unnamed Player") joined team team Red at logic time 192.12/193 [server].
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
7167.124: Pl#0 ("Unnamed Player") joined team team Red at logic time 238.49/239 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
7248.113: Pl#0 ("Unnamed Player") joined team team Red at logic time 66.27/67 [server].
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
7248.224: Pl#1 ("Unnamed Player") joined team team Red at logic time 68.49/69 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
8200.226: Pl#0 ("Unnamed Player") joined team team Red at logic time 164.51/165 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
8821.455: Pl#0 ("Unnamed Player") joined team team Red at logic time 45.11/46 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
10402.472: Pl#0 ("Unnamed Player") joined team team Red at logic time 177.43/178 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
10972.247: Pl#0 ("Unnamed Player") joined team team Red at logic time 52.94/53 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
12148.710: Pl#0 ("Unnamed Player") joined team team Red at logic time 30.21/31 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(26),
Type: (packet.Type)(1),
}),
Version: (uint16)(1),
Passphrase: ([16]uint8)([16]uint8{
(uint8)(115),
(uint8)(111),
(uint8)(109),
(uint8)(101),
(uint8)(114),
(uint8)(97),
(uint8)(110),
(uint8)(100),
(uint8)(111),
(uint8)(109),
(uint8)(112),
(uint8)(97),
(uint8)(115),
(uint8)(115),
(uint8)(48),
(uint8)(49),
}),
Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
Type: (packet.Type)(100),
}),
Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(17),
Type: (packet.Type)(30),
}),
NameLength: (uint8)(14),
Name: ([]uint8)([]uint8{
(uint8)(85),
(uint8)(110),
(uint8)(110),
(uint8)(97),
(uint8)(109),
(uint8)(101),
(uint8)(100),
(uint8)(32),
(uint8)(80),
(uint8)(108),
(uint8)(97),
(uint8)(121),
(uint8)(101),
(uint8)(114),
}),
CommandRate: (uint8)(20),
UpdateRate: (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(0),
Type: (packet.Type)(7),
}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
Length: (uint16)(1),
Type: (packet.Type)(27),
}),
PlayerNumber: (*uint8)(nil),
Team: (packet.Team)(0),
})
12411.588: Pl#0 ("Unnamed Player") joined team team Red at logic time 167.77/168 [server].
tcp conn ended with: conn prob
panic: runtime error: index out of range
goroutine 118 [running]:
main.(*server).processUDPPacket(0xc420074280, 0x84eba0, 0xc42040e2c0, 0xc4203ea3f0, 0x0, 0xc4203ea3f0, 0x0, 0x0)
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:296 +0xbb7
main.(*server).handleUDP(0xc420074280, 0xc4203ea3f0)
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:214 +0xbb
created by main.(*server).listenAndHandleTCPWebSocket.func1
/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:165 +0x13e
@@ -94,6 +94,8 @@ func sendUDPPacketBytes(c *Connection, b []byte) error {
func receiveUDPPacket(c *Connection) ([]byte, packet.UDPHeader, error) {
var b [packet.MAX_UDP_SIZE]byte
n, err := c.udp.Read(b[:])
+ // TODO: Use io.ReadFull or check b[n:] here? But it is UDP, so... Figure it out.
+ // Maybe it's fine because it's Conn.Read, not io.Read?
if err != nil {
return nil, packet.UDPHeader{}, err
}
Originally reported/found by @dominikh.
Seen your comment on the 2d lightning HN article. This code is not really open source yet, though. You might consider putting a license here.
My suggestion is Apache or MIT license if you don't mind what others do with it, and GPLv3+ if you try to make others open their changes to your code as well.
Hi,I'm new in golang and learning you project,it's pretty interesting,but when I build you source code in project , it's show some mistakes such as like that:
# command-line-arguments
.\main.go:18: undefined: server
.\main.go:19: undefined: client
.\main.go:20: undefined: view
.\main.go:32: undefined: newClientNetwork
.\main.go:41: undefined: startClient
.\main.go:44: undefined: startServer
too many errors
I'm skilled in Unity'C# but not golang,Isn't I do something wrong?
My golang's version is 1.7
I'm looking forward to your reply.
I saw the r/golang post about this project—thought this was super cool!
I was able to get the normal Go server/clients working just fine, however I'm brand new to GopherJS and was wondering how it is that the JS is meant to be generated and then run?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.