1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-04 09:17:17 -05:00
OpenDiablo2/common/ObjectTypes.go
2019-11-06 22:12:15 -05:00

32 lines
837 B
Go

package common
import (
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/resourcepaths"
)
type ObjectTypeRecord struct {
Name string
Token string
}
var ObjectTypes []ObjectTypeRecord
func LoadObjectTypes(fileProvider FileProvider) {
objectTypeData := fileProvider.LoadFile(resourcepaths.ObjectType)
streamReader := 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))
}