mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-25 04:36:12 -04:00
d2datadict: Add books.txt loader (#640)
This commit is contained in:
parent
a31fb173eb
commit
50fd6608cf
@ -214,6 +214,7 @@ func (a *App) loadDataDict() error {
|
|||||||
{d2resource.ObjectDetails, d2datadict.LoadObjects},
|
{d2resource.ObjectDetails, d2datadict.LoadObjects},
|
||||||
{d2resource.Weapons, d2datadict.LoadWeapons},
|
{d2resource.Weapons, d2datadict.LoadWeapons},
|
||||||
{d2resource.Armor, d2datadict.LoadArmors},
|
{d2resource.Armor, d2datadict.LoadArmors},
|
||||||
|
{d2resource.Books, d2datadict.LoadBooks},
|
||||||
{d2resource.Misc, d2datadict.LoadMiscItems},
|
{d2resource.Misc, d2datadict.LoadMiscItems},
|
||||||
{d2resource.UniqueItems, d2datadict.LoadUniqueItems},
|
{d2resource.UniqueItems, d2datadict.LoadUniqueItems},
|
||||||
{d2resource.Missiles, d2datadict.LoadMissiles},
|
{d2resource.Missiles, d2datadict.LoadMissiles},
|
||||||
|
54
d2common/d2data/d2datadict/books.go
Normal file
54
d2common/d2data/d2datadict/books.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package d2datadict
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BooksRecord is a representation of a row from books.txt
|
||||||
|
type BooksRecord struct {
|
||||||
|
Name string
|
||||||
|
Namco string // The displayed name, where the string prefix is "Tome"
|
||||||
|
Completed string
|
||||||
|
ScrollSpellCode string
|
||||||
|
BookSpellCode string
|
||||||
|
pSpell int
|
||||||
|
SpellIcon int
|
||||||
|
ScrollSkill string
|
||||||
|
BookSkill string
|
||||||
|
BaseCost int
|
||||||
|
CostPerCharge int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Books stores all of the BooksRecords
|
||||||
|
var Books map[string]*BooksRecord //nolint:gochecknoglobals // Currently global by design, only written once
|
||||||
|
|
||||||
|
// LoadBooks loads Books records into a map[string]*BooksRecord
|
||||||
|
func LoadBooks(file []byte) {
|
||||||
|
Books = make(map[string]*BooksRecord)
|
||||||
|
|
||||||
|
d := d2common.LoadDataDictionary(file)
|
||||||
|
for d.Next() {
|
||||||
|
record := &BooksRecord{
|
||||||
|
Name: d.String("Name"),
|
||||||
|
Namco: d.String("Namco"),
|
||||||
|
Completed: d.String("Completed"),
|
||||||
|
ScrollSpellCode: d.String("ScrollSpellCode"),
|
||||||
|
BookSpellCode: d.String("BooksSpellCode"),
|
||||||
|
pSpell: d.Number("pSpell"),
|
||||||
|
SpellIcon: d.Number("SpellIcon"),
|
||||||
|
ScrollSkill: d.String("ScrollSkill"),
|
||||||
|
BookSkill: d.String("BookSkill"),
|
||||||
|
BaseCost: d.Number("BaseCost"),
|
||||||
|
CostPerCharge: d.Number("CostPerCharge"),
|
||||||
|
}
|
||||||
|
Books[record.Namco] = record
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Err != nil {
|
||||||
|
panic(d.Err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Loaded %d book items", len(Books))
|
||||||
|
}
|
@ -212,6 +212,7 @@ const (
|
|||||||
Inventory = "/data/global/excel/inventory.txt"
|
Inventory = "/data/global/excel/inventory.txt"
|
||||||
Weapons = "/data/global/excel/weapons.txt"
|
Weapons = "/data/global/excel/weapons.txt"
|
||||||
Armor = "/data/global/excel/armor.txt"
|
Armor = "/data/global/excel/armor.txt"
|
||||||
|
Books = "/data/global/excel/books.txt"
|
||||||
Misc = "/data/global/excel/misc.txt"
|
Misc = "/data/global/excel/misc.txt"
|
||||||
UniqueItems = "/data/global/excel/UniqueItems.txt"
|
UniqueItems = "/data/global/excel/UniqueItems.txt"
|
||||||
Gems = "/data/global/excel/gems.txt"
|
Gems = "/data/global/excel/gems.txt"
|
||||||
|
Loading…
Reference in New Issue
Block a user