organize d2common pakage (#716)
* 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
This commit is contained in:
parent
50d40fb5d3
commit
0218cad717
|
@ -6,6 +6,8 @@ import (
|
||||||
"container/ring"
|
"container/ring"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2tbl"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"image"
|
"image"
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
@ -21,7 +23,6 @@ import (
|
||||||
"golang.org/x/image/colornames"
|
"golang.org/x/image/colornames"
|
||||||
"gopkg.in/alecthomas/kingpin.v2"
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
||||||
|
@ -144,7 +145,7 @@ func (a *App) Run() error {
|
||||||
|
|
||||||
func (a *App) initialize() error {
|
func (a *App) initialize() error {
|
||||||
a.timeScale = 1.0
|
a.timeScale = 1.0
|
||||||
a.lastTime = d2common.Now()
|
a.lastTime = d2util.Now()
|
||||||
a.lastScreenAdvance = a.lastTime
|
a.lastScreenAdvance = a.lastTime
|
||||||
|
|
||||||
a.renderer.SetWindowIcon("d2logo.png")
|
a.renderer.SetWindowIcon("d2logo.png")
|
||||||
|
@ -211,7 +212,7 @@ func (a *App) loadStrings() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d2common.LoadTextDictionary(data)
|
d2tbl.LoadTextDictionary(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -424,7 +425,7 @@ func (a *App) advance(elapsed, elapsedUnscaled, current float64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) update(target d2interface.Surface) error {
|
func (a *App) update(target d2interface.Surface) error {
|
||||||
currentTime := d2common.Now()
|
currentTime := d2util.Now()
|
||||||
elapsedTimeUnscaled := currentTime - a.lastTime
|
elapsedTimeUnscaled := currentTime - a.lastTime
|
||||||
elapsedTime := elapsedTimeUnscaled * a.timeScale
|
elapsedTime := elapsedTimeUnscaled * a.timeScale
|
||||||
a.lastTime = currentTime
|
a.lastTime = currentTime
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2calculation
|
||||||
|
|
||||||
// CalcString is a type of string often used in datafiles to specify
|
// CalcString is a type of string often used in datafiles to specify
|
||||||
// a value that is calculated dynamically based on the stats of the relevant
|
// a value that is calculated dynamically based on the stats of the relevant
|
|
@ -1,10 +1,9 @@
|
||||||
package d2data
|
package d2data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -30,7 +29,7 @@ var AnimationData map[string][]*AnimationDataRecord //nolint:gochecknoglobals //
|
||||||
// LoadAnimationData loads the animation data table into the global AnimationData dictionary
|
// LoadAnimationData loads the animation data table into the global AnimationData dictionary
|
||||||
func LoadAnimationData(rawData []byte) {
|
func LoadAnimationData(rawData []byte) {
|
||||||
AnimationData = make(map[string][]*AnimationDataRecord)
|
AnimationData = make(map[string][]*AnimationDataRecord)
|
||||||
streamReader := d2common.CreateStreamReader(rawData)
|
streamReader := d2datautils.CreateStreamReader(rawData)
|
||||||
|
|
||||||
for !streamReader.EOF() {
|
for !streamReader.EOF() {
|
||||||
dataCount := int(streamReader.GetInt32())
|
dataCount := int(streamReader.GetInt32())
|
||||||
|
|
|
@ -33,7 +33,7 @@ package d2compression
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// linkedNode is a node which is both hierachcical (parent/child) and doubly linked (next/prev)
|
// linkedNode is a node which is both hierachcical (parent/child) and doubly linked (next/prev)
|
||||||
|
@ -199,7 +199,7 @@ func getPrimes() [][]byte {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func decode(input *d2common.BitStream, head *linkedNode) *linkedNode {
|
func decode(input *d2datautils.BitStream, head *linkedNode) *linkedNode {
|
||||||
node := head
|
node := head
|
||||||
|
|
||||||
for node.child0 != nil {
|
for node.child0 != nil {
|
||||||
|
@ -386,8 +386,8 @@ func HuffmanDecompress(data []byte) []byte {
|
||||||
tail := buildList(primes[comptype])
|
tail := buildList(primes[comptype])
|
||||||
head := buildTree(tail)
|
head := buildTree(tail)
|
||||||
|
|
||||||
outputstream := d2common.CreateStreamWriter()
|
outputstream := d2datautils.CreateStreamWriter()
|
||||||
bitstream := d2common.CreateBitStream(data[1:])
|
bitstream := d2datautils.CreateBitStream(data[1:])
|
||||||
|
|
||||||
var decoded int
|
var decoded int
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package d2compression
|
package d2compression
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WavDecompress decompresses wav files
|
// WavDecompress decompresses wav files
|
||||||
|
@ -32,8 +32,8 @@ func WavDecompress(data []byte, channelCount int) []byte { //nolint:funlen doesn
|
||||||
-1, 2, -1, 4, -1, 6, -1, 8,
|
-1, 2, -1, 4, -1, 6, -1, 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
input := d2common.CreateStreamReader(data)
|
input := d2datautils.CreateStreamReader(data)
|
||||||
output := d2common.CreateStreamWriter()
|
output := d2datautils.CreateStreamWriter()
|
||||||
|
|
||||||
input.GetByte()
|
input.GetByte()
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AutoMagicRecord describes rules for automatically generating magic properties when spawning
|
// AutoMagicRecord describes rules for automatically generating magic properties when spawning
|
||||||
|
@ -139,7 +139,7 @@ func LoadAutoMagicRecords(file []byte) {
|
||||||
"sor": d2enum.HeroSorceress,
|
"sor": d2enum.HeroSorceress,
|
||||||
}
|
}
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &AutoMagicRecord{
|
record := &AutoMagicRecord{
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AutoMapRecord represents one row from d2data.mpq/AutoMap.txt.
|
// AutoMapRecord represents one row from d2data.mpq/AutoMap.txt.
|
||||||
|
@ -64,7 +64,7 @@ func LoadAutoMaps(file []byte) {
|
||||||
var frameFields = []string{"Cel1", "Cel2", "Cel3", "Cel4"}
|
var frameFields = []string{"Cel1", "Cel2", "Cel3", "Cel4"}
|
||||||
|
|
||||||
// Split file by newlines and tabs
|
// Split file by newlines and tabs
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &AutoMapRecord{
|
record := &AutoMapRecord{
|
||||||
LevelName: d.String("LevelName"),
|
LevelName: d.String("LevelName"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BodyLocationRecord describes a body location that items can be equipped to
|
// BodyLocationRecord describes a body location that items can be equipped to
|
||||||
|
@ -20,7 +20,7 @@ var BodyLocations map[string]*BodyLocationRecord
|
||||||
func LoadBodyLocations(file []byte) {
|
func LoadBodyLocations(file []byte) {
|
||||||
BodyLocations = make(map[string]*BodyLocationRecord)
|
BodyLocations = make(map[string]*BodyLocationRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
location := &BodyLocationRecord{
|
location := &BodyLocationRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BooksRecord is a representation of a row from books.txt
|
// BooksRecord is a representation of a row from books.txt
|
||||||
|
@ -28,7 +28,7 @@ var Books map[string]*BooksRecord //nolint:gochecknoglobals // Currently global
|
||||||
func LoadBooks(file []byte) {
|
func LoadBooks(file []byte) {
|
||||||
Books = make(map[string]*BooksRecord)
|
Books = make(map[string]*BooksRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &BooksRecord{
|
record := &BooksRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CalculationRecord The skillcalc.txt and misscalc.txt files are essentially lookup tables
|
// CalculationRecord The skillcalc.txt and misscalc.txt files are essentially lookup tables
|
||||||
|
@ -24,7 +24,7 @@ var MissileCalculations map[string]*CalculationRecord //nolint:gochecknoglobals
|
||||||
func LoadSkillCalculations(file []byte) {
|
func LoadSkillCalculations(file []byte) {
|
||||||
SkillCalculations = make(map[string]*CalculationRecord)
|
SkillCalculations = make(map[string]*CalculationRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &CalculationRecord{
|
record := &CalculationRecord{
|
||||||
Code: d.String("code"),
|
Code: d.String("code"),
|
||||||
|
@ -44,7 +44,7 @@ func LoadSkillCalculations(file []byte) {
|
||||||
func LoadMissileCalculations(file []byte) {
|
func LoadMissileCalculations(file []byte) {
|
||||||
MissileCalculations = make(map[string]*CalculationRecord)
|
MissileCalculations = make(map[string]*CalculationRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &CalculationRecord{
|
record := &CalculationRecord{
|
||||||
Code: d.String("code"),
|
Code: d.String("code"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CharStatsRecord is a struct that represents a single row from charstats.txt
|
// CharStatsRecord is a struct that represents a single row from charstats.txt
|
||||||
|
@ -97,7 +97,7 @@ func LoadCharStats(file []byte) {
|
||||||
"ht2": d2enum.WeaponClassTwoHandToHand,
|
"ht2": d2enum.WeaponClassTwoHandToHand,
|
||||||
}
|
}
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &CharStatsRecord{
|
record := &CharStatsRecord{
|
||||||
Class: charStringMap[d.String("class")],
|
Class: charStringMap[d.String("class")],
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ComponentCodeRecord represents a single row from compcode.txt
|
// ComponentCodeRecord represents a single row from compcode.txt
|
||||||
|
@ -20,7 +20,7 @@ var ComponentCodes map[string]*ComponentCodeRecord //nolint:gochecknoglobals //
|
||||||
func LoadComponentCodes(file []byte) {
|
func LoadComponentCodes(file []byte) {
|
||||||
ComponentCodes = make(map[string]*ComponentCodeRecord)
|
ComponentCodes = make(map[string]*ComponentCodeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &ComponentCodeRecord{
|
record := &ComponentCodeRecord{
|
||||||
Component: d.String("component"),
|
Component: d.String("component"),
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CubeRecipeRecord represents one row from CubeMain.txt.
|
// CubeRecipeRecord represents one row from CubeMain.txt.
|
||||||
|
@ -159,7 +159,7 @@ func LoadCubeRecipes(file []byte) {
|
||||||
|
|
||||||
var inputFields = []string{"input 1", "input 2", "input 3", "input 4", "input 5", "input 6", "input 7"}
|
var inputFields = []string{"input 1", "input 2", "input 3", "input 4", "input 5", "input 6", "input 7"}
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &CubeRecipeRecord{
|
record := &CubeRecipeRecord{
|
||||||
Description: d.String("description"),
|
Description: d.String("description"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DifficultyLevels contain the difficulty records for each difficulty
|
// DifficultyLevels contain the difficulty records for each difficulty
|
||||||
|
@ -96,7 +96,7 @@ type DifficultyLevelRecord struct {
|
||||||
func LoadDifficultyLevels(file []byte) {
|
func LoadDifficultyLevels(file []byte) {
|
||||||
DifficultyLevels = make(map[string]*DifficultyLevelRecord)
|
DifficultyLevels = make(map[string]*DifficultyLevelRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &DifficultyLevelRecord{
|
record := &DifficultyLevelRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ElemTypeRecord represents a single line in ElemType.txt
|
// ElemTypeRecord represents a single line in ElemType.txt
|
||||||
|
@ -22,7 +22,7 @@ var ElemTypes map[string]*ElemTypeRecord //nolint:gochecknoglobals // Currently
|
||||||
func LoadElemTypes(file []byte) {
|
func LoadElemTypes(file []byte) {
|
||||||
ElemTypes = make(map[string]*ElemTypeRecord)
|
ElemTypes = make(map[string]*ElemTypeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &ElemTypeRecord{
|
record := &ElemTypeRecord{
|
||||||
ElemType: d.String("Elemental Type"),
|
ElemType: d.String("Elemental Type"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EventRecord is a representation of a single row from events.txt
|
// EventRecord is a representation of a single row from events.txt
|
||||||
|
@ -18,7 +18,7 @@ var Events map[string]*EventRecord //nolint:gochecknoglobals // Currently global
|
||||||
func LoadEvents(file []byte) {
|
func LoadEvents(file []byte) {
|
||||||
Events = make(map[string]*EventRecord)
|
Events = make(map[string]*EventRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &EventRecord{
|
record := &EventRecord{
|
||||||
Event: d.String("event"),
|
Event: d.String("event"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* first column of experience.txt
|
/* first column of experience.txt
|
||||||
|
@ -62,7 +62,7 @@ func GetExperienceBreakpoint(heroType d2enum.Hero, level int) int {
|
||||||
func LoadExperienceBreakpoints(file []byte) {
|
func LoadExperienceBreakpoints(file []byte) {
|
||||||
ExperienceBreakpoints = make(map[int]*ExperienceBreakpointsRecord)
|
ExperienceBreakpoints = make(map[int]*ExperienceBreakpointsRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
d.Next()
|
d.Next()
|
||||||
|
|
||||||
// the first row describes the max level of char classes
|
// the first row describes the max level of char classes
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GemsRecord is a representation of a single row of gems.txt
|
// GemsRecord is a representation of a single row of gems.txt
|
||||||
|
@ -59,7 +59,7 @@ var Gems map[string]*GemsRecord //nolint:gochecknoglobals // Currently global by
|
||||||
func LoadGems(file []byte) {
|
func LoadGems(file []byte) {
|
||||||
Gems = make(map[string]*GemsRecord)
|
Gems = make(map[string]*GemsRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
gem := &GemsRecord{
|
gem := &GemsRecord{
|
||||||
Name: d.String("name"),
|
Name: d.String("name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HirelingRecord is a representation of rows in hireling.txt
|
// HirelingRecord is a representation of rows in hireling.txt
|
||||||
|
@ -91,7 +91,7 @@ var Hirelings []*HirelingRecord
|
||||||
func LoadHireling(file []byte) {
|
func LoadHireling(file []byte) {
|
||||||
Hirelings = make([]*HirelingRecord, 0)
|
Hirelings = make([]*HirelingRecord, 0)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
hireling := &HirelingRecord{
|
hireling := &HirelingRecord{
|
||||||
Hireling: d.String("Hireling"),
|
Hireling: d.String("Hireling"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type box struct {
|
type box struct {
|
||||||
|
@ -38,7 +38,7 @@ var Inventory map[string]*InventoryRecord //nolint:gochecknoglobals // Currently
|
||||||
|
|
||||||
// LoadInventory loads all of the inventory records from inventory.txt
|
// LoadInventory loads all of the inventory records from inventory.txt
|
||||||
func LoadInventory(file []byte) { //nolint:funlen // doesn't make sense to split
|
func LoadInventory(file []byte) { //nolint:funlen // doesn't make sense to split
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
Inventory = make(map[string]*InventoryRecord)
|
Inventory = make(map[string]*InventoryRecord)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MagicPrefix stores all of the magic prefix records
|
// MagicPrefix stores all of the magic prefix records
|
||||||
|
@ -56,7 +56,7 @@ func loadDictionary(
|
||||||
superType d2enum.ItemAffixSuperType,
|
superType d2enum.ItemAffixSuperType,
|
||||||
subType d2enum.ItemAffixSubType,
|
subType d2enum.ItemAffixSubType,
|
||||||
) map[string]*ItemAffixCommonRecord {
|
) map[string]*ItemAffixCommonRecord {
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
records := createItemAffixRecords(d, superType, subType)
|
records := createItemAffixRecords(d, superType, subType)
|
||||||
name := getAffixString(superType, subType)
|
name := getAffixString(superType, subType)
|
||||||
log.Printf("Loaded %d %s records", len(records), name)
|
log.Printf("Loaded %d %s records", len(records), name)
|
||||||
|
@ -65,7 +65,7 @@ func loadDictionary(
|
||||||
}
|
}
|
||||||
|
|
||||||
func createItemAffixRecords(
|
func createItemAffixRecords(
|
||||||
d *d2common.DataDictionary,
|
d *d2txt.DataDictionary,
|
||||||
superType d2enum.ItemAffixSuperType,
|
superType d2enum.ItemAffixSuperType,
|
||||||
subType d2enum.ItemAffixSubType,
|
subType d2enum.ItemAffixSubType,
|
||||||
) map[string]*ItemAffixCommonRecord {
|
) map[string]*ItemAffixCommonRecord {
|
||||||
|
|
|
@ -4,26 +4,25 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ItemCommonRecord is a representation of entries from armor.txt, weapons.txt, and misc.txt
|
// ItemCommonRecord is a representation of entries from armor.txt, weapons.txt, and misc.txt
|
||||||
type ItemCommonRecord struct {
|
type ItemCommonRecord struct {
|
||||||
UsageStats [3]ItemUsageStat // stat boosts applied upon usage
|
UsageStats [3]ItemUsageStat // stat boosts applied upon usage
|
||||||
CureOverlayStates [2]string // name of the overlay states that are removed upon use of this item
|
CureOverlayStates [2]string // name of the overlay states that are removed upon use of this item
|
||||||
OverlayState string // name of the overlay state to be applied upon use of this item
|
OverlayState string // name of the overlay state to be applied upon use of this item
|
||||||
SpellDescriptionString string // points to a string containing the description
|
SpellDescriptionString string // points to a string containing the description
|
||||||
BetterGem string // 3 char code pointing to the gem this upgrades to (non if not applicable)
|
BetterGem string // 3 char code pointing to the gem this upgrades to (non if not applicable)
|
||||||
SpellDescriptionCalc d2common.CalcString // a calc string what value to display
|
SpellDescriptionCalc d2calculation.CalcString // a calc string what value to display
|
||||||
WeaponClass string // what kind of attack does this weapon have (i.e. determines attack animations)
|
WeaponClass string // what kind of attack does this weapon have (i.e. determines attack animations)
|
||||||
WeaponClass2Hand string // what kind of attack when wielded with two hands
|
WeaponClass2Hand string // what kind of attack when wielded with two hands
|
||||||
HitClass string // determines sounds/graphic effects when attacking
|
HitClass string // determines sounds/graphic effects when attacking
|
||||||
SpecialFeature string // Just a comment
|
SpecialFeature string // Just a comment
|
||||||
FlavorText string // unknown, probably just for reference
|
FlavorText string // unknown, probably just for reference
|
||||||
TransmogCode string // the 3 char code representing the item this becomes via transmog
|
TransmogCode string // the 3 char code representing the item this becomes via transmog
|
||||||
NightmareUpgrade string // upgraded in higher difficulties
|
NightmareUpgrade string // upgraded in higher difficulties
|
||||||
HellUpgrade string
|
HellUpgrade string
|
||||||
SourceArt string // unused?
|
SourceArt string // unused?
|
||||||
GameArt string // unused?
|
GameArt string // unused?
|
||||||
|
@ -141,8 +140,8 @@ type ItemCommonRecord struct {
|
||||||
|
|
||||||
// ItemUsageStat the stat that gets applied when the item is used
|
// ItemUsageStat the stat that gets applied when the item is used
|
||||||
type ItemUsageStat struct {
|
type ItemUsageStat struct {
|
||||||
Stat string // name of the stat to add to
|
Stat string // name of the stat to add to
|
||||||
Calc d2common.CalcString // calc string representing the amount to add
|
Calc d2calculation.CalcString // calc string representing the amount to add
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemVendorParams are parameters that vendors use
|
// ItemVendorParams are parameters that vendors use
|
||||||
|
@ -342,7 +341,7 @@ func createCommonItemRecord(line string, mapping map[string]int, source d2enum.I
|
||||||
SpellDescriptionType: mapLoadInt(&r, mapping, "spelldesc"),
|
SpellDescriptionType: mapLoadInt(&r, mapping, "spelldesc"),
|
||||||
// 0 = none, 1 = use desc string, 2 = use desc string + calc value
|
// 0 = none, 1 = use desc string, 2 = use desc string + calc value
|
||||||
SpellDescriptionString: mapLoadString(&r, mapping, "spelldescstr"),
|
SpellDescriptionString: mapLoadString(&r, mapping, "spelldescstr"),
|
||||||
SpellDescriptionCalc: d2common.CalcString(mapLoadString(&r, mapping, "spelldesccalc")),
|
SpellDescriptionCalc: d2calculation.CalcString(mapLoadString(&r, mapping, "spelldesccalc")),
|
||||||
|
|
||||||
BetterGem: mapLoadString(&r, mapping, "BetterGem"),
|
BetterGem: mapLoadString(&r, mapping, "BetterGem"),
|
||||||
|
|
||||||
|
@ -392,7 +391,7 @@ func createItemUsageStats(r *[]string, mapping map[string]int) [3]ItemUsageStat
|
||||||
result := [3]ItemUsageStat{}
|
result := [3]ItemUsageStat{}
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
result[i].Stat = mapLoadString(r, mapping, "stat"+strconv.Itoa(i))
|
result[i].Stat = mapLoadString(r, mapping, "stat"+strconv.Itoa(i))
|
||||||
result[i].Calc = d2common.CalcString(mapLoadString(r, mapping, "calc"+strconv.Itoa(i)))
|
result[i].Calc = d2calculation.CalcString(mapLoadString(r, mapping, "calc"+strconv.Itoa(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A helper type for item drop calculation
|
// A helper type for item drop calculation
|
||||||
|
@ -42,7 +42,7 @@ var ItemRatios map[string]*ItemRatioRecord //nolint:gochecknoglobals // Currentl
|
||||||
func LoadItemRatios(file []byte) {
|
func LoadItemRatios(file []byte) {
|
||||||
ItemRatios = make(map[string]*ItemRatioRecord)
|
ItemRatios = make(map[string]*ItemRatioRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &ItemRatioRecord{
|
record := &ItemRatioRecord{
|
||||||
Function: d.String("Function"),
|
Function: d.String("Function"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ItemTypeRecord describes the types for items
|
// ItemTypeRecord describes the types for items
|
||||||
|
@ -201,7 +201,7 @@ func LoadItemTypes(file []byte) {
|
||||||
"sor": d2enum.HeroSorceress,
|
"sor": d2enum.HeroSorceress,
|
||||||
}
|
}
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
if d.String("*eol") == "" {
|
if d.String("*eol") == "" {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ItemStatCostRecord represents a row from itemstatcost.txt
|
// ItemStatCostRecord represents a row from itemstatcost.txt
|
||||||
|
@ -108,7 +108,7 @@ var ItemStatCosts map[string]*ItemStatCostRecord
|
||||||
func LoadItemStatCosts(file []byte) {
|
func LoadItemStatCosts(file []byte) {
|
||||||
ItemStatCosts = make(map[string]*ItemStatCostRecord)
|
ItemStatCosts = make(map[string]*ItemStatCostRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &ItemStatCostRecord{
|
record := &ItemStatCostRecord{
|
||||||
Name: d.String("Stat"),
|
Name: d.String("Stat"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelMazeDetailsRecord is a representation of a row from lvlmaze.txt
|
// LevelMazeDetailsRecord is a representation of a row from lvlmaze.txt
|
||||||
|
@ -43,7 +43,7 @@ var LevelMazeDetails map[int]*LevelMazeDetailsRecord //nolint:gochecknoglobals /
|
||||||
func LoadLevelMazeDetails(file []byte) {
|
func LoadLevelMazeDetails(file []byte) {
|
||||||
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord)
|
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &LevelMazeDetailsRecord{
|
record := &LevelMazeDetailsRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelPresetRecord is a representation of a row from lvlprest.txt
|
// LevelPresetRecord is a representation of a row from lvlprest.txt
|
||||||
|
@ -41,21 +40,21 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
|
||||||
}
|
}
|
||||||
result := LevelPresetRecord{
|
result := LevelPresetRecord{
|
||||||
Name: props[inc()],
|
Name: props[inc()],
|
||||||
DefinitionID: d2common.StringToInt(props[inc()]),
|
DefinitionID: d2util.StringToInt(props[inc()]),
|
||||||
LevelID: d2common.StringToInt(props[inc()]),
|
LevelID: d2util.StringToInt(props[inc()]),
|
||||||
Populate: d2common.StringToUint8(props[inc()]) == 1,
|
Populate: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Logicals: d2common.StringToUint8(props[inc()]) == 1,
|
Logicals: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Outdoors: d2common.StringToUint8(props[inc()]) == 1,
|
Outdoors: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Animate: d2common.StringToUint8(props[inc()]) == 1,
|
Animate: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
KillEdge: d2common.StringToUint8(props[inc()]) == 1,
|
KillEdge: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
FillBlanks: d2common.StringToUint8(props[inc()]) == 1,
|
FillBlanks: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SizeX: d2common.StringToInt(props[inc()]),
|
SizeX: d2util.StringToInt(props[inc()]),
|
||||||
SizeY: d2common.StringToInt(props[inc()]),
|
SizeY: d2util.StringToInt(props[inc()]),
|
||||||
AutoMap: d2common.StringToUint8(props[inc()]) == 1,
|
AutoMap: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Scan: d2common.StringToUint8(props[inc()]) == 1,
|
Scan: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Pops: d2common.StringToInt(props[inc()]),
|
Pops: d2util.StringToInt(props[inc()]),
|
||||||
PopPad: d2common.StringToInt(props[inc()]),
|
PopPad: d2util.StringToInt(props[inc()]),
|
||||||
FileCount: d2common.StringToInt(props[inc()]),
|
FileCount: d2util.StringToInt(props[inc()]),
|
||||||
Files: [6]string{
|
Files: [6]string{
|
||||||
props[inc()],
|
props[inc()],
|
||||||
props[inc()],
|
props[inc()],
|
||||||
|
@ -64,9 +63,9 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
|
||||||
props[inc()],
|
props[inc()],
|
||||||
props[inc()],
|
props[inc()],
|
||||||
},
|
},
|
||||||
Dt1Mask: d2common.StringToUint(props[inc()]),
|
Dt1Mask: d2util.StringToUint(props[inc()]),
|
||||||
Beta: d2common.StringToUint8(props[inc()]) == 1,
|
Beta: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Expansion: d2common.StringToUint8(props[inc()]) == 1,
|
Expansion: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelSubstitutionRecord is a representation of a row from lvlsub.txt
|
// LevelSubstitutionRecord is a representation of a row from lvlsub.txt
|
||||||
|
@ -72,7 +72,7 @@ var LevelSubstitutions map[int]*LevelSubstitutionRecord
|
||||||
func LoadLevelSubstitutions(file []byte) {
|
func LoadLevelSubstitutions(file []byte) {
|
||||||
LevelSubstitutions = make(map[int]*LevelSubstitutionRecord)
|
LevelSubstitutions = make(map[int]*LevelSubstitutionRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &LevelSubstitutionRecord{
|
record := &LevelSubstitutionRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelTypeRecord is a representation of a row from lvltype.txt
|
// LevelTypeRecord is a representation of a row from lvltype.txt
|
||||||
|
@ -45,7 +44,7 @@ func LoadLevelTypes(file []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelTypes[j].Name = parts[inc()]
|
LevelTypes[j].Name = parts[inc()]
|
||||||
LevelTypes[j].ID = d2common.StringToInt(parts[inc()])
|
LevelTypes[j].ID = d2util.StringToInt(parts[inc()])
|
||||||
|
|
||||||
for fileIdx := range LevelTypes[i].Files {
|
for fileIdx := range LevelTypes[i].Files {
|
||||||
LevelTypes[j].Files[fileIdx] = parts[inc()]
|
LevelTypes[j].Files[fileIdx] = parts[inc()]
|
||||||
|
@ -55,7 +54,7 @@ func LoadLevelTypes(file []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelTypes[j].Beta = parts[inc()] != "1"
|
LevelTypes[j].Beta = parts[inc()] != "1"
|
||||||
LevelTypes[j].Act = d2common.StringToInt(parts[inc()])
|
LevelTypes[j].Act = d2util.StringToInt(parts[inc()])
|
||||||
LevelTypes[j].Expansion = parts[inc()] != "1"
|
LevelTypes[j].Expansion = parts[inc()] != "1"
|
||||||
}
|
}
|
||||||
log.Printf("Loaded %d LevelType records", len(LevelTypes))
|
log.Printf("Loaded %d LevelType records", len(LevelTypes))
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelWarpRecord is a representation of a row from lvlwarp.txt
|
// LevelWarpRecord is a representation of a row from lvlwarp.txt
|
||||||
|
@ -32,7 +32,7 @@ var LevelWarps map[int]*LevelWarpRecord
|
||||||
func LoadLevelWarps(file []byte) {
|
func LoadLevelWarps(file []byte) {
|
||||||
LevelWarps = make(map[int]*LevelWarpRecord)
|
LevelWarps = make(map[int]*LevelWarpRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &LevelWarpRecord{
|
record := &LevelWarpRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LevelDetailsRecord is a representation of a row from levels.txt
|
// LevelDetailsRecord is a representation of a row from levels.txt
|
||||||
|
@ -383,7 +383,7 @@ func GetLevelDetails(id int) *LevelDetailsRecord {
|
||||||
func LoadLevelDetails(file []byte) {
|
func LoadLevelDetails(file []byte) {
|
||||||
LevelDetails = make(map[int]*LevelDetailsRecord)
|
LevelDetails = make(map[int]*LevelDetailsRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &LevelDetailsRecord{
|
record := &LevelDetailsRecord{
|
||||||
Name: d.String("Name "),
|
Name: d.String("Name "),
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func mapHeaders(line string) map[string]int {
|
func mapHeaders(line string) map[string]int {
|
||||||
|
@ -20,7 +19,7 @@ func mapHeaders(line string) map[string]int {
|
||||||
func mapLoadInt(r *[]string, mapping map[string]int, field string) int {
|
func mapLoadInt(r *[]string, mapping map[string]int, field string) int {
|
||||||
index, ok := (mapping)[field]
|
index, ok := (mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
|
return d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty((*r)[index])))
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -29,7 +28,7 @@ func mapLoadInt(r *[]string, mapping map[string]int, field string) int {
|
||||||
func mapLoadString(r *[]string, mapping map[string]int, field string) string {
|
func mapLoadString(r *[]string, mapping map[string]int, field string) string {
|
||||||
index, ok := (mapping)[field]
|
index, ok := (mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return d2common.AsterToEmpty((*r)[index])
|
return d2util.AsterToEmpty((*r)[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
@ -42,7 +41,7 @@ func mapLoadBool(r *[]string, mapping map[string]int, field string) bool {
|
||||||
func mapLoadUint8(r *[]string, mapping map[string]int, field string) uint8 {
|
func mapLoadUint8(r *[]string, mapping map[string]int, field string) uint8 {
|
||||||
index, ok := (mapping)[field]
|
index, ok := (mapping)[field]
|
||||||
if ok {
|
if ok {
|
||||||
return d2common.StringToUint8(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
|
return d2util.StringToUint8(d2util.EmptyToZero(d2util.AsterToEmpty((*r)[index])))
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MissileCalcParam is a calculation parameter for a missile
|
// MissileCalcParam is a calculation parameter for a missile
|
||||||
|
@ -15,7 +16,7 @@ type MissileCalcParam struct {
|
||||||
|
|
||||||
// MissileCalc is a calculation for a missile
|
// MissileCalc is a calculation for a missile
|
||||||
type MissileCalc struct {
|
type MissileCalc struct {
|
||||||
Calc d2common.CalcString
|
Calc d2calculation.CalcString
|
||||||
Desc string
|
Desc string
|
||||||
Params []MissileCalcParam
|
Params []MissileCalcParam
|
||||||
}
|
}
|
||||||
|
@ -65,8 +66,8 @@ type MissileDamage struct {
|
||||||
MaxDamage int
|
MaxDamage int
|
||||||
MinLevelDamage [5]int // additional damage per missile level
|
MinLevelDamage [5]int // additional damage per missile level
|
||||||
// [0]: lvs 2-8, [1]: lvs 9-16, [2]: lvs 17-22, [3]: lvs 23-28, [4]: lv 29+
|
// [0]: lvs 2-8, [1]: lvs 9-16, [2]: lvs 17-22, [3]: lvs 23-28, [4]: lv 29+
|
||||||
MaxLevelDamage [5]int // see above
|
MaxLevelDamage [5]int // see above
|
||||||
DamageSynergyPerCalc d2common.CalcString // works like synergy in skills.txt, not clear
|
DamageSynergyPerCalc d2calculation.CalcString // works like synergy in skills.txt, not clear
|
||||||
}
|
}
|
||||||
|
|
||||||
// MissileElementalDamage parameters for calculating missile elemental damage
|
// MissileElementalDamage parameters for calculating missile elemental damage
|
||||||
|
@ -211,13 +212,13 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
// be wrapped in an d2common.EmptyToZero transform
|
// be wrapped in an d2common.EmptyToZero transform
|
||||||
result := MissileRecord{
|
result := MissileRecord{
|
||||||
Name: r[inc()],
|
Name: r[inc()],
|
||||||
Id: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Id: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
ClientMovementFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
ClientMovementFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
|
||||||
ClientCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
ClientCollisionFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
|
||||||
ServerMovementFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
ServerMovementFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
|
||||||
ServerCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
ServerCollisionFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
|
||||||
ServerDamageFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
|
ServerDamageFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
|
||||||
|
|
||||||
ServerMovementCalc: loadMissileCalc(&r, inc, 5),
|
ServerMovementCalc: loadMissileCalc(&r, inc, 5),
|
||||||
ClientMovementCalc: loadMissileCalc(&r, inc, 5),
|
ClientMovementCalc: loadMissileCalc(&r, inc, 5),
|
||||||
|
@ -225,12 +226,12 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
ClientCollisionCalc: loadMissileCalc(&r, inc, 3),
|
ClientCollisionCalc: loadMissileCalc(&r, inc, 3),
|
||||||
ServerDamageCalc: loadMissileCalc(&r, inc, 2),
|
ServerDamageCalc: loadMissileCalc(&r, inc, 2),
|
||||||
|
|
||||||
Velocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Velocity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
MaxVelocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
MaxVelocity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
LevelVelocityBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
LevelVelocityBonus: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
Accel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Accel: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
Range: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Range: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
LevelRangeBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
LevelRangeBonus: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
Light: loadMissileLight(&r, inc),
|
Light: loadMissileLight(&r, inc),
|
||||||
|
|
||||||
|
@ -238,54 +239,54 @@ func createMissileRecord(line string) MissileRecord {
|
||||||
|
|
||||||
Collision: loadMissileCollision(&r, inc),
|
Collision: loadMissileCollision(&r, inc),
|
||||||
|
|
||||||
XOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
XOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
YOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
YOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
ZOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
ZOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
Size: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Size: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
DestroyedByTP: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
DestroyedByTP: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
DestroyedByTPFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
DestroyedByTPFrame: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
CanDestroy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
CanDestroy: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
UseAttackRating: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
UseAttackRating: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
AlwaysExplode: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
AlwaysExplode: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
ClientExplosion: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
ClientExplosion: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
TownSafe: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
TownSafe: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
IgnoreBossModifiers: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
IgnoreBossModifiers: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
IgnoreMultishot: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
IgnoreMultishot: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
HolyFilterType: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
HolyFilterType: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
CanBeSlowed: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
CanBeSlowed: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
TriggersHitEvents: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
TriggersHitEvents: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
TriggersGetHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
TriggersGetHit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
SoftHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
SoftHit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
KnockbackPercent: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
KnockbackPercent: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
TransparencyMode: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
TransparencyMode: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
UseQuantity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
UseQuantity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
AffectedByPierce: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
AffectedByPierce: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
SpecialSetup: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
SpecialSetup: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
MissileSkill: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
MissileSkill: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
SkillName: r[inc()],
|
SkillName: r[inc()],
|
||||||
|
|
||||||
ResultFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
ResultFlags: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
HitFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
HitFlags: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
HitShift: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
HitShift: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
ApplyMastery: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
ApplyMastery: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
SourceDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
SourceDamage: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
HalfDamageForTwoHander: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
HalfDamageForTwoHander: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
SourceMissDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
SourceMissDamage: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
Damage: loadMissileDamage(&r, inc),
|
Damage: loadMissileDamage(&r, inc),
|
||||||
ElementalDamage: loadMissileElementalDamage(&r, inc),
|
ElementalDamage: loadMissileElementalDamage(&r, inc),
|
||||||
|
|
||||||
HitClass: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
HitClass: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
NumDirections: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
NumDirections: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
LocalBlood: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
LocalBlood: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
DamageReductionRate: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
DamageReductionRate: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
TravelSound: r[inc()],
|
TravelSound: r[inc()],
|
||||||
HitSound: r[inc()],
|
HitSound: r[inc()],
|
||||||
|
@ -325,7 +326,7 @@ func LoadMissiles(file []byte) {
|
||||||
|
|
||||||
func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
|
func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
|
||||||
result := MissileCalcParam{
|
result := MissileCalcParam{
|
||||||
Param: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Param: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Desc: (*r)[inc()],
|
Desc: (*r)[inc()],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +335,7 @@ func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
|
||||||
|
|
||||||
func loadMissileCalc(r *[]string, inc func() int, params int) MissileCalc {
|
func loadMissileCalc(r *[]string, inc func() int, params int) MissileCalc {
|
||||||
result := MissileCalc{
|
result := MissileCalc{
|
||||||
Calc: d2common.CalcString((*r)[inc()]),
|
Calc: d2calculation.CalcString((*r)[inc()]),
|
||||||
Desc: (*r)[inc()],
|
Desc: (*r)[inc()],
|
||||||
}
|
}
|
||||||
result.Params = make([]MissileCalcParam, params)
|
result.Params = make([]MissileCalcParam, params)
|
||||||
|
@ -348,11 +349,11 @@ func loadMissileCalc(r *[]string, inc func() int, params int) MissileCalc {
|
||||||
|
|
||||||
func loadMissileLight(r *[]string, inc func() int) MissileLight {
|
func loadMissileLight(r *[]string, inc func() int) MissileLight {
|
||||||
result := MissileLight{
|
result := MissileLight{
|
||||||
Diameter: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Diameter: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Flicker: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Flicker: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Red: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
Red: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Green: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
Green: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Blue: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
|
Blue: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -360,17 +361,17 @@ func loadMissileLight(r *[]string, inc func() int) MissileLight {
|
||||||
|
|
||||||
func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
|
func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
|
||||||
result := MissileAnimation{
|
result := MissileAnimation{
|
||||||
StepsBeforeVisible: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
StepsBeforeVisible: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
StepsBeforeActive: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
StepsBeforeActive: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
LoopAnimation: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
LoopAnimation: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
CelFileName: (*r)[inc()],
|
CelFileName: (*r)[inc()],
|
||||||
AnimationRate: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
AnimationRate: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
AnimationLength: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
AnimationLength: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
AnimationSpeed: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
AnimationSpeed: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
StartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
StartingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
HasSubLoop: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
HasSubLoop: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
SubStartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
SubStartingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
SubEndingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
SubEndingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -378,15 +379,15 @@ func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
|
||||||
|
|
||||||
func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
|
func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
|
||||||
result := MissileCollision{
|
result := MissileCollision{
|
||||||
CollisionType: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
CollisionType: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
DestroyedUponCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
DestroyedUponCollision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
FriendlyFire: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
FriendlyFire: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
LastCollide: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
LastCollide: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
Collision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
Collision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
ClientCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
ClientCollision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
ClientSend: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
ClientSend: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
UseCollisionTimer: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
|
UseCollisionTimer: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
|
||||||
TimerFrames: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
TimerFrames: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -394,23 +395,23 @@ func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
|
||||||
|
|
||||||
func loadMissileDamage(r *[]string, inc func() int) MissileDamage {
|
func loadMissileDamage(r *[]string, inc func() int) MissileDamage {
|
||||||
result := MissileDamage{
|
result := MissileDamage{
|
||||||
MinDamage: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
MinDamage: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
MinLevelDamage: [5]int{
|
MinLevelDamage: [5]int{
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
MaxDamage: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
MaxDamage: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
MaxLevelDamage: [5]int{
|
MaxLevelDamage: [5]int{
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
DamageSynergyPerCalc: d2common.CalcString((*r)[inc()]),
|
DamageSynergyPerCalc: d2calculation.CalcString((*r)[inc()]),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -420,11 +421,11 @@ func loadMissileElementalDamage(r *[]string, inc func() int) MissileElementalDam
|
||||||
result := MissileElementalDamage{
|
result := MissileElementalDamage{
|
||||||
ElementType: (*r)[inc()],
|
ElementType: (*r)[inc()],
|
||||||
Damage: loadMissileDamage(r, inc),
|
Damage: loadMissileDamage(r, inc),
|
||||||
Duration: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Duration: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
LevelDuration: [3]int{
|
LevelDuration: [3]int{
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonModeRecord is a representation of a single row of Monmode.txt
|
// MonModeRecord is a representation of a single row of Monmode.txt
|
||||||
|
@ -20,7 +20,7 @@ var MonModes map[string]*MonModeRecord //nolint:gochecknoglobals // Currently gl
|
||||||
func LoadMonModes(file []byte) {
|
func LoadMonModes(file []byte) {
|
||||||
MonModes = make(map[string]*MonModeRecord)
|
MonModes = make(map[string]*MonModeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonModeRecord{
|
record := &MonModeRecord{
|
||||||
Name: d.String("name"),
|
Name: d.String("name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonPresets stores monster presets
|
// MonPresets stores monster presets
|
||||||
|
@ -14,7 +14,7 @@ var MonPresets map[int32][]string
|
||||||
func LoadMonPresets(file []byte) {
|
func LoadMonPresets(file []byte) {
|
||||||
MonPresets = make(map[int32][]string)
|
MonPresets = make(map[int32][]string)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
act := int32(d.Number("Act"))
|
act := int32(d.Number("Act"))
|
||||||
if _, ok := MonPresets[act]; !ok {
|
if _, ok := MonPresets[act]; !ok {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -45,7 +45,7 @@ var MonProps map[string]*MonPropRecord //nolint:gochecknoglobals // Currently gl
|
||||||
func LoadMonProps(file []byte) {
|
func LoadMonProps(file []byte) {
|
||||||
MonProps = make(map[string]*MonPropRecord)
|
MonProps = make(map[string]*MonPropRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonPropRecord{
|
record := &MonPropRecord{
|
||||||
ID: d.String("Id"),
|
ID: d.String("Id"),
|
||||||
|
|
|
@ -4,8 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://d2mods.info/forum/kb/viewarticle?a=360
|
// https://d2mods.info/forum/kb/viewarticle?a=360
|
||||||
|
@ -687,7 +686,7 @@ var MonStats map[string]*MonStatsRecord //nolint:gochecknoglobals // Currently g
|
||||||
func LoadMonStats(file []byte) { // nolint:funlen // Makes no sense to split
|
func LoadMonStats(file []byte) { // nolint:funlen // Makes no sense to split
|
||||||
MonStats = make(map[string]*MonStatsRecord)
|
MonStats = make(map[string]*MonStatsRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonStatsRecord{
|
record := &MonStatsRecord{
|
||||||
Key: d.String("Id"),
|
Key: d.String("Id"),
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonStats2Record is a representation of a row from monstats2.txt
|
// MonStats2Record is a representation of a row from monstats2.txt
|
||||||
|
@ -174,7 +174,7 @@ var MonStats2 map[string]*MonStats2Record
|
||||||
func LoadMonStats2(file []byte) {
|
func LoadMonStats2(file []byte) {
|
||||||
MonStats2 = make(map[string]*MonStats2Record)
|
MonStats2 = make(map[string]*MonStats2Record)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonStats2Record{
|
record := &MonStats2Record{
|
||||||
Key: d.String("Id"),
|
Key: d.String("Id"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonsterAIRecord represents a single row from monai.txt
|
// MonsterAIRecord represents a single row from monai.txt
|
||||||
|
@ -18,7 +18,7 @@ var MonsterAI map[string]*MonsterAIRecord //nolint:gochecknoglobals // Currently
|
||||||
func LoadMonsterAI(file []byte) {
|
func LoadMonsterAI(file []byte) {
|
||||||
MonsterAI = make(map[string]*MonsterAIRecord)
|
MonsterAI = make(map[string]*MonsterAIRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonsterAIRecord{
|
record := &MonsterAIRecord{
|
||||||
AI: d.String("AI"),
|
AI: d.String("AI"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -48,7 +48,7 @@ var MonsterEquipment map[string][]*MonsterEquipmentRecord //nolint:gochecknoglob
|
||||||
func LoadMonsterEquipment(file []byte) {
|
func LoadMonsterEquipment(file []byte) {
|
||||||
MonsterEquipment = make(map[string][]*MonsterEquipmentRecord)
|
MonsterEquipment = make(map[string][]*MonsterEquipmentRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonsterEquipmentRecord{
|
record := &MonsterEquipmentRecord{
|
||||||
Name: d.String("monster"),
|
Name: d.String("monster"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonsterLevelRecord represents a single row in monlvl.txt
|
// MonsterLevelRecord represents a single row in monlvl.txt
|
||||||
|
@ -58,7 +58,7 @@ var MonsterLevels map[int]*MonsterLevelRecord //nolint:gochecknoglobals // Curre
|
||||||
func LoadMonsterLevels(file []byte) {
|
func LoadMonsterLevels(file []byte) {
|
||||||
MonsterLevels = make(map[int]*MonsterLevelRecord)
|
MonsterLevels = make(map[int]*MonsterLevelRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonsterLevelRecord{
|
record := &MonsterLevelRecord{
|
||||||
Level: d.Number("Level"),
|
Level: d.Number("Level"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonsterPlacementRecord represents a line from MonPlace.txt.
|
// MonsterPlacementRecord represents a line from MonPlace.txt.
|
||||||
|
@ -14,7 +14,7 @@ var MonsterPlacements []MonsterPlacementRecord //nolint:gochecknoglobals // Curr
|
||||||
|
|
||||||
// LoadMonsterPlacements loads the MonsterPlacementRecords into MonsterPlacements.
|
// LoadMonsterPlacements loads the MonsterPlacementRecords into MonsterPlacements.
|
||||||
func LoadMonsterPlacements(file []byte) {
|
func LoadMonsterPlacements(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
MonsterPlacements = append(MonsterPlacements, MonsterPlacementRecord(d.String("code")))
|
MonsterPlacements = append(MonsterPlacements, MonsterPlacementRecord(d.String("code")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonsterSequenceRecord contains a record for a monster sequence
|
// MonsterSequenceRecord contains a record for a monster sequence
|
||||||
|
@ -41,7 +41,7 @@ var MonsterSequences map[string]*MonsterSequenceRecord
|
||||||
func LoadMonsterSequences(file []byte) {
|
func LoadMonsterSequences(file []byte) {
|
||||||
MonsterSequences = make(map[string]*MonsterSequenceRecord)
|
MonsterSequences = make(map[string]*MonsterSequenceRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
name := d.String("sequence")
|
name := d.String("sequence")
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Information gathered from [https://d2mods.info/forum/kb/viewarticle?a=418]
|
// Information gathered from [https://d2mods.info/forum/kb/viewarticle?a=418]
|
||||||
|
@ -112,7 +112,7 @@ var MonsterSounds map[string]*MonsterSoundRecord
|
||||||
func LoadMonsterSounds(file []byte) {
|
func LoadMonsterSounds(file []byte) {
|
||||||
MonsterSounds = make(map[string]*MonsterSoundRecord)
|
MonsterSounds = make(map[string]*MonsterSoundRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonsterSoundRecord{
|
record := &MonsterSoundRecord{
|
||||||
ID: d.String("Id"),
|
ID: d.String("Id"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -72,7 +72,7 @@ func LoadMonsterUniqueModifiers(file []byte) {
|
||||||
MonsterUniqueModifiers = make(map[string]*MonsterUniqueModifierRecord)
|
MonsterUniqueModifiers = make(map[string]*MonsterUniqueModifierRecord)
|
||||||
MonsterUniqueModifierConstants = make([]int, 0, numModifierConstants)
|
MonsterUniqueModifierConstants = make([]int, 0, numModifierConstants)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonsterUniqueModifierRecord{
|
record := &MonsterUniqueModifierRecord{
|
||||||
Name: d.String("uniquemod"),
|
Name: d.String("uniquemod"),
|
||||||
|
|
|
@ -2,8 +2,8 @@ package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonTypeRecord is a representation of a single row of MonType.txt.
|
// MonTypeRecord is a representation of a single row of MonType.txt.
|
||||||
|
@ -26,7 +26,7 @@ var MonTypes map[string]*MonTypeRecord //nolint:gochecknoglobals // Currently gl
|
||||||
func LoadMonTypes(file []byte) {
|
func LoadMonTypes(file []byte) {
|
||||||
MonTypes = make(map[string]*MonTypeRecord)
|
MonTypes = make(map[string]*MonTypeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &MonTypeRecord{
|
record := &MonTypeRecord{
|
||||||
Type: d.String("type"),
|
Type: d.String("type"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -47,7 +47,7 @@ var NPCs map[string]*NPCRecord // nolint:gochecknoglobals // Currently global by
|
||||||
func LoadNPCs(file []byte) {
|
func LoadNPCs(file []byte) {
|
||||||
NPCs = make(map[string]*NPCRecord)
|
NPCs = make(map[string]*NPCRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &NPCRecord{
|
record := &NPCRecord{
|
||||||
Name: d.String("npc"),
|
Name: d.String("npc"),
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -58,7 +58,7 @@ var ObjectGroups map[int]*ObjectGroupRecord //nolint:gochecknoglobals // Current
|
||||||
// LoadObjectGroups loads the ObjectGroupRecords into ObjectGroups.
|
// LoadObjectGroups loads the ObjectGroupRecords into ObjectGroups.
|
||||||
func LoadObjectGroups(file []byte) {
|
func LoadObjectGroups(file []byte) {
|
||||||
ObjectGroups = make(map[int]*ObjectGroupRecord)
|
ObjectGroups = make(map[int]*ObjectGroupRecord)
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
groupName := d.String("GroupName")
|
groupName := d.String("GroupName")
|
||||||
|
@ -84,7 +84,7 @@ func LoadObjectGroups(file []byte) {
|
||||||
log.Printf("Loaded %d ObjectGroup records", len(ObjectGroups))
|
log.Printf("Loaded %d ObjectGroup records", len(ObjectGroups))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMembers(d *d2common.DataDictionary, shrinesOrWells bool) *[objectsGroupSize]ObjectGroupMember {
|
func createMembers(d *d2txt.DataDictionary, shrinesOrWells bool) *[objectsGroupSize]ObjectGroupMember {
|
||||||
var members [objectsGroupSize]ObjectGroupMember
|
var members [objectsGroupSize]ObjectGroupMember
|
||||||
|
|
||||||
for i := 0; i < objectsGroupSize; i++ {
|
for i := 0; i < objectsGroupSize; i++ {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectTypeRecord is a representation of a row from objtype.txt
|
// ObjectTypeRecord is a representation of a row from objtype.txt
|
||||||
|
@ -19,7 +19,7 @@ var ObjectTypes []ObjectTypeRecord
|
||||||
|
|
||||||
// LoadObjectTypes loads ObjectTypeRecords from objtype.txt
|
// LoadObjectTypes loads ObjectTypeRecords from objtype.txt
|
||||||
func LoadObjectTypes(objectTypeData []byte) {
|
func LoadObjectTypes(objectTypeData []byte) {
|
||||||
streamReader := d2common.CreateStreamReader(objectTypeData)
|
streamReader := d2datautils.CreateStreamReader(objectTypeData)
|
||||||
count := streamReader.GetInt32()
|
count := streamReader.GetInt32()
|
||||||
ObjectTypes = make([]ObjectTypeRecord, count)
|
ObjectTypes = make([]ObjectTypeRecord, count)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// An ObjectRecord represents the settings for one type of object from objects.txt
|
// An ObjectRecord represents the settings for one type of object from objects.txt
|
||||||
|
@ -130,206 +129,206 @@ func createObjectRecord(props []string) ObjectRecord {
|
||||||
result := ObjectRecord{
|
result := ObjectRecord{
|
||||||
Name: props[inc()],
|
Name: props[inc()],
|
||||||
Description: props[inc()],
|
Description: props[inc()],
|
||||||
id: d2common.StringToInt(props[inc()]),
|
id: d2util.StringToInt(props[inc()]),
|
||||||
token: props[inc()],
|
token: props[inc()],
|
||||||
|
|
||||||
SpawnMax: d2common.StringToInt(props[inc()]),
|
SpawnMax: d2util.StringToInt(props[inc()]),
|
||||||
Selectable: [8]bool{
|
Selectable: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
TrapProbability: d2common.StringToInt(props[inc()]),
|
TrapProbability: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
SizeX: d2common.StringToInt(props[inc()]),
|
SizeX: d2util.StringToInt(props[inc()]),
|
||||||
SizeY: d2common.StringToInt(props[inc()]),
|
SizeY: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
NTgtFX: d2common.StringToInt(props[inc()]),
|
NTgtFX: d2util.StringToInt(props[inc()]),
|
||||||
NTgtFY: d2common.StringToInt(props[inc()]),
|
NTgtFY: d2util.StringToInt(props[inc()]),
|
||||||
NTgtBX: d2common.StringToInt(props[inc()]),
|
NTgtBX: d2util.StringToInt(props[inc()]),
|
||||||
NTgtBY: d2common.StringToInt(props[inc()]),
|
NTgtBY: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
FrameCount: [8]int{
|
FrameCount: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
FrameDelta: [8]int{
|
FrameDelta: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
CycleAnimation: [8]bool{
|
CycleAnimation: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
LightDiameter: [8]int{
|
LightDiameter: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
BlocksLight: [8]bool{
|
BlocksLight: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
HasCollision: [8]bool{
|
HasCollision: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
IsAttackable: d2common.StringToUint8(props[inc()]) == 1,
|
IsAttackable: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
StartFrame: [8]int{
|
StartFrame: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
|
|
||||||
EnvEffect: d2common.StringToUint8(props[inc()]) == 1,
|
EnvEffect: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
IsDoor: d2common.StringToUint8(props[inc()]) == 1,
|
IsDoor: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
BlockVisibility: d2common.StringToUint8(props[inc()]) == 1,
|
BlockVisibility: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Orientation: d2common.StringToInt(props[inc()]),
|
Orientation: d2util.StringToInt(props[inc()]),
|
||||||
Trans: d2common.StringToInt(props[inc()]),
|
Trans: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
OrderFlag: [8]int{
|
OrderFlag: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
PreOperate: d2common.StringToUint8(props[inc()]) == 1,
|
PreOperate: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
HasAnimationMode: [8]bool{
|
HasAnimationMode: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
XOffset: d2common.StringToInt(props[inc()]),
|
XOffset: d2util.StringToInt(props[inc()]),
|
||||||
YOffset: d2common.StringToInt(props[inc()]),
|
YOffset: d2util.StringToInt(props[inc()]),
|
||||||
Draw: d2common.StringToUint8(props[inc()]) == 1,
|
Draw: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
LightRed: d2common.StringToUint8(props[inc()]),
|
LightRed: d2util.StringToUint8(props[inc()]),
|
||||||
LightGreen: d2common.StringToUint8(props[inc()]),
|
LightGreen: d2util.StringToUint8(props[inc()]),
|
||||||
LightBlue: d2common.StringToUint8(props[inc()]),
|
LightBlue: d2util.StringToUint8(props[inc()]),
|
||||||
|
|
||||||
SelHD: d2common.StringToUint8(props[inc()]) == 1,
|
SelHD: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelTR: d2common.StringToUint8(props[inc()]) == 1,
|
SelTR: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelLG: d2common.StringToUint8(props[inc()]) == 1,
|
SelLG: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelRA: d2common.StringToUint8(props[inc()]) == 1,
|
SelRA: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelLA: d2common.StringToUint8(props[inc()]) == 1,
|
SelLA: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelRH: d2common.StringToUint8(props[inc()]) == 1,
|
SelRH: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelLH: d2common.StringToUint8(props[inc()]) == 1,
|
SelLH: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelSH: d2common.StringToUint8(props[inc()]) == 1,
|
SelSH: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
SelS: [8]bool{
|
SelS: [8]bool{
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
d2common.StringToUint8(props[inc()]) == 1,
|
d2util.StringToUint8(props[inc()]) == 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
TotalPieces: d2common.StringToInt(props[inc()]),
|
TotalPieces: d2util.StringToInt(props[inc()]),
|
||||||
SubClass: d2common.StringToInt(props[inc()]),
|
SubClass: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
XSpace: d2common.StringToInt(props[inc()]),
|
XSpace: d2util.StringToInt(props[inc()]),
|
||||||
YSpace: d2common.StringToInt(props[inc()]),
|
YSpace: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
NameOffset: d2common.StringToInt(props[inc()]),
|
NameOffset: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
MonsterOk: d2common.StringToUint8(props[inc()]) == 1,
|
MonsterOk: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
OperateRange: d2common.StringToInt(props[inc()]),
|
OperateRange: d2util.StringToInt(props[inc()]),
|
||||||
ShrineFunction: d2common.StringToInt(props[inc()]),
|
ShrineFunction: d2util.StringToInt(props[inc()]),
|
||||||
Restore: d2common.StringToUint8(props[inc()]) == 1,
|
Restore: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
Parm: [8]int{
|
Parm: [8]int{
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
d2common.StringToInt(props[inc()]),
|
d2util.StringToInt(props[inc()]),
|
||||||
},
|
},
|
||||||
Act: d2common.StringToInt(props[inc()]),
|
Act: d2util.StringToInt(props[inc()]),
|
||||||
Lockable: d2common.StringToUint8(props[inc()]) == 1,
|
Lockable: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Gore: d2common.StringToUint8(props[inc()]) == 1,
|
Gore: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Sync: d2common.StringToUint8(props[inc()]) == 1,
|
Sync: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Flicker: d2common.StringToUint8(props[inc()]) == 1,
|
Flicker: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Damage: d2common.StringToInt(props[inc()]),
|
Damage: d2util.StringToInt(props[inc()]),
|
||||||
Beta: d2common.StringToUint8(props[inc()]) == 1,
|
Beta: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
Overlay: d2common.StringToUint8(props[inc()]) == 1,
|
Overlay: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
CollisionSubst: d2common.StringToUint8(props[inc()]) == 1,
|
CollisionSubst: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
Left: d2common.StringToInt(props[inc()]),
|
Left: d2util.StringToInt(props[inc()]),
|
||||||
Top: d2common.StringToInt(props[inc()]),
|
Top: d2util.StringToInt(props[inc()]),
|
||||||
Width: d2common.StringToInt(props[inc()]),
|
Width: d2util.StringToInt(props[inc()]),
|
||||||
Height: d2common.StringToInt(props[inc()]),
|
Height: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
OperateFn: d2common.StringToInt(props[inc()]),
|
OperateFn: d2util.StringToInt(props[inc()]),
|
||||||
PopulateFn: d2common.StringToInt(props[inc()]),
|
PopulateFn: d2util.StringToInt(props[inc()]),
|
||||||
InitFn: d2common.StringToInt(props[inc()]),
|
InitFn: d2util.StringToInt(props[inc()]),
|
||||||
ClientFn: d2common.StringToInt(props[inc()]),
|
ClientFn: d2util.StringToInt(props[inc()]),
|
||||||
|
|
||||||
RestoreVirgins: d2common.StringToUint8(props[inc()]) == 1,
|
RestoreVirgins: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
BlockMissile: d2common.StringToUint8(props[inc()]) == 1,
|
BlockMissile: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
DrawUnder: d2common.StringToUint8(props[inc()]) == 1,
|
DrawUnder: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
OpenWarp: d2common.StringToUint8(props[inc()]) == 1,
|
OpenWarp: d2util.StringToUint8(props[inc()]) == 1,
|
||||||
|
|
||||||
AutoMap: d2common.StringToInt(props[inc()]),
|
AutoMap: d2util.StringToInt(props[inc()]),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The information has been gathered from [https://d2mods.info/forum/kb/viewarticle?a=465]
|
// The information has been gathered from [https://d2mods.info/forum/kb/viewarticle?a=465]
|
||||||
|
@ -67,7 +67,7 @@ var Overlays map[string]*OverlayRecord // nolint:gochecknoglobals // Currently g
|
||||||
// LoadOverlays loads overlay records from Overlay.txt
|
// LoadOverlays loads overlay records from Overlay.txt
|
||||||
func LoadOverlays(file []byte) {
|
func LoadOverlays(file []byte) {
|
||||||
Overlays = make(map[string]*OverlayRecord)
|
Overlays = make(map[string]*OverlayRecord)
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &OverlayRecord{
|
record := &OverlayRecord{
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PetTypeRecord represents a single line in PetType.txt
|
// PetTypeRecord represents a single line in PetType.txt
|
||||||
|
@ -68,7 +68,7 @@ var PetTypes map[string]*PetTypeRecord // nolint:gochecknoglobals // Currently g
|
||||||
func LoadPetTypes(file []byte) {
|
func LoadPetTypes(file []byte) {
|
||||||
PetTypes = make(map[string]*PetTypeRecord)
|
PetTypes = make(map[string]*PetTypeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &PetTypeRecord{
|
record := &PetTypeRecord{
|
||||||
Name: d.String("pet type"),
|
Name: d.String("pet type"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PlayerClassRecord represents a single line from PlayerClass.txt
|
// PlayerClassRecord represents a single line from PlayerClass.txt
|
||||||
|
@ -23,7 +23,7 @@ var PlayerClasses map[string]*PlayerClassRecord // nolint:gochecknoglobals // Cu
|
||||||
func LoadPlayerClasses(file []byte) {
|
func LoadPlayerClasses(file []byte) {
|
||||||
PlayerClasses = make(map[string]*PlayerClassRecord)
|
PlayerClasses = make(map[string]*PlayerClassRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &PlayerClassRecord{
|
record := &PlayerClassRecord{
|
||||||
Name: d.String("Player Class"),
|
Name: d.String("Player Class"),
|
||||||
|
|
|
@ -2,8 +2,8 @@ package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PlrModeRecord represents a single line in PlrMode.txt
|
// PlrModeRecord represents a single line in PlrMode.txt
|
||||||
|
@ -22,7 +22,7 @@ var PlrModes map[string]*PlrModeRecord //nolint:gochecknoglobals // Currently gl
|
||||||
func LoadPlrModes(file []byte) {
|
func LoadPlrModes(file []byte) {
|
||||||
PlrModes = make(map[string]*PlrModeRecord)
|
PlrModes = make(map[string]*PlrModeRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &PlrModeRecord{
|
record := &PlrModeRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PropertyStatRecord contains stat information for a property
|
// PropertyStatRecord contains stat information for a property
|
||||||
|
@ -28,7 +28,7 @@ var Properties map[string]*PropertyRecord //nolint:gochecknoglobals // Currently
|
||||||
func LoadProperties(file []byte) {
|
func LoadProperties(file []byte) {
|
||||||
Properties = make(map[string]*PropertyRecord)
|
Properties = make(map[string]*PropertyRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
prop := &PropertyRecord{
|
prop := &PropertyRecord{
|
||||||
Code: d.String("code"),
|
Code: d.String("code"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QualityRecord represents a single row of QualityItems.txt, which controls
|
// QualityRecord represents a single row of QualityItems.txt, which controls
|
||||||
|
@ -46,7 +46,7 @@ var QualityItems map[string]*QualityRecord //nolint:gochecknoglobals // Currentl
|
||||||
func LoadQualityItems(file []byte) {
|
func LoadQualityItems(file []byte) {
|
||||||
QualityItems = make(map[string]*QualityRecord)
|
QualityItems = make(map[string]*QualityRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
qual := &QualityRecord{
|
qual := &QualityRecord{
|
||||||
NumMods: d.Number("nummods"),
|
NumMods: d.Number("nummods"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -27,7 +27,7 @@ var RarePrefixes []*RareItemPrefixRecord // nolint:gochecknoglobals // global by
|
||||||
|
|
||||||
// LoadRareItemPrefixRecords loads the rare item prefix records from rareprefix.txt
|
// LoadRareItemPrefixRecords loads the rare item prefix records from rareprefix.txt
|
||||||
func LoadRareItemPrefixRecords(file []byte) {
|
func LoadRareItemPrefixRecords(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
RarePrefixes = make([]*RareItemPrefixRecord, 0)
|
RarePrefixes = make([]*RareItemPrefixRecord, 0)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -27,7 +27,7 @@ var RareSuffixes []*RareItemSuffixRecord // nolint:gochecknoglobals // global by
|
||||||
|
|
||||||
// LoadRareItemSuffixRecords loads the rare item suffix records from raresuffix.txt
|
// LoadRareItemSuffixRecords loads the rare item suffix records from raresuffix.txt
|
||||||
func LoadRareItemSuffixRecords(file []byte) {
|
func LoadRareItemSuffixRecords(file []byte) {
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
RareSuffixes = make([]*RareItemSuffixRecord, 0)
|
RareSuffixes = make([]*RareItemSuffixRecord, 0)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -67,7 +67,7 @@ var Runewords map[string]*RunesRecord //nolint:gochecknoglobals // Currently glo
|
||||||
func LoadRunewords(file []byte) {
|
func LoadRunewords(file []byte) {
|
||||||
Runewords = make(map[string]*RunesRecord)
|
Runewords = make(map[string]*RunesRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &RunesRecord{
|
record := &RunesRecord{
|
||||||
Name: d.String("name"),
|
Name: d.String("name"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -133,7 +133,7 @@ var SetItems map[string]*SetItemRecord //nolint:gochecknoglobals // Currently gl
|
||||||
func LoadSetItems(file []byte) {
|
func LoadSetItems(file []byte) {
|
||||||
SetItems = make(map[string]*SetItemRecord)
|
SetItems = make(map[string]*SetItemRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &SetItemRecord{
|
record := &SetItemRecord{
|
||||||
|
|
|
@ -3,8 +3,8 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -79,7 +79,7 @@ var SetRecords map[string]*SetRecord //nolint:gochecknoglobals // Currently glob
|
||||||
func LoadSetRecords(file []byte) { //nolint:funlen // doesn't make sense to split
|
func LoadSetRecords(file []byte) { //nolint:funlen // doesn't make sense to split
|
||||||
SetRecords = make(map[string]*SetRecord)
|
SetRecords = make(map[string]*SetRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &SetRecord{
|
record := &SetRecord{
|
||||||
Key: d.String("index"),
|
Key: d.String("index"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShrineRecord is a representation of a row from shrines.txt
|
// ShrineRecord is a representation of a row from shrines.txt
|
||||||
|
@ -29,7 +29,7 @@ var Shrines map[string]*ShrineRecord
|
||||||
func LoadShrines(file []byte) {
|
func LoadShrines(file []byte) {
|
||||||
Shrines = make(map[string]*ShrineRecord)
|
Shrines = make(map[string]*ShrineRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &ShrineRecord{
|
record := &ShrineRecord{
|
||||||
ShrineType: d.String("Shrine Type"),
|
ShrineType: d.String("Shrine Type"),
|
||||||
|
|
|
@ -3,9 +3,9 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation/d2parser"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation/d2parser"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SkillDescriptionRecord is a single row from skilldesc.txt and is used for
|
// SkillDescriptionRecord is a single row from skilldesc.txt and is used for
|
||||||
|
@ -137,7 +137,7 @@ func LoadSkillDescriptions(file []byte) { //nolint:funlen // doesn't make sense
|
||||||
parser := d2parser.New()
|
parser := d2parser.New()
|
||||||
parser.SetCurrentReference("skill", "TODO: connect skill with description!") //nolint:godox // TODO: Connect skill with description.
|
parser.SetCurrentReference("skill", "TODO: connect skill with description!") //nolint:godox // TODO: Connect skill with description.
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &SkillDescriptionRecord{
|
record := &SkillDescriptionRecord{
|
||||||
d.String("skilldesc"),
|
d.String("skilldesc"),
|
||||||
|
|
|
@ -3,9 +3,9 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation/d2parser"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation/d2parser"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SkillDetails has all of the SkillRecords
|
// SkillDetails has all of the SkillRecords
|
||||||
|
@ -266,7 +266,7 @@ func LoadSkills(file []byte) {
|
||||||
|
|
||||||
parser := d2parser.New()
|
parser := d2parser.New()
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
name := d.String("skill")
|
name := d.String("skill")
|
||||||
parser.SetCurrentReference("skill", name)
|
parser.SetCurrentReference("skill", name)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SoundEnvironRecord describes the different sound environments. Not listed on Phrozen Keep.
|
// SoundEnvironRecord describes the different sound environments. Not listed on Phrozen Keep.
|
||||||
|
@ -42,7 +42,7 @@ var SoundEnvirons map[int]*SoundEnvironRecord
|
||||||
func LoadSoundEnvirons(file []byte) {
|
func LoadSoundEnvirons(file []byte) {
|
||||||
SoundEnvirons = make(map[int]*SoundEnvironRecord)
|
SoundEnvirons = make(map[int]*SoundEnvironRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &SoundEnvironRecord{
|
record := &SoundEnvironRecord{
|
||||||
Handle: d.String("Handle"),
|
Handle: d.String("Handle"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SoundEntry represents a sound entry
|
// SoundEntry represents a sound entry
|
||||||
|
@ -43,7 +43,7 @@ var Sounds map[string]*SoundEntry
|
||||||
func LoadSounds(file []byte) {
|
func LoadSounds(file []byte) {
|
||||||
Sounds = make(map[string]*SoundEntry)
|
Sounds = make(map[string]*SoundEntry)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
entry := &SoundEntry{
|
entry := &SoundEntry{
|
||||||
Handle: d.String("Sound"),
|
Handle: d.String("Sound"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StateRecord describes a body location that items can be equipped to
|
// StateRecord describes a body location that items can be equipped to
|
||||||
|
@ -249,7 +249,7 @@ var States map[string]*StateRecord
|
||||||
func LoadStates(file []byte) {
|
func LoadStates(file []byte) {
|
||||||
States = make(map[string]*StateRecord)
|
States = make(map[string]*StateRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &StateRecord{
|
record := &StateRecord{
|
||||||
State: d.String("state"),
|
State: d.String("state"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://d2mods.info/forum/kb/viewarticle?a=162
|
// https://d2mods.info/forum/kb/viewarticle?a=162
|
||||||
|
@ -127,7 +127,7 @@ var SuperUniques map[string]*SuperUniqueRecord
|
||||||
func LoadSuperUniques(file []byte) {
|
func LoadSuperUniques(file []byte) {
|
||||||
SuperUniques = make(map[string]*SuperUniqueRecord)
|
SuperUniques = make(map[string]*SuperUniqueRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &SuperUniqueRecord{
|
record := &SuperUniqueRecord{
|
||||||
Key: d.String("Superunique"),
|
Key: d.String("Superunique"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -42,7 +42,7 @@ var TreasureClass map[string]*TreasureClassRecord //nolint:gochecknoglobals // C
|
||||||
func LoadTreasureClassRecords(file []byte) {
|
func LoadTreasureClassRecords(file []byte) {
|
||||||
TreasureClass = make(map[string]*TreasureClassRecord)
|
TreasureClass = make(map[string]*TreasureClassRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
|
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &TreasureClassRecord{
|
record := &TreasureClassRecord{
|
||||||
|
|
|
@ -3,7 +3,7 @@ package d2datadict
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UniqueAppellationRecord described the extra suffix of a unique monster name
|
// UniqueAppellationRecord described the extra suffix of a unique monster name
|
||||||
|
@ -20,7 +20,7 @@ var UniqueAppellations map[string]*UniqueAppellationRecord
|
||||||
func LoadUniqueAppellations(file []byte) {
|
func LoadUniqueAppellations(file []byte) {
|
||||||
UniqueAppellations = make(map[string]*UniqueAppellationRecord)
|
UniqueAppellations = make(map[string]*UniqueAppellationRecord)
|
||||||
|
|
||||||
d := d2common.LoadDataDictionary(file)
|
d := d2txt.LoadDataDictionary(file)
|
||||||
for d.Next() {
|
for d.Next() {
|
||||||
record := &UniqueAppellationRecord{
|
record := &UniqueAppellationRecord{
|
||||||
Name: d.String("Name"),
|
Name: d.String("Name"),
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// UniqueItemRecord is a representation of a row from uniqueitems.txt
|
// UniqueItemRecord is a representation of a row from uniqueitems.txt
|
||||||
|
@ -56,22 +55,22 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
|
||||||
}
|
}
|
||||||
result := UniqueItemRecord{
|
result := UniqueItemRecord{
|
||||||
Name: r[inc()],
|
Name: r[inc()],
|
||||||
Version: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Version: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
Enabled: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
Enabled: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
Ladder: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
Ladder: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
Rarity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Rarity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
NoLimit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
NoLimit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
|
|
||||||
Level: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
Level: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
RequiredLevel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
RequiredLevel: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
Code: r[inc()],
|
Code: r[inc()],
|
||||||
|
|
||||||
TypeDescription: r[inc()],
|
TypeDescription: r[inc()],
|
||||||
UberDescription: r[inc()],
|
UberDescription: r[inc()],
|
||||||
SingleCopy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
|
SingleCopy: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
|
||||||
CostMultiplier: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
CostMultiplier: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
CostAdd: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
CostAdd: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
|
|
||||||
CharacterGfxTransform: r[inc()],
|
CharacterGfxTransform: r[inc()],
|
||||||
InventoryGfxTransform: r[inc()],
|
InventoryGfxTransform: r[inc()],
|
||||||
|
@ -79,7 +78,7 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
|
||||||
InventoryFile: r[inc()],
|
InventoryFile: r[inc()],
|
||||||
|
|
||||||
DropSound: r[inc()],
|
DropSound: r[inc()],
|
||||||
DropSfxFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
|
DropSfxFrame: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
|
||||||
UseSound: r[inc()],
|
UseSound: r[inc()],
|
||||||
|
|
||||||
Properties: [12]UniqueItemProperty{
|
Properties: [12]UniqueItemProperty{
|
||||||
|
@ -107,8 +106,8 @@ func createUniqueItemProperty(r *[]string, inc func() int) UniqueItemProperty {
|
||||||
result := UniqueItemProperty{
|
result := UniqueItemProperty{
|
||||||
Code: (*r)[inc()],
|
Code: (*r)[inc()],
|
||||||
Parameter: (*r)[inc()],
|
Parameter: (*r)[inc()],
|
||||||
Min: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Min: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
Max: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
|
Max: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package d2video
|
package d2video
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BinkVideoMode is the video mode type
|
// BinkVideoMode is the video mode type
|
||||||
|
@ -53,7 +52,7 @@ type BinkAudioTrack struct {
|
||||||
type BinkDecoder struct {
|
type BinkDecoder struct {
|
||||||
AudioTracks []BinkAudioTrack
|
AudioTracks []BinkAudioTrack
|
||||||
FrameIndexTable []uint32
|
FrameIndexTable []uint32
|
||||||
streamReader *d2common.StreamReader
|
streamReader *d2datautils.StreamReader
|
||||||
fileSize uint32
|
fileSize uint32
|
||||||
numberOfFrames uint32
|
numberOfFrames uint32
|
||||||
largestFrameSizeBytes uint32
|
largestFrameSizeBytes uint32
|
||||||
|
@ -74,7 +73,7 @@ type BinkDecoder struct {
|
||||||
// CreateBinkDecoder returns a new instance of the bink decoder
|
// CreateBinkDecoder returns a new instance of the bink decoder
|
||||||
func CreateBinkDecoder(source []byte) *BinkDecoder {
|
func CreateBinkDecoder(source []byte) *BinkDecoder {
|
||||||
result := &BinkDecoder{
|
result := &BinkDecoder{
|
||||||
streamReader: d2common.CreateStreamReader(source),
|
streamReader: d2datautils.CreateStreamReader(source),
|
||||||
}
|
}
|
||||||
|
|
||||||
result.loadHeaderInformation()
|
result.loadHeaderInformation()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
// BitMuncher is used for parsing files that are not byte-aligned such as the DCC files.
|
// BitMuncher is used for parsing files that are not byte-aligned such as the DCC files.
|
||||||
type BitMuncher struct {
|
type BitMuncher struct {
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2datautils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,9 +1,9 @@
|
||||||
package d2cof
|
package d2cof
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ type COF struct {
|
||||||
// Load loads a COF file.
|
// Load loads a COF file.
|
||||||
func Load(fileData []byte) (*COF, error) {
|
func Load(fileData []byte) (*COF, error) {
|
||||||
result := &COF{}
|
result := &COF{}
|
||||||
streamReader := d2common.CreateStreamReader(fileData)
|
streamReader := d2datautils.CreateStreamReader(fileData)
|
||||||
result.NumberOfLayers = int(streamReader.GetByte())
|
result.NumberOfLayers = int(streamReader.GetByte())
|
||||||
result.FramesPerDirection = int(streamReader.GetByte())
|
result.FramesPerDirection = int(streamReader.GetByte())
|
||||||
result.NumberOfDirections = int(streamReader.GetByte())
|
result.NumberOfDirections = int(streamReader.GetByte())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package d2dc6
|
package d2dc6
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -36,7 +36,7 @@ func Load(data []byte) (*DC6, error) {
|
||||||
terminatorSize = 3
|
terminatorSize = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
r := d2common.CreateStreamReader(data)
|
r := d2datautils.CreateStreamReader(data)
|
||||||
|
|
||||||
var dc DC6
|
var dc DC6
|
||||||
dc.Version = r.GetInt32()
|
dc.Version = r.GetInt32()
|
||||||
|
|
|
@ -2,8 +2,7 @@ package d2dcc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const dccFileSignature = 0x74
|
const dccFileSignature = 0x74
|
||||||
|
@ -25,7 +24,7 @@ func Load(fileData []byte) (*DCC, error) {
|
||||||
fileData: fileData,
|
fileData: fileData,
|
||||||
}
|
}
|
||||||
|
|
||||||
var bm = d2common.CreateBitMuncher(fileData, 0)
|
var bm = d2datautils.CreateBitMuncher(fileData, 0)
|
||||||
|
|
||||||
result.Signature = int(bm.GetByte())
|
result.Signature = int(bm.GetByte())
|
||||||
|
|
||||||
|
@ -54,6 +53,6 @@ func Load(fileData []byte) (*DCC, error) {
|
||||||
|
|
||||||
// DecodeDirection decodes and returns the given direction
|
// DecodeDirection decodes and returns the given direction
|
||||||
func (dcc *DCC) DecodeDirection(direction int) *DCCDirection {
|
func (dcc *DCC) DecodeDirection(direction int) *DCCDirection {
|
||||||
return CreateDCCDirection(d2common.CreateBitMuncher(dcc.fileData,
|
return CreateDCCDirection(d2datautils.CreateBitMuncher(dcc.fileData,
|
||||||
dcc.directionOffsets[direction]*directionOffsetMultiplier), dcc)
|
dcc.directionOffsets[direction]*directionOffsetMultiplier), dcc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package d2dcc
|
package d2dcc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2geom"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ type DCCDirection struct {
|
||||||
RawPixelCodesBitstreamSize int
|
RawPixelCodesBitstreamSize int
|
||||||
Frames []*DCCDirectionFrame
|
Frames []*DCCDirectionFrame
|
||||||
PaletteEntries [256]byte
|
PaletteEntries [256]byte
|
||||||
Box d2common.Rectangle
|
Box d2geom.Rectangle
|
||||||
Cells []*DCCCell
|
Cells []*DCCCell
|
||||||
PixelData []byte
|
PixelData []byte
|
||||||
HorizontalCellCount int
|
HorizontalCellCount int
|
||||||
|
@ -35,7 +36,7 @@ type DCCDirection struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDCCDirection creates an instance of a DCCDirection.
|
// CreateDCCDirection creates an instance of a DCCDirection.
|
||||||
func CreateDCCDirection(bm *d2common.BitMuncher, file *DCC) *DCCDirection {
|
func CreateDCCDirection(bm *d2datautils.BitMuncher, file *DCC) *DCCDirection {
|
||||||
var crazyBitTable = []byte{0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 26, 28, 30, 32}
|
var crazyBitTable = []byte{0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 26, 28, 30, 32}
|
||||||
|
|
||||||
result := &DCCDirection{
|
result := &DCCDirection{
|
||||||
|
@ -65,7 +66,7 @@ func CreateDCCDirection(bm *d2common.BitMuncher, file *DCC) *DCCDirection {
|
||||||
maxy = int(d2math.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy)))
|
maxy = int(d2math.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy)))
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Box = d2common.Rectangle{Left: minx, Top: miny, Width: maxx - minx, Height: maxy - miny}
|
result.Box = d2geom.Rectangle{Left: minx, Top: miny, Width: maxx - minx, Height: maxy - miny}
|
||||||
|
|
||||||
if result.OptionalDataBits > 0 {
|
if result.OptionalDataBits > 0 {
|
||||||
log.Panic("Optional bits in DCC data is not currently supported.")
|
log.Panic("Optional bits in DCC data is not currently supported.")
|
||||||
|
@ -95,23 +96,23 @@ func CreateDCCDirection(bm *d2common.BitMuncher, file *DCC) *DCCDirection {
|
||||||
// here. For example, if you are on byte offset 3, bit offset 6, and
|
// here. For example, if you are on byte offset 3, bit offset 6, and
|
||||||
// the EqualCellsBitstreamSize is 20 bytes, then the next bit stream
|
// the EqualCellsBitstreamSize is 20 bytes, then the next bit stream
|
||||||
// will be located at byte 23, bit offset 6!
|
// will be located at byte 23, bit offset 6!
|
||||||
equalCellsBitstream := d2common.CopyBitMuncher(bm)
|
equalCellsBitstream := d2datautils.CopyBitMuncher(bm)
|
||||||
|
|
||||||
bm.SkipBits(result.EqualCellsBitstreamSize)
|
bm.SkipBits(result.EqualCellsBitstreamSize)
|
||||||
|
|
||||||
pixelMaskBitstream := d2common.CopyBitMuncher(bm)
|
pixelMaskBitstream := d2datautils.CopyBitMuncher(bm)
|
||||||
|
|
||||||
bm.SkipBits(result.PixelMaskBitstreamSize)
|
bm.SkipBits(result.PixelMaskBitstreamSize)
|
||||||
|
|
||||||
encodingTypeBitsream := d2common.CopyBitMuncher(bm)
|
encodingTypeBitsream := d2datautils.CopyBitMuncher(bm)
|
||||||
|
|
||||||
bm.SkipBits(result.EncodingTypeBitsreamSize)
|
bm.SkipBits(result.EncodingTypeBitsreamSize)
|
||||||
|
|
||||||
rawPixelCodesBitstream := d2common.CopyBitMuncher(bm)
|
rawPixelCodesBitstream := d2datautils.CopyBitMuncher(bm)
|
||||||
|
|
||||||
bm.SkipBits(result.RawPixelCodesBitstreamSize)
|
bm.SkipBits(result.RawPixelCodesBitstreamSize)
|
||||||
|
|
||||||
pixelCodeandDisplacement := d2common.CopyBitMuncher(bm)
|
pixelCodeandDisplacement := d2datautils.CopyBitMuncher(bm)
|
||||||
|
|
||||||
// Calculate the cells for the direction
|
// Calculate the cells for the direction
|
||||||
result.calculateCells()
|
result.calculateCells()
|
||||||
|
@ -137,7 +138,7 @@ func CreateDCCDirection(bm *d2common.BitMuncher, file *DCC) *DCCDirection {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *DCCDirection) verify(equalCellsBitstream, pixelMaskBitstream, encodingTypeBitsream, rawPixelCodesBitstream *d2common.BitMuncher) {
|
func (v *DCCDirection) verify(equalCellsBitstream, pixelMaskBitstream, encodingTypeBitsream, rawPixelCodesBitstream *d2datautils.BitMuncher) {
|
||||||
if equalCellsBitstream.BitsRead() != v.EqualCellsBitstreamSize {
|
if equalCellsBitstream.BitsRead() != v.EqualCellsBitstreamSize {
|
||||||
log.Panic("Did not read the correct number of bits!")
|
log.Panic("Did not read the correct number of bits!")
|
||||||
}
|
}
|
||||||
|
@ -156,7 +157,7 @@ func (v *DCCDirection) verify(equalCellsBitstream, pixelMaskBitstream, encodingT
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocognit nolint:gocyclo // Can't reduce
|
//nolint:gocognit nolint:gocyclo // Can't reduce
|
||||||
func (v *DCCDirection) generateFrames(pcd *d2common.BitMuncher) {
|
func (v *DCCDirection) generateFrames(pcd *d2datautils.BitMuncher) {
|
||||||
pbIdx := 0
|
pbIdx := 0
|
||||||
|
|
||||||
for _, cell := range v.Cells {
|
for _, cell := range v.Cells {
|
||||||
|
@ -259,7 +260,7 @@ func (v *DCCDirection) generateFrames(pcd *d2common.BitMuncher) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:funlen nolint:gocognit // can't reduce
|
//nolint:funlen nolint:gocognit // can't reduce
|
||||||
func (v *DCCDirection) fillPixelBuffer(pcd, ec, pm, et, rp *d2common.BitMuncher) {
|
func (v *DCCDirection) fillPixelBuffer(pcd, ec, pm, et, rp *d2datautils.BitMuncher) {
|
||||||
var pixelMaskLookup = []int{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}
|
var pixelMaskLookup = []int{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}
|
||||||
|
|
||||||
lastPixel := uint32(0)
|
lastPixel := uint32(0)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package d2dcc
|
package d2dcc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2geom"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DCCDirectionFrame represents a direction frame for a DCC.
|
// DCCDirectionFrame represents a direction frame for a DCC.
|
||||||
type DCCDirectionFrame struct {
|
type DCCDirectionFrame struct {
|
||||||
Box d2common.Rectangle
|
Box d2geom.Rectangle
|
||||||
Cells []DCCCell
|
Cells []DCCCell
|
||||||
PixelData []byte
|
PixelData []byte
|
||||||
Width int
|
Width int
|
||||||
|
@ -24,7 +24,7 @@ type DCCDirectionFrame struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDCCDirectionFrame Creates a DCCDirectionFrame for a DCC.
|
// CreateDCCDirectionFrame Creates a DCCDirectionFrame for a DCC.
|
||||||
func CreateDCCDirectionFrame(bits *d2common.BitMuncher, direction *DCCDirection) *DCCDirectionFrame {
|
func CreateDCCDirectionFrame(bits *d2datautils.BitMuncher, direction *DCCDirection) *DCCDirectionFrame {
|
||||||
result := &DCCDirectionFrame{}
|
result := &DCCDirectionFrame{}
|
||||||
|
|
||||||
bits.GetBits(direction.Variable0Bits) // Variable0
|
bits.GetBits(direction.Variable0Bits) // Variable0
|
||||||
|
@ -40,7 +40,7 @@ func CreateDCCDirectionFrame(bits *d2common.BitMuncher, direction *DCCDirection)
|
||||||
if result.FrameIsBottomUp {
|
if result.FrameIsBottomUp {
|
||||||
log.Panic("Bottom up frames are not implemented.")
|
log.Panic("Bottom up frames are not implemented.")
|
||||||
} else {
|
} else {
|
||||||
result.Box = d2common.Rectangle{
|
result.Box = d2geom.Rectangle{
|
||||||
Left: result.XOffset,
|
Left: result.XOffset,
|
||||||
Top: result.YOffset - result.Height + 1,
|
Top: result.YOffset - result.Height + 1,
|
||||||
Width: result.Width,
|
Width: result.Width,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package d2ds1
|
package d2ds1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2path"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxActNumber = 5
|
const maxActNumber = 5
|
||||||
|
@ -36,7 +37,7 @@ func LoadDS1(fileData []byte) (*DS1, error) {
|
||||||
NumberOfShadowLayers: 1,
|
NumberOfShadowLayers: 1,
|
||||||
NumberOfSubstitutionLayers: 0,
|
NumberOfSubstitutionLayers: 0,
|
||||||
}
|
}
|
||||||
br := d2common.CreateStreamReader(fileData)
|
br := d2datautils.CreateStreamReader(fileData)
|
||||||
ds1.Version = br.GetInt32()
|
ds1.Version = br.GetInt32()
|
||||||
ds1.Width = br.GetInt32() + 1
|
ds1.Width = br.GetInt32() + 1
|
||||||
ds1.Height = br.GetInt32() + 1
|
ds1.Height = br.GetInt32() + 1
|
||||||
|
@ -107,7 +108,7 @@ func LoadDS1(fileData []byte) (*DS1, error) {
|
||||||
return ds1, nil
|
return ds1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
func (ds1 *DS1) loadObjects(br *d2datautils.StreamReader) {
|
||||||
if ds1.Version >= 2 { //nolint:gomnd // Version number
|
if ds1.Version >= 2 { //nolint:gomnd // Version number
|
||||||
numberOfObjects := br.GetInt32()
|
numberOfObjects := br.GetInt32()
|
||||||
ds1.Objects = make([]Object, numberOfObjects)
|
ds1.Objects = make([]Object, numberOfObjects)
|
||||||
|
@ -127,7 +128,7 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds1 *DS1) loadSubstitutions(br *d2common.StreamReader) {
|
func (ds1 *DS1) loadSubstitutions(br *d2datautils.StreamReader) {
|
||||||
if ds1.Version >= 12 && (ds1.SubstitutionType == 1 || ds1.SubstitutionType == 2) {
|
if ds1.Version >= 12 && (ds1.SubstitutionType == 1 || ds1.SubstitutionType == 2) {
|
||||||
if ds1.Version >= 18 { //nolint:gomnd // Version number
|
if ds1.Version >= 18 { //nolint:gomnd // Version number
|
||||||
br.GetUInt32()
|
br.GetUInt32()
|
||||||
|
@ -188,7 +189,7 @@ func (ds1 *DS1) setupStreamLayerTypes() []d2enum.LayerStreamType {
|
||||||
return layerStream
|
return layerStream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds1 *DS1) loadNPCs(br *d2common.StreamReader) {
|
func (ds1 *DS1) loadNPCs(br *d2datautils.StreamReader) {
|
||||||
if ds1.Version >= 14 { //nolint:gomnd // Version number
|
if ds1.Version >= 14 { //nolint:gomnd // Version number
|
||||||
numberOfNpcs := br.GetInt32()
|
numberOfNpcs := br.GetInt32()
|
||||||
for npcIdx := 0; npcIdx < int(numberOfNpcs); npcIdx++ {
|
for npcIdx := 0; npcIdx < int(numberOfNpcs); npcIdx++ {
|
||||||
|
@ -217,13 +218,13 @@ func (ds1 *DS1) loadNPCs(br *d2common.StreamReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds1 *DS1) loadNpcPaths(br *d2common.StreamReader, objIdx, numPaths int) {
|
func (ds1 *DS1) loadNpcPaths(br *d2datautils.StreamReader, objIdx, numPaths int) {
|
||||||
if ds1.Objects[objIdx].Paths == nil {
|
if ds1.Objects[objIdx].Paths == nil {
|
||||||
ds1.Objects[objIdx].Paths = make([]d2common.Path, numPaths)
|
ds1.Objects[objIdx].Paths = make([]d2path.Path, numPaths)
|
||||||
}
|
}
|
||||||
|
|
||||||
for pathIdx := 0; pathIdx < numPaths; pathIdx++ {
|
for pathIdx := 0; pathIdx < numPaths; pathIdx++ {
|
||||||
newPath := d2common.Path{}
|
newPath := d2path.Path{}
|
||||||
newPath.Position = d2vector.NewPosition(
|
newPath.Position = d2vector.NewPosition(
|
||||||
float64(br.GetInt32()),
|
float64(br.GetInt32()),
|
||||||
float64(br.GetInt32()))
|
float64(br.GetInt32()))
|
||||||
|
@ -236,7 +237,7 @@ func (ds1 *DS1) loadNpcPaths(br *d2common.StreamReader, objIdx, numPaths int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds1 *DS1) loadLayerStreams(br *d2common.StreamReader, layerStream []d2enum.LayerStreamType) {
|
func (ds1 *DS1) loadLayerStreams(br *d2datautils.StreamReader, layerStream []d2enum.LayerStreamType) {
|
||||||
var dirLookup = []int32{
|
var dirLookup = []int32{
|
||||||
0x00, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, 0x05, 0x05, 0x06,
|
0x00, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, 0x05, 0x05, 0x06,
|
||||||
0x06, 0x07, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
0x06, 0x07, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package d2ds1
|
package d2ds1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2path"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Object is a game world object
|
// Object is a game world object
|
||||||
|
@ -11,5 +11,5 @@ type Object struct {
|
||||||
X int
|
X int
|
||||||
Y int
|
Y int
|
||||||
Flags int
|
Flags int
|
||||||
Paths []d2common.Path
|
Paths []d2path.Path
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package d2dt1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DT1 represents a DT1 file.
|
// DT1 represents a DT1 file.
|
||||||
|
@ -26,7 +25,7 @@ const (
|
||||||
//nolint:funlen Can't reduce
|
//nolint:funlen Can't reduce
|
||||||
func LoadDT1(fileData []byte) (*DT1, error) {
|
func LoadDT1(fileData []byte) (*DT1, error) {
|
||||||
result := &DT1{}
|
result := &DT1{}
|
||||||
br := d2common.CreateStreamReader(fileData)
|
br := d2datautils.CreateStreamReader(fileData)
|
||||||
ver1 := br.GetInt32()
|
ver1 := br.GetInt32()
|
||||||
ver2 := br.GetInt32()
|
ver2 := br.GetInt32()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Package d2tbl provides a file parser for tbl string table files
|
||||||
|
package d2tbl
|
|
@ -1,8 +1,10 @@
|
||||||
package d2common
|
package d2tbl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type textDictionaryHashEntry struct {
|
type textDictionaryHashEntry struct {
|
||||||
|
@ -38,7 +40,7 @@ func LoadTextDictionary(dictionaryData []byte) {
|
||||||
lookupTable = make(map[string]string)
|
lookupTable = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
br := CreateStreamReader(dictionaryData)
|
br := d2datautils.CreateStreamReader(dictionaryData)
|
||||||
|
|
||||||
// skip past the CRC
|
// skip past the CRC
|
||||||
br.ReadBytes(crcByteCount)
|
br.ReadBytes(crcByteCount)
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2txt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Package d2txt provides a parser implementation for diablo TSV data files
|
||||||
|
package d2txt
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2geom
|
||||||
|
|
||||||
// Point represents a point
|
// Point represents a point
|
||||||
type Point struct {
|
type Point struct {
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2geom
|
||||||
|
|
||||||
// Rectangle represents a rectangle
|
// Rectangle represents a rectangle
|
||||||
type Rectangle struct {
|
type Rectangle struct {
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2geom
|
||||||
|
|
||||||
// Size represents a size
|
// Size represents a size
|
||||||
type Size struct {
|
type Size struct {
|
|
@ -1,4 +1,4 @@
|
||||||
package d2common
|
package d2path
|
||||||
|
|
||||||
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package d2resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MusicDef stores the music definitions of a region
|
||||||
|
type MusicDef struct {
|
||||||
|
Region d2enum.RegionIdType
|
||||||
|
InTown bool
|
||||||
|
MusicFile string
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMusicDefs() []MusicDef {
|
||||||
|
return []MusicDef{
|
||||||
|
{d2enum.RegionAct1Town, false, BGMAct1Town1},
|
||||||
|
{d2enum.RegionAct1Wilderness, false, BGMAct1Wild},
|
||||||
|
{d2enum.RegionAct1Cave, false, BGMAct1Caves},
|
||||||
|
{d2enum.RegionAct1Crypt, false, BGMAct1Crypt},
|
||||||
|
{d2enum.RegionAct1Monestary, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Courtyard, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Barracks, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Jail, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Cathedral, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Catacombs, false, BGMAct1Monastery},
|
||||||
|
{d2enum.RegionAct1Tristram, false, BGMAct1Tristram},
|
||||||
|
{d2enum.RegionAct2Town, false, BGMAct2Town2},
|
||||||
|
{d2enum.RegionAct2Sewer, false, BGMAct2Sewer},
|
||||||
|
{d2enum.RegionAct2Harem, false, BGMAct2Harem},
|
||||||
|
{d2enum.RegionAct2Basement, false, BGMAct2Harem},
|
||||||
|
{d2enum.RegionAct2Desert, false, BGMAct2Desert},
|
||||||
|
{d2enum.RegionAct2Tomb, false, BGMAct2Tombs},
|
||||||
|
{d2enum.RegionAct2Lair, false, BGMAct2Lair},
|
||||||
|
{d2enum.RegionAct2Arcane, false, BGMAct2Sanctuary},
|
||||||
|
{d2enum.RegionAct3Town, false, BGMAct3Town3},
|
||||||
|
{d2enum.RegionAct3Jungle, false, BGMAct3Jungle},
|
||||||
|
{d2enum.RegionAct3Kurast, false, BGMAct3Kurast},
|
||||||
|
{d2enum.RegionAct3Spider, false, BGMAct3Spider},
|
||||||
|
{d2enum.RegionAct3Dungeon, false, BGMAct3KurastSewer},
|
||||||
|
{d2enum.RegionAct3Sewer, false, BGMAct3KurastSewer},
|
||||||
|
{d2enum.RegionAct4Town, false, BGMAct4Town4},
|
||||||
|
{d2enum.RegionAct4Mesa, false, BGMAct4Mesa},
|
||||||
|
{d2enum.RegionAct4Lava, false, BGMAct4Mesa},
|
||||||
|
{d2enum.RegonAct5Town, false, BGMAct5XTown},
|
||||||
|
{d2enum.RegionAct5Siege, false, BGMAct5Siege},
|
||||||
|
{d2enum.RegionAct5Barricade, false, BGMAct5Siege}, // ?
|
||||||
|
{d2enum.RegionAct5Temple, false, BGMAct5XTemple},
|
||||||
|
{d2enum.RegionAct5IceCaves, false, BGMAct5IceCaves},
|
||||||
|
{d2enum.RegionAct5Baal, false, BGMAct5Baal},
|
||||||
|
{d2enum.RegionAct5Lava, false, BGMAct5Nihlathak}, // ?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMusicDef returns the MusicDef of the given region
|
||||||
|
func GetMusicDef(regionType d2enum.RegionIdType) *MusicDef {
|
||||||
|
musicDefs := getMusicDefs()
|
||||||
|
for idx := range musicDefs {
|
||||||
|
if musicDefs[idx].Region != regionType {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return &musicDefs[idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
return &musicDefs[0]
|
||||||
|
}
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue