2020-06-28 03:15:20 +00:00
|
|
|
package d2datadict
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
|
|
)
|
|
|
|
|
2020-06-29 16:37:11 +00:00
|
|
|
//nolint:gochecknoglobals // Currently global by design, only written once
|
2020-06-28 04:07:52 +00:00
|
|
|
var MonPresets [][]string
|
2020-06-28 03:15:20 +00:00
|
|
|
|
|
|
|
func LoadMonPresets(file []byte) {
|
|
|
|
dict := d2common.LoadDataDictionary(string(file))
|
|
|
|
numRecords := len(dict.Data)
|
2020-06-28 04:07:52 +00:00
|
|
|
MonPresets = make([][]string, numRecords)
|
2020-06-29 16:37:11 +00:00
|
|
|
|
2020-06-28 04:07:52 +00:00
|
|
|
for idx := range MonPresets {
|
|
|
|
MonPresets[idx] = make([]string, numRecords)
|
|
|
|
}
|
|
|
|
|
|
|
|
lastAct := 0
|
|
|
|
placeIdx := 0
|
2020-06-29 16:37:11 +00:00
|
|
|
|
2020-06-28 04:07:52 +00:00
|
|
|
for dictIdx := range dict.Data {
|
|
|
|
act := dict.GetNumber("Act", dictIdx)
|
|
|
|
if act != lastAct {
|
|
|
|
placeIdx = 0
|
2020-06-28 03:15:20 +00:00
|
|
|
}
|
2020-06-29 16:37:11 +00:00
|
|
|
|
2020-06-28 04:07:52 +00:00
|
|
|
MonPresets[act][placeIdx] = dict.GetString("Place", dictIdx)
|
|
|
|
lastAct = act
|
2020-06-29 16:37:11 +00:00
|
|
|
|
|
|
|
placeIdx++
|
2020-06-28 03:15:20 +00:00
|
|
|
}
|
2020-06-29 16:37:11 +00:00
|
|
|
|
2020-06-28 03:15:20 +00:00
|
|
|
log.Printf("Loaded %d MonPreset records", len(MonPresets))
|
|
|
|
}
|