1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-27 01:25:35 +00:00
OpenDiablo2/d2common/d2data/d2datadict/object_types.go
Ziemas aae565d528
Monstat2 loading and a bunch of lint issues (#491)
* MonStat2 loader

* Fix a bunch of lint issues in d2datadict
2020-06-29 12:37:11 -04:00

35 lines
900 B
Go

package d2datadict
import (
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
type ObjectTypeRecord struct {
Name string
Token string
}
//nolint:gochecknoglobals // Currently global by design, only written once
// ObjectTypes contains the name and token for objects
var ObjectTypes []ObjectTypeRecord
func LoadObjectTypes(objectTypeData []byte) {
streamReader := d2common.CreateStreamReader(objectTypeData)
count := streamReader.GetInt32()
ObjectTypes = make([]ObjectTypeRecord, count)
for i := range ObjectTypes {
nameBytes := streamReader.ReadBytes(32)
tokenBytes := streamReader.ReadBytes(20)
ObjectTypes[i] = ObjectTypeRecord{
Name: strings.TrimSpace(strings.ReplaceAll(string(nameBytes), string(0), "")),
Token: strings.TrimSpace(strings.ReplaceAll(string(tokenBytes), string(0), "")),
}
}
log.Printf("Loaded %d object types", len(ObjectTypes))
}