From 9526960ea090d86e480fa3f28de92ed354159568 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Thu, 6 Jun 2024 17:02:52 -0700 Subject: [PATCH] Add version 3 of package with old version 2 contents Due to the way golang handles major versions > v1, the package path *must* contain the major version in the import/module path. This means that importing module version 2 did not work because there was no v2 in the path. To get around this while still maintaining semantic versioning, a package version 3 was created in top-level directory 'v3'. This means import paths for v3 tags will now contain the 'v3' suffix as expected. Additional enhancements were made to the package for v3. Since a breaking change was going to be introduced anyway, some of the package files were reorganized to remove the verbose 'pkg/eolib/...' imports - the directories are all at the top of v3 together now. --- .gitmodules | 3 + Makefile | 4 +- package.go | 2 +- v3/cmd/protocol-gen-v3/main.go | 129 + v3/data/encode.go | 98 + v3/data/encode_test.go | 117 + v3/data/limits.go | 9 + v3/data/package.go | 2 + v3/data/reader.go | 304 + v3/data/reader_test.go | 422 + v3/data/utils.go | 23 + v3/data/writer.go | 200 + v3/data/writer_test.go | 216 + v3/encrypt/encrypt.go | 124 + v3/encrypt/encrypt_test.go | 99 + v3/encrypt/package.go | 2 + v3/encrypt/verification.go | 7 + v3/encrypt/verification_test.go | 40 + v3/eo-protocol | 1 + v3/generate.go | 3 + v3/internal/codegen/enum.go | 74 + v3/internal/codegen/packet.go | 110 + v3/internal/codegen/shared.go | 124 + v3/internal/codegen/shared_test.go | 79 + v3/internal/codegen/struct.go | 1014 ++ v3/internal/codegen/types/aliases.go | 25 + v3/internal/codegen/types/eotype.go | 93 + v3/internal/codegen/types/structinfo.go | 62 + v3/internal/codegen/types/typeconv.go | 56 + v3/internal/codegen/types/typesize.go | 111 + v3/internal/xml/models.go | 333 + v3/package.go | 11 + v3/packet/package.go | 2 + v3/packet/sequencer.go | 28 + v3/packet/sequencer_test.go | 34 + v3/packet/sequences.go | 139 + v3/packet/sequences_test.go | 70 + v3/protocol/enums_generated.go | 137 + v3/protocol/map/enums_generated.go | 217 + v3/protocol/map/package.go | 2 + v3/protocol/map/packets_generated.go | 1 + v3/protocol/map/structs_generated.go | 988 + v3/protocol/net/client/enums_generated.go | 187 + v3/protocol/net/client/package.go | 2 + v3/protocol/net/client/packetmap_generated.go | 176 + v3/protocol/net/client/packets_generated.go | 7285 ++++++++ v3/protocol/net/client/structs_generated.go | 99 + v3/protocol/net/enums_generated.go | 338 + v3/protocol/net/package.go | 2 + v3/protocol/net/packet.go | 18 + v3/protocol/net/packets_generated.go | 1 + v3/protocol/net/server/enums_generated.go | 718 + v3/protocol/net/server/package.go | 2 + v3/protocol/net/server/packetmap_generated.go | 241 + v3/protocol/net/server/packets_generated.go | 14824 ++++++++++++++++ v3/protocol/net/server/structs_generated.go | 4011 +++++ v3/protocol/net/structs_generated.go | 262 + v3/protocol/package.go | 2 + v3/protocol/packets_generated.go | 1 + v3/protocol/pub/enums_generated.go | 386 + v3/protocol/pub/package.go | 2 + v3/protocol/pub/packets_generated.go | 1 + v3/protocol/pub/server/enums_generated.go | 1 + v3/protocol/pub/server/package.go | 2 + v3/protocol/pub/server/structs_generated.go | 1180 ++ v3/protocol/pub/structs_generated.go | 1244 ++ v3/protocol/serialize.go | 18 + v3/protocol/structs_generated.go | 45 + v3/utils/utils.go | 42 + 69 files changed, 36603 insertions(+), 2 deletions(-) create mode 100644 v3/cmd/protocol-gen-v3/main.go create mode 100644 v3/data/encode.go create mode 100644 v3/data/encode_test.go create mode 100644 v3/data/limits.go create mode 100644 v3/data/package.go create mode 100644 v3/data/reader.go create mode 100644 v3/data/reader_test.go create mode 100644 v3/data/utils.go create mode 100644 v3/data/writer.go create mode 100644 v3/data/writer_test.go create mode 100644 v3/encrypt/encrypt.go create mode 100644 v3/encrypt/encrypt_test.go create mode 100644 v3/encrypt/package.go create mode 100644 v3/encrypt/verification.go create mode 100644 v3/encrypt/verification_test.go create mode 160000 v3/eo-protocol create mode 100644 v3/generate.go create mode 100644 v3/internal/codegen/enum.go create mode 100644 v3/internal/codegen/packet.go create mode 100644 v3/internal/codegen/shared.go create mode 100644 v3/internal/codegen/shared_test.go create mode 100644 v3/internal/codegen/struct.go create mode 100644 v3/internal/codegen/types/aliases.go create mode 100644 v3/internal/codegen/types/eotype.go create mode 100644 v3/internal/codegen/types/structinfo.go create mode 100644 v3/internal/codegen/types/typeconv.go create mode 100644 v3/internal/codegen/types/typesize.go create mode 100644 v3/internal/xml/models.go create mode 100644 v3/package.go create mode 100644 v3/packet/package.go create mode 100644 v3/packet/sequencer.go create mode 100644 v3/packet/sequencer_test.go create mode 100644 v3/packet/sequences.go create mode 100644 v3/packet/sequences_test.go create mode 100644 v3/protocol/enums_generated.go create mode 100644 v3/protocol/map/enums_generated.go create mode 100644 v3/protocol/map/package.go create mode 100644 v3/protocol/map/packets_generated.go create mode 100644 v3/protocol/map/structs_generated.go create mode 100644 v3/protocol/net/client/enums_generated.go create mode 100644 v3/protocol/net/client/package.go create mode 100644 v3/protocol/net/client/packetmap_generated.go create mode 100644 v3/protocol/net/client/packets_generated.go create mode 100644 v3/protocol/net/client/structs_generated.go create mode 100644 v3/protocol/net/enums_generated.go create mode 100644 v3/protocol/net/package.go create mode 100644 v3/protocol/net/packet.go create mode 100644 v3/protocol/net/packets_generated.go create mode 100644 v3/protocol/net/server/enums_generated.go create mode 100644 v3/protocol/net/server/package.go create mode 100644 v3/protocol/net/server/packetmap_generated.go create mode 100644 v3/protocol/net/server/packets_generated.go create mode 100644 v3/protocol/net/server/structs_generated.go create mode 100644 v3/protocol/net/structs_generated.go create mode 100644 v3/protocol/package.go create mode 100644 v3/protocol/packets_generated.go create mode 100644 v3/protocol/pub/enums_generated.go create mode 100644 v3/protocol/pub/package.go create mode 100644 v3/protocol/pub/packets_generated.go create mode 100644 v3/protocol/pub/server/enums_generated.go create mode 100644 v3/protocol/pub/server/package.go create mode 100644 v3/protocol/pub/server/structs_generated.go create mode 100644 v3/protocol/pub/structs_generated.go create mode 100644 v3/protocol/serialize.go create mode 100644 v3/protocol/structs_generated.go create mode 100644 v3/utils/utils.go diff --git a/.gitmodules b/.gitmodules index 615ea93..3e3282c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "eo-protocol"] path = eo-protocol url = https://www.github.com/cirras/eo-protocol +[submodule "eo-protocol-v3"] + path = v3/eo-protocol + url = https://www.github.com/cirras/eo-protocol diff --git a/Makefile b/Makefile index 3d63d43..6042bb4 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,9 @@ install: generate: @go install ./cmd/protocol-gen - @go generate ./... + @go generate . + @go install ./v3/cmd/protocol-gen-v3 + @go generate ./v3 clean: @rm $$(go env GOPATH)/bin/protocol-gen diff --git a/package.go b/package.go index 02f5e44..2d0e35a 100644 --- a/package.go +++ b/package.go @@ -1,4 +1,4 @@ // eolibgo is the top-level package for the Go implementation of eolib. // -// More details are available in the eolib subdirectory: [pkg/github.com/ethanmoffat/eolib-go/pkg/eolib] +// See the v3 version for more details: [pkg/github.com/ethanmoffat/eolib-go/v3] package eolibgo diff --git a/v3/cmd/protocol-gen-v3/main.go b/v3/cmd/protocol-gen-v3/main.go new file mode 100644 index 0000000..60e9870 --- /dev/null +++ b/v3/cmd/protocol-gen-v3/main.go @@ -0,0 +1,129 @@ +package main + +import ( + "encoding/xml" + "flag" + "fmt" + "io" + "io/fs" + "os" + "path" + "path/filepath" + "strings" + + "github.com/ethanmoffat/eolib-go/v3/internal/codegen" + eoxml "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +var inputDir string +var outputDir string + +func main() { + flag.StringVar(&inputDir, "i", "eo-protocol", "The input directory for eo-protocol files.") + flag.StringVar(&outputDir, "o", "protocol", "The output directory for generated code.") + flag.Parse() + + if _, err := os.Stat(inputDir); err != nil { + fmt.Printf("error: input directory %s does not exist\n", inputDir) + os.Exit(1) + } + + if _, err := os.Stat(outputDir); err != nil { + fmt.Printf("error: output directory %s does not exist\n", outputDir) + os.Exit(1) + } + + fmt.Printf("Using parameters:\n inputDir: %s\n outputDir: %s\n", inputDir, outputDir) + + protocolFiles := []string{} + filepath.WalkDir(path.Join(inputDir, "xml"), func(currentPath string, d fs.DirEntry, err error) error { + if path.Ext(currentPath) == ".xml" { + relativeDir := strings.ReplaceAll(currentPath, path.Join(inputDir, "xml"), "") + protocolFiles = append(protocolFiles, strings.ReplaceAll(relativeDir, "/protocol.xml", "")) + } + return nil + }) + + dirToPackageName := map[string]string{ + "map": "eomap", + "net": "net", + "net/client": "client", + "net/server": "server", + "pub": "pub", + "pub/server": "serverpub", + "": "protocol", + } + + var fullSpec eoxml.Protocol // all XML specs in a single place, for type lookups + var protocs []eoxml.Protocol // each individual protoc file + for _, file := range protocolFiles { + fullInputPath := path.Join(inputDir, "xml", file, "protocol.xml") + + fp, err := os.Open(fullInputPath) + if err != nil { + fmt.Printf("error opening file: %v\n", err) + os.Exit(1) + } + defer fp.Close() + + bytes, err := io.ReadAll(fp) + if err != nil { + fmt.Printf("error reading file: %v\n", err) + os.Exit(1) + } + + var next eoxml.Protocol + if err := xml.Unmarshal(bytes, &next); err != nil { + fmt.Printf("error unmarshalling xml: %v\n", err) + os.Exit(1) + } + + for i := range next.Enums { + next.Enums[i].Package = dirToPackageName[strings.Trim(file, string(os.PathSeparator))] + next.Enums[i].PackagePath = file + } + + for i := range next.Structs { + next.Structs[i].Package = dirToPackageName[strings.Trim(file, string(os.PathSeparator))] + next.Structs[i].PackagePath = file + } + + for i := range next.Packets { + next.Packets[i].Package = dirToPackageName[strings.Trim(file, string(os.PathSeparator))] + next.Packets[i].PackagePath = file + } + + fullSpec.Enums = append(fullSpec.Enums, next.Enums...) + fullSpec.Structs = append(fullSpec.Structs, next.Structs...) + fullSpec.Packets = append(fullSpec.Packets, next.Packets...) + + protocs = append(protocs, next) + } + + for i, file := range protocolFiles { + protoc := protocs[i] + + if err := protoc.Validate(); err != nil { + fmt.Printf("error validating unmarshalled xml: %v\n", err) + os.Exit(1) + } + + fullOutputPath := path.Join(outputDir, file) + + fmt.Printf("generating code :: %s\n", file) + fmt.Printf(" %3d enums\n", len(protoc.Enums)) + if err := codegen.GenerateEnums(fullOutputPath, protoc.Enums); err != nil { + fmt.Printf(" error generating enums: %v\n", err) + } + + fmt.Printf(" %3d structs\n", len(protoc.Structs)) + if err := codegen.GenerateStructs(fullOutputPath, protoc.Structs, fullSpec); err != nil { + fmt.Printf(" error generating structs: %v\n", err) + } + + fmt.Printf(" %3d packets\n", len(protoc.Packets)) + if err := codegen.GeneratePackets(fullOutputPath, protoc.Packets, fullSpec); err != nil { + fmt.Printf(" error generating packets: %v\n", err) + } + } +} diff --git a/v3/data/encode.go b/v3/data/encode.go new file mode 100644 index 0000000..d999e45 --- /dev/null +++ b/v3/data/encode.go @@ -0,0 +1,98 @@ +package data + +import "github.com/ethanmoffat/eolib-go/v3/utils" + +// EncodeNumber encodes a number to a sequence of bytes. +func EncodeNumber(number int) []byte { + value := number + + d := 0xFE + if number >= THREE_MAX { + d = value/THREE_MAX + 1 + value = value % THREE_MAX + } + + c := 0xFE + if number >= SHORT_MAX { + c = value/SHORT_MAX + 1 + value = value % SHORT_MAX + } + + b := 0xFE + if number >= CHAR_MAX { + b = value/CHAR_MAX + 1 + value = value % CHAR_MAX + } + + a := value + 1 + + return []byte{byte(a), byte(b), byte(c), byte(d)} +} + +// DecodeNumber decodes a number from a sequence of bytes. +func DecodeNumber(bytes []byte) int { + result := 0 + length := utils.Min(len(bytes), 4) + + for i := 0; i < length; i++ { + value := int(bytes[i]) + + if value == 0xFE { + break + } + + value-- + + if i == 0 { + result += value + } else if i == 1 { + result += CHAR_MAX * value + } else if i == 2 { + result += SHORT_MAX * value + } else if i == 3 { + result += THREE_MAX * value + } + } + + return result +} + +// EncodeString encodes a string by inverting the bytes and then reversing them. +func EncodeString(str []byte) []byte { + inverted := invert(str) + return utils.Reverse(inverted) +} + +// DecodeString decodes a string by reversing the bytes and then inverting them. +func DecodeString(bytes []byte) []byte { + reversed := utils.Reverse(bytes) + return invert(reversed) +} + +func invert(bytes []byte) []byte { + flippy := len(bytes)%2 == 1 + + retBytes := make([]byte, len(bytes)) + copy(retBytes, bytes) + + for i, c := range retBytes { + retBytes[i] = c + + f := 0 + + if flippy { + f = 0x2E + if c >= 0x50 { + f *= -1 + } + } + + if c >= 0x22 && c <= 0x7E { + retBytes[i] = 0x9F - c - byte(f) + } + + flippy = !flippy + } + + return retBytes +} diff --git a/v3/data/encode_test.go b/v3/data/encode_test.go new file mode 100644 index 0000000..4fc5969 --- /dev/null +++ b/v3/data/encode_test.go @@ -0,0 +1,117 @@ +package data_test + +import ( + "fmt" + "os" + "testing" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/stretchr/testify/assert" + "golang.org/x/text/encoding/charmap" +) + +type encodeNumberParameters struct { + a byte + b byte + c byte + d byte + number int +} + +type encodeStringParameters struct { + decoded string + encoded string +} + +var encodeNumberTestCases []encodeNumberParameters +var encodeStringTestCases []encodeStringParameters + +func TestMain(m *testing.M) { + encodeNumberTestCases = []encodeNumberParameters{ + {0x01, 0xFE, 0xFE, 0xFE, 0}, + {0x02, 0xFE, 0xFE, 0xFE, 1}, + {0x1D, 0xFE, 0xFE, 0xFE, 28}, + {0x65, 0xFE, 0xFE, 0xFE, 100}, + {0x81, 0xFE, 0xFE, 0xFE, 128}, + {0xFD, 0xFE, 0xFE, 0xFE, 252}, + {0x01, 0x02, 0xFE, 0xFE, 253}, + {0x02, 0x02, 0xFE, 0xFE, 254}, + {0x03, 0x02, 0xFE, 0xFE, 255}, + {0x7E, 0x7F, 0xFE, 0xFE, 32003}, + {0x7F, 0x7F, 0xFE, 0xFE, 32004}, + {0x80, 0x7F, 0xFE, 0xFE, 32005}, + {0xFD, 0xFD, 0xFE, 0xFE, 64008}, + {0x01, 0x01, 0x02, 0xFE, 64009}, + {0x02, 0x01, 0x02, 0xFE, 64010}, + {0xB0, 0x3A, 0x9D, 0xFE, 10_000_000}, + {0xFD, 0xFD, 0xFD, 0xFE, 16_194_276}, + {0x01, 0x01, 0x01, 0x02, 16_194_277}, + {0x02, 0x01, 0x01, 0x02, 16_194_278}, + {0x7E, 0x7F, 0x7F, 0x7F, 2_048_576_039}, + {0x7F, 0x7F, 0x7F, 0x7F, 2_048_576_040}, + {0x80, 0x7F, 0x7F, 0x7F, 2_048_576_041}, + {0xFC, 0xFD, 0xFD, 0xFD, int(4097152079)}, + {0xFD, 0xFD, 0xFD, 0xFD, int(4097152080)}, + } + + encodeStringTestCases = []encodeStringParameters{ + {"Hello, World!", "!;a-^H s^3a:)"}, + {"We're ¼ of the way there, so ¾ is remaining.", "C8_6_6l2h- ,d ¾ ^, sh-h7Y T>V h7Y g0 ¼ :[xhH"}, + {"64² = 4096", ";fAk b ²=i"}, + {"© FÒÖ BÃR BÅZ 2014", "=nAm EÅ] MÃ] ÖÒY ©"}, + {"Öxxö Xööx \"Lëïth Säë\" - \"Ÿ\"", "OŸO D OëäL 7YïëSO UööG öU'Ö"}, + {"Padded with 0xFFÿÿÿÿÿÿÿÿ", "ÿÿÿÿÿÿÿÿ+YUo 7Y6V i:i;lO"}, + } + + os.Exit(m.Run()) +} + +func TestEncodeNumber(t *testing.T) { + for _, tc := range encodeNumberTestCases { + t.Run(fmt.Sprintf("%d should encode to [%d, %d, %d, %d]", tc.number, tc.a, tc.b, tc.c, tc.d), + func(t *testing.T) { + actual := data.EncodeNumber(tc.number) + assert.Equal(t, []byte{tc.a, tc.b, tc.c, tc.d}, actual) + }) + } +} + +func TestDecodeNumber(t *testing.T) { + for _, tc := range encodeNumberTestCases { + t.Run(fmt.Sprintf("[%d, %d, %d, %d] should decode to %d", tc.a, tc.b, tc.c, tc.d, tc.number), + func(t *testing.T) { + actual := data.DecodeNumber([]byte{tc.a, tc.b, tc.c, tc.d}) + assert.Equal(t, tc.number, actual) + }) + } +} + +func TestEncodeString(t *testing.T) { + for _, tc := range encodeStringTestCases { + t.Run(fmt.Sprintf("%s should encode to %s", tc.decoded, tc.encoded), + func(t *testing.T) { + bytes := toBytes(tc.decoded) + encoded := data.EncodeString(bytes) + assert.Equal(t, toBytes(tc.encoded), encoded) + }) + } +} + +func TestDecodeString(t *testing.T) { + for _, tc := range encodeStringTestCases { + t.Run(fmt.Sprintf("%s should decode to %s", tc.encoded, tc.decoded), + func(t *testing.T) { + bytes := toBytes(tc.encoded) + decoded := data.DecodeString(bytes) + assert.Equal(t, toBytes(tc.decoded), decoded) + }) + } +} + +func toBytes(input string) (ret []byte) { + for _, r := range input { + next, _ := charmap.Windows1252.EncodeRune(r) + ret = append(ret, next) + } + return +} diff --git a/v3/data/limits.go b/v3/data/limits.go new file mode 100644 index 0000000..987610b --- /dev/null +++ b/v3/data/limits.go @@ -0,0 +1,9 @@ +package data + +// Numeric maximum values for different EO data sizes +const ( + CHAR_MAX int = 253 // represents the maximum value of an EO char (1-byte encoded integer) + SHORT_MAX int = CHAR_MAX * CHAR_MAX // represents the maximum value of an EO short (2-byte encoded integer) + THREE_MAX int = CHAR_MAX * CHAR_MAX * CHAR_MAX // represents the maximum value of an EO three (3-byte encoded integer) + INT_MAX int = SHORT_MAX * SHORT_MAX // represents the maximum value of an EO int (4-byte encoded integer) +) diff --git a/v3/data/package.go b/v3/data/package.go new file mode 100644 index 0000000..556a05b --- /dev/null +++ b/v3/data/package.go @@ -0,0 +1,2 @@ +// Packate data provides utilities to read and write EO data types. +package data diff --git a/v3/data/reader.go b/v3/data/reader.go new file mode 100644 index 0000000..e1556b2 --- /dev/null +++ b/v3/data/reader.go @@ -0,0 +1,304 @@ +package data + +import ( + "errors" + "io" + "math" + + "github.com/ethanmoffat/eolib-go/v3/utils" +) + +type chunkProperties struct { + isChunked bool + chunkStart int + nextBreak int +} + +// EoReader encapsulates operations related to reading EO data from a sequence of bytes. +// +// EoReader features a "chunked" reading mode, which is important for accurate emulation of the official game client. +// +// See [chunked reading] for more information. +// +// [chunked reading]: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md +type EoReader struct { + data []byte + pos int + chunkInfo chunkProperties +} + +// NewEoReader initializes an [data.EoReader] with the data in the specified byte slice. +func NewEoReader(data []byte) *EoReader { + return &EoReader{data, 0, chunkProperties{false, 0, -1}} +} + +// Read satisfies the io.Reader interface. +// +// Read will read up to len(b) bytes into b. It returns the number of bytes read (0 <= n <= len(b)) and any error encountered. +// +// If Read returns n < len(b), it may use all of b as scratch space during the call. +// If some data is available but not len(b) bytes, Read returns what is available instead of waiting for more. +// +// When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. +// In the end-of-file condition, it returns the (non-nil) error and n == 0 from a subsequent call. +func (r *EoReader) Read(b []byte) (n int, err error) { + if len(b) == 0 { + return 0, errors.New("input is nil or empty") + } + + if r.Remaining() <= 0 { + return 0, io.EOF + } + + n = 0 + var nextByte byte + for nextByte = r.GetByte(); n < len(b) && r.Remaining() > 0; n++ { + b[n] = nextByte + } + + return +} + +// Seek satisfies the io.Seeker interface. +// +// Seek sets the current position of the reader to the specified offset, based on the specified value of whence. +// - io.SeekStart will set the absolute position of the reader relative to the start of the data. +// - io.SeekCurrent will set a relative position of the reader based on the current read position. +// - io.SeekEnd will set an absolute position from the end of the file (negative offset). +// +// Seek returns the new position of the reader and/or any error that occurred while seeking. +func (r *EoReader) Seek(offset int64, whence int) (i int64, err error) { + if offset > math.MaxInt32 { + return 0, errors.New("offset is greater than maximum supported value") + } + + switch whence { + case io.SeekStart: + r.pos = int(offset) + case io.SeekCurrent: + r.pos += int(offset) + case io.SeekEnd: + r.pos = len(r.data) - 1 + int(offset) + } + + i = int64(r.pos) + + if r.pos > len(r.data) { + err = errors.New("attempted to read past the end of available data") + } + + return +} + +// SliceFromCurrent creates a new [data.EoReader] from a slice of the reader's underlying data. +// +// The input data of the new reader will start at this reader's current position and contain all remaining data. The position and chunked reading mode of each reader are independent. +// +// The new reader's position starts at zero with chunked reading mode disabled. +func (r *EoReader) SliceFromCurrent() (*EoReader, error) { + return r.SliceFromIndex(r.pos) +} + +// SliceFromIndex creates a new [data.EoReader] from a slice of the reader's underlying data. +// +// The input data of the new reader will start at the specified index, offset from the start of the underlying data array, and contains all remaining data. The position and chunked reading mode of each reader are independent. +// +// The new reader's position starts at zero with chunked reading mode disabled. +func (r *EoReader) SliceFromIndex(index int) (*EoReader, error) { + return r.Slice(index, utils.Max(0, r.Length()-index)) +} + +// Slice creates a new [data.EoReader] from a slice of the reader's underlying data. +// +// The input data of the new reader will start at the specified index and contain bytes equal to the specified length. The position and chunked reading mode of each reader are independent. +// +// The new reader's position starts at zero with chunked reading mode disabled. +func (r *EoReader) Slice(index int, length int) (ret *EoReader, err error) { + if index < 0 { + err = errors.New("index must not be less than 0") + return + } + + if length < 0 { + err = errors.New("length must not be less than 0") + return + } + + startIndex := utils.Max(0, utils.Min(r.Length(), index)) + endIndex := utils.Min(len(r.data), utils.Min(r.Length(), length)+startIndex) + + return NewEoReader(r.data[startIndex:endIndex]), nil +} + +// GetByte reads a raw byte from the input data. +func (r *EoReader) GetByte() byte { + return r.readByte() +} + +// GetBytes reads an array of raw bytes from the input data. +func (r *EoReader) GetBytes(length int) []byte { + return r.readBytes(length) +} + +// GetChar reads an encoded 1-byte integer from the input data. +func (r *EoReader) GetChar() int { + return DecodeNumber(r.readBytes(1)) +} + +// GetShort reads an encoded 2-byte integer from the input data. +func (r *EoReader) GetShort() int { + return DecodeNumber(r.readBytes(2)) +} + +// GetThree reads an encoded 3-byte integer from the input data. +func (r *EoReader) GetThree() int { + return DecodeNumber(r.readBytes(3)) +} + +// GetInt reads an encoded 4-byte integer from the input data. +func (r *EoReader) GetInt() int { + return DecodeNumber(r.readBytes(4)) +} + +// GetString reads an unencoded string from the input data. +func (r *EoReader) GetString() (string, error) { + return string(r.readBytes(r.Remaining())), nil +} + +// GetFixedString reads an unencoded fixed string from the input data. +func (r *EoReader) GetFixedString(length int) (string, error) { + if length < 0 { + return "", errors.New("negative length") + } + + return string(r.readBytes(length)), nil +} + +// GetPaddedString reads an unencoded fixed string from the input data and removes trailing padding bytes (0xFF value). +func (r *EoReader) GetPaddedString(length int) (string, error) { + if length < 0 { + return "", errors.New("negative length") + } + + bytes := r.removePadding(r.readBytes(length)) + + return string(bytes), nil +} + +// GetEncodedString reads and decodes an encoded string from the input data. +func (r *EoReader) GetEncodedString() (string, error) { + return StringFromBytes(DecodeString(r.readBytes(r.Remaining()))), nil +} + +// GetFixedEncodedString reads and decodes a fixed string from the input data. +func (r *EoReader) GetFixedEncodedString(length int) (string, error) { + if length < 0 { + return "", errors.New("negative length") + } + + return StringFromBytes(DecodeString(r.readBytes(length))), nil +} + +// GetPaddedEncodedString reads and decodes a fixed string from the input data and removes trailing padding bytes (0xFF value). +func (r *EoReader) GetPaddedEncodedString(length int) (string, error) { + if length < 0 { + return "", errors.New("negative length") + } + + decoded := DecodeString(r.readBytes(length)) + bytes := r.removePadding([]byte(decoded)) + + return string(bytes), nil +} + +// IsChunked gets whether chunked reading is enabled for the reader. +func (r *EoReader) IsChunked() bool { + return r.chunkInfo.isChunked +} + +// SetIsChunked sets whether chunked reading is enabled for the reader. +// In chunked reading mode: +// - The reader will treat 0xFF bytes as the end of the current chunk. +// - [EoReader.NextChunk] can be called to move to the next chunk. +func (r *EoReader) SetIsChunked(value bool) { + r.chunkInfo.isChunked = value + if r.chunkInfo.nextBreak == -1 { + r.chunkInfo.nextBreak = r.findNextBreakIndex() + } +} + +// GetRemaining returns the number of bytes remaining in the input data. +// +// If chunked reading mode is enabled, gets the number of bytes remaining in the current chunk. +// Otherwise, gets the total number of bytes remaining in the input data. +func (r *EoReader) Remaining() int { + if r.chunkInfo.isChunked { + return r.chunkInfo.nextBreak - utils.Min(r.pos, r.chunkInfo.nextBreak) + } else { + return len(r.data) - r.pos + } +} + +// NextChunk moves the reader position to the start of the next chunk in the input data. +// An error is returned if the reader is not in chunked reading mode. +func (r *EoReader) NextChunk() error { + if !r.chunkInfo.isChunked { + return errors.New("not in chunked reading mode") + } + + r.pos = r.chunkInfo.nextBreak + if r.pos < len(r.data) { + r.pos++ + } + + r.chunkInfo.chunkStart = r.pos + r.chunkInfo.nextBreak = r.findNextBreakIndex() + + return nil +} + +// Position gets the current position in the input data. +func (r *EoReader) Position() int { + return r.pos +} + +// Length gets the length of the input data. +func (r *EoReader) Length() int { + return len(r.data) +} + +func (r *EoReader) readByte() byte { + if r.Remaining() > 0 { + defer r.Seek(1, io.SeekCurrent) + return r.data[r.pos] + } + + return 0 +} + +func (r *EoReader) readBytes(length int) []byte { + length = utils.Min(length, r.Remaining()) + + defer r.Seek(int64(length), io.SeekCurrent) + return r.data[r.pos : r.pos+length] +} + +func (r *EoReader) removePadding(input []byte) []byte { + for i, b := range input { + if b == 0xFF { + return input[:i] + } + } + + return input +} + +func (r *EoReader) findNextBreakIndex() int { + var i int + for i = r.chunkInfo.chunkStart; i < len(r.data); i++ { + if r.data[i] == 0xFF { + break + } + } + return i +} diff --git a/v3/data/reader_test.go b/v3/data/reader_test.go new file mode 100644 index 0000000..e6d97ef --- /dev/null +++ b/v3/data/reader_test.go @@ -0,0 +1,422 @@ +package data_test + +import ( + "fmt" + "testing" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/stretchr/testify/assert" +) + +func TestSlice(t *testing.T) { + reader := createReader([]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}) + reader.GetByte() + reader.SetIsChunked(true) + + reader2, err := reader.SliceFromCurrent() + assert.NoError(t, err) + assert.Equal(t, 0, reader2.Position()) + assert.Equal(t, 5, reader2.Remaining()) + assert.False(t, reader2.IsChunked()) + + reader3, err := reader2.SliceFromIndex(1) + assert.NoError(t, err) + assert.Equal(t, 0, reader3.Position()) + assert.Equal(t, 4, reader3.Remaining()) + assert.False(t, reader3.IsChunked()) + + reader4, err := reader3.Slice(1, 2) + assert.NoError(t, err) + assert.Equal(t, 0, reader4.Position()) + assert.Equal(t, 2, reader4.Remaining()) + assert.False(t, reader4.IsChunked()) + + assert.Equal(t, 1, reader.Position()) + assert.Equal(t, 5, reader.Remaining()) + assert.True(t, reader.IsChunked()) +} + +func TestSliceOverRead(t *testing.T) { + reader := createReader([]byte{0x01, 0x02, 0x03}) + + res, _ := reader.Slice(2, 5) + assert.Equal(t, 1, res.Remaining()) + + res, _ = reader.SliceFromIndex(3) + assert.Equal(t, 0, res.Remaining()) + + res, _ = reader.SliceFromIndex(4) + assert.Equal(t, 0, res.Remaining()) + + res, _ = reader.Slice(4, 12345) + assert.Equal(t, 0, res.Remaining()) +} + +func TestSliceNegativeInputs(t *testing.T) { + reader := data.EoReader{} + + _, err := reader.SliceFromIndex(-1) + assert.Error(t, err) + + _, err = reader.Slice(0, -1) + assert.Error(t, err) +} + +func TestReaderGetByte(t *testing.T) { + byteValues := []byte{0x00, 0x01, 0x02, 0x80, 0xFD, 0xFE, 0xFF} + for _, expected := range byteValues { + t.Run(fmt.Sprintf("ReadByte_%d", expected), func(t *testing.T) { + reader := createReader([]byte{expected}) + actual := reader.GetByte() + assert.Equal(t, expected, actual) + }) + } +} + +func TestReaderOverReadByte(t *testing.T) { + reader := createReader([]byte{}) + value := reader.GetByte() + assert.Equal(t, byte(0x00), value) +} + +func TestReaderGetBytes(t *testing.T) { + reader := createReader([]byte{0x01, 0x02, 0x03, 0x04, 0x05}) + assert.Equal(t, []byte{0x01, 0x02, 0x03}, reader.GetBytes(3)) + assert.Equal(t, []byte{0x04, 0x05}, reader.GetBytes(10)) + assert.Equal(t, []byte{}, reader.GetBytes(1)) +} + +func TestReaderGetChar(t *testing.T) { + reader := createReader([]byte{0x01, 0x02, 0x80, 0x81, 0xFD, 0xFE, 0xFF}) + assert.Equal(t, 0, reader.GetChar()) + assert.Equal(t, 1, reader.GetChar()) + assert.Equal(t, 127, reader.GetChar()) + assert.Equal(t, 128, reader.GetChar()) + assert.Equal(t, 252, reader.GetChar()) + assert.Equal(t, 0, reader.GetChar()) + assert.Equal(t, 254, reader.GetChar()) +} + +func TestReaderGetShort(t *testing.T) { + reader := data.NewEoReader([]byte{0x01, 0xFE, 0x02, 0xFE, 0x80, 0xFE, 0xFD, 0xFE, + 0xFE, 0xFE, 0xFE, 0x80, 0x7F, 0x7F, 0xFD, 0xFD}) + assert.Equal(t, 0, reader.GetShort()) + assert.Equal(t, 1, reader.GetShort()) + assert.Equal(t, 127, reader.GetShort()) + assert.Equal(t, 252, reader.GetShort()) + assert.Equal(t, 0, reader.GetShort()) + assert.Equal(t, 0, reader.GetShort()) + assert.Equal(t, 32004, reader.GetShort()) + assert.Equal(t, 64008, reader.GetShort()) +} + +func TestReaderGetThree(t *testing.T) { + reader := data.NewEoReader([]byte{ + 0x01, 0xFE, 0xFE, // 0 + 0x02, 0xFE, 0xFE, // 1 + 0x80, 0xFE, 0xFE, // 127 + 0xFD, 0xFE, 0xFE, // 252 + 0xFE, 0xFE, 0xFE, // 0 + 0xFE, 0x80, 0x81, // 0 + 0x7F, 0x7F, 0xFE, // 32004 + 0xFD, 0xFD, 0xFE, // 64008 + 0xFD, 0xFD, 0xFD}) // 16194276 + assert.Equal(t, 0, reader.GetThree()) + assert.Equal(t, 1, reader.GetThree()) + assert.Equal(t, 127, reader.GetThree()) + assert.Equal(t, 252, reader.GetThree()) + assert.Equal(t, 0, reader.GetThree()) + assert.Equal(t, 0, reader.GetThree()) + assert.Equal(t, 32004, reader.GetThree()) + assert.Equal(t, 64008, reader.GetThree()) + assert.Equal(t, 16194276, reader.GetThree()) +} + +func TestReaderGetInt(t *testing.T) { + reader := data.NewEoReader([]byte{ + 0x01, 0xFE, 0xFE, 0xFE, // 0 + 0x02, 0xFE, 0xFE, 0xFE, // 1 + 0x80, 0xFE, 0xFE, 0xFE, // 127 + 0xFD, 0xFE, 0xFE, 0xFE, // 252 + 0xFE, 0xFE, 0xFE, 0xFE, // 0 + 0xFE, 0x80, 0x81, 0x82, // 0 + 0x7F, 0x7F, 0xFE, 0xFE, // 32004 + 0xFD, 0xFD, 0xFE, 0xFE, // 64008 + 0xFD, 0xFD, 0xFD, 0xFE, // 16194276 + 0x7F, 0x7F, 0x7F, 0x7F, // 2048576040 + 0xFD, 0xFD, 0xFD, 0xFD}) // 4097152080 + assert.Equal(t, 0, reader.GetInt()) + assert.Equal(t, 1, reader.GetInt()) + assert.Equal(t, 127, reader.GetInt()) + assert.Equal(t, 252, reader.GetInt()) + assert.Equal(t, 0, reader.GetInt()) + assert.Equal(t, 0, reader.GetInt()) + assert.Equal(t, 32004, reader.GetInt()) + assert.Equal(t, 64008, reader.GetInt()) + assert.Equal(t, 16194276, reader.GetInt()) + assert.Equal(t, 2_048_576_040, reader.GetInt()) + assert.Equal(t, 4_097_152_080, reader.GetInt()) +} + +func TestReaderGetString(t *testing.T) { + const expected = "Hello, World!" + reader := createReader(toBytes(expected)) + actual, _ := reader.GetString() + assert.Equal(t, expected, actual) +} + +func TestReaderGetFixedString(t *testing.T) { + const input = "foobar" + reader := createReader(toBytes(input)) + actual1, _ := reader.GetFixedString(3) + actual2, _ := reader.GetFixedString(3) + assert.Equal(t, input[:3], actual1) + assert.Equal(t, input[3:], actual2) +} + +func TestReaderGetPaddedString(t *testing.T) { + const input = "fooÿbarÿÿÿ" + reader := createReader(toBytes(input)) + actual1, _ := reader.GetPaddedString(4) + actual2, _ := reader.GetPaddedString(6) + assert.Equal(t, "foo", actual1) + assert.Equal(t, "bar", actual2) +} + +func TestReaderGetStringChunked(t *testing.T) { + const input = "Hello,ÿWorld!" + reader := createReader(toBytes(input)) + reader.SetIsChunked(true) + + actual1, _ := reader.GetString() + assert.Equal(t, "Hello,", actual1) + + reader.NextChunk() + actual2, _ := reader.GetString() + assert.Equal(t, "World!", actual2) +} + +func TestReaderGetNegativeLengthFixedString(t *testing.T) { + reader := data.EoReader{} + _, err := reader.GetFixedString(-1) + assert.ErrorContains(t, err, "negative length") +} + +func TestReaderGetNegativeLengthPaddedString(t *testing.T) { + reader := data.EoReader{} + _, err := reader.GetPaddedString(-1) + assert.ErrorContains(t, err, "negative length") +} + +func TestReaderGetEncodedString(t *testing.T) { + const input = "!;a-^H s^3a:)" + reader := createReader(toBytes(input)) + actual, _ := reader.GetEncodedString() + assert.Equal(t, "Hello, World!", actual) +} + +func TestReaderGetFixedEncodedString(t *testing.T) { + const input = "^0g[>k" + reader := createReader(toBytes(input)) + actual1, _ := reader.GetFixedEncodedString(3) + actual2, _ := reader.GetFixedEncodedString(3) + assert.Equal(t, "foo", actual1) + assert.Equal(t, "bar", actual2) +} + +func TestReaderGetPaddedEncodedString(t *testing.T) { + const input = "ÿ0^9ÿÿÿ-l=S>k" + reader := createReader(toBytes(input)) + actual1, _ := reader.GetPaddedEncodedString(4) + actual2, _ := reader.GetPaddedEncodedString(6) + actual3, _ := reader.GetPaddedEncodedString(3) + assert.Equal(t, "foo", actual1) + assert.Equal(t, "bar", actual2) + assert.Equal(t, "baz", actual3) +} + +func TestReaderGetEncodedStringChunked(t *testing.T) { + const input = "E0a3hWÿ!;a-^H" + reader := createReader(toBytes(input)) + reader.SetIsChunked(true) + + actual1, _ := reader.GetEncodedString() + assert.Equal(t, "Hello,", actual1) + + reader.NextChunk() + actual2, _ := reader.GetEncodedString() + assert.Equal(t, "World!", actual2) +} + +func TestReaderGetNegativeLengthFixedEncodedString(t *testing.T) { + reader := data.EoReader{} + _, err := reader.GetFixedEncodedString(-1) + assert.ErrorContains(t, err, "negative length") +} + +func TestReaderGetNegativeLengthPaddedEncodedString(t *testing.T) { + reader := data.EoReader{} + _, err := reader.GetPaddedEncodedString(-1) + assert.ErrorContains(t, err, "negative length") +} + +func TestReaderRemaining(t *testing.T) { + bytes := []byte{0x01, 0x03, 0x04, 0xFE, 0x05, 0xFE, 0xFE, 0x06, 0xFE, 0xFE, 0xFE} + reader := createReader(bytes) + + assert.Equal(t, len(bytes), reader.Remaining()) + + reader.GetByte() + assert.Equal(t, len(bytes)-1, reader.Remaining()) + + reader.GetChar() + assert.Equal(t, len(bytes)-2, reader.Remaining()) + + reader.GetShort() + assert.Equal(t, len(bytes)-4, reader.Remaining()) + + reader.GetThree() + assert.Equal(t, len(bytes)-7, reader.Remaining()) + + reader.GetInt() + assert.Equal(t, len(bytes)-11, reader.Remaining()) + + reader.GetChar() + assert.Equal(t, 0, reader.Remaining()) +} + +func TestReaderRemainingChunked(t *testing.T) { + bytes := []byte{ + 0x01, 0x03, 0x04, + 0xFF, // chunk delimiter + 0x05, 0xFE, 0xFE, 0x06, 0xFE, 0xFE, 0xFE} + + reader := createReader(bytes) + reader.SetIsChunked(true) + + assert.Equal(t, 3, reader.Remaining()) + + reader.GetChar() + reader.GetShort() + assert.Equal(t, 0, reader.Remaining()) + + reader.GetChar() + assert.Equal(t, 0, reader.Remaining()) + + reader.NextChunk() + assert.Equal(t, 7, reader.Remaining()) +} + +func TestReaderNextChunk(t *testing.T) { + bytes := []byte{ + 0x01, 0x02, + 0xFF, // chunk delimiter + 0x03, 0x04, 0x5, + 0xFF, // chunk delimiter + 0x06} + + reader := createReader(bytes) + reader.SetIsChunked(true) + + assert.Equal(t, 0, reader.Position()) + + reader.NextChunk() + assert.Equal(t, 3, reader.Position()) + + reader.NextChunk() + assert.Equal(t, 7, reader.Position()) + + reader.NextChunk() + assert.Equal(t, 8, reader.Position()) + + reader.NextChunk() + assert.Equal(t, 8, reader.Position()) +} + +func TestReaderNextChunkError(t *testing.T) { + reader := data.EoReader{} + err := reader.NextChunk() + assert.ErrorContains(t, err, "not in chunked reading mode") +} + +func TestReaderNextChunkWithChunkedModeToggledInBetween(t *testing.T) { + bytes := []byte{ + 0x01, 0x02, + 0xFF, // chunk delimiter + 0x03, 0x04, 0x5, + 0xFF, // chunk delimiter + 0x06} + + reader := createReader(bytes) + + assert.Equal(t, 0, reader.Position()) + + reader.SetIsChunked(true) + reader.NextChunk() + reader.SetIsChunked(false) + assert.Equal(t, 3, reader.Position()) + + reader.SetIsChunked(true) + reader.NextChunk() + reader.SetIsChunked(false) + assert.Equal(t, 7, reader.Position()) + + reader.SetIsChunked(true) + reader.NextChunk() + reader.SetIsChunked(false) + assert.Equal(t, 8, reader.Position()) + + reader.SetIsChunked(true) + reader.NextChunk() + reader.SetIsChunked(false) + assert.Equal(t, 8, reader.Position()) +} + +func TestReaderUnderRead(t *testing.T) { + // See: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md#1-under-read + reader := createReader([]byte{0x7C, 0x67, 0x61, 0x72, 0x62, 0x61, 0x67, 0x65, 0xFF, 0xCA, 0x31}) + reader.SetIsChunked(true) + + assert.Equal(t, 123, reader.GetChar()) // byte representation: 123 = 0x7C + + reader.NextChunk() + assert.Equal(t, 12345, reader.GetShort()) // byte representation: 12345 = 0xCA 0x31 +} + +func TestOverRead(t *testing.T) { + // See: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md#2-over-read + reader := createReader([]byte{0xFF, 0x7C}) + reader.SetIsChunked(true) + + assert.Equal(t, 0, reader.GetInt()) + + reader.NextChunk() + assert.Equal(t, 123, reader.GetShort()) +} + +func TestDoubleRead(t *testing.T) { + // See: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md#3-double-read + reader := createReader([]byte{0xFF, 0x7C, 0xCA, 0x31}) + + // Reading all 4 bytes of the input data + assert.Equal(t, 790222478, reader.GetInt()) + + // Activating chunked mode and seeking to the first break byte with nextChunk(), which actually + // takes our reader position backwards. + reader.SetIsChunked(true) + reader.NextChunk() + + assert.Equal(t, 123, reader.GetChar()) + assert.Equal(t, 12345, reader.GetShort()) +} + +func createReader(inp []byte) *data.EoReader { + tmp := make([]byte, len(inp)+20) + for i, b := range inp { + tmp[i+10] = b + } + + reader := data.NewEoReader(tmp) + retReader, _ := reader.Slice(10, len(inp)) + return retReader +} diff --git a/v3/data/utils.go b/v3/data/utils.go new file mode 100644 index 0000000..595697f --- /dev/null +++ b/v3/data/utils.go @@ -0,0 +1,23 @@ +package data + +import "golang.org/x/text/encoding/charmap" + +// StringFromBytes converts a sequence of bytes to a string using the Windows-1252 character set +func StringFromBytes(bytes []byte) string { + var ret []rune + for _, b := range bytes { + next := charmap.Windows1252.DecodeByte(b) + ret = append(ret, next) + } + return string(ret) +} + +// BytesFromString converts a string to a sequence of bytes using the Windows-1252 character set +func BytesFromString(str string) []byte { + ret := make([]byte, 0, len(str)) + for _, r := range str { + next, _ := charmap.Windows1252.EncodeRune(r) + ret = append(ret, next) + } + return ret +} diff --git a/v3/data/writer.go b/v3/data/writer.go new file mode 100644 index 0000000..26beb7a --- /dev/null +++ b/v3/data/writer.go @@ -0,0 +1,200 @@ +package data + +import ( + "errors" + "strconv" +) + +// EoWriter encapsulates operations related to writing EO data to a sequence of bytes. +type EoWriter struct { + data []byte + + // SanitizeStrings gets or sets the sanitization mode for the writer. + // With sanitization enabled, the writer will switch 0xFF bytes in strings (ÿ) to 0x79 (y) + // See [Chunked Reading: Sanitization] + // + // [Chunked Reading: Sanitization]: https://github.com/Cirras/eo-protocol/blob/master/docs/chunks.md#sanitization + SanitizeStrings bool +} + +// NewEoWriter initializes an empty [data.EoWriter]. This writer has underlying data with length 0 and capacity 16. +func NewEoWriter() *EoWriter { + return &EoWriter{make([]byte, 0, 16), false} +} + +// Write satisifies the io.Writer interface +// +// Write writes len(p) bytes from p to the writer data. +// This implementation unconditionally writes all bytes in the input slice and returns len(p) and a nil error. +func (w *EoWriter) Write(p []byte) (int, error) { + w.AddBytes(p) + return len(p), nil +} + +// AddByte adds a raw byte to the writer data. +func (w *EoWriter) AddByte(value int) error { + if value > 0xFF { + return errors.New("value is larger than maximum raw byte size") + } + + w.data = append(w.data, byte(value)) + + return nil +} + +// AddBytes adds the specified bytes to the writer data. +func (w *EoWriter) AddBytes(bytes []byte) error { + // append for slices is amortized to O(1) and automatically expands capacity of the underlying array as needed + w.data = append(w.data, bytes...) + return nil +} + +// AddChar adds an encoded 1-byte integer to the writer data. +func (w *EoWriter) AddChar(number int) error { + if number > CHAR_MAX-1 { + return errors.New("value is larger than one byte maximum") + } + + bytes := EncodeNumber(number) + w.AddBytes(bytes[:1]) + + return nil +} + +// AddShort adds an encoded 2-byte integer to the writer data. +func (w *EoWriter) AddShort(number int) error { + if number > SHORT_MAX-1 { + return errors.New("value is larger than two byte maximum") + } + + bytes := EncodeNumber(number) + w.AddBytes(bytes[:2]) + + return nil +} + +// AddThree adds an encoded 3-byte integer to the writer data. +func (w *EoWriter) AddThree(number int) error { + if number > THREE_MAX-1 { + return errors.New("value is larger than three byte maximum") + } + + bytes := EncodeNumber(number) + w.AddBytes(bytes[:3]) + + return nil +} + +// AddInt adds an encoded 4-byte integer to the writer data. +func (w *EoWriter) AddInt(number int) error { + if number > INT_MAX-1 { + return errors.New("value is larger than four byte maximum") + } + + bytes := EncodeNumber(number) + w.AddBytes(bytes[:4]) + + return nil +} + +// AddString adds a string to the writer data. +func (w *EoWriter) AddString(str string) error { + return w.AddBytes(w.sanitize(BytesFromString(str))) +} + +// AddFixedString adds a fixed-length string to the writer data. +func (w *EoWriter) AddFixedString(str string, length int) (err error) { + if err = w.checkLength(str, length, false); err == nil { + w.AddBytes(w.sanitize(BytesFromString(str))) + } + return +} + +// AddPaddedString adds a fixed-length string to the writer data add adds trailing padding (0xFF) bytes. +func (w *EoWriter) AddPaddedString(str string, length int) (err error) { + if err = w.checkLength(str, length, true); err == nil { + w.AddBytes(w.addPadding(w.sanitize(BytesFromString(str)), length)) + } + return +} + +// AddEncodedString encodes and adds a string to the writer data. +func (w *EoWriter) AddEncodedString(str string) error { + sanitized := w.sanitize(BytesFromString(str)) + return w.AddBytes(EncodeString(sanitized)) +} + +// AddFixedEncodedString encodes and adds a fixed-length string to the writer data. +func (w *EoWriter) AddFixedEncodedString(str string, length int) (err error) { + if err = w.checkLength(str, length, false); err == nil { + sanitized := w.sanitize(BytesFromString(str)) + w.AddBytes(EncodeString(sanitized)) + } + return +} + +// AddPaddedEncodedString encodes and adds a fixed-length string to the writer data and adds trailing padding (0xFF) bytes. +func (w *EoWriter) AddPaddedEncodedString(str string, length int) (err error) { + if err = w.checkLength(str, length, true); err == nil { + sanitized := w.sanitize(BytesFromString(str)) + padded := w.addPadding(sanitized, length) + w.AddBytes(EncodeString(padded)) + } + return +} + +// Length gets the length of the writer data. +func (w *EoWriter) Length() int { + return len(w.data) +} + +// Array gets the writer data as a byte array. +func (w *EoWriter) Array() []byte { + ret := make([]byte, len(w.data)) + copy(ret, w.data) + return ret +} + +func (w *EoWriter) sanitize(bytes []byte) (output []byte) { + if !w.SanitizeStrings { + return bytes + } + + output = make([]byte, len(bytes)) + copy(output, bytes) + + for i, b := range output { + if b == 0xFF { + output[i] = 0x79 + } + } + + return +} + +func (w *EoWriter) addPadding(bytes []byte, length int) (output []byte) { + output = make([]byte, length) + copy(output, bytes) + + if length == len(bytes) { + return + } + + for i := len(bytes); i < length; i++ { + output[i] = 0xFF + } + + return +} + +func (w *EoWriter) checkLength(str string, length int, padded bool) error { + if padded { + if length < len([]rune(str)) { + return errors.New("padded string " + str + " is too large for length " + strconv.Itoa(length)) + } + } else if length != len([]rune(str)) { + return errors.New("string " + str + " does not have expected length " + strconv.Itoa(length)) + } + + return nil +} diff --git a/v3/data/writer_test.go b/v3/data/writer_test.go new file mode 100644 index 0000000..ad2c6ea --- /dev/null +++ b/v3/data/writer_test.go @@ -0,0 +1,216 @@ +package data_test + +import ( + "testing" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/stretchr/testify/assert" +) + +func TestWriterAddByte(t *testing.T) { + writer := data.NewEoWriter() + writer.AddByte(0x00) + assert.Equal(t, []byte{0x00}, writer.Array()) +} + +func TestWriterAddBytes(t *testing.T) { + writer := data.NewEoWriter() + writer.AddBytes([]byte{0x00, 0xFF}) + assert.Equal(t, []byte{0x00, 0xFF}, writer.Array()) +} + +func TestWriterAddChar(t *testing.T) { + writer := data.NewEoWriter() + writer.AddChar(123) + assert.Equal(t, []byte{0x7C}, writer.Array()) +} + +func TestWriterAddShort(t *testing.T) { + writer := data.NewEoWriter() + writer.AddShort(12345) + assert.Equal(t, []byte{0xCA, 0x31}, writer.Array()) +} + +func TestWriterAddThree(t *testing.T) { + writer := data.NewEoWriter() + writer.AddThree(10_000_000) + assert.Equal(t, []byte{0xB0, 0x3A, 0x9D}, writer.Array()) +} + +func TestWriterAddInt(t *testing.T) { + writer := data.NewEoWriter() + writer.AddInt(2_048_576_040) + assert.Equal(t, []byte{0x7F, 0x7F, 0x7F, 0x7F}, writer.Array()) +} + +func TestWriterAddString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddString("foo") + assert.Equal(t, toBytes("foo"), writer.Array()) +} + +func TestWriterAddFixedString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddFixedString("bar", 3) + assert.Equal(t, toBytes("bar"), writer.Array()) +} + +func TestWriterAddPaddedString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddPaddedString("bar", 6) + assert.Equal(t, toBytes("barÿÿÿ"), writer.Array()) +} + +func TestWriterAddPaddedStringWithPerfectFit(t *testing.T) { + writer := data.NewEoWriter() + writer.AddPaddedString("bar", 3) + assert.Equal(t, toBytes("bar"), writer.Array()) +} + +func TestWriterAddEncodedString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddEncodedString("foo") + assert.Equal(t, toBytes("^0g"), writer.Array()) +} + +func TestWriterAddFixedEncodedString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddFixedEncodedString("bar", 3) + assert.Equal(t, toBytes("[>k"), writer.Array()) +} + +func TestWriterAddPaddedEncodedString(t *testing.T) { + writer := data.NewEoWriter() + writer.AddPaddedEncodedString("bar", 6) + assert.Equal(t, toBytes("ÿÿÿ-l="), writer.Array()) +} + +func TestWriterAddPaddedEncodedStringWithPerfectFit(t *testing.T) { + writer := data.NewEoWriter() + writer.AddPaddedEncodedString("bar", 3) + assert.Equal(t, toBytes("[>k"), writer.Array()) +} + +func TestWriterAddSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddString("aÿz") + assert.Equal(t, toBytes("ayz"), writer.Array()) +} + +func TestWriterAddFixedSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddFixedString("aÿz", 3) + assert.Equal(t, toBytes("ayz"), writer.Array()) +} + +func TestWriterAddPaddedSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddPaddedString("aÿz", 6) + assert.Equal(t, toBytes("ayzÿÿÿ"), writer.Array()) +} + +func TestWriterAddEncodedSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddEncodedString("aÿz") + assert.Equal(t, toBytes("S&l"), writer.Array()) +} + +func TestWriterAddFixedEncodedSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddFixedEncodedString("aÿz", 3) + assert.Equal(t, toBytes("S&l"), writer.Array()) +} + +func TestWriterAddPaddedEncodedSanitizedString(t *testing.T) { + writer := data.NewEoWriter() + writer.SanitizeStrings = true + + writer.AddPaddedEncodedString("aÿz", 6) + assert.Equal(t, toBytes("ÿÿÿ%T>"), writer.Array()) +} + +func TestWriterAddNumbersOnBoundary(t *testing.T) { + writer := data.NewEoWriter() + var err error + + err = writer.AddByte(255) + assert.NoError(t, err) + + err = writer.AddChar(data.CHAR_MAX - 1) + assert.NoError(t, err) + + err = writer.AddShort(data.SHORT_MAX - 1) + assert.NoError(t, err) + + err = writer.AddThree(data.THREE_MAX - 1) + assert.NoError(t, err) + + err = writer.AddInt(data.INT_MAX - 1) + assert.NoError(t, err) +} + +func TestWriterAddNumbersExceedingLimit(t *testing.T) { + writer := data.NewEoWriter() + var err error + + err = writer.AddByte(256) + assert.ErrorContains(t, err, "value is larger than") + + err = writer.AddChar(data.CHAR_MAX) + assert.ErrorContains(t, err, "value is larger than") + + err = writer.AddShort(data.SHORT_MAX) + assert.ErrorContains(t, err, "value is larger than") + + err = writer.AddThree(data.THREE_MAX) + assert.ErrorContains(t, err, "value is larger than") + + err = writer.AddInt(data.INT_MAX) + assert.ErrorContains(t, err, "value is larger than") +} + +func TestWriterAddFixedStringWithIncorrectLength(t *testing.T) { + writer := data.NewEoWriter() + var err error + + err = writer.AddFixedString("foo", 2) + assert.ErrorContains(t, err, "does not have expected length") + + err = writer.AddPaddedString("foo", 2) + assert.ErrorContains(t, err, "too large for length") + + err = writer.AddFixedString("foo", 4) + assert.ErrorContains(t, err, "does not have expected length") + + err = writer.AddFixedEncodedString("foo", 2) + assert.ErrorContains(t, err, "does not have expected length") + + err = writer.AddPaddedEncodedString("foo", 2) + assert.ErrorContains(t, err, "too large for length") + + err = writer.AddFixedEncodedString("foo", 4) + assert.ErrorContains(t, err, "does not have expected length") +} + +func TestWriterLength(t *testing.T) { + writer := data.NewEoWriter() + assert.Equal(t, 0, writer.Length()) + + writer.AddString("Lorem ipsum dolor sit amet") + assert.Equal(t, 26, writer.Length()) + + for i := 27; i <= 100; i++ { + writer.AddByte(0xFF) + } + assert.Equal(t, 100, writer.Length()) +} diff --git a/v3/encrypt/encrypt.go b/v3/encrypt/encrypt.go new file mode 100644 index 0000000..ec5f4a5 --- /dev/null +++ b/v3/encrypt/encrypt.go @@ -0,0 +1,124 @@ +package encrypt + +import "errors" + +// Interleave interleaves a sequence of bytes. When encrypting EO data, bytes are "woven" into each other. +// Used when encrypting packets and data files. +// +// Example: +// +// {0, 1, 2, 3, 4, 5} -> {0, 5, 1, 4, 2, 3} +func Interleave(data []byte) (output []byte) { + output = make([]byte, len(data)) + copy(output, data) + + i, ii := 0, 0 + + for ; i < len(data); i += 2 { + output[i] = data[ii] + ii++ + } + + i-- + + if len(data)%2 != 0 { + i -= 2 + } + + for ; i >= 0; i -= 2 { + output[i] = data[ii] + ii++ + } + + return +} + +// Deinterleave deinterleaves a sequence of bytes. This is the reverse of [encrypt.Interleave]. +// Used when decrypting packets and data files. +// +// Example: +// +// {0, 1, 2, 3, 4, 5} -> {0, 2, 4, 5, 3, 1} +func Deinterleave(data []byte) (output []byte) { + output = make([]byte, len(data)) + copy(output, data) + + i, ii := 0, 0 + + for ; i < len(data); i += 2 { + output[ii] = data[i] + ii++ + } + + i-- + + if len(data)%2 != 0 { + i -= 2 + } + + for ; i >= 0; i -= 2 { + output[ii] = data[i] + ii++ + } + + return +} + +// FlipMsb flips the most significant bits of each byte in a sequence of bytes (excluding values 0 and 128). +// Used when encrypting and decrypting packets. +// +// Example: +// +// {0, 1, 127, 128, 129, 254, 255} -> {0, 129, 255, 128, 1, 126, 127} +func FlipMsb(data []byte) (output []byte) { + output = make([]byte, len(data)) + copy(output, data) + + for i, b := range data { + if b&0x7F != 0 { + output[i] = data[i] ^ 0x80 + } + } + + return +} + +// SwapMultiples swaps the order of contiguous bytes in a sequence of bytes that are divisible by a given multiple value. +// Used when encrypting and decrypting packets and data files. +// +// Example: +// +// multiple = 3 +// {10, 21, 27} -> {10, 27, 21} +func SwapMultiples(data []byte, multiple int) (output []byte, err error) { + if multiple < 0 { + err = errors.New("multiple must be a positive number") + return + } else if multiple == 0 { + output = data + return + } + + output = make([]byte, len(data)) + copy(output, data) + + sequenceLength := 0 + + for i := 0; i <= len(output); i++ { + if i != len(output) && int(output[i])%multiple == 0 { + sequenceLength++ + } else { + if sequenceLength > 1 { + for ii := 0; ii < sequenceLength/2; ii++ { + a := i - sequenceLength + ii + b := i - ii - 1 + output[a], output[b] = output[b], output[a] + } + } + + sequenceLength = 0 + } + } + + return +} diff --git a/v3/encrypt/encrypt_test.go b/v3/encrypt/encrypt_test.go new file mode 100644 index 0000000..abec92a --- /dev/null +++ b/v3/encrypt/encrypt_test.go @@ -0,0 +1,99 @@ +package encrypt_test + +import ( + "fmt" + "testing" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/encrypt" + "github.com/stretchr/testify/assert" +) + +func TestInterleave(t *testing.T) { + allArgs := []struct { + in string + out string + }{ + {"Hello, World!", "H!edlllroo,W "}, + {"We're ¼ of the way there, so ¾ is remaining.", "W.eg'nrien i¼a moefr tshie ¾w aoys t,heer"}, + {"64² = 4096", "6649²0 4= "}, + {"© FÒÖ BÃR BÅZ 2014", "©4 1F0Ò2Ö ZBÅÃBR "}, + {"Öxxö Xööx \"Lëïth Säë\" - \"Ÿ\"", "Ö\"xŸx\"ö -X ö\"öëxä S\" Lhëtï"}, + {"Padded with 0xFFÿÿÿÿÿÿÿÿ", "Pÿaÿdÿdÿeÿdÿ ÿwÿiFtFhx 0"}, + {"This string contains NUL\x00 (value 0) and a € (value 128)", "T)h8i2s1 seturlianvg( c€o nat adinnas )N0U Le\x00u l(av"}, + } + + for _, arg := range allArgs { + t.Run(fmt.Sprintf("%s should interleave to %s", arg.in, arg.out), func(t *testing.T) { + interleaved := encrypt.Interleave(data.BytesFromString(arg.in)) + assert.Equal(t, arg.out, data.StringFromBytes(interleaved)) + }) + } +} + +func TestDeinterleave(t *testing.T) { + allArgs := []struct { + in string + out string + }{ + {"Hello, World!", "Hlo ol!drW,le"}, + {"We're ¼ of the way there, so ¾ is remaining.", "W'e¼o h a hr,s srmiig.nnae i¾o eetywetf re"}, + {"64² = 4096", "6²=4960 4"}, + {"© FÒÖ BÃR BÅZ 2014", "©FÖBRBZ2140 Å Ã Ò "}, + {"Öxxö Xööx \"Lëïth Säë\" - \"Ÿ\"", "Öx öx\"ët ä\"-\"\"Ÿ ëShïL öXöx"}, + {"Padded with 0xFFÿÿÿÿÿÿÿÿ", "Pde ih0FÿÿÿÿÿÿÿÿFx twdda"}, + {"This string contains NUL\x00 (value 0) and a € (value 128)", "Ti tigcnan U\x00(au )ada€(au 2)81elv n 0elv LNsito nrssh"}, + } + + for _, arg := range allArgs { + t.Run(fmt.Sprintf("%s should deinterleave to %s", arg.in, arg.out), func(t *testing.T) { + deinterleaved := encrypt.Deinterleave(data.BytesFromString(arg.in)) + assert.Equal(t, arg.out, data.StringFromBytes(deinterleaved)) + }) + } +} + +func TestFlipMsb(t *testing.T) { + allArgs := []struct { + in string + out string + }{ + {"Hello, World!", "Èåììï¬\u00A0×ïòìä¡"}, + {"We're ¼ of the way there, so ¾ is remaining.", "×å§òå\u00A0<\u00A0ïæ\u00A0ôèå\u00A0÷áù\u00A0ôèåòå¬\u00A0óï\u00A0>\u00A0éó\u00A0òåíáéîéîç®"}, + {"64² = 4096", "¶´2\u00A0½\u00A0´°¹¶"}, + {"© FÒÖ BÃR BÅZ 2014", ")\u00A0ÆRV\u00A0ÂCÒ\u00A0ÂEÚ\u00A0²°±´"}, + {"Öxxö Xööx \"Lëïth Säë\" - \"Ÿ\"", "Vøøv\u00A0Øvvø\u00A0¢Ìkoôè\u00A0Ódk¢\u00A0\u00AD\u00A0¢\u001F¢"}, + {"Padded with 0xFFÿÿÿÿÿÿÿÿ", "Ðáääåä\u00A0÷éôè\u00A0°øÆÆ\u007F\u007F\u007F\u007F\u007F\u007F\u007F\u007F"}, + {"This string contains NUL\x00 (value 0) and a € (value 128)", "Ôèéó\u00A0óôòéîç\u00A0ãïîôáéîó\u00A0ÎÕÌ\x00\u00A0¨öáìõå\u00A0°©\u00A0áîä\u00A0á\u00A0€\u00A0¨öáìõå\u00A0±²¸©"}, + } + + for _, arg := range allArgs { + t.Run(fmt.Sprintf("%s should flip msb to %s", arg.in, arg.out), func(t *testing.T) { + flipped := encrypt.FlipMsb(data.BytesFromString(arg.in)) + assert.Equal(t, arg.out, data.StringFromBytes(flipped)) + }) + } +} + +func TestSwapMultiples(t *testing.T) { + allArgs := []struct { + in string + out string + }{ + {"Hello, World!", "Heoll, lroWd!"}, + {"We're ¼ of the way there, so ¾ is remaining.", "Wer'e ¼ fo the way there, so ¾ is remaining."}, + {"64² = 4096", "64² = 4690"}, + {"© FÒÖ BÃR BÅZ 2014", "© FÒÖ ÃBR BÅZ 2014"}, + {"Öxxö Xööx \"Lëïth Säë\" - \"Ÿ\"", "Ööxx Xxöö \"Lëïth Säë\" - \"Ÿ\""}, + {"Padded with 0xFFÿÿÿÿÿÿÿÿ", "Padded with x0FFÿÿÿÿÿÿÿÿ"}, + {"This string contains NUL\x00 (value 0) and a € (value 128)", "This stirng ocntains NUL\x00 (vaule 0) and a € (vaule 128)"}, + } + + for _, arg := range allArgs { + t.Run(fmt.Sprintf("%s should swap multiples to %s", arg.in, arg.out), func(t *testing.T) { + swapped, err := encrypt.SwapMultiples(data.BytesFromString(arg.in), 3) + assert.NoError(t, err) + assert.Equal(t, arg.out, data.StringFromBytes(swapped)) + }) + } +} diff --git a/v3/encrypt/package.go b/v3/encrypt/package.go new file mode 100644 index 0000000..6040dcc --- /dev/null +++ b/v3/encrypt/package.go @@ -0,0 +1,2 @@ +// Package encrypt provides utilities to handle EO data encryption. +package encrypt diff --git a/v3/encrypt/verification.go b/v3/encrypt/verification.go new file mode 100644 index 0000000..0881a93 --- /dev/null +++ b/v3/encrypt/verification.go @@ -0,0 +1,7 @@ +package encrypt + +// ServerVerificationHash is used for verification that a game server is genuine. +func ServerVerificationHash(challenge int) int { + challenge++ + return 110905 + (challenge%9+1)*((11092004-challenge)%((challenge%11+1)*119))*119 + challenge%2004 +} diff --git a/v3/encrypt/verification_test.go b/v3/encrypt/verification_test.go new file mode 100644 index 0000000..2b434b7 --- /dev/null +++ b/v3/encrypt/verification_test.go @@ -0,0 +1,40 @@ +package encrypt_test + +import ( + "fmt" + "testing" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/encrypt" + "github.com/stretchr/testify/assert" +) + +func TestServerVerificationHash(t *testing.T) { + allArgs := []struct { + in int + out int + }{ + {0, 114000}, + {1, 115191}, + {2, 229432}, + {5, 613210}, + {12345, 266403}, + {100_000, 145554}, + {5_000_000, 339168}, + {11_092_003, 112773}, + {11_092_004, 112655}, + {11_092_005, 112299}, + {11_092_110, 11016}, + {11_092_111, -2787}, + {11_111_111, 103749}, + {12_345_678, -32046}, + {data.THREE_MAX - 1, 105960}, + } + + for _, arg := range allArgs { + t.Run(fmt.Sprintf("%d should hash to %d", arg.in, arg.out), func(t *testing.T) { + actual := encrypt.ServerVerificationHash(arg.in) + assert.Equal(t, arg.out, actual) + }) + } +} diff --git a/v3/eo-protocol b/v3/eo-protocol new file mode 160000 index 0000000..75691b4 --- /dev/null +++ b/v3/eo-protocol @@ -0,0 +1 @@ +Subproject commit 75691b4442fb176651c05c87d39031ba781cee4a diff --git a/v3/generate.go b/v3/generate.go new file mode 100644 index 0000000..612d05d --- /dev/null +++ b/v3/generate.go @@ -0,0 +1,3 @@ +//go:generate $GOPATH/bin/protocol-gen-v3 +//go:generate gofmt -w ./protocol +package v3 diff --git a/v3/internal/codegen/enum.go b/v3/internal/codegen/enum.go new file mode 100644 index 0000000..4c395dc --- /dev/null +++ b/v3/internal/codegen/enum.go @@ -0,0 +1,74 @@ +package codegen + +import ( + "fmt" + "path" + + "github.com/dave/jennifer/jen" + "github.com/ethanmoffat/eolib-go/v3/internal/codegen/types" + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +const enumFileName = "enums_generated.go" + +func GenerateEnums(outputDir string, enums []xml.ProtocolEnum) error { + packageName, err := getPackageName(outputDir) + if err != nil { + return err + } + + f := jen.NewFile(packageName) + + for _, e := range enums { + writeTypeCommentJen(f, e.Name, e.Comment) + + f.Type().Id(e.Name).Int() + + defsList := make([]jen.Code, len(e.Values)) + expected := 0 + for i, v := range e.Values { + var s *jen.Statement + if i == 0 { + s = jen.Id(fmt.Sprintf("%s_%s", types.SanitizeTypeName(e.Name), v.Name)).Qual("", e.Name).Op("=").Iota() + + if v.Value > 0 { + expected = int(v.Value) + s.Op("+").Lit(expected) + } + } else { + s = jen.Id(fmt.Sprintf("%s_%s", types.SanitizeTypeName(e.Name), v.Name)) + actual := int(v.Value) + if expected != actual { + s.Op("=").Lit(actual) + } + } + + writeInlineCommentJen(s, v.Comment) + expected += 1 + + defsList[i] = s + } + f.Const().Defs(defsList...) + + caseList := make([]jen.Code, len(e.Values)+1) + for ndx, v := range e.Values { + caseList[ndx] = jen.Case(jen.Id(fmt.Sprintf("%s_%s", types.SanitizeTypeName(e.Name), v.Name))).Block(jen.Return(jen.Lit(v.Name), jen.Nil())) + } + caseList[len(e.Values)] = jen.Default().Block().Return( + jen.Lit(""), jen.Qual("fmt", "Errorf").Call(jen.Lit(fmt.Sprintf("could not convert value %%d of type %s to string", e.Name)), jen.Id("e")), + ) + + f.Commentf("String converts a %s value into its string representation", e.Name) + f.Func().Params( + // enum receiver + jen.Id("e").Id(e.Name), + ).Id("String").Params( + // empty parameter list + ).Params(jen.String(), jen.Error()).Block( + jen.Switch(jen.Id("e").Block(caseList...)), + ) + } + + outFileName := path.Join(outputDir, enumFileName) + return writeToFileJen(f, outFileName) +} diff --git a/v3/internal/codegen/packet.go b/v3/internal/codegen/packet.go new file mode 100644 index 0000000..cc7d458 --- /dev/null +++ b/v3/internal/codegen/packet.go @@ -0,0 +1,110 @@ +package codegen + +import ( + "fmt" + "path" + + "github.com/dave/jennifer/jen" + "github.com/ethanmoffat/eolib-go/v3/internal/codegen/types" + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +func GeneratePackets(outputDir string, packets []xml.ProtocolPacket, fullSpec xml.Protocol) error { + if len(packets) == 0 { + return nil + } + + packageName, err := getPackageName(outputDir) + if err != nil { + return err + } + + f := jen.NewFile(packageName) + types.AddImports(f) + + // collect type names to generate packet structs + var typeNames []string + f.Var().Id("packetMap").Op("=").Map(jen.Int()).Qual("reflect", "Type").BlockFunc(func(g *jen.Group) { + // Note that this block is using "BlockFunc" + // Official docs advices to use "Values" with "DictFunc". However, default sorting is alphabetical, which + // creates a nasty git diff of the existing generated code + for _, p := range packets { + typeNames = append(typeNames, p.GetTypeName()) + + g.Qual(types.PackagePath("net"), "PacketId").Call( + jen.Qual(types.PackagePath("net"), fmt.Sprintf("PacketFamily_%s", p.Family)), + jen.Qual(types.PackagePath("net"), fmt.Sprintf("PacketAction_%s", p.Action)), + ).Op(":").Qual("reflect", "TypeOf").Call( + jen.Id(snakeCaseToCamelCase(p.GetTypeName())).Values(), + ).Op(",") + } + }) + + f.Comment("PacketFromId creates a typed packet instance from a [net.PacketFamily] and [net.PacketAction].") + f.Comment("This function calls [PacketFromIntegerId] internally.") + + f.Func().Id("PacketFromId").Params( + jen.Id("family").Qual(types.PackagePath("net"), "PacketFamily"), + jen.Id("action").Qual(types.PackagePath("net"), "PacketAction"), + ).Params( + jen.Qual(types.PackagePath("net"), "Packet"), + jen.Error(), + ).Block( + jen.Return(jen.Id("PacketFromIntegerId").Call( + jen.Qual(types.PackagePath("net"), "PacketId").Call(jen.Id("family"), jen.Id("action")), + )), + ) + + f.Comment(`// PacketFromIntegerId creates a typed packet instance from a packet's ID. An ID may be converted from a family/action pair via the [net.PacketId] function. +// The returned packet implements the [net.Packet] interface. It may be serialized/deserialized without further conversion, or a type assertion may be made to examine the data. The expected type of the assertion is a pointer to a packet structure. +// The following example does both: an incoming CHAIR_REQUEST packet is deserialized from a reader without converting from the interface type, and the data is examined via a type assertion. +// +// pkt, _ := client.PacketFromId(net.PacketFamily_Chair, net.PacketAction_Request) +// if err = pkt.Deserialize(reader); err != nil { +// // handle the error +// } +// switch v := pkt.(type) { +// case *client.ChairRequestClientPacket: +// fmt.Println("SitAction=", v.SitAction) +// switch d := v.SitActionData.(type) { +// case *client.ChairRequestSitActionDataSit: +// fmt.Println("Data.Coords=", v.Data.Coords) +// } +// default: +// fmt.Printf("Unknown type: %s\n", reflect.TypeOf(pkt).Elem().Name()) +// }`) + + f.Func().Id("PacketFromIntegerId").Params( + jen.Id("id").Int(), // func declaration: int parameter 'id' + ).Params( + jen.Qual(types.PackagePath("net"), "Packet"), // func declaration: return types (net.Packet, error) + jen.Error(), + ).Block( + // try to get the packet type out of the map (indexed by the id) + jen.List(jen.Id("packetType"), jen.Id("idOk")).Op(":=").Id("packetMap").Index(jen.Id("id")), + // check that id is ok, return error otherwise + jen.If(jen.Op("!").Id("idOk")).Block( + jen.Return(jen.List(jen.Nil(), jen.Qual("fmt", "Errorf").Call(jen.Lit("could not find packet with id %d"), jen.Id("id")))), + ).Line(), + // type assert that creating the packet type results in an interface that satisfies net.Packet + jen.List(jen.Id("packetInstance"), jen.Id("typeOk").Op(":=").Qual("reflect", "New").Call( + jen.Id("packetType"), + ).Dot("Interface").Call().Assert( + jen.Qual(types.PackagePath("net"), "Packet"), + )), + // check that type is ok, return error otherwise + jen.If(jen.Op("!").Id("typeOk")).Block( + jen.Return(jen.List(jen.Nil(), jen.Qual("fmt", "Errorf").Call(jen.Lit("could not create packet from id %d"), jen.Id("id")))), + ).Line(), + // return packetInstance, nil + jen.Return(jen.Id("packetInstance"), jen.Nil()), + ) + + const packetMapFileName = "packetmap_generated.go" + if err := writeToFileJen(f, path.Join(outputDir, packetMapFileName)); err != nil { + return err + } + + const packetFileName = "packets_generated.go" + return generateStructsShared(outputDir, packetFileName, typeNames, fullSpec) +} diff --git a/v3/internal/codegen/shared.go b/v3/internal/codegen/shared.go new file mode 100644 index 0000000..329acdd --- /dev/null +++ b/v3/internal/codegen/shared.go @@ -0,0 +1,124 @@ +package codegen + +import ( + "fmt" + "io" + "os" + "path" + "strings" + "unicode" + + "github.com/dave/jennifer/jen" +) + +func getPackageStatement(outputDir string) (string, error) { + packageFileName := path.Join(outputDir, "package.go") + fp, err := os.Open(packageFileName) + if err != nil { + return "", err + } + defer fp.Close() + + packageInfo, err := io.ReadAll(fp) + if err != nil { + return "", err + } + + packageInfoLines := strings.Split(string(packageInfo), "\n") + for _, s := range packageInfoLines { + if strings.HasPrefix(s, "package ") { + return s, nil + } + } + + return "", fmt.Errorf("package name not found in %s", outputDir) +} + +func getPackageName(outputDir string) (packageDeclaration string, err error) { + if packageDeclaration, err = getPackageStatement(outputDir); err != nil { + return + } + + split := strings.Split(packageDeclaration, " ") + if len(split) < 2 { + packageDeclaration = "" + err = fmt.Errorf("unable to determine package name from package declaration") + return + } + + packageDeclaration = split[1] + return +} + +func sanitizeComment(comment string) string { + split := strings.Split(comment, "\n") + + for i := range split { + split[i] = strings.TrimSpace(split[i]) + + if len(split[i]) > 0 && !strings.HasSuffix(split[i], ".") { + split[i] += "." + } + } + + return strings.Join(split, " ") +} + +func writeTypeCommentJen(f *jen.File, typeName string, comment string) { + if comment = sanitizeComment(comment); len(comment) > 0 { + f.Commentf("// %s :: %s", typeName, comment) + } +} + +func writeInlineCommentJen(c jen.Code, comment string) { + if comment = sanitizeComment(comment); len(comment) > 0 { + switch v := c.(type) { + case *jen.Statement: + v.Comment(comment) + case *jen.Group: + v.Comment(comment) + } + } +} + +func writeToFileJen(f *jen.File, outFileName string) error { + return f.Save(outFileName) +} + +func snakeCaseToCamelCase(input string) string { + if len(input) == 0 { + return input + } + + out := strings.Clone(input) + for ndx := range out { + if ndx < len(out) && out[ndx] == '_' { + tmp := out[:ndx] + + if ndx+1 < len(out) { + if ndx != 0 { + tmp = tmp + string(unicode.ToUpper(rune(out[ndx+1]))) + } else { + tmp = tmp + string(unicode.ToLower(rune(out[ndx+1]))) + } + } + + if ndx+2 < len(out) { + tmp = tmp + out[ndx+2:] + } + + out = tmp + } + } + return out +} + +func snakeCaseToPascalCase(input string) string { + if len(input) == 0 { + return input + } + + camelCase := snakeCaseToCamelCase(input) + firstRune := []rune(camelCase)[0] + return string(unicode.ToUpper(firstRune)) + camelCase[1:] +} diff --git a/v3/internal/codegen/shared_test.go b/v3/internal/codegen/shared_test.go new file mode 100644 index 0000000..f71f02d --- /dev/null +++ b/v3/internal/codegen/shared_test.go @@ -0,0 +1,79 @@ +package codegen + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestSnakeCaseToCamelCase(t *testing.T) { + const input = "snake_case_name" + const expected = "snakeCaseName" + + actual := snakeCaseToCamelCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToCamelCaseLeadingUnderscore(t *testing.T) { + const input = "_snake_case_name" + const expected = "snakeCaseName" + + actual := snakeCaseToCamelCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToCamelCaseTrailingUnderscore(t *testing.T) { + const input = "snake_case_name_" + const expected = "snakeCaseName" + + actual := snakeCaseToCamelCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToCamelCaseTrailingUnderscoreSingleChar(t *testing.T) { + const input = "snake_case_name_t" + const expected = "snakeCaseNameT" + + actual := snakeCaseToCamelCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToPascalCase(t *testing.T) { + const input = "snake_case_name" + const expected = "SnakeCaseName" + + actual := snakeCaseToPascalCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToPascalCaseLeadingUnderscore(t *testing.T) { + const input = "_snake_case_name" + const expected = "SnakeCaseName" + + actual := snakeCaseToPascalCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToPascalCaseTrailingUnderscore(t *testing.T) { + const input = "snake_case_name_" + const expected = "SnakeCaseName" + + actual := snakeCaseToPascalCase(input) + + assert.Equal(t, expected, actual) +} + +func TestSnakeCaseToPascalCaseTrailingUnderscoreSingleChar(t *testing.T) { + const input = "snake_case_name_t" + const expected = "SnakeCaseNameT" + + actual := snakeCaseToPascalCase(input) + + assert.Equal(t, expected, actual) +} diff --git a/v3/internal/codegen/struct.go b/v3/internal/codegen/struct.go new file mode 100644 index 0000000..54d971e --- /dev/null +++ b/v3/internal/codegen/struct.go @@ -0,0 +1,1014 @@ +package codegen + +import ( + "fmt" + "math" + "path" + "strconv" + "unicode" + + "github.com/dave/jennifer/jen" + "github.com/ethanmoffat/eolib-go/v3/internal/codegen/types" + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +func GenerateStructs(outputDir string, structs []xml.ProtocolStruct, fullSpec xml.Protocol) error { + const structFileName = "structs_generated.go" + + var typeNames []string + for _, s := range structs { + typeNames = append(typeNames, s.Name) + } + return generateStructsShared(outputDir, structFileName, typeNames, fullSpec) +} + +func generateStructsShared(outputDir string, outputFileName string, typeNames []string, fullSpec xml.Protocol) error { + packageName, err := getPackageName(outputDir) + if err != nil { + return err + } + + f := jen.NewFile(packageName) + types.AddImports(f) + + if len(typeNames) > 0 { + for _, typeName := range typeNames { + if err := writeStruct(f, typeName, fullSpec); err != nil { + return err + } + } + } + + outFileName := path.Join(outputDir, outputFileName) + return writeToFileJen(f, outFileName) +} + +func writeStruct(f *jen.File, typeName string, fullSpec xml.Protocol) (err error) { + var si *types.StructInfo + if si, err = types.GetStructInfo(typeName, fullSpec); err != nil { + return err + } + + err = writeStructShared(f, si, fullSpec) + return +} + +func writeStructShared(f *jen.File, si *types.StructInfo, fullSpec xml.Protocol) (err error) { + structName := snakeCaseToPascalCase(si.Name) + writeTypeCommentJen(f, structName, si.Comment) + + // write out fields + var switches []*xml.ProtocolInstruction + f.Type().Id(structName).StructFunc(func(g *jen.Group) { + g.Id("byteSize").Int().Line() + switches, err = writeStructFields(g, si, fullSpec) + }).Line() + + if err != nil { + return + } + + for _, sw := range switches { + if err = writeSwitchStructs(f, *sw, si, fullSpec); err != nil { + return + } + } + + if len(si.Family) > 0 && len(si.Action) > 0 { + // write out family/action methods + f.Func().Params(jen.Id("s").Id(structName)).Id("Family").Params().Qual(types.PackagePath("net"), "PacketFamily").Block( + jen.Return(jen.Qual(types.PackagePath("net"), fmt.Sprintf("PacketFamily_%s", si.Family))), + ).Line() + f.Func().Params(jen.Id("s").Id(structName)).Id("Action").Params().Qual(types.PackagePath("net"), "PacketAction").Block( + jen.Return(jen.Qual(types.PackagePath("net"), fmt.Sprintf("PacketAction_%s", si.Action))), + ).Line() + } + + // write out ByteSize getter + f.Comment("ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data.") + f.Func().Params(jen.Id("s").Op("*").Id(structName)).Id("ByteSize").Params().Int().BlockFunc(func(g *jen.Group) { + g.Return(jen.Id("s").Dot("byteSize")) + }).Line() + + // write out serialize method + f.Func().Params(jen.Id("s").Op("*").Id(structName)).Id("Serialize").Params(jen.Id("writer").Op("*").Qual(types.PackagePath("data"), "EoWriter")).Params(jen.Id("err").Id("error")).BlockFunc(func(g *jen.Group) { + g.Id("oldSanitizeStrings").Op(":=").Id("writer").Dot("SanitizeStrings") + // defer here uses 'Values' instead of 'Block' so the deferred function is single-line style + g.Defer().Func().Params().Values(jen.Id("writer").Dot("SanitizeStrings").Op("=").Id("oldSanitizeStrings")).Call().Line() + + err = writeSerializeBody(g, si, fullSpec, nil) + + g.Return() + }).Line() + + if err != nil { + return + } + + // write out deserialize method + f.Func().Params(jen.Id("s").Op("*").Id(structName)).Id("Deserialize").Params(jen.Id("reader").Op("*").Qual(types.PackagePath("data"), "EoReader")).Params(jen.Id("err").Id("error")).BlockFunc(func(g *jen.Group) { + g.Id("oldIsChunked").Op(":=").Id("reader").Dot("IsChunked").Call() + // defer here uses 'Values' instead of 'Block' so the deferred function is single-line style + g.Defer().Func().Params().Values(jen.Id("reader").Dot("SetIsChunked").Call(jen.Id("oldIsChunked"))).Call().Line() + + g.Id("readerStartPosition").Op(":=").Id("reader").Dot("Position").Call() + err = writeDeserializeBody(g, si, fullSpec, nil) + g.Id("s").Dot("byteSize").Op("=").Id("reader").Dot("Position").Call().Op("-").Id("readerStartPosition") + + g.Line().Return() + }).Line() + + return +} + +func writeStructFields(g *jen.Group, si *types.StructInfo, fullSpec xml.Protocol) (switches []*xml.ProtocolInstruction, err error) { + isEmpty := true + + for i, inst := range si.Instructions { + var instName string + + if inst.Name != nil { + instName = snakeCaseToPascalCase(*inst.Name) + } else if inst.Field != nil { + instName = snakeCaseToPascalCase(*inst.Field) + } + + var fieldTypeInfo struct { + typeName string + nextImport *types.ImportInfo + isPointer bool + } + if inst.Type != nil { + fieldTypeInfo.typeName, fieldTypeInfo.nextImport = types.ProtocolSpecTypeToGoType(*inst.Type, si.PackageName, fullSpec) + if inst.Optional != nil && *inst.Optional { + switch inst.XMLName.Local { + // these are the only supported values where the type of the rendered field needs to be modified to a pointer + // arrays also support the "optional" attribute in the spec but default to nil since they are rendered as slices + case "field": + fallthrough + case "length": + fieldTypeInfo.isPointer = true + } + } + } + + qualifiedTypeName := func(s *jen.Statement) { + if fieldTypeInfo.isPointer { + s.Op("*") + } + + writeComment := func(ss *jen.Statement) { + if inst.Comment != nil { + writeInlineCommentJen(ss, *inst.Comment) + } + } + + if fieldTypeInfo.nextImport != nil && fieldTypeInfo.nextImport.Package != si.PackageName { + s.Qual(fieldTypeInfo.nextImport.Path, fieldTypeInfo.typeName).Do(writeComment) + } else { + s.Id(fieldTypeInfo.typeName).Do(writeComment) + } + } + + switch inst.XMLName.Local { + case "field": + if len(instName) > 0 { + g.Id(instName).Do(qualifiedTypeName) + } else { + g.Line() + } + isEmpty = false + case "array": + g.Id(instName).Index().Do(qualifiedTypeName) + isEmpty = false + case "length": + // lengths do not write a separate property + // length is implicitly determined for serialization by using the built-in len() function + // length is stored in a local variable for deserialization + continue + case "switch": + g.Id(fmt.Sprintf("%sData", instName)).Id(fmt.Sprintf("%s%sData", si.SwitchStructQualifier, instName)) + switches = append(switches, &si.Instructions[i]) + isEmpty = false + case "chunked": + nestedStructInfo, _ := si.Nested(&inst) + + var nextSwitches []*xml.ProtocolInstruction + if nextSwitches, err = writeStructFields(g, nestedStructInfo, fullSpec); err != nil { + switches = nil + return + } + + switches = append(switches, nextSwitches...) + case "dummy": + continue + case "break": + if !inst.IsChunked { + switches = nil + err = fmt.Errorf("break bytes must be within a chunked section") + return + } + + continue // no data to write + } + } + + if isEmpty { + g.Line() + } + + return +} + +func writeSwitchStructs(f *jen.File, switchInst xml.ProtocolInstruction, si *types.StructInfo, fullSpec xml.Protocol) (err error) { + if switchInst.XMLName.Local != "switch" { + return + } + + switchInterfaceName := fmt.Sprintf("%sData", snakeCaseToPascalCase(*switchInst.Field)) + if len(si.SwitchStructQualifier) > 0 { + switchInterfaceName = si.SwitchStructQualifier + switchInterfaceName + } + + if switchInst.Comment != nil { + writeTypeCommentJen(f, switchInterfaceName, *switchInst.Comment) + } + f.Type().Id(switchInterfaceName).Interface(jen.Qual(types.PackagePath("protocol"), "EoData")).Line() + + for _, c := range switchInst.Cases { + if len(c.Instructions) == 0 { + continue + } + + var caseName string + if c.Default { + caseName = "Default" + } else { + caseName = snakeCaseToPascalCase(c.Value) + } + caseStructName := fmt.Sprintf("%s%s", switchInterfaceName, caseName) + + nestedStructInfo := &types.StructInfo{ + Name: caseStructName, + Comment: c.Comment, + Instructions: c.Instructions, + PackageName: si.PackageName, + SwitchStructQualifier: si.SwitchStructQualifier, + } + err = writeStructShared(f, nestedStructInfo, fullSpec) + if err != nil { + return + } + } + + return +} + +func writeSerializeBody(g *jen.Group, si *types.StructInfo, fullSpec xml.Protocol, outerInstructionList []xml.ProtocolInstruction) (err error) { + for _, instruction := range si.Instructions { + instructionType := instruction.XMLName.Local + instructionName := getInstructionName(instruction) + + switch instructionType { + case "chunked": + g.Id("writer").Dot("SanitizeStrings").Op("=").True() + + var nestedInfo *types.StructInfo + if nestedInfo, err = si.Nested(&instruction); err != nil { + return + } + + if err = writeSerializeBody(g, nestedInfo, fullSpec, si.Instructions); err != nil { + return + } + + g.Id("writer").Dot("SanitizeStrings").Op("=").False() + case "break": + g.Id("writer").Dot("AddByte").Call(jen.Lit(0xFF)) + case "switch": + // get type of Value field + switchFieldSanitizedType := "" + switchFieldEnumType := "" + for _, tmpInst := range append(outerInstructionList, si.Instructions...) { + if tmpInst.XMLName.Local == "field" && snakeCaseToPascalCase(*tmpInst.Name) == instructionName { + switchFieldEnumType = *tmpInst.Type + switchFieldSanitizedType = types.SanitizeTypeName(switchFieldEnumType) + break + } + } + + var switchBlock []jen.Code + for _, c := range instruction.Cases { + if len(c.Instructions) == 0 { + continue + } + + var switchDataType string + if c.Default { + switchDataType = fmt.Sprintf("%sDataDefault", instructionName) + switchBlock = append(switchBlock, jen.Default()) + } else { + switchDataType = fmt.Sprintf("%sData%s", instructionName, c.Value) + if value, err := strconv.ParseInt(c.Value, 10, 32); err != nil { + // case is for an enum value + if enumTypeInfo, ok := fullSpec.IsEnum(switchFieldEnumType); !ok { + return fmt.Errorf("type %s in switch is not an enum", switchFieldEnumType) + } else { + packageQualifier := "" + if enumTypeInfo.Package != si.PackageName { + packageQualifier = enumTypeInfo.Package + } + switchBlock = append( + switchBlock, + jen.CaseFunc(func(g *jen.Group) { + if packageQualifier != "" { + g.Qual(types.PackagePath(packageQualifier), fmt.Sprintf("%s_%s", switchFieldSanitizedType, c.Value)) + } else { + g.Id(fmt.Sprintf("%s_%s", switchFieldSanitizedType, c.Value)) + } + }), + ) + } + } else { + // case is for an integer constant + switchBlock = append(switchBlock, jen.Case(jen.Lit(int(value)))) + } + } + + // Serialize call for the case structure + caseSerialize := jen.If( + jen.Id("err").Op("=").Id("s").Dot(fmt.Sprintf("%sData", instructionName)).Dot("Serialize").Call(jen.Id("writer")), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()) + + if len(switchDataType) > 0 { + // The object to serialize needs a type assertion + // Wrap it in a type assert switch that returns an error if it does not match + switchBlock = append( + switchBlock, + jen.Switch( + jen.Id("s").Dot( + fmt.Sprintf("%sData", instructionName), + ).Assert(jen.Id("type")).Block( + jen.Case( + jen.Op("*").Id(fmt.Sprintf("%s%s", si.SwitchStructQualifier, switchDataType)), + ).Block(caseSerialize), + jen.Default().Block( + jen.Id("err").Op("=").Qual("fmt", "Errorf").Call( + jen.Lit("invalid switch struct type for switch value %d"), + jen.Id("s").Dot(instructionName), + ).Line().Return(), + ), + ), + ), + ) + } else { + // The object to serialize does not need a type assertion + switchBlock = append(switchBlock, caseSerialize) + } + } + + g.Switch(jen.Id("s").Dot(instructionName)).Block(switchBlock...) + default: + typeName, typeSize := types.GetInstructionTypeName(instruction) + + isContent := false + if len(instructionName) == 0 && instruction.Content != nil { + isContent = true + instructionName = *instruction.Content + } + g.Commentf("// %s : %s : %s", instructionName, instructionType, *instruction.Type) + + stringType := types.String + + var serializeCodes []jen.Code + switch typeName { + case "byte": + fallthrough + case "char": + fallthrough + case "short": + fallthrough + case "three": + fallthrough + case "int": + fallthrough + case "blob": + serializeCodes, err = getSerializeForInstruction(instruction, types.NewEoType(typeName), false) + case "bool": + if len(typeSize) > 0 { + typeName = string(unicode.ToUpper(rune(typeSize[0]))) + typeSize[1:] + } else { + typeName = "Char" + } + serializeCodes = []jen.Code{ + jen.If(jen.Id("s").Dot(instructionName)).Block( + jen.Id("err").Op("=").Id("writer").Dot(fmt.Sprintf("Add%s", typeName)).Call(jen.Lit(1)), + ).Else().Block( + jen.Id("err").Op("=").Id("writer").Dot(fmt.Sprintf("Add%s", typeName)).Call(jen.Lit(0)), + ).Line(), + jen.If(jen.Id("err").Op("!=").Nil()).Block(jen.Return()).Line(), + } + case "encoded_string": + stringType = types.EncodedString + fallthrough + case "string": + if instruction.Length != nil && instructionType == "field" { + isPadded := instruction.Padded != nil && *instruction.Padded + if isPadded { + serializeCodes, err = getSerializeForInstruction(instruction, stringType+types.Padded, false) + } else { + serializeCodes, err = getSerializeForInstruction(instruction, stringType+types.Fixed, false) + } + + if err == nil { + if parsed, isConst := isConstantLengthExpression(*instruction.Length); isConst && !isContent { + lengthAssertCodes := getLengthAssertCodes(instructionName, parsed, isPadded) + serializeCodes = append(lengthAssertCodes, serializeCodes...) + } + } + } else { + serializeCodes, err = getSerializeForInstruction(instruction, stringType, false) + } + default: + if _, ok := fullSpec.IsStruct(typeName); ok { + serializeCodes = []jen.Code{ + jen.If( + jen.Id("err").Op("=").Id("s").Dot(instructionName).Do(func(s *jen.Statement) { + if instructionType == "array" { + s.Index(jen.Id("ndx")) + } + }).Dot("Serialize").Call(jen.Id("writer")), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()), + } + } else if e, ok := fullSpec.IsEnum(typeName); ok { + if t := types.NewEoType(e.Type); t&types.Primitive > 0 { + serializeCodes, err = getSerializeForInstruction(instruction, t, true) + } + } else { + err = fmt.Errorf("unable to find type '%s' when writing serialization function (member: %s, type: %s)", typeName, instructionName, instructionType) + return + } + } + + if err != nil { + return + } + + if instructionType == "array" { + delimited := instruction.Delimited != nil && *instruction.Delimited + trailingDelimiter := instruction.TrailingDelimiter == nil || *instruction.TrailingDelimiter + + if delimited { + addByteCode := jen.Id("writer").Dot("AddByte").Call(jen.Lit(0xFF)) + if !trailingDelimiter { + delimiterCode := jen.If( + jen.Id("ndx").Op(">").Lit(0).Block(addByteCode).Line(), + ) + serializeCodes = append([]jen.Code{delimiterCode}, serializeCodes...) + } else { + serializeCodes = append(serializeCodes, addByteCode) + } + } + + var lenExpr *jen.Statement + if instruction.Length != nil { + if parsed, isConst := isConstantLengthExpression(*instruction.Length); isConst { + lenExpr = jen.Lit(parsed) + + lengthAssertCodes := getLengthAssertCodes(instructionName, parsed, false) + serializeCodes = append(lengthAssertCodes, serializeCodes...) + } else { + // implicit length: use the built-in length function for array length + lenExpr = jen.Len(jen.Id("s").Dot(instructionName)) + } + } else { + lenExpr = jen.Len(jen.Id("s").Dot(instructionName)) + } + + g.For( + jen.Id("ndx").Op(":=").Lit(0), + jen.Id("ndx").Op("<").Add(lenExpr), + jen.Id("ndx").Op("++"), + ).Block(serializeCodes...).Line() + } else { + g.Add(serializeCodes...) + } + } + } + + return +} + +func writeDeserializeBody(g *jen.Group, si *types.StructInfo, fullSpec xml.Protocol, outerInstructionList []xml.ProtocolInstruction) (err error) { + for _, instruction := range si.Instructions { + instructionType := instruction.XMLName.Local + instructionName := getInstructionName(instruction) + + switch instructionType { + case "chunked": + g.Id("reader").Dot("SetIsChunked").Call(jen.True()) + + var nestedInfo *types.StructInfo + if nestedInfo, err = si.Nested(&instruction); err != nil { + return + } + + if err = writeDeserializeBody(g, nestedInfo, fullSpec, si.Instructions); err != nil { + return + } + + g.Id("reader").Dot("SetIsChunked").Call(jen.False()) + case "break": + if instruction.IsChunked { + g.If( + jen.Id("err").Op("=").Id("reader").Dot("NextChunk").Call(), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()) + } else { + g.If( + jen.Id("breakByte").Op(":=").Id("reader").Dot("GetByte").Call(), + jen.Id("breakByte").Op("!=").Lit(0xFF), + ).Block( + jen.Return(jen.Qual("fmt", "Errorf").Call(jen.Lit("missing expected break byte"))), + ) + } + case "switch": + // get type of Value field + switchFieldSanitizedType := "" + switchFieldEnumType := "" + for _, tmpInst := range append(outerInstructionList, si.Instructions...) { + if tmpInst.XMLName.Local == "field" && snakeCaseToPascalCase(*tmpInst.Name) == instructionName { + switchFieldEnumType = *tmpInst.Type + switchFieldSanitizedType = types.SanitizeTypeName(switchFieldEnumType) + break + } + } + + var switchBlock []jen.Code + for _, c := range instruction.Cases { + if len(c.Instructions) == 0 { + continue + } + + var switchDataType string + if c.Default { + switchDataType = fmt.Sprintf("%sDataDefault", instructionName) + switchBlock = append(switchBlock, jen.Default()) + } else { + switchDataType = fmt.Sprintf("%sData%s", instructionName, c.Value) + if value, err := strconv.ParseInt(c.Value, 10, 32); err != nil { + // case is for an enum value + if enumTypeInfo, ok := fullSpec.IsEnum(switchFieldEnumType); !ok { + return fmt.Errorf("type %s in switch is not an enum", switchFieldEnumType) + } else { + packageQualifier := "" + if enumTypeInfo.Package != si.PackageName { + packageQualifier = enumTypeInfo.Package + } + switchBlock = append(switchBlock, jen.CaseFunc(func(g *jen.Group) { + if packageQualifier != "" { + g.Qual(types.PackagePath(packageQualifier), fmt.Sprintf("%s_%s", switchFieldSanitizedType, c.Value)) + } else { + g.Id(fmt.Sprintf("%s_%s", switchFieldSanitizedType, c.Value)) + } + })) + } + } else { + // case is for an integer constant + switchBlock = append(switchBlock, jen.Case(jen.Lit(int(value)))) + } + } + + // Deserialize call for the case structure + sDotData := jen.Id("s").Dot(fmt.Sprintf("%sData", instructionName)) + caseDeserialize := sDotData.Clone().Op("=").Op("&").Id(si.SwitchStructQualifier + switchDataType).Block().Line() + caseDeserialize = caseDeserialize.If( + jen.Id("err").Op("=").Add(sDotData).Dot("Deserialize").Call(jen.Id("reader")), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()) + + switchBlock = append(switchBlock, caseDeserialize) + } + + g.Switch(jen.Id("s").Dot(instructionName)).Block(switchBlock...) + default: + typeName, typeSize := types.GetInstructionTypeName(instruction) + + if len(instructionName) == 0 && instruction.Content != nil { + instructionName = *instruction.Content + } + g.Commentf("// %s : %s : %s", instructionName, instructionType, *instruction.Type) + + stringType := types.String + + var deserializeCodes []jen.Code + switch typeName { + case "byte": + deserializeCodes, err = getDeserializeForInstruction(instruction, types.NewEoType(typeName), jen.Id("int")) + case "char": + fallthrough + case "short": + fallthrough + case "three": + fallthrough + case "int": + fallthrough + case "blob": + deserializeCodes, err = getDeserializeForInstruction(instruction, types.NewEoType(typeName), nil) + case "bool": + if len(typeSize) > 0 { + typeName = string(unicode.ToUpper(rune(typeSize[0]))) + typeSize[1:] + } else { + typeName = "Char" + } + + deserializeCodes = []jen.Code{ + jen.If( + jen.Id("boolVal").Op(":=").Id("reader").Dot("Get"+typeName).Call(), + jen.Id("boolVal").Op(">").Lit(0), + ).Block( + jen.Id("s").Dot(instructionName).Op("=").True(), + ).Else().Block( + jen.Id("s").Dot(instructionName).Op("=").False(), + ), + } + case "encoded_string": + stringType = types.EncodedString + fallthrough + case "string": + if instruction.Length != nil && instructionType == "field" { + if instruction.Padded != nil && *instruction.Padded { + deserializeCodes, err = getDeserializeForInstruction(instruction, stringType+types.Padded, nil) + } else { + deserializeCodes, err = getDeserializeForInstruction(instruction, stringType+types.Fixed, nil) + } + } else { + deserializeCodes, err = getDeserializeForInstruction(instruction, stringType, nil) + } + default: + if s, ok := fullSpec.IsStruct(typeName); ok { + arrayCode := jen.Null() + if instructionType == "array" { + _, tp := types.ProtocolSpecTypeToGoType(s.Name, si.PackageName, fullSpec) + arrayCode = jen.Id("s").Dot(instructionName).Op("=").Append( + jen.Id("s").Dot(instructionName), + jen.Do(func(s *jen.Statement) { + if tp != nil { + s.Qual(tp.Path, typeName) + } else { + s.Id(typeName) + } + }).Block(), + ) + } + + deserializeCodes = []jen.Code{ + arrayCode, + jen.If( + jen.Id("err").Op("=").Id("s").Dot(instructionName).Do(func(s *jen.Statement) { + if instructionType == "array" { + s.Index(jen.Id("ndx")) + } + }).Dot("Deserialize").Call(jen.Id("reader")), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()), + } + } else if e, ok := fullSpec.IsEnum(typeName); ok { + if eoType := types.NewEoType(e.Type); eoType&types.Primitive > 0 { + _, tp := types.ProtocolSpecTypeToGoType(e.Name, si.PackageName, fullSpec) + deserializeCodes, err = getDeserializeForInstruction( + instruction, + eoType, + jen.Do(func(s *jen.Statement) { + if tp != nil { + s.Qual(tp.Path, e.Name) + } else { + s.Id(e.Name) + } + }), + ) + } else { + err = fmt.Errorf("expected primitive base type for enum %s when writing deserialize function", e.Name) + } + } else { + panic("Unable to find type '" + typeName + "' when writing serialization function") + } + } + + if err != nil { + return + } + + if instructionType == "array" { + delimited := instruction.Delimited != nil && *instruction.Delimited + + var varAssignExpr *jen.Statement + var lenExpr *jen.Statement + if instruction.Length != nil { + lenExpr = jen.Id("ndx").Op("<").Add(getLengthExpression(*instruction.Length)) + } else if !delimited && instruction.IsChunked { + if rawLen, err := types.CalculateTypeSize(typeName, fullSpec); err != nil || rawLen == 1 { + lenExpr = jen.Id("reader").Dot("Remaining").Call().Op(">").Lit(0) + } else { + varAssignExpr = jen.Id(instructionName + "Remaining").Op(":=").Id("reader").Dot("Remaining").Call() + lenExpr = jen.Id("ndx").Op("<").Id(instructionName + "Remaining").Op("/").Lit(rawLen) + } + } else { + lenExpr = jen.Id("reader").Dot("Remaining").Call().Op(">").Lit(0) + } + + trailingDelimiter := instruction.TrailingDelimiter == nil || *instruction.TrailingDelimiter + + if delimited && instruction.IsChunked { + delimiterExpr := jen.If( + jen.Id("err").Op("=").Id("reader").Dot("NextChunk").Call(), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()) + + if !trailingDelimiter { + if instruction.Length == nil { + err = fmt.Errorf("delimited arrays with trailing-delimiter=false must have a length (array %s)", instructionName) + return + } + + delimiterExpr = jen.If( + jen.Id("ndx").Op("+").Lit(1).Op("<").Add(getLengthExpression(*instruction.Length))).Block(delimiterExpr) + } + + deserializeCodes = append(deserializeCodes, delimiterExpr) + } + + if varAssignExpr != nil { + g.Add(varAssignExpr) + } + + g.For( + jen.Id("ndx").Op(":=").Lit(0), + lenExpr, + jen.Id("ndx").Op("++"), + ).Block(deserializeCodes...).Line() + } else { + g.Add(deserializeCodes...) + } + } + } + + return +} + +func getInstructionName(inst xml.ProtocolInstruction) (instName string) { + if inst.Name != nil { + instName = snakeCaseToPascalCase(*inst.Name) + } else if inst.Field != nil { + instName = snakeCaseToPascalCase(*inst.Field) + } + return +} + +func getSerializeForInstruction(instruction xml.ProtocolInstruction, methodType types.EoType, needsCastToInt bool) ([]jen.Code, error) { + instructionName := getInstructionName(instruction) + + // the method type is a string if it has the eotype_str or eotype_str_encoded flag + isString := (methodType&types.String) > 0 || (methodType&types.EncodedString) > 0 + + var instructionCode, nilCheckCode *jen.Statement + if len(instructionName) == 0 && instruction.Content != nil { + if isString { + instructionCode = jen.Lit(*instruction.Content) + } else { + instructionCode = jen.Id(*instruction.Content) + } + } else { + if instruction.XMLName.Local == "length" { + if instruction.ReferencedBy != nil { + // implicit length: this is a length instruction; serialize the length of the actual collection referencing it + instructionCode = jen.Len(jen.Id("s").Dot(snakeCaseToPascalCase(*instruction.ReferencedBy))) + } else { + return nil, fmt.Errorf("length instruction is not referenced by any other instruction") + } + } else { + instructionCode = jen.Id("s").Dot(instructionName) + } + } + + isArray := false + optional := instruction.Optional != nil && *instruction.Optional + if instruction.XMLName.Local == "array" { + instructionCode = instructionCode.Index(jen.Id("ndx")) + + // optional arrays that are unset will be nil. + // The length expression in the loop checks the length of the nil slice, which evaluates to 0. + // This means that arrays do not need additional dereferencing when optional. + optional = false + isArray = true + } + + if optional { + nilCheckCode = instructionCode.Clone() + instructionCode = jen.Op("*").Add(instructionCode) + } + + if needsCastToInt { + instructionCode = jen.Int().Call(instructionCode) + } + + if instruction.Offset != nil { + var op string + if *instruction.Offset < 0 { + op = "+" + } else { + op = "-" + } + instructionCode = instructionCode.Op(op).Lit(int(math.Abs(float64(*instruction.Offset)))) + } + + serializeCode := jen.If( + jen.Id("err").Op("=").Id("writer").Dot("Add"+methodType.String()).Call( + instructionCode, + jen.Do(func(s *jen.Statement) { + // strings may have a fixed length that needs to be serialized + if !isArray && isString && instruction.Length != nil { + if parsed, isConst := isConstantLengthExpression(*instruction.Length); isConst { + s.Add(jen.Lit(parsed)) + } else { + // implicit length: use the built-in length function for string length + s.Add(jen.Len(jen.Id("s").Dot(instructionName))) + } + } + }), + ), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()) + + return []jen.Code{ + jen.Do(func(s *jen.Statement) { + if optional { + s.If(nilCheckCode.Op("!=").Nil()).Block(serializeCode) + } else { + s.Add(serializeCode) + } + }), + }, nil +} + +func getDeserializeForInstruction(instruction xml.ProtocolInstruction, methodType types.EoType, castType *jen.Statement) ([]jen.Code, error) { + instructionName := getInstructionName(instruction) + + // the method type is a string if it has the eotype_str or eotype_str_encoded flag + isString := (methodType&types.String) > 0 || (methodType&types.EncodedString) > 0 + + isArray := false + optional := instruction.Optional != nil && *instruction.Optional + + lengthExpr := jen.Null() + if instruction.XMLName.Local != "array" { + if instruction.Length != nil { + lengthExpr = getLengthExpression(*instruction.Length) + } else if methodType == types.Bytes { + lengthExpr = jen.Id("reader").Dot("Remaining").Call() + } + } else { + // optional arrays that are unset will be nil. + // The length expression in the loop checks the length of the nil slice, which evaluates to 0. + // This means that arrays do not need additional dereferencing when optional. + optional = false + isArray = true + } + + readerGetCode := jen.Id("reader").Dot("Get" + methodType.String()).Call(lengthExpr) + if instruction.Offset != nil { + var op string + if *instruction.Offset < 0 { + op = "-" + } else { + op = "+" + } + readerGetCode = readerGetCode.Op(op).Lit(int(math.Abs(float64(*instruction.Offset)))) + } + + var retCodes []jen.Code + var assignRHS, assignLHS *jen.Statement + hasAssignTarget := false + if len(instructionName) == 0 && instruction.Content != nil { + if isString { + assignRHS = jen.Op("=").Add(readerGetCode) + assignLHS = jen.Id("_") + } else { + assignRHS = jen.Add(readerGetCode) + assignLHS = jen.Null() + } + } else { + hasAssignTarget = true + assignOp := "=" + + indexCode := jen.Null() + if isArray { + // pre-append an item to the array in the struct field + var defaultCode *jen.Statement + if isString { + defaultCode = jen.Lit("") + } else { + defaultCode = jen.Lit(0) + } + + retCodes = append(retCodes, jen.Id("s").Dot(instructionName).Op("=").Append(jen.Id("s").Dot(instructionName), defaultCode)) + indexCode = jen.Index(jen.Id("ndx")) + } + + if optional { + // instantiate the optional struct field + retCodes = append(retCodes, jen.Id("s").Dot(instructionName).Op("=").New(jen.Do(func(s *jen.Statement) { + if castType != nil { + s.Add(castType) + } else if isString { + s.String() + } else { + s.Int() + } + }))) + + assignLHS = jen.Op("*").Id("s").Dot(instructionName).Add(indexCode) + } else { + if instruction.XMLName.Local == "length" { + if instruction.ReferencedBy != nil { + // implicit length: this is a length instruction; deserialize the length to a local variable + assignLHS = getLengthExpression(*instruction.Name) + assignOp = ":=" + } else { + return nil, fmt.Errorf("length instruction is not referenced by any other instruction") + } + } else { + assignLHS = jen.Id("s").Dot(instructionName).Add(indexCode) + } + } + + assignRHS = jen.Op(assignOp).Do(func(s *jen.Statement) { + if castType != nil { + s.Add(castType).Call(readerGetCode) + } else { + s.Add(readerGetCode) + } + }) + } + + var assignBlock *jen.Statement + if isString { + assignBlock = jen.If( + jen.List(assignLHS, jen.Id("err")).Add(assignRHS), + jen.Id("err").Op("!=").Nil(), + ).Block(jen.Return()).Do(func(s *jen.Statement) { + if hasAssignTarget { + // For compatibility: prior codegen inserted an extra newline after fixed strings that referenced a length field + s.Line() + } + }) + } else { + assignBlock = assignLHS.Add(assignRHS) + } + + if optional { + retCodes = append(retCodes, assignBlock) + retCodes = []jen.Code{jen.If(jen.Id("reader").Dot("Remaining").Call().Op(">").Lit(0)).Block(retCodes...)} + } else { + retCodes = append(retCodes, assignBlock) + } + + return retCodes, nil +} + +func getLengthAssertCodes(instructionName string, parsed int, isPadded bool) []jen.Code { + var op string + if isPadded { + op = ">" + } else { + op = "!=" + } + + return []jen.Code{ + jen.If(jen.Len(jen.Id("s").Dot(instructionName)).Op(op).Lit(parsed)).BlockFunc(func(g *jen.Group) { + errMsg := fmt.Sprintf("expected %s with length %d, got %%d", instructionName, parsed) + g.Id("err").Op("=").Qual("fmt", "Errorf").Call( + jen.Lit(errMsg), + jen.Len(jen.Id("s").Dot(instructionName)), + ) + g.Return() + }).Line(), + } +} + +func isConstantLengthExpression(instLength string) (int, bool) { + parsed, err := strconv.ParseInt(instLength, 10, 32) + return int(parsed), err == nil +} + +func getLengthExpression(instLength string) *jen.Statement { + if parsed, isConst := isConstantLengthExpression(instLength); isConst { + // string length is a numeric constant + return jen.Lit(parsed) + } else { + // string length is a reference to another field + return jen.Id(snakeCaseToCamelCase(instLength)) + } +} diff --git a/v3/internal/codegen/types/aliases.go b/v3/internal/codegen/types/aliases.go new file mode 100644 index 0000000..3b68c71 --- /dev/null +++ b/v3/internal/codegen/types/aliases.go @@ -0,0 +1,25 @@ +package types + +import "github.com/dave/jennifer/jen" + +// packageAliases is a map of package short names to package paths. For use with Jennifer. +var packageAliases = map[string]string{ + "data": "github.com/ethanmoffat/eolib-go/v3/data", + "net": "github.com/ethanmoffat/eolib-go/v3/protocol/net", + "protocol": "github.com/ethanmoffat/eolib-go/v3/protocol", + "pub": "github.com/ethanmoffat/eolib-go/v3/protocol/pub", +} + +func PackagePath(packageName string) string { + if v, ok := packageAliases[packageName]; ok { + return v + } + + return packageName +} + +func AddImports(f *jen.File) { + for k, v := range packageAliases { + f.ImportName(v, k) + } +} diff --git a/v3/internal/codegen/types/eotype.go b/v3/internal/codegen/types/eotype.go new file mode 100644 index 0000000..58101ea --- /dev/null +++ b/v3/internal/codegen/types/eotype.go @@ -0,0 +1,93 @@ +package types + +type EoType int + +const ( + Invalid EoType = 0 +) + +const ( + Primitive EoType = iota + 0x0100 // flag indicating type is a primitive (supported for bool) + Byte + Char + Short + Three + Int + Bool +) + +const ( + Complex EoType = iota + 0x0200 // flag indicating type is complex (not supported for bool) + Bytes +) + +const ( + String EoType = iota + 0x0400 // flag indicating type is a string type + PaddedString + FixedString +) + +const ( + EncodedString EoType = iota + 0x0800 // flag indicating type is an encoded string type + PaddedEncodedString + FixedEncodedString +) + +// offsets from String or EncodedString to the other string method types +const ( + _ EoType = iota + Padded + Fixed +) + +func (t EoType) String() string { + switch t { + case Byte: + return "Byte" + case Char: + return "Char" + case Short: + return "Short" + case Three: + return "Three" + case Int: + return "Int" + case Bool: + return "Byte" + case Bytes: + return "Bytes" + case String: + return "String" + case PaddedString: + return "PaddedString" + case FixedString: + return "FixedString" + case EncodedString: + return "EncodedString" + case PaddedEncodedString: + return "PaddedEncodedString" + case FixedEncodedString: + return "FixedEncodedString" + } + + return "" +} + +func NewEoType(str string) EoType { + switch str { + case "byte": + return Byte + case "char": + return Char + case "short": + return Short + case "three": + return Three + case "int": + return Int + case "blob": + return Bytes + } + + return Invalid +} diff --git a/v3/internal/codegen/types/structinfo.go b/v3/internal/codegen/types/structinfo.go new file mode 100644 index 0000000..ea77a4d --- /dev/null +++ b/v3/internal/codegen/types/structinfo.go @@ -0,0 +1,62 @@ +package types + +import ( + "errors" + "fmt" + + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +// StructInfo is a type representing the metadata about a struct that should be rendered as generated code. +// It represents the common properties of either a ProtocolPacket or a ProtocolStruct. +type StructInfo struct { + Name string // Name is the name of the type. It is not converted from protocol naming convention (snake_case). + Comment string // Comment is an optional type comment for the struct. + Instructions []xml.ProtocolInstruction // Instructions is a collection of instructions for the struct. + PackageName string // PackageName is the containing package name for the struct. + + Family string // Family is the Packet Family of the struct, if the struct is a packet struct. + Action string // Action is the Packet Action of the struct, if the struct is a packet struct. + SwitchStructQualifier string // SwitchStructQualifier is an additional qualifier prepended to structs used in switch cases in packets. +} + +// GetStructInfo generates a [StructInfo] for the specified typeName. typeName can be a structure +// or a packet in the full XML spec. +func GetStructInfo(typeName string, fullSpec xml.Protocol) (si *StructInfo, err error) { + si = &StructInfo{SwitchStructQualifier: ""} + err = nil + + if structInfo, ok := fullSpec.IsStruct(typeName); ok { + si.Name = structInfo.Name + si.Comment = structInfo.Comment + si.Instructions = structInfo.Instructions + si.PackageName = structInfo.Package + } else if packetInfo, ok := fullSpec.IsPacket(typeName); ok { + si.Name = packetInfo.GetTypeName() + si.Comment = packetInfo.Comment + si.Instructions = packetInfo.Instructions + si.PackageName = packetInfo.Package + si.SwitchStructQualifier = packetInfo.Family + packetInfo.Action + si.Family = packetInfo.Family + si.Action = packetInfo.Action + } else { + si = nil + err = fmt.Errorf("type %s is not a struct or packet in the spec", typeName) + } + + return +} + +// Nested creates a nested [StructInfo] from the specified 'chunked' [xml.ProtocolInstruction]. +// This function returns an error if the instruction is not of the 'chunked' type. +func (si *StructInfo) Nested(chunked *xml.ProtocolInstruction) (*StructInfo, error) { + if chunked.XMLName.Local != "chunked" { + return nil, errors.New("expected 'chunked' instruction creating nested StructInfo") + } + + return &StructInfo{ + Instructions: chunked.Chunked, + PackageName: si.PackageName, + SwitchStructQualifier: si.SwitchStructQualifier, + }, nil +} diff --git a/v3/internal/codegen/types/typeconv.go b/v3/internal/codegen/types/typeconv.go new file mode 100644 index 0000000..06e30fe --- /dev/null +++ b/v3/internal/codegen/types/typeconv.go @@ -0,0 +1,56 @@ +package types + +import ( + "strings" + + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +type ImportInfo struct { + Package string + Path string +} + +func ProtocolSpecTypeToGoType(eoType string, currentPackage string, fullSpec xml.Protocol) (goType string, nextImport *ImportInfo) { + if strings.ContainsRune(eoType, rune(':')) { + eoType = strings.Split(eoType, ":")[0] + } + + switch eoType { + case "byte": + fallthrough + case "char": + fallthrough + case "short": + fallthrough + case "three": + fallthrough + case "int": + return "int", nil + case "bool": + return "bool", nil + case "blob": + return "[]byte", nil + case "string": + fallthrough + case "encoded_string": + return "string", nil + default: + match := fullSpec.FindType(eoType) + goType = eoType + + if structMatch, ok := match.(*xml.ProtocolStruct); ok && structMatch.Package != currentPackage { + nextImport = &ImportInfo{structMatch.Package, structMatch.PackagePath} + } else if enumMatch, ok := match.(*xml.ProtocolEnum); ok && enumMatch.Package != currentPackage { + nextImport = &ImportInfo{enumMatch.Package, enumMatch.PackagePath} + } + + if nextImport != nil { + if val, ok := packageAliases[nextImport.Package]; ok { + nextImport.Path = val + } + } + + return + } +} diff --git a/v3/internal/codegen/types/typesize.go b/v3/internal/codegen/types/typesize.go new file mode 100644 index 0000000..ed095da --- /dev/null +++ b/v3/internal/codegen/types/typesize.go @@ -0,0 +1,111 @@ +package types + +import ( + "fmt" + "strconv" + "strings" + + "github.com/ethanmoffat/eolib-go/v3/internal/xml" +) + +// SanitizeTypeName sanitizes the type name for serialization. Effectively, this removes the 'Type' +// suffix if present. +func SanitizeTypeName(typeName string) string { + if strings.HasSuffix(typeName, "Type") { + return typeName[:len(typeName)-4] + } + return typeName +} + +// GetInstructionTypeName gets the type name (and byte size, if present) of an instruction. +func GetInstructionTypeName(inst xml.ProtocolInstruction) (typeName string, typeSize string) { + if inst.Type == nil { + return + } + + if strings.ContainsRune(*inst.Type, rune(':')) { + split := strings.Split(*inst.Type, ":") + typeName, typeSize = split[0], split[1] + } else { + typeName = *inst.Type + } + + return +} + +// CalculateTypeSize gets the size of the named type by recursively evaluating and summing the size +// of the named type's members +func CalculateTypeSize(typeName string, fullSpec xml.Protocol) (res int, err error) { + structInfo, isStruct := fullSpec.IsStruct(typeName) + if !isStruct { + return getPrimitiveTypeSize(typeName, fullSpec) + } + + flattenedInstList := xml.Flatten((*structInfo).Instructions) + for _, instruction := range flattenedInstList { + switch instruction.XMLName.Local { + case "array": + fallthrough + case "field": + fieldTypeName, fieldTypeSize := GetInstructionTypeName(*instruction) + if fieldTypeSize != "" { + fieldTypeName = fieldTypeSize + } + + if instruction.Length != nil { + if length, err := strconv.ParseInt(*instruction.Length, 10, 32); err == nil { + // length is a numeric constant + if fieldSize, err := CalculateTypeSize(fieldTypeName, fullSpec); err == nil { + res += fieldSize * int(length) + } else { + return 0, err + } + } else { + return 0, fmt.Errorf("instruction length %s must be a fixed size for %s (%s)", *instruction.Length, *instruction.Name, instruction.XMLName.Local) + } + } else { + if nestedSize, err := getPrimitiveTypeSize(fieldTypeName, fullSpec); err != nil { + return 0, err + } else { + res += nestedSize + } + } + case "break": + res += 1 + } + } + + return +} + +func getPrimitiveTypeSize(fieldTypeName string, fullSpec xml.Protocol) (int, error) { + switch fieldTypeName { + case "byte": + fallthrough + case "char": + return 1, nil + case "short": + return 2, nil + case "three": + return 3, nil + case "int": + return 4, nil + case "bool": + return 1, nil + case "blob": + fallthrough + case "string": + fallthrough + case "encoded_string": + return 0, fmt.Errorf("cannot get size of %s without fixed length", fieldTypeName) + default: + if _, isStruct := fullSpec.IsStruct(fieldTypeName); isStruct { + return CalculateTypeSize(fieldTypeName, fullSpec) + } else if e, isEnum := fullSpec.IsEnum(fieldTypeName); isEnum { + enumTypeName := SanitizeTypeName(e.Type) + return getPrimitiveTypeSize(enumTypeName, fullSpec) + } else { + return 0, fmt.Errorf("cannot get fixed size of unrecognized type %s", fieldTypeName) + } + } +} diff --git a/v3/internal/xml/models.go b/v3/internal/xml/models.go new file mode 100644 index 0000000..6fb951f --- /dev/null +++ b/v3/internal/xml/models.go @@ -0,0 +1,333 @@ +package xml + +import ( + "encoding/xml" + "fmt" + "reflect" + "strconv" + "strings" + "unicode" + + "github.com/ethanmoffat/eolib-go/v3/utils" +) + +type Protocol struct { + Enums []ProtocolEnum `xml:"enum"` + Structs []ProtocolStruct `xml:"struct"` + Packets []ProtocolPacket `xml:"packet"` +} + +type ProtocolEnum struct { + Name string `xml:"name,attr"` + Type string `xml:"type,attr"` + Values []ProtocolValue `xml:"value"` + Comment string `xml:"comment"` + + Package string + PackagePath string +} + +type ProtocolStruct struct { + Name string `xml:"name,attr"` + Instructions []ProtocolInstruction `xml:",any"` + Comment string `xml:"comment"` + + Package string + PackagePath string +} + +type ProtocolPacket struct { + Family string `xml:"family,attr"` + Action string `xml:"action,attr"` + Instructions []ProtocolInstruction `xml:",any"` + Comment string `xml:"comment"` + + Package string + PackagePath string +} + +type ProtocolValue struct { + Name string `xml:"name,attr"` + Comment string `xml:"comment"` + Value OrdinalValue `xml:",chardata"` +} + +type ProtocolInstruction struct { + // XMLName is the XML element name of this instruction. + XMLName xml.Name + // IsChunked is True if this instruction appears within a "chunked" section + IsChunked bool + // ReferencedBy is the name of the instruction that references this instruction. This is only set for length instructions which are referenced by another instruction. + ReferencedBy *string + + // ProtocolField properties + Name *string `xml:"name,attr"` + Type *string `xml:"type,attr"` + Length *string `xml:"length,attr"` + Padded *bool `xml:"padded,attr"` + Optional *bool `xml:"optional,attr"` + Comment *string `xml:"comment"` + Content *string `xml:",chardata"` + + // ProtocolArray properties + // shared: Name, Type, Length, Optional, Comment + Delimited *bool `xml:"delimited,attr"` + TrailingDelimiter *bool `xml:"trailing-delimiter,attr"` + + // ProtocolLength properties + // shared: Name, Type, Optional, Comment + Offset *int `xml:"offset,attr"` + + // ProtocolDummy properties + // shared: Type, Comment, Content shared + + // ProtocolSwitch properties + Field *string `xml:"field,attr"` + Cases []ProtocolCase `xml:"case"` + + // ProtocolChunked properties + Chunked []ProtocolInstruction `xml:",any"` + + // ProtocolBreak properties (none) +} + +type ProtocolCase struct { + IsChunked bool + + Value string `xml:"value,attr"` + Default bool `xml:"default,attr"` + Comment string `xml:"comment"` + Instructions []ProtocolInstruction `xml:",any"` +} + +type OrdinalValue int + +func Flatten(instructions []ProtocolInstruction) []*ProtocolInstruction { + var flattenedInstList []*ProtocolInstruction + for ndx, instruction := range instructions { + if instruction.XMLName.Local == "chunked" { + flattenedInstList = append(flattenedInstList, Flatten(instruction.Chunked)...) + } else { + // note: when flattening, switches are *not* flattened as they may have cases with instructions with name collisions + // see: CharacterReplyServerPacket + flattenedInstList = append(flattenedInstList, &instructions[ndx]) + } + } + return flattenedInstList +} + +func getLengthInstructions(instructions []ProtocolInstruction) (lengthInstructions []*ProtocolInstruction) { + flattened := Flatten(instructions) + for i, inst := range flattened { + if inst.XMLName.Local == "length" { + lengthInstructions = append(lengthInstructions, flattened[i]) + } + } + return +} + +func findLengthInstructionByName(lengthName string, lengthInstructions []*ProtocolInstruction) *ProtocolInstruction { + for i, inst := range lengthInstructions { + if inst.Name != nil && *inst.Name == lengthName { + return lengthInstructions[i] + } + } + return nil +} + +func validate(instructions []ProtocolInstruction, isChunked bool, lengthInstructions []*ProtocolInstruction) error { + localLengths := append(lengthInstructions, getLengthInstructions(instructions)...) + + for i, inst := range instructions { + if isChunked { + instructions[i].IsChunked = true + } + + if inst.Length != nil { + if lengthInstruction := findLengthInstructionByName(*inst.Length, localLengths); lengthInstruction != nil { + lengthInstruction.ReferencedBy = new(string) + *lengthInstruction.ReferencedBy = *inst.Name + } + } + + if err := inst.Validate(); err != nil { + return err + } + + if err := validate(inst.Chunked, true, localLengths); err != nil { + return err + } + + if len(inst.Cases) > 0 { + for _, cs := range inst.Cases { + if err := validate(cs.Instructions, isChunked, localLengths); err != nil { + return err + } + } + } + } + + return nil +} + +func (p Protocol) Validate() error { + for _, st := range p.Structs { + if err := validate(st.Instructions, false, nil); err != nil { + return err + } + } + + for _, pkt := range p.Packets { + if err := validate(pkt.Instructions, false, nil); err != nil { + return err + } + } + + return nil +} + +func (p Protocol) FindType(typeName string) (ps interface{}) { + if e, ok := p.IsEnum(typeName); ok { + return e + } + + if s, ok := p.IsStruct(typeName); ok { + return s + } + + return nil +} + +func (p Protocol) IsEnum(typeName string) (*ProtocolEnum, bool) { + for i, e := range p.Enums { + if e.Name == typeName { + return &p.Enums[i], true + } + } + + return nil, false +} + +func (p Protocol) IsStruct(typeName string) (*ProtocolStruct, bool) { + for i, st := range p.Structs { + if st.Name == typeName { + return &p.Structs[i], true + } + } + + return nil, false +} + +func (p Protocol) IsPacket(typeName string) (*ProtocolPacket, bool) { + for i, pkt := range p.Packets { + if pkt.GetTypeName() == typeName { + return &p.Packets[i], true + } + } + + return nil, false +} + +func (p ProtocolPacket) GetTypeName() string { + packageName := string(unicode.ToUpper([]rune(p.Package)[0])) + p.Package[1:] + return fmt.Sprintf("%s%s%sPacket", p.Family, p.Action, packageName) +} + +func (pi ProtocolInstruction) Validate() error { + all, required, err := pi.expectedFields() + + if err != nil { + return err + } + + if len(all) == 0 { + return nil + } + + reflectValue := reflect.ValueOf(pi) + reflectType := reflectValue.Type() + + strEq := func(a string, b string) bool { return a == b } + for i := 0; i < reflectValue.NumField(); i++ { + fieldName := reflectType.Field(i) + fieldValue := reflectValue.Field(i) + + if fieldName.Name == "XMLName" || fieldName.Name == "IsChunked" || fieldName.Name == "ReferencedBy" { + continue + } + + if utils.FindIndex(all, fieldName.Name, strEq) == -1 { + fieldIsNil := fieldValue.IsNil() + + fieldIsEmpty := true + if !fieldIsNil { + switch fieldValue.Kind() { + case reflect.Pointer: + switch fieldValue.Elem().Kind() { + case reflect.String: + fieldIsEmpty = len(strings.TrimSpace(fieldValue.Elem().String())) == 0 + default: + fieldIsEmpty = fieldValue.Elem().IsZero() + } + default: + fieldIsEmpty = fieldValue.IsZero() + } + } + + if !fieldIsNil && !fieldIsEmpty { + return fmt.Errorf("validation error: instruction of type %s had unexpected field %s with value '%v'", pi.XMLName.Local, fieldName.Name, fieldValue.Elem()) + } + } + + if utils.FindIndex(required, fieldName.Name, strEq) >= 0 && fieldValue.IsNil() { + return fmt.Errorf("valdiation error: instruction of type %s missing required field %s", pi.XMLName.Local, fieldName.Name) + } + } + + return nil +} + +func (pi ProtocolInstruction) expectedFields() (all []string, required []string, err error) { + switch pi.XMLName.Local { + case "field": + all = []string{"Name", "Type", "Length", "Padded", "Optional", "Comment", "Content"} + required = []string{"Type"} + case "array": + all = []string{"Name", "Type", "Length", "Optional", "Comment", "Delimited", "TrailingDelimiter"} + required = []string{"Name", "Type"} + case "length": + all = []string{"Name", "Type", "Optional", "Comment", "Offset"} + required = []string{"Name", "Type"} + case "dummy": + all = []string{"Type", "Comment", "Content"} + required = []string{"Type"} + case "switch": + all = []string{"Field", "Cases"} + required = all + case "chunked": + all = []string{"Chunked"} + case "break": + break + default: + err = fmt.Errorf("validation error: invalid xml name '%s'", pi.XMLName.Local) + } + + return +} + +func (o *OrdinalValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var err error + var s string + if err = d.DecodeElement(&s, &start); err != nil { + return err + } + + var val int64 + if val, err = strconv.ParseInt(s, 10, 32); err != nil { + return err + } + + *o = OrdinalValue(val) + + return nil +} diff --git a/v3/package.go b/v3/package.go new file mode 100644 index 0000000..974f25d --- /dev/null +++ b/v3/package.go @@ -0,0 +1,11 @@ +// v3 is api version 3 of the core library for writing Endless Online applications using the Go programming language. +// +// This package contains top-level functions that are shared between subpackages. +// +// More details are available in the package subdirectories: +// - [pkg/github.com/ethanmoffat/eolib-go/v3/data] :: provides utilities to read and write EO data types. +// - [pkg/github.com/ethanmoffat/eolib-go/v3/encrypt] :: provides utilities to handle EO data encryption. +// - [pkg/github.com/ethanmoffat/eolib-go/v3/packet] :: provides utilities for EO packets. +// - [pkg/github.com/ethanmoffat/eolib-go/v3/protocol] :: provides EO protocol data structures. +// - [pkg/github.com/ethanmoffat/eolib-go/v3/utils] :: provides general utilities +package v3 diff --git a/v3/packet/package.go b/v3/packet/package.go new file mode 100644 index 0000000..17adafb --- /dev/null +++ b/v3/packet/package.go @@ -0,0 +1,2 @@ +// Package packet provides utilities for EO packets. +package packet diff --git a/v3/packet/sequencer.go b/v3/packet/sequencer.go new file mode 100644 index 0000000..10e221e --- /dev/null +++ b/v3/packet/sequencer.go @@ -0,0 +1,28 @@ +package packet + +// PacketSequencer generates packet sequences based on the specified [packet.SequenceGetter] +type PacketSequencer struct { + sequenceGetter SequenceGetter + counter int +} + +// NewPacketSequencer creates a new packet sequencer with the specified [SequenceGetter] and a counter of 0. +func NewPacketSequencer(getter SequenceGetter) PacketSequencer { + return PacketSequencer{getter, 0} +} + +// NextSequence returns the next sequence value, updating the sequence counter in the process +// +// Note: this is not a monotonic operation. The sequence counter increases from 0 to 9 before looping back around to 0. +func (p *PacketSequencer) NextSequence() int { + result := p.sequenceGetter.Value() + p.counter + p.counter = (p.counter + 1) % 10 + return result +} + +// SetSequenceStart sets the sequence start, also known as the "starting counter ID". +// +// Note: this does not reset the sequence counter. +func (p *PacketSequencer) SetSequenceStart(start SequenceGetter) { + p.sequenceGetter = start +} diff --git a/v3/packet/sequencer_test.go b/v3/packet/sequencer_test.go new file mode 100644 index 0000000..a5cac19 --- /dev/null +++ b/v3/packet/sequencer_test.go @@ -0,0 +1,34 @@ +package packet_test + +import ( + "testing" + + "github.com/ethanmoffat/eolib-go/v3/packet" + "github.com/stretchr/testify/assert" +) + +func TestNextSequence(t *testing.T) { + start := packet.NewAccountReplySequence(123) + sequencer := packet.NewPacketSequencer(start) + + // counter should increase 9 times and then wrap around + for i := 0; i < 10; i++ { + assert.Equal(t, sequencer.NextSequence(), 123+i) + } + + // counter should have wrapped around + assert.Equal(t, sequencer.NextSequence(), 123) +} + +func TestSequenceStart(t *testing.T) { + start := packet.NewAccountReplySequence(100) + sequencer := packet.NewPacketSequencer(start) + + assert.Equal(t, 100, sequencer.NextSequence()) + + start = packet.NewAccountReplySequence(200) + sequencer.SetSequenceStart(start) + + // when the sequence start is updated, the counter should not reset + assert.Equal(t, 201, sequencer.NextSequence()) +} diff --git a/v3/packet/sequences.go b/v3/packet/sequences.go new file mode 100644 index 0000000..fe731a5 --- /dev/null +++ b/v3/packet/sequences.go @@ -0,0 +1,139 @@ +package packet + +import ( + "math/rand" + + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/utils" +) + +// SequenceGetter represents a value sent by the server to update the client's sequence start, also known as the "starting counter ID". +type SequenceGetter interface { + // Value gets the sequence value. + Value() int +} + +// ZeroSequence represents an implementation of [packet.SequenceGetter] with a value set to '0'. +type ZeroSequence struct { +} + +// InitSequence represents the sequence start value sent with the INIT_INIT server packet. +type InitSequence struct { + value int + seq1 int + seq2 int +} + +// PingSequence represents the sequence start value sent with the CONNECTION_PLAYER server packet. +type PingSequence struct { + value int + seq1 int + seq2 int +} + +// AccountReplySequence represents the sequence start value sent with the ACCOUNT_REPLY server packet. +type AccountReplySequence struct { + value int +} + +// NewZeroSequence creates a new ZeroSequence instance +func NewZeroSequence() *ZeroSequence { + return &ZeroSequence{} +} + +// NewInitSequence creates an instance of [packet.InitSequence] from the values sent with the INIT_INIT server packet. +func NewInitSequence(seq1 int, seq2 int) *InitSequence { + return &InitSequence{ + value: seq1*7 + seq2 - 13, + seq1: seq1, + seq2: seq2, + } +} + +// GenerateInitSequence generates an instance of [packet.InitSequence] with a random value in the range 0-1757. +func GenerateInitSequence(rand *rand.Rand) *InitSequence { + value := rand.Intn(1757) + seq1Max := (value + 13) / 7 + seq1Min := utils.Max(0, (value-(data.CHAR_MAX-1)+13+6)/7) + + seq1 := rand.Intn(seq1Max-seq1Min) + seq1Min + seq2 := value - seq1*7 + 13 + return &InitSequence{ + value: value, + seq1: seq1, + seq2: seq2, + } +} + +// NewPingSequence creates an instance of [packet.PingSequence] from the values sent with the CONNECTION_PLAYER server packet. +func NewPingSequence(seq1 int, seq2 int) *PingSequence { + return &PingSequence{ + value: seq1 - seq2, + seq1: seq1, + seq2: seq2, + } +} + +// GeneratePingSequence generates an instance of [packet.PingSequence] with a random value in the range 0-1757. +func GeneratePingSequence(rand *rand.Rand) *PingSequence { + value := rand.Intn(1757) + seq1 := value + rand.Intn(data.CHAR_MAX-1) + seq2 := seq1 - value + + return &PingSequence{ + value: value, + seq1: seq1, + seq2: seq2, + } +} + +// NewAccountReplySequence creates an instance of [packet.AccountReplySequence] from the value sent with the ACCOUNT_REPLY server packet. +func NewAccountReplySequence(value int) *AccountReplySequence { + return &AccountReplySequence{value} +} + +// GenerateAccountReplySequence generates an instance of [packet.AccountReplySequence] with a random value in th range 0-240. +func GenerateAccountReplySequence(rand *rand.Rand) *AccountReplySequence { + start := rand.Intn(240) + return &AccountReplySequence{start} +} + +// Value gets the start value of the [packet.ZeroSequence]. This value is always zero. +func (ZeroSequence) Value() int { + return 0 +} + +// Value gets the start value of the [packet.InitSequence]. +func (s InitSequence) Value() int { + return s.value +} + +// Seq1 gets the Seq1 byte sent with the INIT_INIT server packet. +func (s InitSequence) Seq1() int { + return s.seq1 +} + +// Seq2 gets the Seq2 byte sent with the INIT_INIT server packet. +func (s InitSequence) Seq2() int { + return s.seq2 +} + +// Value gets the start value of the [packet.PingSequence]. +func (s PingSequence) Value() int { + return s.value +} + +// Seq1 gets the Seq1 byte sent with the CONNECTION_PLAYER server packet. +func (s PingSequence) Seq1() int { + return s.seq1 +} + +// Seq2 gets the Seq2 byte sent with the CONNECTION_PLAYER server packet. +func (s PingSequence) Seq2() int { + return s.seq2 +} + +// Value gets the start value of the [packet.AccountReplySequence]. +func (a AccountReplySequence) Value() int { + return a.value +} diff --git a/v3/packet/sequences_test.go b/v3/packet/sequences_test.go new file mode 100644 index 0000000..5fc0e70 --- /dev/null +++ b/v3/packet/sequences_test.go @@ -0,0 +1,70 @@ +package packet_test + +import ( + "math/rand" + "testing" + + "github.com/ethanmoffat/eolib-go/v3/packet" + "github.com/stretchr/testify/assert" +) + +func TestZeroSequence(t *testing.T) { + start := packet.NewZeroSequence() + assert.Equal(t, 0, start.Value()) +} + +func TestInitSequenceFromValue(t *testing.T) { + start := packet.NewInitSequence(148, 185) + + assert.Equal(t, 1208, start.Value()) + assert.Equal(t, 148, start.Seq1()) + assert.Equal(t, 185, start.Seq2()) +} + +func TestInitSequenceGenerate(t *testing.T) { + const seed = 123 + random := rand.New(rand.NewSource(seed)) + + start := packet.GenerateInitSequence(random) + + // note: the expected values differ from eolib-java due to a different pseudo-random implementation + assert.Equal(t, 1208, start.Value()) + assert.Equal(t, 163, start.Seq1()) + assert.Equal(t, 80, start.Seq2()) +} + +func TestPingSequenceFromValue(t *testing.T) { + start := packet.NewPingSequence(1253, 45) + + assert.Equal(t, 1208, start.Value()) + assert.Equal(t, 1253, start.Seq1()) + assert.Equal(t, 45, start.Seq2()) +} + +func TestPingSequenceGenerate(t *testing.T) { + const seed = 123 + random := rand.New(rand.NewSource(seed)) + + start := packet.GeneratePingSequence(random) + + // note: the expected values differ from eolib-java due to a different pseudo-random implementation + assert.Equal(t, 1208, start.Value()) + assert.Equal(t, 1253, start.Seq1()) + assert.Equal(t, 45, start.Seq2()) +} + +func TestAccountReplySequenceFromValue(t *testing.T) { + start := packet.NewAccountReplySequence(22) + + assert.Equal(t, 22, start.Value()) +} + +func TestAccountReplySequenceGenerate(t *testing.T) { + const seed = 123 + random := rand.New(rand.NewSource(seed)) + + start := packet.GenerateAccountReplySequence(random) + + // note: the expected values differ from eolib-java due to a different pseudo-random implementation + assert.Equal(t, 155, start.Value()) +} diff --git a/v3/protocol/enums_generated.go b/v3/protocol/enums_generated.go new file mode 100644 index 0000000..2989b2c --- /dev/null +++ b/v3/protocol/enums_generated.go @@ -0,0 +1,137 @@ +package protocol + +import "fmt" + +// AdminLevel :: The admin level of a player. +type AdminLevel int + +const ( + AdminLevel_Player AdminLevel = iota + AdminLevel_Spy + AdminLevel_LightGuide + AdminLevel_Guardian + AdminLevel_GameMaster + AdminLevel_HighGameMaster +) + +// String converts a AdminLevel value into its string representation +func (e AdminLevel) String() (string, error) { + switch e { + case AdminLevel_Player: + return "Player", nil + case AdminLevel_Spy: + return "Spy", nil + case AdminLevel_LightGuide: + return "LightGuide", nil + case AdminLevel_Guardian: + return "Guardian", nil + case AdminLevel_GameMaster: + return "GameMaster", nil + case AdminLevel_HighGameMaster: + return "HighGameMaster", nil + default: + return "", fmt.Errorf("could not convert value %d of type AdminLevel to string", e) + } +} + +// Direction :: The direction a player or NPC is facing. +type Direction int + +const ( + Direction_Down Direction = iota + Direction_Left + Direction_Up + Direction_Right +) + +// String converts a Direction value into its string representation +func (e Direction) String() (string, error) { + switch e { + case Direction_Down: + return "Down", nil + case Direction_Left: + return "Left", nil + case Direction_Up: + return "Up", nil + case Direction_Right: + return "Right", nil + default: + return "", fmt.Errorf("could not convert value %d of type Direction to string", e) + } +} + +// Emote :: Emote that can be played over a player's head. +type Emote int + +const ( + Emote_Happy Emote = iota + 1 + Emote_Depressed + Emote_Sad + Emote_Angry + Emote_Confused + Emote_Surprised + Emote_Hearts + Emote_Moon + Emote_Suicidal + Emote_Embarrassed + Emote_Drunk + Emote_Trade + Emote_LevelUp + Emote_Playful +) + +// String converts a Emote value into its string representation +func (e Emote) String() (string, error) { + switch e { + case Emote_Happy: + return "Happy", nil + case Emote_Depressed: + return "Depressed", nil + case Emote_Sad: + return "Sad", nil + case Emote_Angry: + return "Angry", nil + case Emote_Confused: + return "Confused", nil + case Emote_Surprised: + return "Surprised", nil + case Emote_Hearts: + return "Hearts", nil + case Emote_Moon: + return "Moon", nil + case Emote_Suicidal: + return "Suicidal", nil + case Emote_Embarrassed: + return "Embarrassed", nil + case Emote_Drunk: + return "Drunk", nil + case Emote_Trade: + return "Trade", nil + case Emote_LevelUp: + return "LevelUp", nil + case Emote_Playful: + return "Playful", nil + default: + return "", fmt.Errorf("could not convert value %d of type Emote to string", e) + } +} + +// Gender :: The gender of a player. +type Gender int + +const ( + Gender_Female Gender = iota + Gender_Male +) + +// String converts a Gender value into its string representation +func (e Gender) String() (string, error) { + switch e { + case Gender_Female: + return "Female", nil + case Gender_Male: + return "Male", nil + default: + return "", fmt.Errorf("could not convert value %d of type Gender to string", e) + } +} diff --git a/v3/protocol/map/enums_generated.go b/v3/protocol/map/enums_generated.go new file mode 100644 index 0000000..d336078 --- /dev/null +++ b/v3/protocol/map/enums_generated.go @@ -0,0 +1,217 @@ +package eomap + +import "fmt" + +type MapType int + +const ( + Map_Normal MapType = iota + Map_Pk = 3 +) + +// String converts a MapType value into its string representation +func (e MapType) String() (string, error) { + switch e { + case Map_Normal: + return "Normal", nil + case Map_Pk: + return "Pk", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapType to string", e) + } +} + +// MapTimedEffect :: A timed effect that can occur on a map. +type MapTimedEffect int + +const ( + MapTimedEffect_None MapTimedEffect = iota + MapTimedEffect_HpDrain + MapTimedEffect_TpDrain + MapTimedEffect_Quake1 + MapTimedEffect_Quake2 + MapTimedEffect_Quake3 + MapTimedEffect_Quake4 +) + +// String converts a MapTimedEffect value into its string representation +func (e MapTimedEffect) String() (string, error) { + switch e { + case MapTimedEffect_None: + return "None", nil + case MapTimedEffect_HpDrain: + return "HpDrain", nil + case MapTimedEffect_TpDrain: + return "TpDrain", nil + case MapTimedEffect_Quake1: + return "Quake1", nil + case MapTimedEffect_Quake2: + return "Quake2", nil + case MapTimedEffect_Quake3: + return "Quake3", nil + case MapTimedEffect_Quake4: + return "Quake4", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapTimedEffect to string", e) + } +} + +// MapMusicControl :: How background music should be played on a map. +type MapMusicControl int + +const ( + MapMusicControl_InterruptIfDifferentPlayOnce MapMusicControl = iota + MapMusicControl_InterruptPlayOnce + MapMusicControl_FinishPlayOnce + MapMusicControl_InterruptIfDifferentPlayRepeat + MapMusicControl_InterruptPlayRepeat + MapMusicControl_FinishPlayRepeat + MapMusicControl_InterruptPlayNothing +) + +// String converts a MapMusicControl value into its string representation +func (e MapMusicControl) String() (string, error) { + switch e { + case MapMusicControl_InterruptIfDifferentPlayOnce: + return "InterruptIfDifferentPlayOnce", nil + case MapMusicControl_InterruptPlayOnce: + return "InterruptPlayOnce", nil + case MapMusicControl_FinishPlayOnce: + return "FinishPlayOnce", nil + case MapMusicControl_InterruptIfDifferentPlayRepeat: + return "InterruptIfDifferentPlayRepeat", nil + case MapMusicControl_InterruptPlayRepeat: + return "InterruptPlayRepeat", nil + case MapMusicControl_FinishPlayRepeat: + return "FinishPlayRepeat", nil + case MapMusicControl_InterruptPlayNothing: + return "InterruptPlayNothing", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapMusicControl to string", e) + } +} + +// MapTileSpec :: The type of a tile on a map. +type MapTileSpec int + +const ( + MapTileSpec_Wall MapTileSpec = iota + MapTileSpec_ChairDown + MapTileSpec_ChairLeft + MapTileSpec_ChairRight + MapTileSpec_ChairUp + MapTileSpec_ChairDownRight + MapTileSpec_ChairUpLeft + MapTileSpec_ChairAll + MapTileSpec_Reserved8 + MapTileSpec_Chest + MapTileSpec_Reserved10 + MapTileSpec_Reserved11 + MapTileSpec_Reserved12 + MapTileSpec_Reserved13 + MapTileSpec_Reserved14 + MapTileSpec_Reserved15 + MapTileSpec_BankVault + MapTileSpec_NpcBoundary + MapTileSpec_Edge + MapTileSpec_FakeWall + MapTileSpec_Board1 + MapTileSpec_Board2 + MapTileSpec_Board3 + MapTileSpec_Board4 + MapTileSpec_Board5 + MapTileSpec_Board6 + MapTileSpec_Board7 + MapTileSpec_Board8 + MapTileSpec_Jukebox + MapTileSpec_Jump + MapTileSpec_Water + MapTileSpec_Reserved31 + MapTileSpec_Arena + MapTileSpec_AmbientSource + MapTileSpec_TimedSpikes + MapTileSpec_Spikes + MapTileSpec_HiddenSpikes +) + +// String converts a MapTileSpec value into its string representation +func (e MapTileSpec) String() (string, error) { + switch e { + case MapTileSpec_Wall: + return "Wall", nil + case MapTileSpec_ChairDown: + return "ChairDown", nil + case MapTileSpec_ChairLeft: + return "ChairLeft", nil + case MapTileSpec_ChairRight: + return "ChairRight", nil + case MapTileSpec_ChairUp: + return "ChairUp", nil + case MapTileSpec_ChairDownRight: + return "ChairDownRight", nil + case MapTileSpec_ChairUpLeft: + return "ChairUpLeft", nil + case MapTileSpec_ChairAll: + return "ChairAll", nil + case MapTileSpec_Reserved8: + return "Reserved8", nil + case MapTileSpec_Chest: + return "Chest", nil + case MapTileSpec_Reserved10: + return "Reserved10", nil + case MapTileSpec_Reserved11: + return "Reserved11", nil + case MapTileSpec_Reserved12: + return "Reserved12", nil + case MapTileSpec_Reserved13: + return "Reserved13", nil + case MapTileSpec_Reserved14: + return "Reserved14", nil + case MapTileSpec_Reserved15: + return "Reserved15", nil + case MapTileSpec_BankVault: + return "BankVault", nil + case MapTileSpec_NpcBoundary: + return "NpcBoundary", nil + case MapTileSpec_Edge: + return "Edge", nil + case MapTileSpec_FakeWall: + return "FakeWall", nil + case MapTileSpec_Board1: + return "Board1", nil + case MapTileSpec_Board2: + return "Board2", nil + case MapTileSpec_Board3: + return "Board3", nil + case MapTileSpec_Board4: + return "Board4", nil + case MapTileSpec_Board5: + return "Board5", nil + case MapTileSpec_Board6: + return "Board6", nil + case MapTileSpec_Board7: + return "Board7", nil + case MapTileSpec_Board8: + return "Board8", nil + case MapTileSpec_Jukebox: + return "Jukebox", nil + case MapTileSpec_Jump: + return "Jump", nil + case MapTileSpec_Water: + return "Water", nil + case MapTileSpec_Reserved31: + return "Reserved31", nil + case MapTileSpec_Arena: + return "Arena", nil + case MapTileSpec_AmbientSource: + return "AmbientSource", nil + case MapTileSpec_TimedSpikes: + return "TimedSpikes", nil + case MapTileSpec_Spikes: + return "Spikes", nil + case MapTileSpec_HiddenSpikes: + return "HiddenSpikes", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapTileSpec to string", e) + } +} diff --git a/v3/protocol/map/package.go b/v3/protocol/map/package.go new file mode 100644 index 0000000..b689c05 --- /dev/null +++ b/v3/protocol/map/package.go @@ -0,0 +1,2 @@ +// Package eomap provides EO map data structures. Types and functions in this package are primarily generated from the eo-protocol XML specification. +package eomap diff --git a/v3/protocol/map/packets_generated.go b/v3/protocol/map/packets_generated.go new file mode 100644 index 0000000..0d1ce85 --- /dev/null +++ b/v3/protocol/map/packets_generated.go @@ -0,0 +1 @@ +package eomap diff --git a/v3/protocol/map/structs_generated.go b/v3/protocol/map/structs_generated.go new file mode 100644 index 0000000..65146b9 --- /dev/null +++ b/v3/protocol/map/structs_generated.go @@ -0,0 +1,988 @@ +package eomap + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/protocol" +) + +// MapNpc :: NPC spawn EMF entity. +type MapNpc struct { + byteSize int + + Coords protocol.Coords + Id int + SpawnType int + SpawnTime int + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapNpc) ByteSize() int { + return s.byteSize +} + +func (s *MapNpc) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // SpawnType : field : char + if err = writer.AddChar(s.SpawnType); err != nil { + return + } + // SpawnTime : field : short + if err = writer.AddShort(s.SpawnTime); err != nil { + return + } + // Amount : field : char + if err = writer.AddChar(s.Amount); err != nil { + return + } + return +} + +func (s *MapNpc) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Id : field : short + s.Id = reader.GetShort() + // SpawnType : field : char + s.SpawnType = reader.GetChar() + // SpawnTime : field : short + s.SpawnTime = reader.GetShort() + // Amount : field : char + s.Amount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapLegacyDoorKey :: Legacy EMF entity used to specify a key on a door. +type MapLegacyDoorKey struct { + byteSize int + + Coords protocol.Coords + Key int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapLegacyDoorKey) ByteSize() int { + return s.byteSize +} + +func (s *MapLegacyDoorKey) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Key : field : short + if err = writer.AddShort(s.Key); err != nil { + return + } + return +} + +func (s *MapLegacyDoorKey) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Key : field : short + s.Key = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapItem :: Item spawn EMF entity. +type MapItem struct { + byteSize int + + Coords protocol.Coords + Key int + ChestSlot int + ItemId int + SpawnTime int + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapItem) ByteSize() int { + return s.byteSize +} + +func (s *MapItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Key : field : short + if err = writer.AddShort(s.Key); err != nil { + return + } + // ChestSlot : field : char + if err = writer.AddChar(s.ChestSlot); err != nil { + return + } + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // SpawnTime : field : short + if err = writer.AddShort(s.SpawnTime); err != nil { + return + } + // Amount : field : three + if err = writer.AddThree(s.Amount); err != nil { + return + } + return +} + +func (s *MapItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Key : field : short + s.Key = reader.GetShort() + // ChestSlot : field : char + s.ChestSlot = reader.GetChar() + // ItemId : field : short + s.ItemId = reader.GetShort() + // SpawnTime : field : short + s.SpawnTime = reader.GetShort() + // Amount : field : three + s.Amount = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapWarp :: Warp EMF entity. +type MapWarp struct { + byteSize int + + DestinationMap int + DestinationCoords protocol.Coords + LevelRequired int + Door int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapWarp) ByteSize() int { + return s.byteSize +} + +func (s *MapWarp) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // DestinationMap : field : short + if err = writer.AddShort(s.DestinationMap); err != nil { + return + } + // DestinationCoords : field : Coords + if err = s.DestinationCoords.Serialize(writer); err != nil { + return + } + // LevelRequired : field : char + if err = writer.AddChar(s.LevelRequired); err != nil { + return + } + // Door : field : short + if err = writer.AddShort(s.Door); err != nil { + return + } + return +} + +func (s *MapWarp) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // DestinationMap : field : short + s.DestinationMap = reader.GetShort() + // DestinationCoords : field : Coords + if err = s.DestinationCoords.Deserialize(reader); err != nil { + return + } + // LevelRequired : field : char + s.LevelRequired = reader.GetChar() + // Door : field : short + s.Door = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapSign :: Sign EMF entity. +type MapSign struct { + byteSize int + + Coords protocol.Coords + StringData string + TitleLength int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapSign) ByteSize() int { + return s.byteSize +} + +func (s *MapSign) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // StringDataLength : length : short + if err = writer.AddShort(len(s.StringData) + 1); err != nil { + return + } + // StringData : field : encoded_string + if err = writer.AddFixedEncodedString(s.StringData, len(s.StringData)); err != nil { + return + } + // TitleLength : field : char + if err = writer.AddChar(s.TitleLength); err != nil { + return + } + return +} + +func (s *MapSign) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // StringDataLength : length : short + stringDataLength := reader.GetShort() - 1 + // StringData : field : encoded_string + if s.StringData, err = reader.GetFixedEncodedString(stringDataLength); err != nil { + return + } + + // TitleLength : field : char + s.TitleLength = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapTileSpecRowTile :: A single tile in a row of tilespecs. +type MapTileSpecRowTile struct { + byteSize int + + X int + TileSpec MapTileSpec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapTileSpecRowTile) ByteSize() int { + return s.byteSize +} + +func (s *MapTileSpecRowTile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : char + if err = writer.AddChar(s.X); err != nil { + return + } + // TileSpec : field : MapTileSpec + if err = writer.AddChar(int(s.TileSpec)); err != nil { + return + } + return +} + +func (s *MapTileSpecRowTile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : char + s.X = reader.GetChar() + // TileSpec : field : MapTileSpec + s.TileSpec = MapTileSpec(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapTileSpecRow :: A row of tilespecs. +type MapTileSpecRow struct { + byteSize int + + Y int + Tiles []MapTileSpecRowTile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapTileSpecRow) ByteSize() int { + return s.byteSize +} + +func (s *MapTileSpecRow) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Y : field : char + if err = writer.AddChar(s.Y); err != nil { + return + } + // TilesCount : length : char + if err = writer.AddChar(len(s.Tiles)); err != nil { + return + } + // Tiles : array : MapTileSpecRowTile + for ndx := 0; ndx < len(s.Tiles); ndx++ { + if err = s.Tiles[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *MapTileSpecRow) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Y : field : char + s.Y = reader.GetChar() + // TilesCount : length : char + tilesCount := reader.GetChar() + // Tiles : array : MapTileSpecRowTile + for ndx := 0; ndx < tilesCount; ndx++ { + s.Tiles = append(s.Tiles, MapTileSpecRowTile{}) + if err = s.Tiles[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapWarpRowTile :: A single tile in a row of warp entities. +type MapWarpRowTile struct { + byteSize int + + X int + Warp MapWarp +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapWarpRowTile) ByteSize() int { + return s.byteSize +} + +func (s *MapWarpRowTile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : char + if err = writer.AddChar(s.X); err != nil { + return + } + // Warp : field : MapWarp + if err = s.Warp.Serialize(writer); err != nil { + return + } + return +} + +func (s *MapWarpRowTile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : char + s.X = reader.GetChar() + // Warp : field : MapWarp + if err = s.Warp.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapWarpRow :: A row of warp entities. +type MapWarpRow struct { + byteSize int + + Y int + Tiles []MapWarpRowTile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapWarpRow) ByteSize() int { + return s.byteSize +} + +func (s *MapWarpRow) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Y : field : char + if err = writer.AddChar(s.Y); err != nil { + return + } + // TilesCount : length : char + if err = writer.AddChar(len(s.Tiles)); err != nil { + return + } + // Tiles : array : MapWarpRowTile + for ndx := 0; ndx < len(s.Tiles); ndx++ { + if err = s.Tiles[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *MapWarpRow) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Y : field : char + s.Y = reader.GetChar() + // TilesCount : length : char + tilesCount := reader.GetChar() + // Tiles : array : MapWarpRowTile + for ndx := 0; ndx < tilesCount; ndx++ { + s.Tiles = append(s.Tiles, MapWarpRowTile{}) + if err = s.Tiles[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapGraphicRowTile :: A single tile in a row of map graphics. +type MapGraphicRowTile struct { + byteSize int + + X int + Graphic int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapGraphicRowTile) ByteSize() int { + return s.byteSize +} + +func (s *MapGraphicRowTile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : char + if err = writer.AddChar(s.X); err != nil { + return + } + // Graphic : field : short + if err = writer.AddShort(s.Graphic); err != nil { + return + } + return +} + +func (s *MapGraphicRowTile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : char + s.X = reader.GetChar() + // Graphic : field : short + s.Graphic = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapGraphicRow :: A row in a layer of map graphics. +type MapGraphicRow struct { + byteSize int + + Y int + Tiles []MapGraphicRowTile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapGraphicRow) ByteSize() int { + return s.byteSize +} + +func (s *MapGraphicRow) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Y : field : char + if err = writer.AddChar(s.Y); err != nil { + return + } + // TilesCount : length : char + if err = writer.AddChar(len(s.Tiles)); err != nil { + return + } + // Tiles : array : MapGraphicRowTile + for ndx := 0; ndx < len(s.Tiles); ndx++ { + if err = s.Tiles[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *MapGraphicRow) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Y : field : char + s.Y = reader.GetChar() + // TilesCount : length : char + tilesCount := reader.GetChar() + // Tiles : array : MapGraphicRowTile + for ndx := 0; ndx < tilesCount; ndx++ { + s.Tiles = append(s.Tiles, MapGraphicRowTile{}) + if err = s.Tiles[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapGraphicLayer :: A layer of map graphics. +type MapGraphicLayer struct { + byteSize int + + GraphicRows []MapGraphicRow +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapGraphicLayer) ByteSize() int { + return s.byteSize +} + +func (s *MapGraphicLayer) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GraphicRowsCount : length : char + if err = writer.AddChar(len(s.GraphicRows)); err != nil { + return + } + // GraphicRows : array : MapGraphicRow + for ndx := 0; ndx < len(s.GraphicRows); ndx++ { + if err = s.GraphicRows[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *MapGraphicLayer) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GraphicRowsCount : length : char + graphicRowsCount := reader.GetChar() + // GraphicRows : array : MapGraphicRow + for ndx := 0; ndx < graphicRowsCount; ndx++ { + s.GraphicRows = append(s.GraphicRows, MapGraphicRow{}) + if err = s.GraphicRows[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Emf :: Endless Map File. +type Emf struct { + byteSize int + + Rid []int + Name string + Type MapType + TimedEffect MapTimedEffect + MusicId int + MusicControl MapMusicControl + AmbientSoundId int + Width int + Height int + FillTile int + MapAvailable bool + CanScroll bool + RelogX int + RelogY int + + Npcs []MapNpc + LegacyDoorKeys []MapLegacyDoorKey + Items []MapItem + TileSpecRows []MapTileSpecRow + WarpRows []MapWarpRow + GraphicLayers []MapGraphicLayer // The 9 layers of map graphics. Order is [Ground, Object, Overlay, Down Wall, Right Wall, Roof, Top, Shadow, Overlay2]. + Signs []MapSign +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Emf) ByteSize() int { + return s.byteSize +} + +func (s *Emf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EMF : field : string + if err = writer.AddFixedString("EMF", 3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Rid) != 2 { + err = fmt.Errorf("expected Rid with length 2, got %d", len(s.Rid)) + return + } + + if err = writer.AddShort(s.Rid[ndx]); err != nil { + return + } + } + + // Name : field : encoded_string + if len(s.Name) > 24 { + err = fmt.Errorf("expected Name with length 24, got %d", len(s.Name)) + return + } + if err = writer.AddPaddedEncodedString(s.Name, 24); err != nil { + return + } + // Type : field : MapType + if err = writer.AddChar(int(s.Type)); err != nil { + return + } + // TimedEffect : field : MapTimedEffect + if err = writer.AddChar(int(s.TimedEffect)); err != nil { + return + } + // MusicId : field : char + if err = writer.AddChar(s.MusicId); err != nil { + return + } + // MusicControl : field : MapMusicControl + if err = writer.AddChar(int(s.MusicControl)); err != nil { + return + } + // AmbientSoundId : field : short + if err = writer.AddShort(s.AmbientSoundId); err != nil { + return + } + // Width : field : char + if err = writer.AddChar(s.Width); err != nil { + return + } + // Height : field : char + if err = writer.AddChar(s.Height); err != nil { + return + } + // FillTile : field : short + if err = writer.AddShort(s.FillTile); err != nil { + return + } + // MapAvailable : field : bool + if s.MapAvailable { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // CanScroll : field : bool + if s.CanScroll { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // RelogX : field : char + if err = writer.AddChar(s.RelogX); err != nil { + return + } + // RelogY : field : char + if err = writer.AddChar(s.RelogY); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // NpcsCount : length : char + if err = writer.AddChar(len(s.Npcs)); err != nil { + return + } + // Npcs : array : MapNpc + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + // LegacyDoorKeysCount : length : char + if err = writer.AddChar(len(s.LegacyDoorKeys)); err != nil { + return + } + // LegacyDoorKeys : array : MapLegacyDoorKey + for ndx := 0; ndx < len(s.LegacyDoorKeys); ndx++ { + if err = s.LegacyDoorKeys[ndx].Serialize(writer); err != nil { + return + } + } + + // ItemsCount : length : char + if err = writer.AddChar(len(s.Items)); err != nil { + return + } + // Items : array : MapItem + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + // TileSpecRowsCount : length : char + if err = writer.AddChar(len(s.TileSpecRows)); err != nil { + return + } + // TileSpecRows : array : MapTileSpecRow + for ndx := 0; ndx < len(s.TileSpecRows); ndx++ { + if err = s.TileSpecRows[ndx].Serialize(writer); err != nil { + return + } + } + + // WarpRowsCount : length : char + if err = writer.AddChar(len(s.WarpRows)); err != nil { + return + } + // WarpRows : array : MapWarpRow + for ndx := 0; ndx < len(s.WarpRows); ndx++ { + if err = s.WarpRows[ndx].Serialize(writer); err != nil { + return + } + } + + // GraphicLayers : array : MapGraphicLayer + for ndx := 0; ndx < 9; ndx++ { + if len(s.GraphicLayers) != 9 { + err = fmt.Errorf("expected GraphicLayers with length 9, got %d", len(s.GraphicLayers)) + return + } + + if err = s.GraphicLayers[ndx].Serialize(writer); err != nil { + return + } + } + + // SignsCount : length : char + if err = writer.AddChar(len(s.Signs)); err != nil { + return + } + // Signs : array : MapSign + for ndx := 0; ndx < len(s.Signs); ndx++ { + if err = s.Signs[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *Emf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EMF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Rid = append(s.Rid, 0) + s.Rid[ndx] = reader.GetShort() + } + + // Name : field : encoded_string + if s.Name, err = reader.GetPaddedEncodedString(24); err != nil { + return + } + + // Type : field : MapType + s.Type = MapType(reader.GetChar()) + // TimedEffect : field : MapTimedEffect + s.TimedEffect = MapTimedEffect(reader.GetChar()) + // MusicId : field : char + s.MusicId = reader.GetChar() + // MusicControl : field : MapMusicControl + s.MusicControl = MapMusicControl(reader.GetChar()) + // AmbientSoundId : field : short + s.AmbientSoundId = reader.GetShort() + // Width : field : char + s.Width = reader.GetChar() + // Height : field : char + s.Height = reader.GetChar() + // FillTile : field : short + s.FillTile = reader.GetShort() + // MapAvailable : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.MapAvailable = true + } else { + s.MapAvailable = false + } + // CanScroll : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.CanScroll = true + } else { + s.CanScroll = false + } + // RelogX : field : char + s.RelogX = reader.GetChar() + // RelogY : field : char + s.RelogY = reader.GetChar() + // 0 : field : char + reader.GetChar() + // NpcsCount : length : char + npcsCount := reader.GetChar() + // Npcs : array : MapNpc + for ndx := 0; ndx < npcsCount; ndx++ { + s.Npcs = append(s.Npcs, MapNpc{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + // LegacyDoorKeysCount : length : char + legacyDoorKeysCount := reader.GetChar() + // LegacyDoorKeys : array : MapLegacyDoorKey + for ndx := 0; ndx < legacyDoorKeysCount; ndx++ { + s.LegacyDoorKeys = append(s.LegacyDoorKeys, MapLegacyDoorKey{}) + if err = s.LegacyDoorKeys[ndx].Deserialize(reader); err != nil { + return + } + } + + // ItemsCount : length : char + itemsCount := reader.GetChar() + // Items : array : MapItem + for ndx := 0; ndx < itemsCount; ndx++ { + s.Items = append(s.Items, MapItem{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + // TileSpecRowsCount : length : char + tileSpecRowsCount := reader.GetChar() + // TileSpecRows : array : MapTileSpecRow + for ndx := 0; ndx < tileSpecRowsCount; ndx++ { + s.TileSpecRows = append(s.TileSpecRows, MapTileSpecRow{}) + if err = s.TileSpecRows[ndx].Deserialize(reader); err != nil { + return + } + } + + // WarpRowsCount : length : char + warpRowsCount := reader.GetChar() + // WarpRows : array : MapWarpRow + for ndx := 0; ndx < warpRowsCount; ndx++ { + s.WarpRows = append(s.WarpRows, MapWarpRow{}) + if err = s.WarpRows[ndx].Deserialize(reader); err != nil { + return + } + } + + // GraphicLayers : array : MapGraphicLayer + for ndx := 0; ndx < 9; ndx++ { + s.GraphicLayers = append(s.GraphicLayers, MapGraphicLayer{}) + if err = s.GraphicLayers[ndx].Deserialize(reader); err != nil { + return + } + } + + // SignsCount : length : char + signsCount := reader.GetChar() + // Signs : array : MapSign + for ndx := 0; ndx < signsCount; ndx++ { + s.Signs = append(s.Signs, MapSign{}) + if err = s.Signs[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/net/client/enums_generated.go b/v3/protocol/net/client/enums_generated.go new file mode 100644 index 0000000..d8c426c --- /dev/null +++ b/v3/protocol/net/client/enums_generated.go @@ -0,0 +1,187 @@ +package client + +import "fmt" + +// SitAction :: Whether the player wants to sit or stand. +type SitAction int + +const ( + SitAction_Sit SitAction = iota + 1 + SitAction_Stand +) + +// String converts a SitAction value into its string representation +func (e SitAction) String() (string, error) { + switch e { + case SitAction_Sit: + return "Sit", nil + case SitAction_Stand: + return "Stand", nil + default: + return "", fmt.Errorf("could not convert value %d of type SitAction to string", e) + } +} + +// GuildInfoType :: The type of guild info being interacted with. +type GuildInfoType int + +const ( + GuildInfo_Description GuildInfoType = iota + 1 + GuildInfo_Ranks + GuildInfo_Bank +) + +// String converts a GuildInfoType value into its string representation +func (e GuildInfoType) String() (string, error) { + switch e { + case GuildInfo_Description: + return "Description", nil + case GuildInfo_Ranks: + return "Ranks", nil + case GuildInfo_Bank: + return "Bank", nil + default: + return "", fmt.Errorf("could not convert value %d of type GuildInfoType to string", e) + } +} + +// TrainType :: Whether the player is spending a stat point or a skill point. +type TrainType int + +const ( + Train_Stat TrainType = iota + 1 + Train_Skill +) + +// String converts a TrainType value into its string representation +func (e TrainType) String() (string, error) { + switch e { + case Train_Stat: + return "Stat", nil + case Train_Skill: + return "Skill", nil + default: + return "", fmt.Errorf("could not convert value %d of type TrainType to string", e) + } +} + +// DialogReply :: Whether the player has clicked the OK button or a link in a quest dialog. +type DialogReply int + +const ( + DialogReply_Ok DialogReply = iota + 1 + DialogReply_Link +) + +// String converts a DialogReply value into its string representation +func (e DialogReply) String() (string, error) { + switch e { + case DialogReply_Ok: + return "Ok", nil + case DialogReply_Link: + return "Link", nil + default: + return "", fmt.Errorf("could not convert value %d of type DialogReply to string", e) + } +} + +// FileType :: Data file type. +type FileType int + +const ( + File_Emf FileType = iota + 1 + File_Eif + File_Enf + File_Esf + File_Ecf +) + +// String converts a FileType value into its string representation +func (e FileType) String() (string, error) { + switch e { + case File_Emf: + return "Emf", nil + case File_Eif: + return "Eif", nil + case File_Enf: + return "Enf", nil + case File_Esf: + return "Esf", nil + case File_Ecf: + return "Ecf", nil + default: + return "", fmt.Errorf("could not convert value %d of type FileType to string", e) + } +} + +// StatId :: Base character stat. +type StatId int + +const ( + StatId_Str StatId = iota + 1 + StatId_Int + StatId_Wis + StatId_Agi + StatId_Con + StatId_Cha +) + +// String converts a StatId value into its string representation +func (e StatId) String() (string, error) { + switch e { + case StatId_Str: + return "Str", nil + case StatId_Int: + return "Int", nil + case StatId_Wis: + return "Wis", nil + case StatId_Agi: + return "Agi", nil + case StatId_Con: + return "Con", nil + case StatId_Cha: + return "Cha", nil + default: + return "", fmt.Errorf("could not convert value %d of type StatId to string", e) + } +} + +// SpellTargetType :: Target type of a spell cast. +type SpellTargetType int + +const ( + SpellTarget_Player SpellTargetType = iota + 1 + SpellTarget_Npc +) + +// String converts a SpellTargetType value into its string representation +func (e SpellTargetType) String() (string, error) { + switch e { + case SpellTarget_Player: + return "Player", nil + case SpellTarget_Npc: + return "Npc", nil + default: + return "", fmt.Errorf("could not convert value %d of type SpellTargetType to string", e) + } +} + +// MarriageRequestType :: Request type sent with MARRIAGE_REQUEST packet. +type MarriageRequestType int + +const ( + MarriageRequest_MarriageApproval MarriageRequestType = iota + 1 + MarriageRequest_Divorce +) + +// String converts a MarriageRequestType value into its string representation +func (e MarriageRequestType) String() (string, error) { + switch e { + case MarriageRequest_MarriageApproval: + return "MarriageApproval", nil + case MarriageRequest_Divorce: + return "Divorce", nil + default: + return "", fmt.Errorf("could not convert value %d of type MarriageRequestType to string", e) + } +} diff --git a/v3/protocol/net/client/package.go b/v3/protocol/net/client/package.go new file mode 100644 index 0000000..66c7c5d --- /dev/null +++ b/v3/protocol/net/client/package.go @@ -0,0 +1,2 @@ +// Package client provides EO network protocol data structures. This package contains packets that are sent from client to server. Types and functions in this package are primarily generated from the eo-protocol XML specification. +package client diff --git a/v3/protocol/net/client/packetmap_generated.go b/v3/protocol/net/client/packetmap_generated.go new file mode 100644 index 0000000..6f14995 --- /dev/null +++ b/v3/protocol/net/client/packetmap_generated.go @@ -0,0 +1,176 @@ +package client + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/protocol/net" + "reflect" +) + +var packetMap = map[int]reflect.Type{ + net.PacketId(net.PacketFamily_Init, net.PacketAction_Init): reflect.TypeOf(InitInitClientPacket{}), + net.PacketId(net.PacketFamily_Connection, net.PacketAction_Accept): reflect.TypeOf(ConnectionAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Connection, net.PacketAction_Ping): reflect.TypeOf(ConnectionPingClientPacket{}), + net.PacketId(net.PacketFamily_Account, net.PacketAction_Request): reflect.TypeOf(AccountRequestClientPacket{}), + net.PacketId(net.PacketFamily_Account, net.PacketAction_Create): reflect.TypeOf(AccountCreateClientPacket{}), + net.PacketId(net.PacketFamily_Account, net.PacketAction_Agree): reflect.TypeOf(AccountAgreeClientPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Request): reflect.TypeOf(CharacterRequestClientPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Create): reflect.TypeOf(CharacterCreateClientPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Take): reflect.TypeOf(CharacterTakeClientPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Remove): reflect.TypeOf(CharacterRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Login, net.PacketAction_Request): reflect.TypeOf(LoginRequestClientPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Request): reflect.TypeOf(WelcomeRequestClientPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Msg): reflect.TypeOf(WelcomeMsgClientPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Agree): reflect.TypeOf(WelcomeAgreeClientPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Tell): reflect.TypeOf(AdminInteractTellClientPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Report): reflect.TypeOf(AdminInteractReportClientPacket{}), + net.PacketId(net.PacketFamily_Global, net.PacketAction_Remove): reflect.TypeOf(GlobalRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Global, net.PacketAction_Player): reflect.TypeOf(GlobalPlayerClientPacket{}), + net.PacketId(net.PacketFamily_Global, net.PacketAction_Open): reflect.TypeOf(GlobalOpenClientPacket{}), + net.PacketId(net.PacketFamily_Global, net.PacketAction_Close): reflect.TypeOf(GlobalCloseClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Request): reflect.TypeOf(TalkRequestClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Open): reflect.TypeOf(TalkOpenClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Msg): reflect.TypeOf(TalkMsgClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Tell): reflect.TypeOf(TalkTellClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Report): reflect.TypeOf(TalkReportClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Player): reflect.TypeOf(TalkPlayerClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Use): reflect.TypeOf(TalkUseClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Admin): reflect.TypeOf(TalkAdminClientPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Announce): reflect.TypeOf(TalkAnnounceClientPacket{}), + net.PacketId(net.PacketFamily_Attack, net.PacketAction_Use): reflect.TypeOf(AttackUseClientPacket{}), + net.PacketId(net.PacketFamily_Chair, net.PacketAction_Request): reflect.TypeOf(ChairRequestClientPacket{}), + net.PacketId(net.PacketFamily_Sit, net.PacketAction_Request): reflect.TypeOf(SitRequestClientPacket{}), + net.PacketId(net.PacketFamily_Emote, net.PacketAction_Report): reflect.TypeOf(EmoteReportClientPacket{}), + net.PacketId(net.PacketFamily_Face, net.PacketAction_Player): reflect.TypeOf(FacePlayerClientPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Admin): reflect.TypeOf(WalkAdminClientPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Spec): reflect.TypeOf(WalkSpecClientPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Player): reflect.TypeOf(WalkPlayerClientPacket{}), + net.PacketId(net.PacketFamily_Bank, net.PacketAction_Open): reflect.TypeOf(BankOpenClientPacket{}), + net.PacketId(net.PacketFamily_Bank, net.PacketAction_Add): reflect.TypeOf(BankAddClientPacket{}), + net.PacketId(net.PacketFamily_Bank, net.PacketAction_Take): reflect.TypeOf(BankTakeClientPacket{}), + net.PacketId(net.PacketFamily_Barber, net.PacketAction_Buy): reflect.TypeOf(BarberBuyClientPacket{}), + net.PacketId(net.PacketFamily_Barber, net.PacketAction_Open): reflect.TypeOf(BarberOpenClientPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Add): reflect.TypeOf(LockerAddClientPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Take): reflect.TypeOf(LockerTakeClientPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Open): reflect.TypeOf(LockerOpenClientPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Buy): reflect.TypeOf(LockerBuyClientPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Request): reflect.TypeOf(CitizenRequestClientPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Accept): reflect.TypeOf(CitizenAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Reply): reflect.TypeOf(CitizenReplyClientPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Remove): reflect.TypeOf(CitizenRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Open): reflect.TypeOf(CitizenOpenClientPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Create): reflect.TypeOf(ShopCreateClientPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Buy): reflect.TypeOf(ShopBuyClientPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Sell): reflect.TypeOf(ShopSellClientPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Open): reflect.TypeOf(ShopOpenClientPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Open): reflect.TypeOf(StatSkillOpenClientPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Take): reflect.TypeOf(StatSkillTakeClientPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Remove): reflect.TypeOf(StatSkillRemoveClientPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Add): reflect.TypeOf(StatSkillAddClientPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Junk): reflect.TypeOf(StatSkillJunkClientPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Use): reflect.TypeOf(ItemUseClientPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Drop): reflect.TypeOf(ItemDropClientPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Junk): reflect.TypeOf(ItemJunkClientPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Get): reflect.TypeOf(ItemGetClientPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Remove): reflect.TypeOf(BoardRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Create): reflect.TypeOf(BoardCreateClientPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Take): reflect.TypeOf(BoardTakeClientPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Open): reflect.TypeOf(BoardOpenClientPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Open): reflect.TypeOf(JukeboxOpenClientPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Msg): reflect.TypeOf(JukeboxMsgClientPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Use): reflect.TypeOf(JukeboxUseClientPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Accept): reflect.TypeOf(WarpAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Take): reflect.TypeOf(WarpTakeClientPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Request): reflect.TypeOf(PaperdollRequestClientPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Remove): reflect.TypeOf(PaperdollRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Add): reflect.TypeOf(PaperdollAddClientPacket{}), + net.PacketId(net.PacketFamily_Book, net.PacketAction_Request): reflect.TypeOf(BookRequestClientPacket{}), + net.PacketId(net.PacketFamily_Message, net.PacketAction_Ping): reflect.TypeOf(MessagePingClientPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Accept): reflect.TypeOf(PlayersAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Request): reflect.TypeOf(PlayersRequestClientPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_List): reflect.TypeOf(PlayersListClientPacket{}), + net.PacketId(net.PacketFamily_Door, net.PacketAction_Open): reflect.TypeOf(DoorOpenClientPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Open): reflect.TypeOf(ChestOpenClientPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Add): reflect.TypeOf(ChestAddClientPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Take): reflect.TypeOf(ChestTakeClientPacket{}), + net.PacketId(net.PacketFamily_Refresh, net.PacketAction_Request): reflect.TypeOf(RefreshRequestClientPacket{}), + net.PacketId(net.PacketFamily_Range, net.PacketAction_Request): reflect.TypeOf(RangeRequestClientPacket{}), + net.PacketId(net.PacketFamily_PlayerRange, net.PacketAction_Request): reflect.TypeOf(PlayerRangeRequestClientPacket{}), + net.PacketId(net.PacketFamily_NpcRange, net.PacketAction_Request): reflect.TypeOf(NpcRangeRequestClientPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Request): reflect.TypeOf(PartyRequestClientPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Accept): reflect.TypeOf(PartyAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Remove): reflect.TypeOf(PartyRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Take): reflect.TypeOf(PartyTakeClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Request): reflect.TypeOf(GuildRequestClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Accept): reflect.TypeOf(GuildAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Remove): reflect.TypeOf(GuildRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Agree): reflect.TypeOf(GuildAgreeClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Create): reflect.TypeOf(GuildCreateClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Player): reflect.TypeOf(GuildPlayerClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Take): reflect.TypeOf(GuildTakeClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Use): reflect.TypeOf(GuildUseClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Buy): reflect.TypeOf(GuildBuyClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Open): reflect.TypeOf(GuildOpenClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Tell): reflect.TypeOf(GuildTellClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Report): reflect.TypeOf(GuildReportClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Junk): reflect.TypeOf(GuildJunkClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Kick): reflect.TypeOf(GuildKickClientPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Rank): reflect.TypeOf(GuildRankClientPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_Request): reflect.TypeOf(SpellRequestClientPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetSelf): reflect.TypeOf(SpellTargetSelfClientPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetOther): reflect.TypeOf(SpellTargetOtherClientPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetGroup): reflect.TypeOf(SpellTargetGroupClientPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_Use): reflect.TypeOf(SpellUseClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Request): reflect.TypeOf(TradeRequestClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Accept): reflect.TypeOf(TradeAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Remove): reflect.TypeOf(TradeRemoveClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Agree): reflect.TypeOf(TradeAgreeClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Add): reflect.TypeOf(TradeAddClientPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Close): reflect.TypeOf(TradeCloseClientPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_Use): reflect.TypeOf(QuestUseClientPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_Accept): reflect.TypeOf(QuestAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_List): reflect.TypeOf(QuestListClientPacket{}), + net.PacketId(net.PacketFamily_Marriage, net.PacketAction_Open): reflect.TypeOf(MarriageOpenClientPacket{}), + net.PacketId(net.PacketFamily_Marriage, net.PacketAction_Request): reflect.TypeOf(MarriageRequestClientPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Accept): reflect.TypeOf(PriestAcceptClientPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Open): reflect.TypeOf(PriestOpenClientPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Request): reflect.TypeOf(PriestRequestClientPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Use): reflect.TypeOf(PriestUseClientPacket{}), +} + +// PacketFromId creates a typed packet instance from a [net.PacketFamily] and [net.PacketAction]. +// This function calls [PacketFromIntegerId] internally. +func PacketFromId(family net.PacketFamily, action net.PacketAction) (net.Packet, error) { + return PacketFromIntegerId(net.PacketId(family, action)) +} + +// PacketFromIntegerId creates a typed packet instance from a packet's ID. An ID may be converted from a family/action pair via the [net.PacketId] function. +// The returned packet implements the [net.Packet] interface. It may be serialized/deserialized without further conversion, or a type assertion may be made to examine the data. The expected type of the assertion is a pointer to a packet structure. +// The following example does both: an incoming CHAIR_REQUEST packet is deserialized from a reader without converting from the interface type, and the data is examined via a type assertion. +// +// pkt, _ := client.PacketFromId(net.PacketFamily_Chair, net.PacketAction_Request) +// if err = pkt.Deserialize(reader); err != nil { +// // handle the error +// } +// switch v := pkt.(type) { +// case *client.ChairRequestClientPacket: +// fmt.Println("SitAction=", v.SitAction) +// switch d := v.SitActionData.(type) { +// case *client.ChairRequestSitActionDataSit: +// fmt.Println("Data.Coords=", v.Data.Coords) +// } +// default: +// fmt.Printf("Unknown type: %s\n", reflect.TypeOf(pkt).Elem().Name()) +// } +func PacketFromIntegerId(id int) (net.Packet, error) { + packetType, idOk := packetMap[id] + if !idOk { + return nil, fmt.Errorf("could not find packet with id %d", id) + } + + packetInstance, typeOk := reflect.New(packetType).Interface().(net.Packet) + if !typeOk { + return nil, fmt.Errorf("could not create packet from id %d", id) + } + + return packetInstance, nil +} diff --git a/v3/protocol/net/client/packets_generated.go b/v3/protocol/net/client/packets_generated.go new file mode 100644 index 0000000..30aa6f3 --- /dev/null +++ b/v3/protocol/net/client/packets_generated.go @@ -0,0 +1,7285 @@ +package client + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/protocol" + "github.com/ethanmoffat/eolib-go/v3/protocol/net" +) + +// InitInitClientPacket :: Connection initialization request. This packet is unencrypted. +type InitInitClientPacket struct { + byteSize int + + Challenge int + Version net.Version + + Hdid string +} + +func (s InitInitClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Init +} + +func (s InitInitClientPacket) Action() net.PacketAction { + return net.PacketAction_Init +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *InitInitClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Challenge : field : three + if err = writer.AddThree(s.Challenge); err != nil { + return + } + // Version : field : Version + if err = s.Version.Serialize(writer); err != nil { + return + } + // 112 : field : char + if err = writer.AddChar(112); err != nil { + return + } + // HdidLength : length : char + if err = writer.AddChar(len(s.Hdid)); err != nil { + return + } + // Hdid : field : string + if err = writer.AddFixedString(s.Hdid, len(s.Hdid)); err != nil { + return + } + return +} + +func (s *InitInitClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Challenge : field : three + s.Challenge = reader.GetThree() + // Version : field : Version + if err = s.Version.Deserialize(reader); err != nil { + return + } + // 112 : field : char + reader.GetChar() + // HdidLength : length : char + hdidLength := reader.GetChar() + // Hdid : field : string + if s.Hdid, err = reader.GetFixedString(hdidLength); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ConnectionAcceptClientPacket :: Confirm initialization data. +type ConnectionAcceptClientPacket struct { + byteSize int + + ClientEncryptionMultiple int + ServerEncryptionMultiple int + PlayerId int +} + +func (s ConnectionAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Connection +} + +func (s ConnectionAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ConnectionAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ConnectionAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ClientEncryptionMultiple : field : short + if err = writer.AddShort(s.ClientEncryptionMultiple); err != nil { + return + } + // ServerEncryptionMultiple : field : short + if err = writer.AddShort(s.ServerEncryptionMultiple); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *ConnectionAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ClientEncryptionMultiple : field : short + s.ClientEncryptionMultiple = reader.GetShort() + // ServerEncryptionMultiple : field : short + s.ServerEncryptionMultiple = reader.GetShort() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ConnectionPingClientPacket :: Ping reply. +type ConnectionPingClientPacket struct { + byteSize int +} + +func (s ConnectionPingClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Connection +} + +func (s ConnectionPingClientPacket) Action() net.PacketAction { + return net.PacketAction_Ping +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ConnectionPingClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ConnectionPingClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // k : dummy : string + if err = writer.AddString("k"); err != nil { + return + } + return +} + +func (s *ConnectionPingClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // k : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AccountRequestClientPacket :: Request creating an account. +type AccountRequestClientPacket struct { + byteSize int + + Username string +} + +func (s AccountRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Account +} + +func (s AccountRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AccountRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Username : field : string + if err = writer.AddString(s.Username); err != nil { + return + } + return +} + +func (s *AccountRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Username : field : string + if s.Username, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AccountCreateClientPacket :: Confirm creating an account. +type AccountCreateClientPacket struct { + byteSize int + + SessionId int + Username string + Password string + FullName string + Location string + Email string + Computer string + Hdid string +} + +func (s AccountCreateClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Account +} + +func (s AccountCreateClientPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountCreateClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AccountCreateClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // Username : field : string + if err = writer.AddString(s.Username); err != nil { + return + } + writer.AddByte(255) + // Password : field : string + if err = writer.AddString(s.Password); err != nil { + return + } + writer.AddByte(255) + // FullName : field : string + if err = writer.AddString(s.FullName); err != nil { + return + } + writer.AddByte(255) + // Location : field : string + if err = writer.AddString(s.Location); err != nil { + return + } + writer.AddByte(255) + // Email : field : string + if err = writer.AddString(s.Email); err != nil { + return + } + writer.AddByte(255) + // Computer : field : string + if err = writer.AddString(s.Computer); err != nil { + return + } + writer.AddByte(255) + // Hdid : field : string + if err = writer.AddString(s.Hdid); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *AccountCreateClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : short + s.SessionId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Username : field : string + if s.Username, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Password : field : string + if s.Password, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // FullName : field : string + if s.FullName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Location : field : string + if s.Location, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Email : field : string + if s.Email, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Computer : field : string + if s.Computer, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Hdid : field : string + if s.Hdid, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AccountAgreeClientPacket :: Change password. +type AccountAgreeClientPacket struct { + byteSize int + + Username string + OldPassword string + NewPassword string +} + +func (s AccountAgreeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Account +} + +func (s AccountAgreeClientPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountAgreeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AccountAgreeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Username : field : string + if err = writer.AddString(s.Username); err != nil { + return + } + writer.AddByte(255) + // OldPassword : field : string + if err = writer.AddString(s.OldPassword); err != nil { + return + } + writer.AddByte(255) + // NewPassword : field : string + if err = writer.AddString(s.NewPassword); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *AccountAgreeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Username : field : string + if s.Username, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // OldPassword : field : string + if s.OldPassword, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // NewPassword : field : string + if s.NewPassword, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterRequestClientPacket :: Request to create a character. +type CharacterRequestClientPacket struct { + byteSize int + + RequestString string +} + +func (s CharacterRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // RequestString : field : string + if err = writer.AddString(s.RequestString); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *CharacterRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // RequestString : field : string + if s.RequestString, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterCreateClientPacket :: Confirm creating a character. +type CharacterCreateClientPacket struct { + byteSize int + + SessionId int + Gender protocol.Gender + HairStyle int + HairColor int + Skin int + Name string +} + +func (s CharacterCreateClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterCreateClientPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterCreateClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterCreateClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // Gender : field : Gender:short + if err = writer.AddChar(int(s.Gender)); err != nil { + return + } + // HairStyle : field : short + if err = writer.AddShort(s.HairStyle); err != nil { + return + } + // HairColor : field : short + if err = writer.AddShort(s.HairColor); err != nil { + return + } + // Skin : field : short + if err = writer.AddShort(s.Skin); err != nil { + return + } + writer.AddByte(255) + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *CharacterCreateClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : short + s.SessionId = reader.GetShort() + // Gender : field : Gender:short + s.Gender = protocol.Gender(reader.GetChar()) + // HairStyle : field : short + s.HairStyle = reader.GetShort() + // HairColor : field : short + s.HairColor = reader.GetShort() + // Skin : field : short + s.Skin = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterTakeClientPacket :: Request to delete a character from an account. +type CharacterTakeClientPacket struct { + byteSize int + + CharacterId int +} + +func (s CharacterTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + return +} + +func (s *CharacterTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterRemoveClientPacket :: Confirm deleting character from an account. +type CharacterRemoveClientPacket struct { + byteSize int + + SessionId int + CharacterId int +} + +func (s CharacterRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + return +} + +func (s *CharacterRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LoginRequestClientPacket :: Login request. +type LoginRequestClientPacket struct { + byteSize int + + Username string + Password string +} + +func (s LoginRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Login +} + +func (s LoginRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *LoginRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Username : field : string + if err = writer.AddString(s.Username); err != nil { + return + } + writer.AddByte(255) + // Password : field : string + if err = writer.AddString(s.Password); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *LoginRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Username : field : string + if s.Username, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Password : field : string + if s.Password, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeRequestClientPacket :: Selected a character. +type WelcomeRequestClientPacket struct { + byteSize int + + CharacterId int +} + +func (s WelcomeRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + return +} + +func (s *WelcomeRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeMsgClientPacket :: Entering game. +type WelcomeMsgClientPacket struct { + byteSize int + + SessionId int + CharacterId int +} + +func (s WelcomeMsgClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeMsgClientPacket) Action() net.PacketAction { + return net.PacketAction_Msg +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeMsgClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeMsgClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + return +} + +func (s *WelcomeMsgClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : three + s.SessionId = reader.GetThree() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeAgreeClientPacket :: Requesting a file. +type WelcomeAgreeClientPacket struct { + byteSize int + + FileType FileType + SessionId int + FileTypeData WelcomeAgreeFileTypeData +} + +type WelcomeAgreeFileTypeData interface { + protocol.EoData +} + +type WelcomeAgreeFileTypeDataEmf struct { + byteSize int + + FileId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeFileTypeDataEmf) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeFileTypeDataEmf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : short + if err = writer.AddShort(s.FileId); err != nil { + return + } + return +} + +func (s *WelcomeAgreeFileTypeDataEmf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : short + s.FileId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type WelcomeAgreeFileTypeDataEif struct { + byteSize int + + FileId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeFileTypeDataEif) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeFileTypeDataEif) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : char + if err = writer.AddChar(s.FileId); err != nil { + return + } + return +} + +func (s *WelcomeAgreeFileTypeDataEif) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : char + s.FileId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type WelcomeAgreeFileTypeDataEnf struct { + byteSize int + + FileId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeFileTypeDataEnf) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeFileTypeDataEnf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : char + if err = writer.AddChar(s.FileId); err != nil { + return + } + return +} + +func (s *WelcomeAgreeFileTypeDataEnf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : char + s.FileId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type WelcomeAgreeFileTypeDataEsf struct { + byteSize int + + FileId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeFileTypeDataEsf) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeFileTypeDataEsf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : char + if err = writer.AddChar(s.FileId); err != nil { + return + } + return +} + +func (s *WelcomeAgreeFileTypeDataEsf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : char + s.FileId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type WelcomeAgreeFileTypeDataEcf struct { + byteSize int + + FileId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeFileTypeDataEcf) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeFileTypeDataEcf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : char + if err = writer.AddChar(s.FileId); err != nil { + return + } + return +} + +func (s *WelcomeAgreeFileTypeDataEcf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : char + s.FileId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s WelcomeAgreeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeAgreeClientPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeAgreeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeAgreeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileType : field : FileType + if err = writer.AddChar(int(s.FileType)); err != nil { + return + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + switch s.FileType { + case File_Emf: + switch s.FileTypeData.(type) { + case *WelcomeAgreeFileTypeDataEmf: + if err = s.FileTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.FileType) + return + } + case File_Eif: + switch s.FileTypeData.(type) { + case *WelcomeAgreeFileTypeDataEif: + if err = s.FileTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.FileType) + return + } + case File_Enf: + switch s.FileTypeData.(type) { + case *WelcomeAgreeFileTypeDataEnf: + if err = s.FileTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.FileType) + return + } + case File_Esf: + switch s.FileTypeData.(type) { + case *WelcomeAgreeFileTypeDataEsf: + if err = s.FileTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.FileType) + return + } + case File_Ecf: + switch s.FileTypeData.(type) { + case *WelcomeAgreeFileTypeDataEcf: + if err = s.FileTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.FileType) + return + } + } + return +} + +func (s *WelcomeAgreeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileType : field : FileType + s.FileType = FileType(reader.GetChar()) + // SessionId : field : short + s.SessionId = reader.GetShort() + switch s.FileType { + case File_Emf: + s.FileTypeData = &WelcomeAgreeFileTypeDataEmf{} + if err = s.FileTypeData.Deserialize(reader); err != nil { + return + } + case File_Eif: + s.FileTypeData = &WelcomeAgreeFileTypeDataEif{} + if err = s.FileTypeData.Deserialize(reader); err != nil { + return + } + case File_Enf: + s.FileTypeData = &WelcomeAgreeFileTypeDataEnf{} + if err = s.FileTypeData.Deserialize(reader); err != nil { + return + } + case File_Esf: + s.FileTypeData = &WelcomeAgreeFileTypeDataEsf{} + if err = s.FileTypeData.Deserialize(reader); err != nil { + return + } + case File_Ecf: + s.FileTypeData = &WelcomeAgreeFileTypeDataEcf{} + if err = s.FileTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractTellClientPacket :: Talk to admin. +type AdminInteractTellClientPacket struct { + byteSize int + + Message string +} + +func (s AdminInteractTellClientPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractTellClientPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractTellClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractTellClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *AdminInteractTellClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractReportClientPacket :: Report character. +type AdminInteractReportClientPacket struct { + byteSize int + + Reportee string + Message string +} + +func (s AdminInteractReportClientPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractReportClientPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractReportClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractReportClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Reportee : field : string + if err = writer.AddString(s.Reportee); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *AdminInteractReportClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Reportee : field : string + if s.Reportee, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GlobalRemoveClientPacket :: Enable whispers. +type GlobalRemoveClientPacket struct { + byteSize int +} + +func (s GlobalRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Global +} + +func (s GlobalRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GlobalRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GlobalRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // n : dummy : string + if err = writer.AddString("n"); err != nil { + return + } + return +} + +func (s *GlobalRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // n : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GlobalPlayerClientPacket :: Disable whispers. +type GlobalPlayerClientPacket struct { + byteSize int +} + +func (s GlobalPlayerClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Global +} + +func (s GlobalPlayerClientPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GlobalPlayerClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GlobalPlayerClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // y : dummy : string + if err = writer.AddString("y"); err != nil { + return + } + return +} + +func (s *GlobalPlayerClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // y : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GlobalOpenClientPacket :: Opened global tab. +type GlobalOpenClientPacket struct { + byteSize int +} + +func (s GlobalOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Global +} + +func (s GlobalOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GlobalOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GlobalOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // y : dummy : string + if err = writer.AddString("y"); err != nil { + return + } + return +} + +func (s *GlobalOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // y : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GlobalCloseClientPacket :: Closed global tab. +type GlobalCloseClientPacket struct { + byteSize int +} + +func (s GlobalCloseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Global +} + +func (s GlobalCloseClientPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GlobalCloseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GlobalCloseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // n : dummy : string + if err = writer.AddString("n"); err != nil { + return + } + return +} + +func (s *GlobalCloseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // n : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkRequestClientPacket :: Guild chat message. +type TalkRequestClientPacket struct { + byteSize int + + Message string +} + +func (s TalkRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkOpenClientPacket :: Party chat message. +type TalkOpenClientPacket struct { + byteSize int + + Message string +} + +func (s TalkOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkMsgClientPacket :: Global chat message. +type TalkMsgClientPacket struct { + byteSize int + + Message string +} + +func (s TalkMsgClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkMsgClientPacket) Action() net.PacketAction { + return net.PacketAction_Msg +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkMsgClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkMsgClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkMsgClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkTellClientPacket :: Private chat message. +type TalkTellClientPacket struct { + byteSize int + + Name string + Message string +} + +func (s TalkTellClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkTellClientPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkTellClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkTellClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkTellClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkReportClientPacket :: Public chat message. +type TalkReportClientPacket struct { + byteSize int + + Message string +} + +func (s TalkReportClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkReportClientPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkReportClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkReportClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkReportClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkPlayerClientPacket :: Public chat message - alias of TALK_REPORT (vestigial). +type TalkPlayerClientPacket struct { + byteSize int + + Message string +} + +func (s TalkPlayerClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkPlayerClientPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkPlayerClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkPlayerClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkPlayerClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkUseClientPacket :: Public chat message - alias of TALK_REPORT (vestigial). +type TalkUseClientPacket struct { + byteSize int + + Message string +} + +func (s TalkUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkAdminClientPacket :: Admin chat message. +type TalkAdminClientPacket struct { + byteSize int + + Message string +} + +func (s TalkAdminClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkAdminClientPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkAdminClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkAdminClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkAdminClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkAnnounceClientPacket :: Admin announcement. +type TalkAnnounceClientPacket struct { + byteSize int + + Message string +} + +func (s TalkAnnounceClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkAnnounceClientPacket) Action() net.PacketAction { + return net.PacketAction_Announce +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkAnnounceClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkAnnounceClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkAnnounceClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AttackUseClientPacket :: Attacking. +type AttackUseClientPacket struct { + byteSize int + + Direction protocol.Direction + Timestamp int +} + +func (s AttackUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Attack +} + +func (s AttackUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AttackUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *AttackUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + return +} + +func (s *AttackUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // Timestamp : field : three + s.Timestamp = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChairRequestClientPacket :: Sitting on a chair. +type ChairRequestClientPacket struct { + byteSize int + + SitAction SitAction + SitActionData ChairRequestSitActionData +} + +type ChairRequestSitActionData interface { + protocol.EoData +} + +type ChairRequestSitActionDataSit struct { + byteSize int + + Coords protocol.Coords +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairRequestSitActionDataSit) ByteSize() int { + return s.byteSize +} + +func (s *ChairRequestSitActionDataSit) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChairRequestSitActionDataSit) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s ChairRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Chair +} + +func (s ChairRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChairRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SitAction : field : SitAction + if err = writer.AddChar(int(s.SitAction)); err != nil { + return + } + switch s.SitAction { + case SitAction_Sit: + switch s.SitActionData.(type) { + case *ChairRequestSitActionDataSit: + if err = s.SitActionData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.SitAction) + return + } + } + return +} + +func (s *ChairRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SitAction : field : SitAction + s.SitAction = SitAction(reader.GetChar()) + switch s.SitAction { + case SitAction_Sit: + s.SitActionData = &ChairRequestSitActionDataSit{} + if err = s.SitActionData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SitRequestClientPacket :: Sit/stand request. +type SitRequestClientPacket struct { + byteSize int + + SitAction SitAction + SitActionData SitRequestSitActionData +} + +type SitRequestSitActionData interface { + protocol.EoData +} + +type SitRequestSitActionDataSit struct { + byteSize int + + CursorCoords protocol.Coords // The coordinates of the map cursor. +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitRequestSitActionDataSit) ByteSize() int { + return s.byteSize +} + +func (s *SitRequestSitActionDataSit) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CursorCoords : field : Coords + if err = s.CursorCoords.Serialize(writer); err != nil { + return + } + return +} + +func (s *SitRequestSitActionDataSit) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CursorCoords : field : Coords + if err = s.CursorCoords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s SitRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Sit +} + +func (s SitRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SitRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SitAction : field : SitAction + if err = writer.AddChar(int(s.SitAction)); err != nil { + return + } + switch s.SitAction { + case SitAction_Sit: + switch s.SitActionData.(type) { + case *SitRequestSitActionDataSit: + if err = s.SitActionData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.SitAction) + return + } + } + return +} + +func (s *SitRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SitAction : field : SitAction + s.SitAction = SitAction(reader.GetChar()) + switch s.SitAction { + case SitAction_Sit: + s.SitActionData = &SitRequestSitActionDataSit{} + if err = s.SitActionData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EmoteReportClientPacket :: Doing an emote. +type EmoteReportClientPacket struct { + byteSize int + + Emote protocol.Emote +} + +func (s EmoteReportClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Emote +} + +func (s EmoteReportClientPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EmoteReportClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *EmoteReportClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Emote : field : Emote + if err = writer.AddChar(int(s.Emote)); err != nil { + return + } + return +} + +func (s *EmoteReportClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Emote : field : Emote + s.Emote = protocol.Emote(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// FacePlayerClientPacket :: Facing a direction. +type FacePlayerClientPacket struct { + byteSize int + + Direction protocol.Direction +} + +func (s FacePlayerClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Face +} + +func (s FacePlayerClientPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *FacePlayerClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *FacePlayerClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *FacePlayerClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkAdminClientPacket :: Walking with #nowall. +type WalkAdminClientPacket struct { + byteSize int + + WalkAction WalkAction +} + +func (s WalkAdminClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkAdminClientPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkAdminClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkAdminClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // WalkAction : field : WalkAction + if err = s.WalkAction.Serialize(writer); err != nil { + return + } + return +} + +func (s *WalkAdminClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // WalkAction : field : WalkAction + if err = s.WalkAction.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkSpecClientPacket :: Walking through a player. +type WalkSpecClientPacket struct { + byteSize int + + WalkAction WalkAction +} + +func (s WalkSpecClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkSpecClientPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkSpecClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkSpecClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // WalkAction : field : WalkAction + if err = s.WalkAction.Serialize(writer); err != nil { + return + } + return +} + +func (s *WalkSpecClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // WalkAction : field : WalkAction + if err = s.WalkAction.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkPlayerClientPacket :: Walking. +type WalkPlayerClientPacket struct { + byteSize int + + WalkAction WalkAction +} + +func (s WalkPlayerClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkPlayerClientPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkPlayerClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkPlayerClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // WalkAction : field : WalkAction + if err = s.WalkAction.Serialize(writer); err != nil { + return + } + return +} + +func (s *WalkPlayerClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // WalkAction : field : WalkAction + if err = s.WalkAction.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BankOpenClientPacket :: Talked to a banker NPC. +type BankOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s BankOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Bank +} + +func (s BankOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BankOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BankOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *BankOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BankAddClientPacket :: Depositing gold. +type BankAddClientPacket struct { + byteSize int + + Amount int + SessionId int +} + +func (s BankAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Bank +} + +func (s BankAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BankAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BankAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Amount : field : int + if err = writer.AddInt(s.Amount); err != nil { + return + } + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + return +} + +func (s *BankAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Amount : field : int + s.Amount = reader.GetInt() + // SessionId : field : three + s.SessionId = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BankTakeClientPacket :: Withdrawing gold. +type BankTakeClientPacket struct { + byteSize int + + Amount int + SessionId int +} + +func (s BankTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Bank +} + +func (s BankTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BankTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BankTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Amount : field : int + if err = writer.AddInt(s.Amount); err != nil { + return + } + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + return +} + +func (s *BankTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Amount : field : int + s.Amount = reader.GetInt() + // SessionId : field : three + s.SessionId = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BarberBuyClientPacket :: Purchasing a hair-style. +type BarberBuyClientPacket struct { + byteSize int + + HairStyle int + HairColor int + SessionId int +} + +func (s BarberBuyClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Barber +} + +func (s BarberBuyClientPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BarberBuyClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BarberBuyClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HairStyle : field : char + if err = writer.AddChar(s.HairStyle); err != nil { + return + } + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *BarberBuyClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HairStyle : field : char + s.HairStyle = reader.GetChar() + // HairColor : field : char + s.HairColor = reader.GetChar() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BarberOpenClientPacket :: Talking to a barber NPC. +type BarberOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s BarberOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Barber +} + +func (s BarberOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BarberOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BarberOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *BarberOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerAddClientPacket :: Adding an item to a bank locker. +type LockerAddClientPacket struct { + byteSize int + + LockerCoords protocol.Coords + DepositItem net.ThreeItem +} + +func (s LockerAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LockerCoords : field : Coords + if err = s.LockerCoords.Serialize(writer); err != nil { + return + } + // DepositItem : field : ThreeItem + if err = s.DepositItem.Serialize(writer); err != nil { + return + } + return +} + +func (s *LockerAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LockerCoords : field : Coords + if err = s.LockerCoords.Deserialize(reader); err != nil { + return + } + // DepositItem : field : ThreeItem + if err = s.DepositItem.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerTakeClientPacket :: Taking an item from a bank locker. +type LockerTakeClientPacket struct { + byteSize int + + LockerCoords protocol.Coords + TakeItemId int +} + +func (s LockerTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LockerCoords : field : Coords + if err = s.LockerCoords.Serialize(writer); err != nil { + return + } + // TakeItemId : field : short + if err = writer.AddShort(s.TakeItemId); err != nil { + return + } + return +} + +func (s *LockerTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LockerCoords : field : Coords + if err = s.LockerCoords.Deserialize(reader); err != nil { + return + } + // TakeItemId : field : short + s.TakeItemId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerOpenClientPacket :: Opening a bank locker. +type LockerOpenClientPacket struct { + byteSize int + + LockerCoords protocol.Coords +} + +func (s LockerOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LockerCoords : field : Coords + if err = s.LockerCoords.Serialize(writer); err != nil { + return + } + return +} + +func (s *LockerOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LockerCoords : field : Coords + if err = s.LockerCoords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerBuyClientPacket :: Buying a locker space upgrade from a banker NPC. +type LockerBuyClientPacket struct { + byteSize int +} + +func (s LockerBuyClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerBuyClientPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerBuyClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerBuyClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 1 : dummy : char + if err = writer.AddChar(1); err != nil { + return + } + return +} + +func (s *LockerBuyClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 1 : dummy : char + reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenRequestClientPacket :: Request sleeping at an inn. +type CitizenRequestClientPacket struct { + byteSize int + + SessionId int + BehaviorId int +} + +func (s CitizenRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + return +} + +func (s *CitizenRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenAcceptClientPacket :: Confirm sleeping at an inn. +type CitizenAcceptClientPacket struct { + byteSize int + + SessionId int + BehaviorId int +} + +func (s CitizenAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + return +} + +func (s *CitizenAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenReplyClientPacket :: Subscribing to a town. +type CitizenReplyClientPacket struct { + byteSize int + + SessionId int + BehaviorId int + Answers []string +} + +func (s CitizenReplyClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenReplyClientPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenReplyClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenReplyClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + writer.AddByte(255) + // Answers : array : string + for ndx := 0; ndx < 3; ndx++ { + if len(s.Answers) != 3 { + err = fmt.Errorf("expected Answers with length 3, got %d", len(s.Answers)) + return + } + + if ndx > 0 { + writer.AddByte(255) + } + + if err = writer.AddString(s.Answers[ndx]); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *CitizenReplyClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : short + s.SessionId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Answers : array : string + for ndx := 0; ndx < 3; ndx++ { + s.Answers = append(s.Answers, "") + if s.Answers[ndx], err = reader.GetString(); err != nil { + return + } + + if ndx+1 < 3 { + if err = reader.NextChunk(); err != nil { + return + } + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenRemoveClientPacket :: Giving up citizenship of a town. +type CitizenRemoveClientPacket struct { + byteSize int + + BehaviorId int +} + +func (s CitizenRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + return +} + +func (s *CitizenRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenOpenClientPacket :: Talking to a citizenship NPC. +type CitizenOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s CitizenOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *CitizenOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopCreateClientPacket :: Crafting an item from a shop. +type ShopCreateClientPacket struct { + byteSize int + + CraftItemId int + SessionId int +} + +func (s ShopCreateClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopCreateClientPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopCreateClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopCreateClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CraftItemId : field : short + if err = writer.AddShort(s.CraftItemId); err != nil { + return + } + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *ShopCreateClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CraftItemId : field : short + s.CraftItemId = reader.GetShort() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopBuyClientPacket :: Purchasing an item from a shop. +type ShopBuyClientPacket struct { + byteSize int + + BuyItem net.Item + SessionId int +} + +func (s ShopBuyClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopBuyClientPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopBuyClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopBuyClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BuyItem : field : Item + if err = s.BuyItem.Serialize(writer); err != nil { + return + } + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *ShopBuyClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BuyItem : field : Item + if err = s.BuyItem.Deserialize(reader); err != nil { + return + } + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopSellClientPacket :: Selling an item to a shop. +type ShopSellClientPacket struct { + byteSize int + + SellItem net.Item + SessionId int +} + +func (s ShopSellClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopSellClientPacket) Action() net.PacketAction { + return net.PacketAction_Sell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopSellClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopSellClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SellItem : field : Item + if err = s.SellItem.Serialize(writer); err != nil { + return + } + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *ShopSellClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SellItem : field : Item + if err = s.SellItem.Deserialize(reader); err != nil { + return + } + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopOpenClientPacket :: Talking to a shop NPC. +type ShopOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s ShopOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *ShopOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillOpenClientPacket :: Talking to a skill master NPC. +type StatSkillOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s StatSkillOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *StatSkillOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillTakeClientPacket :: Learning a skill from a skill master NPC. +type StatSkillTakeClientPacket struct { + byteSize int + + SessionId int + SpellId int +} + +func (s StatSkillTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *StatSkillTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillRemoveClientPacket :: Forgetting a skill at a skill master NPC. +type StatSkillRemoveClientPacket struct { + byteSize int + + SessionId int + SpellId int +} + +func (s StatSkillRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *StatSkillRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillAddClientPacket :: Spending a stat point on a stat or skill. +type StatSkillAddClientPacket struct { + byteSize int + + ActionType TrainType + ActionTypeData StatSkillAddActionTypeData +} + +type StatSkillAddActionTypeData interface { + protocol.EoData +} + +type StatSkillAddActionTypeDataStat struct { + byteSize int + + StatId StatId +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillAddActionTypeDataStat) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillAddActionTypeDataStat) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // StatId : field : StatId + if err = writer.AddShort(int(s.StatId)); err != nil { + return + } + return +} + +func (s *StatSkillAddActionTypeDataStat) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // StatId : field : StatId + s.StatId = StatId(reader.GetShort()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type StatSkillAddActionTypeDataSkill struct { + byteSize int + + SpellId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillAddActionTypeDataSkill) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillAddActionTypeDataSkill) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *StatSkillAddActionTypeDataSkill) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s StatSkillAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ActionType : field : TrainType + if err = writer.AddChar(int(s.ActionType)); err != nil { + return + } + switch s.ActionType { + case Train_Stat: + switch s.ActionTypeData.(type) { + case *StatSkillAddActionTypeDataStat: + if err = s.ActionTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ActionType) + return + } + case Train_Skill: + switch s.ActionTypeData.(type) { + case *StatSkillAddActionTypeDataSkill: + if err = s.ActionTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ActionType) + return + } + } + return +} + +func (s *StatSkillAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ActionType : field : TrainType + s.ActionType = TrainType(reader.GetChar()) + switch s.ActionType { + case Train_Stat: + s.ActionTypeData = &StatSkillAddActionTypeDataStat{} + if err = s.ActionTypeData.Deserialize(reader); err != nil { + return + } + case Train_Skill: + s.ActionTypeData = &StatSkillAddActionTypeDataSkill{} + if err = s.ActionTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillJunkClientPacket :: Resetting stats at a skill master. +type StatSkillJunkClientPacket struct { + byteSize int + + SessionId int +} + +func (s StatSkillJunkClientPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillJunkClientPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillJunkClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillJunkClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *StatSkillJunkClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemUseClientPacket :: Using an item. +type ItemUseClientPacket struct { + byteSize int + + ItemId int +} + +func (s ItemUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + return +} + +func (s *ItemUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemDropClientPacket :: Dropping items on the ground. +type ItemDropClientPacket struct { + byteSize int + + Item net.ThreeItem + Coords ByteCoords // The official client sends 255 byte values for the coords if an item is dropped via. the GUI button. 255 values here should be interpreted to mean "drop at current coords". Otherwise, the x and y fields contain encoded numbers that must be explicitly. decoded to get the actual x and y values. +} + +func (s ItemDropClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemDropClientPacket) Action() net.PacketAction { + return net.PacketAction_Drop +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemDropClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemDropClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Item : field : ThreeItem + if err = s.Item.Serialize(writer); err != nil { + return + } + // Coords : field : ByteCoords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemDropClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Item : field : ThreeItem + if err = s.Item.Deserialize(reader); err != nil { + return + } + // Coords : field : ByteCoords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemJunkClientPacket :: Junking items. +type ItemJunkClientPacket struct { + byteSize int + + Item net.Item +} + +func (s ItemJunkClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemJunkClientPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemJunkClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemJunkClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Item : field : Item + if err = s.Item.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemJunkClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Item : field : Item + if err = s.Item.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemGetClientPacket :: Taking items from the ground. +type ItemGetClientPacket struct { + byteSize int + + ItemIndex int +} + +func (s ItemGetClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemGetClientPacket) Action() net.PacketAction { + return net.PacketAction_Get +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemGetClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemGetClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemIndex : field : short + if err = writer.AddShort(s.ItemIndex); err != nil { + return + } + return +} + +func (s *ItemGetClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemIndex : field : short + s.ItemIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardRemoveClientPacket :: Removing a post from a town board. +type BoardRemoveClientPacket struct { + byteSize int + + BoardId int + PostId int +} + +func (s BoardRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BoardId : field : short + if err = writer.AddShort(s.BoardId); err != nil { + return + } + // PostId : field : short + if err = writer.AddShort(s.PostId); err != nil { + return + } + return +} + +func (s *BoardRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BoardId : field : short + s.BoardId = reader.GetShort() + // PostId : field : short + s.PostId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardCreateClientPacket :: Posting a new message to a town board. +type BoardCreateClientPacket struct { + byteSize int + + BoardId int + PostSubject string + PostBody string +} + +func (s BoardCreateClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardCreateClientPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardCreateClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardCreateClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // BoardId : field : short + if err = writer.AddShort(s.BoardId); err != nil { + return + } + writer.AddByte(255) + // PostSubject : field : string + if err = writer.AddString(s.PostSubject); err != nil { + return + } + writer.AddByte(255) + // PostBody : field : string + if err = writer.AddString(s.PostBody); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *BoardCreateClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // BoardId : field : short + s.BoardId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // PostSubject : field : string + if s.PostSubject, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // PostBody : field : string + if s.PostBody, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardTakeClientPacket :: Reading a post on a town board. +type BoardTakeClientPacket struct { + byteSize int + + BoardId int + PostId int +} + +func (s BoardTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BoardId : field : short + if err = writer.AddShort(s.BoardId); err != nil { + return + } + // PostId : field : short + if err = writer.AddShort(s.PostId); err != nil { + return + } + return +} + +func (s *BoardTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BoardId : field : short + s.BoardId = reader.GetShort() + // PostId : field : short + s.PostId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardOpenClientPacket :: Opening a town board. +type BoardOpenClientPacket struct { + byteSize int + + BoardId int +} + +func (s BoardOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BoardId : field : short + if err = writer.AddShort(s.BoardId); err != nil { + return + } + return +} + +func (s *BoardOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BoardId : field : short + s.BoardId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxOpenClientPacket :: Opening the jukebox listing. +type JukeboxOpenClientPacket struct { + byteSize int + + Coords protocol.Coords +} + +func (s JukeboxOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *JukeboxOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxMsgClientPacket :: Requesting a song on a jukebox. +type JukeboxMsgClientPacket struct { + byteSize int + + TrackId int // This value is 0-indexed. +} + +func (s JukeboxMsgClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxMsgClientPacket) Action() net.PacketAction { + return net.PacketAction_Msg +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxMsgClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxMsgClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // TrackId : field : short + if err = writer.AddShort(s.TrackId); err != nil { + return + } + return +} + +func (s *JukeboxMsgClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 0 : field : char + reader.GetChar() + // 0 : field : char + reader.GetChar() + // TrackId : field : short + s.TrackId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxUseClientPacket :: Playing a note with the bard skill. +type JukeboxUseClientPacket struct { + byteSize int + + InstrumentId int + NoteId int +} + +func (s JukeboxUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // InstrumentId : field : char + if err = writer.AddChar(s.InstrumentId); err != nil { + return + } + // NoteId : field : char + if err = writer.AddChar(s.NoteId); err != nil { + return + } + return +} + +func (s *JukeboxUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // InstrumentId : field : char + s.InstrumentId = reader.GetChar() + // NoteId : field : char + s.NoteId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpAcceptClientPacket :: Accept a warp request from the server. +type WarpAcceptClientPacket struct { + byteSize int + + MapId int + SessionId int +} + +func (s WarpAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + return +} + +func (s *WarpAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapId : field : short + s.MapId = reader.GetShort() + // SessionId : field : short + s.SessionId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpTakeClientPacket :: Request to download a copy of the map. +type WarpTakeClientPacket struct { + byteSize int + + MapId int + SessionId int +} + +func (s WarpTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + return +} + +func (s *WarpTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapId : field : short + s.MapId = reader.GetShort() + // SessionId : field : short + s.SessionId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollRequestClientPacket :: Request for a player's paperdoll. +type PaperdollRequestClientPacket struct { + byteSize int + + PlayerId int +} + +func (s PaperdollRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *PaperdollRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollRemoveClientPacket :: Unequipping an item. +type PaperdollRemoveClientPacket struct { + byteSize int + + ItemId int + SubLoc int +} + +func (s PaperdollRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // SubLoc : field : char + if err = writer.AddChar(s.SubLoc); err != nil { + return + } + return +} + +func (s *PaperdollRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // SubLoc : field : char + s.SubLoc = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollAddClientPacket :: Equipping an item. +type PaperdollAddClientPacket struct { + byteSize int + + ItemId int + SubLoc int +} + +func (s PaperdollAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // SubLoc : field : char + if err = writer.AddChar(s.SubLoc); err != nil { + return + } + return +} + +func (s *PaperdollAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // SubLoc : field : char + s.SubLoc = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BookRequestClientPacket :: Request for a player's book. +type BookRequestClientPacket struct { + byteSize int + + PlayerId int +} + +func (s BookRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Book +} + +func (s BookRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BookRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *BookRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *BookRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MessagePingClientPacket :: #ping command request. +type MessagePingClientPacket struct { + byteSize int +} + +func (s MessagePingClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Message +} + +func (s MessagePingClientPacket) Action() net.PacketAction { + return net.PacketAction_Ping +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MessagePingClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *MessagePingClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 2 : dummy : short + if err = writer.AddShort(2); err != nil { + return + } + return +} + +func (s *MessagePingClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 2 : dummy : short + reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersAcceptClientPacket :: #find command request. +type PlayersAcceptClientPacket struct { + byteSize int + + Name string +} + +func (s PlayersAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *PlayersAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersRequestClientPacket :: Requesting a list of online players. +type PlayersRequestClientPacket struct { + byteSize int +} + +func (s PlayersRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *PlayersRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersListClientPacket :: Requesting a list of online friends. +type PlayersListClientPacket struct { + byteSize int +} + +func (s PlayersListClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersListClientPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersListClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersListClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *PlayersListClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DoorOpenClientPacket :: Opening a door. +type DoorOpenClientPacket struct { + byteSize int + + Coords protocol.Coords +} + +func (s DoorOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Door +} + +func (s DoorOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DoorOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *DoorOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *DoorOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestOpenClientPacket :: Opening a chest. +type ChestOpenClientPacket struct { + byteSize int + + Coords protocol.Coords +} + +func (s ChestOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChestOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestAddClientPacket :: Placing an item in to a chest. +type ChestAddClientPacket struct { + byteSize int + + Coords protocol.Coords + AddItem net.ThreeItem +} + +func (s ChestAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // AddItem : field : ThreeItem + if err = s.AddItem.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChestAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // AddItem : field : ThreeItem + if err = s.AddItem.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestTakeClientPacket :: Taking an item from a chest. +type ChestTakeClientPacket struct { + byteSize int + + Coords protocol.Coords + TakeItemId int +} + +func (s ChestTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // TakeItemId : field : short + if err = writer.AddShort(s.TakeItemId); err != nil { + return + } + return +} + +func (s *ChestTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // TakeItemId : field : short + s.TakeItemId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RefreshRequestClientPacket :: Requesting new info about nearby objects. +type RefreshRequestClientPacket struct { + byteSize int +} + +func (s RefreshRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Refresh +} + +func (s RefreshRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RefreshRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *RefreshRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *RefreshRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RangeRequestClientPacket :: Requesting info about nearby players and NPCs. +type RangeRequestClientPacket struct { + byteSize int + + PlayerIds []int + NpcIndexes []int +} + +func (s RangeRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Range +} + +func (s RangeRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RangeRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *RangeRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerIds : array : short + for ndx := 0; ndx < len(s.PlayerIds); ndx++ { + if err = writer.AddShort(s.PlayerIds[ndx]); err != nil { + return + } + } + + writer.AddByte(255) + // NpcIndexes : array : char + for ndx := 0; ndx < len(s.NpcIndexes); ndx++ { + if err = writer.AddChar(s.NpcIndexes[ndx]); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *RangeRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerIds : array : short + PlayerIdsRemaining := reader.Remaining() + for ndx := 0; ndx < PlayerIdsRemaining/2; ndx++ { + s.PlayerIds = append(s.PlayerIds, 0) + s.PlayerIds[ndx] = reader.GetShort() + } + + if err = reader.NextChunk(); err != nil { + return + } + // NpcIndexes : array : char + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.NpcIndexes = append(s.NpcIndexes, 0) + s.NpcIndexes[ndx] = reader.GetChar() + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayerRangeRequestClientPacket :: Requesting info about nearby players. +type PlayerRangeRequestClientPacket struct { + byteSize int + + PlayerIds []int +} + +func (s PlayerRangeRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_PlayerRange +} + +func (s PlayerRangeRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayerRangeRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayerRangeRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerIds : array : short + for ndx := 0; ndx < len(s.PlayerIds); ndx++ { + if err = writer.AddShort(s.PlayerIds[ndx]); err != nil { + return + } + } + + return +} + +func (s *PlayerRangeRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerIds : array : short + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.PlayerIds = append(s.PlayerIds, 0) + s.PlayerIds[ndx] = reader.GetShort() + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcRangeRequestClientPacket :: Requesting info about nearby NPCs. +type NpcRangeRequestClientPacket struct { + byteSize int + + NpcIndexes []int +} + +func (s NpcRangeRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_NpcRange +} + +func (s NpcRangeRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcRangeRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcRangeRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndexesLength : length : char + if err = writer.AddChar(len(s.NpcIndexes)); err != nil { + return + } + // 255 : field : byte + if err = writer.AddByte(255); err != nil { + return + } + // NpcIndexes : array : char + for ndx := 0; ndx < len(s.NpcIndexes); ndx++ { + if err = writer.AddChar(s.NpcIndexes[ndx]); err != nil { + return + } + } + + return +} + +func (s *NpcRangeRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndexesLength : length : char + npcIndexesLength := reader.GetChar() + // 255 : field : byte + reader.GetByte() + // NpcIndexes : array : char + for ndx := 0; ndx < npcIndexesLength; ndx++ { + s.NpcIndexes = append(s.NpcIndexes, 0) + s.NpcIndexes[ndx] = reader.GetChar() + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyRequestClientPacket :: Send party invite / join request. +type PartyRequestClientPacket struct { + byteSize int + + RequestType net.PartyRequestType + PlayerId int +} + +func (s PartyRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // RequestType : field : PartyRequestType + if err = writer.AddChar(int(s.RequestType)); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *PartyRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // RequestType : field : PartyRequestType + s.RequestType = net.PartyRequestType(reader.GetChar()) + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyAcceptClientPacket :: Accept party invite / join request. +type PartyAcceptClientPacket struct { + byteSize int + + RequestType net.PartyRequestType + InviterPlayerId int +} + +func (s PartyAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // RequestType : field : PartyRequestType + if err = writer.AddChar(int(s.RequestType)); err != nil { + return + } + // InviterPlayerId : field : short + if err = writer.AddShort(s.InviterPlayerId); err != nil { + return + } + return +} + +func (s *PartyAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // RequestType : field : PartyRequestType + s.RequestType = net.PartyRequestType(reader.GetChar()) + // InviterPlayerId : field : short + s.InviterPlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyRemoveClientPacket :: Remove player from a party. +type PartyRemoveClientPacket struct { + byteSize int + + PlayerId int +} + +func (s PartyRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *PartyRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyTakeClientPacket :: Request updated party info. +type PartyTakeClientPacket struct { + byteSize int + + MembersCount int +} + +func (s PartyTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MembersCount : field : char + if err = writer.AddChar(s.MembersCount); err != nil { + return + } + return +} + +func (s *PartyTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MembersCount : field : char + s.MembersCount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildRequestClientPacket :: Requested to create a guild. +type GuildRequestClientPacket struct { + byteSize int + + SessionId int + GuildTag string + GuildName string +} + +func (s GuildRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.AddByte(255) + // GuildName : field : string + if err = writer.AddString(s.GuildName); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *GuildRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : int + s.SessionId = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildName : field : string + if s.GuildName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildAcceptClientPacket :: Accept pending guild creation invite. +type GuildAcceptClientPacket struct { + byteSize int + + InviterPlayerId int +} + +func (s GuildAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 20202 : field : int + if err = writer.AddInt(20202); err != nil { + return + } + // InviterPlayerId : field : short + if err = writer.AddShort(s.InviterPlayerId); err != nil { + return + } + return +} + +func (s *GuildAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 20202 : field : int + reader.GetInt() + // InviterPlayerId : field : short + s.InviterPlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildRemoveClientPacket :: Leave guild. +type GuildRemoveClientPacket struct { + byteSize int + + SessionId int +} + +func (s GuildRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *GuildRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildAgreeClientPacket :: Update the guild description or rank list. +type GuildAgreeClientPacket struct { + byteSize int + + SessionId int + InfoType GuildInfoType + InfoTypeData GuildAgreeInfoTypeData +} + +type GuildAgreeInfoTypeData interface { + protocol.EoData +} + +type GuildAgreeInfoTypeDataDescription struct { + byteSize int + + Description string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAgreeInfoTypeDataDescription) ByteSize() int { + return s.byteSize +} + +func (s *GuildAgreeInfoTypeDataDescription) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Description : field : string + if err = writer.AddString(s.Description); err != nil { + return + } + return +} + +func (s *GuildAgreeInfoTypeDataDescription) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Description : field : string + if s.Description, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type GuildAgreeInfoTypeDataRanks struct { + byteSize int + + Ranks []string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAgreeInfoTypeDataRanks) ByteSize() int { + return s.byteSize +} + +func (s *GuildAgreeInfoTypeDataRanks) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + if len(s.Ranks) != 9 { + err = fmt.Errorf("expected Ranks with length 9, got %d", len(s.Ranks)) + return + } + + if err = writer.AddString(s.Ranks[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *GuildAgreeInfoTypeDataRanks) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + s.Ranks = append(s.Ranks, "") + if s.Ranks[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s GuildAgreeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildAgreeClientPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAgreeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildAgreeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // InfoType : field : GuildInfoType + if err = writer.AddShort(int(s.InfoType)); err != nil { + return + } + switch s.InfoType { + case GuildInfo_Description: + switch s.InfoTypeData.(type) { + case *GuildAgreeInfoTypeDataDescription: + if err = s.InfoTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.InfoType) + return + } + case GuildInfo_Ranks: + switch s.InfoTypeData.(type) { + case *GuildAgreeInfoTypeDataRanks: + if err = s.InfoTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.InfoType) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *GuildAgreeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : int + s.SessionId = reader.GetInt() + // InfoType : field : GuildInfoType + s.InfoType = GuildInfoType(reader.GetShort()) + switch s.InfoType { + case GuildInfo_Description: + s.InfoTypeData = &GuildAgreeInfoTypeDataDescription{} + if err = s.InfoTypeData.Deserialize(reader); err != nil { + return + } + case GuildInfo_Ranks: + s.InfoTypeData = &GuildAgreeInfoTypeDataRanks{} + if err = s.InfoTypeData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildCreateClientPacket :: Final confirm creating a guild. +type GuildCreateClientPacket struct { + byteSize int + + SessionId int + GuildTag string + GuildName string + Description string +} + +func (s GuildCreateClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildCreateClientPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildCreateClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildCreateClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.AddByte(255) + // GuildName : field : string + if err = writer.AddString(s.GuildName); err != nil { + return + } + writer.AddByte(255) + // Description : field : string + if err = writer.AddString(s.Description); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *GuildCreateClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : int + s.SessionId = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildName : field : string + if s.GuildName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Description : field : string + if s.Description, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildPlayerClientPacket :: Request to join a guild. +type GuildPlayerClientPacket struct { + byteSize int + + SessionId int + GuildTag string + RecruiterName string +} + +func (s GuildPlayerClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildPlayerClientPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildPlayerClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildPlayerClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.AddByte(255) + // RecruiterName : field : string + if err = writer.AddString(s.RecruiterName); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *GuildPlayerClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : int + s.SessionId = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // RecruiterName : field : string + if s.RecruiterName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildTakeClientPacket :: Request guild description, rank list, or bank balance. +type GuildTakeClientPacket struct { + byteSize int + + SessionId int + InfoType GuildInfoType + GuildTag string +} + +func (s GuildTakeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildTakeClientPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildTakeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildTakeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // InfoType : field : GuildInfoType + if err = writer.AddShort(int(s.InfoType)); err != nil { + return + } + // GuildTag : field : string + if len(s.GuildTag) != 3 { + err = fmt.Errorf("expected GuildTag with length 3, got %d", len(s.GuildTag)) + return + } + if err = writer.AddFixedString(s.GuildTag, 3); err != nil { + return + } + return +} + +func (s *GuildTakeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // InfoType : field : GuildInfoType + s.InfoType = GuildInfoType(reader.GetShort()) + // GuildTag : field : string + if s.GuildTag, err = reader.GetFixedString(3); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildUseClientPacket :: Accepted a join request. +type GuildUseClientPacket struct { + byteSize int + + PlayerId int +} + +func (s GuildUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *GuildUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildBuyClientPacket :: Deposit gold in to the guild bank. +type GuildBuyClientPacket struct { + byteSize int + + SessionId int + GoldAmount int +} + +func (s GuildBuyClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildBuyClientPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildBuyClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildBuyClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *GuildBuyClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildOpenClientPacket :: Talking to a guild master NPC. +type GuildOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s GuildOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *GuildOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildTellClientPacket :: Requested member list of a guild. +type GuildTellClientPacket struct { + byteSize int + + SessionId int + GuildIdentity string +} + +func (s GuildTellClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildTellClientPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildTellClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildTellClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // GuildIdentity : field : string + if err = writer.AddString(s.GuildIdentity); err != nil { + return + } + return +} + +func (s *GuildTellClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // GuildIdentity : field : string + if s.GuildIdentity, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildReportClientPacket :: Requested general information of a guild. +type GuildReportClientPacket struct { + byteSize int + + SessionId int + GuildIdentity string +} + +func (s GuildReportClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildReportClientPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReportClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildReportClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // GuildIdentity : field : string + if err = writer.AddString(s.GuildIdentity); err != nil { + return + } + return +} + +func (s *GuildReportClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // GuildIdentity : field : string + if s.GuildIdentity, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildJunkClientPacket :: Disband guild. +type GuildJunkClientPacket struct { + byteSize int + + SessionId int +} + +func (s GuildJunkClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildJunkClientPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildJunkClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildJunkClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *GuildJunkClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildKickClientPacket :: Kick member from guild. +type GuildKickClientPacket struct { + byteSize int + + SessionId int + MemberName string +} + +func (s GuildKickClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildKickClientPacket) Action() net.PacketAction { + return net.PacketAction_Kick +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildKickClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildKickClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // MemberName : field : string + if err = writer.AddString(s.MemberName); err != nil { + return + } + return +} + +func (s *GuildKickClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // MemberName : field : string + if s.MemberName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildRankClientPacket :: Update a member's rank. +type GuildRankClientPacket struct { + byteSize int + + SessionId int + Rank int + MemberName string +} + +func (s GuildRankClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildRankClientPacket) Action() net.PacketAction { + return net.PacketAction_Rank +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildRankClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildRankClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + // Rank : field : char + if err = writer.AddChar(s.Rank); err != nil { + return + } + // MemberName : field : string + if err = writer.AddString(s.MemberName); err != nil { + return + } + return +} + +func (s *GuildRankClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + // Rank : field : char + s.Rank = reader.GetChar() + // MemberName : field : string + if s.MemberName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellRequestClientPacket :: Begin spell chanting. +type SpellRequestClientPacket struct { + byteSize int + + SpellId int + Timestamp int +} + +func (s SpellRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + return +} + +func (s *SpellRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // Timestamp : field : three + s.Timestamp = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetSelfClientPacket :: Self-targeted spell cast. +type SpellTargetSelfClientPacket struct { + byteSize int + + Direction protocol.Direction + SpellId int + Timestamp int +} + +func (s SpellTargetSelfClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetSelfClientPacket) Action() net.PacketAction { + return net.PacketAction_TargetSelf +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetSelfClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetSelfClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + return +} + +func (s *SpellTargetSelfClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // SpellId : field : short + s.SpellId = reader.GetShort() + // Timestamp : field : three + s.Timestamp = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetOtherClientPacket :: Targeted spell cast. +type SpellTargetOtherClientPacket struct { + byteSize int + + TargetType SpellTargetType + PreviousTimestamp int + SpellId int + VictimId int + Timestamp int +} + +func (s SpellTargetOtherClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetOtherClientPacket) Action() net.PacketAction { + return net.PacketAction_TargetOther +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetOtherClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetOtherClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TargetType : field : SpellTargetType + if err = writer.AddChar(int(s.TargetType)); err != nil { + return + } + // PreviousTimestamp : field : three + if err = writer.AddThree(s.PreviousTimestamp); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // VictimId : field : short + if err = writer.AddShort(s.VictimId); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + return +} + +func (s *SpellTargetOtherClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TargetType : field : SpellTargetType + s.TargetType = SpellTargetType(reader.GetChar()) + // PreviousTimestamp : field : three + s.PreviousTimestamp = reader.GetThree() + // SpellId : field : short + s.SpellId = reader.GetShort() + // VictimId : field : short + s.VictimId = reader.GetShort() + // Timestamp : field : three + s.Timestamp = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetGroupClientPacket :: Group spell cast. +type SpellTargetGroupClientPacket struct { + byteSize int + + SpellId int + Timestamp int +} + +func (s SpellTargetGroupClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetGroupClientPacket) Action() net.PacketAction { + return net.PacketAction_TargetGroup +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetGroupClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetGroupClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + return +} + +func (s *SpellTargetGroupClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // Timestamp : field : three + s.Timestamp = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellUseClientPacket :: Raise arm to cast a spell (vestigial). +type SpellUseClientPacket struct { + byteSize int + + Direction protocol.Direction +} + +func (s SpellUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *SpellUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeRequestClientPacket :: Requesting a trade with another player. +type TradeRequestClientPacket struct { + byteSize int + + PlayerId int +} + +func (s TradeRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 138 : field : char + if err = writer.AddChar(138); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *TradeRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 138 : field : char + reader.GetChar() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeAcceptClientPacket :: Accepting a trade request. +type TradeAcceptClientPacket struct { + byteSize int + + PlayerId int +} + +func (s TradeAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *TradeAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 0 : field : char + reader.GetChar() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeRemoveClientPacket :: Remove an item from the trade screen. +type TradeRemoveClientPacket struct { + byteSize int + + ItemId int +} + +func (s TradeRemoveClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeRemoveClientPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeRemoveClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeRemoveClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + return +} + +func (s *TradeRemoveClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeAgreeClientPacket :: Mark trade as agreed. +type TradeAgreeClientPacket struct { + byteSize int + + Agree bool +} + +func (s TradeAgreeClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeAgreeClientPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeAgreeClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeAgreeClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Agree : field : bool + if s.Agree { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + return +} + +func (s *TradeAgreeClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Agree : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Agree = true + } else { + s.Agree = false + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeAddClientPacket :: Add an item to the trade screen. +type TradeAddClientPacket struct { + byteSize int + + AddItem net.Item +} + +func (s TradeAddClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeAddClientPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeAddClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeAddClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // AddItem : field : Item + if err = s.AddItem.Serialize(writer); err != nil { + return + } + return +} + +func (s *TradeAddClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // AddItem : field : Item + if err = s.AddItem.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeCloseClientPacket :: Cancel the trade. +type TradeCloseClientPacket struct { + byteSize int +} + +func (s TradeCloseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeCloseClientPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeCloseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeCloseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 0 : dummy : char + if err = writer.AddChar(0); err != nil { + return + } + return +} + +func (s *TradeCloseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 0 : dummy : char + reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestUseClientPacket :: Talking to a quest NPC. +type QuestUseClientPacket struct { + byteSize int + + NpcIndex int + QuestId int // Quest ID is 0 unless the player explicitly selects a quest from the quest switcher. +} + +func (s QuestUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // QuestId : field : short + if err = writer.AddShort(s.QuestId); err != nil { + return + } + return +} + +func (s *QuestUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // QuestId : field : short + s.QuestId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestAcceptClientPacket :: Response to a quest NPC dialog. +type QuestAcceptClientPacket struct { + byteSize int + + SessionId int + DialogId int + QuestId int + NpcIndex int + ReplyType DialogReply + ReplyTypeData QuestAcceptReplyTypeData +} + +type QuestAcceptReplyTypeData interface { + protocol.EoData +} + +type QuestAcceptReplyTypeDataLink struct { + byteSize int + + Action int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestAcceptReplyTypeDataLink) ByteSize() int { + return s.byteSize +} + +func (s *QuestAcceptReplyTypeDataLink) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Action : field : char + if err = writer.AddChar(s.Action); err != nil { + return + } + return +} + +func (s *QuestAcceptReplyTypeDataLink) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Action : field : char + s.Action = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s QuestAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // DialogId : field : short + if err = writer.AddShort(s.DialogId); err != nil { + return + } + // QuestId : field : short + if err = writer.AddShort(s.QuestId); err != nil { + return + } + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // ReplyType : field : DialogReply + if err = writer.AddChar(int(s.ReplyType)); err != nil { + return + } + switch s.ReplyType { + case DialogReply_Link: + switch s.ReplyTypeData.(type) { + case *QuestAcceptReplyTypeDataLink: + if err = s.ReplyTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyType) + return + } + } + return +} + +func (s *QuestAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // DialogId : field : short + s.DialogId = reader.GetShort() + // QuestId : field : short + s.QuestId = reader.GetShort() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // ReplyType : field : DialogReply + s.ReplyType = DialogReply(reader.GetChar()) + switch s.ReplyType { + case DialogReply_Link: + s.ReplyTypeData = &QuestAcceptReplyTypeDataLink{} + if err = s.ReplyTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestListClientPacket :: Quest history / progress request. +type QuestListClientPacket struct { + byteSize int + + Page net.QuestPage +} + +func (s QuestListClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestListClientPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestListClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestListClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Page : field : QuestPage + if err = writer.AddChar(int(s.Page)); err != nil { + return + } + return +} + +func (s *QuestListClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Page : field : QuestPage + s.Page = net.QuestPage(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MarriageOpenClientPacket :: Talking to a law NPC. +type MarriageOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s MarriageOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Marriage +} + +func (s MarriageOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MarriageOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *MarriageOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + return +} + +func (s *MarriageOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MarriageRequestClientPacket :: Requesting marriage approval. +type MarriageRequestClientPacket struct { + byteSize int + + RequestType MarriageRequestType + SessionId int + Name string +} + +func (s MarriageRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Marriage +} + +func (s MarriageRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MarriageRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *MarriageRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // RequestType : field : MarriageRequestType + if err = writer.AddChar(int(s.RequestType)); err != nil { + return + } + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *MarriageRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // RequestType : field : MarriageRequestType + s.RequestType = MarriageRequestType(reader.GetChar()) + // SessionId : field : int + s.SessionId = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestAcceptClientPacket :: Accepting a marriage request. +type PriestAcceptClientPacket struct { + byteSize int + + SessionId int +} + +func (s PriestAcceptClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestAcceptClientPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestAcceptClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestAcceptClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + return +} + +func (s *PriestAcceptClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestOpenClientPacket :: Talking to a priest NPC. +type PriestOpenClientPacket struct { + byteSize int + + NpcIndex int +} + +func (s PriestOpenClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestOpenClientPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestOpenClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestOpenClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : int + if err = writer.AddInt(s.NpcIndex); err != nil { + return + } + return +} + +func (s *PriestOpenClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : int + s.NpcIndex = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestRequestClientPacket :: Requesting marriage at a priest. +type PriestRequestClientPacket struct { + byteSize int + + SessionId int + Name string +} + +func (s PriestRequestClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestRequestClientPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestRequestClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestRequestClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *PriestRequestClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : int + s.SessionId = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestUseClientPacket :: Saying "I do" at a wedding. +type PriestUseClientPacket struct { + byteSize int + + SessionId int +} + +func (s PriestUseClientPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestUseClientPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestUseClientPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestUseClientPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *PriestUseClientPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/net/client/structs_generated.go b/v3/protocol/net/client/structs_generated.go new file mode 100644 index 0000000..29f80c4 --- /dev/null +++ b/v3/protocol/net/client/structs_generated.go @@ -0,0 +1,99 @@ +package client + +import ( + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/protocol" +) + +// ByteCoords :: Map coordinates with raw 1-byte values. +type ByteCoords struct { + byteSize int + + X int + Y int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ByteCoords) ByteSize() int { + return s.byteSize +} + +func (s *ByteCoords) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : byte + if err = writer.AddByte(s.X); err != nil { + return + } + // Y : field : byte + if err = writer.AddByte(s.Y); err != nil { + return + } + return +} + +func (s *ByteCoords) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : byte + s.X = int(reader.GetByte()) + // Y : field : byte + s.Y = int(reader.GetByte()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkAction :: Common data between walk packets. +type WalkAction struct { + byteSize int + + Direction protocol.Direction + Timestamp int + Coords protocol.Coords +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkAction) ByteSize() int { + return s.byteSize +} + +func (s *WalkAction) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // Timestamp : field : three + if err = writer.AddThree(s.Timestamp); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *WalkAction) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // Timestamp : field : three + s.Timestamp = reader.GetThree() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/net/enums_generated.go b/v3/protocol/net/enums_generated.go new file mode 100644 index 0000000..35d2855 --- /dev/null +++ b/v3/protocol/net/enums_generated.go @@ -0,0 +1,338 @@ +package net + +import "fmt" + +// PacketFamily :: The type of operation that a packet performs. Part of the unique packet ID. +type PacketFamily int + +const ( + PacketFamily_Connection PacketFamily = iota + 1 + PacketFamily_Account + PacketFamily_Character + PacketFamily_Login + PacketFamily_Welcome + PacketFamily_Walk + PacketFamily_Face + PacketFamily_Chair + PacketFamily_Emote + PacketFamily_Attack = 11 + PacketFamily_Spell = 12 + PacketFamily_Shop = 13 + PacketFamily_Item = 14 + PacketFamily_StatSkill = 16 + PacketFamily_Global = 17 + PacketFamily_Talk = 18 + PacketFamily_Warp = 19 + PacketFamily_Jukebox = 21 + PacketFamily_Players = 22 + PacketFamily_Avatar = 23 + PacketFamily_Party = 24 + PacketFamily_Refresh = 25 + PacketFamily_Npc = 26 + PacketFamily_PlayerRange = 27 + PacketFamily_NpcRange = 28 + PacketFamily_Range = 29 + PacketFamily_Paperdoll = 30 + PacketFamily_Effect = 31 + PacketFamily_Trade = 32 + PacketFamily_Chest = 33 + PacketFamily_Door = 34 + PacketFamily_Message = 35 + PacketFamily_Bank = 36 + PacketFamily_Locker = 37 + PacketFamily_Barber = 38 + PacketFamily_Guild = 39 + PacketFamily_Music = 40 + PacketFamily_Sit = 41 + PacketFamily_Recover = 42 + PacketFamily_Board = 43 + PacketFamily_Cast = 44 + PacketFamily_Arena = 45 + PacketFamily_Priest = 46 + PacketFamily_Marriage = 47 + PacketFamily_AdminInteract = 48 + PacketFamily_Citizen = 49 + PacketFamily_Quest = 50 + PacketFamily_Book = 51 + PacketFamily_Error = 250 + PacketFamily_Init = 255 +) + +// String converts a PacketFamily value into its string representation +func (e PacketFamily) String() (string, error) { + switch e { + case PacketFamily_Connection: + return "Connection", nil + case PacketFamily_Account: + return "Account", nil + case PacketFamily_Character: + return "Character", nil + case PacketFamily_Login: + return "Login", nil + case PacketFamily_Welcome: + return "Welcome", nil + case PacketFamily_Walk: + return "Walk", nil + case PacketFamily_Face: + return "Face", nil + case PacketFamily_Chair: + return "Chair", nil + case PacketFamily_Emote: + return "Emote", nil + case PacketFamily_Attack: + return "Attack", nil + case PacketFamily_Spell: + return "Spell", nil + case PacketFamily_Shop: + return "Shop", nil + case PacketFamily_Item: + return "Item", nil + case PacketFamily_StatSkill: + return "StatSkill", nil + case PacketFamily_Global: + return "Global", nil + case PacketFamily_Talk: + return "Talk", nil + case PacketFamily_Warp: + return "Warp", nil + case PacketFamily_Jukebox: + return "Jukebox", nil + case PacketFamily_Players: + return "Players", nil + case PacketFamily_Avatar: + return "Avatar", nil + case PacketFamily_Party: + return "Party", nil + case PacketFamily_Refresh: + return "Refresh", nil + case PacketFamily_Npc: + return "Npc", nil + case PacketFamily_PlayerRange: + return "PlayerRange", nil + case PacketFamily_NpcRange: + return "NpcRange", nil + case PacketFamily_Range: + return "Range", nil + case PacketFamily_Paperdoll: + return "Paperdoll", nil + case PacketFamily_Effect: + return "Effect", nil + case PacketFamily_Trade: + return "Trade", nil + case PacketFamily_Chest: + return "Chest", nil + case PacketFamily_Door: + return "Door", nil + case PacketFamily_Message: + return "Message", nil + case PacketFamily_Bank: + return "Bank", nil + case PacketFamily_Locker: + return "Locker", nil + case PacketFamily_Barber: + return "Barber", nil + case PacketFamily_Guild: + return "Guild", nil + case PacketFamily_Music: + return "Music", nil + case PacketFamily_Sit: + return "Sit", nil + case PacketFamily_Recover: + return "Recover", nil + case PacketFamily_Board: + return "Board", nil + case PacketFamily_Cast: + return "Cast", nil + case PacketFamily_Arena: + return "Arena", nil + case PacketFamily_Priest: + return "Priest", nil + case PacketFamily_Marriage: + return "Marriage", nil + case PacketFamily_AdminInteract: + return "AdminInteract", nil + case PacketFamily_Citizen: + return "Citizen", nil + case PacketFamily_Quest: + return "Quest", nil + case PacketFamily_Book: + return "Book", nil + case PacketFamily_Error: + return "Error", nil + case PacketFamily_Init: + return "Init", nil + default: + return "", fmt.Errorf("could not convert value %d of type PacketFamily to string", e) + } +} + +// PacketAction :: The specific action that a packet performs. Part of the unique packet ID. +type PacketAction int + +const ( + PacketAction_Request PacketAction = iota + 1 + PacketAction_Accept + PacketAction_Reply + PacketAction_Remove + PacketAction_Agree + PacketAction_Create + PacketAction_Add + PacketAction_Player + PacketAction_Take + PacketAction_Use + PacketAction_Buy + PacketAction_Sell + PacketAction_Open + PacketAction_Close + PacketAction_Msg + PacketAction_Spec + PacketAction_Admin + PacketAction_List + PacketAction_Tell = 20 + PacketAction_Report = 21 + PacketAction_Announce = 22 + PacketAction_Server = 23 + PacketAction_Drop = 24 + PacketAction_Junk = 25 + PacketAction_Obtain = 26 + PacketAction_Get = 27 + PacketAction_Kick = 28 + PacketAction_Rank = 29 + PacketAction_TargetSelf = 30 + PacketAction_TargetOther = 31 + PacketAction_TargetGroup = 33 + PacketAction_Dialog = 34 + PacketAction_Ping = 240 + PacketAction_Pong = 241 + PacketAction_Net242 = 242 + PacketAction_Net243 = 243 + PacketAction_Net244 = 244 + PacketAction_Error = 250 + PacketAction_Init = 255 +) + +// String converts a PacketAction value into its string representation +func (e PacketAction) String() (string, error) { + switch e { + case PacketAction_Request: + return "Request", nil + case PacketAction_Accept: + return "Accept", nil + case PacketAction_Reply: + return "Reply", nil + case PacketAction_Remove: + return "Remove", nil + case PacketAction_Agree: + return "Agree", nil + case PacketAction_Create: + return "Create", nil + case PacketAction_Add: + return "Add", nil + case PacketAction_Player: + return "Player", nil + case PacketAction_Take: + return "Take", nil + case PacketAction_Use: + return "Use", nil + case PacketAction_Buy: + return "Buy", nil + case PacketAction_Sell: + return "Sell", nil + case PacketAction_Open: + return "Open", nil + case PacketAction_Close: + return "Close", nil + case PacketAction_Msg: + return "Msg", nil + case PacketAction_Spec: + return "Spec", nil + case PacketAction_Admin: + return "Admin", nil + case PacketAction_List: + return "List", nil + case PacketAction_Tell: + return "Tell", nil + case PacketAction_Report: + return "Report", nil + case PacketAction_Announce: + return "Announce", nil + case PacketAction_Server: + return "Server", nil + case PacketAction_Drop: + return "Drop", nil + case PacketAction_Junk: + return "Junk", nil + case PacketAction_Obtain: + return "Obtain", nil + case PacketAction_Get: + return "Get", nil + case PacketAction_Kick: + return "Kick", nil + case PacketAction_Rank: + return "Rank", nil + case PacketAction_TargetSelf: + return "TargetSelf", nil + case PacketAction_TargetOther: + return "TargetOther", nil + case PacketAction_TargetGroup: + return "TargetGroup", nil + case PacketAction_Dialog: + return "Dialog", nil + case PacketAction_Ping: + return "Ping", nil + case PacketAction_Pong: + return "Pong", nil + case PacketAction_Net242: + return "Net242", nil + case PacketAction_Net243: + return "Net243", nil + case PacketAction_Net244: + return "Net244", nil + case PacketAction_Error: + return "Error", nil + case PacketAction_Init: + return "Init", nil + default: + return "", fmt.Errorf("could not convert value %d of type PacketAction to string", e) + } +} + +// QuestPage :: A page in the Quest menu. +type QuestPage int + +const ( + QuestPage_Progress QuestPage = iota + 1 + QuestPage_History +) + +// String converts a QuestPage value into its string representation +func (e QuestPage) String() (string, error) { + switch e { + case QuestPage_Progress: + return "Progress", nil + case QuestPage_History: + return "History", nil + default: + return "", fmt.Errorf("could not convert value %d of type QuestPage to string", e) + } +} + +// PartyRequestType :: Whether a player is requesting to join a party, or inviting someone to join theirs. +type PartyRequestType int + +const ( + PartyRequest_Join PartyRequestType = iota + PartyRequest_Invite +) + +// String converts a PartyRequestType value into its string representation +func (e PartyRequestType) String() (string, error) { + switch e { + case PartyRequest_Join: + return "Join", nil + case PartyRequest_Invite: + return "Invite", nil + default: + return "", fmt.Errorf("could not convert value %d of type PartyRequestType to string", e) + } +} diff --git a/v3/protocol/net/package.go b/v3/protocol/net/package.go new file mode 100644 index 0000000..f23b367 --- /dev/null +++ b/v3/protocol/net/package.go @@ -0,0 +1,2 @@ +// Package net provides EO network protocol data structures. Types and functions in this package are primarily generated from the eo-protocol XML specification. +package net diff --git a/v3/protocol/net/packet.go b/v3/protocol/net/packet.go new file mode 100644 index 0000000..f360e94 --- /dev/null +++ b/v3/protocol/net/packet.go @@ -0,0 +1,18 @@ +package net + +import ( + "github.com/ethanmoffat/eolib-go/v3/protocol" +) + +// Packet represents a packet object in the EO network protocol. +type Packet interface { + protocol.EoData + + Family() PacketFamily // Family gets the family of the EO packet. + Action() PacketAction // Action gets the action of the EO packet.EoData +} + +// PacketId gets an integer representation of the packet ID from a [PacketFamily] and [PacketAction] +func PacketId(family PacketFamily, action PacketAction) int { + return ((int(action) & 0xFF) << 8) | (int(family) & 0xFF) +} diff --git a/v3/protocol/net/packets_generated.go b/v3/protocol/net/packets_generated.go new file mode 100644 index 0000000..9d9f1a1 --- /dev/null +++ b/v3/protocol/net/packets_generated.go @@ -0,0 +1 @@ +package net diff --git a/v3/protocol/net/server/enums_generated.go b/v3/protocol/net/server/enums_generated.go new file mode 100644 index 0000000..322cd0a --- /dev/null +++ b/v3/protocol/net/server/enums_generated.go @@ -0,0 +1,718 @@ +package server + +import "fmt" + +// InitReply :: Reply code sent with INIT_INIT packet. +type InitReply int + +const ( + InitReply_OutOfDate InitReply = iota + 1 + InitReply_Ok + InitReply_Banned // The official client won't display a message until the connection from the server is closed. + InitReply_WarpMap + InitReply_FileEmf + InitReply_FileEif + InitReply_FileEnf + InitReply_FileEsf + InitReply_PlayersList + InitReply_MapMutation + InitReply_PlayersListFriends + InitReply_FileEcf +) + +// String converts a InitReply value into its string representation +func (e InitReply) String() (string, error) { + switch e { + case InitReply_OutOfDate: + return "OutOfDate", nil + case InitReply_Ok: + return "Ok", nil + case InitReply_Banned: + return "Banned", nil + case InitReply_WarpMap: + return "WarpMap", nil + case InitReply_FileEmf: + return "FileEmf", nil + case InitReply_FileEif: + return "FileEif", nil + case InitReply_FileEnf: + return "FileEnf", nil + case InitReply_FileEsf: + return "FileEsf", nil + case InitReply_PlayersList: + return "PlayersList", nil + case InitReply_MapMutation: + return "MapMutation", nil + case InitReply_PlayersListFriends: + return "PlayersListFriends", nil + case InitReply_FileEcf: + return "FileEcf", nil + default: + return "", fmt.Errorf("could not convert value %d of type InitReply to string", e) + } +} + +// InitBanType :: Ban type sent with INIT_INIT packet. The official client treats a value >= 2 as Permanent. Otherwise, it's Temporary. +type InitBanType int + +const ( + InitBan_Temporary InitBanType = iota + 1 + InitBan_Permanent +) + +// String converts a InitBanType value into its string representation +func (e InitBanType) String() (string, error) { + switch e { + case InitBan_Temporary: + return "Temporary", nil + case InitBan_Permanent: + return "Permanent", nil + default: + return "", fmt.Errorf("could not convert value %d of type InitBanType to string", e) + } +} + +// CharacterIcon :: Icon displayed in paperdolls, books, and the online list. +type CharacterIcon int + +const ( + CharacterIcon_Player CharacterIcon = iota + 1 + CharacterIcon_Gm = 4 + CharacterIcon_Hgm = 5 + CharacterIcon_Party = 6 + CharacterIcon_GmParty = 9 + CharacterIcon_HgmParty = 10 +) + +// String converts a CharacterIcon value into its string representation +func (e CharacterIcon) String() (string, error) { + switch e { + case CharacterIcon_Player: + return "Player", nil + case CharacterIcon_Gm: + return "Gm", nil + case CharacterIcon_Hgm: + return "Hgm", nil + case CharacterIcon_Party: + return "Party", nil + case CharacterIcon_GmParty: + return "GmParty", nil + case CharacterIcon_HgmParty: + return "HgmParty", nil + default: + return "", fmt.Errorf("could not convert value %d of type CharacterIcon to string", e) + } +} + +// AvatarChangeType :: How a player's appearance is changing. +type AvatarChangeType int + +const ( + AvatarChange_Equipment AvatarChangeType = iota + 1 + AvatarChange_Hair + AvatarChange_HairColor +) + +// String converts a AvatarChangeType value into its string representation +func (e AvatarChangeType) String() (string, error) { + switch e { + case AvatarChange_Equipment: + return "Equipment", nil + case AvatarChange_Hair: + return "Hair", nil + case AvatarChange_HairColor: + return "HairColor", nil + default: + return "", fmt.Errorf("could not convert value %d of type AvatarChangeType to string", e) + } +} + +// TalkReply :: Reply code sent with TALK_REPLY packet. +type TalkReply int + +const ( + TalkReply_NotFound TalkReply = iota + 1 +) + +// String converts a TalkReply value into its string representation +func (e TalkReply) String() (string, error) { + switch e { + case TalkReply_NotFound: + return "NotFound", nil + default: + return "", fmt.Errorf("could not convert value %d of type TalkReply to string", e) + } +} + +// SitState :: Indicates how a player is sitting (or not sitting). +type SitState int + +const ( + SitState_Stand SitState = iota + SitState_Chair + SitState_Floor +) + +// String converts a SitState value into its string representation +func (e SitState) String() (string, error) { + switch e { + case SitState_Stand: + return "Stand", nil + case SitState_Chair: + return "Chair", nil + case SitState_Floor: + return "Floor", nil + default: + return "", fmt.Errorf("could not convert value %d of type SitState to string", e) + } +} + +// MapEffect :: An effect that occurs for all players on a map. +type MapEffect int + +const ( + MapEffect_Quake MapEffect = iota + 1 +) + +// String converts a MapEffect value into its string representation +func (e MapEffect) String() (string, error) { + switch e { + case MapEffect_Quake: + return "Quake", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapEffect to string", e) + } +} + +// GuildReply :: Reply code sent with GUILD_REPLY packet. +type GuildReply int + +const ( + GuildReply_Busy GuildReply = iota + 1 + GuildReply_NotApproved + GuildReply_AlreadyMember + GuildReply_NoCandidates + GuildReply_Exists + GuildReply_CreateBegin + GuildReply_CreateAddConfirm + GuildReply_CreateAdd + GuildReply_RecruiterOffline + GuildReply_RecruiterNotHere + GuildReply_RecruiterWrongGuild + GuildReply_NotRecruiter + GuildReply_JoinRequest + GuildReply_NotPresent + GuildReply_AccountLow + GuildReply_Accepted + GuildReply_NotFound + GuildReply_Updated + GuildReply_RanksUpdated + GuildReply_RemoveLeader + GuildReply_RemoveNotMember + GuildReply_Removed + GuildReply_RankingLeader + GuildReply_RankingNotMember +) + +// String converts a GuildReply value into its string representation +func (e GuildReply) String() (string, error) { + switch e { + case GuildReply_Busy: + return "Busy", nil + case GuildReply_NotApproved: + return "NotApproved", nil + case GuildReply_AlreadyMember: + return "AlreadyMember", nil + case GuildReply_NoCandidates: + return "NoCandidates", nil + case GuildReply_Exists: + return "Exists", nil + case GuildReply_CreateBegin: + return "CreateBegin", nil + case GuildReply_CreateAddConfirm: + return "CreateAddConfirm", nil + case GuildReply_CreateAdd: + return "CreateAdd", nil + case GuildReply_RecruiterOffline: + return "RecruiterOffline", nil + case GuildReply_RecruiterNotHere: + return "RecruiterNotHere", nil + case GuildReply_RecruiterWrongGuild: + return "RecruiterWrongGuild", nil + case GuildReply_NotRecruiter: + return "NotRecruiter", nil + case GuildReply_JoinRequest: + return "JoinRequest", nil + case GuildReply_NotPresent: + return "NotPresent", nil + case GuildReply_AccountLow: + return "AccountLow", nil + case GuildReply_Accepted: + return "Accepted", nil + case GuildReply_NotFound: + return "NotFound", nil + case GuildReply_Updated: + return "Updated", nil + case GuildReply_RanksUpdated: + return "RanksUpdated", nil + case GuildReply_RemoveLeader: + return "RemoveLeader", nil + case GuildReply_RemoveNotMember: + return "RemoveNotMember", nil + case GuildReply_Removed: + return "Removed", nil + case GuildReply_RankingLeader: + return "RankingLeader", nil + case GuildReply_RankingNotMember: + return "RankingNotMember", nil + default: + return "", fmt.Errorf("could not convert value %d of type GuildReply to string", e) + } +} + +// InnUnsubscribeReply :: Reply code sent with CITIZEN_REMOVE packet. Indicates the result of trying to give up citizenship to a town. +type InnUnsubscribeReply int + +const ( + InnUnsubscribeReply_NotCitizen InnUnsubscribeReply = iota + InnUnsubscribeReply_Unsubscribed +) + +// String converts a InnUnsubscribeReply value into its string representation +func (e InnUnsubscribeReply) String() (string, error) { + switch e { + case InnUnsubscribeReply_NotCitizen: + return "NotCitizen", nil + case InnUnsubscribeReply_Unsubscribed: + return "Unsubscribed", nil + default: + return "", fmt.Errorf("could not convert value %d of type InnUnsubscribeReply to string", e) + } +} + +// CharacterReply :: Reply code sent with CHARACTER_REPLY packet. +type CharacterReply int + +const ( + CharacterReply_Exists CharacterReply = iota + 1 + CharacterReply_Full // Only sent in reply to Character_Create packets. Displays the same message as CharacterReply.Full3 in the official client. + CharacterReply_Full3 // Only sent in reply to Character_Request packets. Displays the same message as CharacterReply.Full in the official client. + CharacterReply_NotApproved + CharacterReply_Ok + CharacterReply_Deleted +) + +// String converts a CharacterReply value into its string representation +func (e CharacterReply) String() (string, error) { + switch e { + case CharacterReply_Exists: + return "Exists", nil + case CharacterReply_Full: + return "Full", nil + case CharacterReply_Full3: + return "Full3", nil + case CharacterReply_NotApproved: + return "NotApproved", nil + case CharacterReply_Ok: + return "Ok", nil + case CharacterReply_Deleted: + return "Deleted", nil + default: + return "", fmt.Errorf("could not convert value %d of type CharacterReply to string", e) + } +} + +// SkillMasterReply :: Reply code sent with STATSKILL_REPLY packet. Indicates why an action was unsuccessful. +type SkillMasterReply int + +const ( + SkillMasterReply_RemoveItems SkillMasterReply = iota + 1 + SkillMasterReply_WrongClass +) + +// String converts a SkillMasterReply value into its string representation +func (e SkillMasterReply) String() (string, error) { + switch e { + case SkillMasterReply_RemoveItems: + return "RemoveItems", nil + case SkillMasterReply_WrongClass: + return "WrongClass", nil + default: + return "", fmt.Errorf("could not convert value %d of type SkillMasterReply to string", e) + } +} + +// AccountReply :: Reply code sent with ACCOUNT_REPLY packet. +type AccountReply int + +const ( + AccountReply_Exists AccountReply = iota + 1 + AccountReply_NotApproved + AccountReply_Created + AccountReply_ChangeFailed = 5 + AccountReply_Changed = 6 + AccountReply_RequestDenied = 7 +) + +// String converts a AccountReply value into its string representation +func (e AccountReply) String() (string, error) { + switch e { + case AccountReply_Exists: + return "Exists", nil + case AccountReply_NotApproved: + return "NotApproved", nil + case AccountReply_Created: + return "Created", nil + case AccountReply_ChangeFailed: + return "ChangeFailed", nil + case AccountReply_Changed: + return "Changed", nil + case AccountReply_RequestDenied: + return "RequestDenied", nil + default: + return "", fmt.Errorf("could not convert value %d of type AccountReply to string", e) + } +} + +// LoginReply :: Reply code sent with LOGIN_REPLY packet. Indicates the result of a login attempt. +type LoginReply int + +const ( + LoginReply_WrongUser LoginReply = iota + 1 + LoginReply_WrongUserPassword + LoginReply_Ok + LoginReply_Banned // The official client won't display a message until the connection from the server is closed. + LoginReply_LoggedIn + LoginReply_Busy // The official client won't display a message until the connection from the server is closed. +) + +// String converts a LoginReply value into its string representation +func (e LoginReply) String() (string, error) { + switch e { + case LoginReply_WrongUser: + return "WrongUser", nil + case LoginReply_WrongUserPassword: + return "WrongUserPassword", nil + case LoginReply_Ok: + return "Ok", nil + case LoginReply_Banned: + return "Banned", nil + case LoginReply_LoggedIn: + return "LoggedIn", nil + case LoginReply_Busy: + return "Busy", nil + default: + return "", fmt.Errorf("could not convert value %d of type LoginReply to string", e) + } +} + +// DialogEntryType :: The type of an entry in a quest dialog. +type DialogEntryType int + +const ( + DialogEntry_Text DialogEntryType = iota + 1 + DialogEntry_Link +) + +// String converts a DialogEntryType value into its string representation +func (e DialogEntryType) String() (string, error) { + switch e { + case DialogEntry_Text: + return "Text", nil + case DialogEntry_Link: + return "Link", nil + default: + return "", fmt.Errorf("could not convert value %d of type DialogEntryType to string", e) + } +} + +// QuestRequirementIcon :: Icon displayed for each quest in the Quest Progress window. +type QuestRequirementIcon int + +const ( + QuestRequirementIcon_Item QuestRequirementIcon = iota + 3 + QuestRequirementIcon_Talk = 5 + QuestRequirementIcon_Kill = 8 + QuestRequirementIcon_Step = 10 +) + +// String converts a QuestRequirementIcon value into its string representation +func (e QuestRequirementIcon) String() (string, error) { + switch e { + case QuestRequirementIcon_Item: + return "Item", nil + case QuestRequirementIcon_Talk: + return "Talk", nil + case QuestRequirementIcon_Kill: + return "Kill", nil + case QuestRequirementIcon_Step: + return "Step", nil + default: + return "", fmt.Errorf("could not convert value %d of type QuestRequirementIcon to string", e) + } +} + +// WarpEffect :: An effect that accompanies a player warp. +type WarpEffect int + +const ( + WarpEffect_None WarpEffect = iota // Does nothing. + WarpEffect_Scroll // Plays the scroll sound effect. + WarpEffect_Admin // Plays the admin warp sound effect and animation. +) + +// String converts a WarpEffect value into its string representation +func (e WarpEffect) String() (string, error) { + switch e { + case WarpEffect_None: + return "None", nil + case WarpEffect_Scroll: + return "Scroll", nil + case WarpEffect_Admin: + return "Admin", nil + default: + return "", fmt.Errorf("could not convert value %d of type WarpEffect to string", e) + } +} + +// WarpType :: Indicates whether a warp is within the current map, or switching to another map. +type WarpType int + +const ( + Warp_Local WarpType = iota + 1 + Warp_MapSwitch +) + +// String converts a WarpType value into its string representation +func (e WarpType) String() (string, error) { + switch e { + case Warp_Local: + return "Local", nil + case Warp_MapSwitch: + return "MapSwitch", nil + default: + return "", fmt.Errorf("could not convert value %d of type WarpType to string", e) + } +} + +// WelcomeCode :: Reply code sent with WELCOME_REPLY packet. +type WelcomeCode int + +const ( + WelcomeCode_SelectCharacter WelcomeCode = iota + 1 + WelcomeCode_EnterGame + WelcomeCode_ServerBusy + WelcomeCode_LoggedIn +) + +// String converts a WelcomeCode value into its string representation +func (e WelcomeCode) String() (string, error) { + switch e { + case WelcomeCode_SelectCharacter: + return "SelectCharacter", nil + case WelcomeCode_EnterGame: + return "EnterGame", nil + case WelcomeCode_ServerBusy: + return "ServerBusy", nil + case WelcomeCode_LoggedIn: + return "LoggedIn", nil + default: + return "", fmt.Errorf("could not convert value %d of type WelcomeCode to string", e) + } +} + +// LoginMessageCode :: Whether a warning message should be displayed upon entering the game. +type LoginMessageCode int + +const ( + LoginMessageCode_No LoginMessageCode = iota + LoginMessageCode_Yes = 2 +) + +// String converts a LoginMessageCode value into its string representation +func (e LoginMessageCode) String() (string, error) { + switch e { + case LoginMessageCode_No: + return "No", nil + case LoginMessageCode_Yes: + return "Yes", nil + default: + return "", fmt.Errorf("could not convert value %d of type LoginMessageCode to string", e) + } +} + +// AdminMessageType :: Type of message sent to admins via the Help menu. +type AdminMessageType int + +const ( + AdminMessage_Message AdminMessageType = iota + 1 + AdminMessage_Report +) + +// String converts a AdminMessageType value into its string representation +func (e AdminMessageType) String() (string, error) { + switch e { + case AdminMessage_Message: + return "Message", nil + case AdminMessage_Report: + return "Report", nil + default: + return "", fmt.Errorf("could not convert value %d of type AdminMessageType to string", e) + } +} + +// PlayerKilledState :: Flag to indicate that a player has been killed. +type PlayerKilledState int + +const ( + PlayerKilledState_Alive PlayerKilledState = iota + 1 + PlayerKilledState_Killed +) + +// String converts a PlayerKilledState value into its string representation +func (e PlayerKilledState) String() (string, error) { + switch e { + case PlayerKilledState_Alive: + return "Alive", nil + case PlayerKilledState_Killed: + return "Killed", nil + default: + return "", fmt.Errorf("could not convert value %d of type PlayerKilledState to string", e) + } +} + +// NpcKillStealProtectionState :: Flag to indicate whether you are able to attack an NPC. +type NpcKillStealProtectionState int + +const ( + NpcKillStealProtectionState_Unprotected NpcKillStealProtectionState = iota + 1 + NpcKillStealProtectionState_Protected +) + +// String converts a NpcKillStealProtectionState value into its string representation +func (e NpcKillStealProtectionState) String() (string, error) { + switch e { + case NpcKillStealProtectionState_Unprotected: + return "Unprotected", nil + case NpcKillStealProtectionState_Protected: + return "Protected", nil + default: + return "", fmt.Errorf("could not convert value %d of type NpcKillStealProtectionState to string", e) + } +} + +// MapDamageType :: Type of damage being caused by the environment. +type MapDamageType int + +const ( + MapDamage_TpDrain MapDamageType = iota + 1 + MapDamage_Spikes +) + +// String converts a MapDamageType value into its string representation +func (e MapDamageType) String() (string, error) { + switch e { + case MapDamage_TpDrain: + return "TpDrain", nil + case MapDamage_Spikes: + return "Spikes", nil + default: + return "", fmt.Errorf("could not convert value %d of type MapDamageType to string", e) + } +} + +// MarriageReply :: Reply code sent with MARRIAGE_REPLY packet. +type MarriageReply int + +const ( + MarriageReply_AlreadyMarried MarriageReply = iota + 1 + MarriageReply_NotMarried + MarriageReply_Success + MarriageReply_NotEnoughGold + MarriageReply_WrongName + MarriageReply_ServiceBusy + MarriageReply_DivorceNotification +) + +// String converts a MarriageReply value into its string representation +func (e MarriageReply) String() (string, error) { + switch e { + case MarriageReply_AlreadyMarried: + return "AlreadyMarried", nil + case MarriageReply_NotMarried: + return "NotMarried", nil + case MarriageReply_Success: + return "Success", nil + case MarriageReply_NotEnoughGold: + return "NotEnoughGold", nil + case MarriageReply_WrongName: + return "WrongName", nil + case MarriageReply_ServiceBusy: + return "ServiceBusy", nil + case MarriageReply_DivorceNotification: + return "DivorceNotification", nil + default: + return "", fmt.Errorf("could not convert value %d of type MarriageReply to string", e) + } +} + +// PriestReply :: Reply code sent with PRIEST_REPLY packet. +type PriestReply int + +const ( + PriestReply_NotDressed PriestReply = iota + 1 + PriestReply_LowLevel + PriestReply_PartnerNotPresent + PriestReply_PartnerNotDressed + PriestReply_Busy + PriestReply_DoYou + PriestReply_PartnerAlreadyMarried + PriestReply_NoPermission +) + +// String converts a PriestReply value into its string representation +func (e PriestReply) String() (string, error) { + switch e { + case PriestReply_NotDressed: + return "NotDressed", nil + case PriestReply_LowLevel: + return "LowLevel", nil + case PriestReply_PartnerNotPresent: + return "PartnerNotPresent", nil + case PriestReply_PartnerNotDressed: + return "PartnerNotDressed", nil + case PriestReply_Busy: + return "Busy", nil + case PriestReply_DoYou: + return "DoYou", nil + case PriestReply_PartnerAlreadyMarried: + return "PartnerAlreadyMarried", nil + case PriestReply_NoPermission: + return "NoPermission", nil + default: + return "", fmt.Errorf("could not convert value %d of type PriestReply to string", e) + } +} + +// PartyReplyCode :: Reply code sent with PARTY_REPLY packet. Indicates why an invite or join request failed. +type PartyReplyCode int + +const ( + PartyReplyCode_AlreadyInAnotherParty PartyReplyCode = iota + PartyReplyCode_AlreadyInYourParty + PartyReplyCode_PartyIsFull +) + +// String converts a PartyReplyCode value into its string representation +func (e PartyReplyCode) String() (string, error) { + switch e { + case PartyReplyCode_AlreadyInAnotherParty: + return "AlreadyInAnotherParty", nil + case PartyReplyCode_AlreadyInYourParty: + return "AlreadyInYourParty", nil + case PartyReplyCode_PartyIsFull: + return "PartyIsFull", nil + default: + return "", fmt.Errorf("could not convert value %d of type PartyReplyCode to string", e) + } +} diff --git a/v3/protocol/net/server/package.go b/v3/protocol/net/server/package.go new file mode 100644 index 0000000..0da39ff --- /dev/null +++ b/v3/protocol/net/server/package.go @@ -0,0 +1,2 @@ +// Package server provides EO network protocol data structures. This package contains packets that are sent from server to client. Types and functions in this package are primarily generated from the eo-protocol XML specification. +package server diff --git a/v3/protocol/net/server/packetmap_generated.go b/v3/protocol/net/server/packetmap_generated.go new file mode 100644 index 0000000..b889d49 --- /dev/null +++ b/v3/protocol/net/server/packetmap_generated.go @@ -0,0 +1,241 @@ +package server + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/protocol/net" + "reflect" +) + +var packetMap = map[int]reflect.Type{ + net.PacketId(net.PacketFamily_Init, net.PacketAction_Init): reflect.TypeOf(InitInitServerPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Player): reflect.TypeOf(WarpPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Ping): reflect.TypeOf(WelcomePingServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Pong): reflect.TypeOf(WelcomePongServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Net242): reflect.TypeOf(WelcomeNet242ServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Net243): reflect.TypeOf(WelcomeNet243ServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_List): reflect.TypeOf(PlayersListServerPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Create): reflect.TypeOf(WarpCreateServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Reply): reflect.TypeOf(PlayersReplyServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Net244): reflect.TypeOf(WelcomeNet244ServerPacket{}), + net.PacketId(net.PacketFamily_Connection, net.PacketAction_Player): reflect.TypeOf(ConnectionPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Account, net.PacketAction_Reply): reflect.TypeOf(AccountReplyServerPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Reply): reflect.TypeOf(CharacterReplyServerPacket{}), + net.PacketId(net.PacketFamily_Character, net.PacketAction_Player): reflect.TypeOf(CharacterPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Login, net.PacketAction_Reply): reflect.TypeOf(LoginReplyServerPacket{}), + net.PacketId(net.PacketFamily_Welcome, net.PacketAction_Reply): reflect.TypeOf(WelcomeReplyServerPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Reply): reflect.TypeOf(AdminInteractReplyServerPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Remove): reflect.TypeOf(AdminInteractRemoveServerPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Agree): reflect.TypeOf(AdminInteractAgreeServerPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_List): reflect.TypeOf(AdminInteractListServerPacket{}), + net.PacketId(net.PacketFamily_AdminInteract, net.PacketAction_Tell): reflect.TypeOf(AdminInteractTellServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Request): reflect.TypeOf(TalkRequestServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Open): reflect.TypeOf(TalkOpenServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Msg): reflect.TypeOf(TalkMsgServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Tell): reflect.TypeOf(TalkTellServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Player): reflect.TypeOf(TalkPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Reply): reflect.TypeOf(TalkReplyServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Admin): reflect.TypeOf(TalkAdminServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Announce): reflect.TypeOf(TalkAnnounceServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Server): reflect.TypeOf(TalkServerServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_List): reflect.TypeOf(TalkListServerPacket{}), + net.PacketId(net.PacketFamily_Message, net.PacketAction_Open): reflect.TypeOf(MessageOpenServerPacket{}), + net.PacketId(net.PacketFamily_Message, net.PacketAction_Close): reflect.TypeOf(MessageCloseServerPacket{}), + net.PacketId(net.PacketFamily_Message, net.PacketAction_Accept): reflect.TypeOf(MessageAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Talk, net.PacketAction_Spec): reflect.TypeOf(TalkSpecServerPacket{}), + net.PacketId(net.PacketFamily_Attack, net.PacketAction_Player): reflect.TypeOf(AttackPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Attack, net.PacketAction_Error): reflect.TypeOf(AttackErrorServerPacket{}), + net.PacketId(net.PacketFamily_Avatar, net.PacketAction_Reply): reflect.TypeOf(AvatarReplyServerPacket{}), + net.PacketId(net.PacketFamily_Chair, net.PacketAction_Player): reflect.TypeOf(ChairPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Chair, net.PacketAction_Reply): reflect.TypeOf(ChairReplyServerPacket{}), + net.PacketId(net.PacketFamily_Chair, net.PacketAction_Close): reflect.TypeOf(ChairCloseServerPacket{}), + net.PacketId(net.PacketFamily_Chair, net.PacketAction_Remove): reflect.TypeOf(ChairRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Sit, net.PacketAction_Player): reflect.TypeOf(SitPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Sit, net.PacketAction_Close): reflect.TypeOf(SitCloseServerPacket{}), + net.PacketId(net.PacketFamily_Sit, net.PacketAction_Remove): reflect.TypeOf(SitRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Sit, net.PacketAction_Reply): reflect.TypeOf(SitReplyServerPacket{}), + net.PacketId(net.PacketFamily_Emote, net.PacketAction_Player): reflect.TypeOf(EmotePlayerServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Player): reflect.TypeOf(EffectPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Face, net.PacketAction_Player): reflect.TypeOf(FacePlayerServerPacket{}), + net.PacketId(net.PacketFamily_Avatar, net.PacketAction_Remove): reflect.TypeOf(AvatarRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Agree): reflect.TypeOf(PlayersAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Remove): reflect.TypeOf(PlayersRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Range, net.PacketAction_Reply): reflect.TypeOf(RangeReplyServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Agree): reflect.TypeOf(NpcAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Player): reflect.TypeOf(WalkPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Reply): reflect.TypeOf(WalkReplyServerPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Close): reflect.TypeOf(WalkCloseServerPacket{}), + net.PacketId(net.PacketFamily_Walk, net.PacketAction_Open): reflect.TypeOf(WalkOpenServerPacket{}), + net.PacketId(net.PacketFamily_Bank, net.PacketAction_Open): reflect.TypeOf(BankOpenServerPacket{}), + net.PacketId(net.PacketFamily_Bank, net.PacketAction_Reply): reflect.TypeOf(BankReplyServerPacket{}), + net.PacketId(net.PacketFamily_Barber, net.PacketAction_Agree): reflect.TypeOf(BarberAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Barber, net.PacketAction_Open): reflect.TypeOf(BarberOpenServerPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Reply): reflect.TypeOf(LockerReplyServerPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Get): reflect.TypeOf(LockerGetServerPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Open): reflect.TypeOf(LockerOpenServerPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Buy): reflect.TypeOf(LockerBuyServerPacket{}), + net.PacketId(net.PacketFamily_Locker, net.PacketAction_Spec): reflect.TypeOf(LockerSpecServerPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Reply): reflect.TypeOf(CitizenReplyServerPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Remove): reflect.TypeOf(CitizenRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Open): reflect.TypeOf(CitizenOpenServerPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Request): reflect.TypeOf(CitizenRequestServerPacket{}), + net.PacketId(net.PacketFamily_Citizen, net.PacketAction_Accept): reflect.TypeOf(CitizenAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Create): reflect.TypeOf(ShopCreateServerPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Buy): reflect.TypeOf(ShopBuyServerPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Sell): reflect.TypeOf(ShopSellServerPacket{}), + net.PacketId(net.PacketFamily_Shop, net.PacketAction_Open): reflect.TypeOf(ShopOpenServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Open): reflect.TypeOf(StatSkillOpenServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Reply): reflect.TypeOf(StatSkillReplyServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Take): reflect.TypeOf(StatSkillTakeServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Remove): reflect.TypeOf(StatSkillRemoveServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Player): reflect.TypeOf(StatSkillPlayerServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Accept): reflect.TypeOf(StatSkillAcceptServerPacket{}), + net.PacketId(net.PacketFamily_StatSkill, net.PacketAction_Junk): reflect.TypeOf(StatSkillJunkServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Reply): reflect.TypeOf(ItemReplyServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Drop): reflect.TypeOf(ItemDropServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Add): reflect.TypeOf(ItemAddServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Remove): reflect.TypeOf(ItemRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Junk): reflect.TypeOf(ItemJunkServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Get): reflect.TypeOf(ItemGetServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Obtain): reflect.TypeOf(ItemObtainServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Kick): reflect.TypeOf(ItemKickServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Agree): reflect.TypeOf(ItemAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Spec): reflect.TypeOf(ItemSpecServerPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Player): reflect.TypeOf(BoardPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Board, net.PacketAction_Open): reflect.TypeOf(BoardOpenServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Agree): reflect.TypeOf(JukeboxAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Reply): reflect.TypeOf(JukeboxReplyServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Open): reflect.TypeOf(JukeboxOpenServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Msg): reflect.TypeOf(JukeboxMsgServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Player): reflect.TypeOf(JukeboxPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Jukebox, net.PacketAction_Use): reflect.TypeOf(JukeboxUseServerPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Request): reflect.TypeOf(WarpRequestServerPacket{}), + net.PacketId(net.PacketFamily_Warp, net.PacketAction_Agree): reflect.TypeOf(WarpAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Reply): reflect.TypeOf(PaperdollReplyServerPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Ping): reflect.TypeOf(PaperdollPingServerPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Remove): reflect.TypeOf(PaperdollRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Paperdoll, net.PacketAction_Agree): reflect.TypeOf(PaperdollAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Avatar, net.PacketAction_Agree): reflect.TypeOf(AvatarAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Book, net.PacketAction_Reply): reflect.TypeOf(BookReplyServerPacket{}), + net.PacketId(net.PacketFamily_Message, net.PacketAction_Pong): reflect.TypeOf(MessagePongServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Ping): reflect.TypeOf(PlayersPingServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Pong): reflect.TypeOf(PlayersPongServerPacket{}), + net.PacketId(net.PacketFamily_Players, net.PacketAction_Net242): reflect.TypeOf(PlayersNet242ServerPacket{}), + net.PacketId(net.PacketFamily_Door, net.PacketAction_Open): reflect.TypeOf(DoorOpenServerPacket{}), + net.PacketId(net.PacketFamily_Door, net.PacketAction_Close): reflect.TypeOf(DoorCloseServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Open): reflect.TypeOf(ChestOpenServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Reply): reflect.TypeOf(ChestReplyServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Get): reflect.TypeOf(ChestGetServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Agree): reflect.TypeOf(ChestAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Spec): reflect.TypeOf(ChestSpecServerPacket{}), + net.PacketId(net.PacketFamily_Chest, net.PacketAction_Close): reflect.TypeOf(ChestCloseServerPacket{}), + net.PacketId(net.PacketFamily_Refresh, net.PacketAction_Reply): reflect.TypeOf(RefreshReplyServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Request): reflect.TypeOf(PartyRequestServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Reply): reflect.TypeOf(PartyReplyServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Create): reflect.TypeOf(PartyCreateServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Add): reflect.TypeOf(PartyAddServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Remove): reflect.TypeOf(PartyRemoveServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Close): reflect.TypeOf(PartyCloseServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_List): reflect.TypeOf(PartyListServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_Agree): reflect.TypeOf(PartyAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Party, net.PacketAction_TargetGroup): reflect.TypeOf(PartyTargetGroupServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Reply): reflect.TypeOf(GuildReplyServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Request): reflect.TypeOf(GuildRequestServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Create): reflect.TypeOf(GuildCreateServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Take): reflect.TypeOf(GuildTakeServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Rank): reflect.TypeOf(GuildRankServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Sell): reflect.TypeOf(GuildSellServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Buy): reflect.TypeOf(GuildBuyServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Open): reflect.TypeOf(GuildOpenServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Tell): reflect.TypeOf(GuildTellServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Report): reflect.TypeOf(GuildReportServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Agree): reflect.TypeOf(GuildAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Accept): reflect.TypeOf(GuildAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Guild, net.PacketAction_Kick): reflect.TypeOf(GuildKickServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_Request): reflect.TypeOf(SpellRequestServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetSelf): reflect.TypeOf(SpellTargetSelfServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_Player): reflect.TypeOf(SpellPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_Error): reflect.TypeOf(SpellErrorServerPacket{}), + net.PacketId(net.PacketFamily_Avatar, net.PacketAction_Admin): reflect.TypeOf(AvatarAdminServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetGroup): reflect.TypeOf(SpellTargetGroupServerPacket{}), + net.PacketId(net.PacketFamily_Spell, net.PacketAction_TargetOther): reflect.TypeOf(SpellTargetOtherServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Request): reflect.TypeOf(TradeRequestServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Open): reflect.TypeOf(TradeOpenServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Reply): reflect.TypeOf(TradeReplyServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Admin): reflect.TypeOf(TradeAdminServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Use): reflect.TypeOf(TradeUseServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Spec): reflect.TypeOf(TradeSpecServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Agree): reflect.TypeOf(TradeAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Trade, net.PacketAction_Close): reflect.TypeOf(TradeCloseServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Reply): reflect.TypeOf(NpcReplyServerPacket{}), + net.PacketId(net.PacketFamily_Cast, net.PacketAction_Reply): reflect.TypeOf(CastReplyServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Spec): reflect.TypeOf(NpcSpecServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Accept): reflect.TypeOf(NpcAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Cast, net.PacketAction_Spec): reflect.TypeOf(CastSpecServerPacket{}), + net.PacketId(net.PacketFamily_Cast, net.PacketAction_Accept): reflect.TypeOf(CastAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Junk): reflect.TypeOf(NpcJunkServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Player): reflect.TypeOf(NpcPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Npc, net.PacketAction_Dialog): reflect.TypeOf(NpcDialogServerPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_Report): reflect.TypeOf(QuestReportServerPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_Dialog): reflect.TypeOf(QuestDialogServerPacket{}), + net.PacketId(net.PacketFamily_Quest, net.PacketAction_List): reflect.TypeOf(QuestListServerPacket{}), + net.PacketId(net.PacketFamily_Item, net.PacketAction_Accept): reflect.TypeOf(ItemAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Arena, net.PacketAction_Drop): reflect.TypeOf(ArenaDropServerPacket{}), + net.PacketId(net.PacketFamily_Arena, net.PacketAction_Use): reflect.TypeOf(ArenaUseServerPacket{}), + net.PacketId(net.PacketFamily_Arena, net.PacketAction_Spec): reflect.TypeOf(ArenaSpecServerPacket{}), + net.PacketId(net.PacketFamily_Arena, net.PacketAction_Accept): reflect.TypeOf(ArenaAcceptServerPacket{}), + net.PacketId(net.PacketFamily_Marriage, net.PacketAction_Open): reflect.TypeOf(MarriageOpenServerPacket{}), + net.PacketId(net.PacketFamily_Marriage, net.PacketAction_Reply): reflect.TypeOf(MarriageReplyServerPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Open): reflect.TypeOf(PriestOpenServerPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Reply): reflect.TypeOf(PriestReplyServerPacket{}), + net.PacketId(net.PacketFamily_Priest, net.PacketAction_Request): reflect.TypeOf(PriestRequestServerPacket{}), + net.PacketId(net.PacketFamily_Recover, net.PacketAction_Player): reflect.TypeOf(RecoverPlayerServerPacket{}), + net.PacketId(net.PacketFamily_Recover, net.PacketAction_Agree): reflect.TypeOf(RecoverAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Recover, net.PacketAction_List): reflect.TypeOf(RecoverListServerPacket{}), + net.PacketId(net.PacketFamily_Recover, net.PacketAction_Reply): reflect.TypeOf(RecoverReplyServerPacket{}), + net.PacketId(net.PacketFamily_Recover, net.PacketAction_TargetGroup): reflect.TypeOf(RecoverTargetGroupServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Use): reflect.TypeOf(EffectUseServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Agree): reflect.TypeOf(EffectAgreeServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_TargetOther): reflect.TypeOf(EffectTargetOtherServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Report): reflect.TypeOf(EffectReportServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Spec): reflect.TypeOf(EffectSpecServerPacket{}), + net.PacketId(net.PacketFamily_Effect, net.PacketAction_Admin): reflect.TypeOf(EffectAdminServerPacket{}), + net.PacketId(net.PacketFamily_Music, net.PacketAction_Player): reflect.TypeOf(MusicPlayerServerPacket{}), +} + +// PacketFromId creates a typed packet instance from a [net.PacketFamily] and [net.PacketAction]. +// This function calls [PacketFromIntegerId] internally. +func PacketFromId(family net.PacketFamily, action net.PacketAction) (net.Packet, error) { + return PacketFromIntegerId(net.PacketId(family, action)) +} + +// PacketFromIntegerId creates a typed packet instance from a packet's ID. An ID may be converted from a family/action pair via the [net.PacketId] function. +// The returned packet implements the [net.Packet] interface. It may be serialized/deserialized without further conversion, or a type assertion may be made to examine the data. The expected type of the assertion is a pointer to a packet structure. +// The following example does both: an incoming CHAIR_REQUEST packet is deserialized from a reader without converting from the interface type, and the data is examined via a type assertion. +// +// pkt, _ := client.PacketFromId(net.PacketFamily_Chair, net.PacketAction_Request) +// if err = pkt.Deserialize(reader); err != nil { +// // handle the error +// } +// switch v := pkt.(type) { +// case *client.ChairRequestClientPacket: +// fmt.Println("SitAction=", v.SitAction) +// switch d := v.SitActionData.(type) { +// case *client.ChairRequestSitActionDataSit: +// fmt.Println("Data.Coords=", v.Data.Coords) +// } +// default: +// fmt.Printf("Unknown type: %s\n", reflect.TypeOf(pkt).Elem().Name()) +// } +func PacketFromIntegerId(id int) (net.Packet, error) { + packetType, idOk := packetMap[id] + if !idOk { + return nil, fmt.Errorf("could not find packet with id %d", id) + } + + packetInstance, typeOk := reflect.New(packetType).Interface().(net.Packet) + if !typeOk { + return nil, fmt.Errorf("could not create packet from id %d", id) + } + + return packetInstance, nil +} diff --git a/v3/protocol/net/server/packets_generated.go b/v3/protocol/net/server/packets_generated.go new file mode 100644 index 0000000..7528db5 --- /dev/null +++ b/v3/protocol/net/server/packets_generated.go @@ -0,0 +1,14824 @@ +package server + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/protocol" + "github.com/ethanmoffat/eolib-go/v3/protocol/net" + "github.com/ethanmoffat/eolib-go/v3/protocol/pub" +) + +// InitInitServerPacket :: Reply to connection initialization and requests for unencrypted data. This packet is unencrypted. +type InitInitServerPacket struct { + byteSize int + + ReplyCode InitReply + ReplyCodeData InitInitReplyCodeData +} + +type InitInitReplyCodeData interface { + protocol.EoData +} + +type InitInitReplyCodeDataOutOfDate struct { + byteSize int + + Version net.Version +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataOutOfDate) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataOutOfDate) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Version : field : Version + if err = s.Version.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataOutOfDate) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Version : field : Version + if err = s.Version.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataOk struct { + byteSize int + + Seq1 int + Seq2 int + ServerEncryptionMultiple int + ClientEncryptionMultiple int + PlayerId int + ChallengeResponse int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataOk) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataOk) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Seq1 : field : byte + if err = writer.AddByte(s.Seq1); err != nil { + return + } + // Seq2 : field : byte + if err = writer.AddByte(s.Seq2); err != nil { + return + } + // ServerEncryptionMultiple : field : byte + if err = writer.AddByte(s.ServerEncryptionMultiple); err != nil { + return + } + // ClientEncryptionMultiple : field : byte + if err = writer.AddByte(s.ClientEncryptionMultiple); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // ChallengeResponse : field : three + if err = writer.AddThree(s.ChallengeResponse); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataOk) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Seq1 : field : byte + s.Seq1 = int(reader.GetByte()) + // Seq2 : field : byte + s.Seq2 = int(reader.GetByte()) + // ServerEncryptionMultiple : field : byte + s.ServerEncryptionMultiple = int(reader.GetByte()) + // ClientEncryptionMultiple : field : byte + s.ClientEncryptionMultiple = int(reader.GetByte()) + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // ChallengeResponse : field : three + s.ChallengeResponse = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataBanned struct { + byteSize int + + BanType InitBanType + BanTypeData InitInitBanTypeData +} + +type InitInitBanTypeData interface { + protocol.EoData +} + +// InitInitBanTypeData0 :: The official client treats any value below 2 as a temporary ban. The official server sends 1, but some game server implementations. erroneously send 0. +type InitInitBanTypeData0 struct { + byteSize int + + MinutesRemaining int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitBanTypeData0) ByteSize() int { + return s.byteSize +} + +func (s *InitInitBanTypeData0) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MinutesRemaining : field : byte + if err = writer.AddByte(s.MinutesRemaining); err != nil { + return + } + return +} + +func (s *InitInitBanTypeData0) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MinutesRemaining : field : byte + s.MinutesRemaining = int(reader.GetByte()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitBanTypeDataTemporary struct { + byteSize int + + MinutesRemaining int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitBanTypeDataTemporary) ByteSize() int { + return s.byteSize +} + +func (s *InitInitBanTypeDataTemporary) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MinutesRemaining : field : byte + if err = writer.AddByte(s.MinutesRemaining); err != nil { + return + } + return +} + +func (s *InitInitBanTypeDataTemporary) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MinutesRemaining : field : byte + s.MinutesRemaining = int(reader.GetByte()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataBanned) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataBanned) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BanType : field : InitBanType + if err = writer.AddByte(int(s.BanType)); err != nil { + return + } + switch s.BanType { + case 0: + switch s.BanTypeData.(type) { + case *InitInitBanTypeData0: + if err = s.BanTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.BanType) + return + } + case InitBan_Temporary: + switch s.BanTypeData.(type) { + case *InitInitBanTypeDataTemporary: + if err = s.BanTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.BanType) + return + } + } + return +} + +func (s *InitInitReplyCodeDataBanned) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BanType : field : InitBanType + s.BanType = InitBanType(reader.GetByte()) + switch s.BanType { + case 0: + s.BanTypeData = &InitInitBanTypeData0{} + if err = s.BanTypeData.Deserialize(reader); err != nil { + return + } + case InitBan_Temporary: + s.BanTypeData = &InitInitBanTypeDataTemporary{} + if err = s.BanTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataWarpMap struct { + byteSize int + + MapFile MapFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataWarpMap) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataWarpMap) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataWarpMap) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataFileEmf struct { + byteSize int + + MapFile MapFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataFileEmf) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataFileEmf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataFileEmf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataFileEif struct { + byteSize int + + PubFile PubFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataFileEif) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataFileEif) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataFileEif) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataFileEnf struct { + byteSize int + + PubFile PubFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataFileEnf) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataFileEnf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataFileEnf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataFileEsf struct { + byteSize int + + PubFile PubFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataFileEsf) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataFileEsf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataFileEsf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataFileEcf struct { + byteSize int + + PubFile PubFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataFileEcf) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataFileEcf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataFileEcf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataMapMutation struct { + byteSize int + + MapFile MapFile +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataMapMutation) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataMapMutation) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *InitInitReplyCodeDataMapMutation) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataPlayersList struct { + byteSize int + + PlayersList PlayersList +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataPlayersList) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataPlayersList) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersList : field : PlayersList + if err = s.PlayersList.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *InitInitReplyCodeDataPlayersList) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersList : field : PlayersList + if err = s.PlayersList.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type InitInitReplyCodeDataPlayersListFriends struct { + byteSize int + + PlayersList PlayersListFriends +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitReplyCodeDataPlayersListFriends) ByteSize() int { + return s.byteSize +} + +func (s *InitInitReplyCodeDataPlayersListFriends) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersList : field : PlayersListFriends + if err = s.PlayersList.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *InitInitReplyCodeDataPlayersListFriends) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersList : field : PlayersListFriends + if err = s.PlayersList.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s InitInitServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Init +} + +func (s InitInitServerPacket) Action() net.PacketAction { + return net.PacketAction_Init +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InitInitServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *InitInitServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : InitReply + if err = writer.AddByte(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case InitReply_OutOfDate: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataOutOfDate: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_Ok: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataOk: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_Banned: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataBanned: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_WarpMap: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataWarpMap: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_FileEmf: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataFileEmf: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_FileEif: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataFileEif: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_FileEnf: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataFileEnf: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_FileEsf: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataFileEsf: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_FileEcf: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataFileEcf: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_MapMutation: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataMapMutation: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_PlayersList: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataPlayersList: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case InitReply_PlayersListFriends: + switch s.ReplyCodeData.(type) { + case *InitInitReplyCodeDataPlayersListFriends: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *InitInitServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : InitReply + s.ReplyCode = InitReply(reader.GetByte()) + switch s.ReplyCode { + case InitReply_OutOfDate: + s.ReplyCodeData = &InitInitReplyCodeDataOutOfDate{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_Ok: + s.ReplyCodeData = &InitInitReplyCodeDataOk{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_Banned: + s.ReplyCodeData = &InitInitReplyCodeDataBanned{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_WarpMap: + s.ReplyCodeData = &InitInitReplyCodeDataWarpMap{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_FileEmf: + s.ReplyCodeData = &InitInitReplyCodeDataFileEmf{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_FileEif: + s.ReplyCodeData = &InitInitReplyCodeDataFileEif{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_FileEnf: + s.ReplyCodeData = &InitInitReplyCodeDataFileEnf{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_FileEsf: + s.ReplyCodeData = &InitInitReplyCodeDataFileEsf{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_FileEcf: + s.ReplyCodeData = &InitInitReplyCodeDataFileEcf{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_MapMutation: + s.ReplyCodeData = &InitInitReplyCodeDataMapMutation{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_PlayersList: + s.ReplyCodeData = &InitInitReplyCodeDataPlayersList{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case InitReply_PlayersListFriends: + s.ReplyCodeData = &InitInitReplyCodeDataPlayersListFriends{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpPlayerServerPacket :: Equivalent to INIT_INIT with InitReply.WarpMap. +type WarpPlayerServerPacket struct { + byteSize int + + MapFile MapFile +} + +func (s WarpPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WarpPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomePingServerPacket :: Equivalent to INIT_INIT with InitReply.FileMap. +type WelcomePingServerPacket struct { + byteSize int + + MapFile MapFile +} + +func (s WelcomePingServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomePingServerPacket) Action() net.PacketAction { + return net.PacketAction_Ping +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomePingServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomePingServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomePingServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomePongServerPacket :: Equivalent to INIT_INIT with InitReply.FileEif. +type WelcomePongServerPacket struct { + byteSize int + + PubFile PubFile +} + +func (s WelcomePongServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomePongServerPacket) Action() net.PacketAction { + return net.PacketAction_Pong +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomePongServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomePongServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomePongServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeNet242ServerPacket :: Equivalent to INIT_INIT with InitReply.FileEnf. +type WelcomeNet242ServerPacket struct { + byteSize int + + PubFile PubFile +} + +func (s WelcomeNet242ServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeNet242ServerPacket) Action() net.PacketAction { + return net.PacketAction_Net242 +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeNet242ServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeNet242ServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomeNet242ServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeNet243ServerPacket :: Equivalent to INIT_INIT with InitReply.FileEsf. +type WelcomeNet243ServerPacket struct { + byteSize int + + PubFile PubFile +} + +func (s WelcomeNet243ServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeNet243ServerPacket) Action() net.PacketAction { + return net.PacketAction_Net243 +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeNet243ServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeNet243ServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomeNet243ServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersListServerPacket :: Equivalent to INIT_INIT with InitReply.PlayersList. +type PlayersListServerPacket struct { + byteSize int + + PlayersList PlayersList +} + +func (s PlayersListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersList : field : PlayersList + if err = s.PlayersList.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *PlayersListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersList : field : PlayersList + if err = s.PlayersList.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpCreateServerPacket :: Equivalent to INIT_INIT with InitReply.MapMutation. +type WarpCreateServerPacket struct { + byteSize int + + MapFile MapFile +} + +func (s WarpCreateServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpCreateServerPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpCreateServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpCreateServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapFile : field : MapFile + if err = s.MapFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WarpCreateServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapFile : field : MapFile + if err = s.MapFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersReplyServerPacket :: Equivalent to INIT_INIT with InitReply.PlayersListFriends. +type PlayersReplyServerPacket struct { + byteSize int + + PlayersList PlayersListFriends +} + +func (s PlayersReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersList : field : PlayersListFriends + if err = s.PlayersList.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *PlayersReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersList : field : PlayersListFriends + if err = s.PlayersList.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeNet244ServerPacket :: Equivalent to INIT_INIT with InitReply.FileEcf. +type WelcomeNet244ServerPacket struct { + byteSize int + + PubFile PubFile +} + +func (s WelcomeNet244ServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeNet244ServerPacket) Action() net.PacketAction { + return net.PacketAction_Net244 +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeNet244ServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeNet244ServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PubFile : field : PubFile + if err = s.PubFile.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomeNet244ServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PubFile : field : PubFile + if err = s.PubFile.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ConnectionPlayerServerPacket :: Ping request. +type ConnectionPlayerServerPacket struct { + byteSize int + + Seq1 int + Seq2 int +} + +func (s ConnectionPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Connection +} + +func (s ConnectionPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ConnectionPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ConnectionPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Seq1 : field : short + if err = writer.AddShort(s.Seq1); err != nil { + return + } + // Seq2 : field : char + if err = writer.AddChar(s.Seq2); err != nil { + return + } + return +} + +func (s *ConnectionPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Seq1 : field : short + s.Seq1 = reader.GetShort() + // Seq2 : field : char + s.Seq2 = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AccountReplyServerPacket :: Reply to client Account-family packets. +type AccountReplyServerPacket struct { + byteSize int + + ReplyCode AccountReply // Sometimes an AccountReply code, sometimes a session ID for account creation. + ReplyCodeData AccountReplyReplyCodeData +} + +type AccountReplyReplyCodeData interface { + protocol.EoData +} + +type AccountReplyReplyCodeDataExists struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataExists) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataExists) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataExists) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AccountReplyReplyCodeDataNotApproved struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataNotApproved) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataNotApproved) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataNotApproved) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AccountReplyReplyCodeDataCreated struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataCreated) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataCreated) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GO : field : string + if err = writer.AddString("GO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataCreated) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AccountReplyReplyCodeDataChangeFailed struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataChangeFailed) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataChangeFailed) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataChangeFailed) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AccountReplyReplyCodeDataChanged struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataChanged) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataChanged) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataChanged) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AccountReplyReplyCodeDataRequestDenied struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataRequestDenied) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataRequestDenied) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataRequestDenied) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AccountReplyReplyCodeDataDefault :: In this case (reply_code > 9), reply_code is a session ID for account creation. +type AccountReplyReplyCodeDataDefault struct { + byteSize int + + SequenceStart int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyReplyCodeDataDefault) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyReplyCodeDataDefault) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SequenceStart : field : char + if err = writer.AddChar(s.SequenceStart); err != nil { + return + } + // OK : field : string + if err = writer.AddString("OK"); err != nil { + return + } + return +} + +func (s *AccountReplyReplyCodeDataDefault) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SequenceStart : field : char + s.SequenceStart = reader.GetChar() + // OK : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s AccountReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Account +} + +func (s AccountReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AccountReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AccountReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : AccountReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case AccountReply_Exists: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataExists: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case AccountReply_NotApproved: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataNotApproved: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case AccountReply_Created: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataCreated: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case AccountReply_ChangeFailed: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataChangeFailed: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case AccountReply_Changed: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataChanged: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case AccountReply_RequestDenied: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataRequestDenied: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + default: + switch s.ReplyCodeData.(type) { + case *AccountReplyReplyCodeDataDefault: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *AccountReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : AccountReply + s.ReplyCode = AccountReply(reader.GetShort()) + switch s.ReplyCode { + case AccountReply_Exists: + s.ReplyCodeData = &AccountReplyReplyCodeDataExists{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case AccountReply_NotApproved: + s.ReplyCodeData = &AccountReplyReplyCodeDataNotApproved{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case AccountReply_Created: + s.ReplyCodeData = &AccountReplyReplyCodeDataCreated{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case AccountReply_ChangeFailed: + s.ReplyCodeData = &AccountReplyReplyCodeDataChangeFailed{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case AccountReply_Changed: + s.ReplyCodeData = &AccountReplyReplyCodeDataChanged{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case AccountReply_RequestDenied: + s.ReplyCodeData = &AccountReplyReplyCodeDataRequestDenied{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + default: + s.ReplyCodeData = &AccountReplyReplyCodeDataDefault{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterReplyServerPacket :: Reply to client Character-family packets. +type CharacterReplyServerPacket struct { + byteSize int + + ReplyCode CharacterReply // Sometimes a CharacterReply code, sometimes a session ID for character creation. + ReplyCodeData CharacterReplyReplyCodeData +} + +type CharacterReplyReplyCodeData interface { + protocol.EoData +} + +type CharacterReplyReplyCodeDataExists struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataExists) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataExists) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *CharacterReplyReplyCodeDataExists) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type CharacterReplyReplyCodeDataFull struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataFull) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataFull) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *CharacterReplyReplyCodeDataFull) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type CharacterReplyReplyCodeDataFull3 struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataFull3) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataFull3) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *CharacterReplyReplyCodeDataFull3) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type CharacterReplyReplyCodeDataNotApproved struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataNotApproved) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataNotApproved) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *CharacterReplyReplyCodeDataNotApproved) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type CharacterReplyReplyCodeDataOk struct { + byteSize int + + Characters []CharacterSelectionListEntry +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataOk) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataOk) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharactersCount : length : char + if err = writer.AddChar(len(s.Characters)); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + writer.AddByte(255) + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < len(s.Characters); ndx++ { + if err = s.Characters[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *CharacterReplyReplyCodeDataOk) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharactersCount : length : char + charactersCount := reader.GetChar() + // 0 : field : char + reader.GetChar() + if err = reader.NextChunk(); err != nil { + return + } + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < charactersCount; ndx++ { + s.Characters = append(s.Characters, CharacterSelectionListEntry{}) + if err = s.Characters[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type CharacterReplyReplyCodeDataDeleted struct { + byteSize int + + Characters []CharacterSelectionListEntry +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataDeleted) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataDeleted) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharactersCount : length : char + if err = writer.AddChar(len(s.Characters)); err != nil { + return + } + writer.AddByte(255) + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < len(s.Characters); ndx++ { + if err = s.Characters[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *CharacterReplyReplyCodeDataDeleted) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharactersCount : length : char + charactersCount := reader.GetChar() + if err = reader.NextChunk(); err != nil { + return + } + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < charactersCount; ndx++ { + s.Characters = append(s.Characters, CharacterSelectionListEntry{}) + if err = s.Characters[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterReplyReplyCodeDataDefault :: In this case (reply_code > 9), reply_code is a session ID for character creation. +type CharacterReplyReplyCodeDataDefault struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyReplyCodeDataDefault) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyReplyCodeDataDefault) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // OK : field : string + if err = writer.AddString("OK"); err != nil { + return + } + return +} + +func (s *CharacterReplyReplyCodeDataDefault) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // OK : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s CharacterReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // ReplyCode : field : CharacterReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case CharacterReply_Exists: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataExists: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case CharacterReply_Full: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataFull: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case CharacterReply_Full3: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataFull3: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case CharacterReply_NotApproved: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataNotApproved: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case CharacterReply_Ok: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataOk: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case CharacterReply_Deleted: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataDeleted: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + default: + switch s.ReplyCodeData.(type) { + case *CharacterReplyReplyCodeDataDefault: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *CharacterReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // ReplyCode : field : CharacterReply + s.ReplyCode = CharacterReply(reader.GetShort()) + switch s.ReplyCode { + case CharacterReply_Exists: + s.ReplyCodeData = &CharacterReplyReplyCodeDataExists{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case CharacterReply_Full: + s.ReplyCodeData = &CharacterReplyReplyCodeDataFull{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case CharacterReply_Full3: + s.ReplyCodeData = &CharacterReplyReplyCodeDataFull3{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case CharacterReply_NotApproved: + s.ReplyCodeData = &CharacterReplyReplyCodeDataNotApproved{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case CharacterReply_Ok: + s.ReplyCodeData = &CharacterReplyReplyCodeDataOk{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case CharacterReply_Deleted: + s.ReplyCodeData = &CharacterReplyReplyCodeDataDeleted{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + default: + s.ReplyCodeData = &CharacterReplyReplyCodeDataDefault{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterPlayerServerPacket :: Reply to client request to delete a character from the account (Character_Take). +type CharacterPlayerServerPacket struct { + byteSize int + + SessionId int + CharacterId int +} + +func (s CharacterPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Character +} + +func (s CharacterPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CharacterPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + return +} + +func (s *CharacterPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LoginReplyServerPacket :: Login reply. +type LoginReplyServerPacket struct { + byteSize int + + ReplyCode LoginReply + ReplyCodeData LoginReplyReplyCodeData +} + +type LoginReplyReplyCodeData interface { + protocol.EoData +} + +type LoginReplyReplyCodeDataWrongUser struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataWrongUser) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataWrongUser) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *LoginReplyReplyCodeDataWrongUser) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type LoginReplyReplyCodeDataWrongUserPassword struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataWrongUserPassword) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataWrongUserPassword) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *LoginReplyReplyCodeDataWrongUserPassword) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type LoginReplyReplyCodeDataOk struct { + byteSize int + + Characters []CharacterSelectionListEntry +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataOk) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataOk) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharactersCount : length : char + if err = writer.AddChar(len(s.Characters)); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + writer.AddByte(255) + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < len(s.Characters); ndx++ { + if err = s.Characters[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *LoginReplyReplyCodeDataOk) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharactersCount : length : char + charactersCount := reader.GetChar() + // 0 : field : char + reader.GetChar() + if err = reader.NextChunk(); err != nil { + return + } + // Characters : array : CharacterSelectionListEntry + for ndx := 0; ndx < charactersCount; ndx++ { + s.Characters = append(s.Characters, CharacterSelectionListEntry{}) + if err = s.Characters[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type LoginReplyReplyCodeDataBanned struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataBanned) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataBanned) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *LoginReplyReplyCodeDataBanned) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type LoginReplyReplyCodeDataLoggedIn struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataLoggedIn) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataLoggedIn) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *LoginReplyReplyCodeDataLoggedIn) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type LoginReplyReplyCodeDataBusy struct { + byteSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyReplyCodeDataBusy) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyReplyCodeDataBusy) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NO : field : string + if err = writer.AddString("NO"); err != nil { + return + } + return +} + +func (s *LoginReplyReplyCodeDataBusy) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NO : field : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s LoginReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Login +} + +func (s LoginReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LoginReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LoginReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // ReplyCode : field : LoginReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case LoginReply_WrongUser: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataWrongUser: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case LoginReply_WrongUserPassword: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataWrongUserPassword: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case LoginReply_Ok: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataOk: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case LoginReply_Banned: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataBanned: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case LoginReply_LoggedIn: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataLoggedIn: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case LoginReply_Busy: + switch s.ReplyCodeData.(type) { + case *LoginReplyReplyCodeDataBusy: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *LoginReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // ReplyCode : field : LoginReply + s.ReplyCode = LoginReply(reader.GetShort()) + switch s.ReplyCode { + case LoginReply_WrongUser: + s.ReplyCodeData = &LoginReplyReplyCodeDataWrongUser{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case LoginReply_WrongUserPassword: + s.ReplyCodeData = &LoginReplyReplyCodeDataWrongUserPassword{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case LoginReply_Ok: + s.ReplyCodeData = &LoginReplyReplyCodeDataOk{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case LoginReply_Banned: + s.ReplyCodeData = &LoginReplyReplyCodeDataBanned{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case LoginReply_LoggedIn: + s.ReplyCodeData = &LoginReplyReplyCodeDataLoggedIn{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case LoginReply_Busy: + s.ReplyCodeData = &LoginReplyReplyCodeDataBusy{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WelcomeReplyServerPacket :: Reply to selecting a character / entering game. +type WelcomeReplyServerPacket struct { + byteSize int + + WelcomeCode WelcomeCode + WelcomeCodeData WelcomeReplyWelcomeCodeData +} + +type WelcomeReplyWelcomeCodeData interface { + protocol.EoData +} + +type WelcomeReplyWelcomeCodeDataSelectCharacter struct { + byteSize int + + SessionId int + CharacterId int + MapId int + MapRid []int + MapFileSize int + EifRid []int + EifLength int + EnfRid []int + EnfLength int + EsfRid []int + EsfLength int + EcfRid []int + EcfLength int + Name string + Title string + GuildName string + GuildRankName string + ClassId int + GuildTag string + Admin protocol.AdminLevel + Level int + Experience int + Usage int + Stats CharacterStatsWelcome + Equipment EquipmentWelcome + GuildRank int + Settings ServerSettings + LoginMessageCode LoginMessageCode +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeReplyWelcomeCodeDataSelectCharacter) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeReplyWelcomeCodeDataSelectCharacter) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // CharacterId : field : int + if err = writer.AddInt(s.CharacterId); err != nil { + return + } + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // MapRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.MapRid) != 2 { + err = fmt.Errorf("expected MapRid with length 2, got %d", len(s.MapRid)) + return + } + + if err = writer.AddShort(s.MapRid[ndx]); err != nil { + return + } + } + + // MapFileSize : field : three + if err = writer.AddThree(s.MapFileSize); err != nil { + return + } + // EifRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.EifRid) != 2 { + err = fmt.Errorf("expected EifRid with length 2, got %d", len(s.EifRid)) + return + } + + if err = writer.AddShort(s.EifRid[ndx]); err != nil { + return + } + } + + // EifLength : field : short + if err = writer.AddShort(s.EifLength); err != nil { + return + } + // EnfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.EnfRid) != 2 { + err = fmt.Errorf("expected EnfRid with length 2, got %d", len(s.EnfRid)) + return + } + + if err = writer.AddShort(s.EnfRid[ndx]); err != nil { + return + } + } + + // EnfLength : field : short + if err = writer.AddShort(s.EnfLength); err != nil { + return + } + // EsfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.EsfRid) != 2 { + err = fmt.Errorf("expected EsfRid with length 2, got %d", len(s.EsfRid)) + return + } + + if err = writer.AddShort(s.EsfRid[ndx]); err != nil { + return + } + } + + // EsfLength : field : short + if err = writer.AddShort(s.EsfLength); err != nil { + return + } + // EcfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.EcfRid) != 2 { + err = fmt.Errorf("expected EcfRid with length 2, got %d", len(s.EcfRid)) + return + } + + if err = writer.AddShort(s.EcfRid[ndx]); err != nil { + return + } + } + + // EcfLength : field : short + if err = writer.AddShort(s.EcfLength); err != nil { + return + } + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Title : field : string + if err = writer.AddString(s.Title); err != nil { + return + } + writer.AddByte(255) + // GuildName : field : string + if err = writer.AddString(s.GuildName); err != nil { + return + } + writer.AddByte(255) + // GuildRankName : field : string + if err = writer.AddString(s.GuildRankName); err != nil { + return + } + writer.AddByte(255) + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + // GuildTag : field : string + if len(s.GuildTag) != 3 { + err = fmt.Errorf("expected GuildTag with length 3, got %d", len(s.GuildTag)) + return + } + if err = writer.AddFixedString(s.GuildTag, 3); err != nil { + return + } + // Admin : field : AdminLevel + if err = writer.AddChar(int(s.Admin)); err != nil { + return + } + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // Experience : field : int + if err = writer.AddInt(s.Experience); err != nil { + return + } + // Usage : field : int + if err = writer.AddInt(s.Usage); err != nil { + return + } + // Stats : field : CharacterStatsWelcome + if err = s.Stats.Serialize(writer); err != nil { + return + } + // Equipment : field : EquipmentWelcome + if err = s.Equipment.Serialize(writer); err != nil { + return + } + // GuildRank : field : char + if err = writer.AddChar(s.GuildRank); err != nil { + return + } + // Settings : field : ServerSettings + if err = s.Settings.Serialize(writer); err != nil { + return + } + // LoginMessageCode : field : LoginMessageCode + if err = writer.AddChar(int(s.LoginMessageCode)); err != nil { + return + } + writer.AddByte(255) + return +} + +func (s *WelcomeReplyWelcomeCodeDataSelectCharacter) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // CharacterId : field : int + s.CharacterId = reader.GetInt() + // MapId : field : short + s.MapId = reader.GetShort() + // MapRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.MapRid = append(s.MapRid, 0) + s.MapRid[ndx] = reader.GetShort() + } + + // MapFileSize : field : three + s.MapFileSize = reader.GetThree() + // EifRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.EifRid = append(s.EifRid, 0) + s.EifRid[ndx] = reader.GetShort() + } + + // EifLength : field : short + s.EifLength = reader.GetShort() + // EnfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.EnfRid = append(s.EnfRid, 0) + s.EnfRid[ndx] = reader.GetShort() + } + + // EnfLength : field : short + s.EnfLength = reader.GetShort() + // EsfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.EsfRid = append(s.EsfRid, 0) + s.EsfRid[ndx] = reader.GetShort() + } + + // EsfLength : field : short + s.EsfLength = reader.GetShort() + // EcfRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.EcfRid = append(s.EcfRid, 0) + s.EcfRid[ndx] = reader.GetShort() + } + + // EcfLength : field : short + s.EcfLength = reader.GetShort() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Title : field : string + if s.Title, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildName : field : string + if s.GuildName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildRankName : field : string + if s.GuildRankName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // ClassId : field : char + s.ClassId = reader.GetChar() + // GuildTag : field : string + if s.GuildTag, err = reader.GetFixedString(3); err != nil { + return + } + + // Admin : field : AdminLevel + s.Admin = protocol.AdminLevel(reader.GetChar()) + // Level : field : char + s.Level = reader.GetChar() + // Experience : field : int + s.Experience = reader.GetInt() + // Usage : field : int + s.Usage = reader.GetInt() + // Stats : field : CharacterStatsWelcome + if err = s.Stats.Deserialize(reader); err != nil { + return + } + // Equipment : field : EquipmentWelcome + if err = s.Equipment.Deserialize(reader); err != nil { + return + } + // GuildRank : field : char + s.GuildRank = reader.GetChar() + // Settings : field : ServerSettings + if err = s.Settings.Deserialize(reader); err != nil { + return + } + // LoginMessageCode : field : LoginMessageCode + s.LoginMessageCode = LoginMessageCode(reader.GetChar()) + if err = reader.NextChunk(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type WelcomeReplyWelcomeCodeDataEnterGame struct { + byteSize int + + News []string + Weight net.Weight + Items []net.Item + Spells []net.Spell + Nearby NearbyInfo +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeReplyWelcomeCodeDataEnterGame) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeReplyWelcomeCodeDataEnterGame) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.AddByte(255) + // News : array : string + for ndx := 0; ndx < 9; ndx++ { + if len(s.News) != 9 { + err = fmt.Errorf("expected News with length 9, got %d", len(s.News)) + return + } + + if err = writer.AddString(s.News[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // Items : array : Item + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Spells : array : Spell + for ndx := 0; ndx < len(s.Spells); ndx++ { + if err = s.Spells[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Nearby : field : NearbyInfo + if err = s.Nearby.Serialize(writer); err != nil { + return + } + return +} + +func (s *WelcomeReplyWelcomeCodeDataEnterGame) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + if err = reader.NextChunk(); err != nil { + return + } + // News : array : string + for ndx := 0; ndx < 9; ndx++ { + s.News = append(s.News, "") + if s.News[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // Items : array : Item + ItemsRemaining := reader.Remaining() + for ndx := 0; ndx < ItemsRemaining/6; ndx++ { + s.Items = append(s.Items, net.Item{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Spells : array : Spell + SpellsRemaining := reader.Remaining() + for ndx := 0; ndx < SpellsRemaining/4; ndx++ { + s.Spells = append(s.Spells, net.Spell{}) + if err = s.Spells[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Nearby : field : NearbyInfo + if err = s.Nearby.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s WelcomeReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Welcome +} + +func (s WelcomeReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WelcomeReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WelcomeReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // WelcomeCode : field : WelcomeCode + if err = writer.AddShort(int(s.WelcomeCode)); err != nil { + return + } + writer.SanitizeStrings = true + switch s.WelcomeCode { + case WelcomeCode_SelectCharacter: + switch s.WelcomeCodeData.(type) { + case *WelcomeReplyWelcomeCodeDataSelectCharacter: + if err = s.WelcomeCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.WelcomeCode) + return + } + case WelcomeCode_EnterGame: + switch s.WelcomeCodeData.(type) { + case *WelcomeReplyWelcomeCodeDataEnterGame: + if err = s.WelcomeCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.WelcomeCode) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *WelcomeReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // WelcomeCode : field : WelcomeCode + s.WelcomeCode = WelcomeCode(reader.GetShort()) + reader.SetIsChunked(true) + switch s.WelcomeCode { + case WelcomeCode_SelectCharacter: + s.WelcomeCodeData = &WelcomeReplyWelcomeCodeDataSelectCharacter{} + if err = s.WelcomeCodeData.Deserialize(reader); err != nil { + return + } + case WelcomeCode_EnterGame: + s.WelcomeCodeData = &WelcomeReplyWelcomeCodeDataEnterGame{} + if err = s.WelcomeCodeData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractReplyServerPacket :: Incoming admin message. +type AdminInteractReplyServerPacket struct { + byteSize int + + MessageType AdminMessageType + MessageTypeData AdminInteractReplyMessageTypeData +} + +type AdminInteractReplyMessageTypeData interface { + protocol.EoData +} + +type AdminInteractReplyMessageTypeDataMessage struct { + byteSize int + + PlayerName string + Message string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractReplyMessageTypeDataMessage) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractReplyMessageTypeDataMessage) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.AddByte(255) + return +} + +func (s *AdminInteractReplyMessageTypeDataMessage) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type AdminInteractReplyMessageTypeDataReport struct { + byteSize int + + PlayerName string + Message string + ReporteeName string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractReplyMessageTypeDataReport) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractReplyMessageTypeDataReport) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.AddByte(255) + // ReporteeName : field : string + if err = writer.AddString(s.ReporteeName); err != nil { + return + } + writer.AddByte(255) + return +} + +func (s *AdminInteractReplyMessageTypeDataReport) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // ReporteeName : field : string + if s.ReporteeName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s AdminInteractReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // MessageType : field : AdminMessageType + if err = writer.AddChar(int(s.MessageType)); err != nil { + return + } + writer.AddByte(255) + switch s.MessageType { + case AdminMessage_Message: + switch s.MessageTypeData.(type) { + case *AdminInteractReplyMessageTypeDataMessage: + if err = s.MessageTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.MessageType) + return + } + case AdminMessage_Report: + switch s.MessageTypeData.(type) { + case *AdminInteractReplyMessageTypeDataReport: + if err = s.MessageTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.MessageType) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *AdminInteractReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // MessageType : field : AdminMessageType + s.MessageType = AdminMessageType(reader.GetChar()) + if err = reader.NextChunk(); err != nil { + return + } + switch s.MessageType { + case AdminMessage_Message: + s.MessageTypeData = &AdminInteractReplyMessageTypeDataMessage{} + if err = s.MessageTypeData.Deserialize(reader); err != nil { + return + } + case AdminMessage_Report: + s.MessageTypeData = &AdminInteractReplyMessageTypeDataReport{} + if err = s.MessageTypeData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractRemoveServerPacket :: Nearby player disappearing (admin hide). +type AdminInteractRemoveServerPacket struct { + byteSize int + + PlayerId int +} + +func (s AdminInteractRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *AdminInteractRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractAgreeServerPacket :: Nearby player appearing (admin un-hide). +type AdminInteractAgreeServerPacket struct { + byteSize int + + PlayerId int +} + +func (s AdminInteractAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *AdminInteractAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractListServerPacket :: Admin character inventory popup. +type AdminInteractListServerPacket struct { + byteSize int + + Name string + Usage int + GoldBank int + Inventory []net.Item + Bank []net.ThreeItem +} + +func (s AdminInteractListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Usage : field : int + if err = writer.AddInt(s.Usage); err != nil { + return + } + writer.AddByte(255) + // GoldBank : field : int + if err = writer.AddInt(s.GoldBank); err != nil { + return + } + writer.AddByte(255) + // Inventory : array : Item + for ndx := 0; ndx < len(s.Inventory); ndx++ { + if err = s.Inventory[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Bank : array : ThreeItem + for ndx := 0; ndx < len(s.Bank); ndx++ { + if err = s.Bank[ndx].Serialize(writer); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *AdminInteractListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Usage : field : int + s.Usage = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // GoldBank : field : int + s.GoldBank = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // Inventory : array : Item + InventoryRemaining := reader.Remaining() + for ndx := 0; ndx < InventoryRemaining/6; ndx++ { + s.Inventory = append(s.Inventory, net.Item{}) + if err = s.Inventory[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Bank : array : ThreeItem + BankRemaining := reader.Remaining() + for ndx := 0; ndx < BankRemaining/5; ndx++ { + s.Bank = append(s.Bank, net.ThreeItem{}) + if err = s.Bank[ndx].Deserialize(reader); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AdminInteractTellServerPacket :: Admin character info lookup. +type AdminInteractTellServerPacket struct { + byteSize int + + Name string + Usage int + Exp int + Level int + MapId int + MapCoords BigCoords + Stats CharacterStatsInfoLookup + Weight net.Weight +} + +func (s AdminInteractTellServerPacket) Family() net.PacketFamily { + return net.PacketFamily_AdminInteract +} + +func (s AdminInteractTellServerPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AdminInteractTellServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AdminInteractTellServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Usage : field : int + if err = writer.AddInt(s.Usage); err != nil { + return + } + writer.AddByte(255) + writer.AddByte(255) + // Exp : field : int + if err = writer.AddInt(s.Exp); err != nil { + return + } + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // MapCoords : field : BigCoords + if err = s.MapCoords.Serialize(writer); err != nil { + return + } + // Stats : field : CharacterStatsInfoLookup + if err = s.Stats.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *AdminInteractTellServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Usage : field : int + s.Usage = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + // Exp : field : int + s.Exp = reader.GetInt() + // Level : field : char + s.Level = reader.GetChar() + // MapId : field : short + s.MapId = reader.GetShort() + // MapCoords : field : BigCoords + if err = s.MapCoords.Deserialize(reader); err != nil { + return + } + // Stats : field : CharacterStatsInfoLookup + if err = s.Stats.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkRequestServerPacket :: Guild chat message. +type TalkRequestServerPacket struct { + byteSize int + + PlayerName string + Message string +} + +func (s TalkRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkOpenServerPacket :: Party chat message. +type TalkOpenServerPacket struct { + byteSize int + + PlayerId int + Message string +} + +func (s TalkOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkMsgServerPacket :: Global chat message. +type TalkMsgServerPacket struct { + byteSize int + + PlayerName string + Message string +} + +func (s TalkMsgServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkMsgServerPacket) Action() net.PacketAction { + return net.PacketAction_Msg +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkMsgServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkMsgServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkMsgServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkTellServerPacket :: Private chat message. +type TalkTellServerPacket struct { + byteSize int + + PlayerName string + Message string +} + +func (s TalkTellServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkTellServerPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkTellServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkTellServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkTellServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkPlayerServerPacket :: Public chat message. +type TalkPlayerServerPacket struct { + byteSize int + + PlayerId int + Message string +} + +func (s TalkPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkReplyServerPacket :: Reply to trying to send a private message. +type TalkReplyServerPacket struct { + byteSize int + + ReplyCode TalkReply + Name string +} + +func (s TalkReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : TalkReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *TalkReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : TalkReply + s.ReplyCode = TalkReply(reader.GetShort()) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkAdminServerPacket :: Admin chat message. +type TalkAdminServerPacket struct { + byteSize int + + PlayerName string + Message string +} + +func (s TalkAdminServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkAdminServerPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkAdminServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkAdminServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkAdminServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkAnnounceServerPacket :: Admin announcement. +type TalkAnnounceServerPacket struct { + byteSize int + + PlayerName string + Message string +} + +func (s TalkAnnounceServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkAnnounceServerPacket) Action() net.PacketAction { + return net.PacketAction_Announce +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkAnnounceServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkAnnounceServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *TalkAnnounceServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkServerServerPacket :: Server message. +type TalkServerServerPacket struct { + byteSize int + + Message string +} + +func (s TalkServerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkServerServerPacket) Action() net.PacketAction { + return net.PacketAction_Server +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkServerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkServerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *TalkServerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkListServerPacket :: Global chat backfill. Sent by the official game server when a player opens the global chat tab. +type TalkListServerPacket struct { + byteSize int + + Messages []GlobalBackfillMessage +} + +func (s TalkListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Messages : array : GlobalBackfillMessage + for ndx := 0; ndx < len(s.Messages); ndx++ { + if err = s.Messages[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *TalkListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Messages : array : GlobalBackfillMessage + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Messages = append(s.Messages, GlobalBackfillMessage{}) + if err = s.Messages[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MessageOpenServerPacket :: Status bar message. +type MessageOpenServerPacket struct { + byteSize int + + Message string +} + +func (s MessageOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Message +} + +func (s MessageOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MessageOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MessageOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *MessageOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MessageCloseServerPacket :: Server is rebooting. +type MessageCloseServerPacket struct { + byteSize int +} + +func (s MessageCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Message +} + +func (s MessageCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MessageCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MessageCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // r : dummy : string + if err = writer.AddString("r"); err != nil { + return + } + return +} + +func (s *MessageCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // r : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MessageAcceptServerPacket :: Large message box. +type MessageAcceptServerPacket struct { + byteSize int + + Messages []string +} + +func (s MessageAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Message +} + +func (s MessageAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MessageAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MessageAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Messages : array : string + for ndx := 0; ndx < 4; ndx++ { + if len(s.Messages) != 4 { + err = fmt.Errorf("expected Messages with length 4, got %d", len(s.Messages)) + return + } + + if err = writer.AddString(s.Messages[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *MessageAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Messages : array : string + for ndx := 0; ndx < 4; ndx++ { + s.Messages = append(s.Messages, "") + if s.Messages[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkSpecServerPacket :: Temporary mute applied. +type TalkSpecServerPacket struct { + byteSize int + + AdminName string +} + +func (s TalkSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Talk +} + +func (s TalkSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TalkSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // AdminName : field : string + if err = writer.AddString(s.AdminName); err != nil { + return + } + return +} + +func (s *TalkSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // AdminName : field : string + if s.AdminName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AttackPlayerServerPacket :: Nearby player attacking. +type AttackPlayerServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction +} + +func (s AttackPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Attack +} + +func (s AttackPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AttackPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AttackPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *AttackPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AttackErrorServerPacket :: Show flood protection message (vestigial). +type AttackErrorServerPacket struct { + byteSize int +} + +func (s AttackErrorServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Attack +} + +func (s AttackErrorServerPacket) Action() net.PacketAction { + return net.PacketAction_Error +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AttackErrorServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AttackErrorServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *AttackErrorServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AvatarReplyServerPacket :: Nearby player hit by another player. +type AvatarReplyServerPacket struct { + byteSize int + + PlayerId int + VictimId int + Damage int + Direction protocol.Direction + HpPercentage int + Dead bool +} + +func (s AvatarReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Avatar +} + +func (s AvatarReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AvatarReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AvatarReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // VictimId : field : short + if err = writer.AddShort(s.VictimId); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Dead : field : bool + if s.Dead { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + return +} + +func (s *AvatarReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // VictimId : field : short + s.VictimId = reader.GetShort() + // Damage : field : three + s.Damage = reader.GetThree() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Dead : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Dead = true + } else { + s.Dead = false + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChairPlayerServerPacket :: Nearby player sitting on a chair. +type ChairPlayerServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords + Direction protocol.Direction +} + +func (s ChairPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chair +} + +func (s ChairPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChairPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *ChairPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChairReplyServerPacket :: Your character sitting on a chair. +type ChairReplyServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords + Direction protocol.Direction +} + +func (s ChairReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chair +} + +func (s ChairReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChairReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *ChairReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChairCloseServerPacket :: Your character standing up from a chair. +type ChairCloseServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords +} + +func (s ChairCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chair +} + +func (s ChairCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChairCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChairCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChairRemoveServerPacket :: Nearby player standing up from a chair. +type ChairRemoveServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords +} + +func (s ChairRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chair +} + +func (s ChairRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChairRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChairRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChairRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SitPlayerServerPacket :: Nearby player sitting down. +type SitPlayerServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords + Direction protocol.Direction +} + +func (s SitPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Sit +} + +func (s SitPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SitPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + return +} + +func (s *SitPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // 0 : field : char + reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SitCloseServerPacket :: Your character standing up. +type SitCloseServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords +} + +func (s SitCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Sit +} + +func (s SitCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SitCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *SitCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SitRemoveServerPacket :: Nearby player standing up. +type SitRemoveServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords +} + +func (s SitRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Sit +} + +func (s SitRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SitRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *SitRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SitReplyServerPacket :: Your character sitting down. +type SitReplyServerPacket struct { + byteSize int + + PlayerId int + Coords protocol.Coords + Direction protocol.Direction +} + +func (s SitReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Sit +} + +func (s SitReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SitReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SitReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + return +} + +func (s *SitReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // 0 : field : char + reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EmotePlayerServerPacket :: Nearby player doing an emote. +type EmotePlayerServerPacket struct { + byteSize int + + PlayerId int + Emote protocol.Emote +} + +func (s EmotePlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Emote +} + +func (s EmotePlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EmotePlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EmotePlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Emote : field : Emote + if err = writer.AddChar(int(s.Emote)); err != nil { + return + } + return +} + +func (s *EmotePlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Emote : field : Emote + s.Emote = protocol.Emote(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectPlayerServerPacket :: Effects playing on nearby players. +type EffectPlayerServerPacket struct { + byteSize int + + Effects []PlayerEffect +} + +func (s EffectPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Effects : array : PlayerEffect + for ndx := 0; ndx < len(s.Effects); ndx++ { + if err = s.Effects[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *EffectPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Effects : array : PlayerEffect + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Effects = append(s.Effects, PlayerEffect{}) + if err = s.Effects[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// FacePlayerServerPacket :: Nearby player facing a direction. +type FacePlayerServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction +} + +func (s FacePlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Face +} + +func (s FacePlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *FacePlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *FacePlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *FacePlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AvatarRemoveServerPacket :: Nearby player has disappeared from view. +type AvatarRemoveServerPacket struct { + byteSize int + + PlayerId int + WarpEffect *WarpEffect +} + +func (s AvatarRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Avatar +} + +func (s AvatarRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AvatarRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AvatarRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // WarpEffect : field : WarpEffect + if s.WarpEffect != nil { + if err = writer.AddChar(int(*s.WarpEffect)); err != nil { + return + } + } + return +} + +func (s *AvatarRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // WarpEffect : field : WarpEffect + if reader.Remaining() > 0 { + s.WarpEffect = new(WarpEffect) + *s.WarpEffect = WarpEffect(reader.GetChar()) + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersAgreeServerPacket :: Player has appeared in nearby view. +type PlayersAgreeServerPacket struct { + byteSize int + + Nearby NearbyInfo +} + +func (s PlayersAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Nearby : field : NearbyInfo + if err = s.Nearby.Serialize(writer); err != nil { + return + } + return +} + +func (s *PlayersAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Nearby : field : NearbyInfo + if err = s.Nearby.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersRemoveServerPacket :: Nearby player has logged out. +type PlayersRemoveServerPacket struct { + byteSize int + + PlayerId int +} + +func (s PlayersRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *PlayersRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RangeReplyServerPacket :: Reply to request for information about nearby players and NPCs. +type RangeReplyServerPacket struct { + byteSize int + + Nearby NearbyInfo +} + +func (s RangeReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Range +} + +func (s RangeReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RangeReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RangeReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Nearby : field : NearbyInfo + if err = s.Nearby.Serialize(writer); err != nil { + return + } + return +} + +func (s *RangeReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Nearby : field : NearbyInfo + if err = s.Nearby.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcAgreeServerPacket :: Reply to request for information about nearby NPCs. +type NpcAgreeServerPacket struct { + byteSize int + + Npcs []NpcMapInfo +} + +func (s NpcAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcsCount : length : char + if err = writer.AddChar(len(s.Npcs)); err != nil { + return + } + // Npcs : array : NpcMapInfo + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *NpcAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcsCount : length : char + npcsCount := reader.GetChar() + // Npcs : array : NpcMapInfo + for ndx := 0; ndx < npcsCount; ndx++ { + s.Npcs = append(s.Npcs, NpcMapInfo{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkPlayerServerPacket :: Nearby player has walked. +type WalkPlayerServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction + Coords protocol.Coords +} + +func (s WalkPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *WalkPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkReplyServerPacket :: Players, NPCs, and Items appearing in nearby view. +type WalkReplyServerPacket struct { + byteSize int + + PlayerIds []int + NpcIndexes []int + Items []ItemMapInfo +} + +func (s WalkReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerIds : array : short + for ndx := 0; ndx < len(s.PlayerIds); ndx++ { + if err = writer.AddShort(s.PlayerIds[ndx]); err != nil { + return + } + } + + writer.AddByte(255) + // NpcIndexes : array : char + for ndx := 0; ndx < len(s.NpcIndexes); ndx++ { + if err = writer.AddChar(s.NpcIndexes[ndx]); err != nil { + return + } + } + + writer.AddByte(255) + // Items : array : ItemMapInfo + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *WalkReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerIds : array : short + PlayerIdsRemaining := reader.Remaining() + for ndx := 0; ndx < PlayerIdsRemaining/2; ndx++ { + s.PlayerIds = append(s.PlayerIds, 0) + s.PlayerIds[ndx] = reader.GetShort() + } + + if err = reader.NextChunk(); err != nil { + return + } + // NpcIndexes : array : char + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.NpcIndexes = append(s.NpcIndexes, 0) + s.NpcIndexes[ndx] = reader.GetChar() + } + + if err = reader.NextChunk(); err != nil { + return + } + // Items : array : ItemMapInfo + ItemsRemaining := reader.Remaining() + for ndx := 0; ndx < ItemsRemaining/9; ndx++ { + s.Items = append(s.Items, ItemMapInfo{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkCloseServerPacket :: Your character has been frozen. +type WalkCloseServerPacket struct { + byteSize int +} + +func (s WalkCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // S : dummy : string + if err = writer.AddString("S"); err != nil { + return + } + return +} + +func (s *WalkCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // S : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WalkOpenServerPacket :: Your character has been unfrozen. +type WalkOpenServerPacket struct { + byteSize int +} + +func (s WalkOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Walk +} + +func (s WalkOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WalkOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WalkOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // S : dummy : string + if err = writer.AddString("S"); err != nil { + return + } + return +} + +func (s *WalkOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // S : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BankOpenServerPacket :: Open banker NPC interface. +type BankOpenServerPacket struct { + byteSize int + + GoldBank int + SessionId int + LockerUpgrades int +} + +func (s BankOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Bank +} + +func (s BankOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BankOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BankOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldBank : field : int + if err = writer.AddInt(s.GoldBank); err != nil { + return + } + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + // LockerUpgrades : field : char + if err = writer.AddChar(s.LockerUpgrades); err != nil { + return + } + return +} + +func (s *BankOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldBank : field : int + s.GoldBank = reader.GetInt() + // SessionId : field : three + s.SessionId = reader.GetThree() + // LockerUpgrades : field : char + s.LockerUpgrades = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BankReplyServerPacket :: Update gold counts after deposit/withdraw. +type BankReplyServerPacket struct { + byteSize int + + GoldInventory int + GoldBank int +} + +func (s BankReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Bank +} + +func (s BankReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BankReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BankReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldInventory : field : int + if err = writer.AddInt(s.GoldInventory); err != nil { + return + } + // GoldBank : field : int + if err = writer.AddInt(s.GoldBank); err != nil { + return + } + return +} + +func (s *BankReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldInventory : field : int + s.GoldInventory = reader.GetInt() + // GoldBank : field : int + s.GoldBank = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BarberAgreeServerPacket :: Purchasing a new hair style. +type BarberAgreeServerPacket struct { + byteSize int + + GoldAmount int + Change AvatarChange +} + +func (s BarberAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Barber +} + +func (s BarberAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BarberAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BarberAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + // Change : field : AvatarChange + if err = s.Change.Serialize(writer); err != nil { + return + } + return +} + +func (s *BarberAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + // Change : field : AvatarChange + if err = s.Change.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BarberOpenServerPacket :: Response from talking to a barber NPC. +type BarberOpenServerPacket struct { + byteSize int + + SessionId int +} + +func (s BarberOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Barber +} + +func (s BarberOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BarberOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BarberOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *BarberOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerReplyServerPacket :: Response to adding an item to a bank locker. +type LockerReplyServerPacket struct { + byteSize int + + DepositedItem net.Item + Weight net.Weight + LockerItems []net.ThreeItem +} + +func (s LockerReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // DepositedItem : field : Item + if err = s.DepositedItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; ndx < len(s.LockerItems); ndx++ { + if err = s.LockerItems[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *LockerReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // DepositedItem : field : Item + if err = s.DepositedItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.LockerItems = append(s.LockerItems, net.ThreeItem{}) + if err = s.LockerItems[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerGetServerPacket :: Response to taking an item from a bank locker. +type LockerGetServerPacket struct { + byteSize int + + TakenItem net.ThreeItem + Weight net.Weight + LockerItems []net.ThreeItem +} + +func (s LockerGetServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerGetServerPacket) Action() net.PacketAction { + return net.PacketAction_Get +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerGetServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerGetServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TakenItem : field : ThreeItem + if err = s.TakenItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; ndx < len(s.LockerItems); ndx++ { + if err = s.LockerItems[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *LockerGetServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TakenItem : field : ThreeItem + if err = s.TakenItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.LockerItems = append(s.LockerItems, net.ThreeItem{}) + if err = s.LockerItems[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerOpenServerPacket :: Opening a bank locker. +type LockerOpenServerPacket struct { + byteSize int + + LockerCoords protocol.Coords + LockerItems []net.ThreeItem +} + +func (s LockerOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LockerCoords : field : Coords + if err = s.LockerCoords.Serialize(writer); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; ndx < len(s.LockerItems); ndx++ { + if err = s.LockerItems[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *LockerOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LockerCoords : field : Coords + if err = s.LockerCoords.Deserialize(reader); err != nil { + return + } + // LockerItems : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.LockerItems = append(s.LockerItems, net.ThreeItem{}) + if err = s.LockerItems[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerBuyServerPacket :: Response to buying a locker space upgrade from a banker NPC. +type LockerBuyServerPacket struct { + byteSize int + + GoldAmount int + LockerUpgrades int +} + +func (s LockerBuyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerBuyServerPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerBuyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerBuyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + // LockerUpgrades : field : char + if err = writer.AddChar(s.LockerUpgrades); err != nil { + return + } + return +} + +func (s *LockerBuyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + // LockerUpgrades : field : char + s.LockerUpgrades = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LockerSpecServerPacket :: Reply to trying to add an item to a full locker. +type LockerSpecServerPacket struct { + byteSize int + + LockerMaxItems int +} + +func (s LockerSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Locker +} + +func (s LockerSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LockerSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *LockerSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LockerMaxItems : field : char + if err = writer.AddChar(s.LockerMaxItems); err != nil { + return + } + return +} + +func (s *LockerSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LockerMaxItems : field : char + s.LockerMaxItems = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenReplyServerPacket :: Response to subscribing to a town. +type CitizenReplyServerPacket struct { + byteSize int + + QuestionsWrong int +} + +func (s CitizenReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // QuestionsWrong : field : char + if err = writer.AddChar(s.QuestionsWrong); err != nil { + return + } + return +} + +func (s *CitizenReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // QuestionsWrong : field : char + s.QuestionsWrong = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenRemoveServerPacket :: Response to giving up citizenship of a town. +type CitizenRemoveServerPacket struct { + byteSize int + + ReplyCode InnUnsubscribeReply +} + +func (s CitizenRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : InnUnsubscribeReply + if err = writer.AddChar(int(s.ReplyCode)); err != nil { + return + } + return +} + +func (s *CitizenRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : InnUnsubscribeReply + s.ReplyCode = InnUnsubscribeReply(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenOpenServerPacket :: Response from talking to a citizenship NPC. +type CitizenOpenServerPacket struct { + byteSize int + + BehaviorId int + CurrentHomeId int + SessionId int + Questions []string +} + +func (s CitizenOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // BehaviorId : field : three + if err = writer.AddThree(s.BehaviorId); err != nil { + return + } + // CurrentHomeId : field : char + if err = writer.AddChar(s.CurrentHomeId); err != nil { + return + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + writer.AddByte(255) + // Questions : array : string + for ndx := 0; ndx < 3; ndx++ { + if len(s.Questions) != 3 { + err = fmt.Errorf("expected Questions with length 3, got %d", len(s.Questions)) + return + } + + if ndx > 0 { + writer.AddByte(255) + } + + if err = writer.AddString(s.Questions[ndx]); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *CitizenOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // BehaviorId : field : three + s.BehaviorId = reader.GetThree() + // CurrentHomeId : field : char + s.CurrentHomeId = reader.GetChar() + // SessionId : field : short + s.SessionId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Questions : array : string + for ndx := 0; ndx < 3; ndx++ { + s.Questions = append(s.Questions, "") + if s.Questions[ndx], err = reader.GetString(); err != nil { + return + } + + if ndx+1 < 3 { + if err = reader.NextChunk(); err != nil { + return + } + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenRequestServerPacket :: Reply to requesting sleeping at an inn. +type CitizenRequestServerPacket struct { + byteSize int + + Cost int +} + +func (s CitizenRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Cost : field : int + if err = writer.AddInt(s.Cost); err != nil { + return + } + return +} + +func (s *CitizenRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Cost : field : int + s.Cost = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CitizenAcceptServerPacket :: Sleeping at an inn. +type CitizenAcceptServerPacket struct { + byteSize int + + GoldAmount int +} + +func (s CitizenAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Citizen +} + +func (s CitizenAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CitizenAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CitizenAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *CitizenAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopCreateServerPacket :: Response to crafting an item from a shop. +type ShopCreateServerPacket struct { + byteSize int + + CraftItemId int + Weight net.Weight + Ingredients []net.Item +} + +func (s ShopCreateServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopCreateServerPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopCreateServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopCreateServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CraftItemId : field : short + if err = writer.AddShort(s.CraftItemId); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // Ingredients : array : Item + for ndx := 0; ndx < 4; ndx++ { + if len(s.Ingredients) != 4 { + err = fmt.Errorf("expected Ingredients with length 4, got %d", len(s.Ingredients)) + return + } + + if err = s.Ingredients[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ShopCreateServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CraftItemId : field : short + s.CraftItemId = reader.GetShort() + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // Ingredients : array : Item + for ndx := 0; ndx < 4; ndx++ { + s.Ingredients = append(s.Ingredients, net.Item{}) + if err = s.Ingredients[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopBuyServerPacket :: Response to purchasing an item from a shop. +type ShopBuyServerPacket struct { + byteSize int + + GoldAmount int + BoughtItem net.Item + Weight net.Weight +} + +func (s ShopBuyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopBuyServerPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopBuyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopBuyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + // BoughtItem : field : Item + if err = s.BoughtItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + return +} + +func (s *ShopBuyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + // BoughtItem : field : Item + if err = s.BoughtItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopSellServerPacket :: Response to selling an item to a shop. +type ShopSellServerPacket struct { + byteSize int + + SoldItem ShopSoldItem + GoldAmount int + Weight net.Weight +} + +func (s ShopSellServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopSellServerPacket) Action() net.PacketAction { + return net.PacketAction_Sell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopSellServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopSellServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SoldItem : field : ShopSoldItem + if err = s.SoldItem.Serialize(writer); err != nil { + return + } + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + return +} + +func (s *ShopSellServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SoldItem : field : ShopSoldItem + if err = s.SoldItem.Deserialize(reader); err != nil { + return + } + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopOpenServerPacket :: Response from talking to a shop NPC. +type ShopOpenServerPacket struct { + byteSize int + + SessionId int + ShopName string + TradeItems []ShopTradeItem + CraftItems []ShopCraftItem +} + +func (s ShopOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Shop +} + +func (s ShopOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ShopOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // ShopName : field : string + if err = writer.AddString(s.ShopName); err != nil { + return + } + writer.AddByte(255) + // TradeItems : array : ShopTradeItem + for ndx := 0; ndx < len(s.TradeItems); ndx++ { + if err = s.TradeItems[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // CraftItems : array : ShopCraftItem + for ndx := 0; ndx < len(s.CraftItems); ndx++ { + if err = s.CraftItems[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *ShopOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : short + s.SessionId = reader.GetShort() + // ShopName : field : string + if s.ShopName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // TradeItems : array : ShopTradeItem + TradeItemsRemaining := reader.Remaining() + for ndx := 0; ndx < TradeItemsRemaining/9; ndx++ { + s.TradeItems = append(s.TradeItems, ShopTradeItem{}) + if err = s.TradeItems[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // CraftItems : array : ShopCraftItem + CraftItemsRemaining := reader.Remaining() + for ndx := 0; ndx < CraftItemsRemaining/14; ndx++ { + s.CraftItems = append(s.CraftItems, ShopCraftItem{}) + if err = s.CraftItems[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillOpenServerPacket :: Response from talking to a skill master NPC. +type StatSkillOpenServerPacket struct { + byteSize int + + SessionId int + ShopName string + Skills []SkillLearn +} + +func (s StatSkillOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // ShopName : field : string + if err = writer.AddString(s.ShopName); err != nil { + return + } + writer.AddByte(255) + // Skills : array : SkillLearn + for ndx := 0; ndx < len(s.Skills); ndx++ { + if err = s.Skills[ndx].Serialize(writer); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *StatSkillOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // SessionId : field : short + s.SessionId = reader.GetShort() + // ShopName : field : string + if s.ShopName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Skills : array : SkillLearn + SkillsRemaining := reader.Remaining() + for ndx := 0; ndx < SkillsRemaining/28; ndx++ { + s.Skills = append(s.Skills, SkillLearn{}) + if err = s.Skills[ndx].Deserialize(reader); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillReplyServerPacket :: Response from unsuccessful action at a skill master. +type StatSkillReplyServerPacket struct { + byteSize int + + ReplyCode SkillMasterReply + ReplyCodeData StatSkillReplyReplyCodeData +} + +type StatSkillReplyReplyCodeData interface { + protocol.EoData +} + +type StatSkillReplyReplyCodeDataWrongClass struct { + byteSize int + + ClassId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillReplyReplyCodeDataWrongClass) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillReplyReplyCodeDataWrongClass) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + return +} + +func (s *StatSkillReplyReplyCodeDataWrongClass) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ClassId : field : char + s.ClassId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s StatSkillReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : SkillMasterReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case SkillMasterReply_WrongClass: + switch s.ReplyCodeData.(type) { + case *StatSkillReplyReplyCodeDataWrongClass: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *StatSkillReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : SkillMasterReply + s.ReplyCode = SkillMasterReply(reader.GetShort()) + switch s.ReplyCode { + case SkillMasterReply_WrongClass: + s.ReplyCodeData = &StatSkillReplyReplyCodeDataWrongClass{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillTakeServerPacket :: Response from learning a skill from a skill master. +type StatSkillTakeServerPacket struct { + byteSize int + + SpellId int + GoldAmount int +} + +func (s StatSkillTakeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillTakeServerPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillTakeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillTakeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *StatSkillTakeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillRemoveServerPacket :: Response to forgetting a skill at a skill master. +type StatSkillRemoveServerPacket struct { + byteSize int + + SpellId int +} + +func (s StatSkillRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *StatSkillRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillPlayerServerPacket :: Response to spending stat points. +type StatSkillPlayerServerPacket struct { + byteSize int + + StatPoints int + Stats CharacterStatsUpdate +} + +func (s StatSkillPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // Stats : field : CharacterStatsUpdate + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *StatSkillPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // Stats : field : CharacterStatsUpdate + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillAcceptServerPacket :: Response to spending skill points. +type StatSkillAcceptServerPacket struct { + byteSize int + + SkillPoints int + Spell net.Spell +} + +func (s StatSkillAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // Spell : field : Spell + if err = s.Spell.Serialize(writer); err != nil { + return + } + return +} + +func (s *StatSkillAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // Spell : field : Spell + if err = s.Spell.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// StatSkillJunkServerPacket :: Response to resetting stats and skills at a skill master. +type StatSkillJunkServerPacket struct { + byteSize int + + Stats CharacterStatsReset +} + +func (s StatSkillJunkServerPacket) Family() net.PacketFamily { + return net.PacketFamily_StatSkill +} + +func (s StatSkillJunkServerPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *StatSkillJunkServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *StatSkillJunkServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Stats : field : CharacterStatsReset + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *StatSkillJunkServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Stats : field : CharacterStatsReset + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemReplyServerPacket :: Reply to using an item. +type ItemReplyServerPacket struct { + byteSize int + + ItemType pub.ItemType + UsedItem net.Item + Weight net.Weight + ItemTypeData ItemReplyItemTypeData +} + +type ItemReplyItemTypeData interface { + protocol.EoData +} + +type ItemReplyItemTypeDataHeal struct { + byteSize int + + HpGain int + Hp int + Tp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyItemTypeDataHeal) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyItemTypeDataHeal) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HpGain : field : int + if err = writer.AddInt(s.HpGain); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + return +} + +func (s *ItemReplyItemTypeDataHeal) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HpGain : field : int + s.HpGain = reader.GetInt() + // Hp : field : short + s.Hp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ItemReplyItemTypeDataHairDye struct { + byteSize int + + HairColor int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyItemTypeDataHairDye) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyItemTypeDataHairDye) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + return +} + +func (s *ItemReplyItemTypeDataHairDye) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HairColor : field : char + s.HairColor = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ItemReplyItemTypeDataEffectPotion struct { + byteSize int + + EffectId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyItemTypeDataEffectPotion) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyItemTypeDataEffectPotion) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EffectId : field : short + if err = writer.AddShort(s.EffectId); err != nil { + return + } + return +} + +func (s *ItemReplyItemTypeDataEffectPotion) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EffectId : field : short + s.EffectId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ItemReplyItemTypeDataCureCurse struct { + byteSize int + + Stats CharacterStatsEquipmentChange +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyItemTypeDataCureCurse) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyItemTypeDataCureCurse) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemReplyItemTypeDataCureCurse) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ItemReplyItemTypeDataExpReward struct { + byteSize int + + Experience int + LevelUp int // A value greater than 0 is "new level" and indicates the player leveled up. + StatPoints int + SkillPoints int + MaxHp int + MaxTp int + MaxSp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyItemTypeDataExpReward) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyItemTypeDataExpReward) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Experience : field : int + if err = writer.AddInt(s.Experience); err != nil { + return + } + // LevelUp : field : char + if err = writer.AddChar(s.LevelUp); err != nil { + return + } + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + return +} + +func (s *ItemReplyItemTypeDataExpReward) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Experience : field : int + s.Experience = reader.GetInt() + // LevelUp : field : char + s.LevelUp = reader.GetChar() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s ItemReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemType : field : ItemType + if err = writer.AddChar(int(s.ItemType)); err != nil { + return + } + // UsedItem : field : Item + if err = s.UsedItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + switch s.ItemType { + case pub.Item_Heal: + switch s.ItemTypeData.(type) { + case *ItemReplyItemTypeDataHeal: + if err = s.ItemTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ItemType) + return + } + case pub.Item_HairDye: + switch s.ItemTypeData.(type) { + case *ItemReplyItemTypeDataHairDye: + if err = s.ItemTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ItemType) + return + } + case pub.Item_EffectPotion: + switch s.ItemTypeData.(type) { + case *ItemReplyItemTypeDataEffectPotion: + if err = s.ItemTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ItemType) + return + } + case pub.Item_CureCurse: + switch s.ItemTypeData.(type) { + case *ItemReplyItemTypeDataCureCurse: + if err = s.ItemTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ItemType) + return + } + case pub.Item_ExpReward: + switch s.ItemTypeData.(type) { + case *ItemReplyItemTypeDataExpReward: + if err = s.ItemTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ItemType) + return + } + } + return +} + +func (s *ItemReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemType : field : ItemType + s.ItemType = pub.ItemType(reader.GetChar()) + // UsedItem : field : Item + if err = s.UsedItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + switch s.ItemType { + case pub.Item_Heal: + s.ItemTypeData = &ItemReplyItemTypeDataHeal{} + if err = s.ItemTypeData.Deserialize(reader); err != nil { + return + } + case pub.Item_HairDye: + s.ItemTypeData = &ItemReplyItemTypeDataHairDye{} + if err = s.ItemTypeData.Deserialize(reader); err != nil { + return + } + case pub.Item_EffectPotion: + s.ItemTypeData = &ItemReplyItemTypeDataEffectPotion{} + if err = s.ItemTypeData.Deserialize(reader); err != nil { + return + } + case pub.Item_CureCurse: + s.ItemTypeData = &ItemReplyItemTypeDataCureCurse{} + if err = s.ItemTypeData.Deserialize(reader); err != nil { + return + } + case pub.Item_ExpReward: + s.ItemTypeData = &ItemReplyItemTypeDataExpReward{} + if err = s.ItemTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemDropServerPacket :: Reply to dropping items on the ground. +type ItemDropServerPacket struct { + byteSize int + + DroppedItem net.ThreeItem + RemainingAmount int + ItemIndex int + Coords protocol.Coords + Weight net.Weight +} + +func (s ItemDropServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemDropServerPacket) Action() net.PacketAction { + return net.PacketAction_Drop +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemDropServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemDropServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // DroppedItem : field : ThreeItem + if err = s.DroppedItem.Serialize(writer); err != nil { + return + } + // RemainingAmount : field : int + if err = writer.AddInt(s.RemainingAmount); err != nil { + return + } + // ItemIndex : field : short + if err = writer.AddShort(s.ItemIndex); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemDropServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // DroppedItem : field : ThreeItem + if err = s.DroppedItem.Deserialize(reader); err != nil { + return + } + // RemainingAmount : field : int + s.RemainingAmount = reader.GetInt() + // ItemIndex : field : short + s.ItemIndex = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemAddServerPacket :: Item appeared on the ground. +type ItemAddServerPacket struct { + byteSize int + + ItemId int + ItemIndex int + ItemAmount int + Coords protocol.Coords +} + +func (s ItemAddServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemAddServerPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemAddServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemAddServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // ItemIndex : field : short + if err = writer.AddShort(s.ItemIndex); err != nil { + return + } + // ItemAmount : field : three + if err = writer.AddThree(s.ItemAmount); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemAddServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // ItemIndex : field : short + s.ItemIndex = reader.GetShort() + // ItemAmount : field : three + s.ItemAmount = reader.GetThree() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemRemoveServerPacket :: Item disappeared from the ground. +type ItemRemoveServerPacket struct { + byteSize int + + ItemIndex int +} + +func (s ItemRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemIndex : field : short + if err = writer.AddShort(s.ItemIndex); err != nil { + return + } + return +} + +func (s *ItemRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemIndex : field : short + s.ItemIndex = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemJunkServerPacket :: Reply to junking items. +type ItemJunkServerPacket struct { + byteSize int + + JunkedItem net.ThreeItem + RemainingAmount int + Weight net.Weight +} + +func (s ItemJunkServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemJunkServerPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemJunkServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemJunkServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // JunkedItem : field : ThreeItem + if err = s.JunkedItem.Serialize(writer); err != nil { + return + } + // RemainingAmount : field : int + if err = writer.AddInt(s.RemainingAmount); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemJunkServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // JunkedItem : field : ThreeItem + if err = s.JunkedItem.Deserialize(reader); err != nil { + return + } + // RemainingAmount : field : int + s.RemainingAmount = reader.GetInt() + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemGetServerPacket :: Reply to taking items from the ground. +type ItemGetServerPacket struct { + byteSize int + + TakenItemIndex int + TakenItem net.ThreeItem + Weight net.Weight +} + +func (s ItemGetServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemGetServerPacket) Action() net.PacketAction { + return net.PacketAction_Get +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemGetServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemGetServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TakenItemIndex : field : short + if err = writer.AddShort(s.TakenItemIndex); err != nil { + return + } + // TakenItem : field : ThreeItem + if err = s.TakenItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + return +} + +func (s *ItemGetServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TakenItemIndex : field : short + s.TakenItemIndex = reader.GetShort() + // TakenItem : field : ThreeItem + if err = s.TakenItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemObtainServerPacket :: Receive item (from quest). +type ItemObtainServerPacket struct { + byteSize int + + Item net.ThreeItem + CurrentWeight int +} + +func (s ItemObtainServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemObtainServerPacket) Action() net.PacketAction { + return net.PacketAction_Obtain +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemObtainServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemObtainServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Item : field : ThreeItem + if err = s.Item.Serialize(writer); err != nil { + return + } + // CurrentWeight : field : char + if err = writer.AddChar(s.CurrentWeight); err != nil { + return + } + return +} + +func (s *ItemObtainServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Item : field : ThreeItem + if err = s.Item.Deserialize(reader); err != nil { + return + } + // CurrentWeight : field : char + s.CurrentWeight = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemKickServerPacket :: Lose item (from quest). +type ItemKickServerPacket struct { + byteSize int + + Item net.Item + CurrentWeight int +} + +func (s ItemKickServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemKickServerPacket) Action() net.PacketAction { + return net.PacketAction_Kick +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemKickServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemKickServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Item : field : Item + if err = s.Item.Serialize(writer); err != nil { + return + } + // CurrentWeight : field : char + if err = writer.AddChar(s.CurrentWeight); err != nil { + return + } + return +} + +func (s *ItemKickServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Item : field : Item + if err = s.Item.Deserialize(reader); err != nil { + return + } + // CurrentWeight : field : char + s.CurrentWeight = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemAgreeServerPacket :: Reply to using an item that you don't have. +type ItemAgreeServerPacket struct { + byteSize int + + ItemId int +} + +func (s ItemAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + return +} + +func (s *ItemAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemSpecServerPacket :: Reply to trying to take a protected item from the ground. +type ItemSpecServerPacket struct { + byteSize int +} + +func (s ItemSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 2 : dummy : short + if err = writer.AddShort(2); err != nil { + return + } + return +} + +func (s *ItemSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 2 : dummy : short + reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardPlayerServerPacket :: Reply to reading a post on a town board. +type BoardPlayerServerPacket struct { + byteSize int + + PostId int + PostBody string +} + +func (s BoardPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PostId : field : short + if err = writer.AddShort(s.PostId); err != nil { + return + } + // PostBody : field : string + if err = writer.AddString(s.PostBody); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *BoardPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PostId : field : short + s.PostId = reader.GetShort() + // PostBody : field : string + if s.PostBody, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardOpenServerPacket :: Reply to opening a town board. +type BoardOpenServerPacket struct { + byteSize int + + BoardId int + Posts []BoardPostListing +} + +func (s BoardOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Board +} + +func (s BoardOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BoardOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // BoardId : field : char + if err = writer.AddChar(s.BoardId); err != nil { + return + } + // PostsCount : length : char + if err = writer.AddChar(len(s.Posts)); err != nil { + return + } + // Posts : array : BoardPostListing + for ndx := 0; ndx < len(s.Posts); ndx++ { + if err = s.Posts[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *BoardOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // BoardId : field : char + s.BoardId = reader.GetChar() + // PostsCount : length : char + postsCount := reader.GetChar() + // Posts : array : BoardPostListing + for ndx := 0; ndx < postsCount; ndx++ { + s.Posts = append(s.Posts, BoardPostListing{}) + if err = s.Posts[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxAgreeServerPacket :: Reply to successfully requesting a song. +type JukeboxAgreeServerPacket struct { + byteSize int + + GoldAmount int +} + +func (s JukeboxAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *JukeboxAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxReplyServerPacket :: Reply to unsuccessfully requesting a song. +type JukeboxReplyServerPacket struct { + byteSize int +} + +func (s JukeboxReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 1 : dummy : short + if err = writer.AddShort(1); err != nil { + return + } + return +} + +func (s *JukeboxReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 1 : dummy : short + reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxOpenServerPacket :: Reply to opening the jukebox listing. +type JukeboxOpenServerPacket struct { + byteSize int + + MapId int + JukeboxPlayer string +} + +func (s JukeboxOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // JukeboxPlayer : field : string + if err = writer.AddString(s.JukeboxPlayer); err != nil { + return + } + return +} + +func (s *JukeboxOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapId : field : short + s.MapId = reader.GetShort() + // JukeboxPlayer : field : string + if s.JukeboxPlayer, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxMsgServerPacket :: Someone playing a note with the bard skill nearby. +type JukeboxMsgServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction + InstrumentId int + NoteId int +} + +func (s JukeboxMsgServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxMsgServerPacket) Action() net.PacketAction { + return net.PacketAction_Msg +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxMsgServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxMsgServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // InstrumentId : field : char + if err = writer.AddChar(s.InstrumentId); err != nil { + return + } + // NoteId : field : char + if err = writer.AddChar(s.NoteId); err != nil { + return + } + return +} + +func (s *JukeboxMsgServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // InstrumentId : field : char + s.InstrumentId = reader.GetChar() + // NoteId : field : char + s.NoteId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxPlayerServerPacket :: Play background music. +type JukeboxPlayerServerPacket struct { + byteSize int + + MfxId int +} + +func (s JukeboxPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MfxId : field : char + if err = writer.AddChar(s.MfxId); err != nil { + return + } + return +} + +func (s *JukeboxPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MfxId : field : char + s.MfxId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// JukeboxUseServerPacket :: Play jukebox music. +type JukeboxUseServerPacket struct { + byteSize int + + TrackId int // This value is 1-indexed. +} + +func (s JukeboxUseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Jukebox +} + +func (s JukeboxUseServerPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *JukeboxUseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *JukeboxUseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TrackId : field : short + if err = writer.AddShort(s.TrackId); err != nil { + return + } + return +} + +func (s *JukeboxUseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TrackId : field : short + s.TrackId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpRequestServerPacket :: Warp request from server. +type WarpRequestServerPacket struct { + byteSize int + + WarpType WarpType + MapId int + WarpTypeData WarpRequestWarpTypeData + SessionId int +} + +type WarpRequestWarpTypeData interface { + protocol.EoData +} + +type WarpRequestWarpTypeDataMapSwitch struct { + byteSize int + + MapRid []int + MapFileSize int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpRequestWarpTypeDataMapSwitch) ByteSize() int { + return s.byteSize +} + +func (s *WarpRequestWarpTypeDataMapSwitch) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapRid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.MapRid) != 2 { + err = fmt.Errorf("expected MapRid with length 2, got %d", len(s.MapRid)) + return + } + + if err = writer.AddShort(s.MapRid[ndx]); err != nil { + return + } + } + + // MapFileSize : field : three + if err = writer.AddThree(s.MapFileSize); err != nil { + return + } + return +} + +func (s *WarpRequestWarpTypeDataMapSwitch) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapRid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.MapRid = append(s.MapRid, 0) + s.MapRid[ndx] = reader.GetShort() + } + + // MapFileSize : field : three + s.MapFileSize = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s WarpRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // WarpType : field : WarpType + if err = writer.AddChar(int(s.WarpType)); err != nil { + return + } + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + switch s.WarpType { + case Warp_MapSwitch: + switch s.WarpTypeData.(type) { + case *WarpRequestWarpTypeDataMapSwitch: + if err = s.WarpTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.WarpType) + return + } + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + return +} + +func (s *WarpRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // WarpType : field : WarpType + s.WarpType = WarpType(reader.GetChar()) + // MapId : field : short + s.MapId = reader.GetShort() + switch s.WarpType { + case Warp_MapSwitch: + s.WarpTypeData = &WarpRequestWarpTypeDataMapSwitch{} + if err = s.WarpTypeData.Deserialize(reader); err != nil { + return + } + } + // SessionId : field : short + s.SessionId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// WarpAgreeServerPacket :: Reply after accepting a warp. +type WarpAgreeServerPacket struct { + byteSize int + + WarpType WarpType + WarpTypeData WarpAgreeWarpTypeData + Nearby NearbyInfo +} + +type WarpAgreeWarpTypeData interface { + protocol.EoData +} + +type WarpAgreeWarpTypeDataMapSwitch struct { + byteSize int + + MapId int + WarpEffect WarpEffect +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpAgreeWarpTypeDataMapSwitch) ByteSize() int { + return s.byteSize +} + +func (s *WarpAgreeWarpTypeDataMapSwitch) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // WarpEffect : field : WarpEffect + if err = writer.AddChar(int(s.WarpEffect)); err != nil { + return + } + return +} + +func (s *WarpAgreeWarpTypeDataMapSwitch) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapId : field : short + s.MapId = reader.GetShort() + // WarpEffect : field : WarpEffect + s.WarpEffect = WarpEffect(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s WarpAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Warp +} + +func (s WarpAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *WarpAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *WarpAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // WarpType : field : WarpType + if err = writer.AddChar(int(s.WarpType)); err != nil { + return + } + switch s.WarpType { + case Warp_MapSwitch: + switch s.WarpTypeData.(type) { + case *WarpAgreeWarpTypeDataMapSwitch: + if err = s.WarpTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.WarpType) + return + } + } + // Nearby : field : NearbyInfo + if err = s.Nearby.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *WarpAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // WarpType : field : WarpType + s.WarpType = WarpType(reader.GetChar()) + switch s.WarpType { + case Warp_MapSwitch: + s.WarpTypeData = &WarpAgreeWarpTypeDataMapSwitch{} + if err = s.WarpTypeData.Deserialize(reader); err != nil { + return + } + } + // Nearby : field : NearbyInfo + if err = s.Nearby.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollReplyServerPacket :: Reply to requesting a paperdoll. +type PaperdollReplyServerPacket struct { + byteSize int + + Details CharacterDetails + Equipment EquipmentPaperdoll + Icon CharacterIcon +} + +func (s PaperdollReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Details : field : CharacterDetails + if err = s.Details.Serialize(writer); err != nil { + return + } + // Equipment : field : EquipmentPaperdoll + if err = s.Equipment.Serialize(writer); err != nil { + return + } + // Icon : field : CharacterIcon + if err = writer.AddChar(int(s.Icon)); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *PaperdollReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Details : field : CharacterDetails + if err = s.Details.Deserialize(reader); err != nil { + return + } + // Equipment : field : EquipmentPaperdoll + if err = s.Equipment.Deserialize(reader); err != nil { + return + } + // Icon : field : CharacterIcon + s.Icon = CharacterIcon(reader.GetChar()) + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollPingServerPacket :: Failed to equip an item due to being the incorrect class. +type PaperdollPingServerPacket struct { + byteSize int + + ClassId int // The player's current class ID (not the item's required class ID). +} + +func (s PaperdollPingServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollPingServerPacket) Action() net.PacketAction { + return net.PacketAction_Ping +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollPingServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollPingServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + return +} + +func (s *PaperdollPingServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ClassId : field : char + s.ClassId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollRemoveServerPacket :: Reply to unequipping an item. +type PaperdollRemoveServerPacket struct { + byteSize int + + Change AvatarChange + ItemId int + SubLoc int + Stats CharacterStatsEquipmentChange +} + +func (s PaperdollRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Change : field : AvatarChange + if err = s.Change.Serialize(writer); err != nil { + return + } + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // SubLoc : field : char + if err = writer.AddChar(s.SubLoc); err != nil { + return + } + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *PaperdollRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Change : field : AvatarChange + if err = s.Change.Deserialize(reader); err != nil { + return + } + // ItemId : field : short + s.ItemId = reader.GetShort() + // SubLoc : field : char + s.SubLoc = reader.GetChar() + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PaperdollAgreeServerPacket :: Reply to equipping an item. +type PaperdollAgreeServerPacket struct { + byteSize int + + Change AvatarChange + ItemId int + RemainingAmount int + SubLoc int + Stats CharacterStatsEquipmentChange +} + +func (s PaperdollAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Paperdoll +} + +func (s PaperdollAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PaperdollAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PaperdollAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Change : field : AvatarChange + if err = s.Change.Serialize(writer); err != nil { + return + } + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // RemainingAmount : field : three + if err = writer.AddThree(s.RemainingAmount); err != nil { + return + } + // SubLoc : field : char + if err = writer.AddChar(s.SubLoc); err != nil { + return + } + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *PaperdollAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Change : field : AvatarChange + if err = s.Change.Deserialize(reader); err != nil { + return + } + // ItemId : field : short + s.ItemId = reader.GetShort() + // RemainingAmount : field : three + s.RemainingAmount = reader.GetThree() + // SubLoc : field : char + s.SubLoc = reader.GetChar() + // Stats : field : CharacterStatsEquipmentChange + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AvatarAgreeServerPacket :: Nearby player changed appearance. +type AvatarAgreeServerPacket struct { + byteSize int + + Change AvatarChange +} + +func (s AvatarAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Avatar +} + +func (s AvatarAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AvatarAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AvatarAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Change : field : AvatarChange + if err = s.Change.Serialize(writer); err != nil { + return + } + return +} + +func (s *AvatarAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Change : field : AvatarChange + if err = s.Change.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BookReplyServerPacket :: Reply to requesting a book. +type BookReplyServerPacket struct { + byteSize int + + Details CharacterDetails + Icon CharacterIcon + QuestNames []string +} + +func (s BookReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Book +} + +func (s BookReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BookReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *BookReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Details : field : CharacterDetails + if err = s.Details.Serialize(writer); err != nil { + return + } + // Icon : field : CharacterIcon + if err = writer.AddChar(int(s.Icon)); err != nil { + return + } + writer.AddByte(255) + // QuestNames : array : string + for ndx := 0; ndx < len(s.QuestNames); ndx++ { + if err = writer.AddString(s.QuestNames[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *BookReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Details : field : CharacterDetails + if err = s.Details.Deserialize(reader); err != nil { + return + } + // Icon : field : CharacterIcon + s.Icon = CharacterIcon(reader.GetChar()) + if err = reader.NextChunk(); err != nil { + return + } + // QuestNames : array : string + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.QuestNames = append(s.QuestNames, "") + if s.QuestNames[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MessagePongServerPacket :: #ping command reply. +type MessagePongServerPacket struct { + byteSize int +} + +func (s MessagePongServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Message +} + +func (s MessagePongServerPacket) Action() net.PacketAction { + return net.PacketAction_Pong +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MessagePongServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MessagePongServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 2 : dummy : short + if err = writer.AddShort(2); err != nil { + return + } + return +} + +func (s *MessagePongServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 2 : dummy : short + reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersPingServerPacket :: #find command reply - offline. +type PlayersPingServerPacket struct { + byteSize int + + Name string +} + +func (s PlayersPingServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersPingServerPacket) Action() net.PacketAction { + return net.PacketAction_Ping +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersPingServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersPingServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *PlayersPingServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersPongServerPacket :: #find command reply - same map. +type PlayersPongServerPacket struct { + byteSize int + + Name string +} + +func (s PlayersPongServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersPongServerPacket) Action() net.PacketAction { + return net.PacketAction_Pong +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersPongServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersPongServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *PlayersPongServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersNet242ServerPacket :: #find command reply - different map. +type PlayersNet242ServerPacket struct { + byteSize int + + Name string +} + +func (s PlayersNet242ServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Players +} + +func (s PlayersNet242ServerPacket) Action() net.PacketAction { + return net.PacketAction_Net242 +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersNet242ServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PlayersNet242ServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *PlayersNet242ServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DoorOpenServerPacket :: Nearby door opening. +type DoorOpenServerPacket struct { + byteSize int + + Coords protocol.Coords +} + +func (s DoorOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Door +} + +func (s DoorOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DoorOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *DoorOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + return +} + +func (s *DoorOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // 0 : field : char + reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DoorCloseServerPacket :: Reply to trying to open a locked door. +type DoorCloseServerPacket struct { + byteSize int + + Key int +} + +func (s DoorCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Door +} + +func (s DoorCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DoorCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *DoorCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Key : field : char + if err = writer.AddChar(s.Key); err != nil { + return + } + return +} + +func (s *DoorCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Key : field : char + s.Key = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestOpenServerPacket :: Reply to opening a chest. +type ChestOpenServerPacket struct { + byteSize int + + Coords protocol.Coords + Items []net.ThreeItem +} + +func (s ChestOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ChestOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Items = append(s.Items, net.ThreeItem{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestReplyServerPacket :: Reply to placing an item in to a chest. +type ChestReplyServerPacket struct { + byteSize int + + AddedItemId int + RemainingAmount int + Weight net.Weight + Items []net.ThreeItem +} + +func (s ChestReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // AddedItemId : field : short + if err = writer.AddShort(s.AddedItemId); err != nil { + return + } + // RemainingAmount : field : int + if err = writer.AddInt(s.RemainingAmount); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ChestReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // AddedItemId : field : short + s.AddedItemId = reader.GetShort() + // RemainingAmount : field : int + s.RemainingAmount = reader.GetInt() + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Items = append(s.Items, net.ThreeItem{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestGetServerPacket :: Reply to removing an item from a chest. +type ChestGetServerPacket struct { + byteSize int + + TakenItem net.ThreeItem + Weight net.Weight + Items []net.ThreeItem +} + +func (s ChestGetServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestGetServerPacket) Action() net.PacketAction { + return net.PacketAction_Get +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestGetServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestGetServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TakenItem : field : ThreeItem + if err = s.TakenItem.Serialize(writer); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Serialize(writer); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ChestGetServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TakenItem : field : ThreeItem + if err = s.TakenItem.Deserialize(reader); err != nil { + return + } + // Weight : field : Weight + if err = s.Weight.Deserialize(reader); err != nil { + return + } + // Items : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Items = append(s.Items, net.ThreeItem{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestAgreeServerPacket :: Chest contents updating. +type ChestAgreeServerPacket struct { + byteSize int + + Items []net.ThreeItem +} + +func (s ChestAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Items : array : ThreeItem + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ChestAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Items : array : ThreeItem + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Items = append(s.Items, net.ThreeItem{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestSpecServerPacket :: Reply to trying to add an item to a full chest. +type ChestSpecServerPacket struct { + byteSize int +} + +func (s ChestSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 0 : dummy : byte + if err = writer.AddByte(0); err != nil { + return + } + return +} + +func (s *ChestSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 0 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ChestCloseServerPacket :: Reply to trying to interact with a locked or "broken" chest. The official client assumes a broken chest if the packet is under 2 bytes in length. +type ChestCloseServerPacket struct { + byteSize int + + Key *int // Sent if the player is trying to interact with a locked chest. +} + +func (s ChestCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Chest +} + +func (s ChestCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChestCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ChestCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Key : field : short + if s.Key != nil { + if err = writer.AddShort(*s.Key); err != nil { + return + } + } + // N : dummy : string + if err = writer.AddString("N"); err != nil { + return + } + return +} + +func (s *ChestCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Key : field : short + if reader.Remaining() > 0 { + s.Key = new(int) + *s.Key = reader.GetShort() + } + // N : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RefreshReplyServerPacket :: Reply to request for new info about nearby objects. +type RefreshReplyServerPacket struct { + byteSize int + + Nearby NearbyInfo +} + +func (s RefreshReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Refresh +} + +func (s RefreshReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RefreshReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RefreshReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Nearby : field : NearbyInfo + if err = s.Nearby.Serialize(writer); err != nil { + return + } + return +} + +func (s *RefreshReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Nearby : field : NearbyInfo + if err = s.Nearby.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyRequestServerPacket :: Received party invite / join request. +type PartyRequestServerPacket struct { + byteSize int + + RequestType net.PartyRequestType + InviterPlayerId int + PlayerName string +} + +func (s PartyRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // RequestType : field : PartyRequestType + if err = writer.AddChar(int(s.RequestType)); err != nil { + return + } + // InviterPlayerId : field : short + if err = writer.AddShort(s.InviterPlayerId); err != nil { + return + } + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + return +} + +func (s *PartyRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // RequestType : field : PartyRequestType + s.RequestType = net.PartyRequestType(reader.GetChar()) + // InviterPlayerId : field : short + s.InviterPlayerId = reader.GetShort() + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyReplyServerPacket :: Failed party invite / join request. +type PartyReplyServerPacket struct { + byteSize int + + ReplyCode PartyReplyCode + ReplyCodeData PartyReplyReplyCodeData +} + +type PartyReplyReplyCodeData interface { + protocol.EoData +} + +type PartyReplyReplyCodeDataAlreadyInAnotherParty struct { + byteSize int + + PlayerName string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyReplyReplyCodeDataAlreadyInAnotherParty) ByteSize() int { + return s.byteSize +} + +func (s *PartyReplyReplyCodeDataAlreadyInAnotherParty) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + return +} + +func (s *PartyReplyReplyCodeDataAlreadyInAnotherParty) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type PartyReplyReplyCodeDataAlreadyInYourParty struct { + byteSize int + + PlayerName string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyReplyReplyCodeDataAlreadyInYourParty) ByteSize() int { + return s.byteSize +} + +func (s *PartyReplyReplyCodeDataAlreadyInYourParty) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + return +} + +func (s *PartyReplyReplyCodeDataAlreadyInYourParty) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s PartyReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : PartyReplyCode + if err = writer.AddChar(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case PartyReplyCode_AlreadyInAnotherParty: + switch s.ReplyCodeData.(type) { + case *PartyReplyReplyCodeDataAlreadyInAnotherParty: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case PartyReplyCode_AlreadyInYourParty: + switch s.ReplyCodeData.(type) { + case *PartyReplyReplyCodeDataAlreadyInYourParty: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *PartyReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : PartyReplyCode + s.ReplyCode = PartyReplyCode(reader.GetChar()) + switch s.ReplyCode { + case PartyReplyCode_AlreadyInAnotherParty: + s.ReplyCodeData = &PartyReplyReplyCodeDataAlreadyInAnotherParty{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case PartyReplyCode_AlreadyInYourParty: + s.ReplyCodeData = &PartyReplyReplyCodeDataAlreadyInYourParty{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyCreateServerPacket :: Member list received when party is first joined. +type PartyCreateServerPacket struct { + byteSize int + + Members []PartyMember +} + +func (s PartyCreateServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyCreateServerPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyCreateServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyCreateServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Members : array : PartyMember + for ndx := 0; ndx < len(s.Members); ndx++ { + if err = s.Members[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *PartyCreateServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Members : array : PartyMember + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Members = append(s.Members, PartyMember{}) + if err = s.Members[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyAddServerPacket :: New player joined the party. +type PartyAddServerPacket struct { + byteSize int + + Member PartyMember +} + +func (s PartyAddServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyAddServerPacket) Action() net.PacketAction { + return net.PacketAction_Add +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyAddServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyAddServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Member : field : PartyMember + if err = s.Member.Serialize(writer); err != nil { + return + } + return +} + +func (s *PartyAddServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Member : field : PartyMember + if err = s.Member.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyRemoveServerPacket :: Player left the party. +type PartyRemoveServerPacket struct { + byteSize int + + PlayerId int +} + +func (s PartyRemoveServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyRemoveServerPacket) Action() net.PacketAction { + return net.PacketAction_Remove +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyRemoveServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyRemoveServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *PartyRemoveServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyCloseServerPacket :: Left / disbanded a party. +type PartyCloseServerPacket struct { + byteSize int +} + +func (s PartyCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *PartyCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyListServerPacket :: Party member list update. +type PartyListServerPacket struct { + byteSize int + + Members []PartyMember +} + +func (s PartyListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Members : array : PartyMember + for ndx := 0; ndx < len(s.Members); ndx++ { + if err = s.Members[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *PartyListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Members : array : PartyMember + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Members = append(s.Members, PartyMember{}) + if err = s.Members[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyAgreeServerPacket :: Party member list update. +type PartyAgreeServerPacket struct { + byteSize int + + PlayerId int + HpPercentage int +} + +func (s PartyAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + return +} + +func (s *PartyAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyTargetGroupServerPacket :: Updated experience and level-ups from party experience. +type PartyTargetGroupServerPacket struct { + byteSize int + + Gains []PartyExpShare +} + +func (s PartyTargetGroupServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Party +} + +func (s PartyTargetGroupServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetGroup +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyTargetGroupServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PartyTargetGroupServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Gains : array : PartyExpShare + for ndx := 0; ndx < len(s.Gains); ndx++ { + if err = s.Gains[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *PartyTargetGroupServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Gains : array : PartyExpShare + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Gains = append(s.Gains, PartyExpShare{}) + if err = s.Gains[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildReplyServerPacket :: Generic guild reply messages. +type GuildReplyServerPacket struct { + byteSize int + + ReplyCode GuildReply + ReplyCodeData GuildReplyReplyCodeData +} + +type GuildReplyReplyCodeData interface { + protocol.EoData +} + +type GuildReplyReplyCodeDataCreateAdd struct { + byteSize int + + Name string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReplyReplyCodeDataCreateAdd) ByteSize() int { + return s.byteSize +} + +func (s *GuildReplyReplyCodeDataCreateAdd) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *GuildReplyReplyCodeDataCreateAdd) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type GuildReplyReplyCodeDataCreateAddConfirm struct { + byteSize int + + Name string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReplyReplyCodeDataCreateAddConfirm) ByteSize() int { + return s.byteSize +} + +func (s *GuildReplyReplyCodeDataCreateAddConfirm) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *GuildReplyReplyCodeDataCreateAddConfirm) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type GuildReplyReplyCodeDataJoinRequest struct { + byteSize int + + PlayerId int + Name string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReplyReplyCodeDataJoinRequest) ByteSize() int { + return s.byteSize +} + +func (s *GuildReplyReplyCodeDataJoinRequest) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *GuildReplyReplyCodeDataJoinRequest) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s GuildReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : GuildReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case GuildReply_CreateAdd: + switch s.ReplyCodeData.(type) { + case *GuildReplyReplyCodeDataCreateAdd: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case GuildReply_CreateAddConfirm: + switch s.ReplyCodeData.(type) { + case *GuildReplyReplyCodeDataCreateAddConfirm: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + case GuildReply_JoinRequest: + switch s.ReplyCodeData.(type) { + case *GuildReplyReplyCodeDataJoinRequest: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *GuildReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : GuildReply + s.ReplyCode = GuildReply(reader.GetShort()) + switch s.ReplyCode { + case GuildReply_CreateAdd: + s.ReplyCodeData = &GuildReplyReplyCodeDataCreateAdd{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case GuildReply_CreateAddConfirm: + s.ReplyCodeData = &GuildReplyReplyCodeDataCreateAddConfirm{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + case GuildReply_JoinRequest: + s.ReplyCodeData = &GuildReplyReplyCodeDataJoinRequest{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildRequestServerPacket :: Guild create request. +type GuildRequestServerPacket struct { + byteSize int + + PlayerId int + GuildIdentity string +} + +func (s GuildRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // GuildIdentity : field : string + if err = writer.AddString(s.GuildIdentity); err != nil { + return + } + return +} + +func (s *GuildRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // GuildIdentity : field : string + if s.GuildIdentity, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildCreateServerPacket :: Guild created. +type GuildCreateServerPacket struct { + byteSize int + + LeaderPlayerId int + GuildTag string + GuildName string + RankName string + GoldAmount int +} + +func (s GuildCreateServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildCreateServerPacket) Action() net.PacketAction { + return net.PacketAction_Create +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildCreateServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildCreateServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // LeaderPlayerId : field : short + if err = writer.AddShort(s.LeaderPlayerId); err != nil { + return + } + writer.AddByte(255) + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.AddByte(255) + // GuildName : field : string + if err = writer.AddString(s.GuildName); err != nil { + return + } + writer.AddByte(255) + // RankName : field : string + if err = writer.AddString(s.RankName); err != nil { + return + } + writer.AddByte(255) + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *GuildCreateServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // LeaderPlayerId : field : short + s.LeaderPlayerId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildName : field : string + if s.GuildName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // RankName : field : string + if s.RankName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildTakeServerPacket :: Get guild description reply. +type GuildTakeServerPacket struct { + byteSize int + + Description string +} + +func (s GuildTakeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildTakeServerPacket) Action() net.PacketAction { + return net.PacketAction_Take +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildTakeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildTakeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Description : field : string + if err = writer.AddString(s.Description); err != nil { + return + } + return +} + +func (s *GuildTakeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Description : field : string + if s.Description, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildRankServerPacket :: Get guild rank list reply. +type GuildRankServerPacket struct { + byteSize int + + Ranks []string +} + +func (s GuildRankServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildRankServerPacket) Action() net.PacketAction { + return net.PacketAction_Rank +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildRankServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildRankServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + if len(s.Ranks) != 9 { + err = fmt.Errorf("expected Ranks with length 9, got %d", len(s.Ranks)) + return + } + + if err = writer.AddString(s.Ranks[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *GuildRankServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + s.Ranks = append(s.Ranks, "") + if s.Ranks[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildSellServerPacket :: Get guild bank reply. +type GuildSellServerPacket struct { + byteSize int + + GoldAmount int +} + +func (s GuildSellServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildSellServerPacket) Action() net.PacketAction { + return net.PacketAction_Sell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildSellServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildSellServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *GuildSellServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildBuyServerPacket :: Deposit guild bank reply. +type GuildBuyServerPacket struct { + byteSize int + + GoldAmount int +} + +func (s GuildBuyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildBuyServerPacket) Action() net.PacketAction { + return net.PacketAction_Buy +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildBuyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildBuyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *GuildBuyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildOpenServerPacket :: Talk to guild master NPC reply. +type GuildOpenServerPacket struct { + byteSize int + + SessionId int +} + +func (s GuildOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + return +} + +func (s *GuildOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : three + s.SessionId = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildTellServerPacket :: Get guild member list reply. +type GuildTellServerPacket struct { + byteSize int + + Members []GuildMember +} + +func (s GuildTellServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildTellServerPacket) Action() net.PacketAction { + return net.PacketAction_Tell +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildTellServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildTellServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // MembersCount : length : short + if err = writer.AddShort(len(s.Members)); err != nil { + return + } + writer.AddByte(255) + // Members : array : GuildMember + for ndx := 0; ndx < len(s.Members); ndx++ { + if err = s.Members[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *GuildTellServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // MembersCount : length : short + membersCount := reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Members : array : GuildMember + for ndx := 0; ndx < membersCount; ndx++ { + s.Members = append(s.Members, GuildMember{}) + if err = s.Members[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildReportServerPacket :: Get guild info reply. +type GuildReportServerPacket struct { + byteSize int + + Name string + Tag string + CreateDate string + Description string + Wealth string + Ranks []string + Staff []GuildStaff +} + +func (s GuildReportServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildReportServerPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildReportServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildReportServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Tag : field : string + if err = writer.AddString(s.Tag); err != nil { + return + } + writer.AddByte(255) + // CreateDate : field : string + if err = writer.AddString(s.CreateDate); err != nil { + return + } + writer.AddByte(255) + // Description : field : string + if err = writer.AddString(s.Description); err != nil { + return + } + writer.AddByte(255) + // Wealth : field : string + if err = writer.AddString(s.Wealth); err != nil { + return + } + writer.AddByte(255) + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + if len(s.Ranks) != 9 { + err = fmt.Errorf("expected Ranks with length 9, got %d", len(s.Ranks)) + return + } + + if err = writer.AddString(s.Ranks[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + // StaffCount : length : short + if err = writer.AddShort(len(s.Staff)); err != nil { + return + } + writer.AddByte(255) + // Staff : array : GuildStaff + for ndx := 0; ndx < len(s.Staff); ndx++ { + if err = s.Staff[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *GuildReportServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Tag : field : string + if s.Tag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // CreateDate : field : string + if s.CreateDate, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Description : field : string + if s.Description, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Wealth : field : string + if s.Wealth, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Ranks : array : string + for ndx := 0; ndx < 9; ndx++ { + s.Ranks = append(s.Ranks, "") + if s.Ranks[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + // StaffCount : length : short + staffCount := reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Staff : array : GuildStaff + for ndx := 0; ndx < staffCount; ndx++ { + s.Staff = append(s.Staff, GuildStaff{}) + if err = s.Staff[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildAgreeServerPacket :: Joined guild info. +type GuildAgreeServerPacket struct { + byteSize int + + RecruiterId int + GuildTag string + GuildName string + RankName string +} + +func (s GuildAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // RecruiterId : field : short + if err = writer.AddShort(s.RecruiterId); err != nil { + return + } + writer.AddByte(255) + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.AddByte(255) + // GuildName : field : string + if err = writer.AddString(s.GuildName); err != nil { + return + } + writer.AddByte(255) + // RankName : field : string + if err = writer.AddString(s.RankName); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *GuildAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // RecruiterId : field : short + s.RecruiterId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildName : field : string + if s.GuildName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // RankName : field : string + if s.RankName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildAcceptServerPacket :: Update guild rank. +type GuildAcceptServerPacket struct { + byteSize int + + Rank int +} + +func (s GuildAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Rank : field : char + if err = writer.AddChar(s.Rank); err != nil { + return + } + return +} + +func (s *GuildAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Rank : field : char + s.Rank = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildKickServerPacket :: Left the guild. +type GuildKickServerPacket struct { + byteSize int +} + +func (s GuildKickServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Guild +} + +func (s GuildKickServerPacket) Action() net.PacketAction { + return net.PacketAction_Kick +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildKickServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *GuildKickServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *GuildKickServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellRequestServerPacket :: Nearby player chanting a spell. +type SpellRequestServerPacket struct { + byteSize int + + PlayerId int + SpellId int +} + +func (s SpellRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *SpellRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetSelfServerPacket :: Nearby player self-casted a spell. +type SpellTargetSelfServerPacket struct { + byteSize int + + PlayerId int + SpellId int + SpellHealHp int + HpPercentage int + Hp *int // The official client reads this if the packet is larger than 12 bytes. + Tp *int // The official client reads this if the packet is larger than 12 bytes. +} + +func (s SpellTargetSelfServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetSelfServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetSelf +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetSelfServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetSelfServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // SpellHealHp : field : int + if err = writer.AddInt(s.SpellHealHp); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Hp : field : short + if s.Hp != nil { + if err = writer.AddShort(*s.Hp); err != nil { + return + } + } + // Tp : field : short + if s.Tp != nil { + if err = writer.AddShort(*s.Tp); err != nil { + return + } + } + return +} + +func (s *SpellTargetSelfServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // SpellId : field : short + s.SpellId = reader.GetShort() + // SpellHealHp : field : int + s.SpellHealHp = reader.GetInt() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Hp : field : short + if reader.Remaining() > 0 { + s.Hp = new(int) + *s.Hp = reader.GetShort() + } + // Tp : field : short + if reader.Remaining() > 0 { + s.Tp = new(int) + *s.Tp = reader.GetShort() + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellPlayerServerPacket :: Nearby player raising their arm to cast a spell (vestigial). +type SpellPlayerServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction +} + +func (s SpellPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *SpellPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellErrorServerPacket :: Show flood protection message (vestigial). +type SpellErrorServerPacket struct { + byteSize int +} + +func (s SpellErrorServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellErrorServerPacket) Action() net.PacketAction { + return net.PacketAction_Error +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellErrorServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellErrorServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 255 : dummy : byte + if err = writer.AddByte(255); err != nil { + return + } + return +} + +func (s *SpellErrorServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 255 : dummy : byte + reader.GetByte() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AvatarAdminServerPacket :: Nearby player hit by a damage spell from a player. +type AvatarAdminServerPacket struct { + byteSize int + + CasterId int + VictimId int + Damage int + CasterDirection protocol.Direction + HpPercentage int + VictimDied bool + SpellId int +} + +func (s AvatarAdminServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Avatar +} + +func (s AvatarAdminServerPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AvatarAdminServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *AvatarAdminServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CasterId : field : short + if err = writer.AddShort(s.CasterId); err != nil { + return + } + // VictimId : field : short + if err = writer.AddShort(s.VictimId); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + // CasterDirection : field : Direction + if err = writer.AddChar(int(s.CasterDirection)); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // VictimDied : field : bool + if s.VictimDied { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + return +} + +func (s *AvatarAdminServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CasterId : field : short + s.CasterId = reader.GetShort() + // VictimId : field : short + s.VictimId = reader.GetShort() + // Damage : field : three + s.Damage = reader.GetThree() + // CasterDirection : field : Direction + s.CasterDirection = protocol.Direction(reader.GetChar()) + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // VictimDied : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.VictimDied = true + } else { + s.VictimDied = false + } + // SpellId : field : short + s.SpellId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetGroupServerPacket :: Nearby player(s) hit by a group heal spell from a player. +type SpellTargetGroupServerPacket struct { + byteSize int + + SpellId int + CasterId int + CasterTp int + SpellHealHp int + Players []GroupHealTargetPlayer +} + +func (s SpellTargetGroupServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetGroupServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetGroup +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetGroupServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetGroupServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // CasterId : field : short + if err = writer.AddShort(s.CasterId); err != nil { + return + } + // CasterTp : field : short + if err = writer.AddShort(s.CasterTp); err != nil { + return + } + // SpellHealHp : field : short + if err = writer.AddShort(s.SpellHealHp); err != nil { + return + } + // Players : array : GroupHealTargetPlayer + for ndx := 0; ndx < len(s.Players); ndx++ { + if err = s.Players[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *SpellTargetGroupServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // CasterId : field : short + s.CasterId = reader.GetShort() + // CasterTp : field : short + s.CasterTp = reader.GetShort() + // SpellHealHp : field : short + s.SpellHealHp = reader.GetShort() + // Players : array : GroupHealTargetPlayer + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Players = append(s.Players, GroupHealTargetPlayer{}) + if err = s.Players[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SpellTargetOtherServerPacket :: Nearby player hit by a heal spell from a player. +type SpellTargetOtherServerPacket struct { + byteSize int + + VictimId int + CasterId int + CasterDirection protocol.Direction + SpellId int + SpellHealHp int + HpPercentage int + Hp *int +} + +func (s SpellTargetOtherServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Spell +} + +func (s SpellTargetOtherServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetOther +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SpellTargetOtherServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *SpellTargetOtherServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // VictimId : field : short + if err = writer.AddShort(s.VictimId); err != nil { + return + } + // CasterId : field : short + if err = writer.AddShort(s.CasterId); err != nil { + return + } + // CasterDirection : field : Direction + if err = writer.AddChar(int(s.CasterDirection)); err != nil { + return + } + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // SpellHealHp : field : int + if err = writer.AddInt(s.SpellHealHp); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Hp : field : short + if s.Hp != nil { + if err = writer.AddShort(*s.Hp); err != nil { + return + } + } + return +} + +func (s *SpellTargetOtherServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // VictimId : field : short + s.VictimId = reader.GetShort() + // CasterId : field : short + s.CasterId = reader.GetShort() + // CasterDirection : field : Direction + s.CasterDirection = protocol.Direction(reader.GetChar()) + // SpellId : field : short + s.SpellId = reader.GetShort() + // SpellHealHp : field : int + s.SpellHealHp = reader.GetInt() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Hp : field : short + if reader.Remaining() > 0 { + s.Hp = new(int) + *s.Hp = reader.GetShort() + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeRequestServerPacket :: Trade request from another player. +type TradeRequestServerPacket struct { + byteSize int + + PartnerPlayerId int + PartnerPlayerName string +} + +func (s TradeRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // 138 : field : char + if err = writer.AddChar(138); err != nil { + return + } + // PartnerPlayerId : field : short + if err = writer.AddShort(s.PartnerPlayerId); err != nil { + return + } + // PartnerPlayerName : field : string + if err = writer.AddString(s.PartnerPlayerName); err != nil { + return + } + return +} + +func (s *TradeRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // 138 : field : char + reader.GetChar() + // PartnerPlayerId : field : short + s.PartnerPlayerId = reader.GetShort() + // PartnerPlayerName : field : string + if s.PartnerPlayerName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeOpenServerPacket :: Trade window opens. +type TradeOpenServerPacket struct { + byteSize int + + PartnerPlayerId int + PartnerPlayerName string + YourPlayerId int + YourPlayerName string +} + +func (s TradeOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PartnerPlayerId : field : short + if err = writer.AddShort(s.PartnerPlayerId); err != nil { + return + } + // PartnerPlayerName : field : string + if err = writer.AddString(s.PartnerPlayerName); err != nil { + return + } + writer.AddByte(255) + // YourPlayerId : field : short + if err = writer.AddShort(s.YourPlayerId); err != nil { + return + } + // YourPlayerName : field : string + if err = writer.AddString(s.YourPlayerName); err != nil { + return + } + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *TradeOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PartnerPlayerId : field : short + s.PartnerPlayerId = reader.GetShort() + // PartnerPlayerName : field : string + if s.PartnerPlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // YourPlayerId : field : short + s.YourPlayerId = reader.GetShort() + // YourPlayerName : field : string + if s.YourPlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeReplyServerPacket :: Trade updated (items changed). +type TradeReplyServerPacket struct { + byteSize int + + TradeData TradeItemData +} + +func (s TradeReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TradeData : field : TradeItemData + if err = s.TradeData.Serialize(writer); err != nil { + return + } + return +} + +func (s *TradeReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TradeData : field : TradeItemData + if err = s.TradeData.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeAdminServerPacket :: Trade updated (items changed while trade was accepted). +type TradeAdminServerPacket struct { + byteSize int + + TradeData TradeItemData +} + +func (s TradeAdminServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeAdminServerPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeAdminServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeAdminServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TradeData : field : TradeItemData + if err = s.TradeData.Serialize(writer); err != nil { + return + } + return +} + +func (s *TradeAdminServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TradeData : field : TradeItemData + if err = s.TradeData.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeUseServerPacket :: Trade completed. +type TradeUseServerPacket struct { + byteSize int + + TradeData TradeItemData +} + +func (s TradeUseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeUseServerPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeUseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeUseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TradeData : field : TradeItemData + if err = s.TradeData.Serialize(writer); err != nil { + return + } + return +} + +func (s *TradeUseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TradeData : field : TradeItemData + if err = s.TradeData.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeSpecServerPacket :: Own agree state updated. +type TradeSpecServerPacket struct { + byteSize int + + Agree bool +} + +func (s TradeSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Agree : field : bool + if s.Agree { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + return +} + +func (s *TradeSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Agree : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Agree = true + } else { + s.Agree = false + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeAgreeServerPacket :: Partner agree state updated. +type TradeAgreeServerPacket struct { + byteSize int + + PartnerPlayerId int + Agree bool +} + +func (s TradeAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PartnerPlayerId : field : short + if err = writer.AddShort(s.PartnerPlayerId); err != nil { + return + } + // Agree : field : bool + if s.Agree { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + return +} + +func (s *TradeAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PartnerPlayerId : field : short + s.PartnerPlayerId = reader.GetShort() + // Agree : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Agree = true + } else { + s.Agree = false + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeCloseServerPacket :: Partner closed trade window. +type TradeCloseServerPacket struct { + byteSize int + + PartnerPlayerId int +} + +func (s TradeCloseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Trade +} + +func (s TradeCloseServerPacket) Action() net.PacketAction { + return net.PacketAction_Close +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeCloseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *TradeCloseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PartnerPlayerId : field : short + if err = writer.AddShort(s.PartnerPlayerId); err != nil { + return + } + return +} + +func (s *TradeCloseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PartnerPlayerId : field : short + s.PartnerPlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcReplyServerPacket :: Nearby NPC hit by a player. +type NpcReplyServerPacket struct { + byteSize int + + PlayerId int + PlayerDirection protocol.Direction + NpcIndex int + Damage int + HpPercentage int + KillStealProtection *NpcKillStealProtectionState // This field should be sent to the attacker, but not nearby players. +} + +func (s NpcReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // PlayerDirection : field : Direction + if err = writer.AddChar(int(s.PlayerDirection)); err != nil { + return + } + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + // HpPercentage : field : short + if err = writer.AddShort(s.HpPercentage); err != nil { + return + } + // KillStealProtection : field : NpcKillStealProtectionState + if s.KillStealProtection != nil { + if err = writer.AddChar(int(*s.KillStealProtection)); err != nil { + return + } + } + return +} + +func (s *NpcReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // PlayerDirection : field : Direction + s.PlayerDirection = protocol.Direction(reader.GetChar()) + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // Damage : field : three + s.Damage = reader.GetThree() + // HpPercentage : field : short + s.HpPercentage = reader.GetShort() + // KillStealProtection : field : NpcKillStealProtectionState + if reader.Remaining() > 0 { + s.KillStealProtection = new(NpcKillStealProtectionState) + *s.KillStealProtection = NpcKillStealProtectionState(reader.GetChar()) + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CastReplyServerPacket :: Nearby NPC hit by a spell from a player. +type CastReplyServerPacket struct { + byteSize int + + SpellId int + CasterId int + CasterDirection protocol.Direction + NpcIndex int + Damage int + HpPercentage int + CasterTp *int // This field should be sent to the attacker, but not nearby players. + KillStealProtection *NpcKillStealProtectionState // This field should be sent to the attacker, but not nearby players. +} + +func (s CastReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Cast +} + +func (s CastReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CastReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CastReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // CasterId : field : short + if err = writer.AddShort(s.CasterId); err != nil { + return + } + // CasterDirection : field : Direction + if err = writer.AddChar(int(s.CasterDirection)); err != nil { + return + } + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + // HpPercentage : field : short + if err = writer.AddShort(s.HpPercentage); err != nil { + return + } + // CasterTp : field : short + if s.CasterTp != nil { + if err = writer.AddShort(*s.CasterTp); err != nil { + return + } + } + // KillStealProtection : field : NpcKillStealProtectionState + if s.KillStealProtection != nil { + if err = writer.AddChar(int(*s.KillStealProtection)); err != nil { + return + } + } + return +} + +func (s *CastReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // CasterId : field : short + s.CasterId = reader.GetShort() + // CasterDirection : field : Direction + s.CasterDirection = protocol.Direction(reader.GetChar()) + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // Damage : field : three + s.Damage = reader.GetThree() + // HpPercentage : field : short + s.HpPercentage = reader.GetShort() + // CasterTp : field : short + if reader.Remaining() > 0 { + s.CasterTp = new(int) + *s.CasterTp = reader.GetShort() + } + // KillStealProtection : field : NpcKillStealProtectionState + if reader.Remaining() > 0 { + s.KillStealProtection = new(NpcKillStealProtectionState) + *s.KillStealProtection = NpcKillStealProtectionState(reader.GetChar()) + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcSpecServerPacket :: Nearby NPC killed by player. +type NpcSpecServerPacket struct { + byteSize int + + NpcKilledData NpcKilledData + Experience *int // This field should be sent to the killer, but not nearby players. +} + +func (s NpcSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Serialize(writer); err != nil { + return + } + // Experience : field : int + if s.Experience != nil { + if err = writer.AddInt(*s.Experience); err != nil { + return + } + } + return +} + +func (s *NpcSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Deserialize(reader); err != nil { + return + } + // Experience : field : int + if reader.Remaining() > 0 { + s.Experience = new(int) + *s.Experience = reader.GetInt() + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcAcceptServerPacket :: Nearby NPC killed and killer leveled up. +type NpcAcceptServerPacket struct { + byteSize int + + NpcKilledData NpcKilledData + Experience *int // This field should be sent to the killer, but not nearby players. + LevelUp *LevelUpStats // This field should be sent to the killer if they leveled up, but not nearby players. +} + +func (s NpcAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Serialize(writer); err != nil { + return + } + // Experience : field : int + if s.Experience != nil { + if err = writer.AddInt(*s.Experience); err != nil { + return + } + } + // LevelUp : field : LevelUpStats + if err = s.LevelUp.Serialize(writer); err != nil { + return + } + return +} + +func (s *NpcAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Deserialize(reader); err != nil { + return + } + // Experience : field : int + if reader.Remaining() > 0 { + s.Experience = new(int) + *s.Experience = reader.GetInt() + } + // LevelUp : field : LevelUpStats + if err = s.LevelUp.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CastSpecServerPacket :: Nearby NPC killed by player spell. +type CastSpecServerPacket struct { + byteSize int + + SpellId int + NpcKilledData NpcKilledData + CasterTp *int // This field should be sent to the killer, but not nearby players. + Experience *int // This field should be sent to the killer, but not nearby players. +} + +func (s CastSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Cast +} + +func (s CastSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CastSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CastSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Serialize(writer); err != nil { + return + } + // CasterTp : field : short + if s.CasterTp != nil { + if err = writer.AddShort(*s.CasterTp); err != nil { + return + } + } + // Experience : field : int + if s.Experience != nil { + if err = writer.AddInt(*s.Experience); err != nil { + return + } + } + return +} + +func (s *CastSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Deserialize(reader); err != nil { + return + } + // CasterTp : field : short + if reader.Remaining() > 0 { + s.CasterTp = new(int) + *s.CasterTp = reader.GetShort() + } + // Experience : field : int + if reader.Remaining() > 0 { + s.Experience = new(int) + *s.Experience = reader.GetInt() + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CastAcceptServerPacket :: Nearby NPC killed by player spell and killer leveled up. +type CastAcceptServerPacket struct { + byteSize int + + SpellId int + NpcKilledData NpcKilledData + CasterTp *int // This field should be sent to the killer, but not nearby players. + Experience *int // This field should be sent to the killer, but not nearby players. + LevelUp *LevelUpStats // This field should be sent to the killer if they leveled up, but not nearby players. +} + +func (s CastAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Cast +} + +func (s CastAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CastAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *CastAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SpellId : field : short + if err = writer.AddShort(s.SpellId); err != nil { + return + } + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Serialize(writer); err != nil { + return + } + // CasterTp : field : short + if s.CasterTp != nil { + if err = writer.AddShort(*s.CasterTp); err != nil { + return + } + } + // Experience : field : int + if s.Experience != nil { + if err = writer.AddInt(*s.Experience); err != nil { + return + } + } + // LevelUp : field : LevelUpStats + if err = s.LevelUp.Serialize(writer); err != nil { + return + } + return +} + +func (s *CastAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SpellId : field : short + s.SpellId = reader.GetShort() + // NpcKilledData : field : NpcKilledData + if err = s.NpcKilledData.Deserialize(reader); err != nil { + return + } + // CasterTp : field : short + if reader.Remaining() > 0 { + s.CasterTp = new(int) + *s.CasterTp = reader.GetShort() + } + // Experience : field : int + if reader.Remaining() > 0 { + s.Experience = new(int) + *s.Experience = reader.GetInt() + } + // LevelUp : field : LevelUpStats + if err = s.LevelUp.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcJunkServerPacket :: Clearing all boss children. +type NpcJunkServerPacket struct { + byteSize int + + NpcId int +} + +func (s NpcJunkServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcJunkServerPacket) Action() net.PacketAction { + return net.PacketAction_Junk +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcJunkServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcJunkServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcId : field : short + if err = writer.AddShort(s.NpcId); err != nil { + return + } + return +} + +func (s *NpcJunkServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcId : field : short + s.NpcId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcPlayerServerPacket :: Main NPC update message. +type NpcPlayerServerPacket struct { + byteSize int + + Positions []NpcUpdatePosition + Attacks []NpcUpdateAttack + Chats []NpcUpdateChat + Hp *int + Tp *int +} + +func (s NpcPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Positions : array : NpcUpdatePosition + for ndx := 0; ndx < len(s.Positions); ndx++ { + if err = s.Positions[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Attacks : array : NpcUpdateAttack + for ndx := 0; ndx < len(s.Attacks); ndx++ { + if err = s.Attacks[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Chats : array : NpcUpdateChat + for ndx := 0; ndx < len(s.Chats); ndx++ { + if err = s.Chats[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Hp : field : short + if s.Hp != nil { + if err = writer.AddShort(*s.Hp); err != nil { + return + } + } + // Tp : field : short + if s.Tp != nil { + if err = writer.AddShort(*s.Tp); err != nil { + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *NpcPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Positions : array : NpcUpdatePosition + PositionsRemaining := reader.Remaining() + for ndx := 0; ndx < PositionsRemaining/4; ndx++ { + s.Positions = append(s.Positions, NpcUpdatePosition{}) + if err = s.Positions[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Attacks : array : NpcUpdateAttack + AttacksRemaining := reader.Remaining() + for ndx := 0; ndx < AttacksRemaining/9; ndx++ { + s.Attacks = append(s.Attacks, NpcUpdateAttack{}) + if err = s.Attacks[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Chats : array : NpcUpdateChat + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Chats = append(s.Chats, NpcUpdateChat{}) + if err = s.Chats[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Hp : field : short + if reader.Remaining() > 0 { + s.Hp = new(int) + *s.Hp = reader.GetShort() + } + // Tp : field : short + if reader.Remaining() > 0 { + s.Tp = new(int) + *s.Tp = reader.GetShort() + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcDialogServerPacket :: NPC chat message. +type NpcDialogServerPacket struct { + byteSize int + + NpcIndex int + Message string +} + +func (s NpcDialogServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Npc +} + +func (s NpcDialogServerPacket) Action() net.PacketAction { + return net.PacketAction_Dialog +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcDialogServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *NpcDialogServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + return +} + +func (s *NpcDialogServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestReportServerPacket :: NPC chat messages. +type QuestReportServerPacket struct { + byteSize int + + NpcId int + Messages []string +} + +func (s QuestReportServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestReportServerPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestReportServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestReportServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // NpcId : field : short + if err = writer.AddShort(s.NpcId); err != nil { + return + } + writer.AddByte(255) + // Messages : array : string + for ndx := 0; ndx < len(s.Messages); ndx++ { + if err = writer.AddString(s.Messages[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *QuestReportServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // NpcId : field : short + s.NpcId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Messages : array : string + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Messages = append(s.Messages, "") + if s.Messages[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestDialogServerPacket :: Quest selection dialog. +type QuestDialogServerPacket struct { + byteSize int + + BehaviorId int + QuestId int + SessionId int + DialogId int + QuestEntries []DialogQuestEntry + DialogEntries []DialogEntry +} + +func (s QuestDialogServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestDialogServerPacket) Action() net.PacketAction { + return net.PacketAction_Dialog +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestDialogServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestDialogServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // QuestCount : length : char + if err = writer.AddChar(len(s.QuestEntries)); err != nil { + return + } + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + // QuestId : field : short + if err = writer.AddShort(s.QuestId); err != nil { + return + } + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // DialogId : field : short + if err = writer.AddShort(s.DialogId); err != nil { + return + } + writer.AddByte(255) + // QuestEntries : array : DialogQuestEntry + for ndx := 0; ndx < len(s.QuestEntries); ndx++ { + if err = s.QuestEntries[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + // DialogEntries : array : DialogEntry + for ndx := 0; ndx < len(s.DialogEntries); ndx++ { + if err = s.DialogEntries[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *QuestDialogServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // QuestCount : length : char + questCount := reader.GetChar() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + // QuestId : field : short + s.QuestId = reader.GetShort() + // SessionId : field : short + s.SessionId = reader.GetShort() + // DialogId : field : short + s.DialogId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // QuestEntries : array : DialogQuestEntry + for ndx := 0; ndx < questCount; ndx++ { + s.QuestEntries = append(s.QuestEntries, DialogQuestEntry{}) + if err = s.QuestEntries[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + // DialogEntries : array : DialogEntry + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.DialogEntries = append(s.DialogEntries, DialogEntry{}) + if err = s.DialogEntries[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestListServerPacket :: Quest history / progress reply. +type QuestListServerPacket struct { + byteSize int + + Page net.QuestPage + QuestsCount int + PageData QuestListPageData +} + +type QuestListPageData interface { + protocol.EoData +} + +type QuestListPageDataProgress struct { + byteSize int + + QuestProgressEntries []QuestProgressEntry +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestListPageDataProgress) ByteSize() int { + return s.byteSize +} + +func (s *QuestListPageDataProgress) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // QuestProgressEntries : array : QuestProgressEntry + for ndx := 0; ndx < len(s.QuestProgressEntries); ndx++ { + if err = s.QuestProgressEntries[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *QuestListPageDataProgress) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // QuestProgressEntries : array : QuestProgressEntry + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.QuestProgressEntries = append(s.QuestProgressEntries, QuestProgressEntry{}) + if err = s.QuestProgressEntries[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type QuestListPageDataHistory struct { + byteSize int + + CompletedQuests []string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestListPageDataHistory) ByteSize() int { + return s.byteSize +} + +func (s *QuestListPageDataHistory) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CompletedQuests : array : string + for ndx := 0; ndx < len(s.CompletedQuests); ndx++ { + if err = writer.AddString(s.CompletedQuests[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + return +} + +func (s *QuestListPageDataHistory) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CompletedQuests : array : string + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.CompletedQuests = append(s.CompletedQuests, "") + if s.CompletedQuests[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s QuestListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Quest +} + +func (s QuestListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *QuestListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Page : field : QuestPage + if err = writer.AddChar(int(s.Page)); err != nil { + return + } + // QuestsCount : field : short + if err = writer.AddShort(s.QuestsCount); err != nil { + return + } + switch s.Page { + case net.QuestPage_Progress: + switch s.PageData.(type) { + case *QuestListPageDataProgress: + if err = s.PageData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.Page) + return + } + case net.QuestPage_History: + switch s.PageData.(type) { + case *QuestListPageDataHistory: + if err = s.PageData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.Page) + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *QuestListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Page : field : QuestPage + s.Page = net.QuestPage(reader.GetChar()) + // QuestsCount : field : short + s.QuestsCount = reader.GetShort() + switch s.Page { + case net.QuestPage_Progress: + s.PageData = &QuestListPageDataProgress{} + if err = s.PageData.Deserialize(reader); err != nil { + return + } + case net.QuestPage_History: + s.PageData = &QuestListPageDataHistory{} + if err = s.PageData.Deserialize(reader); err != nil { + return + } + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemAcceptServerPacket :: Nearby player leveled up from quest. +type ItemAcceptServerPacket struct { + byteSize int + + PlayerId int +} + +func (s ItemAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Item +} + +func (s ItemAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ItemAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + return +} + +func (s *ItemAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ArenaDropServerPacket :: "Arena is blocked" message. +type ArenaDropServerPacket struct { + byteSize int +} + +func (s ArenaDropServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Arena +} + +func (s ArenaDropServerPacket) Action() net.PacketAction { + return net.PacketAction_Drop +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ArenaDropServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ArenaDropServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // N : dummy : string + if err = writer.AddString("N"); err != nil { + return + } + return +} + +func (s *ArenaDropServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // N : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ArenaUseServerPacket :: Arena start message. +type ArenaUseServerPacket struct { + byteSize int + + PlayersCount int +} + +func (s ArenaUseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Arena +} + +func (s ArenaUseServerPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ArenaUseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ArenaUseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayersCount : field : char + if err = writer.AddChar(s.PlayersCount); err != nil { + return + } + return +} + +func (s *ArenaUseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayersCount : field : char + s.PlayersCount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ArenaSpecServerPacket :: Arena kill message. +type ArenaSpecServerPacket struct { + byteSize int + + PlayerId int + Direction protocol.Direction + KillsCount int + KillerName string + VictimName string +} + +func (s ArenaSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Arena +} + +func (s ArenaSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ArenaSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ArenaSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + writer.AddByte(255) + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + writer.AddByte(255) + // KillsCount : field : int + if err = writer.AddInt(s.KillsCount); err != nil { + return + } + writer.AddByte(255) + // KillerName : field : string + if err = writer.AddString(s.KillerName); err != nil { + return + } + writer.AddByte(255) + // VictimName : field : string + if err = writer.AddString(s.VictimName); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *ArenaSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerId : field : short + s.PlayerId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + if err = reader.NextChunk(); err != nil { + return + } + // KillsCount : field : int + s.KillsCount = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // KillerName : field : string + if s.KillerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // VictimName : field : string + if s.VictimName, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ArenaAcceptServerPacket :: Arena win message. +type ArenaAcceptServerPacket struct { + byteSize int + + WinnerName string + KillsCount int + KillerName string + VictimName string +} + +func (s ArenaAcceptServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Arena +} + +func (s ArenaAcceptServerPacket) Action() net.PacketAction { + return net.PacketAction_Accept +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ArenaAcceptServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *ArenaAcceptServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // WinnerName : field : string + if err = writer.AddString(s.WinnerName); err != nil { + return + } + writer.AddByte(255) + // KillsCount : field : int + if err = writer.AddInt(s.KillsCount); err != nil { + return + } + writer.AddByte(255) + // KillerName : field : string + if err = writer.AddString(s.KillerName); err != nil { + return + } + writer.AddByte(255) + // VictimName : field : string + if err = writer.AddString(s.VictimName); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *ArenaAcceptServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // WinnerName : field : string + if s.WinnerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // KillsCount : field : int + s.KillsCount = reader.GetInt() + if err = reader.NextChunk(); err != nil { + return + } + // KillerName : field : string + if s.KillerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // VictimName : field : string + if s.VictimName, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MarriageOpenServerPacket :: Response from talking to a law NPC. +type MarriageOpenServerPacket struct { + byteSize int + + SessionId int +} + +func (s MarriageOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Marriage +} + +func (s MarriageOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MarriageOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MarriageOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : three + if err = writer.AddThree(s.SessionId); err != nil { + return + } + return +} + +func (s *MarriageOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : three + s.SessionId = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MarriageReplyServerPacket :: Reply to client Marriage-family packets. +type MarriageReplyServerPacket struct { + byteSize int + + ReplyCode MarriageReply + ReplyCodeData MarriageReplyReplyCodeData +} + +type MarriageReplyReplyCodeData interface { + protocol.EoData +} + +type MarriageReplyReplyCodeDataSuccess struct { + byteSize int + + GoldAmount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MarriageReplyReplyCodeDataSuccess) ByteSize() int { + return s.byteSize +} + +func (s *MarriageReplyReplyCodeDataSuccess) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // GoldAmount : field : int + if err = writer.AddInt(s.GoldAmount); err != nil { + return + } + return +} + +func (s *MarriageReplyReplyCodeDataSuccess) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // GoldAmount : field : int + s.GoldAmount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s MarriageReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Marriage +} + +func (s MarriageReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MarriageReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MarriageReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : MarriageReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + switch s.ReplyCode { + case MarriageReply_Success: + switch s.ReplyCodeData.(type) { + case *MarriageReplyReplyCodeDataSuccess: + if err = s.ReplyCodeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ReplyCode) + return + } + } + return +} + +func (s *MarriageReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : MarriageReply + s.ReplyCode = MarriageReply(reader.GetShort()) + switch s.ReplyCode { + case MarriageReply_Success: + s.ReplyCodeData = &MarriageReplyReplyCodeDataSuccess{} + if err = s.ReplyCodeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestOpenServerPacket :: Response from talking to a priest NPC. +type PriestOpenServerPacket struct { + byteSize int + + SessionId int +} + +func (s PriestOpenServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestOpenServerPacket) Action() net.PacketAction { + return net.PacketAction_Open +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestOpenServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestOpenServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : int + if err = writer.AddInt(s.SessionId); err != nil { + return + } + return +} + +func (s *PriestOpenServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : int + s.SessionId = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestReplyServerPacket :: Reply to client Priest-family packets. +type PriestReplyServerPacket struct { + byteSize int + + ReplyCode PriestReply +} + +func (s PriestReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ReplyCode : field : PriestReply + if err = writer.AddShort(int(s.ReplyCode)); err != nil { + return + } + return +} + +func (s *PriestReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ReplyCode : field : PriestReply + s.ReplyCode = PriestReply(reader.GetShort()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PriestRequestServerPacket :: Wedding request. +type PriestRequestServerPacket struct { + byteSize int + + SessionId int + PartnerName string +} + +func (s PriestRequestServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Priest +} + +func (s PriestRequestServerPacket) Action() net.PacketAction { + return net.PacketAction_Request +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PriestRequestServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *PriestRequestServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SessionId : field : short + if err = writer.AddShort(s.SessionId); err != nil { + return + } + // PartnerName : field : string + if err = writer.AddString(s.PartnerName); err != nil { + return + } + return +} + +func (s *PriestRequestServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SessionId : field : short + s.SessionId = reader.GetShort() + // PartnerName : field : string + if s.PartnerName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RecoverPlayerServerPacket :: HP/TP update. +type RecoverPlayerServerPacket struct { + byteSize int + + Hp int + Tp int +} + +func (s RecoverPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Recover +} + +func (s RecoverPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RecoverPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RecoverPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + return +} + +func (s *RecoverPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Hp : field : short + s.Hp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RecoverAgreeServerPacket :: Nearby player gained HP. +type RecoverAgreeServerPacket struct { + byteSize int + + PlayerId int + HealHp int + HpPercentage int +} + +func (s RecoverAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Recover +} + +func (s RecoverAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RecoverAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RecoverAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // HealHp : field : int + if err = writer.AddInt(s.HealHp); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + return +} + +func (s *RecoverAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // HealHp : field : int + s.HealHp = reader.GetInt() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RecoverListServerPacket :: Stats update. +type RecoverListServerPacket struct { + byteSize int + + ClassId int + Stats CharacterStatsUpdate +} + +func (s RecoverListServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Recover +} + +func (s RecoverListServerPacket) Action() net.PacketAction { + return net.PacketAction_List +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RecoverListServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RecoverListServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ClassId : field : short + if err = writer.AddShort(s.ClassId); err != nil { + return + } + // Stats : field : CharacterStatsUpdate + if err = s.Stats.Serialize(writer); err != nil { + return + } + return +} + +func (s *RecoverListServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ClassId : field : short + s.ClassId = reader.GetShort() + // Stats : field : CharacterStatsUpdate + if err = s.Stats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RecoverReplyServerPacket :: Karma/experience update. +type RecoverReplyServerPacket struct { + byteSize int + + Experience int + Karma int + LevelUp *int // A value greater than 0 is "new level" and indicates the player leveled up. The official client reads this if the packet is larger than 6 bytes. + StatPoints *int // The official client reads this if the player leveled up. + SkillPoints *int // The official client reads this if the player leveled up. +} + +func (s RecoverReplyServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Recover +} + +func (s RecoverReplyServerPacket) Action() net.PacketAction { + return net.PacketAction_Reply +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RecoverReplyServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RecoverReplyServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Experience : field : int + if err = writer.AddInt(s.Experience); err != nil { + return + } + // Karma : field : short + if err = writer.AddShort(s.Karma); err != nil { + return + } + // LevelUp : field : char + if s.LevelUp != nil { + if err = writer.AddChar(*s.LevelUp); err != nil { + return + } + } + // StatPoints : field : short + if s.StatPoints != nil { + if err = writer.AddShort(*s.StatPoints); err != nil { + return + } + } + // SkillPoints : field : short + if s.SkillPoints != nil { + if err = writer.AddShort(*s.SkillPoints); err != nil { + return + } + } + return +} + +func (s *RecoverReplyServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Experience : field : int + s.Experience = reader.GetInt() + // Karma : field : short + s.Karma = reader.GetShort() + // LevelUp : field : char + if reader.Remaining() > 0 { + s.LevelUp = new(int) + *s.LevelUp = reader.GetChar() + } + // StatPoints : field : short + if reader.Remaining() > 0 { + s.StatPoints = new(int) + *s.StatPoints = reader.GetShort() + } + // SkillPoints : field : short + if reader.Remaining() > 0 { + s.SkillPoints = new(int) + *s.SkillPoints = reader.GetShort() + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// RecoverTargetGroupServerPacket :: Updated stats when levelling up from party experience. +type RecoverTargetGroupServerPacket struct { + byteSize int + + StatPoints int + SkillPoints int + MaxHp int + MaxTp int + MaxSp int +} + +func (s RecoverTargetGroupServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Recover +} + +func (s RecoverTargetGroupServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetGroup +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *RecoverTargetGroupServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *RecoverTargetGroupServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + return +} + +func (s *RecoverTargetGroupServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectUseServerPacket :: Map effect. +type EffectUseServerPacket struct { + byteSize int + + Effect MapEffect + EffectData EffectUseEffectData +} + +type EffectUseEffectData interface { + protocol.EoData +} + +type EffectUseEffectDataQuake struct { + byteSize int + + QuakeStrength int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectUseEffectDataQuake) ByteSize() int { + return s.byteSize +} + +func (s *EffectUseEffectDataQuake) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // QuakeStrength : field : char + if err = writer.AddChar(s.QuakeStrength); err != nil { + return + } + return +} + +func (s *EffectUseEffectDataQuake) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // QuakeStrength : field : char + s.QuakeStrength = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s EffectUseServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectUseServerPacket) Action() net.PacketAction { + return net.PacketAction_Use +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectUseServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectUseServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Effect : field : MapEffect + if err = writer.AddChar(int(s.Effect)); err != nil { + return + } + switch s.Effect { + case MapEffect_Quake: + switch s.EffectData.(type) { + case *EffectUseEffectDataQuake: + if err = s.EffectData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.Effect) + return + } + } + return +} + +func (s *EffectUseServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Effect : field : MapEffect + s.Effect = MapEffect(reader.GetChar()) + switch s.Effect { + case MapEffect_Quake: + s.EffectData = &EffectUseEffectDataQuake{} + if err = s.EffectData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectAgreeServerPacket :: Effects playing on nearby tiles. +type EffectAgreeServerPacket struct { + byteSize int + + Effects []TileEffect +} + +func (s EffectAgreeServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectAgreeServerPacket) Action() net.PacketAction { + return net.PacketAction_Agree +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectAgreeServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectAgreeServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Effects : array : TileEffect + for ndx := 0; ndx < len(s.Effects); ndx++ { + if err = s.Effects[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *EffectAgreeServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Effects : array : TileEffect + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Effects = append(s.Effects, TileEffect{}) + if err = s.Effects[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectTargetOtherServerPacket :: Map drain damage. +type EffectTargetOtherServerPacket struct { + byteSize int + + Damage int + Hp int + MaxHp int + Others []MapDrainDamageOther +} + +func (s EffectTargetOtherServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectTargetOtherServerPacket) Action() net.PacketAction { + return net.PacketAction_TargetOther +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectTargetOtherServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectTargetOtherServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Damage : field : short + if err = writer.AddShort(s.Damage); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // Others : array : MapDrainDamageOther + for ndx := 0; ndx < len(s.Others); ndx++ { + if err = s.Others[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *EffectTargetOtherServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Damage : field : short + s.Damage = reader.GetShort() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // Others : array : MapDrainDamageOther + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Others = append(s.Others, MapDrainDamageOther{}) + if err = s.Others[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectReportServerPacket :: Map spike timer. +type EffectReportServerPacket struct { + byteSize int +} + +func (s EffectReportServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectReportServerPacket) Action() net.PacketAction { + return net.PacketAction_Report +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectReportServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectReportServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // S : dummy : string + if err = writer.AddString("S"); err != nil { + return + } + return +} + +func (s *EffectReportServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // S : dummy : string + if _, err = reader.GetString(); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectSpecServerPacket :: Taking spike or tp drain damage. +type EffectSpecServerPacket struct { + byteSize int + + MapDamageType MapDamageType + MapDamageTypeData EffectSpecMapDamageTypeData +} + +type EffectSpecMapDamageTypeData interface { + protocol.EoData +} + +type EffectSpecMapDamageTypeDataTpDrain struct { + byteSize int + + TpDamage int + Tp int + MaxTp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectSpecMapDamageTypeDataTpDrain) ByteSize() int { + return s.byteSize +} + +func (s *EffectSpecMapDamageTypeDataTpDrain) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // TpDamage : field : short + if err = writer.AddShort(s.TpDamage); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + return +} + +func (s *EffectSpecMapDamageTypeDataTpDrain) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // TpDamage : field : short + s.TpDamage = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type EffectSpecMapDamageTypeDataSpikes struct { + byteSize int + + HpDamage int + Hp int + MaxHp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectSpecMapDamageTypeDataSpikes) ByteSize() int { + return s.byteSize +} + +func (s *EffectSpecMapDamageTypeDataSpikes) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HpDamage : field : short + if err = writer.AddShort(s.HpDamage); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + return +} + +func (s *EffectSpecMapDamageTypeDataSpikes) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HpDamage : field : short + s.HpDamage = reader.GetShort() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +func (s EffectSpecServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectSpecServerPacket) Action() net.PacketAction { + return net.PacketAction_Spec +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectSpecServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectSpecServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MapDamageType : field : MapDamageType + if err = writer.AddChar(int(s.MapDamageType)); err != nil { + return + } + switch s.MapDamageType { + case MapDamage_TpDrain: + switch s.MapDamageTypeData.(type) { + case *EffectSpecMapDamageTypeDataTpDrain: + if err = s.MapDamageTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.MapDamageType) + return + } + case MapDamage_Spikes: + switch s.MapDamageTypeData.(type) { + case *EffectSpecMapDamageTypeDataSpikes: + if err = s.MapDamageTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.MapDamageType) + return + } + } + return +} + +func (s *EffectSpecServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MapDamageType : field : MapDamageType + s.MapDamageType = MapDamageType(reader.GetChar()) + switch s.MapDamageType { + case MapDamage_TpDrain: + s.MapDamageTypeData = &EffectSpecMapDamageTypeDataTpDrain{} + if err = s.MapDamageTypeData.Deserialize(reader); err != nil { + return + } + case MapDamage_Spikes: + s.MapDamageTypeData = &EffectSpecMapDamageTypeDataSpikes{} + if err = s.MapDamageTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EffectAdminServerPacket :: Nearby character taking spike damage. +type EffectAdminServerPacket struct { + byteSize int + + PlayerId int + HpPercentage int + Died bool + Damage int +} + +func (s EffectAdminServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Effect +} + +func (s EffectAdminServerPacket) Action() net.PacketAction { + return net.PacketAction_Admin +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EffectAdminServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *EffectAdminServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Died : field : bool + if s.Died { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + return +} + +func (s *EffectAdminServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Died : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Died = true + } else { + s.Died = false + } + // Damage : field : three + s.Damage = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MusicPlayerServerPacket :: Sound effect. +type MusicPlayerServerPacket struct { + byteSize int + + SoundId int +} + +func (s MusicPlayerServerPacket) Family() net.PacketFamily { + return net.PacketFamily_Music +} + +func (s MusicPlayerServerPacket) Action() net.PacketAction { + return net.PacketAction_Player +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MusicPlayerServerPacket) ByteSize() int { + return s.byteSize +} + +func (s *MusicPlayerServerPacket) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SoundId : field : char + if err = writer.AddChar(s.SoundId); err != nil { + return + } + return +} + +func (s *MusicPlayerServerPacket) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SoundId : field : char + s.SoundId = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/net/server/structs_generated.go b/v3/protocol/net/server/structs_generated.go new file mode 100644 index 0000000..56376e9 --- /dev/null +++ b/v3/protocol/net/server/structs_generated.go @@ -0,0 +1,4011 @@ +package server + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" + "github.com/ethanmoffat/eolib-go/v3/protocol" + "github.com/ethanmoffat/eolib-go/v3/protocol/net" +) + +// BigCoords :: Map coordinates with 2-byte values. +type BigCoords struct { + byteSize int + + X int + Y int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BigCoords) ByteSize() int { + return s.byteSize +} + +func (s *BigCoords) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : short + if err = writer.AddShort(s.X); err != nil { + return + } + // Y : field : short + if err = writer.AddShort(s.Y); err != nil { + return + } + return +} + +func (s *BigCoords) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : short + s.X = reader.GetShort() + // Y : field : short + s.Y = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EquipmentChange :: Player equipment data. Sent when a player's visible equipment changes. Note that these values are graphic IDs. +type EquipmentChange struct { + byteSize int + + Boots int + Armor int + Hat int + Weapon int + Shield int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EquipmentChange) ByteSize() int { + return s.byteSize +} + +func (s *EquipmentChange) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Boots : field : short + if err = writer.AddShort(s.Boots); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // Hat : field : short + if err = writer.AddShort(s.Hat); err != nil { + return + } + // Weapon : field : short + if err = writer.AddShort(s.Weapon); err != nil { + return + } + // Shield : field : short + if err = writer.AddShort(s.Shield); err != nil { + return + } + return +} + +func (s *EquipmentChange) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Boots : field : short + s.Boots = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // Hat : field : short + s.Hat = reader.GetShort() + // Weapon : field : short + s.Weapon = reader.GetShort() + // Shield : field : short + s.Shield = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EquipmentMapInfo :: Player equipment data. Sent with map information about a nearby character. Note that these values are graphic IDs. +type EquipmentMapInfo struct { + byteSize int + + Boots int + + Armor int + + Hat int + Shield int + Weapon int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EquipmentMapInfo) ByteSize() int { + return s.byteSize +} + +func (s *EquipmentMapInfo) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Boots : field : short + if err = writer.AddShort(s.Boots); err != nil { + return + } + // 0 : field : short + if err = writer.AddShort(0); err != nil { + return + } + // 0 : field : short + if err = writer.AddShort(0); err != nil { + return + } + // 0 : field : short + if err = writer.AddShort(0); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // 0 : field : short + if err = writer.AddShort(0); err != nil { + return + } + // Hat : field : short + if err = writer.AddShort(s.Hat); err != nil { + return + } + // Shield : field : short + if err = writer.AddShort(s.Shield); err != nil { + return + } + // Weapon : field : short + if err = writer.AddShort(s.Weapon); err != nil { + return + } + return +} + +func (s *EquipmentMapInfo) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Boots : field : short + s.Boots = reader.GetShort() + // 0 : field : short + reader.GetShort() + // 0 : field : short + reader.GetShort() + // 0 : field : short + reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // 0 : field : short + reader.GetShort() + // Hat : field : short + s.Hat = reader.GetShort() + // Shield : field : short + s.Shield = reader.GetShort() + // Weapon : field : short + s.Weapon = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EquipmentCharacterSelect :: Player equipment data. Sent with a character in the character selection list. Note that these values are graphic IDs. +type EquipmentCharacterSelect struct { + byteSize int + + Boots int + Armor int + Hat int + Shield int + Weapon int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EquipmentCharacterSelect) ByteSize() int { + return s.byteSize +} + +func (s *EquipmentCharacterSelect) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Boots : field : short + if err = writer.AddShort(s.Boots); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // Hat : field : short + if err = writer.AddShort(s.Hat); err != nil { + return + } + // Shield : field : short + if err = writer.AddShort(s.Shield); err != nil { + return + } + // Weapon : field : short + if err = writer.AddShort(s.Weapon); err != nil { + return + } + return +} + +func (s *EquipmentCharacterSelect) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Boots : field : short + s.Boots = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // Hat : field : short + s.Hat = reader.GetShort() + // Shield : field : short + s.Shield = reader.GetShort() + // Weapon : field : short + s.Weapon = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EquipmentWelcome :: Player equipment data. Sent upon selecting a character and entering the game. Note that these values are item IDs. +type EquipmentWelcome struct { + byteSize int + + Boots int + Gloves int + Accessory int + Armor int + Belt int + Necklace int + Hat int + Shield int + Weapon int + Ring []int + Armlet []int + Bracer []int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EquipmentWelcome) ByteSize() int { + return s.byteSize +} + +func (s *EquipmentWelcome) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Boots : field : short + if err = writer.AddShort(s.Boots); err != nil { + return + } + // Gloves : field : short + if err = writer.AddShort(s.Gloves); err != nil { + return + } + // Accessory : field : short + if err = writer.AddShort(s.Accessory); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // Belt : field : short + if err = writer.AddShort(s.Belt); err != nil { + return + } + // Necklace : field : short + if err = writer.AddShort(s.Necklace); err != nil { + return + } + // Hat : field : short + if err = writer.AddShort(s.Hat); err != nil { + return + } + // Shield : field : short + if err = writer.AddShort(s.Shield); err != nil { + return + } + // Weapon : field : short + if err = writer.AddShort(s.Weapon); err != nil { + return + } + // Ring : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Ring) != 2 { + err = fmt.Errorf("expected Ring with length 2, got %d", len(s.Ring)) + return + } + + if err = writer.AddShort(s.Ring[ndx]); err != nil { + return + } + } + + // Armlet : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Armlet) != 2 { + err = fmt.Errorf("expected Armlet with length 2, got %d", len(s.Armlet)) + return + } + + if err = writer.AddShort(s.Armlet[ndx]); err != nil { + return + } + } + + // Bracer : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Bracer) != 2 { + err = fmt.Errorf("expected Bracer with length 2, got %d", len(s.Bracer)) + return + } + + if err = writer.AddShort(s.Bracer[ndx]); err != nil { + return + } + } + + return +} + +func (s *EquipmentWelcome) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Boots : field : short + s.Boots = reader.GetShort() + // Gloves : field : short + s.Gloves = reader.GetShort() + // Accessory : field : short + s.Accessory = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // Belt : field : short + s.Belt = reader.GetShort() + // Necklace : field : short + s.Necklace = reader.GetShort() + // Hat : field : short + s.Hat = reader.GetShort() + // Shield : field : short + s.Shield = reader.GetShort() + // Weapon : field : short + s.Weapon = reader.GetShort() + // Ring : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Ring = append(s.Ring, 0) + s.Ring[ndx] = reader.GetShort() + } + + // Armlet : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Armlet = append(s.Armlet, 0) + s.Armlet[ndx] = reader.GetShort() + } + + // Bracer : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Bracer = append(s.Bracer, 0) + s.Bracer[ndx] = reader.GetShort() + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EquipmentPaperdoll :: Player equipment data. Sent with information about a player's paperdoll. Note that these values are item IDs. +type EquipmentPaperdoll struct { + byteSize int + + Boots int + Accessory int + Gloves int + Belt int + Armor int + Necklace int + Hat int + Shield int + Weapon int + Ring []int + Armlet []int + Bracer []int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EquipmentPaperdoll) ByteSize() int { + return s.byteSize +} + +func (s *EquipmentPaperdoll) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Boots : field : short + if err = writer.AddShort(s.Boots); err != nil { + return + } + // Accessory : field : short + if err = writer.AddShort(s.Accessory); err != nil { + return + } + // Gloves : field : short + if err = writer.AddShort(s.Gloves); err != nil { + return + } + // Belt : field : short + if err = writer.AddShort(s.Belt); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // Necklace : field : short + if err = writer.AddShort(s.Necklace); err != nil { + return + } + // Hat : field : short + if err = writer.AddShort(s.Hat); err != nil { + return + } + // Shield : field : short + if err = writer.AddShort(s.Shield); err != nil { + return + } + // Weapon : field : short + if err = writer.AddShort(s.Weapon); err != nil { + return + } + // Ring : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Ring) != 2 { + err = fmt.Errorf("expected Ring with length 2, got %d", len(s.Ring)) + return + } + + if err = writer.AddShort(s.Ring[ndx]); err != nil { + return + } + } + + // Armlet : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Armlet) != 2 { + err = fmt.Errorf("expected Armlet with length 2, got %d", len(s.Armlet)) + return + } + + if err = writer.AddShort(s.Armlet[ndx]); err != nil { + return + } + } + + // Bracer : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Bracer) != 2 { + err = fmt.Errorf("expected Bracer with length 2, got %d", len(s.Bracer)) + return + } + + if err = writer.AddShort(s.Bracer[ndx]); err != nil { + return + } + } + + return +} + +func (s *EquipmentPaperdoll) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Boots : field : short + s.Boots = reader.GetShort() + // Accessory : field : short + s.Accessory = reader.GetShort() + // Gloves : field : short + s.Gloves = reader.GetShort() + // Belt : field : short + s.Belt = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // Necklace : field : short + s.Necklace = reader.GetShort() + // Hat : field : short + s.Hat = reader.GetShort() + // Shield : field : short + s.Shield = reader.GetShort() + // Weapon : field : short + s.Weapon = reader.GetShort() + // Ring : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Ring = append(s.Ring, 0) + s.Ring[ndx] = reader.GetShort() + } + + // Armlet : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Armlet = append(s.Armlet, 0) + s.Armlet[ndx] = reader.GetShort() + } + + // Bracer : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Bracer = append(s.Bracer, 0) + s.Bracer[ndx] = reader.GetShort() + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterMapInfo :: Information about a nearby character. The official client skips these if they're under 42 bytes in length. +type CharacterMapInfo struct { + byteSize int + + Name string + PlayerId int + MapId int + Coords BigCoords + Direction protocol.Direction + ClassId int + GuildTag string + Level int + Gender protocol.Gender + HairStyle int + HairColor int + Skin int + MaxHp int + Hp int + MaxTp int + Tp int + Equipment EquipmentMapInfo + SitState SitState + Invisible bool + WarpEffect *WarpEffect +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterMapInfo) ByteSize() int { + return s.byteSize +} + +func (s *CharacterMapInfo) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // MapId : field : short + if err = writer.AddShort(s.MapId); err != nil { + return + } + // Coords : field : BigCoords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + // GuildTag : field : string + if len(s.GuildTag) != 3 { + err = fmt.Errorf("expected GuildTag with length 3, got %d", len(s.GuildTag)) + return + } + if err = writer.AddFixedString(s.GuildTag, 3); err != nil { + return + } + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // Gender : field : Gender + if err = writer.AddChar(int(s.Gender)); err != nil { + return + } + // HairStyle : field : char + if err = writer.AddChar(s.HairStyle); err != nil { + return + } + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + // Skin : field : char + if err = writer.AddChar(s.Skin); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // Equipment : field : EquipmentMapInfo + if err = s.Equipment.Serialize(writer); err != nil { + return + } + // SitState : field : SitState + if err = writer.AddChar(int(s.SitState)); err != nil { + return + } + // Invisible : field : bool + if s.Invisible { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // WarpEffect : field : WarpEffect + if s.WarpEffect != nil { + if err = writer.AddChar(int(*s.WarpEffect)); err != nil { + return + } + } + writer.SanitizeStrings = false + return +} + +func (s *CharacterMapInfo) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // MapId : field : short + s.MapId = reader.GetShort() + // Coords : field : BigCoords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // ClassId : field : char + s.ClassId = reader.GetChar() + // GuildTag : field : string + if s.GuildTag, err = reader.GetFixedString(3); err != nil { + return + } + + // Level : field : char + s.Level = reader.GetChar() + // Gender : field : Gender + s.Gender = protocol.Gender(reader.GetChar()) + // HairStyle : field : char + s.HairStyle = reader.GetChar() + // HairColor : field : char + s.HairColor = reader.GetChar() + // Skin : field : char + s.Skin = reader.GetChar() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // Equipment : field : EquipmentMapInfo + if err = s.Equipment.Deserialize(reader); err != nil { + return + } + // SitState : field : SitState + s.SitState = SitState(reader.GetChar()) + // Invisible : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Invisible = true + } else { + s.Invisible = false + } + // WarpEffect : field : WarpEffect + if reader.Remaining() > 0 { + s.WarpEffect = new(WarpEffect) + *s.WarpEffect = WarpEffect(reader.GetChar()) + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcMapInfo :: Information about a nearby NPC. +type NpcMapInfo struct { + byteSize int + + Index int + Id int + Coords protocol.Coords + Direction protocol.Direction +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcMapInfo) ByteSize() int { + return s.byteSize +} + +func (s *NpcMapInfo) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Index : field : char + if err = writer.AddChar(s.Index); err != nil { + return + } + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *NpcMapInfo) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Index : field : char + s.Index = reader.GetChar() + // Id : field : short + s.Id = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ItemMapInfo :: Information about a nearby item on the ground. +type ItemMapInfo struct { + byteSize int + + Uid int + Id int + Coords protocol.Coords + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ItemMapInfo) ByteSize() int { + return s.byteSize +} + +func (s *ItemMapInfo) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Uid : field : short + if err = writer.AddShort(s.Uid); err != nil { + return + } + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Amount : field : three + if err = writer.AddThree(s.Amount); err != nil { + return + } + return +} + +func (s *ItemMapInfo) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Uid : field : short + s.Uid = reader.GetShort() + // Id : field : short + s.Id = reader.GetShort() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Amount : field : three + s.Amount = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// AvatarChange :: Information about a nearby player's appearance changing. +type AvatarChange struct { + byteSize int + + PlayerId int + ChangeType AvatarChangeType + Sound bool + ChangeTypeData ChangeTypeData +} + +type ChangeTypeData interface { + protocol.EoData +} + +type ChangeTypeDataEquipment struct { + byteSize int + + Equipment EquipmentChange +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChangeTypeDataEquipment) ByteSize() int { + return s.byteSize +} + +func (s *ChangeTypeDataEquipment) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Equipment : field : EquipmentChange + if err = s.Equipment.Serialize(writer); err != nil { + return + } + return +} + +func (s *ChangeTypeDataEquipment) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Equipment : field : EquipmentChange + if err = s.Equipment.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ChangeTypeDataHair struct { + byteSize int + + HairStyle int + HairColor int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChangeTypeDataHair) ByteSize() int { + return s.byteSize +} + +func (s *ChangeTypeDataHair) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HairStyle : field : char + if err = writer.AddChar(s.HairStyle); err != nil { + return + } + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + return +} + +func (s *ChangeTypeDataHair) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HairStyle : field : char + s.HairStyle = reader.GetChar() + // HairColor : field : char + s.HairColor = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +type ChangeTypeDataHairColor struct { + byteSize int + + HairColor int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ChangeTypeDataHairColor) ByteSize() int { + return s.byteSize +} + +func (s *ChangeTypeDataHairColor) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + return +} + +func (s *ChangeTypeDataHairColor) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // HairColor : field : char + s.HairColor = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *AvatarChange) ByteSize() int { + return s.byteSize +} + +func (s *AvatarChange) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // ChangeType : field : AvatarChangeType + if err = writer.AddChar(int(s.ChangeType)); err != nil { + return + } + // Sound : field : bool + if s.Sound { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + switch s.ChangeType { + case AvatarChange_Equipment: + switch s.ChangeTypeData.(type) { + case *ChangeTypeDataEquipment: + if err = s.ChangeTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ChangeType) + return + } + case AvatarChange_Hair: + switch s.ChangeTypeData.(type) { + case *ChangeTypeDataHair: + if err = s.ChangeTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ChangeType) + return + } + case AvatarChange_HairColor: + switch s.ChangeTypeData.(type) { + case *ChangeTypeDataHairColor: + if err = s.ChangeTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.ChangeType) + return + } + } + return +} + +func (s *AvatarChange) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // ChangeType : field : AvatarChangeType + s.ChangeType = AvatarChangeType(reader.GetChar()) + // Sound : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Sound = true + } else { + s.Sound = false + } + switch s.ChangeType { + case AvatarChange_Equipment: + s.ChangeTypeData = &ChangeTypeDataEquipment{} + if err = s.ChangeTypeData.Deserialize(reader); err != nil { + return + } + case AvatarChange_Hair: + s.ChangeTypeData = &ChangeTypeDataHair{} + if err = s.ChangeTypeData.Deserialize(reader); err != nil { + return + } + case AvatarChange_HairColor: + s.ChangeTypeData = &ChangeTypeDataHairColor{} + if err = s.ChangeTypeData.Deserialize(reader); err != nil { + return + } + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NearbyInfo :: Information about nearby entities. +type NearbyInfo struct { + byteSize int + + Characters []CharacterMapInfo + Npcs []NpcMapInfo + Items []ItemMapInfo +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NearbyInfo) ByteSize() int { + return s.byteSize +} + +func (s *NearbyInfo) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // CharactersCount : length : char + if err = writer.AddChar(len(s.Characters)); err != nil { + return + } + writer.SanitizeStrings = true + writer.AddByte(255) + // Characters : array : CharacterMapInfo + for ndx := 0; ndx < len(s.Characters); ndx++ { + if err = s.Characters[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + // Npcs : array : NpcMapInfo + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // Items : array : ItemMapInfo + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + writer.SanitizeStrings = false + return +} + +func (s *NearbyInfo) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // CharactersCount : length : char + charactersCount := reader.GetChar() + reader.SetIsChunked(true) + if err = reader.NextChunk(); err != nil { + return + } + // Characters : array : CharacterMapInfo + for ndx := 0; ndx < charactersCount; ndx++ { + s.Characters = append(s.Characters, CharacterMapInfo{}) + if err = s.Characters[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + // Npcs : array : NpcMapInfo + NpcsRemaining := reader.Remaining() + for ndx := 0; ndx < NpcsRemaining/6; ndx++ { + s.Npcs = append(s.Npcs, NpcMapInfo{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // Items : array : ItemMapInfo + ItemsRemaining := reader.Remaining() + for ndx := 0; ndx < ItemsRemaining/9; ndx++ { + s.Items = append(s.Items, ItemMapInfo{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapFile :: A map file (EMF). +type MapFile struct { + byteSize int + + Content []byte +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapFile) ByteSize() int { + return s.byteSize +} + +func (s *MapFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Content : field : blob + if err = writer.AddBytes(s.Content); err != nil { + return + } + return +} + +func (s *MapFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Content : field : blob + s.Content = reader.GetBytes(reader.Remaining()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PubFile :: A pub file (EIF, ENF, ECF, ESF). +type PubFile struct { + byteSize int + + FileId int + Content []byte +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PubFile) ByteSize() int { + return s.byteSize +} + +func (s *PubFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // FileId : field : char + if err = writer.AddChar(s.FileId); err != nil { + return + } + // Content : field : blob + if err = writer.AddBytes(s.Content); err != nil { + return + } + return +} + +func (s *PubFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // FileId : field : char + s.FileId = reader.GetChar() + // Content : field : blob + s.Content = reader.GetBytes(reader.Remaining()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersList :: Information about online players. +type PlayersList struct { + byteSize int + + Players []OnlinePlayer +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersList) ByteSize() int { + return s.byteSize +} + +func (s *PlayersList) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersCount : length : short + if err = writer.AddShort(len(s.Players)); err != nil { + return + } + writer.AddByte(255) + // Players : array : OnlinePlayer + for ndx := 0; ndx < len(s.Players); ndx++ { + if err = s.Players[ndx].Serialize(writer); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *PlayersList) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersCount : length : short + playersCount := reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Players : array : OnlinePlayer + for ndx := 0; ndx < playersCount; ndx++ { + s.Players = append(s.Players, OnlinePlayer{}) + if err = s.Players[ndx].Deserialize(reader); err != nil { + return + } + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayersListFriends :: Information about online players. Sent in reply to friends list requests. +type PlayersListFriends struct { + byteSize int + + Players []string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayersListFriends) ByteSize() int { + return s.byteSize +} + +func (s *PlayersListFriends) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayersCount : length : short + if err = writer.AddShort(len(s.Players)); err != nil { + return + } + writer.AddByte(255) + // Players : array : string + for ndx := 0; ndx < len(s.Players); ndx++ { + if err = writer.AddString(s.Players[ndx]); err != nil { + return + } + writer.AddByte(255) + } + + writer.SanitizeStrings = false + return +} + +func (s *PlayersListFriends) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayersCount : length : short + playersCount := reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Players : array : string + for ndx := 0; ndx < playersCount; ndx++ { + s.Players = append(s.Players, "") + if s.Players[ndx], err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// OnlinePlayer :: A player in the online list. +type OnlinePlayer struct { + byteSize int + + Name string + Title string + Level int + Icon CharacterIcon + ClassId int + GuildTag string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *OnlinePlayer) ByteSize() int { + return s.byteSize +} + +func (s *OnlinePlayer) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Title : field : string + if err = writer.AddString(s.Title); err != nil { + return + } + writer.AddByte(255) + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // Icon : field : CharacterIcon + if err = writer.AddChar(int(s.Icon)); err != nil { + return + } + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + // GuildTag : field : string + if err = writer.AddString(s.GuildTag); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *OnlinePlayer) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Title : field : string + if s.Title, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Level : field : char + s.Level = reader.GetChar() + // Icon : field : CharacterIcon + s.Icon = CharacterIcon(reader.GetChar()) + // ClassId : field : char + s.ClassId = reader.GetChar() + // GuildTag : field : string + if s.GuildTag, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterSelectionListEntry :: Character selection screen character. +type CharacterSelectionListEntry struct { + byteSize int + + Name string + Id int + Level int + Gender protocol.Gender + HairStyle int + HairColor int + Skin int + Admin protocol.AdminLevel + Equipment EquipmentCharacterSelect +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterSelectionListEntry) ByteSize() int { + return s.byteSize +} + +func (s *CharacterSelectionListEntry) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Id : field : int + if err = writer.AddInt(s.Id); err != nil { + return + } + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // Gender : field : Gender + if err = writer.AddChar(int(s.Gender)); err != nil { + return + } + // HairStyle : field : char + if err = writer.AddChar(s.HairStyle); err != nil { + return + } + // HairColor : field : char + if err = writer.AddChar(s.HairColor); err != nil { + return + } + // Skin : field : char + if err = writer.AddChar(s.Skin); err != nil { + return + } + // Admin : field : AdminLevel + if err = writer.AddChar(int(s.Admin)); err != nil { + return + } + // Equipment : field : EquipmentCharacterSelect + if err = s.Equipment.Serialize(writer); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *CharacterSelectionListEntry) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Id : field : int + s.Id = reader.GetInt() + // Level : field : char + s.Level = reader.GetChar() + // Gender : field : Gender + s.Gender = protocol.Gender(reader.GetChar()) + // HairStyle : field : char + s.HairStyle = reader.GetChar() + // HairColor : field : char + s.HairColor = reader.GetChar() + // Skin : field : char + s.Skin = reader.GetChar() + // Admin : field : AdminLevel + s.Admin = protocol.AdminLevel(reader.GetChar()) + // Equipment : field : EquipmentCharacterSelect + if err = s.Equipment.Deserialize(reader); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ServerSettings :: Settings sent with WELCOME_REPLY packet. +type ServerSettings struct { + byteSize int + + JailMap int + RescueMap int + RescueCoords protocol.Coords + SpyAndLightGuideFloodRate int + GuardianFloodRate int + GameMasterFloodRate int + HighGameMasterFloodRate int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ServerSettings) ByteSize() int { + return s.byteSize +} + +func (s *ServerSettings) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // JailMap : field : short + if err = writer.AddShort(s.JailMap); err != nil { + return + } + // RescueMap : field : short + if err = writer.AddShort(s.RescueMap); err != nil { + return + } + // RescueCoords : field : Coords + if err = s.RescueCoords.Serialize(writer); err != nil { + return + } + // SpyAndLightGuideFloodRate : field : short + if err = writer.AddShort(s.SpyAndLightGuideFloodRate); err != nil { + return + } + // GuardianFloodRate : field : short + if err = writer.AddShort(s.GuardianFloodRate); err != nil { + return + } + // GameMasterFloodRate : field : short + if err = writer.AddShort(s.GameMasterFloodRate); err != nil { + return + } + // HighGameMasterFloodRate : field : short + if err = writer.AddShort(s.HighGameMasterFloodRate); err != nil { + return + } + return +} + +func (s *ServerSettings) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // JailMap : field : short + s.JailMap = reader.GetShort() + // RescueMap : field : short + s.RescueMap = reader.GetShort() + // RescueCoords : field : Coords + if err = s.RescueCoords.Deserialize(reader); err != nil { + return + } + // SpyAndLightGuideFloodRate : field : short + s.SpyAndLightGuideFloodRate = reader.GetShort() + // GuardianFloodRate : field : short + s.GuardianFloodRate = reader.GetShort() + // GameMasterFloodRate : field : short + s.GameMasterFloodRate = reader.GetShort() + // HighGameMasterFloodRate : field : short + s.HighGameMasterFloodRate = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopTradeItem :: An item that a shop can buy or sell. +type ShopTradeItem struct { + byteSize int + + ItemId int + BuyPrice int + SellPrice int + MaxBuyAmount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopTradeItem) ByteSize() int { + return s.byteSize +} + +func (s *ShopTradeItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // BuyPrice : field : three + if err = writer.AddThree(s.BuyPrice); err != nil { + return + } + // SellPrice : field : three + if err = writer.AddThree(s.SellPrice); err != nil { + return + } + // MaxBuyAmount : field : char + if err = writer.AddChar(s.MaxBuyAmount); err != nil { + return + } + return +} + +func (s *ShopTradeItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // BuyPrice : field : three + s.BuyPrice = reader.GetThree() + // SellPrice : field : three + s.SellPrice = reader.GetThree() + // MaxBuyAmount : field : char + s.MaxBuyAmount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopCraftItem :: An item that a shop can craft. +type ShopCraftItem struct { + byteSize int + + ItemId int + Ingredients []net.CharItem +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopCraftItem) ByteSize() int { + return s.byteSize +} + +func (s *ShopCraftItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // Ingredients : array : CharItem + for ndx := 0; ndx < 4; ndx++ { + if len(s.Ingredients) != 4 { + err = fmt.Errorf("expected Ingredients with length 4, got %d", len(s.Ingredients)) + return + } + + if err = s.Ingredients[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ShopCraftItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // Ingredients : array : CharItem + for ndx := 0; ndx < 4; ndx++ { + s.Ingredients = append(s.Ingredients, net.CharItem{}) + if err = s.Ingredients[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopSoldItem :: A sold item when selling an item to a shop. +type ShopSoldItem struct { + byteSize int + + Amount int + Id int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopSoldItem) ByteSize() int { + return s.byteSize +} + +func (s *ShopSoldItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Amount : field : int + if err = writer.AddInt(s.Amount); err != nil { + return + } + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + return +} + +func (s *ShopSoldItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Amount : field : int + s.Amount = reader.GetInt() + // Id : field : short + s.Id = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterBaseStats :: The 6 base character stats. +type CharacterBaseStats struct { + byteSize int + + Str int + Intl int + Wis int + Agi int + Con int + Cha int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterBaseStats) ByteSize() int { + return s.byteSize +} + +func (s *CharacterBaseStats) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Str : field : short + if err = writer.AddShort(s.Str); err != nil { + return + } + // Intl : field : short + if err = writer.AddShort(s.Intl); err != nil { + return + } + // Wis : field : short + if err = writer.AddShort(s.Wis); err != nil { + return + } + // Agi : field : short + if err = writer.AddShort(s.Agi); err != nil { + return + } + // Con : field : short + if err = writer.AddShort(s.Con); err != nil { + return + } + // Cha : field : short + if err = writer.AddShort(s.Cha); err != nil { + return + } + return +} + +func (s *CharacterBaseStats) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Str : field : short + s.Str = reader.GetShort() + // Intl : field : short + s.Intl = reader.GetShort() + // Wis : field : short + s.Wis = reader.GetShort() + // Agi : field : short + s.Agi = reader.GetShort() + // Con : field : short + s.Con = reader.GetShort() + // Cha : field : short + s.Cha = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterBaseStatsWelcome :: The 6 base character stats. Sent upon selecting a character and entering the game. +type CharacterBaseStatsWelcome struct { + byteSize int + + Str int + Wis int + Intl int + Agi int + Con int + Cha int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterBaseStatsWelcome) ByteSize() int { + return s.byteSize +} + +func (s *CharacterBaseStatsWelcome) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Str : field : short + if err = writer.AddShort(s.Str); err != nil { + return + } + // Wis : field : short + if err = writer.AddShort(s.Wis); err != nil { + return + } + // Intl : field : short + if err = writer.AddShort(s.Intl); err != nil { + return + } + // Agi : field : short + if err = writer.AddShort(s.Agi); err != nil { + return + } + // Con : field : short + if err = writer.AddShort(s.Con); err != nil { + return + } + // Cha : field : short + if err = writer.AddShort(s.Cha); err != nil { + return + } + return +} + +func (s *CharacterBaseStatsWelcome) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Str : field : short + s.Str = reader.GetShort() + // Wis : field : short + s.Wis = reader.GetShort() + // Intl : field : short + s.Intl = reader.GetShort() + // Agi : field : short + s.Agi = reader.GetShort() + // Con : field : short + s.Con = reader.GetShort() + // Cha : field : short + s.Cha = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterSecondaryStats :: The 5 secondary character stats. +type CharacterSecondaryStats struct { + byteSize int + + MinDamage int + MaxDamage int + Accuracy int + Evade int + Armor int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterSecondaryStats) ByteSize() int { + return s.byteSize +} + +func (s *CharacterSecondaryStats) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MinDamage : field : short + if err = writer.AddShort(s.MinDamage); err != nil { + return + } + // MaxDamage : field : short + if err = writer.AddShort(s.MaxDamage); err != nil { + return + } + // Accuracy : field : short + if err = writer.AddShort(s.Accuracy); err != nil { + return + } + // Evade : field : short + if err = writer.AddShort(s.Evade); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + return +} + +func (s *CharacterSecondaryStats) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MinDamage : field : short + s.MinDamage = reader.GetShort() + // MaxDamage : field : short + s.MaxDamage = reader.GetShort() + // Accuracy : field : short + s.Accuracy = reader.GetShort() + // Evade : field : short + s.Evade = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterSecondaryStatsInfoLookup :: The 5 secondary character stats. Sent with character info lookups. +type CharacterSecondaryStatsInfoLookup struct { + byteSize int + + MaxDamage int + MinDamage int + Accuracy int + Evade int + Armor int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterSecondaryStatsInfoLookup) ByteSize() int { + return s.byteSize +} + +func (s *CharacterSecondaryStatsInfoLookup) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MaxDamage : field : short + if err = writer.AddShort(s.MaxDamage); err != nil { + return + } + // MinDamage : field : short + if err = writer.AddShort(s.MinDamage); err != nil { + return + } + // Accuracy : field : short + if err = writer.AddShort(s.Accuracy); err != nil { + return + } + // Evade : field : short + if err = writer.AddShort(s.Evade); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + return +} + +func (s *CharacterSecondaryStatsInfoLookup) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MaxDamage : field : short + s.MaxDamage = reader.GetShort() + // MinDamage : field : short + s.MinDamage = reader.GetShort() + // Accuracy : field : short + s.Accuracy = reader.GetShort() + // Evade : field : short + s.Evade = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterElementalStats :: The 6 elemental character stats. +type CharacterElementalStats struct { + byteSize int + + Light int + Dark int + Fire int + Water int + Earth int + Wind int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterElementalStats) ByteSize() int { + return s.byteSize +} + +func (s *CharacterElementalStats) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Light : field : short + if err = writer.AddShort(s.Light); err != nil { + return + } + // Dark : field : short + if err = writer.AddShort(s.Dark); err != nil { + return + } + // Fire : field : short + if err = writer.AddShort(s.Fire); err != nil { + return + } + // Water : field : short + if err = writer.AddShort(s.Water); err != nil { + return + } + // Earth : field : short + if err = writer.AddShort(s.Earth); err != nil { + return + } + // Wind : field : short + if err = writer.AddShort(s.Wind); err != nil { + return + } + return +} + +func (s *CharacterElementalStats) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Light : field : short + s.Light = reader.GetShort() + // Dark : field : short + s.Dark = reader.GetShort() + // Fire : field : short + s.Fire = reader.GetShort() + // Water : field : short + s.Water = reader.GetShort() + // Earth : field : short + s.Earth = reader.GetShort() + // Wind : field : short + s.Wind = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterStatsReset :: Character stats data. Sent when resetting stats and skills at a skill master NPC. +type CharacterStatsReset struct { + byteSize int + + StatPoints int + SkillPoints int + Hp int + MaxHp int + Tp int + MaxTp int + MaxSp int + Base CharacterBaseStats + Secondary CharacterSecondaryStats +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterStatsReset) ByteSize() int { + return s.byteSize +} + +func (s *CharacterStatsReset) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + // Base : field : CharacterBaseStats + if err = s.Base.Serialize(writer); err != nil { + return + } + // Secondary : field : CharacterSecondaryStats + if err = s.Secondary.Serialize(writer); err != nil { + return + } + return +} + +func (s *CharacterStatsReset) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + // Base : field : CharacterBaseStats + if err = s.Base.Deserialize(reader); err != nil { + return + } + // Secondary : field : CharacterSecondaryStats + if err = s.Secondary.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterStatsWelcome :: Character stats data. Sent upon selecting a character and entering the game. +type CharacterStatsWelcome struct { + byteSize int + + Hp int + MaxHp int + Tp int + MaxTp int + MaxSp int + StatPoints int + SkillPoints int + Karma int + Secondary CharacterSecondaryStats + Base CharacterBaseStatsWelcome +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterStatsWelcome) ByteSize() int { + return s.byteSize +} + +func (s *CharacterStatsWelcome) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // Karma : field : short + if err = writer.AddShort(s.Karma); err != nil { + return + } + // Secondary : field : CharacterSecondaryStats + if err = s.Secondary.Serialize(writer); err != nil { + return + } + // Base : field : CharacterBaseStatsWelcome + if err = s.Base.Serialize(writer); err != nil { + return + } + return +} + +func (s *CharacterStatsWelcome) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // Karma : field : short + s.Karma = reader.GetShort() + // Secondary : field : CharacterSecondaryStats + if err = s.Secondary.Deserialize(reader); err != nil { + return + } + // Base : field : CharacterBaseStatsWelcome + if err = s.Base.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterStatsUpdate :: Character stats data. Sent when stats are updated. +type CharacterStatsUpdate struct { + byteSize int + + BaseStats CharacterBaseStats + MaxHp int + MaxTp int + MaxSp int + MaxWeight int + SecondaryStats CharacterSecondaryStats +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterStatsUpdate) ByteSize() int { + return s.byteSize +} + +func (s *CharacterStatsUpdate) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Serialize(writer); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + // MaxWeight : field : short + if err = writer.AddShort(s.MaxWeight); err != nil { + return + } + // SecondaryStats : field : CharacterSecondaryStats + if err = s.SecondaryStats.Serialize(writer); err != nil { + return + } + return +} + +func (s *CharacterStatsUpdate) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Deserialize(reader); err != nil { + return + } + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + // MaxWeight : field : short + s.MaxWeight = reader.GetShort() + // SecondaryStats : field : CharacterSecondaryStats + if err = s.SecondaryStats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterStatsInfoLookup :: Character stats data. Sent with character info lookups. +type CharacterStatsInfoLookup struct { + byteSize int + + Hp int + MaxHp int + Tp int + MaxTp int + BaseStats CharacterBaseStats + SecondaryStats CharacterSecondaryStatsInfoLookup + ElementalStats CharacterElementalStats +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterStatsInfoLookup) ByteSize() int { + return s.byteSize +} + +func (s *CharacterStatsInfoLookup) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Serialize(writer); err != nil { + return + } + // SecondaryStats : field : CharacterSecondaryStatsInfoLookup + if err = s.SecondaryStats.Serialize(writer); err != nil { + return + } + // ElementalStats : field : CharacterElementalStats + if err = s.ElementalStats.Serialize(writer); err != nil { + return + } + return +} + +func (s *CharacterStatsInfoLookup) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Hp : field : short + s.Hp = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Deserialize(reader); err != nil { + return + } + // SecondaryStats : field : CharacterSecondaryStatsInfoLookup + if err = s.SecondaryStats.Deserialize(reader); err != nil { + return + } + // ElementalStats : field : CharacterElementalStats + if err = s.ElementalStats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterStatsEquipmentChange :: Character stats data. Sent when an item is equipped or unequipped. +type CharacterStatsEquipmentChange struct { + byteSize int + + MaxHp int + MaxTp int + BaseStats CharacterBaseStats + SecondaryStats CharacterSecondaryStats +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterStatsEquipmentChange) ByteSize() int { + return s.byteSize +} + +func (s *CharacterStatsEquipmentChange) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Serialize(writer); err != nil { + return + } + // SecondaryStats : field : CharacterSecondaryStats + if err = s.SecondaryStats.Serialize(writer); err != nil { + return + } + return +} + +func (s *CharacterStatsEquipmentChange) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // BaseStats : field : CharacterBaseStats + if err = s.BaseStats.Deserialize(reader); err != nil { + return + } + // SecondaryStats : field : CharacterSecondaryStats + if err = s.SecondaryStats.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SkillLearn :: A skill that can be learned from a skill master NPC. +type SkillLearn struct { + byteSize int + + Id int + LevelRequirement int + ClassRequirement int + Cost int + SkillRequirements []int + StatRequirements CharacterBaseStats +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SkillLearn) ByteSize() int { + return s.byteSize +} + +func (s *SkillLearn) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // LevelRequirement : field : char + if err = writer.AddChar(s.LevelRequirement); err != nil { + return + } + // ClassRequirement : field : char + if err = writer.AddChar(s.ClassRequirement); err != nil { + return + } + // Cost : field : int + if err = writer.AddInt(s.Cost); err != nil { + return + } + // SkillRequirements : array : short + for ndx := 0; ndx < 4; ndx++ { + if len(s.SkillRequirements) != 4 { + err = fmt.Errorf("expected SkillRequirements with length 4, got %d", len(s.SkillRequirements)) + return + } + + if err = writer.AddShort(s.SkillRequirements[ndx]); err != nil { + return + } + } + + // StatRequirements : field : CharacterBaseStats + if err = s.StatRequirements.Serialize(writer); err != nil { + return + } + return +} + +func (s *SkillLearn) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Id : field : short + s.Id = reader.GetShort() + // LevelRequirement : field : char + s.LevelRequirement = reader.GetChar() + // ClassRequirement : field : char + s.ClassRequirement = reader.GetChar() + // Cost : field : int + s.Cost = reader.GetInt() + // SkillRequirements : array : short + for ndx := 0; ndx < 4; ndx++ { + s.SkillRequirements = append(s.SkillRequirements, 0) + s.SkillRequirements[ndx] = reader.GetShort() + } + + // StatRequirements : field : CharacterBaseStats + if err = s.StatRequirements.Deserialize(reader); err != nil { + return + } + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// BoardPostListing :: An entry in the list of town board posts. +type BoardPostListing struct { + byteSize int + + PostId int + Author string + Subject string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *BoardPostListing) ByteSize() int { + return s.byteSize +} + +func (s *BoardPostListing) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PostId : field : short + if err = writer.AddShort(s.PostId); err != nil { + return + } + writer.AddByte(255) + // Author : field : string + if err = writer.AddString(s.Author); err != nil { + return + } + writer.AddByte(255) + // Subject : field : string + if err = writer.AddString(s.Subject); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *BoardPostListing) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PostId : field : short + s.PostId = reader.GetShort() + if err = reader.NextChunk(); err != nil { + return + } + // Author : field : string + if s.Author, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Subject : field : string + if s.Subject, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharacterDetails :: Information displayed on the paperdoll and book. +type CharacterDetails struct { + byteSize int + + Name string + Home string + Partner string + Title string + Guild string + GuildRank string + PlayerId int + ClassId int + Gender protocol.Gender + Admin protocol.AdminLevel +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharacterDetails) ByteSize() int { + return s.byteSize +} + +func (s *CharacterDetails) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Home : field : string + if err = writer.AddString(s.Home); err != nil { + return + } + writer.AddByte(255) + // Partner : field : string + if err = writer.AddString(s.Partner); err != nil { + return + } + writer.AddByte(255) + // Title : field : string + if err = writer.AddString(s.Title); err != nil { + return + } + writer.AddByte(255) + // Guild : field : string + if err = writer.AddString(s.Guild); err != nil { + return + } + writer.AddByte(255) + // GuildRank : field : string + if err = writer.AddString(s.GuildRank); err != nil { + return + } + writer.AddByte(255) + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // ClassId : field : char + if err = writer.AddChar(s.ClassId); err != nil { + return + } + // Gender : field : Gender + if err = writer.AddChar(int(s.Gender)); err != nil { + return + } + // Admin : field : AdminLevel + if err = writer.AddChar(int(s.Admin)); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *CharacterDetails) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Home : field : string + if s.Home, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Partner : field : string + if s.Partner, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Title : field : string + if s.Title, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Guild : field : string + if s.Guild, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // GuildRank : field : string + if s.GuildRank, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // ClassId : field : char + s.ClassId = reader.GetChar() + // Gender : field : Gender + s.Gender = protocol.Gender(reader.GetChar()) + // Admin : field : AdminLevel + s.Admin = protocol.AdminLevel(reader.GetChar()) + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyMember :: A member of the player's party. +type PartyMember struct { + byteSize int + + PlayerId int + Leader bool + Level int + HpPercentage int + Name string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyMember) ByteSize() int { + return s.byteSize +} + +func (s *PartyMember) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Leader : field : bool + if s.Leader { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + return +} + +func (s *PartyMember) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Leader : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.Leader = true + } else { + s.Leader = false + } + // Level : field : char + s.Level = reader.GetChar() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PartyExpShare :: EXP gain for a member of the player's party. +type PartyExpShare struct { + byteSize int + + PlayerId int + Experience int + LevelUp int // A value greater than 0 is "new level" and indicates the player leveled up. +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PartyExpShare) ByteSize() int { + return s.byteSize +} + +func (s *PartyExpShare) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Experience : field : int + if err = writer.AddInt(s.Experience); err != nil { + return + } + // LevelUp : field : char + if err = writer.AddChar(s.LevelUp); err != nil { + return + } + return +} + +func (s *PartyExpShare) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Experience : field : int + s.Experience = reader.GetInt() + // LevelUp : field : char + s.LevelUp = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildStaff :: Information about a guild staff member (recruiter or leader). +type GuildStaff struct { + byteSize int + + Rank int + Name string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildStaff) ByteSize() int { + return s.byteSize +} + +func (s *GuildStaff) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Rank : field : char + if err = writer.AddChar(s.Rank); err != nil { + return + } + writer.AddByte(255) + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *GuildStaff) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Rank : field : char + s.Rank = reader.GetChar() + if err = reader.NextChunk(); err != nil { + return + } + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GuildMember :: Information about a guild member. +type GuildMember struct { + byteSize int + + Rank int + Name string + RankName string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GuildMember) ByteSize() int { + return s.byteSize +} + +func (s *GuildMember) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Rank : field : char + if err = writer.AddChar(s.Rank); err != nil { + return + } + writer.AddByte(255) + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // RankName : field : string + if err = writer.AddString(s.RankName); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *GuildMember) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Rank : field : char + s.Rank = reader.GetChar() + if err = reader.NextChunk(); err != nil { + return + } + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // RankName : field : string + if s.RankName, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GroupHealTargetPlayer :: Nearby player hit by a group heal spell. +type GroupHealTargetPlayer struct { + byteSize int + + PlayerId int + HpPercentage int + Hp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GroupHealTargetPlayer) ByteSize() int { + return s.byteSize +} + +func (s *GroupHealTargetPlayer) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + return +} + +func (s *GroupHealTargetPlayer) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Hp : field : short + s.Hp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TradeItemData :: Trade window item data. +type TradeItemData struct { + byteSize int + + PartnerPlayerId int + PartnerItems []net.Item + YourPlayerId int + YourItems []net.Item +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TradeItemData) ByteSize() int { + return s.byteSize +} + +func (s *TradeItemData) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PartnerPlayerId : field : short + if err = writer.AddShort(s.PartnerPlayerId); err != nil { + return + } + // PartnerItems : array : Item + for ndx := 0; ndx < len(s.PartnerItems); ndx++ { + if err = s.PartnerItems[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + // YourPlayerId : field : short + if err = writer.AddShort(s.YourPlayerId); err != nil { + return + } + // YourItems : array : Item + for ndx := 0; ndx < len(s.YourItems); ndx++ { + if err = s.YourItems[ndx].Serialize(writer); err != nil { + return + } + } + + writer.AddByte(255) + writer.SanitizeStrings = false + return +} + +func (s *TradeItemData) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PartnerPlayerId : field : short + s.PartnerPlayerId = reader.GetShort() + // PartnerItems : array : Item + PartnerItemsRemaining := reader.Remaining() + for ndx := 0; ndx < PartnerItemsRemaining/6; ndx++ { + s.PartnerItems = append(s.PartnerItems, net.Item{}) + if err = s.PartnerItems[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + // YourPlayerId : field : short + s.YourPlayerId = reader.GetShort() + // YourItems : array : Item + YourItemsRemaining := reader.Remaining() + for ndx := 0; ndx < YourItemsRemaining/6; ndx++ { + s.YourItems = append(s.YourItems, net.Item{}) + if err = s.YourItems[ndx].Deserialize(reader); err != nil { + return + } + } + + if err = reader.NextChunk(); err != nil { + return + } + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcKilledData :: Information about an NPC that has been killed. +type NpcKilledData struct { + byteSize int + + KillerId int + KillerDirection protocol.Direction + NpcIndex int + DropIndex int + DropId int + DropCoords protocol.Coords + DropAmount int + Damage int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcKilledData) ByteSize() int { + return s.byteSize +} + +func (s *NpcKilledData) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // KillerId : field : short + if err = writer.AddShort(s.KillerId); err != nil { + return + } + // KillerDirection : field : Direction + if err = writer.AddChar(int(s.KillerDirection)); err != nil { + return + } + // NpcIndex : field : short + if err = writer.AddShort(s.NpcIndex); err != nil { + return + } + // DropIndex : field : short + if err = writer.AddShort(s.DropIndex); err != nil { + return + } + // DropId : field : short + if err = writer.AddShort(s.DropId); err != nil { + return + } + // DropCoords : field : Coords + if err = s.DropCoords.Serialize(writer); err != nil { + return + } + // DropAmount : field : int + if err = writer.AddInt(s.DropAmount); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + return +} + +func (s *NpcKilledData) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // KillerId : field : short + s.KillerId = reader.GetShort() + // KillerDirection : field : Direction + s.KillerDirection = protocol.Direction(reader.GetChar()) + // NpcIndex : field : short + s.NpcIndex = reader.GetShort() + // DropIndex : field : short + s.DropIndex = reader.GetShort() + // DropId : field : short + s.DropId = reader.GetShort() + // DropCoords : field : Coords + if err = s.DropCoords.Deserialize(reader); err != nil { + return + } + // DropAmount : field : int + s.DropAmount = reader.GetInt() + // Damage : field : three + s.Damage = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// LevelUpStats :: Level and stat updates. +type LevelUpStats struct { + byteSize int + + Level int + StatPoints int + SkillPoints int + MaxHp int + MaxTp int + MaxSp int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *LevelUpStats) ByteSize() int { + return s.byteSize +} + +func (s *LevelUpStats) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // StatPoints : field : short + if err = writer.AddShort(s.StatPoints); err != nil { + return + } + // SkillPoints : field : short + if err = writer.AddShort(s.SkillPoints); err != nil { + return + } + // MaxHp : field : short + if err = writer.AddShort(s.MaxHp); err != nil { + return + } + // MaxTp : field : short + if err = writer.AddShort(s.MaxTp); err != nil { + return + } + // MaxSp : field : short + if err = writer.AddShort(s.MaxSp); err != nil { + return + } + return +} + +func (s *LevelUpStats) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Level : field : char + s.Level = reader.GetChar() + // StatPoints : field : short + s.StatPoints = reader.GetShort() + // SkillPoints : field : short + s.SkillPoints = reader.GetShort() + // MaxHp : field : short + s.MaxHp = reader.GetShort() + // MaxTp : field : short + s.MaxTp = reader.GetShort() + // MaxSp : field : short + s.MaxSp = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcUpdatePosition :: An NPC walking. +type NpcUpdatePosition struct { + byteSize int + + NpcIndex int + Coords protocol.Coords + Direction protocol.Direction +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcUpdatePosition) ByteSize() int { + return s.byteSize +} + +func (s *NpcUpdatePosition) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : char + if err = writer.AddChar(s.NpcIndex); err != nil { + return + } + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + return +} + +func (s *NpcUpdatePosition) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : char + s.NpcIndex = reader.GetChar() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcUpdateAttack :: An NPC attacking. +type NpcUpdateAttack struct { + byteSize int + + NpcIndex int + Killed PlayerKilledState + Direction protocol.Direction + PlayerId int + Damage int + HpPercentage int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcUpdateAttack) ByteSize() int { + return s.byteSize +} + +func (s *NpcUpdateAttack) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : char + if err = writer.AddChar(s.NpcIndex); err != nil { + return + } + // Killed : field : PlayerKilledState + if err = writer.AddChar(int(s.Killed)); err != nil { + return + } + // Direction : field : Direction + if err = writer.AddChar(int(s.Direction)); err != nil { + return + } + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // Damage : field : three + if err = writer.AddThree(s.Damage); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + return +} + +func (s *NpcUpdateAttack) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : char + s.NpcIndex = reader.GetChar() + // Killed : field : PlayerKilledState + s.Killed = PlayerKilledState(reader.GetChar()) + // Direction : field : Direction + s.Direction = protocol.Direction(reader.GetChar()) + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // Damage : field : three + s.Damage = reader.GetThree() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// NpcUpdateChat :: An NPC talking. +type NpcUpdateChat struct { + byteSize int + + NpcIndex int + Message string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *NpcUpdateChat) ByteSize() int { + return s.byteSize +} + +func (s *NpcUpdateChat) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcIndex : field : char + if err = writer.AddChar(s.NpcIndex); err != nil { + return + } + // MessageLength : length : char + if err = writer.AddChar(len(s.Message)); err != nil { + return + } + // Message : field : string + if err = writer.AddFixedString(s.Message, len(s.Message)); err != nil { + return + } + return +} + +func (s *NpcUpdateChat) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcIndex : field : char + s.NpcIndex = reader.GetChar() + // MessageLength : length : char + messageLength := reader.GetChar() + // Message : field : string + if s.Message, err = reader.GetFixedString(messageLength); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// QuestProgressEntry :: An entry in the Quest Progress window. +type QuestProgressEntry struct { + byteSize int + + Name string + Description string + Icon QuestRequirementIcon + Progress int + Target int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *QuestProgressEntry) ByteSize() int { + return s.byteSize +} + +func (s *QuestProgressEntry) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // Name : field : string + if err = writer.AddString(s.Name); err != nil { + return + } + writer.AddByte(255) + // Description : field : string + if err = writer.AddString(s.Description); err != nil { + return + } + writer.AddByte(255) + // Icon : field : QuestRequirementIcon + if err = writer.AddShort(int(s.Icon)); err != nil { + return + } + // Progress : field : short + if err = writer.AddShort(s.Progress); err != nil { + return + } + // Target : field : short + if err = writer.AddShort(s.Target); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *QuestProgressEntry) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // Name : field : string + if s.Name, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Description : field : string + if s.Description, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Icon : field : QuestRequirementIcon + s.Icon = QuestRequirementIcon(reader.GetShort()) + // Progress : field : short + s.Progress = reader.GetShort() + // Target : field : short + s.Target = reader.GetShort() + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DialogQuestEntry :: An entry in the quest switcher. +type DialogQuestEntry struct { + byteSize int + + QuestId int + QuestName string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DialogQuestEntry) ByteSize() int { + return s.byteSize +} + +func (s *DialogQuestEntry) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // QuestId : field : short + if err = writer.AddShort(s.QuestId); err != nil { + return + } + // QuestName : field : string + if err = writer.AddString(s.QuestName); err != nil { + return + } + return +} + +func (s *DialogQuestEntry) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // QuestId : field : short + s.QuestId = reader.GetShort() + // QuestName : field : string + if s.QuestName, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DialogEntry :: An entry in a quest dialog. +type DialogEntry struct { + byteSize int + + EntryType DialogEntryType + EntryTypeData EntryTypeData + Line string +} + +type EntryTypeData interface { + protocol.EoData +} + +type EntryTypeDataLink struct { + byteSize int + + LinkId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EntryTypeDataLink) ByteSize() int { + return s.byteSize +} + +func (s *EntryTypeDataLink) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // LinkId : field : short + if err = writer.AddShort(s.LinkId); err != nil { + return + } + return +} + +func (s *EntryTypeDataLink) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // LinkId : field : short + s.LinkId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DialogEntry) ByteSize() int { + return s.byteSize +} + +func (s *DialogEntry) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EntryType : field : DialogEntryType + if err = writer.AddShort(int(s.EntryType)); err != nil { + return + } + switch s.EntryType { + case DialogEntry_Link: + switch s.EntryTypeData.(type) { + case *EntryTypeDataLink: + if err = s.EntryTypeData.Serialize(writer); err != nil { + return + } + default: + err = fmt.Errorf("invalid switch struct type for switch value %d", s.EntryType) + return + } + } + // Line : field : string + if err = writer.AddString(s.Line); err != nil { + return + } + return +} + +func (s *DialogEntry) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EntryType : field : DialogEntryType + s.EntryType = DialogEntryType(reader.GetShort()) + switch s.EntryType { + case DialogEntry_Link: + s.EntryTypeData = &EntryTypeDataLink{} + if err = s.EntryTypeData.Deserialize(reader); err != nil { + return + } + } + // Line : field : string + if s.Line, err = reader.GetString(); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// MapDrainDamageOther :: Another player taking damage from a map HP drain. +type MapDrainDamageOther struct { + byteSize int + + PlayerId int + HpPercentage int + Damage int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *MapDrainDamageOther) ByteSize() int { + return s.byteSize +} + +func (s *MapDrainDamageOther) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // HpPercentage : field : char + if err = writer.AddChar(s.HpPercentage); err != nil { + return + } + // Damage : field : short + if err = writer.AddShort(s.Damage); err != nil { + return + } + return +} + +func (s *MapDrainDamageOther) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // HpPercentage : field : char + s.HpPercentage = reader.GetChar() + // Damage : field : short + s.Damage = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// GlobalBackfillMessage :: A backfilled global chat message. +type GlobalBackfillMessage struct { + byteSize int + + PlayerName string + Message string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *GlobalBackfillMessage) ByteSize() int { + return s.byteSize +} + +func (s *GlobalBackfillMessage) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + writer.SanitizeStrings = true + // PlayerName : field : string + if err = writer.AddString(s.PlayerName); err != nil { + return + } + writer.AddByte(255) + // Message : field : string + if err = writer.AddString(s.Message); err != nil { + return + } + writer.SanitizeStrings = false + return +} + +func (s *GlobalBackfillMessage) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + reader.SetIsChunked(true) + // PlayerName : field : string + if s.PlayerName, err = reader.GetString(); err != nil { + return + } + + if err = reader.NextChunk(); err != nil { + return + } + // Message : field : string + if s.Message, err = reader.GetString(); err != nil { + return + } + + reader.SetIsChunked(false) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// PlayerEffect :: An effect playing on a player. +type PlayerEffect struct { + byteSize int + + PlayerId int + EffectId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *PlayerEffect) ByteSize() int { + return s.byteSize +} + +func (s *PlayerEffect) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // PlayerId : field : short + if err = writer.AddShort(s.PlayerId); err != nil { + return + } + // EffectId : field : three + if err = writer.AddThree(s.EffectId); err != nil { + return + } + return +} + +func (s *PlayerEffect) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // PlayerId : field : short + s.PlayerId = reader.GetShort() + // EffectId : field : three + s.EffectId = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TileEffect :: An effect playing on a tile. +type TileEffect struct { + byteSize int + + Coords protocol.Coords + EffectId int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TileEffect) ByteSize() int { + return s.byteSize +} + +func (s *TileEffect) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Coords : field : Coords + if err = s.Coords.Serialize(writer); err != nil { + return + } + // EffectId : field : short + if err = writer.AddShort(s.EffectId); err != nil { + return + } + return +} + +func (s *TileEffect) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Coords : field : Coords + if err = s.Coords.Deserialize(reader); err != nil { + return + } + // EffectId : field : short + s.EffectId = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/net/structs_generated.go b/v3/protocol/net/structs_generated.go new file mode 100644 index 0000000..537c55f --- /dev/null +++ b/v3/protocol/net/structs_generated.go @@ -0,0 +1,262 @@ +package net + +import "github.com/ethanmoffat/eolib-go/v3/data" + +// Version :: Client version. +type Version struct { + byteSize int + + Major int + Minor int + Patch int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Version) ByteSize() int { + return s.byteSize +} + +func (s *Version) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Major : field : char + if err = writer.AddChar(s.Major); err != nil { + return + } + // Minor : field : char + if err = writer.AddChar(s.Minor); err != nil { + return + } + // Patch : field : char + if err = writer.AddChar(s.Patch); err != nil { + return + } + return +} + +func (s *Version) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Major : field : char + s.Major = reader.GetChar() + // Minor : field : char + s.Minor = reader.GetChar() + // Patch : field : char + s.Patch = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Weight :: Current carry weight and maximum carry capacity of a player. +type Weight struct { + byteSize int + + Current int + Max int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Weight) ByteSize() int { + return s.byteSize +} + +func (s *Weight) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Current : field : char + if err = writer.AddChar(s.Current); err != nil { + return + } + // Max : field : char + if err = writer.AddChar(s.Max); err != nil { + return + } + return +} + +func (s *Weight) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Current : field : char + s.Current = reader.GetChar() + // Max : field : char + s.Max = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Item :: An item reference with a 4-byte amount. +type Item struct { + byteSize int + + Id int + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Item) ByteSize() int { + return s.byteSize +} + +func (s *Item) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Amount : field : int + if err = writer.AddInt(s.Amount); err != nil { + return + } + return +} + +func (s *Item) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Id : field : short + s.Id = reader.GetShort() + // Amount : field : int + s.Amount = reader.GetInt() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ThreeItem :: An item reference with a 3-byte amount. Used for shops, lockers, and various item transfers. +type ThreeItem struct { + byteSize int + + Id int + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ThreeItem) ByteSize() int { + return s.byteSize +} + +func (s *ThreeItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Amount : field : three + if err = writer.AddThree(s.Amount); err != nil { + return + } + return +} + +func (s *ThreeItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Id : field : short + s.Id = reader.GetShort() + // Amount : field : three + s.Amount = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// CharItem :: An item reference with a 1-byte amount. Used for craft ingredients. +type CharItem struct { + byteSize int + + Id int + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *CharItem) ByteSize() int { + return s.byteSize +} + +func (s *CharItem) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Amount : field : char + if err = writer.AddChar(s.Amount); err != nil { + return + } + return +} + +func (s *CharItem) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Id : field : short + s.Id = reader.GetShort() + // Amount : field : char + s.Amount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Spell :: A spell known by the player. +type Spell struct { + byteSize int + + Id int + Level int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Spell) ByteSize() int { + return s.byteSize +} + +func (s *Spell) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // Id : field : short + if err = writer.AddShort(s.Id); err != nil { + return + } + // Level : field : short + if err = writer.AddShort(s.Level); err != nil { + return + } + return +} + +func (s *Spell) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // Id : field : short + s.Id = reader.GetShort() + // Level : field : short + s.Level = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/package.go b/v3/protocol/package.go new file mode 100644 index 0000000..a92af5e --- /dev/null +++ b/v3/protocol/package.go @@ -0,0 +1,2 @@ +// Package protocol provides EO protocol data structures. Types and functions in this package are primarily generated from the eo-protocol XML specification. +package protocol diff --git a/v3/protocol/packets_generated.go b/v3/protocol/packets_generated.go new file mode 100644 index 0000000..2d0eaff --- /dev/null +++ b/v3/protocol/packets_generated.go @@ -0,0 +1 @@ +package protocol diff --git a/v3/protocol/pub/enums_generated.go b/v3/protocol/pub/enums_generated.go new file mode 100644 index 0000000..aca6e86 --- /dev/null +++ b/v3/protocol/pub/enums_generated.go @@ -0,0 +1,386 @@ +package pub + +import "fmt" + +type Element int + +const ( + Element_None Element = iota + Element_Light + Element_Dark + Element_Earth + Element_Wind + Element_Water + Element_Fire +) + +// String converts a Element value into its string representation +func (e Element) String() (string, error) { + switch e { + case Element_None: + return "None", nil + case Element_Light: + return "Light", nil + case Element_Dark: + return "Dark", nil + case Element_Earth: + return "Earth", nil + case Element_Wind: + return "Wind", nil + case Element_Water: + return "Water", nil + case Element_Fire: + return "Fire", nil + default: + return "", fmt.Errorf("could not convert value %d of type Element to string", e) + } +} + +type ItemType int + +const ( + Item_General ItemType = iota + Item_Reserved1 + Item_Currency + Item_Heal + Item_Teleport + Item_Reserved5 + Item_ExpReward + Item_Reserved7 + Item_Reserved8 + Item_Key + Item_Weapon + Item_Shield + Item_Armor + Item_Hat + Item_Boots + Item_Gloves + Item_Accessory + Item_Belt + Item_Necklace + Item_Ring + Item_Armlet + Item_Bracer + Item_Alcohol + Item_EffectPotion + Item_HairDye + Item_CureCurse + Item_Reserved26 + Item_Reserved27 + Item_Reserved28 + Item_Reserved29 +) + +// String converts a ItemType value into its string representation +func (e ItemType) String() (string, error) { + switch e { + case Item_General: + return "General", nil + case Item_Reserved1: + return "Reserved1", nil + case Item_Currency: + return "Currency", nil + case Item_Heal: + return "Heal", nil + case Item_Teleport: + return "Teleport", nil + case Item_Reserved5: + return "Reserved5", nil + case Item_ExpReward: + return "ExpReward", nil + case Item_Reserved7: + return "Reserved7", nil + case Item_Reserved8: + return "Reserved8", nil + case Item_Key: + return "Key", nil + case Item_Weapon: + return "Weapon", nil + case Item_Shield: + return "Shield", nil + case Item_Armor: + return "Armor", nil + case Item_Hat: + return "Hat", nil + case Item_Boots: + return "Boots", nil + case Item_Gloves: + return "Gloves", nil + case Item_Accessory: + return "Accessory", nil + case Item_Belt: + return "Belt", nil + case Item_Necklace: + return "Necklace", nil + case Item_Ring: + return "Ring", nil + case Item_Armlet: + return "Armlet", nil + case Item_Bracer: + return "Bracer", nil + case Item_Alcohol: + return "Alcohol", nil + case Item_EffectPotion: + return "EffectPotion", nil + case Item_HairDye: + return "HairDye", nil + case Item_CureCurse: + return "CureCurse", nil + case Item_Reserved26: + return "Reserved26", nil + case Item_Reserved27: + return "Reserved27", nil + case Item_Reserved28: + return "Reserved28", nil + case Item_Reserved29: + return "Reserved29", nil + default: + return "", fmt.Errorf("could not convert value %d of type ItemType to string", e) + } +} + +type ItemSubtype int + +const ( + ItemSubtype_None ItemSubtype = iota + ItemSubtype_Ranged + ItemSubtype_Arrows + ItemSubtype_Wings + ItemSubtype_Reserved4 +) + +// String converts a ItemSubtype value into its string representation +func (e ItemSubtype) String() (string, error) { + switch e { + case ItemSubtype_None: + return "None", nil + case ItemSubtype_Ranged: + return "Ranged", nil + case ItemSubtype_Arrows: + return "Arrows", nil + case ItemSubtype_Wings: + return "Wings", nil + case ItemSubtype_Reserved4: + return "Reserved4", nil + default: + return "", fmt.Errorf("could not convert value %d of type ItemSubtype to string", e) + } +} + +type ItemSpecial int + +const ( + ItemSpecial_Normal ItemSpecial = iota + ItemSpecial_Rare + ItemSpecial_Legendary + ItemSpecial_Unique + ItemSpecial_Lore + ItemSpecial_Cursed +) + +// String converts a ItemSpecial value into its string representation +func (e ItemSpecial) String() (string, error) { + switch e { + case ItemSpecial_Normal: + return "Normal", nil + case ItemSpecial_Rare: + return "Rare", nil + case ItemSpecial_Legendary: + return "Legendary", nil + case ItemSpecial_Unique: + return "Unique", nil + case ItemSpecial_Lore: + return "Lore", nil + case ItemSpecial_Cursed: + return "Cursed", nil + default: + return "", fmt.Errorf("could not convert value %d of type ItemSpecial to string", e) + } +} + +// ItemSize :: Size of an item in the inventory. +type ItemSize int + +const ( + ItemSize_Size1x1 ItemSize = iota + ItemSize_Size1x2 + ItemSize_Size1x3 + ItemSize_Size1x4 + ItemSize_Size2x1 + ItemSize_Size2x2 + ItemSize_Size2x3 + ItemSize_Size2x4 +) + +// String converts a ItemSize value into its string representation +func (e ItemSize) String() (string, error) { + switch e { + case ItemSize_Size1x1: + return "Size1x1", nil + case ItemSize_Size1x2: + return "Size1x2", nil + case ItemSize_Size1x3: + return "Size1x3", nil + case ItemSize_Size1x4: + return "Size1x4", nil + case ItemSize_Size2x1: + return "Size2x1", nil + case ItemSize_Size2x2: + return "Size2x2", nil + case ItemSize_Size2x3: + return "Size2x3", nil + case ItemSize_Size2x4: + return "Size2x4", nil + default: + return "", fmt.Errorf("could not convert value %d of type ItemSize to string", e) + } +} + +type NpcType int + +const ( + Npc_Friendly NpcType = iota + Npc_Passive + Npc_Aggressive + Npc_Reserved3 + Npc_Reserved4 + Npc_Reserved5 + Npc_Shop + Npc_Inn + Npc_Reserved8 + Npc_Bank + Npc_Barber + Npc_Guild + Npc_Priest + Npc_Lawyer + Npc_Trainer + Npc_Quest +) + +// String converts a NpcType value into its string representation +func (e NpcType) String() (string, error) { + switch e { + case Npc_Friendly: + return "Friendly", nil + case Npc_Passive: + return "Passive", nil + case Npc_Aggressive: + return "Aggressive", nil + case Npc_Reserved3: + return "Reserved3", nil + case Npc_Reserved4: + return "Reserved4", nil + case Npc_Reserved5: + return "Reserved5", nil + case Npc_Shop: + return "Shop", nil + case Npc_Inn: + return "Inn", nil + case Npc_Reserved8: + return "Reserved8", nil + case Npc_Bank: + return "Bank", nil + case Npc_Barber: + return "Barber", nil + case Npc_Guild: + return "Guild", nil + case Npc_Priest: + return "Priest", nil + case Npc_Lawyer: + return "Lawyer", nil + case Npc_Trainer: + return "Trainer", nil + case Npc_Quest: + return "Quest", nil + default: + return "", fmt.Errorf("could not convert value %d of type NpcType to string", e) + } +} + +type SkillNature int + +const ( + SkillNature_Spell SkillNature = iota + SkillNature_Skill +) + +// String converts a SkillNature value into its string representation +func (e SkillNature) String() (string, error) { + switch e { + case SkillNature_Spell: + return "Spell", nil + case SkillNature_Skill: + return "Skill", nil + default: + return "", fmt.Errorf("could not convert value %d of type SkillNature to string", e) + } +} + +type SkillType int + +const ( + Skill_Heal SkillType = iota + Skill_Attack + Skill_Bard +) + +// String converts a SkillType value into its string representation +func (e SkillType) String() (string, error) { + switch e { + case Skill_Heal: + return "Heal", nil + case Skill_Attack: + return "Attack", nil + case Skill_Bard: + return "Bard", nil + default: + return "", fmt.Errorf("could not convert value %d of type SkillType to string", e) + } +} + +type SkillTargetRestrict int + +const ( + SkillTargetRestrict_Npc SkillTargetRestrict = iota + SkillTargetRestrict_Friendly + SkillTargetRestrict_Opponent +) + +// String converts a SkillTargetRestrict value into its string representation +func (e SkillTargetRestrict) String() (string, error) { + switch e { + case SkillTargetRestrict_Npc: + return "Npc", nil + case SkillTargetRestrict_Friendly: + return "Friendly", nil + case SkillTargetRestrict_Opponent: + return "Opponent", nil + default: + return "", fmt.Errorf("could not convert value %d of type SkillTargetRestrict to string", e) + } +} + +type SkillTargetType int + +const ( + SkillTarget_Normal SkillTargetType = iota + SkillTarget_Self + SkillTarget_Reserved2 + SkillTarget_Group +) + +// String converts a SkillTargetType value into its string representation +func (e SkillTargetType) String() (string, error) { + switch e { + case SkillTarget_Normal: + return "Normal", nil + case SkillTarget_Self: + return "Self", nil + case SkillTarget_Reserved2: + return "Reserved2", nil + case SkillTarget_Group: + return "Group", nil + default: + return "", fmt.Errorf("could not convert value %d of type SkillTargetType to string", e) + } +} diff --git a/v3/protocol/pub/package.go b/v3/protocol/pub/package.go new file mode 100644 index 0000000..7208937 --- /dev/null +++ b/v3/protocol/pub/package.go @@ -0,0 +1,2 @@ +// Package pub provides EO pub file data structures. Types and functions in this package are primarily generated from the eo-protocol XML specification. These structures are generally relevant to both EO clients and EO servers. +package pub diff --git a/v3/protocol/pub/packets_generated.go b/v3/protocol/pub/packets_generated.go new file mode 100644 index 0000000..e791779 --- /dev/null +++ b/v3/protocol/pub/packets_generated.go @@ -0,0 +1 @@ +package pub diff --git a/v3/protocol/pub/server/enums_generated.go b/v3/protocol/pub/server/enums_generated.go new file mode 100644 index 0000000..7b53336 --- /dev/null +++ b/v3/protocol/pub/server/enums_generated.go @@ -0,0 +1 @@ +package serverpub diff --git a/v3/protocol/pub/server/package.go b/v3/protocol/pub/server/package.go new file mode 100644 index 0000000..2d7e75c --- /dev/null +++ b/v3/protocol/pub/server/package.go @@ -0,0 +1,2 @@ +// Package serverpub provides EO server pub file data structures. Types and functions in this package are primarily generated from the eo-protocol XML specification. These structures are generally relevant only to EO servers. +package serverpub diff --git a/v3/protocol/pub/server/structs_generated.go b/v3/protocol/pub/server/structs_generated.go new file mode 100644 index 0000000..442120f --- /dev/null +++ b/v3/protocol/pub/server/structs_generated.go @@ -0,0 +1,1180 @@ +package serverpub + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" +) + +// DropRecord :: Record of an item an NPC can drop when killed. +type DropRecord struct { + byteSize int + + ItemId int + MinAmount int + MaxAmount int + Rate int // Chance (x in 64,000) of the item being dropped. +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DropRecord) ByteSize() int { + return s.byteSize +} + +func (s *DropRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // MinAmount : field : three + if err = writer.AddThree(s.MinAmount); err != nil { + return + } + // MaxAmount : field : three + if err = writer.AddThree(s.MaxAmount); err != nil { + return + } + // Rate : field : short + if err = writer.AddShort(s.Rate); err != nil { + return + } + return +} + +func (s *DropRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // MinAmount : field : three + s.MinAmount = reader.GetThree() + // MaxAmount : field : three + s.MaxAmount = reader.GetThree() + // Rate : field : short + s.Rate = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DropNpcRecord :: Record of potential drops from an NPC. +type DropNpcRecord struct { + byteSize int + + NpcId int + Drops []DropRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DropNpcRecord) ByteSize() int { + return s.byteSize +} + +func (s *DropNpcRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcId : field : short + if err = writer.AddShort(s.NpcId); err != nil { + return + } + // DropsCount : length : short + if err = writer.AddShort(len(s.Drops)); err != nil { + return + } + // Drops : array : DropRecord + for ndx := 0; ndx < len(s.Drops); ndx++ { + if err = s.Drops[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *DropNpcRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcId : field : short + s.NpcId = reader.GetShort() + // DropsCount : length : short + dropsCount := reader.GetShort() + // Drops : array : DropRecord + for ndx := 0; ndx < dropsCount; ndx++ { + s.Drops = append(s.Drops, DropRecord{}) + if err = s.Drops[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// DropFile :: Endless Drop File. +type DropFile struct { + byteSize int + + Npcs []DropNpcRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *DropFile) ByteSize() int { + return s.byteSize +} + +func (s *DropFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EDF : field : string + if err = writer.AddFixedString("EDF", 3); err != nil { + return + } + // Npcs : array : DropNpcRecord + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *DropFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EDF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Npcs : array : DropNpcRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Npcs = append(s.Npcs, DropNpcRecord{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// InnQuestionRecord :: Record of a question and answer that the player must answer to register citizenship with an inn. +type InnQuestionRecord struct { + byteSize int + + Question string + Answer string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InnQuestionRecord) ByteSize() int { + return s.byteSize +} + +func (s *InnQuestionRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // QuestionLength : length : char + if err = writer.AddChar(len(s.Question)); err != nil { + return + } + // Question : field : string + if err = writer.AddFixedString(s.Question, len(s.Question)); err != nil { + return + } + // AnswerLength : length : char + if err = writer.AddChar(len(s.Answer)); err != nil { + return + } + // Answer : field : string + if err = writer.AddFixedString(s.Answer, len(s.Answer)); err != nil { + return + } + return +} + +func (s *InnQuestionRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // QuestionLength : length : char + questionLength := reader.GetChar() + // Question : field : string + if s.Question, err = reader.GetFixedString(questionLength); err != nil { + return + } + + // AnswerLength : length : char + answerLength := reader.GetChar() + // Answer : field : string + if s.Answer, err = reader.GetFixedString(answerLength); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// InnRecord :: Record of Inn data in an Endless Inn File. +type InnRecord struct { + byteSize int + + BehaviorId int // Behavior ID of the NPC that runs the inn. 0 for default inn. + Name string + SpawnMap int // ID of the map the player is sent to after respawning. + SpawnX int // X coordinate of the map the player is sent to after respawning. + SpawnY int // Y coordinate of the map the player is sent to after respawning. + SleepMap int // ID of the map the player is sent to after sleeping at the inn. + SleepX int // X coordinate of the map the player is sent to after sleeping at the inn. + SleepY int // Y coordinate of the map the player is sent to after sleeping at the inn. + AlternateSpawnEnabled bool // Flag for an alternate spawn point. If true, the server will use this alternate spawn. map, x, and, y based on some other condition. In the official server, this is used to respawn new characters on the noob island. until they reach a certain level. + AlternateSpawnMap int + AlternateSpawnX int + AlternateSpawnY int + Questions []InnQuestionRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InnRecord) ByteSize() int { + return s.byteSize +} + +func (s *InnRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // SpawnMap : field : short + if err = writer.AddShort(s.SpawnMap); err != nil { + return + } + // SpawnX : field : char + if err = writer.AddChar(s.SpawnX); err != nil { + return + } + // SpawnY : field : char + if err = writer.AddChar(s.SpawnY); err != nil { + return + } + // SleepMap : field : short + if err = writer.AddShort(s.SleepMap); err != nil { + return + } + // SleepX : field : char + if err = writer.AddChar(s.SleepX); err != nil { + return + } + // SleepY : field : char + if err = writer.AddChar(s.SleepY); err != nil { + return + } + // AlternateSpawnEnabled : field : bool + if s.AlternateSpawnEnabled { + err = writer.AddChar(1) + } else { + err = writer.AddChar(0) + } + if err != nil { + return + } + + // AlternateSpawnMap : field : short + if err = writer.AddShort(s.AlternateSpawnMap); err != nil { + return + } + // AlternateSpawnX : field : char + if err = writer.AddChar(s.AlternateSpawnX); err != nil { + return + } + // AlternateSpawnY : field : char + if err = writer.AddChar(s.AlternateSpawnY); err != nil { + return + } + // Questions : array : InnQuestionRecord + for ndx := 0; ndx < 3; ndx++ { + if len(s.Questions) != 3 { + err = fmt.Errorf("expected Questions with length 3, got %d", len(s.Questions)) + return + } + + if err = s.Questions[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *InnRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // SpawnMap : field : short + s.SpawnMap = reader.GetShort() + // SpawnX : field : char + s.SpawnX = reader.GetChar() + // SpawnY : field : char + s.SpawnY = reader.GetChar() + // SleepMap : field : short + s.SleepMap = reader.GetShort() + // SleepX : field : char + s.SleepX = reader.GetChar() + // SleepY : field : char + s.SleepY = reader.GetChar() + // AlternateSpawnEnabled : field : bool + if boolVal := reader.GetChar(); boolVal > 0 { + s.AlternateSpawnEnabled = true + } else { + s.AlternateSpawnEnabled = false + } + // AlternateSpawnMap : field : short + s.AlternateSpawnMap = reader.GetShort() + // AlternateSpawnX : field : char + s.AlternateSpawnX = reader.GetChar() + // AlternateSpawnY : field : char + s.AlternateSpawnY = reader.GetChar() + // Questions : array : InnQuestionRecord + for ndx := 0; ndx < 3; ndx++ { + s.Questions = append(s.Questions, InnQuestionRecord{}) + if err = s.Questions[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// InnFile :: Endless Inn File. +type InnFile struct { + byteSize int + + Inns []InnRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *InnFile) ByteSize() int { + return s.byteSize +} + +func (s *InnFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EID : field : string + if err = writer.AddFixedString("EID", 3); err != nil { + return + } + // Inns : array : InnRecord + for ndx := 0; ndx < len(s.Inns); ndx++ { + if err = s.Inns[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *InnFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EID : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Inns : array : InnRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Inns = append(s.Inns, InnRecord{}) + if err = s.Inns[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SkillMasterSkillRecord :: Record of a skill that a Skill Master NPC can teach. +type SkillMasterSkillRecord struct { + byteSize int + + SkillId int + LevelRequirement int // Level required to learn this skill. + ClassRequirement int // Class required to learn this skill. + Price int + SkillRequirements []int // IDs of skills that must be learned before a player can learn this skill. + StrRequirement int // Strength required to learn this skill. + IntRequirement int // Intelligence required to learn this skill. + WisRequirement int // Wisdom required to learn this skill. + AgiRequirement int // Agility required to learn this skill. + ConRequirement int // Constitution required to learn this skill. + ChaRequirement int // Charisma required to learn this skill. +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SkillMasterSkillRecord) ByteSize() int { + return s.byteSize +} + +func (s *SkillMasterSkillRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // SkillId : field : short + if err = writer.AddShort(s.SkillId); err != nil { + return + } + // LevelRequirement : field : char + if err = writer.AddChar(s.LevelRequirement); err != nil { + return + } + // ClassRequirement : field : char + if err = writer.AddChar(s.ClassRequirement); err != nil { + return + } + // Price : field : int + if err = writer.AddInt(s.Price); err != nil { + return + } + // SkillRequirements : array : short + for ndx := 0; ndx < 4; ndx++ { + if len(s.SkillRequirements) != 4 { + err = fmt.Errorf("expected SkillRequirements with length 4, got %d", len(s.SkillRequirements)) + return + } + + if err = writer.AddShort(s.SkillRequirements[ndx]); err != nil { + return + } + } + + // StrRequirement : field : short + if err = writer.AddShort(s.StrRequirement); err != nil { + return + } + // IntRequirement : field : short + if err = writer.AddShort(s.IntRequirement); err != nil { + return + } + // WisRequirement : field : short + if err = writer.AddShort(s.WisRequirement); err != nil { + return + } + // AgiRequirement : field : short + if err = writer.AddShort(s.AgiRequirement); err != nil { + return + } + // ConRequirement : field : short + if err = writer.AddShort(s.ConRequirement); err != nil { + return + } + // ChaRequirement : field : short + if err = writer.AddShort(s.ChaRequirement); err != nil { + return + } + return +} + +func (s *SkillMasterSkillRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // SkillId : field : short + s.SkillId = reader.GetShort() + // LevelRequirement : field : char + s.LevelRequirement = reader.GetChar() + // ClassRequirement : field : char + s.ClassRequirement = reader.GetChar() + // Price : field : int + s.Price = reader.GetInt() + // SkillRequirements : array : short + for ndx := 0; ndx < 4; ndx++ { + s.SkillRequirements = append(s.SkillRequirements, 0) + s.SkillRequirements[ndx] = reader.GetShort() + } + + // StrRequirement : field : short + s.StrRequirement = reader.GetShort() + // IntRequirement : field : short + s.IntRequirement = reader.GetShort() + // WisRequirement : field : short + s.WisRequirement = reader.GetShort() + // AgiRequirement : field : short + s.AgiRequirement = reader.GetShort() + // ConRequirement : field : short + s.ConRequirement = reader.GetShort() + // ChaRequirement : field : short + s.ChaRequirement = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SkillMasterRecord :: Record of Skill Master data in an Endless Skill Master File. +type SkillMasterRecord struct { + byteSize int + + BehaviorId int // Behavior ID of the Skill Master NPC. + Name string + MinLevel int // Minimum level required to use this Skill Master. + MaxLevel int // Maximum level allowed to use this Skill Master. + ClassRequirement int // Class required to use this Skill Master. + Skills []SkillMasterSkillRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SkillMasterRecord) ByteSize() int { + return s.byteSize +} + +func (s *SkillMasterRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // MinLevel : field : char + if err = writer.AddChar(s.MinLevel); err != nil { + return + } + // MaxLevel : field : char + if err = writer.AddChar(s.MaxLevel); err != nil { + return + } + // ClassRequirement : field : char + if err = writer.AddChar(s.ClassRequirement); err != nil { + return + } + // SkillsCount : length : short + if err = writer.AddShort(len(s.Skills)); err != nil { + return + } + // Skills : array : SkillMasterSkillRecord + for ndx := 0; ndx < len(s.Skills); ndx++ { + if err = s.Skills[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *SkillMasterRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // MinLevel : field : char + s.MinLevel = reader.GetChar() + // MaxLevel : field : char + s.MaxLevel = reader.GetChar() + // ClassRequirement : field : char + s.ClassRequirement = reader.GetChar() + // SkillsCount : length : short + skillsCount := reader.GetShort() + // Skills : array : SkillMasterSkillRecord + for ndx := 0; ndx < skillsCount; ndx++ { + s.Skills = append(s.Skills, SkillMasterSkillRecord{}) + if err = s.Skills[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// SkillMasterFile :: Endless Skill Master File. +type SkillMasterFile struct { + byteSize int + + SkillMasters []SkillMasterRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *SkillMasterFile) ByteSize() int { + return s.byteSize +} + +func (s *SkillMasterFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EMF : field : string + if err = writer.AddFixedString("EMF", 3); err != nil { + return + } + // SkillMasters : array : SkillMasterRecord + for ndx := 0; ndx < len(s.SkillMasters); ndx++ { + if err = s.SkillMasters[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *SkillMasterFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EMF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // SkillMasters : array : SkillMasterRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.SkillMasters = append(s.SkillMasters, SkillMasterRecord{}) + if err = s.SkillMasters[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopTradeRecord :: Record of an item that can be bought or sold in a shop. +type ShopTradeRecord struct { + byteSize int + + ItemId int + BuyPrice int // How much it costs to buy the item from the shop. + SellPrice int // How much the shop will pay for the item. + MaxAmount int // Max amount of the item that can be bought or sold at one time. +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopTradeRecord) ByteSize() int { + return s.byteSize +} + +func (s *ShopTradeRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // BuyPrice : field : three + if err = writer.AddThree(s.BuyPrice); err != nil { + return + } + // SellPrice : field : three + if err = writer.AddThree(s.SellPrice); err != nil { + return + } + // MaxAmount : field : char + if err = writer.AddChar(s.MaxAmount); err != nil { + return + } + return +} + +func (s *ShopTradeRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // BuyPrice : field : three + s.BuyPrice = reader.GetThree() + // SellPrice : field : three + s.SellPrice = reader.GetThree() + // MaxAmount : field : char + s.MaxAmount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopCraftIngredientRecord :: Record of an ingredient for crafting an item in a shop. +type ShopCraftIngredientRecord struct { + byteSize int + + ItemId int // Item ID of the craft ingredient, or 0 if the ingredient is not present. + Amount int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopCraftIngredientRecord) ByteSize() int { + return s.byteSize +} + +func (s *ShopCraftIngredientRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // Amount : field : char + if err = writer.AddChar(s.Amount); err != nil { + return + } + return +} + +func (s *ShopCraftIngredientRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // Amount : field : char + s.Amount = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopCraftRecord :: Record of an item that can be crafted in a shop. +type ShopCraftRecord struct { + byteSize int + + ItemId int + Ingredients []ShopCraftIngredientRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopCraftRecord) ByteSize() int { + return s.byteSize +} + +func (s *ShopCraftRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ItemId : field : short + if err = writer.AddShort(s.ItemId); err != nil { + return + } + // Ingredients : array : ShopCraftIngredientRecord + for ndx := 0; ndx < 4; ndx++ { + if len(s.Ingredients) != 4 { + err = fmt.Errorf("expected Ingredients with length 4, got %d", len(s.Ingredients)) + return + } + + if err = s.Ingredients[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ShopCraftRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ItemId : field : short + s.ItemId = reader.GetShort() + // Ingredients : array : ShopCraftIngredientRecord + for ndx := 0; ndx < 4; ndx++ { + s.Ingredients = append(s.Ingredients, ShopCraftIngredientRecord{}) + if err = s.Ingredients[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopRecord :: Record of Shop data in an Endless Shop File. +type ShopRecord struct { + byteSize int + + BehaviorId int + Name string + MinLevel int // Minimum level required to use this shop. + MaxLevel int // Maximum level allowed to use this shop. + ClassRequirement int // Class required to use this shop. + Trades []ShopTradeRecord + Crafts []ShopCraftRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopRecord) ByteSize() int { + return s.byteSize +} + +func (s *ShopRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // MinLevel : field : char + if err = writer.AddChar(s.MinLevel); err != nil { + return + } + // MaxLevel : field : char + if err = writer.AddChar(s.MaxLevel); err != nil { + return + } + // ClassRequirement : field : char + if err = writer.AddChar(s.ClassRequirement); err != nil { + return + } + // TradesCount : length : short + if err = writer.AddShort(len(s.Trades)); err != nil { + return + } + // CraftsCount : length : char + if err = writer.AddChar(len(s.Crafts)); err != nil { + return + } + // Trades : array : ShopTradeRecord + for ndx := 0; ndx < len(s.Trades); ndx++ { + if err = s.Trades[ndx].Serialize(writer); err != nil { + return + } + } + + // Crafts : array : ShopCraftRecord + for ndx := 0; ndx < len(s.Crafts); ndx++ { + if err = s.Crafts[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ShopRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // MinLevel : field : char + s.MinLevel = reader.GetChar() + // MaxLevel : field : char + s.MaxLevel = reader.GetChar() + // ClassRequirement : field : char + s.ClassRequirement = reader.GetChar() + // TradesCount : length : short + tradesCount := reader.GetShort() + // CraftsCount : length : char + craftsCount := reader.GetChar() + // Trades : array : ShopTradeRecord + for ndx := 0; ndx < tradesCount; ndx++ { + s.Trades = append(s.Trades, ShopTradeRecord{}) + if err = s.Trades[ndx].Deserialize(reader); err != nil { + return + } + } + + // Crafts : array : ShopCraftRecord + for ndx := 0; ndx < craftsCount; ndx++ { + s.Crafts = append(s.Crafts, ShopCraftRecord{}) + if err = s.Crafts[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// ShopFile :: Endless Shop File. +type ShopFile struct { + byteSize int + + Shops []ShopRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *ShopFile) ByteSize() int { + return s.byteSize +} + +func (s *ShopFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ESF : field : string + if err = writer.AddFixedString("ESF", 3); err != nil { + return + } + // Shops : array : ShopRecord + for ndx := 0; ndx < len(s.Shops); ndx++ { + if err = s.Shops[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *ShopFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ESF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Shops : array : ShopRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Shops = append(s.Shops, ShopRecord{}) + if err = s.Shops[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkMessageRecord :: Record of a message that an NPC can say. +type TalkMessageRecord struct { + byteSize int + + Message string +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkMessageRecord) ByteSize() int { + return s.byteSize +} + +func (s *TalkMessageRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // MessageLength : length : char + if err = writer.AddChar(len(s.Message)); err != nil { + return + } + // Message : field : string + if err = writer.AddFixedString(s.Message, len(s.Message)); err != nil { + return + } + return +} + +func (s *TalkMessageRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // MessageLength : length : char + messageLength := reader.GetChar() + // Message : field : string + if s.Message, err = reader.GetFixedString(messageLength); err != nil { + return + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkRecord :: Record of Talk data in an Endless Talk File. +type TalkRecord struct { + byteSize int + + NpcId int // ID of the NPC that will talk. + Rate int // Chance that the NPC will talk (0-100). + Messages []TalkMessageRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkRecord) ByteSize() int { + return s.byteSize +} + +func (s *TalkRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NpcId : field : short + if err = writer.AddShort(s.NpcId); err != nil { + return + } + // Rate : field : char + if err = writer.AddChar(s.Rate); err != nil { + return + } + // MessagesCount : length : char + if err = writer.AddChar(len(s.Messages)); err != nil { + return + } + // Messages : array : TalkMessageRecord + for ndx := 0; ndx < len(s.Messages); ndx++ { + if err = s.Messages[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *TalkRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NpcId : field : short + s.NpcId = reader.GetShort() + // Rate : field : char + s.Rate = reader.GetChar() + // MessagesCount : length : char + messagesCount := reader.GetChar() + // Messages : array : TalkMessageRecord + for ndx := 0; ndx < messagesCount; ndx++ { + s.Messages = append(s.Messages, TalkMessageRecord{}) + if err = s.Messages[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// TalkFile :: Endless Talk File. +type TalkFile struct { + byteSize int + + Npcs []TalkRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *TalkFile) ByteSize() int { + return s.byteSize +} + +func (s *TalkFile) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ETF : field : string + if err = writer.AddFixedString("ETF", 3); err != nil { + return + } + // Npcs : array : TalkRecord + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *TalkFile) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ETF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Npcs : array : TalkRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Npcs = append(s.Npcs, TalkRecord{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/pub/structs_generated.go b/v3/protocol/pub/structs_generated.go new file mode 100644 index 0000000..337ea57 --- /dev/null +++ b/v3/protocol/pub/structs_generated.go @@ -0,0 +1,1244 @@ +package pub + +import ( + "fmt" + "github.com/ethanmoffat/eolib-go/v3/data" +) + +// EifRecord :: Record of Item data in an Endless Item File. +type EifRecord struct { + byteSize int + + Name string + GraphicId int + Type ItemType + Subtype ItemSubtype + Special ItemSpecial + Hp int + Tp int + MinDamage int + MaxDamage int + Accuracy int + Evade int + Armor int + ReturnDamage int + Str int + Intl int + Wis int + Agi int + Con int + Cha int + LightResistance int + DarkResistance int + EarthResistance int + AirResistance int + WaterResistance int + FireResistance int + Spec1 int // Holds one the following values, depending on item type:. scroll_map, doll_graphic, exp_reward, hair_color, effect, key, alcohol_potency. + Spec2 int // Holds one the following values, depending on item type:. scroll_x, gender. + Spec3 int // Holds one the following values, depending on item type:. scroll_y. + LevelRequirement int + ClassRequirement int + StrRequirement int + IntRequirement int + WisRequirement int + AgiRequirement int + ConRequirement int + ChaRequirement int + Element Element + ElementDamage int + Weight int + + Size ItemSize +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EifRecord) ByteSize() int { + return s.byteSize +} + +func (s *EifRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // GraphicId : field : short + if err = writer.AddShort(s.GraphicId); err != nil { + return + } + // Type : field : ItemType + if err = writer.AddChar(int(s.Type)); err != nil { + return + } + // Subtype : field : ItemSubtype + if err = writer.AddChar(int(s.Subtype)); err != nil { + return + } + // Special : field : ItemSpecial + if err = writer.AddChar(int(s.Special)); err != nil { + return + } + // Hp : field : short + if err = writer.AddShort(s.Hp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MinDamage : field : short + if err = writer.AddShort(s.MinDamage); err != nil { + return + } + // MaxDamage : field : short + if err = writer.AddShort(s.MaxDamage); err != nil { + return + } + // Accuracy : field : short + if err = writer.AddShort(s.Accuracy); err != nil { + return + } + // Evade : field : short + if err = writer.AddShort(s.Evade); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // ReturnDamage : field : char + if err = writer.AddChar(s.ReturnDamage); err != nil { + return + } + // Str : field : char + if err = writer.AddChar(s.Str); err != nil { + return + } + // Intl : field : char + if err = writer.AddChar(s.Intl); err != nil { + return + } + // Wis : field : char + if err = writer.AddChar(s.Wis); err != nil { + return + } + // Agi : field : char + if err = writer.AddChar(s.Agi); err != nil { + return + } + // Con : field : char + if err = writer.AddChar(s.Con); err != nil { + return + } + // Cha : field : char + if err = writer.AddChar(s.Cha); err != nil { + return + } + // LightResistance : field : char + if err = writer.AddChar(s.LightResistance); err != nil { + return + } + // DarkResistance : field : char + if err = writer.AddChar(s.DarkResistance); err != nil { + return + } + // EarthResistance : field : char + if err = writer.AddChar(s.EarthResistance); err != nil { + return + } + // AirResistance : field : char + if err = writer.AddChar(s.AirResistance); err != nil { + return + } + // WaterResistance : field : char + if err = writer.AddChar(s.WaterResistance); err != nil { + return + } + // FireResistance : field : char + if err = writer.AddChar(s.FireResistance); err != nil { + return + } + // Spec1 : field : three + if err = writer.AddThree(s.Spec1); err != nil { + return + } + // Spec2 : field : char + if err = writer.AddChar(s.Spec2); err != nil { + return + } + // Spec3 : field : char + if err = writer.AddChar(s.Spec3); err != nil { + return + } + // LevelRequirement : field : short + if err = writer.AddShort(s.LevelRequirement); err != nil { + return + } + // ClassRequirement : field : short + if err = writer.AddShort(s.ClassRequirement); err != nil { + return + } + // StrRequirement : field : short + if err = writer.AddShort(s.StrRequirement); err != nil { + return + } + // IntRequirement : field : short + if err = writer.AddShort(s.IntRequirement); err != nil { + return + } + // WisRequirement : field : short + if err = writer.AddShort(s.WisRequirement); err != nil { + return + } + // AgiRequirement : field : short + if err = writer.AddShort(s.AgiRequirement); err != nil { + return + } + // ConRequirement : field : short + if err = writer.AddShort(s.ConRequirement); err != nil { + return + } + // ChaRequirement : field : short + if err = writer.AddShort(s.ChaRequirement); err != nil { + return + } + // Element : field : Element + if err = writer.AddChar(int(s.Element)); err != nil { + return + } + // ElementDamage : field : char + if err = writer.AddChar(s.ElementDamage); err != nil { + return + } + // Weight : field : char + if err = writer.AddChar(s.Weight); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // Size : field : ItemSize + if err = writer.AddChar(int(s.Size)); err != nil { + return + } + return +} + +func (s *EifRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // GraphicId : field : short + s.GraphicId = reader.GetShort() + // Type : field : ItemType + s.Type = ItemType(reader.GetChar()) + // Subtype : field : ItemSubtype + s.Subtype = ItemSubtype(reader.GetChar()) + // Special : field : ItemSpecial + s.Special = ItemSpecial(reader.GetChar()) + // Hp : field : short + s.Hp = reader.GetShort() + // Tp : field : short + s.Tp = reader.GetShort() + // MinDamage : field : short + s.MinDamage = reader.GetShort() + // MaxDamage : field : short + s.MaxDamage = reader.GetShort() + // Accuracy : field : short + s.Accuracy = reader.GetShort() + // Evade : field : short + s.Evade = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // ReturnDamage : field : char + s.ReturnDamage = reader.GetChar() + // Str : field : char + s.Str = reader.GetChar() + // Intl : field : char + s.Intl = reader.GetChar() + // Wis : field : char + s.Wis = reader.GetChar() + // Agi : field : char + s.Agi = reader.GetChar() + // Con : field : char + s.Con = reader.GetChar() + // Cha : field : char + s.Cha = reader.GetChar() + // LightResistance : field : char + s.LightResistance = reader.GetChar() + // DarkResistance : field : char + s.DarkResistance = reader.GetChar() + // EarthResistance : field : char + s.EarthResistance = reader.GetChar() + // AirResistance : field : char + s.AirResistance = reader.GetChar() + // WaterResistance : field : char + s.WaterResistance = reader.GetChar() + // FireResistance : field : char + s.FireResistance = reader.GetChar() + // Spec1 : field : three + s.Spec1 = reader.GetThree() + // Spec2 : field : char + s.Spec2 = reader.GetChar() + // Spec3 : field : char + s.Spec3 = reader.GetChar() + // LevelRequirement : field : short + s.LevelRequirement = reader.GetShort() + // ClassRequirement : field : short + s.ClassRequirement = reader.GetShort() + // StrRequirement : field : short + s.StrRequirement = reader.GetShort() + // IntRequirement : field : short + s.IntRequirement = reader.GetShort() + // WisRequirement : field : short + s.WisRequirement = reader.GetShort() + // AgiRequirement : field : short + s.AgiRequirement = reader.GetShort() + // ConRequirement : field : short + s.ConRequirement = reader.GetShort() + // ChaRequirement : field : short + s.ChaRequirement = reader.GetShort() + // Element : field : Element + s.Element = Element(reader.GetChar()) + // ElementDamage : field : char + s.ElementDamage = reader.GetChar() + // Weight : field : char + s.Weight = reader.GetChar() + // 0 : field : char + reader.GetChar() + // Size : field : ItemSize + s.Size = ItemSize(reader.GetChar()) + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Eif :: Endless Item File. +type Eif struct { + byteSize int + + Rid []int + TotalItemsCount int + Version int + Items []EifRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Eif) ByteSize() int { + return s.byteSize +} + +func (s *Eif) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // EIF : field : string + if err = writer.AddFixedString("EIF", 3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Rid) != 2 { + err = fmt.Errorf("expected Rid with length 2, got %d", len(s.Rid)) + return + } + + if err = writer.AddShort(s.Rid[ndx]); err != nil { + return + } + } + + // TotalItemsCount : field : short + if err = writer.AddShort(s.TotalItemsCount); err != nil { + return + } + // Version : field : char + if err = writer.AddChar(s.Version); err != nil { + return + } + // Items : array : EifRecord + for ndx := 0; ndx < len(s.Items); ndx++ { + if err = s.Items[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *Eif) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // EIF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Rid = append(s.Rid, 0) + s.Rid[ndx] = reader.GetShort() + } + + // TotalItemsCount : field : short + s.TotalItemsCount = reader.GetShort() + // Version : field : char + s.Version = reader.GetChar() + // Items : array : EifRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Items = append(s.Items, EifRecord{}) + if err = s.Items[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EnfRecord :: Record of NPC data in an Endless NPC File. +type EnfRecord struct { + byteSize int + + Name string + GraphicId int + Race int + Boss bool + Child bool + Type NpcType + BehaviorId int + Hp int + Tp int + MinDamage int + MaxDamage int + Accuracy int + Evade int + Armor int + ReturnDamage int + Element Element + ElementDamage int + ElementWeakness Element + ElementWeaknessDamage int + Level int + Experience int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EnfRecord) ByteSize() int { + return s.byteSize +} + +func (s *EnfRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // GraphicId : field : short + if err = writer.AddShort(s.GraphicId); err != nil { + return + } + // Race : field : char + if err = writer.AddChar(s.Race); err != nil { + return + } + // Boss : field : bool:short + if s.Boss { + err = writer.AddShort(1) + } else { + err = writer.AddShort(0) + } + if err != nil { + return + } + + // Child : field : bool:short + if s.Child { + err = writer.AddShort(1) + } else { + err = writer.AddShort(0) + } + if err != nil { + return + } + + // Type : field : NpcType + if err = writer.AddShort(int(s.Type)); err != nil { + return + } + // BehaviorId : field : short + if err = writer.AddShort(s.BehaviorId); err != nil { + return + } + // Hp : field : three + if err = writer.AddThree(s.Hp); err != nil { + return + } + // Tp : field : short + if err = writer.AddShort(s.Tp); err != nil { + return + } + // MinDamage : field : short + if err = writer.AddShort(s.MinDamage); err != nil { + return + } + // MaxDamage : field : short + if err = writer.AddShort(s.MaxDamage); err != nil { + return + } + // Accuracy : field : short + if err = writer.AddShort(s.Accuracy); err != nil { + return + } + // Evade : field : short + if err = writer.AddShort(s.Evade); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // ReturnDamage : field : char + if err = writer.AddChar(s.ReturnDamage); err != nil { + return + } + // Element : field : Element:short + if err = writer.AddChar(int(s.Element)); err != nil { + return + } + // ElementDamage : field : short + if err = writer.AddShort(s.ElementDamage); err != nil { + return + } + // ElementWeakness : field : Element:short + if err = writer.AddChar(int(s.ElementWeakness)); err != nil { + return + } + // ElementWeaknessDamage : field : short + if err = writer.AddShort(s.ElementWeaknessDamage); err != nil { + return + } + // Level : field : char + if err = writer.AddChar(s.Level); err != nil { + return + } + // Experience : field : three + if err = writer.AddThree(s.Experience); err != nil { + return + } + return +} + +func (s *EnfRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // GraphicId : field : short + s.GraphicId = reader.GetShort() + // Race : field : char + s.Race = reader.GetChar() + // Boss : field : bool:short + if boolVal := reader.GetShort(); boolVal > 0 { + s.Boss = true + } else { + s.Boss = false + } + // Child : field : bool:short + if boolVal := reader.GetShort(); boolVal > 0 { + s.Child = true + } else { + s.Child = false + } + // Type : field : NpcType + s.Type = NpcType(reader.GetShort()) + // BehaviorId : field : short + s.BehaviorId = reader.GetShort() + // Hp : field : three + s.Hp = reader.GetThree() + // Tp : field : short + s.Tp = reader.GetShort() + // MinDamage : field : short + s.MinDamage = reader.GetShort() + // MaxDamage : field : short + s.MaxDamage = reader.GetShort() + // Accuracy : field : short + s.Accuracy = reader.GetShort() + // Evade : field : short + s.Evade = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // ReturnDamage : field : char + s.ReturnDamage = reader.GetChar() + // Element : field : Element:short + s.Element = Element(reader.GetChar()) + // ElementDamage : field : short + s.ElementDamage = reader.GetShort() + // ElementWeakness : field : Element:short + s.ElementWeakness = Element(reader.GetChar()) + // ElementWeaknessDamage : field : short + s.ElementWeaknessDamage = reader.GetShort() + // Level : field : char + s.Level = reader.GetChar() + // Experience : field : three + s.Experience = reader.GetThree() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Enf :: Endless NPC File. +type Enf struct { + byteSize int + + Rid []int + TotalNpcsCount int + Version int + Npcs []EnfRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Enf) ByteSize() int { + return s.byteSize +} + +func (s *Enf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ENF : field : string + if err = writer.AddFixedString("ENF", 3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Rid) != 2 { + err = fmt.Errorf("expected Rid with length 2, got %d", len(s.Rid)) + return + } + + if err = writer.AddShort(s.Rid[ndx]); err != nil { + return + } + } + + // TotalNpcsCount : field : short + if err = writer.AddShort(s.TotalNpcsCount); err != nil { + return + } + // Version : field : char + if err = writer.AddChar(s.Version); err != nil { + return + } + // Npcs : array : EnfRecord + for ndx := 0; ndx < len(s.Npcs); ndx++ { + if err = s.Npcs[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *Enf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ENF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Rid = append(s.Rid, 0) + s.Rid[ndx] = reader.GetShort() + } + + // TotalNpcsCount : field : short + s.TotalNpcsCount = reader.GetShort() + // Version : field : char + s.Version = reader.GetChar() + // Npcs : array : EnfRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Npcs = append(s.Npcs, EnfRecord{}) + if err = s.Npcs[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EcfRecord :: Record of Class data in an Endless Class File. +type EcfRecord struct { + byteSize int + + Name string + ParentType int + StatGroup int + Str int + Intl int + Wis int + Agi int + Con int + Cha int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EcfRecord) ByteSize() int { + return s.byteSize +} + +func (s *EcfRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // ParentType : field : char + if err = writer.AddChar(s.ParentType); err != nil { + return + } + // StatGroup : field : char + if err = writer.AddChar(s.StatGroup); err != nil { + return + } + // Str : field : short + if err = writer.AddShort(s.Str); err != nil { + return + } + // Intl : field : short + if err = writer.AddShort(s.Intl); err != nil { + return + } + // Wis : field : short + if err = writer.AddShort(s.Wis); err != nil { + return + } + // Agi : field : short + if err = writer.AddShort(s.Agi); err != nil { + return + } + // Con : field : short + if err = writer.AddShort(s.Con); err != nil { + return + } + // Cha : field : short + if err = writer.AddShort(s.Cha); err != nil { + return + } + return +} + +func (s *EcfRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NameLength : length : char + nameLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // ParentType : field : char + s.ParentType = reader.GetChar() + // StatGroup : field : char + s.StatGroup = reader.GetChar() + // Str : field : short + s.Str = reader.GetShort() + // Intl : field : short + s.Intl = reader.GetShort() + // Wis : field : short + s.Wis = reader.GetShort() + // Agi : field : short + s.Agi = reader.GetShort() + // Con : field : short + s.Con = reader.GetShort() + // Cha : field : short + s.Cha = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Ecf :: Endless Class File. +type Ecf struct { + byteSize int + + Rid []int + TotalClassesCount int + Version int + Classes []EcfRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Ecf) ByteSize() int { + return s.byteSize +} + +func (s *Ecf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ECF : field : string + if err = writer.AddFixedString("ECF", 3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Rid) != 2 { + err = fmt.Errorf("expected Rid with length 2, got %d", len(s.Rid)) + return + } + + if err = writer.AddShort(s.Rid[ndx]); err != nil { + return + } + } + + // TotalClassesCount : field : short + if err = writer.AddShort(s.TotalClassesCount); err != nil { + return + } + // Version : field : char + if err = writer.AddChar(s.Version); err != nil { + return + } + // Classes : array : EcfRecord + for ndx := 0; ndx < len(s.Classes); ndx++ { + if err = s.Classes[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *Ecf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ECF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Rid = append(s.Rid, 0) + s.Rid[ndx] = reader.GetShort() + } + + // TotalClassesCount : field : short + s.TotalClassesCount = reader.GetShort() + // Version : field : char + s.Version = reader.GetChar() + // Classes : array : EcfRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Classes = append(s.Classes, EcfRecord{}) + if err = s.Classes[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// EsfRecord :: Record of Skill data in an Endless Skill File. +type EsfRecord struct { + byteSize int + + Name string + Chant string + IconId int + GraphicId int + TpCost int + SpCost int + CastTime int + Nature SkillNature + + Type SkillType + Element Element + ElementPower int + TargetRestrict SkillTargetRestrict + TargetType SkillTargetType + TargetTime int + + MaxSkillLevel int + MinDamage int + MaxDamage int + Accuracy int + Evade int + Armor int + ReturnDamage int + HpHeal int + TpHeal int + SpHeal int + Str int + Intl int + Wis int + Agi int + Con int + Cha int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *EsfRecord) ByteSize() int { + return s.byteSize +} + +func (s *EsfRecord) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // NameLength : length : char + if err = writer.AddChar(len(s.Name)); err != nil { + return + } + // ChantLength : length : char + if err = writer.AddChar(len(s.Chant)); err != nil { + return + } + // Name : field : string + if err = writer.AddFixedString(s.Name, len(s.Name)); err != nil { + return + } + // Chant : field : string + if err = writer.AddFixedString(s.Chant, len(s.Chant)); err != nil { + return + } + // IconId : field : short + if err = writer.AddShort(s.IconId); err != nil { + return + } + // GraphicId : field : short + if err = writer.AddShort(s.GraphicId); err != nil { + return + } + // TpCost : field : short + if err = writer.AddShort(s.TpCost); err != nil { + return + } + // SpCost : field : short + if err = writer.AddShort(s.SpCost); err != nil { + return + } + // CastTime : field : char + if err = writer.AddChar(s.CastTime); err != nil { + return + } + // Nature : field : SkillNature + if err = writer.AddChar(int(s.Nature)); err != nil { + return + } + // 1 : field : char + if err = writer.AddChar(1); err != nil { + return + } + // Type : field : SkillType + if err = writer.AddThree(int(s.Type)); err != nil { + return + } + // Element : field : Element + if err = writer.AddChar(int(s.Element)); err != nil { + return + } + // ElementPower : field : short + if err = writer.AddShort(s.ElementPower); err != nil { + return + } + // TargetRestrict : field : SkillTargetRestrict + if err = writer.AddChar(int(s.TargetRestrict)); err != nil { + return + } + // TargetType : field : SkillTargetType + if err = writer.AddChar(int(s.TargetType)); err != nil { + return + } + // TargetTime : field : char + if err = writer.AddChar(s.TargetTime); err != nil { + return + } + // 0 : field : char + if err = writer.AddChar(0); err != nil { + return + } + // MaxSkillLevel : field : short + if err = writer.AddShort(s.MaxSkillLevel); err != nil { + return + } + // MinDamage : field : short + if err = writer.AddShort(s.MinDamage); err != nil { + return + } + // MaxDamage : field : short + if err = writer.AddShort(s.MaxDamage); err != nil { + return + } + // Accuracy : field : short + if err = writer.AddShort(s.Accuracy); err != nil { + return + } + // Evade : field : short + if err = writer.AddShort(s.Evade); err != nil { + return + } + // Armor : field : short + if err = writer.AddShort(s.Armor); err != nil { + return + } + // ReturnDamage : field : char + if err = writer.AddChar(s.ReturnDamage); err != nil { + return + } + // HpHeal : field : short + if err = writer.AddShort(s.HpHeal); err != nil { + return + } + // TpHeal : field : short + if err = writer.AddShort(s.TpHeal); err != nil { + return + } + // SpHeal : field : char + if err = writer.AddChar(s.SpHeal); err != nil { + return + } + // Str : field : short + if err = writer.AddShort(s.Str); err != nil { + return + } + // Intl : field : short + if err = writer.AddShort(s.Intl); err != nil { + return + } + // Wis : field : short + if err = writer.AddShort(s.Wis); err != nil { + return + } + // Agi : field : short + if err = writer.AddShort(s.Agi); err != nil { + return + } + // Con : field : short + if err = writer.AddShort(s.Con); err != nil { + return + } + // Cha : field : short + if err = writer.AddShort(s.Cha); err != nil { + return + } + return +} + +func (s *EsfRecord) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // NameLength : length : char + nameLength := reader.GetChar() + // ChantLength : length : char + chantLength := reader.GetChar() + // Name : field : string + if s.Name, err = reader.GetFixedString(nameLength); err != nil { + return + } + + // Chant : field : string + if s.Chant, err = reader.GetFixedString(chantLength); err != nil { + return + } + + // IconId : field : short + s.IconId = reader.GetShort() + // GraphicId : field : short + s.GraphicId = reader.GetShort() + // TpCost : field : short + s.TpCost = reader.GetShort() + // SpCost : field : short + s.SpCost = reader.GetShort() + // CastTime : field : char + s.CastTime = reader.GetChar() + // Nature : field : SkillNature + s.Nature = SkillNature(reader.GetChar()) + // 1 : field : char + reader.GetChar() + // Type : field : SkillType + s.Type = SkillType(reader.GetThree()) + // Element : field : Element + s.Element = Element(reader.GetChar()) + // ElementPower : field : short + s.ElementPower = reader.GetShort() + // TargetRestrict : field : SkillTargetRestrict + s.TargetRestrict = SkillTargetRestrict(reader.GetChar()) + // TargetType : field : SkillTargetType + s.TargetType = SkillTargetType(reader.GetChar()) + // TargetTime : field : char + s.TargetTime = reader.GetChar() + // 0 : field : char + reader.GetChar() + // MaxSkillLevel : field : short + s.MaxSkillLevel = reader.GetShort() + // MinDamage : field : short + s.MinDamage = reader.GetShort() + // MaxDamage : field : short + s.MaxDamage = reader.GetShort() + // Accuracy : field : short + s.Accuracy = reader.GetShort() + // Evade : field : short + s.Evade = reader.GetShort() + // Armor : field : short + s.Armor = reader.GetShort() + // ReturnDamage : field : char + s.ReturnDamage = reader.GetChar() + // HpHeal : field : short + s.HpHeal = reader.GetShort() + // TpHeal : field : short + s.TpHeal = reader.GetShort() + // SpHeal : field : char + s.SpHeal = reader.GetChar() + // Str : field : short + s.Str = reader.GetShort() + // Intl : field : short + s.Intl = reader.GetShort() + // Wis : field : short + s.Wis = reader.GetShort() + // Agi : field : short + s.Agi = reader.GetShort() + // Con : field : short + s.Con = reader.GetShort() + // Cha : field : short + s.Cha = reader.GetShort() + s.byteSize = reader.Position() - readerStartPosition + + return +} + +// Esf :: Endless Skill File. +type Esf struct { + byteSize int + + Rid []int + TotalSkillsCount int + Version int + Skills []EsfRecord +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Esf) ByteSize() int { + return s.byteSize +} + +func (s *Esf) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // ESF : field : string + if err = writer.AddFixedString("ESF", 3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + if len(s.Rid) != 2 { + err = fmt.Errorf("expected Rid with length 2, got %d", len(s.Rid)) + return + } + + if err = writer.AddShort(s.Rid[ndx]); err != nil { + return + } + } + + // TotalSkillsCount : field : short + if err = writer.AddShort(s.TotalSkillsCount); err != nil { + return + } + // Version : field : char + if err = writer.AddChar(s.Version); err != nil { + return + } + // Skills : array : EsfRecord + for ndx := 0; ndx < len(s.Skills); ndx++ { + if err = s.Skills[ndx].Serialize(writer); err != nil { + return + } + } + + return +} + +func (s *Esf) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // ESF : field : string + if _, err = reader.GetFixedString(3); err != nil { + return + } + // Rid : array : short + for ndx := 0; ndx < 2; ndx++ { + s.Rid = append(s.Rid, 0) + s.Rid[ndx] = reader.GetShort() + } + + // TotalSkillsCount : field : short + s.TotalSkillsCount = reader.GetShort() + // Version : field : char + s.Version = reader.GetChar() + // Skills : array : EsfRecord + for ndx := 0; reader.Remaining() > 0; ndx++ { + s.Skills = append(s.Skills, EsfRecord{}) + if err = s.Skills[ndx].Deserialize(reader); err != nil { + return + } + } + + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/protocol/serialize.go b/v3/protocol/serialize.go new file mode 100644 index 0000000..40e8299 --- /dev/null +++ b/v3/protocol/serialize.go @@ -0,0 +1,18 @@ +package protocol + +import "github.com/ethanmoffat/eolib-go/v3/data" + +type Serializer interface { + Serialize(writer *data.EoWriter) error +} + +type Deserializer interface { + Deserialize(reader *data.EoReader) error +} + +type EoData interface { + Serializer + Deserializer + + ByteSize() int +} diff --git a/v3/protocol/structs_generated.go b/v3/protocol/structs_generated.go new file mode 100644 index 0000000..590724f --- /dev/null +++ b/v3/protocol/structs_generated.go @@ -0,0 +1,45 @@ +package protocol + +import "github.com/ethanmoffat/eolib-go/v3/data" + +// Coords :: Map coordinates. +type Coords struct { + byteSize int + + X int + Y int +} + +// ByteSize gets the deserialized size of this object. This value is zero for an object that was not deserialized from data. +func (s *Coords) ByteSize() int { + return s.byteSize +} + +func (s *Coords) Serialize(writer *data.EoWriter) (err error) { + oldSanitizeStrings := writer.SanitizeStrings + defer func() { writer.SanitizeStrings = oldSanitizeStrings }() + + // X : field : char + if err = writer.AddChar(s.X); err != nil { + return + } + // Y : field : char + if err = writer.AddChar(s.Y); err != nil { + return + } + return +} + +func (s *Coords) Deserialize(reader *data.EoReader) (err error) { + oldIsChunked := reader.IsChunked() + defer func() { reader.SetIsChunked(oldIsChunked) }() + + readerStartPosition := reader.Position() + // X : field : char + s.X = reader.GetChar() + // Y : field : char + s.Y = reader.GetChar() + s.byteSize = reader.Position() - readerStartPosition + + return +} diff --git a/v3/utils/utils.go b/v3/utils/utils.go new file mode 100644 index 0000000..173e942 --- /dev/null +++ b/v3/utils/utils.go @@ -0,0 +1,42 @@ +package utils + +import "golang.org/x/exp/constraints" + +// Min provides a generic method for getting the lesser of two input values. +// In the event that the inputs are equal, the second input will be returned. +func Min[T constraints.Ordered](a, b T) T { + if a < b { + return a + } + return b +} + +// Max provides a generic method for getting the greater of two input values. +// In the event that the inputs are equal, the second input will be returned. +func Max[T constraints.Ordered](a, b T) T { + if a > b { + return a + } + return b +} + +// Reverse returns a new slice containing the elements of the input slice in reverse order. +func Reverse[T constraints.Ordered](input []T) []T { + ret := make([]T, len(input)) + copy(ret, input) + + for i, j := 0, len(input)-1; i < j; i, j = i+1, j-1 { + ret[i], ret[j] = input[j], input[i] + } + + return ret +} + +func FindIndex[T constraints.Ordered](input []T, val T, eq func(T, T) bool) int { + for i, v := range input { + if eq(v, val) { + return i + } + } + return -1 +}