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

Add reading of ElemTypes.txt (#644)

This commit is contained in:
AndrejMijic 2020-07-30 08:41:19 +02:00 committed by GitHub
parent cec3fb91d8
commit a1ea22c81f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

@ -255,6 +255,7 @@ func (a *App) loadDataDict() error {
{d2resource.States, d2datadict.LoadStates},
{d2resource.SoundEnvirons, d2datadict.LoadSoundEnvirons},
{d2resource.Shrines, d2datadict.LoadShrines},
{d2resource.ElemType, d2datadict.LoadElemTypes},
}
d2datadict.InitObjectRecords()

View File

@ -0,0 +1,39 @@
package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
//ElemTypeRecord represents a single line in ElemType.txt
type ElemTypeRecord struct {
//Elemental damage type name
ElemType string
//Elemental damage type code
Code string
}
//ElemTypes stores the ElemTypeRecords
var ElemTypes map[string]*ElemTypeRecord //nolint:gochecknoglobals // Currently global by design
//LoadElemTypes loads ElemTypeRecords into ElemTypes
func LoadElemTypes(file []byte) {
ElemTypes = make(map[string]*ElemTypeRecord)
d := d2common.LoadDataDictionary(file)
for d.Next() {
record := &ElemTypeRecord{
ElemType: d.String("Elemental Type"),
Code: d.String("Code"),
}
ElemTypes[record.ElemType] = record
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d ElemType records", len(ElemTypes))
}

View File

@ -199,6 +199,7 @@ const (
SoundEnvirons = "/data/global/excel/soundenviron.txt"
Shrines = "/data/global/excel/shrines.txt"
MonProp = "/data/global/excel/Monprop.txt"
ElemType = "/data/global/excel/ElemTypes.txt"
// --- Animations ---