w3m

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package w3m implements basic information extraction functions for w3m/w3x files.

Example
package main

import (
	"fmt"

	"github.com/nielsAD/gowarcraft3/file/w3m"
)

func main() {
	m, err := w3m.Open("./test_tft.w3x")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer m.Close()

	info, err := m.Info()
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(info.Name)

}
Output:

Small Wars

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrBadFormat = errors.New("w3m: Invalid file format")
)

Errors

Functions

This section is empty.

Types

type CustomTechAvailability

type CustomTechAvailability struct {
	PlayerSet protocol.BitSet32
	TechID    protocol.DWordString
}

CustomTechAvailability in war3map.w3i file

type CustomUpgradeAvailability

type CustomUpgradeAvailability struct {
	PlayerSet    protocol.BitSet32
	UpgradeID    protocol.DWordString
	Level        uint32
	Availability UpgradeAvailability
}

CustomUpgradeAvailability in war3map.w3i file

type Force

type Force struct {
	Flags     ForceFlags
	PlayerSet protocol.BitSet32
	Name      string
}

Force structure in war3map.w3i file

type ForceFlags

type ForceFlags uint32

ForceFlags enum

const (
	ForceFlagAllied           ForceFlags = 0x01
	ForceFlagAlliedVictory    ForceFlags = 0x02
	ForceFlagShareVision      ForceFlags = 0x08
	ForceFlagShareUnitControl ForceFlags = 0x10
	ForceFlagShareAdvUnit     ForceFlags = 0x20
)

Force Flags

func (ForceFlags) String

func (f ForceFlags) String() string

type GameCodeFormat

type GameCodeFormat uint32

GameCodeFormat of source code

const (
	GameCodeFormatJASS GameCodeFormat = iota
	GameCodeFormatLua
)

Triggers source code types

type GameVersion

type GameVersion struct {
	Major  uint32
	Minor  uint32
	Patch  uint32
	Commit uint32
}

GameVersion stored in map file

type Hash

type Hash struct {
	Xoro uint32
	Sha1 [20]byte
}

Hash used to identify a loaded w3m/w3x map

func (*Hash) String

func (h *Hash) String() string

type Info

type Info struct {
	FileFormat    uint32
	SaveCount     uint32
	EditorVersion uint32
	GameVersion   GameVersion
	CodeFormat    GameCodeFormat

	Name             string
	Author           string
	Description      string
	SuggestedPlayers string

	CamBounds      [8]float32
	CamBoundsCompl [4]uint32

	Width  uint32
	Height uint32
	Flags  MapFlags

	Tileset      Tileset
	LsBackground uint32
	LsPath       string
	LsText       string
	LsTitle      string
	LsSubTitle   string

	DataSet    uint32
	PsPath     string
	PsText     string
	PsTitle    string
	PsSubTitle string

	Fog        uint32
	FogStart   float32
	FogEnd     float32
	FogDensity float32
	FogColor   uint32
	WeatherID  protocol.DWordString

	SoundEnv   string
	LightEnv   Tileset
	WaterColor uint32

	Players                     []Player
	Forces                      []Force
	CustomUpgradeAvailabilities []CustomUpgradeAvailability
	CustomTechAvailabilities    []CustomTechAvailability
}

Info for Warcraft III maps as found in the war3map.w3i file

func (*Info) Size

func (m *Info) Size() Size

Size returns the map size category

type Map

type Map struct {
	Archive *mpq.Archive
	// contains filtered or unexported fields
}

Map refers to an w3m/w3x map (MPQ archive)

func Open

func Open(fileName string) (*Map, error)

Open a w3m/w3x map file

func (*Map) Checksum

func (m *Map) Checksum(stor *fs.Storage) (*Hash, error)

Checksum returns the content hash that identifies the map (used in version < 1.32)

func (*Map) Close

func (m *Map) Close() error

Close a w3m/w3x map file

func (*Map) ExpandString

func (m *Map) ExpandString(s string) (string, error)

ExpandString expands trigger strings in s and returns the expanded string

func (*Map) Info

func (m *Map) Info() (*Info, error)

Info read from war3map.w3i

func (*Map) MenuMinimap

func (m *Map) MenuMinimap() (image.Image, error)

MenuMinimap returns the minimap with icons

func (*Map) Minimap

func (m *Map) Minimap() (image.Image, error)

Minimap returns an image with the minimap

func (*Map) MinimapIcons

func (m *Map) MinimapIcons() (image.Image, error)

MinimapIcons returns an image with (just the) minimap icons

func (*Map) Preview

func (m *Map) Preview() (image.Image, error)

Preview returns a preview image

func (*Map) Signed

func (m *Map) Signed() bool

Signed checks if map is signed with a strong signature

func (*Map) TriggerStrings

func (m *Map) TriggerStrings() (map[int]string, error)

TriggerStrings from war3map.wts

type MapFlags

type MapFlags uint32

MapFlags enum

const (
	MapFlagHideMinimap             MapFlags = 0x0001
	MapFlagModifyAllyPriorities    MapFlags = 0x0002
	MapFlagMelee                   MapFlags = 0x0004
	MapFlagRevealTerrain           MapFlags = 0x0010
	MapFlagFixedPlayerSettings     MapFlags = 0x0020
	MapFlagCustomForces            MapFlags = 0x0040
	MapFlagCustomTechTree          MapFlags = 0x0080
	MapFlagCustomAbilities         MapFlags = 0x0100
	MapFlagCustomUpgrades          MapFlags = 0x0200
	MapFlagWaterWavesOnCliffShores MapFlags = 0x0800
	MapFlagWaterWavesOnSlopeShores MapFlags = 0x1000
)

Map Flags

func (MapFlags) String

func (f MapFlags) String() string

type MinimapIcon

type MinimapIcon uint32

MinimapIcon enum

const (
	IconGold MinimapIcon = iota
	IconNeutral
	IconCross
)

MinimapIcon for preview

func (MinimapIcon) Icon

func (i MinimapIcon) Icon() image.Image

Icon image

func (MinimapIcon) String

func (i MinimapIcon) String() string

type Player

type Player struct {
	ID           uint32
	Type         PlayerType
	Race         Race
	Flags        PlayerFlags
	Name         string
	StartPosX    float32
	StartPosY    float32
	AllyPrioLow  protocol.BitSet32
	AllyPrioHigh protocol.BitSet32
}

Player structure in war3map.w3i file

type PlayerFlags

type PlayerFlags uint32

PlayerFlags enum

const (
	PlayerFlagFixedPos PlayerFlags = 0x01
)

Player Flags

func (PlayerFlags) String

func (f PlayerFlags) String() string

type PlayerType

type PlayerType uint32

PlayerType enum

const (
	PlayerHuman PlayerType = iota + 1
	PlayerComputer
	PlayerNeutral
	PlayerRescuable
)

Player types

func (PlayerType) String

func (p PlayerType) String() string

type Race

type Race uint32

Race enum

const (
	RaceSelectable Race = iota
	RaceHuman
	RaceOrc
	RaceUndead
	RaceNightElf
)

Races

func (Race) String

func (r Race) String() string

type Size

type Size uint8

Size enum

const (
	SizeTiny Size = iota
	SizeExtraSmall
	SizeSmall
	SizeNormal
	SizeLarge
	SizeExtraLarge
	SizeHuge
	SizeEpic
)

Map size categories

func (Size) String

func (s Size) String() string

type Tileset

type Tileset byte

Tileset enum

const (
	TileAshenvale       Tileset = 'A'
	TileBarrens         Tileset = 'B'
	TileFelwood         Tileset = 'C'
	TileDungeon         Tileset = 'D'
	TileLordaeronFall   Tileset = 'F'
	TileUnderground     Tileset = 'G'
	TileLordaeronSummer Tileset = 'L'
	TileNorthrend       Tileset = 'N'
	TileVillageFall     Tileset = 'Q'
	TileVillage         Tileset = 'V'
	TileLordaeronWinter Tileset = 'W'
	TileDalaran         Tileset = 'X'
	TileCityscape       Tileset = 'Y'
	TileSunkenRuins     Tileset = 'Z'
	TileIcecrown        Tileset = 'I'
	TileDalaranRuins    Tileset = 'J'
	TileOutland         Tileset = 'O'
	TileBlackCitadel    Tileset = 'K'
)

Tileset

func (Tileset) String

func (t Tileset) String() string

type UpgradeAvailability

type UpgradeAvailability uint32

UpgradeAvailability enum

const (
	UpgradeUnavailable UpgradeAvailability = iota
	UpgradeAvailable
	UpgradeResearched
)

Upgrade availabilities

func (UpgradeAvailability) String

func (u UpgradeAvailability) String() string

Jump to

Keyboard shortcuts

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