Change default port to 1984
This commit is contained in:
parent
df42979b16
commit
31d7971372
6 changed files with 21 additions and 20 deletions
|
@ -39,7 +39,7 @@ var (
|
|||
logMessages []string
|
||||
renderLogMessages bool
|
||||
logMutex = new(sync.Mutex)
|
||||
showLogLines = 7
|
||||
showLogLines = 7 // TODO Set in resize func?
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -163,7 +163,7 @@ func main() {
|
|||
}()
|
||||
}
|
||||
|
||||
localListenAddress := "localhost:19840"
|
||||
localListenAddress := fmt.Sprintf("localhost:%d", game.DefaultPort)
|
||||
|
||||
go server.Listen(localListenAddress)
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ const (
|
|||
LogVerbose
|
||||
)
|
||||
|
||||
const DefaultPort = 1984
|
||||
|
||||
type Game struct {
|
||||
Rank int
|
||||
Minos []mino.Mino
|
||||
|
|
|
@ -298,11 +298,7 @@ func (s *Server) handleGameCommands(pl *Player, g *Game) {
|
|||
|
||||
func (s *Server) Listen(address string) {
|
||||
var network string
|
||||
if strings.ContainsRune(address, ':') {
|
||||
network = "tcp"
|
||||
} else {
|
||||
network = "unix"
|
||||
}
|
||||
network, address = NetworkAndAddress(address)
|
||||
|
||||
listener, err := net.Listen(network, address)
|
||||
if err != nil {
|
||||
|
@ -342,3 +338,18 @@ func (s *Server) Logf(format string, a ...interface{}) {
|
|||
|
||||
s.Logger <- fmt.Sprintf(format, a...)
|
||||
}
|
||||
|
||||
func NetworkAndAddress(address string) (string, string) {
|
||||
var network string
|
||||
if strings.ContainsAny(address, `\/`) {
|
||||
network = "unix"
|
||||
} else {
|
||||
network = "tcp"
|
||||
|
||||
if !strings.Contains(address, `:`) {
|
||||
address = fmt.Sprintf("%s:%d", address, DefaultPort)
|
||||
}
|
||||
}
|
||||
|
||||
return network, address
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -63,11 +62,7 @@ func Connect(address string) *ServerConn {
|
|||
err error
|
||||
tries int
|
||||
)
|
||||
if strings.ContainsRune(address, ':') {
|
||||
network = "tcp"
|
||||
} else {
|
||||
network = "unix"
|
||||
}
|
||||
network, address = NetworkAndAddress(address)
|
||||
|
||||
for {
|
||||
conn, err = net.DialTimeout(network, address, ConnTimeout)
|
||||
|
|
|
@ -253,7 +253,6 @@ func (m Mino) Flatten() Mino {
|
|||
rotateFunc = Point.Rotate180
|
||||
}
|
||||
if right > flattest {
|
||||
flattest = right
|
||||
rotateFunc = Point.Rotate90
|
||||
}
|
||||
if rotateFunc != nil {
|
||||
|
|
|
@ -166,12 +166,6 @@ func (p *Piece) Rotate(rotations int, direction int) Mino {
|
|||
newMino := make(Mino, len(p.Mino))
|
||||
copy(newMino, p.Mino.Origin())
|
||||
|
||||
w, h := newMino.Size()
|
||||
maxSize := w
|
||||
if h > maxSize {
|
||||
maxSize = h
|
||||
}
|
||||
|
||||
var rotationPivot int
|
||||
for j := 0; j < rotations; j++ {
|
||||
if direction == 0 {
|
||||
|
|
Loading…
Reference in a new issue