1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-19 21:55:24 +00:00

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" "github.com/OpenDiablo2/OpenDiablo2/d2common"
) )
type MonPresetRecord struct { var MonPresets [][]string
Act int
Place string
}
var MonPresets []MonPresetRecord
func LoadMonPresets(file []byte) { func LoadMonPresets(file []byte) {
dict := d2common.LoadDataDictionary(string(file)) dict := d2common.LoadDataDictionary(string(file))
numRecords := len(dict.Data) numRecords := len(dict.Data)
MonPresets = make([]MonPresetRecord, numRecords) MonPresets = make([][]string, numRecords)
for idx := range dict.Data { for idx := range MonPresets {
record := MonPresetRecord{ MonPresets[idx] = make([]string, numRecords)
Act: dict.GetNumber("Act", idx), }
Place: dict.GetString("Place", idx),
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)) 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) newObject.Lookup = d2datadict.LookupObject(int(ds1.Act), newObject.Type, newObject.Id)
if newObject.Lookup != nil && newObject.Type == 1 { 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 { if newObject.Lookup != nil && newObject.Lookup.ObjectsTxtId != -1 {