guid

package
v0.0.0-...-382259f Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package guid stores the GUID or (Globally Unique Identifier), a 128-bit data type which can contain a type specifier, a server ID, and a global counter. This package uses the 128-bit format, but allows lossy conversion and semi-compatibility the old 64-bit format.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Nil represents the zero value of a GUID.
	Nil = GUID{0, 0}
	// Oldest known revision, unchanged until NewFormat
	OldFormat vsn.Build = 3368
	NewFormat vsn.Build = 19027
)
View Source
var (
	TypeMaskDescriptors = map[vsn.Build]TypeMaskDescriptor{
		vsn.Alpha: {
			TypeMaskObject:        0x0001,
			TypeMaskItem:          0x0002,
			TypeMaskContainer:     0x0004,
			TypeMaskUnit:          0x0008,
			TypeMaskPlayer:        0x0010,
			TypeMaskGameObject:    0x0020,
			TypeMaskDynamicObject: 0x0040,
			TypeMaskCorpse:        0x0080,
		},
	}
)

Functions

func DecodePacked64

func DecodePacked64(r io.Reader) uint64

func EncodeTypeID

func EncodeTypeID(version vsn.Build, id TypeID, out io.Writer) error

Types

type GUID

type GUID struct {
	Hi uint64
	Lo uint64
}

func Classic

func Classic(u64 uint64) GUID

func DecodePacked

func DecodePacked(version vsn.Build, reader io.Reader) (GUID, error)

func DecodePacked128

func DecodePacked128(r io.Reader) GUID

func DecodeUnpacked

func DecodeUnpacked(version vsn.Build, reader io.Reader) (GUID, error)

func FromString

func FromString(s string) (GUID, error)

func Global

func Global(t HighType, low uint64) GUID

func MapSpecific

func MapSpecific(t HighType, realmID uint64, subType uint8, mapID uint16, serverID uint32, entry uint32, counter uint32) GUID

func New

func New(high, low uint64) GUID

func RealmSpecific

func RealmSpecific(t HighType, realmID, low uint64) GUID

func (GUID) Classic

func (g GUID) Classic() uint64

func (GUID) Cmp

func (g GUID) Cmp(g2 GUID) int

func (GUID) Counter

func (g GUID) Counter() uint64

func (GUID) EncodePacked

func (g GUID) EncodePacked(version vsn.Build, w io.Writer)

EncodePacked GUIDs are encoded in a couple ways. 64-bit GUIDs can be encoded plainly as an 8-byte field, or in the "packed" format, a very simple compression mechanism. The packed format is a 8-bit mask value, followed by up to 8 bytes. If a bit n is true in the mask, it means that there is a byte that follows it at that position. If bit n is false, there is no byte that follows it and its decoded byte should be zero. Example (3 bytes):

byte(01000010) + byte(31) + byte(36)

Is decoded as (8 bytes):

[8]byte{0, 31, 0, 0, 0, 0, 36, 0}

The 128-bit format uses the exact same packing scheme, just with a 16-bit mask and up to 16 bytes following it.

func (GUID) EncodeUnpacked

func (g GUID) EncodeUnpacked(version vsn.Build, w io.Writer)

func (GUID) HiClassic

func (g GUID) HiClassic() uint32

func (GUID) HighType

func (g GUID) HighType() HighType

func (GUID) HighTypeBuild

func (g GUID) HighTypeBuild(build vsn.Build) uint64

func (GUID) IsUnit

func (g GUID) IsUnit() bool

func (GUID) LoClassic

func (g GUID) LoClassic() uint32

func (GUID) RealmID

func (g GUID) RealmID() uint32

func (GUID) SetRealmID

func (g GUID) SetRealmID(realmID uint64) GUID

func (GUID) String

func (g GUID) String() string

func (GUID) Summary

func (g GUID) Summary() string

type HighType

type HighType uint64
const (
	Null             HighType = 0
	Uniq             HighType = 1
	Player           HighType = 2
	Item             HighType = 3
	WorldTransaction HighType = 4
	StaticDoor       HighType = 5 //NYI
	Transport        HighType = 6
	Conversation     HighType = 7
	Creature         HighType = 8
	Vehicle          HighType = 9
	Pet              HighType = 10
	GameObject       HighType = 11
	DynamicObject    HighType = 12
	AreaTrigger      HighType = 13
	Corpse           HighType = 14
	LootObject       HighType = 15
	SceneObject      HighType = 16
	Scenario         HighType = 17
	AIGroup          HighType = 18
	DynamicDoor      HighType = 19
	ClientActor      HighType = 20 //NYI
	Vignette         HighType = 21
	CallForHelp      HighType = 22
	AIResource       HighType = 23
	AILock           HighType = 24
	AILockTicket     HighType = 25
	ChatChannel      HighType = 26
	Party            HighType = 27
	Guild            HighType = 28
	WowAccount       HighType = 29
	BNetAccount      HighType = 30
	GMTask           HighType = 31
	MobileSession    HighType = 32 //NYI
	RaidGroup        HighType = 33
	Spell            HighType = 34
	Mail             HighType = 35
	WebObj           HighType = 36 //NYI
	LFGObject        HighType = 37 //NYI
	LFGList          HighType = 38 //NYI
	UserRouter       HighType = 39
	PVPQueueGroup    HighType = 40
	UserClient       HighType = 41
	PetBattle        HighType = 42 //NYI
	UniqUserClient   HighType = 43
	BattlePet        HighType = 44
	CommerceObj      HighType = 45
	ClientSession    HighType = 46
	Cast             HighType = 47
	ClientConnection HighType = 48
	// virtual gophercraft codes for back compatibility
	Mo_Transport HighType = 60
	Instance     HighType = 61
	Group        HighType = 62
)

func (HighType) String

func (i HighType) String() string

type TypeID

type TypeID uint8
const (
	TypeObject TypeID = iota
	TypeItem
	TypeContainer
	TypeAzeriteEmpoweredItem
	TypeAzeriteItem
	TypeUnit
	TypePlayer
	TypeActivePlayer
	TypeGameObject
	TypeDynamicObject
	TypeCorpse
	TypeAreaTrigger
	TypeSceneObject
	TypeConversation

	TypeNPCText TypeID = 100
)

func DecodeTypeID

func DecodeTypeID(version vsn.Build, in io.Reader) (TypeID, error)

func (TypeID) String

func (i TypeID) String() string

type TypeIDDescriptor

type TypeIDDescriptor map[TypeID]uint8

type TypeMask

type TypeMask uint32
const (
	TypeMaskObject               TypeMask = 0x0001
	TypeMaskItem                 TypeMask = 0x0002
	TypeMaskContainer            TypeMask = 0x0004
	TypeMaskAzeriteEmpoweredItem TypeMask = 0x0008
	TypeMaskAzeriteItem          TypeMask = 0x0010
	TypeMaskUnit                 TypeMask = 0x0020
	TypeMaskPlayer               TypeMask = 0x0040
	TypeMaskActivePlayer         TypeMask = 0x0080
	TypeMaskGameObject           TypeMask = 0x0100
	TypeMaskDynamicObject        TypeMask = 0x0200
	TypeMaskCorpse               TypeMask = 0x0400
	TypeMaskAreaTrigger          TypeMask = 0x0800
	TypeMaskSceneObject          TypeMask = 0x1000
	TypeMaskConversation         TypeMask = 0x2000
	TypeMaskSeer                 TypeMask = TypeMaskPlayer | TypeMaskUnit | TypeMaskDynamicObject
)

func ResolveTypeMask

func ResolveTypeMask(version vsn.Build, unresolvedTypeMask uint32) (TypeMask, error)

func (TypeMask) Resolve

func (t TypeMask) Resolve(version vsn.Build) (uint32, error)

func (TypeMask) String

func (t TypeMask) String() string

type TypeMaskDescriptor

type TypeMaskDescriptor map[TypeMask]uint32

Jump to

Keyboard shortcuts

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