Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ jobs:
- name: Build
run: |
go build ./...
go doc bg
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[tools]
go = "1.25"
"go:github.com/go-delve/delve/cmd/dlv" = "latest"
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
26 changes: 14 additions & 12 deletions bg/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bg
import (
"encoding/binary"
"encoding/json"
"fmt"
"io"
"strings"
)
Expand All @@ -29,12 +28,19 @@ func max(x, y int) int {

type LongString [32]byte

func (r *LongString) String() string {
return string(r[0:])
func (l *LongString) String() string {
return string(l[:])
}

func (r *LongString) MarshalJSON() ([]byte, error) {
return fmt.Appendf(nil, "\\%s\\", r.String()), nil
func (l *LongString) MarshalJSON() ([]byte, error) {
return []byte(l.String()), nil
}

func (l *LongString) UnmarshalJSON(b []byte) error {
for i := range min(len(b)-2, 32) {
l[i] = b[i+1]
}
return nil
}

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

type strref uint32

func parseArray[A any](r io.ReadSeeker, count, start uint32) ([]A, error) {
out := make([]A, count)
func parseArray(r io.ReadSeeker, start uint32, out any) error {
if _, err := r.Seek(int64(start), io.SeekStart); err != nil {
return nil, err
}
if err := binary.Read(r, binary.LittleEndian, &out); err != nil {
return nil, err
return err
}
return out, nil
return binary.Read(r, binary.LittleEndian, out)
}
Loading