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

Add PlayerClass.txt loader (#667)

This commit is contained in:
AndrejMijic 2020-08-03 03:26:57 +02:00 committed by GitHub
parent 524132c122
commit efb554c42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -269,6 +269,7 @@ func (a *App) loadDataDict() error {
{d2resource.MonsterLevel, d2datadict.LoadMonsterLevels},
{d2resource.MonsterSound, d2datadict.LoadMonsterSounds},
{d2resource.MonsterSequence, d2datadict.LoadMonsterSequences},
{d2resource.PlayerClass, d2datadict.LoadPlayerClasses},
}
d2datadict.InitObjectRecords()

View File

@ -0,0 +1,43 @@
package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
//PlayerClassRecord represents a single line from PlayerClass.txt
//Lookup table for class codes
type PlayerClassRecord struct {
//Class name
Name string
//Class code
Code string
}
//PlayerClasses stores the PlayerClassRecords
var PlayerClasses map[string]*PlayerClassRecord
//LoadPlayerClasses loads the PlayerClassRecords into PlayerClasses
func LoadPlayerClasses(file []byte) {
PlayerClasses = make(map[string]*PlayerClassRecord)
d := d2common.LoadDataDictionary(file)
for d.Next() {
record := &PlayerClassRecord{
Name: d.String("Player Class"),
Code: d.String("Code"),
}
if record.Name == "Expansion" {
continue
}
PlayerClasses[record.Name] = record
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d PlayerClass records", len(PlayerClasses))
}

View File

@ -213,6 +213,7 @@ const (
MonsterLevel = "/data/global/excel/monlvl.txt"
MonsterSound = "/data/global/excel/monsounds.txt"
MonsterSequence = "/data/global/excel/monseq.txt"
PlayerClass = "/data/global/excel/PlayerClass.txt"
// --- Animations ---