1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-16 17:35:57 -05:00
OpenDiablo2/d2common/d2data/d2datadict/monpreset.go
dk 4938ec1f44
Resolved most lint errors in d2data and d2datadict (#499)
* adding comments to d2interface for linter

* moved d2render renderer interfaces and types into d2interface

* fixed most lint errors for monstats loader

* de-lint d2data wip

* d2data: resolve linting errors
2020-06-30 09:17:07 -04:00

40 lines
834 B
Go

package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// MonPresets stores monster presets
//nolint:gochecknoglobals // Currently global by design, only written once
var MonPresets [][]string
// LoadMonPresets loads monster presets from monpresets.txt
func LoadMonPresets(file []byte) {
dict := d2common.LoadDataDictionary(string(file))
numRecords := len(dict.Data)
MonPresets = make([][]string, numRecords)
for idx := range MonPresets {
MonPresets[idx] = make([]string, numRecords)
}
lastAct := 0
placeIdx := 0
for dictIdx := range dict.Data {
act := dict.GetNumber("Act", dictIdx)
if act != lastAct {
placeIdx = 0
}
MonPresets[act][placeIdx] = dict.GetString("Place", dictIdx)
lastAct = act
placeIdx++
}
log.Printf("Loaded %d MonPreset records", len(MonPresets))
}