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:
parent
cec3fb91d8
commit
a1ea22c81f
@ -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()
|
||||
|
39
d2common/d2data/d2datadict/elemtype.go
Normal file
39
d2common/d2data/d2datadict/elemtype.go
Normal 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))
|
||||
}
|
@ -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 ---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user