gokira

package module
v0.0.0-...-ec5fe00 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 10 Imported by: 0

README

GoKira

GoKira is your go-to cache library for OldSchool RuneScape, written in Go.

Install

go get -u -v github.com/sinoz/gokira

Supported Revisions

GoKira has been tested on the following revisions of OldSchool RuneScape:

  • 149
  • 177
  • 178
  • 187

How To Use

Loading the cache is as easy as:

cache, err := gokira.LoadCache("cache/", 21)

If you are interested in the raw file data of the underlying file bundle, you can also do:

bundle, err := gokira.LoadFileBundle("cache/", 21)
if err != nil {
    log.Fatal(err)
}

cache, err := gokira.NewCache(bundle)
if err != nil {
    log.Fatal(err)
}

Developers who aren't very familiar with the cache might only want to use this library for streaming purposes in their server application. The game client expects to receive a collection of pages that together make up a categorized folder. To fetch such a folder (or the release manifest / update keys):

if archiveId == 255 && folderId == 255 {
    m, err := cache.getReleaseManifest()
    if err != nil {
        return nil, err
    }

    return m.Encode(), nil
}

return cache.getFolderPages(archiveId, folderId), nil

To learn more on how to use this library for your OldSchool RuneScape application, check out the examples directory.

Extras

Supported Cryptographic/Compression Utilities
  • XTEA (deciphering, enciphering)
  • RSA (decrypting, encrypting)
  • DJB2 (One-way hashing)
  • GZIP (Decompression)
  • BZIP2 (Decompression)

FAQ

Why the name?

I was watching the anime Death Note and couldn't really think of anything else. I needed something so here we go. If you have any suggestions, feel free to make an issue or comment on an existing issue.

Does this also support applying cache modifications?

No. The focus of this library is to give developers a cache library to build (server) applications with. Additionally, the Go standard library currently, at the time of this writing, does not support Bzip2 encoding. Although Gzip can be used, perhaps one day.

Will this library also support RuneScape 3?

No.

Giving Credits

  • Sini for some of the namings
  • Authors of OpenRS for illustrating the cache encoding format in their work

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	Id int
	// contains filtered or unexported fields
}

Archive is an aggregate of folders of packs of assets.

func (*Archive) GetFolder

func (archive *Archive) GetFolder(id int, keySet [4]int) (*Folder, error)

GetFolder produces a Folder of pages. May return an error.

func (*Archive) GetFolderPages

func (archive *Archive) GetFolderPages(folderId int) ([]byte, error)

GetFolderPages collects a set of raw pages that together make up the requested folder. May throw an error.

type ArchiveManifest

type ArchiveManifest struct {
	Id               int
	Format           uint8
	Version          uint32
	Directive        uint8
	FolderReferences []*FolderManifest
}

ArchiveManifest contains metadata about an archive.

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a file store that can serve information found within the contents of the FileBundle.

func LoadCache

func LoadCache(path string, indexCount int) (*Cache, error)

LoadCache loads a FileBundle from the specified path and wraps it into an instance of a Cache.

func NewCache

func NewCache(bundle *FileBundle) (*Cache, error)

NewCache constructs a new file store for the given file bundle. May return an error.

func (*Cache) ArchiveCount

func (cache *Cache) ArchiveCount() int

ArchiveCount returns the amount of archives this storage has available. This does not include the release manifest file as an index, unlike its IndexCount() variant.

func (*Cache) GetArchive

func (cache *Cache) GetArchive(id int) (*Archive, error)

func (*Cache) GetArchiveManifest

func (cache *Cache) GetArchiveManifest(archiveId int) (*ArchiveManifest, error)

func (*Cache) GetFolder

func (cache *Cache) GetFolder(archiveId, folderId int, keySet [4]int) (*Folder, error)

func (*Cache) GetFolderManifest

func (cache *Cache) GetFolderManifest(archiveId, folderId int) (*FolderManifest, error)

func (*Cache) GetFolderManifestByName

func (cache *Cache) GetFolderManifestByName(archiveId int, target string) (*FolderManifest, error)

func (*Cache) GetFolderPages

func (cache *Cache) GetFolderPages(archiveId, folderId int) ([]byte, error)

func (*Cache) GetReleaseManifest

func (cache *Cache) GetReleaseManifest() (*ReleaseManifest, error)

func (*Cache) GetUnencryptedFolder

func (cache *Cache) GetUnencryptedFolder(archive, folderId int) (*Folder, error)

func (*Cache) IndexCount

func (cache *Cache) IndexCount() int

IndexCount returns the amount of index files this store has available. This may include the release manifest file as an index.

type FileBundle

type FileBundle struct {
	// contains filtered or unexported fields
}

FileBundle is the bundle of binary resource files.

func LoadFileBundle

func LoadFileBundle(rootPath string, indexCount int) (*FileBundle, error)

LoadFileBundle attempts to load a specific collection of resource files located in in the specified root path. May also return an error.

func NewFileBundle

func NewFileBundle(data []byte, indices [][]byte, manifest []byte) *FileBundle

NewFileBundle constructs a new FileBundle using the given resources.

type Folder

type Folder struct {
	CompressionType byte
	Data            []byte
}

func (*Folder) GetPacks

func (folder *Folder) GetPacks(manifest *FolderManifest) ([]*Pack, error)

type FolderManifest

type FolderManifest struct {
	Index          int
	Id             int
	LabelHash      uint32
	Version        uint32
	Checksum       uint32
	PackReferences []*PackManifest
}

FolderManifest contains metadata about a folder in an archive.

type Pack

type Pack struct {
	Data []byte
}

Pack is a pack of assets stored in a Folder.

type PackManifest

type PackManifest struct {
}

PackManifest contains metadata about a pack in a folder.

type ReleaseManifest

type ReleaseManifest struct {
	Versions  []uint32
	Checksums []uint32
}

ReleaseManifest contains metadata about every archive in a storage.

func (*ReleaseManifest) Encode

func (manifest *ReleaseManifest) Encode() []byte

Encode encodes the checksums and versions of this manifest into byte array.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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