Skip to content

Commit 7fb7671

Browse files
committed
feat(writer): GLORIOUS WRITER
Signed-off-by: dark0dave <dark0dave@mykolab.com>
1 parent dc46139 commit 7fb7671

26 files changed

Lines changed: 2050 additions & 655 deletions

.github/workflows/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ jobs:
5656
- name: Build
5757
run: |
5858
go build ./...
59+
go doc bg

.mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[tools]
22
go = "1.25"
3+
"go:github.com/go-delve/delve/cmd/dlv" = "latest"

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Package",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${fileDirname}"
13+
}
14+
]
15+
}

bg/all.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package bg
33
import (
44
"encoding/binary"
55
"encoding/json"
6-
"fmt"
76
"io"
87
"strings"
98
)
@@ -29,12 +28,19 @@ func max(x, y int) int {
2928

3029
type LongString [32]byte
3130

32-
func (r *LongString) String() string {
33-
return string(r[0:])
31+
func (l *LongString) String() string {
32+
return string(l[:])
3433
}
3534

36-
func (r *LongString) MarshalJSON() ([]byte, error) {
37-
return fmt.Appendf(nil, "\\%s\\", r.String()), nil
35+
func (l *LongString) MarshalJSON() ([]byte, error) {
36+
return []byte(l.String()), nil
37+
}
38+
39+
func (l *LongString) UnmarshalJSON(b []byte) error {
40+
for i := range min(len(b)-2, 32) {
41+
l[i] = b[i+1]
42+
}
43+
return nil
3844
}
3945

4046
type Signature [4]byte
@@ -112,13 +118,9 @@ func (r Resref) String() string {
112118

113119
type strref uint32
114120

115-
func parseArray[A any](r io.ReadSeeker, count, start uint32) ([]A, error) {
116-
out := make([]A, count)
121+
func parseArray(r io.ReadSeeker, start uint32, out any) error {
117122
if _, err := r.Seek(int64(start), io.SeekStart); err != nil {
118-
return nil, err
119-
}
120-
if err := binary.Read(r, binary.LittleEndian, &out); err != nil {
121-
return nil, err
123+
return err
122124
}
123-
return out, nil
125+
return binary.Read(r, binary.LittleEndian, out)
124126
}

0 commit comments

Comments
 (0)