itemsotb

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package itemsotb reads in an items.otb file.

Top level OTB node's data represents version header, and its children represents individual items.

Index

Constants

View Source
const (
	CLIENT_VERSION_750                     = ClientVersion(1)
	CLIENT_VERSION_755                     = ClientVersion(2)
	CLIENT_VERSION_760, CLIENT_VERSION_770 = ClientVersion(3), ClientVersion(3)
	CLIENT_VERSION_780                     = ClientVersion(4)
	CLIENT_VERSION_790                     = ClientVersion(5)
	CLIENT_VERSION_792                     = ClientVersion(6)
	CLIENT_VERSION_800                     = ClientVersion(7)
	CLIENT_VERSION_810                     = ClientVersion(8)
	CLIENT_VERSION_811                     = ClientVersion(9)
	CLIENT_VERSION_820                     = ClientVersion(10)
	CLIENT_VERSION_830                     = ClientVersion(11)
	CLIENT_VERSION_840                     = ClientVersion(12)
	CLIENT_VERSION_841                     = ClientVersion(13)
	CLIENT_VERSION_842                     = ClientVersion(14)
	CLIENT_VERSION_850                     = ClientVersion(15)
	CLIENT_VERSION_854_BAD                 = ClientVersion(16)
	CLIENT_VERSION_854                     = ClientVersion(17)
	CLIENT_VERSION_855                     = ClientVersion(18)
	CLIENT_VERSION_860_OLD                 = ClientVersion(19)
	CLIENT_VERSION_860                     = ClientVersion(20)
	CLIENT_VERSION_861                     = ClientVersion(21)
	CLIENT_VERSION_862                     = ClientVersion(22)
	CLIENT_VERSION_870                     = ClientVersion(23)
)

Enumeration containing recognized protocol versions for which a particular items.otb file might be targeted.

Implementation detail: iota is not used primarily for easier referencing in case of an error.

View Source
const (
	ROOT_ATTR_VERSION = 0x01
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientVersion added in v0.0.8

type ClientVersion uint32

Enumeration containing recognized protocol versions for which a particular items.otb file might be targeted.

func (ClientVersion) String added in v0.0.8

func (v ClientVersion) String() string

String implements the stringer interface.

type Item

type Item struct {
	Group      ItemGroup
	Flags      ItemsFlags
	Attributes map[ItemsAttribute]interface{}
	// contains filtered or unexported fields
}

Item represents a single item stored in the items.otb file.

func (*Item) Article added in v0.0.8

func (i *Item) Article() string

Article returns the name of the item. This will only be sourced from XML, if loaded.

If empty, no article should be used; otherwise, in singular, prefix with article and a space.

func (*Item) ClientID added in v0.0.8

func (i *Item) ClientID() uint16

ClientID returns the item client ID for the client version for which this OTB is intended. If the item does not exist in this client version, zero is returned.

func (*Item) Description added in v0.0.8

func (i *Item) Description() string

Description returns the description of the item. This may be sourced from XML, if loaded.

If multiple descriptions are supplied, only the first one will be used.

func (*Item) Name

func (i *Item) Name() string

Name returns the name of the item. This may be sourced from XML, if loaded.

func (*Item) ServerID added in v0.0.8

func (i *Item) ServerID() uint16

ServerID returns the item server ID. If the item does not have a server ID (which would be highly irregular for an item that appears in the otb file), zero is returned.

type ItemGroup

type ItemGroup int

Enumeration containing which overarching item group this item belongs to.

Useful primarily for editors.

const (
	ITEM_GROUP_NONE ItemGroup = iota
	ITEM_GROUP_GROUND
	ITEM_GROUP_CONTAINER
	ITEM_GROUP_WEAPON     // deprecated
	ITEM_GROUP_AMMUNITION // deprecated
	ITEM_GROUP_ARMOR      // deprecated
	ITEM_GROUP_CHARGES
	ITEM_GROUP_TELEPORT   // deprecated
	ITEM_GROUP_MAGICFIELD // deprecated
	ITEM_GROUP_WRITEABLE  // deprecated
	ITEM_GROUP_KEY        // deprecated
	ITEM_GROUP_SPLASH
	ITEM_GROUP_FLUID
	ITEM_GROUP_DOOR // deprecated
	ITEM_GROUP_DEPRECATED
	ITEM_GROUP_LAST
)

func (ItemGroup) String

func (g ItemGroup) String() string

type Items

type Items struct {
	otb.OTB
	Version ItemsVersion
	Items   []Item

	ClientIDToArrayIndex map[uint16]int
	ServerIDToArrayIndex map[uint16]int

	ExtantClientItemIDs       []uint16
	ExtantServerItemIDs       []uint16
	ExtantClientItemArrayIdxs []int
	ExtantServerItemArrayIdxs []int

	ServerIDToExtantClientItemArrayIDXs map[uint16]int // a strange hack allowing us to seek within ExtantClientItemArrayIdxs based on server ID

	MinClientID, MaxClientID uint16
	MinServerID, MaxServerID uint16
}

func New

func New(r io.ReadSeeker) (*Items, error)

New reads an OTB file from a given reader.

func (*Items) AddXMLInfo

func (otb *Items) AddXMLInfo(r io.Reader) error

func (*Items) ItemByClientID

func (otb *Items) ItemByClientID(clientID uint16) (*Item, error)

ItemByClientID allows lookup of an item stored in an items.otb file based on its ID used by the network protocol and associated data files.

func (*Items) ItemByServerID

func (otb *Items) ItemByServerID(serverID uint16) (*Item, error)

ItemByServerID allows lookup of an item stored in an items.otb file based on its persistent 'server' ID, which stays fixed between versions, and is used by the server-side data storage, by map files, etc.

type ItemsAttribute

type ItemsAttribute uint8
const (
	ITEM_ATTR_FIRST    ItemsAttribute = 0x10
	ITEM_ATTR_SERVERID ItemsAttribute = iota + 0x10 - 1
	ITEM_ATTR_CLIENTID
	ITEM_ATTR_NAME  // deprecated
	ITEM_ATTR_DESCR // deprecated
	ITEM_ATTR_SPEED
	ITEM_ATTR_SLOT         // deprecated
	ITEM_ATTR_MAXITEMS     // deprecated
	ITEM_ATTR_WEIGHT       // deprecated
	ITEM_ATTR_WEAPON       // deprecated
	ITEM_ATTR_AMU          // deprecated
	ITEM_ATTR_ARMOR        // deprecated
	ITEM_ATTR_MAGLEVEL     // deprecated
	ITEM_ATTR_MAGFIELDTYPE // deprecated
	ITEM_ATTR_WRITEABLE    // deprecated
	ITEM_ATTR_ROTATETO     // deprecated
	ITEM_ATTR_DECAY        // deprecated
	ITEM_ATTR_SPRITEHASH
	ITEM_ATTR_MINIMAPCOLOR
	ITEM_ATTR_07
	ITEM_ATTR_08
	ITEM_ATTR_LIGHT

	// 1byte aligned
	ITEM_ATTR_DECAY2     // deprecated
	ITEM_ATTR_WEAPON2    // deprecated
	ITEM_ATTR_AMU2       // deprecated
	ITEM_ATTR_ARMOR2     // deprecated
	ITEM_ATTR_WRITEABLE2 // deprecated
	ITEM_ATTR_LIGHT2
	ITEM_ATTR_TOPORDER
	ITEM_ATTR_WRITEABLE3 // deprecated
	ITEM_ATTR_LAST
)

Enumeration containing recognized attributes in the items.otb file.

func (ItemsAttribute) String

func (a ItemsAttribute) String() string

type ItemsDataSize

type ItemsDataSize uint16

type ItemsFlags

type ItemsFlags uint32
const (
	FLAG_BLOCK_SOLID ItemsFlags = 1 << iota
	FLAG_BLOCK_PROJECTILE
	FLAG_BLOCK_PATHFIND
	FLAG_HAS_HEIGHT
	FLAG_USEABLE
	FLAG_PICKUPABLE
	FLAG_MOVEABLE
	FLAG_STACKABLE
	FLAG_FLOORCHANGEDOWN
	FLAG_FLOORCHANGENORTH
	FLAG_FLOORCHANGEEAST
	FLAG_FLOORCHANGESOUTH
	FLAG_FLOORCHANGEWEST
	FLAG_ALWAYSONTOP
	FLAG_READABLE
	FLAG_ROTABLE
	FLAG_HANGABLE
	FLAG_VERTICAL
	FLAG_HORIZONTAL
	FLAG_CANNOTDECAY
	FLAG_ALLOWDISTREAD
	FLAG_UNUSED
	FLAG_CLIENTCHARGES // deprecated
	FLAG_LOOKTHROUGH
	FLAG_ANIMATION
	FLAG_WALKSTACK

	FLAG_LAST
)

Enumeration containing possible bits in the `flags` bitmask of an item.

func (ItemsFlags) String

func (f ItemsFlags) String() string

type ItemsVersion

type ItemsVersion struct {
	MajorVersion uint32
	MinorVersion ClientVersion // uint32
	BuildNumber  uint32
	CSDVersion   [128]uint8
}

ItemsVersion represents the version of the items.otb file.

MajorVersion means a revision of the file format, MinorVersion means the targeted protocol version, BuildNumber is an arbitrary number representing ther revision of the file, and CSDVersion is a byte array with a C-style null-terminated string.

func (ItemsVersion) CSDVersionAsString

func (v ItemsVersion) CSDVersionAsString() string

CSDVersionAsString formats null-terminated C-style string `CSDArray` from a byte array into usual Go string.

type Light

type Light struct {
	LightLevel uint16
	LightColor uint16
}

Light represents the data structure describing a lit-up item's light attribute ITEM_ATTR_LIGHT2, as stored in an items.otb file.

Jump to

Keyboard shortcuts

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