maps

package
v0.0.0-...-b9edb71 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 31 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Magic    = 0xFADEFACE
	MagicOld = 0xFADEBEEF
)
View Source
const (
	Dir           = "maps"
	Ext           = ".map"
	SoloPrefixWar = "war"
	SoloPrefixWiz = "wiz"
	SoloPrefixCon = "con"
)
View Source
const (
	DefaultPort = common.GameHTTPPort
)

Variables

View Source
var (
	ErrAPIUnsupported = errors.New("map API not supported")
	ErrNotFound       = errors.New("map not found")
)
View Source
var (
	Log = log.New("map")
)

Functions

func CompressMap

func CompressMap(w io.Writer, fss fs.FS, dir string) error

CompressMap collects and compresses relevant files from Nox/OpenNox map directory.

func IsAllowedFile

func IsAllowedFile(path string) bool

IsAllowedFile checks if the file with a given name is allowed to be distributed with the map.

func RegisterSection

func RegisterSection(sect Section)

func SectionOrder

func SectionOrder(name string) int

SectionOrder returns an order in which the section should be written. It returns math.MaxInt for unknown sections, so they sort last.

func SortRawSections

func SortRawSections(arr []RawSection)

SortRawSections sorts a slice of sections according to SectionOrder.

func SortSections

func SortSections(arr []Section)

SortSections sorts a slice of sections according to SectionOrder.

Types

type AmbientData

type AmbientData struct {
	AmbientColor types.RGB
}

func (*AmbientData) Decode

func (sect *AmbientData) Decode(r *binenc.Reader) error

func (*AmbientData) MapSection

func (*AmbientData) MapSection() string

func (*AmbientData) MarshalBinary

func (sect *AmbientData) MarshalBinary() ([]byte, error)

func (*AmbientData) UnmarshalBinary

func (sect *AmbientData) UnmarshalBinary(data []byte) error

type Client

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

func NewClient

func NewClient(ctx context.Context, addr string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) DownloadMap

func (c *Client) DownloadMap(ctx context.Context, dest string, name string) error

DownloadMap with a given name to dest.

type DestructableWall

type DestructableWall struct {
	Pos image.Point
}

func (*DestructableWall) Decode

func (w *DestructableWall) Decode(r *binenc.Reader) error

func (*DestructableWall) MarshalBinary

func (w *DestructableWall) MarshalBinary() ([]byte, error)

type DestructableWalls

type DestructableWalls struct {
	Walls []DestructableWall
}

func (*DestructableWalls) Decode

func (sect *DestructableWalls) Decode(r *binenc.Reader) error

func (*DestructableWalls) MapSection

func (*DestructableWalls) MapSection() string

func (*DestructableWalls) MarshalBinary

func (sect *DestructableWalls) MarshalBinary() ([]byte, error)

func (*DestructableWalls) UnmarshalBinary

func (sect *DestructableWalls) UnmarshalBinary(data []byte) error

type Edge

type Edge struct {
	Image   byte
	Variant uint16
	Edge    byte
	Dir     byte
}

func (*Edge) Decode

func (e *Edge) Decode(r *binenc.Reader) error

func (*Edge) MarshalBinary

func (e *Edge) MarshalBinary() ([]byte, error)

type FloorMap

type FloorMap struct {
	Grid  GridData
	Tiles []TilePair
}

func (*FloorMap) Decode

func (sect *FloorMap) Decode(r *binenc.Reader) error

func (*FloorMap) MapSection

func (*FloorMap) MapSection() string

func (*FloorMap) MarshalBinary

func (sect *FloorMap) MarshalBinary() ([]byte, error)

func (*FloorMap) UnmarshalBinary

func (sect *FloorMap) UnmarshalBinary(data []byte) error

type FloorPos

type FloorPos struct {
	X, Y uint16
}

type GridData

type GridData struct {
	Prefix uint16
	Var1   uint32
	Var2   uint32
	Var3   uint32
	Var4   uint32
}

func (*GridData) Decode

func (g *GridData) Decode(r *binenc.Reader) error

func (*GridData) MarshalBinary

func (g *GridData) MarshalBinary() ([]byte, error)
type Header struct {
	Magic uint32
	Offs  image.Point
}

type Info

type Info struct {
	Filename string `json:"name"`
	Size     int    `json:"size"`
	MapInfo
}

func ReadMapInfo

func ReadMapInfo(dir string) (*Info, error)

type Map

type Map struct {
	Info

	Intro             *MapIntro
	Ambient           *AmbientData
	Walls             *WallMap
	Floor             *FloorMap
	Script            *Script
	ScriptData        *ScriptData
	SecretWalls       *SecretWalls
	WindowWalls       *WindowWalls
	DestructableWalls *DestructableWalls
	Waypoints         *Waypoints
	Unknown           []RawSection
	// contains filtered or unexported fields
}

func ReadMap

func ReadMap(dir string) (*Map, error)

func (*Map) CRC

func (m *Map) CRC() uint32

func (*Map) GridBoundingBox

func (m *Map) GridBoundingBox() image.Rectangle

GridBoundingBox returns a bounding box for all walls and tiles on the map. Returned rectangle uses grid coordinates, not pixel coordinates.

func (*Map) Header

func (m *Map) Header() Header

type MapInfo

type MapInfo struct {
	Format        uint16        `json:"format,omitempty"`
	Summary       string        `json:"summary,omitempty"`        // 0 [64]
	Description   string        `json:"description,omitempty"`    // 64 [512]
	Version       string        `json:"version,omitempty"`        // 576 [16]
	Author        string        `json:"author,omitempty"`         // 592 [64]
	Email         string        `json:"email,omitempty"`          // 656 [64]
	Author2       string        `json:"author_2,omitempty"`       // 720 [128]
	Email2        string        `json:"email_2,omitempty"`        // 848 [128]
	Field7        string        `json:",omitempty"`               // 976 [256]
	Copyright     string        `json:"copyright,omitempty"`      // 1232 [128]
	Date          string        `json:"date_str,omitempty"`       // 1360 [32]
	Flags         uint32        `json:"flags,omitempty"`          // 1392
	MinPlayers    byte          `json:"min_players,omitempty"`    // 1396
	MaxPlayers    byte          `json:"max_players,omitempty"`    // 1397
	QuestIntro    string        `json:"quest_intro,omitempty"`    // 1398
	QuestGraphics string        `json:"quest_graphics,omitempty"` // 1430
	Trailing      MapInfoCompat `json:"trailing,omitempty"`
}

func (*MapInfo) Decode

func (info *MapInfo) Decode(r *binenc.Reader) error

func (*MapInfo) MapSection

func (*MapInfo) MapSection() string

func (*MapInfo) MarshalBinary

func (info *MapInfo) MarshalBinary() ([]byte, error)

func (*MapInfo) UnmarshalBinary

func (info *MapInfo) UnmarshalBinary(data []byte) error

type MapInfoCompat

type MapInfoCompat struct {
	Summary     string `json:"summary,omitempty"`
	Description string `json:"description,omitempty"`
	Version     string `json:"version,omitempty"`
	Author      string `json:"author,omitempty"`
	Email       string `json:"email,omitempty"`
	Author2     string `json:"author_2,omitempty"`
	Email2      string `json:"email_2,omitempty"`
	Field7      string `json:",omitempty"`
	Copyright   string `json:"copyright,omitempty"`
	Date        string `json:"date_str,omitempty"`
}

type MapIntro

type MapIntro struct {
	Data string
}

func (*MapIntro) Decode

func (sect *MapIntro) Decode(r *binenc.Reader) error

func (*MapIntro) MapSection

func (*MapIntro) MapSection() string

func (*MapIntro) MarshalBinary

func (sect *MapIntro) MarshalBinary() ([]byte, error)

func (*MapIntro) UnmarshalBinary

func (sect *MapIntro) UnmarshalBinary(data []byte) error

type MapItem

type MapItem struct {
	Field6 int
	Info
}

type MapItemList

type MapItemList []MapItem

func (*MapItemList) Sort

func (m *MapItemList) Sort()

type MapList

type MapList []Info

func Scan

func Scan(path string, opts *ScanOptions) (MapList, error)

func (*MapList) Sort

func (m *MapList) Sort()

type NativeDownloader

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

func NewNativeDownloader

func NewNativeDownloader(dir string) *NativeDownloader

func (*NativeDownloader) CancelAndCleanup

func (d *NativeDownloader) CancelAndCleanup()

func (*NativeDownloader) CancelAndDelete

func (d *NativeDownloader) CancelAndDelete()

func (*NativeDownloader) Complete

func (d *NativeDownloader) Complete() bool

func (*NativeDownloader) DownloadOK

func (d *NativeDownloader) DownloadOK() bool

func (*NativeDownloader) Progress

func (d *NativeDownloader) Progress() float64

func (*NativeDownloader) Reset

func (d *NativeDownloader) Reset()

func (*NativeDownloader) Start

func (d *NativeDownloader) Start(path string, sz uint) error

func (*NativeDownloader) WritePart

func (d *NativeDownloader) WritePart(ind uint, data []byte)

type ObjectTOC

type ObjectTOC struct {
	Ind  uint16
	Type string
}

func (*ObjectTOC) Decode

func (w *ObjectTOC) Decode(r *binenc.Reader) error

func (*ObjectTOC) MarshalBinary

func (w *ObjectTOC) MarshalBinary() ([]byte, error)

type Objects

type Objects struct {
	Vers uint16
	Data []byte
}

func (*Objects) Decode

func (sect *Objects) Decode(r *binenc.Reader) error

func (*Objects) MapSection

func (*Objects) MapSection() string

func (*Objects) MarshalBinary

func (sect *Objects) MarshalBinary() ([]byte, error)

func (*Objects) ReadObjects

func (sect *Objects) ReadObjects(toc *ObjectsTOC, reg xfer.ObjectRegistry) ([]Xfer, error)

func (*Objects) UnmarshalBinary

func (sect *Objects) UnmarshalBinary(data []byte) error

type ObjectsTOC

type ObjectsTOC struct {
	Vers uint16
	TOC  []ObjectTOC
}

func (*ObjectsTOC) Decode

func (sect *ObjectsTOC) Decode(r *binenc.Reader) error

func (*ObjectsTOC) MapSection

func (*ObjectsTOC) MapSection() string

func (*ObjectsTOC) MarshalBinary

func (sect *ObjectsTOC) MarshalBinary() ([]byte, error)

func (*ObjectsTOC) UnmarshalBinary

func (sect *ObjectsTOC) UnmarshalBinary(data []byte) error

type Polygon

type Polygon struct {
	Name         string
	AmbientLight types.RGB
	MinimapGroup byte
	Points       []uint32
	PlayerEnter  *ScriptHandler
	MonsterEnter *ScriptHandler
	Flags        uint32
}

func (*Polygon) Decode

func (w *Polygon) Decode(r *binenc.Reader, vers uint16) error

func (*Polygon) EncodingSize

func (w *Polygon) EncodingSize() int

func (*Polygon) MarshalBinary

func (w *Polygon) MarshalBinary(vers uint16) ([]byte, error)

type PolygonPoint

type PolygonPoint struct {
	ID  uint32
	Pos types.Pointf
}

func (*PolygonPoint) Decode

func (w *PolygonPoint) Decode(r *binenc.Reader) error

func (*PolygonPoint) EncodingSize

func (w *PolygonPoint) EncodingSize() int

func (*PolygonPoint) MarshalBinary

func (w *PolygonPoint) MarshalBinary() ([]byte, error)

type Polygons

type Polygons struct {
	Vers     uint16
	Points   []PolygonPoint
	Polygons []Polygon
}

func (*Polygons) Decode

func (sect *Polygons) Decode(r *binenc.Reader) error

func (*Polygons) MapSection

func (*Polygons) MapSection() string

func (*Polygons) MarshalBinary

func (sect *Polygons) MarshalBinary() ([]byte, error)

func (*Polygons) UnmarshalBinary

func (sect *Polygons) UnmarshalBinary(data []byte) error

type RawSection

type RawSection struct {
	Name string
	Data []byte
}

func (RawSection) Decode

func (sect RawSection) Decode() (Section, error)

func (RawSection) Supported

func (sect RawSection) Supported() bool

type Reader

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

func NewReader

func NewReader(r io.Reader) (*Reader, error)

func (*Reader) Header

func (r *Reader) Header() Header

func (*Reader) Info

func (r *Reader) Info() *Info

func (*Reader) Map

func (r *Reader) Map() *Map

func (*Reader) ReadInfo

func (r *Reader) ReadInfo() (*Info, error)

func (*Reader) ReadScript

func (r *Reader) ReadScript() (*Script, error)

func (*Reader) ReadSections

func (r *Reader) ReadSections() error

func (*Reader) ReadSectionsRaw

func (r *Reader) ReadSectionsRaw() ([]RawSection, error)

type ScanOptions

type ScanOptions struct {
	Solo bool // don't skip solo maps
}

type Script

type Script struct {
	Data []byte
}

func ReadScript

func ReadScript(r io.Reader) (*Script, error)

func (*Script) Decode

func (sect *Script) Decode(r *binenc.Reader) error

func (*Script) MapSection

func (*Script) MapSection() string

func (*Script) MarshalBinary

func (sect *Script) MarshalBinary() ([]byte, error)

func (*Script) ReadScript

func (sect *Script) ReadScript() (*asm.Script, error)

func (*Script) UnmarshalBinary

func (sect *Script) UnmarshalBinary(data []byte) error

type ScriptData

type ScriptData struct {
	Data []byte
}

func (*ScriptData) Decode

func (sect *ScriptData) Decode(r *binenc.Reader) error

func (*ScriptData) MapSection

func (*ScriptData) MapSection() string

func (*ScriptData) MarshalBinary

func (sect *ScriptData) MarshalBinary() ([]byte, error)

func (*ScriptData) UnmarshalBinary

func (sect *ScriptData) UnmarshalBinary(data []byte) error

type ScriptHandler

type ScriptHandler struct {
	Ind  int16
	Func string
	Val3 uint32
}

func (*ScriptHandler) Decode

func (w *ScriptHandler) Decode(r *binenc.Reader) error

func (*ScriptHandler) EncodingSize

func (w *ScriptHandler) EncodingSize() int

func (*ScriptHandler) MarshalBinary

func (w *ScriptHandler) MarshalBinary() ([]byte, error)

func (*ScriptHandler) UnmarshalBinary

func (w *ScriptHandler) UnmarshalBinary(data []byte) error

type SecretWall

type SecretWall struct {
	Pos       image.Point
	OpenWait  uint32
	Flags     byte
	State     byte
	OpenDelay byte
	LastOpen  uint32
	R2        uint32
}

func (*SecretWall) Decode

func (w *SecretWall) Decode(r *binenc.Reader) error

func (*SecretWall) MarshalBinary

func (w *SecretWall) MarshalBinary() ([]byte, error)

type SecretWalls

type SecretWalls struct {
	Walls []SecretWall
}

func (*SecretWalls) Decode

func (sect *SecretWalls) Decode(r *binenc.Reader) error

func (*SecretWalls) MapSection

func (*SecretWalls) MapSection() string

func (*SecretWalls) MarshalBinary

func (sect *SecretWalls) MarshalBinary() ([]byte, error)

func (*SecretWalls) UnmarshalBinary

func (sect *SecretWalls) UnmarshalBinary(data []byte) error

type Section

type Section interface {
	MapSection() string
	Decode(r *binenc.Reader) error
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

type Server

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

func NewServer

func NewServer(path string) *Server

func (*Server) RegisterOnMux

func (s *Server) RegisterOnMux(mux *http.ServeMux)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Tile

type Tile struct {
	Image   byte
	Variant uint16
	Field4  uint16
	Edges   []Edge
}

func (*Tile) Decode

func (t *Tile) Decode(r *binenc.Reader) error

func (*Tile) IsZero

func (t *Tile) IsZero() bool

func (*Tile) MarshalBinary

func (t *Tile) MarshalBinary() ([]byte, error)

type TilePair

type TilePair struct {
	Pos    FloorPos
	F1, F2 byte
	L, R   *Tile
}

func (*TilePair) Decode

func (p *TilePair) Decode(r *binenc.Reader) error

func (*TilePair) HasLeft

func (p *TilePair) HasLeft() bool

func (*TilePair) HasRight

func (p *TilePair) HasRight() bool

func (*TilePair) IsZero

func (p *TilePair) IsZero() bool

func (*TilePair) LeftPos

func (p *TilePair) LeftPos() FloorPos

func (*TilePair) MarshalBinary

func (p *TilePair) MarshalBinary() ([]byte, error)

func (*TilePair) RightPos

func (p *TilePair) RightPos() FloorPos

type Wall

type Wall struct {
	Pos      WallPos
	Dir      byte
	DirBit   byte
	Material byte
	Variant  byte
	Minimap  byte
	Modified byte
}

func (*Wall) Decode

func (w *Wall) Decode(r *binenc.Reader) error

func (*Wall) IsZero

func (w *Wall) IsZero() bool

func (*Wall) MarshalBinary

func (w *Wall) MarshalBinary() ([]byte, error)

type WallMap

type WallMap struct {
	Grid  GridData
	Walls []Wall
}

func (*WallMap) Decode

func (sect *WallMap) Decode(r *binenc.Reader) error

func (*WallMap) MapSection

func (*WallMap) MapSection() string

func (*WallMap) MarshalBinary

func (sect *WallMap) MarshalBinary() ([]byte, error)

func (*WallMap) UnmarshalBinary

func (sect *WallMap) UnmarshalBinary(data []byte) error

type WallPos

type WallPos struct {
	X, Y byte
}

type Waypoint

type Waypoint struct {
	ID    uint32
	Pos   types.Pointf
	Name  string
	Flags uint32
	Links []WaypointLink
}

func (*Waypoint) Decode

func (w *Waypoint) Decode(r *binenc.Reader) error

func (*Waypoint) EncodingSize

func (w *Waypoint) EncodingSize() int

func (*Waypoint) MarshalBinary

func (w *Waypoint) MarshalBinary() ([]byte, error)
type WaypointLink struct {
	ID    uint32
	Flags byte
}

func (*WaypointLink) Decode

func (w *WaypointLink) Decode(r *binenc.Reader) error

func (*WaypointLink) MarshalBinary

func (w *WaypointLink) MarshalBinary() ([]byte, error)

type Waypoints

type Waypoints struct {
	Waypoints []Waypoint
}

func (*Waypoints) Decode

func (sect *Waypoints) Decode(r *binenc.Reader) error

func (*Waypoints) MapSection

func (*Waypoints) MapSection() string

func (*Waypoints) MarshalBinary

func (sect *Waypoints) MarshalBinary() ([]byte, error)

func (*Waypoints) UnmarshalBinary

func (sect *Waypoints) UnmarshalBinary(data []byte) error

type WindowWall

type WindowWall struct {
	Pos image.Point
}

func (*WindowWall) Decode

func (w *WindowWall) Decode(r *binenc.Reader) error

func (*WindowWall) MarshalBinary

func (w *WindowWall) MarshalBinary() ([]byte, error)

type WindowWalls

type WindowWalls struct {
	Walls []WindowWall
}

func (*WindowWalls) Decode

func (sect *WindowWalls) Decode(r *binenc.Reader) error

func (*WindowWalls) MapSection

func (*WindowWalls) MapSection() string

func (*WindowWalls) MarshalBinary

func (sect *WindowWalls) MarshalBinary() ([]byte, error)

func (*WindowWalls) UnmarshalBinary

func (sect *WindowWalls) UnmarshalBinary(data []byte) error

type Writer

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

func NewWriter

func NewWriter(w WriterAt, h Header) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) WriteRawSection

func (w *Writer) WriteRawSection(s RawSection) error

func (*Writer) WriteRawSections

func (w *Writer) WriteRawSections(arr []RawSection) error

func (*Writer) WriteSection

func (w *Writer) WriteSection(s Section) error

func (*Writer) WriteSections

func (w *Writer) WriteSections(arr []Section) error

type WriterAt

type WriterAt interface {
	io.Writer
	io.WriterAt
}

type Xfer

type Xfer struct {
	Type string
	Xfer xfer.Xfer
}

Directories

Path Synopsis
Package minidraw implements functions for drawing simple minimaps based on Nox maps.
Package minidraw implements functions for drawing simple minimaps based on Nox maps.

Jump to

Keyboard shortcuts

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