2019-11-06 22:12:15 -05:00
|
|
|
package common
|
2019-11-03 11:04:58 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"strings"
|
|
|
|
|
2019-11-06 22:12:15 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/resourcepaths"
|
2019-11-03 11:04:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type ObjectTypeRecord struct {
|
|
|
|
Name string
|
|
|
|
Token string
|
|
|
|
}
|
|
|
|
|
|
|
|
var ObjectTypes []ObjectTypeRecord
|
|
|
|
|
|
|
|
func LoadObjectTypes(fileProvider FileProvider) {
|
2019-11-06 22:12:15 -05:00
|
|
|
objectTypeData := fileProvider.LoadFile(resourcepaths.ObjectType)
|
2019-11-03 11:04:58 -05:00
|
|
|
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))
|
|
|
|
}
|