diff --git a/d2common/d2data/d2datadict/monpreset.go b/d2common/d2data/d2datadict/monpreset.go index baf558f3..8680437e 100644 --- a/d2common/d2data/d2datadict/monpreset.go +++ b/d2common/d2data/d2datadict/monpreset.go @@ -6,23 +6,26 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" ) -type MonPresetRecord struct { - Act int - Place string -} - -var MonPresets []MonPresetRecord +var MonPresets [][]string func LoadMonPresets(file []byte) { dict := d2common.LoadDataDictionary(string(file)) numRecords := len(dict.Data) - MonPresets = make([]MonPresetRecord, numRecords) - for idx := range dict.Data { - record := MonPresetRecord{ - Act: dict.GetNumber("Act", idx), - Place: dict.GetString("Place", idx), + 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[idx] = record + MonPresets[act][placeIdx] = dict.GetString("Place", dictIdx) + placeIdx++ + lastAct = act } log.Printf("Loaded %d MonPreset records", len(MonPresets)) } diff --git a/d2common/d2fileformats/d2ds1/ds1.go b/d2common/d2fileformats/d2ds1/ds1.go index 26447116..dfa36f85 100644 --- a/d2common/d2fileformats/d2ds1/ds1.go +++ b/d2common/d2fileformats/d2ds1/ds1.go @@ -123,7 +123,7 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) { newObject.Lookup = d2datadict.LookupObject(int(ds1.Act), newObject.Type, newObject.Id) if newObject.Lookup != nil && newObject.Type == 1 { - newObject.Lookup.Name = d2datadict.MonPresets[newObject.Id].Place + newObject.Lookup.Name = d2datadict.MonPresets[ds1.Act][newObject.Id] } if newObject.Lookup != nil && newObject.Lookup.ObjectsTxtId != -1 {