1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-25 19:46:50 -05:00

Add monpreset.txt loader (#675)

This commit is contained in:
AndrejMijic 2020-08-04 15:06:33 +02:00 committed by GitHub
parent f49770a0d7
commit c216ddab53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -270,6 +270,7 @@ func (a *App) loadDataDict() error {
{d2resource.MonsterSound, d2datadict.LoadMonsterSounds},
{d2resource.MonsterSequence, d2datadict.LoadMonsterSequences},
{d2resource.PlayerClass, d2datadict.LoadPlayerClasses},
{d2resource.MonsterPlacement, d2datadict.LoadMonsterPlacements},
}
d2datadict.InitObjectRecords()

View File

@ -0,0 +1,27 @@
package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// MonsterPlacementRecord represents a line from MonPlace.txt.
type MonsterPlacementRecord string
// MonsterPlacements stores the MonsterPlacementRecords.
var MonsterPlacements []MonsterPlacementRecord //nolint:gochecknoglobals // Currently global by design
// LoadMonsterPlacements loads the MonsterPlacementRecords into MonsterPlacements.
func LoadMonsterPlacements(file []byte) {
d := d2common.LoadDataDictionary(file)
for d.Next() {
MonsterPlacements = append(MonsterPlacements, MonsterPlacementRecord(d.String("code")))
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d MonsterPlacement records", len(MonsterPlacements))
}

View File

@ -322,6 +322,7 @@ const (
MonType = "/data/global/excel/Montype.txt"
SuperUniques = "/data/global/excel/SuperUniques.txt"
MonMode = "/data/global/excel/monmode.txt"
MonsterPlacement = "/data/global/excel/MonPlace.txt"
// --- Skill Data ---