1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-30 07:06:18 -04:00
OpenDiablo2/d2common/d2data/d2datadict/body_locations.go
lord b13175b070
d2data item related loaders (#619)
* added loader for ItemTypes.txt

* added loader for bodylocs.txt

* lint fix for item_types loader

* adding loader for sets.txt

* minor edit

* adding loader for SetItems.txt

* added loader for automagic.txt
2020-07-24 21:56:19 -04:00

38 lines
846 B
Go

package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// BodyLocationRecord describes a body location that items can be equipped to
type BodyLocationRecord struct {
Name string
Code string
}
// BodyLocations contains the body location records
//nolint:gochecknoglobals // Currently global by design, only written once
var BodyLocations map[string]*BodyLocationRecord
// LoadBodyLocations loads body locations from
func LoadBodyLocations(file []byte) {
BodyLocations = make(map[string]*BodyLocationRecord)
d := d2common.LoadDataDictionary(file)
for d.Next() {
location := &BodyLocationRecord{
Name: d.String("Name"),
Code: d.String("Code"),
}
BodyLocations[location.Code] = location
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d Body Location records", len(BodyLocations))
}