1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-02 09:17:19 -04:00

d2datadict: Add Monmode.txt loader (#638)

This commit is contained in:
Huw Griffiths 2020-07-29 22:38:34 +10:00 committed by GitHub
parent 6f30dffa1c
commit a31fb173eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View File

@ -224,6 +224,7 @@ func (a *App) loadDataDict() error {
{d2resource.MonPreset, d2datadict.LoadMonPresets},
{d2resource.MonProp, d2datadict.LoadMonProps},
{d2resource.MonType, d2datadict.LoadMonTypes},
{d2resource.MonMode, d2datadict.LoadMonModes},
{d2resource.MagicPrefix, d2datadict.LoadMagicPrefix},
{d2resource.MagicSuffix, d2datadict.LoadMagicSuffix},
{d2resource.ItemStatCost, d2datadict.LoadItemStatCosts},

View File

@ -0,0 +1,38 @@
package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// MonModeRecord is a representation of a single row of Monmode.txt
type MonModeRecord struct {
Name string
Token string
Code string
}
// MonModes stores all of the GemsRecords
var MonModes map[string]*MonModeRecord //nolint:gochecknoglobals // Currently global by design, only written once
// LoadMonModes loads gem records into a map[string]*MonModeRecord
func LoadMonModes(file []byte) {
MonModes = make(map[string]*MonModeRecord)
d := d2common.LoadDataDictionary(file)
for d.Next() {
record := &MonModeRecord{
Name: d.String("name"),
Token: d.String("token"),
Code: d.String("code"),
}
MonModes[record.Name] = record
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d MonMode records", len(MonModes))
}

View File

@ -304,6 +304,7 @@ const (
MonPreset = "/data/global/excel/monpreset.txt"
MonType = "/data/global/excel/Montype.txt"
SuperUniques = "/data/global/excel/SuperUniques.txt"
MonMode = "/data/global/excel/monmode.txt"
// --- Skill Data ---