mpqLoader

package
v0.0.0-...-126e10b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 14 Imported by: 0

README

MPQ Archive Loader & Decompression Service

The purpose of this Service Mesh service is to provide a single service which loads and is able to decompress files from the collection of MPQ archive files used by diablo.

Dependencies

This service depends upon the config file service and will initialize its own default config.

There is an external dependency of this service, namely the presence of the Diablo 2 MPQ files on your local filesystem. The MPQ files are:

  • patch_d2.mpq
  • d2exp.mpq
  • d2xmusic.mpq
  • d2xtalk.mpq
  • d2xvideo.mpq
  • d2data.mpq
  • d2char.mpq
  • d2music.mpq
  • d2sfx.mpq
  • d2video.mpq
  • d2speech.mpq

These archives are searched in order, and the general idea is:

  • patch archives are searched first
  • the LOD expansion archives are searched second
  • the vanilla d2 archives are searched last

For modding, obviously you would want to place your own patch MPQ file at the top of the list so that it is checked for the presence of files first.

Integration with other services

This service exports an integration interface ReadsMpqArchives with an alias Dependencncy which are intended to be used by other services for dependency resolution (see servicemesh.HasDependencies), and expose just the methods which other services should use.

type Dependency = ReadsMpqArchives

type ReadsMpqArchives interface {
    RequiredArchivesLoaded() bool
    Archives() map[string]*mpq.MPQ
    AddArchive(filepath string) error
    RemoveArchive(filepath string) error
    Load(filepath string) (io.Reader, error)
}

Other services should use the ReadsMpqArchives or Dependency interfaces to resolve their dependency on this service.

The RequiredArchivesLoaded method is intended to be used to delay other dependent services from initializing in their respective dependency resolution DependenciesResolved method .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency = ReadsMpqArchives

type ReadsMpqArchives

type ReadsMpqArchives interface {
	servicemesh.Service
	RequiredArchivesLoaded() bool
	Archives() map[string]*mpq.MPQ
	AddArchive(filepath string) error
	RemoveArchive(filepath string) error
	Load(filepath string) (io.Reader, error)
}

type Service

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

func (*Service) AddArchive

func (s *Service) AddArchive(filepath string) error

func (*Service) Archives

func (s *Service) Archives() map[string]*mpq.MPQ

func (*Service) ConfigFileName

func (s *Service) ConfigFileName() string

func (*Service) DefaultConfig

func (s *Service) DefaultConfig() (cfg configFile.Config)

func (*Service) DependenciesResolved

func (s *Service) DependenciesResolved() bool

func (*Service) Init

func (s *Service) Init(mesh servicemesh.Mesh)

func (*Service) Load

func (s *Service) Load(filepath string) (io.Reader, error)

func (*Service) LoadConfig

func (s *Service) LoadConfig(config *configFile.Config)

func (*Service) Logger

func (s *Service) Logger() *slog.Logger

func (*Service) Name

func (s *Service) Name() string

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) RemoveArchive

func (s *Service) RemoveArchive(filepath string) error

func (*Service) RequiredArchivesLoaded

func (s *Service) RequiredArchivesLoaded() bool

func (*Service) ResolveDependencies

func (s *Service) ResolveDependencies(services []servicemesh.Service)

func (*Service) SetLogger

func (s *Service) SetLogger(logger *slog.Logger)

Jump to

Keyboard shortcuts

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