Fix monpreset for other acts (#478)

This commit is contained in:
Ziemas 2020-06-28 06:07:52 +02:00 committed by GitHub
parent 3f1fe538e2
commit 6c56027731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -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))
}

View File

@ -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 {