freeroam

package module
v0.0.0-...-ced3aca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteSubpacket

func WriteSubpacket(buf *bytes.Buffer, typ uint8, data []byte)

WriteSubpacket writes a subpacket with specified type and payload to a bytes.Buffer

Types

type ArrayDiffResult

type ArrayDiffResult struct {
	Kept    []*Client
	Added   []*Client
	Removed []*Client
}

func ArrayDiff

func ArrayDiff(old []*Client, new []*Client) ArrayDiffResult

type CarPosPacket

type CarPosPacket struct {
	// contains filtered or unexported fields
}

func (*CarPosPacket) Packet

func (p *CarPosPacket) Packet() []byte

Packet returns the packet data with the packet time replaced by the argument.

func (*CarPosPacket) Pos

func (p *CarPosPacket) Pos() math.Vector2D

Pos returns the car position as a Vector2D.

func (*CarPosPacket) Rotation

func (p *CarPosPacket) Rotation() float64

Rotation returns the car rotation in degrees.

func (*CarPosPacket) Update

func (p *CarPosPacket) Update(packet []byte)

Update updates CarPosPacket with the specified byte slice. The supplied slice shouldn't be modified after calling this method.

func (*CarPosPacket) Valid

func (p *CarPosPacket) Valid() bool

Valid returns true if CarPosPacket contains valid packet data.

type Client

type Client struct {
	Addr *net.UDPAddr

	LastPacket  time.Time
	PersonaName string
	// contains filtered or unexported fields
}

func (Client) Active

func (c Client) Active() bool

Active returns true if the client has communicated with the server lately.

func (*Client) Cleanup

func (c *Client) Cleanup()

func (*Client) GetPendingPlayersCount

func (c *Client) GetPendingPlayersCount() int

func (*Client) GetPlayerSpawnDelay

func (c *Client) GetPlayerSpawnDelay() int

func (Client) GetPos

func (c Client) GetPos() math.Vector2D

GetPos returns the current position of the client.

func (Client) GetRotation

func (c Client) GetRotation() float64

GetRotation returns the current rotation of the client.

func (*Client) IsRadiusSyncDisabled

func (c *Client) IsRadiusSyncDisabled() bool

func (Client) IsReady

func (c Client) IsReady() bool

IsReady returns true if the client is ready to be broadcasted to other clients. This means that the server has valid channel info, player info and position data of the client.

func (*Client) SendRawPacket

func (c *Client) SendRawPacket(b []byte) error

SendRawPacket sends a raw UDP packet to the client.

func (*Client) SetPlayerSpawnDelay

func (c *Client) SetPlayerSpawnDelay(delayMs int)

func (*Client) SetRadiusSync

func (c *Client) SetRadiusSync(enabled bool)

type ClientConfig

type ClientConfig struct {
	InitialTick        uint16
	Addr               *net.UDPAddr
	Conn               *net.UDPConn
	Buffers            *sync.Pool
	Clients            map[string]*Client
	AllowedPersonas    []int
	VisibilityRadius   float64
	MaxVisiblePlayers  int
	PlayerSpawnDelayMs int
	DisableRadiusSync  bool
}

type Config

type Config struct {
	UDP UDPConfig
	FMS FMSConfig
}

func DefaultConfig

func DefaultConfig() Config

type FMSConfig

type FMSConfig struct {
	ListenAddress  string
	AllowedOrigin  string
	UpdateInterval int
}

type Server

type Server struct {
	sync.Mutex

	Clients map[string]*Client
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config Config) *Server

func (*Server) Listen

func (i *Server) Listen(addrStr string) error

func (*Server) RunPacketRead

func (i *Server) RunPacketRead()

func (*Server) RunTimer

func (i *Server) RunTimer()

func (*Server) SetPlayerSpawnDelayForAllClients

func (i *Server) SetPlayerSpawnDelayForAllClients(delayMs int)

func (*Server) SetRadiusSyncForAllClients

func (i *Server) SetRadiusSyncForAllClients(enabled bool)

type UDPConfig

type UDPConfig struct {
	ListenAddress      string
	VisibilityRadius   float64
	MaxVisiblePlayers  int
	PlayerSpawnDelayMs int
	DisableRadiusSync  bool
}

Directories

Path Synopsis
cmd
freeroamd command
postest command
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL