mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-10-15 06:33:46 -04:00
0218cad717
* move music path enumerations into d2resource * move text dictionary (.tbl) loader into d2fileformats sub-package d2tbl * lint fix, add doc file for d2tbl * moved data_dictionary.go into d2fileformats sub-package d2txt, added doc file * added sub-packages d2geom for geometry-related things, and d2path for path-related things * moved calcstring.go to d2calculation * move bitmuncher, bitstream, stream reader/writer from d2common into sub-package d2datautils * fix lint errors in d2datadict loaders (caused by moving stuf around in d2common) * move size.go into d2geom * move d2common/cache.go into sub-package d2common/d2cache * renamed d2debugutil to d2util, moved utility functions from d2common into d2util
86 lines
2.0 KiB
Go
86 lines
2.0 KiB
Go
package d2datadict
|
|
|
|
import (
|
|
"log"
|
|
"strconv"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
|
)
|
|
|
|
// QualityRecord represents a single row of QualityItems.txt, which controls
|
|
// properties for superior quality items
|
|
type QualityRecord struct {
|
|
NumMods int
|
|
Mod1Code string
|
|
Mod1Param int
|
|
Mod1Min int
|
|
Mod1Max int
|
|
Mod2Code string
|
|
Mod2Param int
|
|
Mod2Min int
|
|
Mod2Max int
|
|
|
|
// The following fields determine this row's applicability to
|
|
// categories of item.
|
|
Armor bool
|
|
Weapon bool
|
|
Shield bool
|
|
Thrown bool
|
|
Scepter bool
|
|
Wand bool
|
|
Staff bool
|
|
Bow bool
|
|
Boots bool
|
|
Gloves bool
|
|
Belt bool
|
|
|
|
Level int
|
|
Multiply int
|
|
Add int
|
|
}
|
|
|
|
// QualityItems stores all of the QualityRecords
|
|
var QualityItems map[string]*QualityRecord //nolint:gochecknoglobals // Currently global by design, only written once
|
|
|
|
// LoadQualityItems loads QualityItem records into a map[string]*QualityRecord
|
|
func LoadQualityItems(file []byte) {
|
|
QualityItems = make(map[string]*QualityRecord)
|
|
|
|
d := d2txt.LoadDataDictionary(file)
|
|
for d.Next() {
|
|
qual := &QualityRecord{
|
|
NumMods: d.Number("nummods"),
|
|
Mod1Code: d.String("mod1code"),
|
|
Mod1Param: d.Number("mod1param"),
|
|
Mod1Min: d.Number("mod1min"),
|
|
Mod1Max: d.Number("mod1max"),
|
|
Mod2Code: d.String("mod2code"),
|
|
Mod2Param: d.Number("mod2param"),
|
|
Mod2Min: d.Number("mod2min"),
|
|
Mod2Max: d.Number("mod2max"),
|
|
Armor: d.Bool("armor"),
|
|
Weapon: d.Bool("weapon"),
|
|
Shield: d.Bool("shield"),
|
|
Thrown: d.Bool("thrown"),
|
|
Scepter: d.Bool("scepter"),
|
|
Wand: d.Bool("wand"),
|
|
Staff: d.Bool("staff"),
|
|
Bow: d.Bool("bow"),
|
|
Boots: d.Bool("boots"),
|
|
Gloves: d.Bool("gloves"),
|
|
Belt: d.Bool("belt"),
|
|
Level: d.Number("level"),
|
|
Multiply: d.Number("multiply"),
|
|
Add: d.Number("add"),
|
|
}
|
|
|
|
QualityItems[strconv.Itoa(len(QualityItems))] = qual
|
|
}
|
|
|
|
if d.Err != nil {
|
|
panic(d.Err)
|
|
}
|
|
|
|
log.Printf("Loaded %d QualityItems records", len(QualityItems))
|
|
}
|