sde

package
v0.0.0-...-c7d0891 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2015 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeDoesNotExist    = fmt.Errorf("sde: type does not exist")
	ErrCacheNotInitialized = fmt.Errorf("sde: cache not initialized")
	ErrSDEIsNil            = fmt.Errorf("sde: SDE struct was nil")
	ErrTypeIsNil           = fmt.Errorf("sde: SDEType struct was nil")
)

Functions

func Save

func Save(filename string, s *SDE) error

Save saves a provided SDE object to disk

Types

type Cache

type Cache struct {
	TypeNameLookup map[string]*SDEType
}

Cache is a struct that is included within SDE.

Whenever an SDE file is loaded we populate this and whenever an SDE is saved we make the pointer nil. The struct is supposed to provide faster lookups for things like TypeName and mDisplayName

@TODO: Finish implementing Cache relating things

type Modifier

type Modifier struct {
	StackingPenalized string
	AttributeName     string
	ModifierValue     float64
	ModifierType      string
}

Modifier represents a modifier that a Type has in it's attributes

type SDE

type SDE struct {
	Version  string
	Official bool
	Types    map[int]*SDEType
	Cache    *Cache
}

SDE is a struct that owns every type for a given SDE.

func Load

func Load(filename string) (*SDE, error)

Load loads an encoding/gob encoded SDE object from file

func LoadReader

func LoadReader(r io.Reader) (*SDE, error)

LoadReader returns an SDE pointer given an io.Reader to read from

func (*SDE) DoCaching

func (s *SDE) DoCaching(c bool)

func (*SDE) FindTypesThatReference

func (s *SDE) FindTypesThatReference(t *SDEType) ([]*SDEType, error)

FindTypeThatReferences returns any time that refers to the given type

Suprising how fast this method runs

@TODO:

When our caching system is finished update this to not iterate all ~3400

types lol Not sure how I would cache referencing type attributes.. Hmmm

func (*SDE) GetType

func (s *SDE) GetType(id int) (sdetype *SDEType, err error)

GetType returns a pointer to an SDEType or nil and an error

func (*SDE) GetTypeByName

func (s *SDE) GetTypeByName(name string) ([]*SDEType, error)

GetTypeByName @TODO: Finish implementing

func (*SDE) GetTypesByTag

func (s *SDE) GetTypesByTag(tag int) ([]*SDEType, error)

GetTypeByTag @TODO: Finish implementing

func (*SDE) Search

func (s *SDE) Search(ss string) (sdetypes []*SDEType, err error)

Search checks for the existance of ss in mDisplayName or TypeName in every type and returns a slice of pointers to SDETypes

func (*SDE) Size

func (s *SDE) Size() int

Size estimates the memory usage of the SDE instance.

func (*SDE) VerifySDEPrint

func (s *SDE) VerifySDEPrint()

VerifySDEPrint prints the entire list of types/typeids to check for DB corruption

type SDEType

type SDEType struct {
	TypeID     int
	TypeName   string
	Attributes map[string]interface{}
	Parent     *SDE
}

SDEType is a struct representing a single individual type in an SDE.

func ApplyTypeToType

func ApplyTypeToType(tone, ttwo SDEType) (*SDEType, error)

ApplyTypeToType is a function that applies all the attributes given by tone to ttwo and returns the results as a pointer For now it doesn't work for skills. I'll likly write a different function for it.

func (*SDEType) CompareTo

func (s *SDEType) CompareTo(t *SDEType)

CompareTo prints the differences between two types

func (*SDEType) GetAttribute

func (s *SDEType) GetAttribute(attr string) interface{}

GetAttribute checks if the type has the attribute and returns it. If it doesn't exist we lookup the weapons projectile type

func (*SDEType) GetName

func (s *SDEType) GetName() string

GetName returns the string value of Attributes["mDisplayName"] if it exists. Otherwise we return TypeName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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