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:
lord 2020-09-08 12:58:35 -07:00 committed by GitHub
parent 50d40fb5d3
commit 0218cad717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
132 changed files with 727 additions and 730 deletions

View File

@ -6,6 +6,8 @@ import (
"container/ring"
"errors"
"fmt"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2tbl"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"image"
"image/gif"
"image/png"
@ -21,7 +23,6 @@ import (
"golang.org/x/image/colornames"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
@ -144,7 +145,7 @@ func (a *App) Run() error {
func (a *App) initialize() error {
a.timeScale = 1.0
a.lastTime = d2common.Now()
a.lastTime = d2util.Now()
a.lastScreenAdvance = a.lastTime
a.renderer.SetWindowIcon("d2logo.png")
@ -211,7 +212,7 @@ func (a *App) loadStrings() error {
return err
}
d2common.LoadTextDictionary(data)
d2tbl.LoadTextDictionary(data)
}
return nil
@ -424,7 +425,7 @@ func (a *App) advance(elapsed, elapsedUnscaled, current float64) error {
}
func (a *App) update(target d2interface.Surface) error {
currentTime := d2common.Now()
currentTime := d2util.Now()
elapsedTimeUnscaled := currentTime - a.lastTime
elapsedTime := elapsedTimeUnscaled * a.timeScale
a.lastTime = currentTime

View File

@ -1,4 +1,4 @@
package d2common
package d2cache
import (
"errors"

View File

@ -1,4 +1,4 @@
package d2common
package d2calculation
// 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

View File

@ -1,10 +1,9 @@
package d2data
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
const (
@ -30,7 +29,7 @@ var AnimationData map[string][]*AnimationDataRecord //nolint:gochecknoglobals //
// LoadAnimationData loads the animation data table into the global AnimationData dictionary
func LoadAnimationData(rawData []byte) {
AnimationData = make(map[string][]*AnimationDataRecord)
streamReader := d2common.CreateStreamReader(rawData)
streamReader := d2datautils.CreateStreamReader(rawData)
for !streamReader.EOF() {
dataCount := int(streamReader.GetInt32())

View File

@ -33,7 +33,7 @@ package d2compression
import (
"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)
@ -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
for node.child0 != nil {
@ -386,8 +386,8 @@ func HuffmanDecompress(data []byte) []byte {
tail := buildList(primes[comptype])
head := buildTree(tail)
outputstream := d2common.CreateStreamWriter()
bitstream := d2common.CreateBitStream(data[1:])
outputstream := d2datautils.CreateStreamWriter()
bitstream := d2datautils.CreateBitStream(data[1:])
var decoded int

View File

@ -1,7 +1,7 @@
package d2compression
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
// 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,
}
input := d2common.CreateStreamReader(data)
output := d2common.CreateStreamWriter()
input := d2datautils.CreateStreamReader(data)
output := d2datautils.CreateStreamWriter()
input.GetByte()

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// AutoMagicRecord describes rules for automatically generating magic properties when spawning
@ -139,7 +139,7 @@ func LoadAutoMagicRecords(file []byte) {
"sor": d2enum.HeroSorceress,
}
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &AutoMagicRecord{

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// AutoMapRecord represents one row from d2data.mpq/AutoMap.txt.
@ -64,7 +64,7 @@ func LoadAutoMaps(file []byte) {
var frameFields = []string{"Cel1", "Cel2", "Cel3", "Cel4"}
// Split file by newlines and tabs
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &AutoMapRecord{
LevelName: d.String("LevelName"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// BodyLocationRecord describes a body location that items can be equipped to
@ -20,7 +20,7 @@ var BodyLocations map[string]*BodyLocationRecord
func LoadBodyLocations(file []byte) {
BodyLocations = make(map[string]*BodyLocationRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
location := &BodyLocationRecord{
Name: d.String("Name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
Books = make(map[string]*BooksRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &BooksRecord{
Name: d.String("Name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"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
@ -24,7 +24,7 @@ var MissileCalculations map[string]*CalculationRecord //nolint:gochecknoglobals
func LoadSkillCalculations(file []byte) {
SkillCalculations = make(map[string]*CalculationRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &CalculationRecord{
Code: d.String("code"),
@ -44,7 +44,7 @@ func LoadSkillCalculations(file []byte) {
func LoadMissileCalculations(file []byte) {
MissileCalculations = make(map[string]*CalculationRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &CalculationRecord{
Code: d.String("code"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"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
@ -97,7 +97,7 @@ func LoadCharStats(file []byte) {
"ht2": d2enum.WeaponClassTwoHandToHand,
}
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &CharStatsRecord{
Class: charStringMap[d.String("class")],

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// ComponentCodeRecord represents a single row from compcode.txt
@ -20,7 +20,7 @@ var ComponentCodes map[string]*ComponentCodeRecord //nolint:gochecknoglobals //
func LoadComponentCodes(file []byte) {
ComponentCodes = make(map[string]*ComponentCodeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &ComponentCodeRecord{
Component: d.String("component"),

View File

@ -5,8 +5,8 @@ import (
"strconv"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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"}
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &CubeRecipeRecord{
Description: d.String("description"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// DifficultyLevels contain the difficulty records for each difficulty
@ -96,7 +96,7 @@ type DifficultyLevelRecord struct {
func LoadDifficultyLevels(file []byte) {
DifficultyLevels = make(map[string]*DifficultyLevelRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &DifficultyLevelRecord{
Name: d.String("Name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// ElemTypeRecord represents a single line in ElemType.txt
@ -22,7 +22,7 @@ var ElemTypes map[string]*ElemTypeRecord //nolint:gochecknoglobals // Currently
func LoadElemTypes(file []byte) {
ElemTypes = make(map[string]*ElemTypeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &ElemTypeRecord{
ElemType: d.String("Elemental Type"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
Events = make(map[string]*EventRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &EventRecord{
Event: d.String("event"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
/* first column of experience.txt
@ -62,7 +62,7 @@ func GetExperienceBreakpoint(heroType d2enum.Hero, level int) int {
func LoadExperienceBreakpoints(file []byte) {
ExperienceBreakpoints = make(map[int]*ExperienceBreakpointsRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
d.Next()
// the first row describes the max level of char classes

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
Gems = make(map[string]*GemsRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
gem := &GemsRecord{
Name: d.String("name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// HirelingRecord is a representation of rows in hireling.txt
@ -91,7 +91,7 @@ var Hirelings []*HirelingRecord
func LoadHireling(file []byte) {
Hirelings = make([]*HirelingRecord, 0)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
hireling := &HirelingRecord{
Hireling: d.String("Hireling"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
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
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)
for d.Next() {

View File

@ -4,8 +4,8 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MagicPrefix stores all of the magic prefix records
@ -56,7 +56,7 @@ func loadDictionary(
superType d2enum.ItemAffixSuperType,
subType d2enum.ItemAffixSubType,
) map[string]*ItemAffixCommonRecord {
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
records := createItemAffixRecords(d, superType, subType)
name := getAffixString(superType, subType)
log.Printf("Loaded %d %s records", len(records), name)
@ -65,7 +65,7 @@ func loadDictionary(
}
func createItemAffixRecords(
d *d2common.DataDictionary,
d *d2txt.DataDictionary,
superType d2enum.ItemAffixSuperType,
subType d2enum.ItemAffixSubType,
) map[string]*ItemAffixCommonRecord {

View File

@ -4,26 +4,25 @@ import (
"strconv"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
)
// ItemCommonRecord is a representation of entries from armor.txt, weapons.txt, and misc.txt
type ItemCommonRecord struct {
UsageStats [3]ItemUsageStat // stat boosts applied upon usage
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
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)
SpellDescriptionCalc d2common.CalcString // a calc string what value to display
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
HitClass string // determines sounds/graphic effects when attacking
SpecialFeature string // Just a comment
FlavorText string // unknown, probably just for reference
TransmogCode string // the 3 char code representing the item this becomes via transmog
NightmareUpgrade string // upgraded in higher difficulties
UsageStats [3]ItemUsageStat // stat boosts applied upon usage
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
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)
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)
WeaponClass2Hand string // what kind of attack when wielded with two hands
HitClass string // determines sounds/graphic effects when attacking
SpecialFeature string // Just a comment
FlavorText string // unknown, probably just for reference
TransmogCode string // the 3 char code representing the item this becomes via transmog
NightmareUpgrade string // upgraded in higher difficulties
HellUpgrade string
SourceArt string // unused?
GameArt string // unused?
@ -141,8 +140,8 @@ type ItemCommonRecord struct {
// ItemUsageStat the stat that gets applied when the item is used
type ItemUsageStat struct {
Stat string // name of the stat to add to
Calc d2common.CalcString // calc string representing the amount to add
Stat string // name of the stat to add to
Calc d2calculation.CalcString // calc string representing the amount to add
}
// 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"),
// 0 = none, 1 = use desc string, 2 = use desc string + calc value
SpellDescriptionString: mapLoadString(&r, mapping, "spelldescstr"),
SpellDescriptionCalc: d2common.CalcString(mapLoadString(&r, mapping, "spelldesccalc")),
SpellDescriptionCalc: d2calculation.CalcString(mapLoadString(&r, mapping, "spelldesccalc")),
BetterGem: mapLoadString(&r, mapping, "BetterGem"),
@ -392,7 +391,7 @@ func createItemUsageStats(r *[]string, mapping map[string]int) [3]ItemUsageStat
result := [3]ItemUsageStat{}
for i := 0; i < 3; 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

View File

@ -4,7 +4,7 @@ import (
"log"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// A helper type for item drop calculation
@ -42,7 +42,7 @@ var ItemRatios map[string]*ItemRatioRecord //nolint:gochecknoglobals // Currentl
func LoadItemRatios(file []byte) {
ItemRatios = make(map[string]*ItemRatioRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &ItemRatioRecord{
Function: d.String("Function"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// ItemTypeRecord describes the types for items
@ -201,7 +201,7 @@ func LoadItemTypes(file []byte) {
"sor": d2enum.HeroSorceress,
}
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
if d.String("*eol") == "" {
continue

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// ItemStatCostRecord represents a row from itemstatcost.txt
@ -108,7 +108,7 @@ var ItemStatCosts map[string]*ItemStatCostRecord
func LoadItemStatCosts(file []byte) {
ItemStatCosts = make(map[string]*ItemStatCostRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &ItemStatCostRecord{
Name: d.String("Stat"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &LevelMazeDetailsRecord{
Name: d.String("Name"),

View File

@ -1,10 +1,9 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// LevelPresetRecord is a representation of a row from lvlprest.txt
@ -41,21 +40,21 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
}
result := LevelPresetRecord{
Name: props[inc()],
DefinitionID: d2common.StringToInt(props[inc()]),
LevelID: d2common.StringToInt(props[inc()]),
Populate: d2common.StringToUint8(props[inc()]) == 1,
Logicals: d2common.StringToUint8(props[inc()]) == 1,
Outdoors: d2common.StringToUint8(props[inc()]) == 1,
Animate: d2common.StringToUint8(props[inc()]) == 1,
KillEdge: d2common.StringToUint8(props[inc()]) == 1,
FillBlanks: d2common.StringToUint8(props[inc()]) == 1,
SizeX: d2common.StringToInt(props[inc()]),
SizeY: d2common.StringToInt(props[inc()]),
AutoMap: d2common.StringToUint8(props[inc()]) == 1,
Scan: d2common.StringToUint8(props[inc()]) == 1,
Pops: d2common.StringToInt(props[inc()]),
PopPad: d2common.StringToInt(props[inc()]),
FileCount: d2common.StringToInt(props[inc()]),
DefinitionID: d2util.StringToInt(props[inc()]),
LevelID: d2util.StringToInt(props[inc()]),
Populate: d2util.StringToUint8(props[inc()]) == 1,
Logicals: d2util.StringToUint8(props[inc()]) == 1,
Outdoors: d2util.StringToUint8(props[inc()]) == 1,
Animate: d2util.StringToUint8(props[inc()]) == 1,
KillEdge: d2util.StringToUint8(props[inc()]) == 1,
FillBlanks: d2util.StringToUint8(props[inc()]) == 1,
SizeX: d2util.StringToInt(props[inc()]),
SizeY: d2util.StringToInt(props[inc()]),
AutoMap: d2util.StringToUint8(props[inc()]) == 1,
Scan: d2util.StringToUint8(props[inc()]) == 1,
Pops: d2util.StringToInt(props[inc()]),
PopPad: d2util.StringToInt(props[inc()]),
FileCount: d2util.StringToInt(props[inc()]),
Files: [6]string{
props[inc()],
props[inc()],
@ -64,9 +63,9 @@ func createLevelPresetRecord(props []string) LevelPresetRecord {
props[inc()],
props[inc()],
},
Dt1Mask: d2common.StringToUint(props[inc()]),
Beta: d2common.StringToUint8(props[inc()]) == 1,
Expansion: d2common.StringToUint8(props[inc()]) == 1,
Dt1Mask: d2util.StringToUint(props[inc()]),
Beta: d2util.StringToUint8(props[inc()]) == 1,
Expansion: d2util.StringToUint8(props[inc()]) == 1,
}
return result

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// LevelSubstitutionRecord is a representation of a row from lvlsub.txt
@ -72,7 +72,7 @@ var LevelSubstitutions map[int]*LevelSubstitutionRecord
func LoadLevelSubstitutions(file []byte) {
LevelSubstitutions = make(map[int]*LevelSubstitutionRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &LevelSubstitutionRecord{
Name: d.String("Name"),

View File

@ -1,10 +1,9 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// 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].ID = d2common.StringToInt(parts[inc()])
LevelTypes[j].ID = d2util.StringToInt(parts[inc()])
for fileIdx := range LevelTypes[i].Files {
LevelTypes[j].Files[fileIdx] = parts[inc()]
@ -55,7 +54,7 @@ func LoadLevelTypes(file []byte) {
}
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"
}
log.Printf("Loaded %d LevelType records", len(LevelTypes))

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// LevelWarpRecord is a representation of a row from lvlwarp.txt
@ -32,7 +32,7 @@ var LevelWarps map[int]*LevelWarpRecord
func LoadLevelWarps(file []byte) {
LevelWarps = make(map[int]*LevelWarpRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &LevelWarpRecord{
Name: d.String("Name"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// LevelDetailsRecord is a representation of a row from levels.txt
@ -383,7 +383,7 @@ func GetLevelDetails(id int) *LevelDetailsRecord {
func LoadLevelDetails(file []byte) {
LevelDetails = make(map[int]*LevelDetailsRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &LevelDetailsRecord{
Name: d.String("Name "),

View File

@ -1,9 +1,8 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
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 {
index, ok := (mapping)[field]
if ok {
return d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
return d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty((*r)[index])))
}
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 {
index, ok := (mapping)[field]
if ok {
return d2common.AsterToEmpty((*r)[index])
return d2util.AsterToEmpty((*r)[index])
}
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 {
index, ok := (mapping)[field]
if ok {
return d2common.StringToUint8(d2common.EmptyToZero(d2common.AsterToEmpty((*r)[index])))
return d2util.StringToUint8(d2util.EmptyToZero(d2util.AsterToEmpty((*r)[index])))
}
return 0

View File

@ -1,10 +1,11 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
)
// MissileCalcParam is a calculation parameter for a missile
@ -15,7 +16,7 @@ type MissileCalcParam struct {
// MissileCalc is a calculation for a missile
type MissileCalc struct {
Calc d2common.CalcString
Calc d2calculation.CalcString
Desc string
Params []MissileCalcParam
}
@ -65,8 +66,8 @@ type MissileDamage struct {
MaxDamage int
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+
MaxLevelDamage [5]int // see above
DamageSynergyPerCalc d2common.CalcString // works like synergy in skills.txt, not clear
MaxLevelDamage [5]int // see above
DamageSynergyPerCalc d2calculation.CalcString // works like synergy in skills.txt, not clear
}
// MissileElementalDamage parameters for calculating missile elemental damage
@ -211,13 +212,13 @@ func createMissileRecord(line string) MissileRecord {
// be wrapped in an d2common.EmptyToZero transform
result := MissileRecord{
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()]))),
ClientCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
ServerMovementFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
ServerCollisionFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
ServerDamageFunc: d2common.StringToInt(d2common.EmptyToZero(d2common.AsterToEmpty(r[inc()]))),
ClientMovementFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
ClientCollisionFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
ServerMovementFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
ServerCollisionFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
ServerDamageFunc: d2util.StringToInt(d2util.EmptyToZero(d2util.AsterToEmpty(r[inc()]))),
ServerMovementCalc: loadMissileCalc(&r, inc, 5),
ClientMovementCalc: loadMissileCalc(&r, inc, 5),
@ -225,12 +226,12 @@ func createMissileRecord(line string) MissileRecord {
ClientCollisionCalc: loadMissileCalc(&r, inc, 3),
ServerDamageCalc: loadMissileCalc(&r, inc, 2),
Velocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
MaxVelocity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
LevelVelocityBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Accel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Range: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
LevelRangeBonus: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Velocity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
MaxVelocity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
LevelVelocityBonus: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Accel: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Range: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
LevelRangeBonus: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Light: loadMissileLight(&r, inc),
@ -238,54 +239,54 @@ func createMissileRecord(line string) MissileRecord {
Collision: loadMissileCollision(&r, inc),
XOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
YOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
ZOffset: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Size: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
XOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
YOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
ZOffset: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Size: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
DestroyedByTP: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
DestroyedByTPFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
CanDestroy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
DestroyedByTP: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
DestroyedByTPFrame: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
CanDestroy: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
UseAttackRating: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
AlwaysExplode: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
UseAttackRating: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
AlwaysExplode: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
ClientExplosion: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
TownSafe: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
IgnoreBossModifiers: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
IgnoreMultishot: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
HolyFilterType: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
CanBeSlowed: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
TriggersHitEvents: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
TriggersGetHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
SoftHit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
KnockbackPercent: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
ClientExplosion: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
TownSafe: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
IgnoreBossModifiers: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
IgnoreMultishot: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
HolyFilterType: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
CanBeSlowed: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
TriggersHitEvents: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
TriggersGetHit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
SoftHit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
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,
AffectedByPierce: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
SpecialSetup: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
UseQuantity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
AffectedByPierce: d2util.StringToInt(d2util.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()],
ResultFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
HitFlags: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
ResultFlags: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
HitFlags: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
HitShift: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
ApplyMastery: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
SourceDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
HalfDamageForTwoHander: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
SourceMissDamage: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
HitShift: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
ApplyMastery: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
SourceDamage: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
HalfDamageForTwoHander: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
SourceMissDamage: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Damage: loadMissileDamage(&r, inc),
ElementalDamage: loadMissileElementalDamage(&r, inc),
HitClass: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
NumDirections: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
LocalBlood: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
DamageReductionRate: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
HitClass: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
NumDirections: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
LocalBlood: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
DamageReductionRate: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
TravelSound: r[inc()],
HitSound: r[inc()],
@ -325,7 +326,7 @@ func LoadMissiles(file []byte) {
func loadMissileCalcParam(r *[]string, inc func() int) MissileCalcParam {
result := MissileCalcParam{
Param: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Param: d2util.StringToInt(d2util.EmptyToZero((*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 {
result := MissileCalc{
Calc: d2common.CalcString((*r)[inc()]),
Calc: d2calculation.CalcString((*r)[inc()]),
Desc: (*r)[inc()],
}
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 {
result := MissileLight{
Diameter: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Flicker: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Red: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
Green: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
Blue: d2common.StringToUint8(d2common.EmptyToZero((*r)[inc()])),
Diameter: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
Flicker: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
Red: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
Green: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
Blue: d2util.StringToUint8(d2util.EmptyToZero((*r)[inc()])),
}
return result
@ -360,17 +361,17 @@ func loadMissileLight(r *[]string, inc func() int) MissileLight {
func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
result := MissileAnimation{
StepsBeforeVisible: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
StepsBeforeActive: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
LoopAnimation: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
StepsBeforeVisible: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
StepsBeforeActive: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
LoopAnimation: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
CelFileName: (*r)[inc()],
AnimationRate: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
AnimationLength: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
AnimationSpeed: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
StartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
HasSubLoop: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
SubStartingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
SubEndingFrame: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
AnimationRate: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
AnimationLength: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
AnimationSpeed: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
StartingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
HasSubLoop: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
SubStartingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
SubEndingFrame: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
}
return result
@ -378,15 +379,15 @@ func loadMissileAnimation(r *[]string, inc func() int) MissileAnimation {
func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
result := MissileCollision{
CollisionType: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
DestroyedUponCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
FriendlyFire: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
LastCollide: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
Collision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
ClientCollision: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
ClientSend: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
UseCollisionTimer: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])) == 1,
TimerFrames: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
CollisionType: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
DestroyedUponCollision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
FriendlyFire: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
LastCollide: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
Collision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
ClientCollision: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
ClientSend: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
UseCollisionTimer: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])) == 1,
TimerFrames: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
}
return result
@ -394,23 +395,23 @@ func loadMissileCollision(r *[]string, inc func() int) MissileCollision {
func loadMissileDamage(r *[]string, inc func() int) MissileDamage {
result := MissileDamage{
MinDamage: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
MinDamage: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
MinLevelDamage: [5]int{
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.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{
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
},
DamageSynergyPerCalc: d2common.CalcString((*r)[inc()]),
DamageSynergyPerCalc: d2calculation.CalcString((*r)[inc()]),
}
return result
@ -420,11 +421,11 @@ func loadMissileElementalDamage(r *[]string, inc func() int) MissileElementalDam
result := MissileElementalDamage{
ElementType: (*r)[inc()],
Damage: loadMissileDamage(r, inc),
Duration: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Duration: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
LevelDuration: [3]int{
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
},
}

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
MonModes = make(map[string]*MonModeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonModeRecord{
Name: d.String("name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonPresets stores monster presets
@ -14,7 +14,7 @@ var MonPresets map[int32][]string
func LoadMonPresets(file []byte) {
MonPresets = make(map[int32][]string)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
act := int32(d.Number("Act"))
if _, ok := MonPresets[act]; !ok {

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -45,7 +45,7 @@ var MonProps map[string]*MonPropRecord //nolint:gochecknoglobals // Currently gl
func LoadMonProps(file []byte) {
MonProps = make(map[string]*MonPropRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonPropRecord{
ID: d.String("Id"),

View File

@ -4,8 +4,7 @@ import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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
MonStats = make(map[string]*MonStatsRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonStatsRecord{
Key: d.String("Id"),

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonStats2Record is a representation of a row from monstats2.txt
@ -174,7 +174,7 @@ var MonStats2 map[string]*MonStats2Record
func LoadMonStats2(file []byte) {
MonStats2 = make(map[string]*MonStats2Record)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonStats2Record{
Key: d.String("Id"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonsterAIRecord represents a single row from monai.txt
@ -18,7 +18,7 @@ var MonsterAI map[string]*MonsterAIRecord //nolint:gochecknoglobals // Currently
func LoadMonsterAI(file []byte) {
MonsterAI = make(map[string]*MonsterAIRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonsterAIRecord{
AI: d.String("AI"),

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -48,7 +48,7 @@ var MonsterEquipment map[string][]*MonsterEquipmentRecord //nolint:gochecknoglob
func LoadMonsterEquipment(file []byte) {
MonsterEquipment = make(map[string][]*MonsterEquipmentRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonsterEquipmentRecord{
Name: d.String("monster"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonsterLevelRecord represents a single row in monlvl.txt
@ -58,7 +58,7 @@ var MonsterLevels map[int]*MonsterLevelRecord //nolint:gochecknoglobals // Curre
func LoadMonsterLevels(file []byte) {
MonsterLevels = make(map[int]*MonsterLevelRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonsterLevelRecord{
Level: d.Number("Level"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonsterPlacementRecord represents a line from MonPlace.txt.
@ -14,7 +14,7 @@ var MonsterPlacements []MonsterPlacementRecord //nolint:gochecknoglobals // Curr
// LoadMonsterPlacements loads the MonsterPlacementRecords into MonsterPlacements.
func LoadMonsterPlacements(file []byte) {
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
MonsterPlacements = append(MonsterPlacements, MonsterPlacementRecord(d.String("code")))
}

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// MonsterSequenceRecord contains a record for a monster sequence
@ -41,7 +41,7 @@ var MonsterSequences map[string]*MonsterSequenceRecord
func LoadMonsterSequences(file []byte) {
MonsterSequences = make(map[string]*MonsterSequenceRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
name := d.String("sequence")

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// Information gathered from [https://d2mods.info/forum/kb/viewarticle?a=418]
@ -112,7 +112,7 @@ var MonsterSounds map[string]*MonsterSoundRecord
func LoadMonsterSounds(file []byte) {
MonsterSounds = make(map[string]*MonsterSoundRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonsterSoundRecord{
ID: d.String("Id"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -72,7 +72,7 @@ func LoadMonsterUniqueModifiers(file []byte) {
MonsterUniqueModifiers = make(map[string]*MonsterUniqueModifierRecord)
MonsterUniqueModifierConstants = make([]int, 0, numModifierConstants)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonsterUniqueModifierRecord{
Name: d.String("uniquemod"),

View File

@ -2,8 +2,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
MonTypes = make(map[string]*MonTypeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &MonTypeRecord{
Type: d.String("type"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -47,7 +47,7 @@ var NPCs map[string]*NPCRecord // nolint:gochecknoglobals // Currently global by
func LoadNPCs(file []byte) {
NPCs = make(map[string]*NPCRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &NPCRecord{
Name: d.String("npc"),

View File

@ -4,8 +4,8 @@ import (
"fmt"
"log"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -58,7 +58,7 @@ var ObjectGroups map[int]*ObjectGroupRecord //nolint:gochecknoglobals // Current
// LoadObjectGroups loads the ObjectGroupRecords into ObjectGroups.
func LoadObjectGroups(file []byte) {
ObjectGroups = make(map[int]*ObjectGroupRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
groupName := d.String("GroupName")
@ -84,7 +84,7 @@ func LoadObjectGroups(file []byte) {
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
for i := 0; i < objectsGroupSize; i++ {

View File

@ -4,7 +4,7 @@ import (
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
// ObjectTypeRecord is a representation of a row from objtype.txt
@ -19,7 +19,7 @@ var ObjectTypes []ObjectTypeRecord
// LoadObjectTypes loads ObjectTypeRecords from objtype.txt
func LoadObjectTypes(objectTypeData []byte) {
streamReader := d2common.CreateStreamReader(objectTypeData)
streamReader := d2datautils.CreateStreamReader(objectTypeData)
count := streamReader.GetInt32()
ObjectTypes = make([]ObjectTypeRecord, count)

View File

@ -1,10 +1,9 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// An ObjectRecord represents the settings for one type of object from objects.txt
@ -130,206 +129,206 @@ func createObjectRecord(props []string) ObjectRecord {
result := ObjectRecord{
Name: props[inc()],
Description: props[inc()],
id: d2common.StringToInt(props[inc()]),
id: d2util.StringToInt(props[inc()]),
token: props[inc()],
SpawnMax: d2common.StringToInt(props[inc()]),
SpawnMax: d2util.StringToInt(props[inc()]),
Selectable: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
TrapProbability: d2common.StringToInt(props[inc()]),
TrapProbability: d2util.StringToInt(props[inc()]),
SizeX: d2common.StringToInt(props[inc()]),
SizeY: d2common.StringToInt(props[inc()]),
SizeX: d2util.StringToInt(props[inc()]),
SizeY: d2util.StringToInt(props[inc()]),
NTgtFX: d2common.StringToInt(props[inc()]),
NTgtFY: d2common.StringToInt(props[inc()]),
NTgtBX: d2common.StringToInt(props[inc()]),
NTgtBY: d2common.StringToInt(props[inc()]),
NTgtFX: d2util.StringToInt(props[inc()]),
NTgtFY: d2util.StringToInt(props[inc()]),
NTgtBX: d2util.StringToInt(props[inc()]),
NTgtBY: d2util.StringToInt(props[inc()]),
FrameCount: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
FrameDelta: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
CycleAnimation: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
LightDiameter: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
BlocksLight: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
HasCollision: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
IsAttackable: d2common.StringToUint8(props[inc()]) == 1,
IsAttackable: d2util.StringToUint8(props[inc()]) == 1,
StartFrame: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
EnvEffect: d2common.StringToUint8(props[inc()]) == 1,
IsDoor: d2common.StringToUint8(props[inc()]) == 1,
BlockVisibility: d2common.StringToUint8(props[inc()]) == 1,
Orientation: d2common.StringToInt(props[inc()]),
Trans: d2common.StringToInt(props[inc()]),
EnvEffect: d2util.StringToUint8(props[inc()]) == 1,
IsDoor: d2util.StringToUint8(props[inc()]) == 1,
BlockVisibility: d2util.StringToUint8(props[inc()]) == 1,
Orientation: d2util.StringToInt(props[inc()]),
Trans: d2util.StringToInt(props[inc()]),
OrderFlag: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
PreOperate: d2common.StringToUint8(props[inc()]) == 1,
PreOperate: d2util.StringToUint8(props[inc()]) == 1,
HasAnimationMode: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
XOffset: d2common.StringToInt(props[inc()]),
YOffset: d2common.StringToInt(props[inc()]),
Draw: d2common.StringToUint8(props[inc()]) == 1,
XOffset: d2util.StringToInt(props[inc()]),
YOffset: d2util.StringToInt(props[inc()]),
Draw: d2util.StringToUint8(props[inc()]) == 1,
LightRed: d2common.StringToUint8(props[inc()]),
LightGreen: d2common.StringToUint8(props[inc()]),
LightBlue: d2common.StringToUint8(props[inc()]),
LightRed: d2util.StringToUint8(props[inc()]),
LightGreen: d2util.StringToUint8(props[inc()]),
LightBlue: d2util.StringToUint8(props[inc()]),
SelHD: d2common.StringToUint8(props[inc()]) == 1,
SelTR: d2common.StringToUint8(props[inc()]) == 1,
SelLG: d2common.StringToUint8(props[inc()]) == 1,
SelRA: d2common.StringToUint8(props[inc()]) == 1,
SelLA: d2common.StringToUint8(props[inc()]) == 1,
SelRH: d2common.StringToUint8(props[inc()]) == 1,
SelLH: d2common.StringToUint8(props[inc()]) == 1,
SelSH: d2common.StringToUint8(props[inc()]) == 1,
SelHD: d2util.StringToUint8(props[inc()]) == 1,
SelTR: d2util.StringToUint8(props[inc()]) == 1,
SelLG: d2util.StringToUint8(props[inc()]) == 1,
SelRA: d2util.StringToUint8(props[inc()]) == 1,
SelLA: d2util.StringToUint8(props[inc()]) == 1,
SelRH: d2util.StringToUint8(props[inc()]) == 1,
SelLH: d2util.StringToUint8(props[inc()]) == 1,
SelSH: d2util.StringToUint8(props[inc()]) == 1,
SelS: [8]bool{
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2common.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
d2util.StringToUint8(props[inc()]) == 1,
},
TotalPieces: d2common.StringToInt(props[inc()]),
SubClass: d2common.StringToInt(props[inc()]),
TotalPieces: d2util.StringToInt(props[inc()]),
SubClass: d2util.StringToInt(props[inc()]),
XSpace: d2common.StringToInt(props[inc()]),
YSpace: d2common.StringToInt(props[inc()]),
XSpace: d2util.StringToInt(props[inc()]),
YSpace: d2util.StringToInt(props[inc()]),
NameOffset: d2common.StringToInt(props[inc()]),
NameOffset: d2util.StringToInt(props[inc()]),
MonsterOk: d2common.StringToUint8(props[inc()]) == 1,
OperateRange: d2common.StringToInt(props[inc()]),
ShrineFunction: d2common.StringToInt(props[inc()]),
Restore: d2common.StringToUint8(props[inc()]) == 1,
MonsterOk: d2util.StringToUint8(props[inc()]) == 1,
OperateRange: d2util.StringToInt(props[inc()]),
ShrineFunction: d2util.StringToInt(props[inc()]),
Restore: d2util.StringToUint8(props[inc()]) == 1,
Parm: [8]int{
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2common.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
d2util.StringToInt(props[inc()]),
},
Act: d2common.StringToInt(props[inc()]),
Lockable: d2common.StringToUint8(props[inc()]) == 1,
Gore: d2common.StringToUint8(props[inc()]) == 1,
Sync: d2common.StringToUint8(props[inc()]) == 1,
Flicker: d2common.StringToUint8(props[inc()]) == 1,
Damage: d2common.StringToInt(props[inc()]),
Beta: d2common.StringToUint8(props[inc()]) == 1,
Overlay: d2common.StringToUint8(props[inc()]) == 1,
CollisionSubst: d2common.StringToUint8(props[inc()]) == 1,
Act: d2util.StringToInt(props[inc()]),
Lockable: d2util.StringToUint8(props[inc()]) == 1,
Gore: d2util.StringToUint8(props[inc()]) == 1,
Sync: d2util.StringToUint8(props[inc()]) == 1,
Flicker: d2util.StringToUint8(props[inc()]) == 1,
Damage: d2util.StringToInt(props[inc()]),
Beta: d2util.StringToUint8(props[inc()]) == 1,
Overlay: d2util.StringToUint8(props[inc()]) == 1,
CollisionSubst: d2util.StringToUint8(props[inc()]) == 1,
Left: d2common.StringToInt(props[inc()]),
Top: d2common.StringToInt(props[inc()]),
Width: d2common.StringToInt(props[inc()]),
Height: d2common.StringToInt(props[inc()]),
Left: d2util.StringToInt(props[inc()]),
Top: d2util.StringToInt(props[inc()]),
Width: d2util.StringToInt(props[inc()]),
Height: d2util.StringToInt(props[inc()]),
OperateFn: d2common.StringToInt(props[inc()]),
PopulateFn: d2common.StringToInt(props[inc()]),
InitFn: d2common.StringToInt(props[inc()]),
ClientFn: d2common.StringToInt(props[inc()]),
OperateFn: d2util.StringToInt(props[inc()]),
PopulateFn: d2util.StringToInt(props[inc()]),
InitFn: d2util.StringToInt(props[inc()]),
ClientFn: d2util.StringToInt(props[inc()]),
RestoreVirgins: d2common.StringToUint8(props[inc()]) == 1,
BlockMissile: d2common.StringToUint8(props[inc()]) == 1,
DrawUnder: d2common.StringToUint8(props[inc()]) == 1,
OpenWarp: d2common.StringToUint8(props[inc()]) == 1,
RestoreVirgins: d2util.StringToUint8(props[inc()]) == 1,
BlockMissile: d2util.StringToUint8(props[inc()]) == 1,
DrawUnder: d2util.StringToUint8(props[inc()]) == 1,
OpenWarp: d2util.StringToUint8(props[inc()]) == 1,
AutoMap: d2common.StringToInt(props[inc()]),
AutoMap: d2util.StringToInt(props[inc()]),
}
return result

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"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]
@ -67,7 +67,7 @@ var Overlays map[string]*OverlayRecord // nolint:gochecknoglobals // Currently g
// LoadOverlays loads overlay records from Overlay.txt
func LoadOverlays(file []byte) {
Overlays = make(map[string]*OverlayRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &OverlayRecord{

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
PetTypes = make(map[string]*PetTypeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &PetTypeRecord{
Name: d.String("pet type"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// PlayerClassRecord represents a single line from PlayerClass.txt
@ -23,7 +23,7 @@ var PlayerClasses map[string]*PlayerClassRecord // nolint:gochecknoglobals // Cu
func LoadPlayerClasses(file []byte) {
PlayerClasses = make(map[string]*PlayerClassRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &PlayerClassRecord{
Name: d.String("Player Class"),

View File

@ -2,8 +2,8 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
PlrModes = make(map[string]*PlrModeRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &PlrModeRecord{
Name: d.String("Name"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// PropertyStatRecord contains stat information for a property
@ -28,7 +28,7 @@ var Properties map[string]*PropertyRecord //nolint:gochecknoglobals // Currently
func LoadProperties(file []byte) {
Properties = make(map[string]*PropertyRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
prop := &PropertyRecord{
Code: d.String("code"),

View File

@ -4,7 +4,7 @@ import (
"log"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// 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) {
QualityItems = make(map[string]*QualityRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
qual := &QualityRecord{
NumMods: d.Number("nummods"),

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -27,7 +27,7 @@ var RarePrefixes []*RareItemPrefixRecord // nolint:gochecknoglobals // global by
// LoadRareItemPrefixRecords loads the rare item prefix records from rareprefix.txt
func LoadRareItemPrefixRecords(file []byte) {
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
RarePrefixes = make([]*RareItemPrefixRecord, 0)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -27,7 +27,7 @@ var RareSuffixes []*RareItemSuffixRecord // nolint:gochecknoglobals // global by
// LoadRareItemSuffixRecords loads the rare item suffix records from raresuffix.txt
func LoadRareItemSuffixRecords(file []byte) {
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
RareSuffixes = make([]*RareItemSuffixRecord, 0)

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -67,7 +67,7 @@ var Runewords map[string]*RunesRecord //nolint:gochecknoglobals // Currently glo
func LoadRunewords(file []byte) {
Runewords = make(map[string]*RunesRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &RunesRecord{
Name: d.String("name"),

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -133,7 +133,7 @@ var SetItems map[string]*SetItemRecord //nolint:gochecknoglobals // Currently gl
func LoadSetItems(file []byte) {
SetItems = make(map[string]*SetItemRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &SetItemRecord{

View File

@ -3,8 +3,8 @@ package d2datadict
import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
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
SetRecords = make(map[string]*SetRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &SetRecord{
Key: d.String("index"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// ShrineRecord is a representation of a row from shrines.txt
@ -29,7 +29,7 @@ var Shrines map[string]*ShrineRecord
func LoadShrines(file []byte) {
Shrines = make(map[string]*ShrineRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &ShrineRecord{
ShrineType: d.String("Shrine Type"),

View File

@ -3,9 +3,9 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
"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
@ -137,7 +137,7 @@ func LoadSkillDescriptions(file []byte) { //nolint:funlen // doesn't make sense
parser := d2parser.New()
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() {
record := &SkillDescriptionRecord{
d.String("skilldesc"),

View File

@ -3,9 +3,9 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2calculation/d2parser"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// SkillDetails has all of the SkillRecords
@ -266,7 +266,7 @@ func LoadSkills(file []byte) {
parser := d2parser.New()
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
name := d.String("skill")
parser.SetCurrentReference("skill", name)

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// SoundEnvironRecord describes the different sound environments. Not listed on Phrozen Keep.
@ -42,7 +42,7 @@ var SoundEnvirons map[int]*SoundEnvironRecord
func LoadSoundEnvirons(file []byte) {
SoundEnvirons = make(map[int]*SoundEnvironRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &SoundEnvironRecord{
Handle: d.String("Handle"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// SoundEntry represents a sound entry
@ -43,7 +43,7 @@ var Sounds map[string]*SoundEntry
func LoadSounds(file []byte) {
Sounds = make(map[string]*SoundEntry)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
entry := &SoundEntry{
Handle: d.String("Sound"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// StateRecord describes a body location that items can be equipped to
@ -249,7 +249,7 @@ var States map[string]*StateRecord
func LoadStates(file []byte) {
States = make(map[string]*StateRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &StateRecord{
State: d.String("state"),

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// https://d2mods.info/forum/kb/viewarticle?a=162
@ -127,7 +127,7 @@ var SuperUniques map[string]*SuperUniqueRecord
func LoadSuperUniques(file []byte) {
SuperUniques = make(map[string]*SuperUniqueRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &SuperUniqueRecord{
Key: d.String("Superunique"),

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
const (
@ -42,7 +42,7 @@ var TreasureClass map[string]*TreasureClassRecord //nolint:gochecknoglobals // C
func LoadTreasureClassRecords(file []byte) {
TreasureClass = make(map[string]*TreasureClassRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &TreasureClassRecord{

View File

@ -3,7 +3,7 @@ package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// UniqueAppellationRecord described the extra suffix of a unique monster name
@ -20,7 +20,7 @@ var UniqueAppellations map[string]*UniqueAppellationRecord
func LoadUniqueAppellations(file []byte) {
UniqueAppellations = make(map[string]*UniqueAppellationRecord)
d := d2common.LoadDataDictionary(file)
d := d2txt.LoadDataDictionary(file)
for d.Next() {
record := &UniqueAppellationRecord{
Name: d.String("Name"),

View File

@ -1,10 +1,9 @@
package d2datadict
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"log"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// UniqueItemRecord is a representation of a row from uniqueitems.txt
@ -56,22 +55,22 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
}
result := UniqueItemRecord{
Name: r[inc()],
Version: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Enabled: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
Version: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Enabled: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
Ladder: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
Rarity: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
NoLimit: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
Ladder: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
Rarity: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
NoLimit: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
Level: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
RequiredLevel: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
Level: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
RequiredLevel: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
Code: r[inc()],
TypeDescription: r[inc()],
UberDescription: r[inc()],
SingleCopy: d2common.StringToInt(d2common.EmptyToZero(r[inc()])) == 1,
CostMultiplier: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
CostAdd: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
SingleCopy: d2util.StringToInt(d2util.EmptyToZero(r[inc()])) == 1,
CostMultiplier: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
CostAdd: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
CharacterGfxTransform: r[inc()],
InventoryGfxTransform: r[inc()],
@ -79,7 +78,7 @@ func createUniqueItemRecord(r []string) UniqueItemRecord {
InventoryFile: r[inc()],
DropSound: r[inc()],
DropSfxFrame: d2common.StringToInt(d2common.EmptyToZero(r[inc()])),
DropSfxFrame: d2util.StringToInt(d2util.EmptyToZero(r[inc()])),
UseSound: r[inc()],
Properties: [12]UniqueItemProperty{
@ -107,8 +106,8 @@ func createUniqueItemProperty(r *[]string, inc func() int) UniqueItemProperty {
result := UniqueItemProperty{
Code: (*r)[inc()],
Parameter: (*r)[inc()],
Min: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Max: d2common.StringToInt(d2common.EmptyToZero((*r)[inc()])),
Min: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
Max: d2util.StringToInt(d2util.EmptyToZero((*r)[inc()])),
}
return result

View File

@ -1,9 +1,8 @@
package d2video
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// BinkVideoMode is the video mode type
@ -53,7 +52,7 @@ type BinkAudioTrack struct {
type BinkDecoder struct {
AudioTracks []BinkAudioTrack
FrameIndexTable []uint32
streamReader *d2common.StreamReader
streamReader *d2datautils.StreamReader
fileSize uint32
numberOfFrames uint32
largestFrameSizeBytes uint32
@ -74,7 +73,7 @@ type BinkDecoder struct {
// CreateBinkDecoder returns a new instance of the bink decoder
func CreateBinkDecoder(source []byte) *BinkDecoder {
result := &BinkDecoder{
streamReader: d2common.CreateStreamReader(source),
streamReader: d2datautils.CreateStreamReader(source),
}
result.loadHeaderInformation()

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
// BitMuncher is used for parsing files that are not byte-aligned such as the DCC files.
type BitMuncher struct {

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import (
"log"

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import (
"testing"

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import (
"io"

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import (
"testing"

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import "bytes"

View File

@ -1,4 +1,4 @@
package d2common
package d2datautils
import (
"testing"

View File

@ -1,9 +1,9 @@
package d2cof
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
)
@ -22,7 +22,7 @@ type COF struct {
// Load loads a COF file.
func Load(fileData []byte) (*COF, error) {
result := &COF{}
streamReader := d2common.CreateStreamReader(fileData)
streamReader := d2datautils.CreateStreamReader(fileData)
result.NumberOfLayers = int(streamReader.GetByte())
result.FramesPerDirection = int(streamReader.GetByte())
result.NumberOfDirections = int(streamReader.GetByte())

View File

@ -1,7 +1,7 @@
package d2dc6
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
const (
@ -36,7 +36,7 @@ func Load(data []byte) (*DC6, error) {
terminatorSize = 3
)
r := d2common.CreateStreamReader(data)
r := d2datautils.CreateStreamReader(data)
var dc DC6
dc.Version = r.GetInt32()

View File

@ -2,8 +2,7 @@ package d2dcc
import (
"errors"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
const dccFileSignature = 0x74
@ -25,7 +24,7 @@ func Load(fileData []byte) (*DCC, error) {
fileData: fileData,
}
var bm = d2common.CreateBitMuncher(fileData, 0)
var bm = d2datautils.CreateBitMuncher(fileData, 0)
result.Signature = int(bm.GetByte())
@ -54,6 +53,6 @@ func Load(fileData []byte) (*DCC, error) {
// DecodeDirection decodes and returns the given direction
func (dcc *DCC) DecodeDirection(direction int) *DCCDirection {
return CreateDCCDirection(d2common.CreateBitMuncher(dcc.fileData,
return CreateDCCDirection(d2datautils.CreateBitMuncher(dcc.fileData,
dcc.directionOffsets[direction]*directionOffsetMultiplier), dcc)
}

View File

@ -1,9 +1,10 @@
package d2dcc
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2geom"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
)
@ -26,7 +27,7 @@ type DCCDirection struct {
RawPixelCodesBitstreamSize int
Frames []*DCCDirectionFrame
PaletteEntries [256]byte
Box d2common.Rectangle
Box d2geom.Rectangle
Cells []*DCCCell
PixelData []byte
HorizontalCellCount int
@ -35,7 +36,7 @@ type DCCDirection struct {
}
// 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}
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)))
}
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 {
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
// the EqualCellsBitstreamSize is 20 bytes, then the next bit stream
// will be located at byte 23, bit offset 6!
equalCellsBitstream := d2common.CopyBitMuncher(bm)
equalCellsBitstream := d2datautils.CopyBitMuncher(bm)
bm.SkipBits(result.EqualCellsBitstreamSize)
pixelMaskBitstream := d2common.CopyBitMuncher(bm)
pixelMaskBitstream := d2datautils.CopyBitMuncher(bm)
bm.SkipBits(result.PixelMaskBitstreamSize)
encodingTypeBitsream := d2common.CopyBitMuncher(bm)
encodingTypeBitsream := d2datautils.CopyBitMuncher(bm)
bm.SkipBits(result.EncodingTypeBitsreamSize)
rawPixelCodesBitstream := d2common.CopyBitMuncher(bm)
rawPixelCodesBitstream := d2datautils.CopyBitMuncher(bm)
bm.SkipBits(result.RawPixelCodesBitstreamSize)
pixelCodeandDisplacement := d2common.CopyBitMuncher(bm)
pixelCodeandDisplacement := d2datautils.CopyBitMuncher(bm)
// Calculate the cells for the direction
result.calculateCells()
@ -137,7 +138,7 @@ func CreateDCCDirection(bm *d2common.BitMuncher, file *DCC) *DCCDirection {
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 {
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
func (v *DCCDirection) generateFrames(pcd *d2common.BitMuncher) {
func (v *DCCDirection) generateFrames(pcd *d2datautils.BitMuncher) {
pbIdx := 0
for _, cell := range v.Cells {
@ -259,7 +260,7 @@ func (v *DCCDirection) generateFrames(pcd *d2common.BitMuncher) {
}
//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}
lastPixel := uint32(0)

View File

@ -1,14 +1,14 @@
package d2dcc
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2geom"
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
// DCCDirectionFrame represents a direction frame for a DCC.
type DCCDirectionFrame struct {
Box d2common.Rectangle
Box d2geom.Rectangle
Cells []DCCCell
PixelData []byte
Width int
@ -24,7 +24,7 @@ type DCCDirectionFrame struct {
}
// 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{}
bits.GetBits(direction.Variable0Bits) // Variable0
@ -40,7 +40,7 @@ func CreateDCCDirectionFrame(bits *d2common.BitMuncher, direction *DCCDirection)
if result.FrameIsBottomUp {
log.Panic("Bottom up frames are not implemented.")
} else {
result.Box = d2common.Rectangle{
result.Box = d2geom.Rectangle{
Left: result.XOffset,
Top: result.YOffset - result.Height + 1,
Width: result.Width,

View File

@ -1,10 +1,11 @@
package d2ds1
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2path"
)
const maxActNumber = 5
@ -36,7 +37,7 @@ func LoadDS1(fileData []byte) (*DS1, error) {
NumberOfShadowLayers: 1,
NumberOfSubstitutionLayers: 0,
}
br := d2common.CreateStreamReader(fileData)
br := d2datautils.CreateStreamReader(fileData)
ds1.Version = br.GetInt32()
ds1.Width = br.GetInt32() + 1
ds1.Height = br.GetInt32() + 1
@ -107,7 +108,7 @@ func LoadDS1(fileData []byte) (*DS1, error) {
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
numberOfObjects := br.GetInt32()
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 >= 18 { //nolint:gomnd // Version number
br.GetUInt32()
@ -188,7 +189,7 @@ func (ds1 *DS1) setupStreamLayerTypes() []d2enum.LayerStreamType {
return layerStream
}
func (ds1 *DS1) loadNPCs(br *d2common.StreamReader) {
func (ds1 *DS1) loadNPCs(br *d2datautils.StreamReader) {
if ds1.Version >= 14 { //nolint:gomnd // Version number
numberOfNpcs := br.GetInt32()
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 {
ds1.Objects[objIdx].Paths = make([]d2common.Path, numPaths)
ds1.Objects[objIdx].Paths = make([]d2path.Path, numPaths)
}
for pathIdx := 0; pathIdx < numPaths; pathIdx++ {
newPath := d2common.Path{}
newPath := d2path.Path{}
newPath.Position = d2vector.NewPosition(
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{
0x00, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, 0x05, 0x05, 0x06,
0x06, 0x07, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,

View File

@ -1,7 +1,7 @@
package d2ds1
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2path"
)
// Object is a game world object
@ -11,5 +11,5 @@ type Object struct {
X int
Y int
Flags int
Paths []d2common.Path
Paths []d2path.Path
}

View File

@ -2,8 +2,7 @@ package d2dt1
import (
"fmt"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
// DT1 represents a DT1 file.
@ -26,7 +25,7 @@ const (
//nolint:funlen Can't reduce
func LoadDT1(fileData []byte) (*DT1, error) {
result := &DT1{}
br := d2common.CreateStreamReader(fileData)
br := d2datautils.CreateStreamReader(fileData)
ver1 := br.GetInt32()
ver2 := br.GetInt32()

View File

@ -0,0 +1,2 @@
// Package d2tbl provides a file parser for tbl string table files
package d2tbl

View File

@ -1,8 +1,10 @@
package d2common
package d2tbl
import (
"log"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
)
type textDictionaryHashEntry struct {
@ -38,7 +40,7 @@ func LoadTextDictionary(dictionaryData []byte) {
lookupTable = make(map[string]string)
}
br := CreateStreamReader(dictionaryData)
br := d2datautils.CreateStreamReader(dictionaryData)
// skip past the CRC
br.ReadBytes(crcByteCount)

View File

@ -1,4 +1,4 @@
package d2common
package d2txt
import (
"bytes"

View File

@ -0,0 +1,2 @@
// Package d2txt provides a parser implementation for diablo TSV data files
package d2txt

View File

@ -1,4 +1,4 @@
package d2common
package d2geom
// Point represents a point
type Point struct {

View File

@ -1,4 +1,4 @@
package d2common
package d2geom
// Rectangle represents a rectangle
type Rectangle struct {

View File

@ -1,4 +1,4 @@
package d2common
package d2geom
// Size represents a size
type Size struct {

View File

@ -1,4 +1,4 @@
package d2common
package d2path
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"

View File

@ -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]
}

View File

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