steam

package
v0.0.0-...-b5fa7f3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceMasterServerAddr = "hl2master.steampowered.com:27011"
)

Variables

View Source
var (
	GamesList = []*GameInfo{
		MustInitGameInfo(GameInfo{
			ID:          1012110,
			Title:       "Military Conflict - Vietnam",
			MapImageDir: "materials/panorama/images/map_icons/playmenu",
			BgVideoFn:   "panorama/videos/background.webm",
			PakDir:      "vietnam",
			PakPfx:      "vietnam/pak01",
		}),
	}

	GamesMap = func() map[ID]*GameInfo {
		m := map[ID]*GameInfo{}
		for _, g := range GamesList {
			m[g.ID] = g
		}
		return m
	}()

	GamesMapString = func() map[string]*GameInfo {
		m := map[string]*GameInfo{}
		for _, g := range GamesList {
			m[g.ID.String()] = g
		}
		return m
	}()
)
View Source
var (
	ErrNoServers     = errors.New("No servers found")
	ErrChallenge     = errors.New("Challenge")
	ErrUnknownPrefix = errors.New("Unknown Prefix")
	ErrUnknownHeader = errors.New("Unknown Header")
)
View Source
var (
	Logs = logs.AppLogger()
)

Functions

func AvatarURI

func AvatarURI(db *store.DB, userID ID) string

func FindSteamPaths

func FindSteamPaths(rel ...string) []string

func MustReadGameImageURI

func MustReadGameImageURI(id ID, kind GameImageKind) string

func OpenAvatar

func OpenAvatar(db *store.DB, userID ID) (fs.File, error)

func QueryServerInfo

func QueryServerInfo(db *store.DB, maxAge time.Duration, region Region, addr string) (ServerInfo, *ServerReply, error)

func QueryServerList

func QueryServerList(db *store.DB, maxAge time.Duration, gameID ID) (map[string]Region, error)

func ReadGameImage

func ReadGameImage(id ID, kind GameImageKind) (mime string, _ []byte, _ error)

func ReadVDF

func ReadVDF[T any](fn string) (v T, err error)

Types

type GameImageKind

type GameImageKind string
const (
	IconImage GameImageKind = "icon"
	HeroImage GameImageKind = "library_hero"
)

type GameInfo

type GameInfo struct {
	ID           ID     `json:"id"`
	Title        string `json:"title"`
	DirName      string `json:"dirName"`
	IconURI      string `json:"iconURI"`
	HeroURI      string `json:"heroURI"`
	MapImageDir  string
	MapImageURL  string   `json:"mapImageURL"`
	BgVideoURL   string   `json:"bgVideoURL"`
	MapNames     []string `json:"mapNames"`
	MapImageURLs []string `json:"mapImageURLs"`
	BgVideoFn    string
	PakDir       string
	PakPfx       string
}

func MustInitGameInfo

func MustInitGameInfo(g GameInfo) *GameInfo

func (*GameInfo) OpenBgVideo

func (g *GameInfo) OpenBgVideo() (fs.File, error)

func (*GameInfo) OpenFile

func (g *GameInfo) OpenFile(path string) (fs.File, error)

func (*GameInfo) OpenMapImage

func (g *GameInfo) OpenMapImage(name string) (fs.File, error)

func (*GameInfo) ReadMapNames

func (g *GameInfo) ReadMapNames() ([]string, error)

type ID

type ID uint32

func ParseID

func ParseID(s string) (id ID, err error)

func ToID

func ToID(n uint64) ID

func (ID) MarshalJSON

func (i ID) MarshalJSON() ([]byte, error)

func (ID) String

func (i ID) String() string

func (ID) String32

func (i ID) String32() string

func (ID) String64

func (i ID) String64() string

func (ID) To32

func (i ID) To32() uint32

func (ID) To64

func (i ID) To64() uint64

func (*ID) UnmarshalJSON

func (i *ID) UnmarshalJSON(p []byte) error

type LibFS

type LibFS struct {
	Dir       string
	ConfigDir string
	// contains filtered or unexported fields
}

func FindSteamLibs

func FindSteamLibs() []*LibFS

func NewLibFS

func NewLibFS(dir string) *LibFS

func (*LibFS) Mtime

func (lib *LibFS) Mtime(name string) (time.Time, error)

func (*LibFS) Open

func (lib *LibFS) Open(name string) (fs.File, error)

func (*LibFS) Stat

func (lib *LibFS) Stat(name string) (fs.FileInfo, error)

type LocalAppConfig

type LocalAppConfig struct {
	LaunchOptions string
}

type LocalConfig

type LocalConfig struct {
	Apps map[ID]LocalAppConfig
}

func ReadLocalConfig

func ReadLocalConfig(userID ID) (LocalConfig, error)

type MasterQuery

type MasterQuery struct {
	Header byte
	Region Region
	Addr   string
	Filter string
	// contains filtered or unexported fields
}

func (*MasterQuery) Encode

func (mq *MasterQuery) Encode(w io.Writer) error

type MasterReply

type MasterReply struct {
	Region Region
	// contains filtered or unexported fields
}

func (*MasterReply) Decode

func (mr *MasterReply) Decode(r *memio.File) error

func (*MasterReply) ID

func (mr *MasterReply) ID() netip.Addr

func (*MasterReply) Port

func (mr *MasterReply) Port() int

func (*MasterReply) String

func (mr *MasterReply) String() string

type PakDirEntry

type PakDirEntry struct {
	Fn   string
	Mode fs.FileMode
	Inf  fs.FileInfo
}

func (*PakDirEntry) Info

func (p *PakDirEntry) Info() (fs.FileInfo, error)

func (*PakDirEntry) IsDir

func (p *PakDirEntry) IsDir() bool

func (*PakDirEntry) Name

func (p *PakDirEntry) Name() string

func (*PakDirEntry) Type

func (p *PakDirEntry) Type() fs.FileMode

type PakFS

type PakFS struct {
	Dir string
	Pfx string
	// contains filtered or unexported fields
}

func GetPakFS

func GetPakFS(game *GameInfo) (*PakFS, error)

func NewPakFS

func NewPakFS(dir, pfx string) (*PakFS, error)

func (*PakFS) Open

func (p *PakFS) Open(name string) (fs.File, error)

func (*PakFS) ReadDir

func (p *PakFS) ReadDir(name string) ([]fs.DirEntry, error)

type PakFile

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

func (*PakFile) Close

func (pf *PakFile) Close() error

func (*PakFile) Name

func (pf *PakFile) Name() string

func (*PakFile) Read

func (pf *PakFile) Read(p []byte) (n int, err error)

func (*PakFile) Stat

func (pf *PakFile) Stat() (fs.FileInfo, error)

func (*PakFile) String

func (pf *PakFile) String() string

type Profile

type Profile struct {
	UserID    ID     `json:"userID"`
	AvatarURI string `json:"avatarURI"`
	Username  string `json:"username"`
	Clan      string `json:"clan"`
	Name      string `json:"name"`
}

func FetchProfile

func FetchProfile(db *store.DB, userID ID, username string) (Profile, error)

type Region

type Region byte
const (
	USEastCoast    Region = 0x00
	USWestCoast    Region = 0x01
	SouthAmerica   Region = 0x02
	Europe         Region = 0x03
	Asia           Region = 0x04
	Australia      Region = 0x05
	MiddleEast     Region = 0x06
	Africa         Region = 0x07
	RestOfTheworld Region = 0xFF
)

func (Region) String

func (r Region) String() string

type ServerInfo

type ServerInfo struct {
	Addr       string    `json:"addr"`
	Name       string    `json:"name"`
	Players    int       `json:"players"`
	Bots       int       `json:"bots"`
	Restricted bool      `json:"restricted"`
	PingMs     int       `json:"ping"`
	Map        string    `json:"map"`
	Game       string    `json:"game"`
	MaxPlayers int       `json:"maxPlayers"`
	Region     Region    `json:"region"`
	Country    string    `json:"country"`
	Ts         time.Time `json:"ts"`
}

type ServerQuery

type ServerQuery struct {
	Header    byte
	Payload   string
	Challenge int32
	// contains filtered or unexported fields
}

func (*ServerQuery) Encode

func (sq *ServerQuery) Encode(w io.Writer) error

type ServerReply

type ServerReply struct {
	// 	Always equal to 'I' (0x49)
	Header byte

	// 	Protocol version used by the server.
	Protocol byte

	// Name of the server.
	Name string

	// Map the server has currently loaded.
	Map string

	// Name of the folder containing the game files.
	Folder string

	// Full name of the game.
	Game string

	// Steam Application ID of game.
	ID int16

	// 	Number of players on the server.
	Players byte

	// 	Maximum number of players the server reports it can hold.
	MaxPlayers byte

	// Number of bots on the server.
	Bots byte

	// Indicates the type of server:
	// 'd' for a dedicated server
	// 'l' for a non-dedicated server
	// 'p' for a SourceTV relay (proxy)
	ServerType byte

	// Indicates the operating system of the server:
	// 'l' for Linux
	// 'w' for Windows
	// 'm' or 'o' for Mac (the code changed after L4D1)
	Environment byte

	// Indicates whether the server requires a password:
	// 0 for public
	// 1 for private
	Visibility byte

	// Specifies whether the server uses VAC:
	// 0 for unsecured
	// 1 for secured
	VAC byte

	Ping      time.Duration
	Challenge int32

	Ts time.Time
}

func (*ServerReply) Decode

func (sr *ServerReply) Decode(r *memio.File) error

type User

type User struct {
	ID   ID
	Name string
	Ts   time.Time
	// contains filtered or unexported fields
}

func FindUser

func FindUser(db *store.DB, searchID ID) (*User, bool)

func ReadLoginUsers

func ReadLoginUsers(db *store.DB, lib *LibFS) ([]*User, error)

func (*User) Lib

func (su *User) Lib() *LibFS

func (*User) String

func (su *User) String() string

Jump to

Keyboard shortcuts

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