ffxiv

package module
v0.0.0-...-80a4c24 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 7 Imported by: 0

README

ffxiv-go

Go types for parsing FFXIV network communications (WIP)

Documentation

Index

Constants

View Source
const (
	MessageHeaderSize                            = int(unsafe.Sizeof(MessageHeader{}))
	MessageMarketTaxRatesSize                    = int(unsafe.Sizeof(MessageMarketTaxRates{}))
	MessageMarketBoardItemListingCountSize       = int(unsafe.Sizeof(MessageMarketBoardItemListingCount{}))
	MessageMarketBoardItemListingSize            = int(unsafe.Sizeof(MessageMarketBoardItemListing{}))
	MessageMarketBoardItemListingHistorySize     = int(unsafe.Sizeof(MessageMarketBoardItemListingHistory{}))
	MessageMarketBoardSearchResultSize           = int(unsafe.Sizeof(MessageMarketBoardSearchResult{}))
	MessageMarketBoardRequestItemListingInfoSize = int(unsafe.Sizeof(MessageMarketBoardRequestItemListingInfo{}))
)

These are constants for known message sizes

View Source
const BundleHeaderSize = 40

BundleHeaderSize is the known length of a bundle header

Variables

This section is empty.

Functions

func Decode

func Decode(encoding uint16, data []byte) ([]byte, error)

Decode returns a decoded byte slice for the provided data given a specified encoding.

func MagicIdentifier

func MagicIdentifier() []byte

MagicIdentifier is a function to lazily return the unique identifier of an FFXIV bundle headers based on a known constant. This function will panic if something goes wrong with the computation

Types

type BundleHeader

type BundleHeader struct {
	Magic      [4]uint32 `json:"magic"`
	Timestamp  uint64    `json:"timestamp"`
	Length     uint32    `json:"bundle_length"`
	Connection uint16    `json:"connection_type"`
	Count      uint16    `json:"message_count"`
	Encoding   uint16    `json:"encoding"`
	Unknown    [4]byte   `json:"-"`
}

BundleHeader is the header of an FFXIV message

func NewBundleHeader

func NewBundleHeader(b []byte) (*BundleHeader, error)

NewBundleHeader returns a new header from a given byte array. The byte array's size is expected to be exactly BundleHeaderSize bytes.

type Decoder

type Decoder func([]byte) ([]byte, error)

Decoder is a type to represent different encodings

type MarketBoardItem

type MarketBoardItem struct {
	ItemCatalogID uint32 `json:"item_catalog_id"`
	Quantity      uint16 `json:"quantity"`
	Demand        uint16 `json:"demand"`
}

MarketBoardItem is part of a message

type MarketHistoryListing

type MarketHistoryListing struct {
	SalePrice     uint32   `json:"sale_price"`
	PurchaseTime  uint32   `json:"purchase_time"`
	Quantity      uint32   `json:"quantity"`
	HQ            uint8    `json:"hq"`
	Unknown       byte     `json:"-"`
	OnMannequin   uint8    `json:"on_mannequin"`
	BuyerName     [33]byte `json:"buyer_name"`
	ItemCatalogID uint32   `json:"item_catalog_id"`
}

MarketHistoryListing is part of a message

type MarketItemListing

type MarketItemListing struct {
	ListingID       uint64    `json:"listing_id"`
	RetainerID      uint64    `json:"retainer_id"`
	RetainerOwnerID uint64    `json:"retainer_owner_id"`
	ArtisanID       uint64    `json:"artisan_id"`
	PricePerUnit    uint32    `json:"price_per_unit"`
	TotalTax        uint32    `json:"total_tax"`
	ItemQuantity    uint32    `json:"item_quantity"`
	ItemID          uint32    `json:"item_id"`
	LastReviewTime  uint16    `json:"last_review_time"`
	ContainerID     uint16    `json:"container_id"`
	SlotID          uint32    `json:"slot_id"`
	Durability      uint16    `json:"durability"`
	SpiritBond      uint16    `json:"spirit_bond"`
	MateriaValue    [5]uint16 `json:"materia_value"`
	Unknown1        [6]byte   `json:"-"`
	RetainerName    [32]byte  `json:"retainer_name"`
	PlayerName      [32]byte  `json:"player_name"`
	HQ              bool      `json:"hq"`
	MateriaCount    uint8     `json:"materia_count"`
	OnMannequin     uint8     `json:"on_mannequin"`
	MarketCity      uint8     `json:"market_city"`
	DyeID           uint16    `json:"dye_id"`
	Unknown2        [6]byte   `json:"-"`
}

MarketItemListing is part of a message

type Message

type Message interface {
	IsMessage()
}

Message is composed of a message header and type-specific data

func NewMessage

func NewMessage(b []byte) (Message, error)

NewMessage returns a new message from a given byte array based on its type

func NewMessageBytes

func NewMessageBytes(b []byte) (Message, error)

NewMessageBytes returns a new message from a given byte array containing a message header and the raw bytes for the remaining message.

type MessageBytes

type MessageBytes struct {
	MessageHeader
	Bytes []byte `json:"bytes"`
}

MessageBytes is a generic message containing a header and raw bytes

type MessageHeader

type MessageHeader struct {
	Length        uint32  `json:"message_length"`
	SourceActorID uint32  `json:"source_actor_id"`
	TargetActorID uint32  `json:"target_actor_id"`
	ControlType   uint16  `json:"control_type"`
	Unknown1      [4]byte `json:"-"`
	Type          uint16  `json:"message_type"`
	Unknown2      [2]byte `json:"-"`
	ServerID      uint16  `json:"server_id"`
	Timestamp     uint32  `json:"timestamp"`
	Unknown3      uint32  `json:"-"`
}

MessageHeader is the header of an FFXIV message

func NewMessageHeader

func NewMessageHeader(b []byte) (*MessageHeader, error)

NewMessageHeader returns a new message header from a given byte array

func (MessageHeader) IsMessage

func (MessageHeader) IsMessage()

IsMessage exists for anything embedding a message header

type MessageMarketBoardItemListing

type MessageMarketBoardItemListing struct {
	MessageHeader
	Listing           [10]MarketItemListing `json:"listing"`
	ListingIndexEnd   uint8                 `json:"listing_index_end"`
	ListingIndexStart uint8                 `json:"listing_index_start"`
	RequestID         uint16                `json:"request_id"`
	Unknown           [4]byte               `json:"-"`
}

MessageMarketBoardItemListing is a message

type MessageMarketBoardItemListingCount

type MessageMarketBoardItemListingCount struct {
	MessageHeader
	ItemCatalogID uint32  `json:"item_catalog_id"`
	Unknown1      [4]byte `json:"-"`
	RequestID     uint16  `json:"request_id"`
	Quantity      uint16  `json:"quantity"`
	Unknown2      [4]byte `json:"-"`
}

MessageMarketBoardItemListingCount is a message

type MessageMarketBoardItemListingHistory

type MessageMarketBoardItemListingHistory struct {
	MessageHeader
	ItemCatalogID [2]uint32                `json:"item_catalog_id"`
	Listing       [20]MarketHistoryListing `json:"listing"`
}

MessageMarketBoardItemListingHistory is a message

type MessageMarketBoardRequestItemListingInfo

type MessageMarketBoardRequestItemListingInfo struct {
	MessageHeader
	CatalogID uint32 `json:"catalog_id"`
	RequestID uint32 `json:"request_id"`
}

MessageMarketBoardRequestItemListingInfo is a message

type MessageMarketBoardSearchResult

type MessageMarketBoardSearchResult struct {
	MessageHeader
	Items          [20]MarketBoardItem `json:"items"`
	ItemIndexEnd   uint32              `json:"item_index_end"`
	Unknown        [4]byte             `json:"-"`
	ItemIndexStart uint32              `json:"item_index_start"`
	RequestID      uint32              `json:"request_id"`
}

MessageMarketBoardSearchResult is a message

type MessageMarketTaxRates

type MessageMarketTaxRates struct {
	MessageHeader
	Unknown1 [8]byte           `json:"-"`
	TaxRates [townCount]uint32 `json:"tax_rates"`
	Unknown2 [8]byte           `json:"-"`
}

MessageMarketTaxRates is a message

type MessageParser

type MessageParser func([]byte) (Message, error)

MessageParser is a function to parse a message out of a byte slice

Jump to

Keyboard shortcuts

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