core

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package core is what the launcher does, independent of any UI: it loads servers, keeps their folders up to date, reads and writes their settings, and starts them.

Index

Constants

View Source
const CustomVersion = "custom"

CustomVersion is the component "version" for the player's own files: a maphack build they're testing, say. The launcher doesn't install, update, repair or remove anything that component could hold. It isn't supported by the server; the launcher says so when it's chosen.

View Source
const LegacyServer = "slashdiablo"

LegacyServer is the server the old SlashDiablo launcher's settings belong to.

View Source
const MaxFavourites = 3

MaxFavourites is how many servers can be pinned to the rail.

Variables

View Source
var D2GLResolutions = []string{
	"800x600", "960x720", "1024x768", "1200x900", "1280x960", "1440x1080",
	"1600x1200", "1920x1440", "2560x1920", "2732x2048",
	"1068x600", "1280x720", "1600x900", "1920x1080", "2048x1152",
	"2560x1440", "3200x1800", "3840x2160",
}

D2GLResolutions are the window sizes d2gl offers itself, from its own list, for per-box profiles. "" means leave the profile's size alone.

View Source
var ErrAlreadyListed = errors.New("this server is already listed; open it from All servers")

ErrAlreadyListed means a server added by URL is already in the listing.

View Source
var ErrBaseNotSaved = errors.New("Diablo II is installed, but the launcher couldn't save where")

ErrBaseNotSaved means the game was installed but the launcher couldn't save that it's now the Diablo II folder. Installing again won't help: the folder is no longer empty.

View Source
var ErrInstalling = errors.New("Diablo II is already being installed")

ErrInstalling means an install is already under way.

View Source
var ErrNotLoggedIn = errors.New("log in first")

ErrNotLoggedIn is Play on a server with its own login before the player has logged in.

View Source
var ErrTooManyFavourites = fmt.Errorf("you can pin up to %d servers; unpin one first", MaxFavourites)

ErrTooManyFavourites means the rail is full.

View Source
var ErrWineNotReady = errors.New("Wine needs setting up first")

ErrWineNotReady means Play needs Wine set up first, which the setup screen does.

Functions

func BuildIndex

func BuildIndex(dir string) ([]byte, error)

BuildIndex checks every profile in a folder, including that each file is named after its server's id, and renders the index.

func LegacyConfigPath

func LegacyConfigPath() string

LegacyConfigPath is where the old SlashDiablo launcher kept its settings.

Types

type BaseInstaller

type BaseInstaller struct {
	basegame.Installer
	// DefaultDir is where it suggests installing.
	DefaultDir string
	// Unavailable says why it can't, such as legacy-dl missing.
	Unavailable string
}

BaseInstaller is how the launcher installs the base game itself.

type BaseSetup

type BaseSetup struct {
	// Available is whether the launcher can install the game; when it
	// can't, Unavailable says why.
	Available   bool   `json:"available"`
	Unavailable string `json:"unavailable"`
	// DefaultDir is the suggested install folder.
	DefaultDir     string   `json:"defaultDir"`
	Versions       []string `json:"versions"`
	DefaultVersion string   `json:"defaultVersion"`
	// Owner is the name suggested to store beside the keys.
	Owner string `json:"owner"`
	// CacheBytes is the download cache left by an install.
	CacheBytes int64 `json:"cacheBytes"`
}

BaseSetup is what the "Get Diablo II" step offers.

type Board

type Board struct {
	ID      string        `json:"id"`
	Name    string        `json:"name"`
	Entries []LadderEntry `json:"entries"`
}

Board is one ranked list.

type Choices

type Choices struct {
	Channel    string            `json:"channel"`
	Components map[string]string `json:"components"`
	Instances  int               `json:"instances"`
	SplitD2GL  bool              `json:"splitD2gl"`

	D2GLMainResolution   string   `json:"d2glMainResolution"`
	D2GLLoaderResolution string   `json:"d2glLoaderResolution"`
	D2GLResolutions      []string `json:"d2glResolutions"`
}

Choices is what the player has picked for a server.

type DEP

type DEP struct {
	Supported bool `json:"supported"`
	// Off is set once DEP is off for the server's Game.exe. The launcher has
	// no undo: the player removes it on the exe's Compatibility tab.
	Off bool `json:"off"`
}

DEP is the DEP fix for a server's game: Windows only, where some old game code trips Data Execution Prevention and crashes on start.

type DirListing

type DirListing string

DirListing reads profiles from a folder, like servers/ in the repo. Used for development and to build the index.

func (DirListing) Profiles

func (d DirListing) Profiles(context.Context) ([]json.RawMessage, error)

Profiles returns every *.json file in the folder except the index.

type ErrNeedsCopy

type ErrNeedsCopy struct {
	Bytes int64
}

ErrNeedsCopy means the base archives can't be hard linked into the server folder and would need copying, which uses real disk space. The player is asked, and Update is called again with allowCopy.

func (ErrNeedsCopy) Error

func (e ErrNeedsCopy) Error() string

type Index

type Index struct {
	Schema  int               `json:"schema"`
	Servers []json.RawMessage `json:"servers"`
}

Index is servers/index.json: every listed profile in one file, so the launcher fetches the whole listing in one request. It is generated from servers/*.json by cmd/listing, and a test fails when it is out of date.

type Ladder

type Ladder struct {
	Boards []Board `json:"boards"`
}

Ladder is a server's ladder: one or more boards, such as softcore and hardcore. See docs/SPEC.md section 3.

type LadderEntry

type LadderEntry struct {
	Rank   int    `json:"rank"`
	Name   string `json:"name"`
	Class  string `json:"class"`
	Level  int    `json:"level"`
	Title  string `json:"title,omitempty"`
	Status string `json:"status,omitempty"`
}

LadderEntry is one character on a board.

type Listing

type Listing interface {
	Profiles(ctx context.Context) ([]json.RawMessage, error)
}

Listing supplies the listed servers' profiles. The listing is the trust decision: a server gets in by a reviewed pull request adding its profile to servers/, so anything in a listed profile has been approved.

type Login

type Login struct {
	// Needed is set for a server with its own login service.
	Needed bool `json:"needed"`
	// LoggedIn is set once the player has logged in.
	LoggedIn bool `json:"loggedIn"`
	// Name is who the player is logged in as: their Discord name, or the
	// realm account when the service gave no name.
	Name string `json:"name"`
}

Login is a server's login as the player sees it.

type Manager

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

Manager runs the launcher.

func New

func New(st *store.Store, listing Listing, l *launch.Launcher, clientOpts ...fetch.Option) (*Manager, error)

New returns a manager. clientOpts are passed to every fetch client, which is how development builds trust the local test server.

func (*Manager) AddServer

func (m *Manager) AddServer(ctx context.Context, profileURL string) (*spec.Profile, error)

AddServer adds a server that isn't in the listing, from the URL of its profile. Such servers haven't been reviewed and show as not verified. For a server that is already listed it returns the profile with ErrAlreadyListed, so the caller can open that server instead.

func (*Manager) Asset

func (m *Manager) Asset(ctx context.Context, id, which string) ([]byte, error)

Asset returns one of a server's branding images, cached after the first download and checked against its SHA-256 when the profile gives one.

func (*Manager) Base

func (m *Manager) Base() string

Base is the player's Diablo II folder.

func (*Manager) BaseSetup

func (m *Manager) BaseSetup() BaseSetup

BaseSetup describes installing the base game.

func (*Manager) CheckBase

func (m *Manager) CheckBase() (install.Report, string, error)

CheckBase reports on the current Diablo II folder.

func (*Manager) Choices

func (m *Manager) Choices(ctx context.Context, id string) (Choices, error)

Choices returns the player's current picks, with defaults filled in.

func (*Manager) ClearBaseCache

func (m *Manager) ClearBaseCache() error

ClearBaseCache deletes the base game's download cache.

func (*Manager) DEP

func (m *Manager) DEP(ctx context.Context, id string) (DEP, error)

DEP reports the DEP fix for a server.

func (*Manager) DetectBase

func (m *Manager) DetectBase() error

DetectBase fills in the Diablo II folder from where the game itself last recorded it, if the player hasn't chosen one.

func (*Manager) Favourites

func (m *Manager) Favourites() []string

Favourites returns the pinned server ids in order.

func (*Manager) FinishWelcome

func (m *Manager) FinishWelcome(pins []string) error

FinishWelcome pins the servers picked on the welcome screen and records that the player has been through it, in one save, so a failure can't leave pins without the welcome or the other way round. On failure nothing changes.

func (*Manager) FirstRun

func (m *Manager) FirstRun() bool

FirstRun reports whether to show the welcome screen: the player hasn't been through it, and has no servers pinned, as anyone who has used the launcher, or the old SlashDiablo one, will have.

func (*Manager) ImportLegacy

func (m *Manager) ImportLegacy(ctx context.Context, configPath string) (bool, error)

ImportLegacy brings a SlashDiablo player's old launcher settings across, once: their Diablo II folder, box count, flags, maphack, HD and D2GL versions, and launch delay. It only fills in what isn't set yet, and only choices the SlashDiablo profile actually offers. It reports whether anything was imported.

func (*Manager) InstallBase

func (m *Manager) InstallBase(ctx context.Context, o basegame.Options, progress func(basegame.Progress)) (basegame.Result, error)

InstallBase installs the base game and, once it passes its check, makes it the Diablo II folder. Cancelling ctx stops it; installing again resumes.

func (*Manager) InstallRosetta

func (m *Manager) InstallRosetta(ctx context.Context) error

InstallRosetta installs Rosetta 2, which macOS asks an administrator to agree to.

func (*Manager) Ladder

func (m *Manager) Ladder(ctx context.Context, id string) (*Ladder, error)

Ladder returns a server's ladder.

func (*Manager) LaunchDelay

func (m *Manager) LaunchDelay() int

LaunchDelay is the wait between starting boxes, in milliseconds.

func (*Manager) LogIn

func (m *Manager) LogIn(ctx context.Context, id string, open func(url string) error) (Login, error)

LogIn opens the server's login page in the player's browser with open and waits for them to finish there.

func (*Manager) LogOut

func (m *Manager) LogOut(id string) error

LogOut forgets the server's login.

func (*Manager) LoginStatus

func (m *Manager) LoginStatus(ctx context.Context, id string) (Login, error)

LoginStatus is the server's login.

func (*Manager) News

func (m *Manager) News(ctx context.Context, id string) ([]NewsItem, error)

News returns a server's latest posts, newest first. Only plain text is used: HTML from a feed is never rendered.

func (*Manager) Play

func (m *Manager) Play(ctx context.Context, id string) error

Play starts the server's boxes.

func (*Manager) PostReport

func (m *Manager) PostReport(ctx context.Context, id, contentType string, body []byte) ([]byte, error)

PostReport sends a bug report to the server's report URL and returns its answer.

func (*Manager) Profile

func (m *Manager) Profile(ctx context.Context, id string) (*spec.Profile, error)

Profile returns a server's profile, loading the listing first if needed.

func (*Manager) RemoveServer

func (m *Manager) RemoveServer(id string) error

RemoveServer forgets a server added by URL. Its folder under the Diablo II install is left alone.

func (*Manager) ServerFolder

func (m *Manager) ServerFolder(id string) (string, error)

ServerFolder returns a server's folder under the Diablo II install, creating it if needed, so the player can open it and add their own files.

func (*Manager) Servers

func (m *Manager) Servers(ctx context.Context) ([]ServerInfo, error)

Servers loads the listing and any servers the player added by URL. A server whose profile doesn't load is still returned, with the error, so the player sees why. If the listing itself can't be loaded, servers added by URL are still returned alongside the error.

func (*Manager) SetBase

func (m *Manager) SetBase(dir string) (install.Report, error)

SetBase changes the Diablo II folder after checking it.

func (*Manager) SetBaseInstaller

func (m *Manager) SetBaseInstaller(b BaseInstaller)

SetBaseInstaller lets the manager install the base game.

func (*Manager) SetChannel

func (m *Manager) SetChannel(ctx context.Context, id, channel string) error

SetChannel switches release channel.

func (*Manager) SetComponent

func (m *Manager) SetComponent(ctx context.Context, id, comp, version string) error

SetComponent turns a component on at a version, on with the player's own files (CustomVersion), or off with "". Takes effect on the next update.

func (*Manager) SetD2GLResolutions

func (m *Manager) SetD2GLResolutions(id, main, loader string) error

SetD2GLResolutions sets the window size for the main box and the loader boxes when d2gl profiles are split.

func (*Manager) SetFavourite

func (m *Manager) SetFavourite(id string, on bool) error

SetFavourite pins or unpins a server.

func (*Manager) SetFavouriteOrder

func (m *Manager) SetFavouriteOrder(ids []string) error

SetFavouriteOrder reorders the pinned servers, as when the player drags them in the rail. ids must be exactly the pinned servers, in their new order.

func (*Manager) SetInstances

func (m *Manager) SetInstances(ctx context.Context, id string, n int, splitD2GL bool) error

SetInstances sets how many boxes to start.

func (*Manager) SetLaunchDelay

func (m *Manager) SetLaunchDelay(ms int) error

SetLaunchDelay changes the wait between boxes.

func (*Manager) SetSetting

func (m *Manager) SetSetting(ctx context.Context, id, settingID string, value interface{}) error

SetSetting changes one setting. File settings are written straight to the file; flag settings are stored and passed at launch.

func (*Manager) SetWine

func (m *Manager) SetWine(h *wine.Host)

SetWine has the game run under Wine, set up by h: on macOS and Linux. d2gl is then on by default, where the player hasn't chosen.

func (*Manager) Settings

func (m *Manager) Settings(ctx context.Context, id string) ([]SettingValue, error)

Settings returns every setting the server declares, with its value. File settings are read from the file itself, so changes made in game show up.

func (*Manager) SetupWine

func (m *Manager) SetupWine(ctx context.Context, progress func(wine.Progress)) error

SetupWine downloads Wine and makes the prefix, as needed. Quick when it's already done.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context, id string) Status

Status reports whether the server is installed and up to date.

func (*Manager) TurnOffDEP

func (m *Manager) TurnOffDEP(ctx context.Context, id string) error

TurnOffDEP turns DEP off for a server's Game.exe, for this Windows account.

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, id string, allowCopy bool, progress func(sync.Progress)) error

Update brings a server's folder up to date.

func (*Manager) Verify

func (m *Manager) Verify(ctx context.Context, id string) Status

Verify checks every file in a server's folder against its manifests, hashing each one again rather than trusting the remembered hashes, and reports what an update would repair. Files the player owns ("once" files and custom components) are left out, as they are for an update.

func (*Manager) WineStatus

func (m *Manager) WineStatus(ctx context.Context) WineStatus

WineStatus checks Wine without setting anything up.

type NewsItem

type NewsItem struct {
	Title   string    `json:"title"`
	URL     string    `json:"url"`
	Summary string    `json:"summary"`
	Date    time.Time `json:"date"`
}

NewsItem is one post from a server's JSON Feed.

type RemoteListing

type RemoteListing struct {
	URL    string
	Client *fetch.Client
	Store  *store.Store
}

RemoteListing fetches the published index, falling back to the last copy when offline.

func (RemoteListing) Profiles

func (r RemoteListing) Profiles(ctx context.Context) ([]json.RawMessage, error)

Profiles fetches the index.

type ServerInfo

type ServerInfo struct {
	ID        string        `json:"id"`
	Verified  bool          `json:"verified"`
	Favourite bool          `json:"favourite"`
	Profile   *spec.Profile `json:"profile"`
	Error     string        `json:"error"`
}

ServerInfo is a server as the catalog shows it.

type SettingValue

type SettingValue struct {
	Setting   spec.Setting `json:"setting"`
	Value     interface{}  `json:"value"`
	Available bool         `json:"available"`
	Reason    string       `json:"reason"`
}

SettingValue is one declared setting with its current value.

type Status

type Status struct {
	Installed   bool   `json:"installed"`
	UpToDate    bool   `json:"upToDate"`
	UpdateFiles int    `json:"updateFiles"`
	UpdateBytes int64  `json:"updateBytes"`
	Error       string `json:"error"`
}

Status is whether a server is ready to play.

type WineStatus

type WineStatus struct {
	Needed bool `json:"needed"`
	Ready  bool `json:"ready"`
	// NeedsRosetta asks the player to install Rosetta 2 first (Apple
	// Silicon).
	NeedsRosetta bool `json:"needsRosetta"`
}

WineStatus is whether the game needs Wine here, and whether it's ready.

Jump to

Keyboard shortcuts

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