Skip to content

Commit

Permalink
Fix for broken line in Nox Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykirc authored and dennwc committed Feb 10, 2024
1 parent 18d8ab2 commit e15d353
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions things/thing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"reflect"
"strconv"
"strings"
"regexp"

"github.com/noxworld-dev/opennox-lib/log"
"github.com/noxworld-dev/opennox-lib/strman"
"github.com/noxworld-dev/opennox-lib/types"
)
Expand All @@ -17,6 +19,7 @@ var (
reflThing = reflect.TypeOf(Thing{})
reflProcFunc = reflect.TypeOf(ProcFunc{})
reflThingKeys = make(map[string]reflect.StructField)
regexAlphanum = regexp.MustCompile(`^[A-Za-z0-9_]+`)
)

func init() {
Expand Down Expand Up @@ -279,6 +282,11 @@ func (f *Reader) ReadThingSect() (*Thing, error) {
if len(kv) == 2 {
val = strings.TrimSpace(kv[1])
}
// workaround for single bugged entry in demo
if !regexAlphanum.MatchString(key) {
log.Printf("failed to parse thing attr entry: %s", kv)
continue
}
switch key {
case "DRAW":
if val != "" {
Expand Down

0 comments on commit e15d353

Please sign in to comment.