Skip to content

Commit 3b46bfc

Browse files
committed
update parser
1 parent 4ef1a5a commit 3b46bfc

File tree

4 files changed

+13
-33
lines changed

4 files changed

+13
-33
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919

2020
# Go workspace file
2121
go.work
22+
23+
cheats.json

cheat-parser.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"os"
88
"path/filepath"
9+
"regexp"
910
"strings"
1011

1112
"github.com/go-git/go-billy/v5/memfs"
@@ -19,6 +20,11 @@ type Cheat struct {
1920
Options map[string]string `json:"options"`
2021
}
2122

23+
func isHex(s string) bool {
24+
var hexRegex = regexp.MustCompile(`^[0-9A-F ?]+$`)
25+
return hexRegex.MatchString(s)
26+
}
27+
2228
func main() {
2329
fs := memfs.New()
2430

@@ -69,9 +75,12 @@ func main() {
6975
} else if cheat.Options != nil && len(strings.Split(scanner.Text(), " ")[0]) < 8 {
7076
cheat.Options[strings.Join(strings.Split(scanner.Text(), " ")[1:], " ")] = strings.Split(scanner.Text(), " ")[0]
7177
game[currentCheat] = cheat
72-
} else {
78+
} else if isHex(scanner.Text()) {
7379
cheat.Data = append(cheat.Data, scanner.Text())
7480
game[currentCheat] = cheat
81+
} else {
82+
delete(game, currentCheat)
83+
log.Printf("Unknown line in cheat file %s, %s: %s\n", filepath.Join(basePath, item.Name()), currentCheat, scanner.Text())
7584
}
7685
}
7786

cheats.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)