You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
hexmap/server/state/coords.pbconv.go

25 lines
510 B

package state
import (
"errors"
"math"
)
var ErrOutOfBounds = errors.New("coordinate was out of bounds")
func (x *StorageCoordinatesPB) ToGo() (StorageCoordinates, error) {
if x.Line > math.MaxUint8 || x.Cell > math.MaxUint8 {
return StorageCoordinates{}, ErrOutOfBounds
}
return StorageCoordinates{
Line: uint8(x.Line),
Cell: uint8(x.Cell),
}, nil
}
func (s StorageCoordinates) ToPB() *StorageCoordinatesPB {
return &StorageCoordinatesPB{
Line: uint32(s.Line),
Cell: uint32(s.Cell),
}
}