mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-10-15 06:33:46 -04:00
fixed most lint errors in d2data (#701)
- moved ds1 object definition into the ds1 dir - added doc files - only lint errors remaining are for the unused variables in d2video
This commit is contained in:
parent
33f66badfc
commit
16b8a6467f
@ -7,6 +7,11 @@ import (
|
|||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
numCofNameBytes = 8
|
||||||
|
numFlagBytes = 144
|
||||||
|
)
|
||||||
|
|
||||||
// AnimationDataRecord represents a single entry in the animation data dictionary file
|
// AnimationDataRecord represents a single entry in the animation data dictionary file
|
||||||
type AnimationDataRecord struct {
|
type AnimationDataRecord struct {
|
||||||
// COFName is the name of the COF file used for this animation
|
// COFName is the name of the COF file used for this animation
|
||||||
@ -30,13 +35,13 @@ func LoadAnimationData(rawData []byte) {
|
|||||||
for !streamReader.EOF() {
|
for !streamReader.EOF() {
|
||||||
dataCount := int(streamReader.GetInt32())
|
dataCount := int(streamReader.GetInt32())
|
||||||
for i := 0; i < dataCount; i++ {
|
for i := 0; i < dataCount; i++ {
|
||||||
cofNameBytes := streamReader.ReadBytes(8)
|
cofNameBytes := streamReader.ReadBytes(numCofNameBytes)
|
||||||
data := &AnimationDataRecord{
|
data := &AnimationDataRecord{
|
||||||
COFName: strings.ReplaceAll(string(cofNameBytes), string(0), ""),
|
COFName: strings.ReplaceAll(string(cofNameBytes), string(0), ""),
|
||||||
FramesPerDirection: int(streamReader.GetInt32()),
|
FramesPerDirection: int(streamReader.GetInt32()),
|
||||||
AnimationSpeed: int(streamReader.GetInt32()),
|
AnimationSpeed: int(streamReader.GetInt32()),
|
||||||
}
|
}
|
||||||
data.Flags = streamReader.ReadBytes(144)
|
data.Flags = streamReader.ReadBytes(numFlagBytes)
|
||||||
cofIndex := strings.ToLower(data.COFName)
|
cofIndex := strings.ToLower(data.COFName)
|
||||||
|
|
||||||
if _, found := AnimationData[cofIndex]; !found {
|
if _, found := AnimationData[cofIndex]; !found {
|
||||||
|
@ -256,7 +256,8 @@ func insertNode(tail *linkedNode, decomp int) *linkedNode {
|
|||||||
|
|
||||||
adjustTree(newnode)
|
adjustTree(newnode)
|
||||||
|
|
||||||
// TODO: For compression type 0, AdjustTree should be called once for every value written and only once here
|
// ISSUE #680: For compression type 0, adjustTree should be
|
||||||
|
// called once for every value written and only once here
|
||||||
adjustTree(newnode)
|
adjustTree(newnode)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Package d2datadict parses txt files as data dictionaries and exports records arrays
|
|
||||||
// For the Diablo II MPQ's, data dictionaries are the tab-separated value txt files found in `data/global/excel`
|
|
||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
|
// these show up in a lot of txt files where blizzard added LoD expansion stuff
|
||||||
const (
|
const (
|
||||||
expansion = "Expansion"
|
expansion = "Expansion"
|
||||||
expansionCode = 100
|
expansionCode = 100
|
||||||
|
4
d2common/d2data/d2datadict/doc.go
Normal file
4
d2common/d2data/d2datadict/doc.go
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// Package d2datadict parses txt files as data dictionaries and exports records arrays
|
||||||
|
// For the Diablo II MPQ's, data dictionaries are the tab-separated value txt files
|
||||||
|
// found in `data/global/excel`
|
||||||
|
package d2datadict
|
@ -11,22 +11,22 @@ type BinkVideoMode uint32
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// BinkVideoModeNormal is a normal video
|
// BinkVideoModeNormal is a normal video
|
||||||
BinkVideoModeNormal BinkVideoMode = 0
|
BinkVideoModeNormal BinkVideoMode = iota
|
||||||
|
|
||||||
// BinkVideoModeHeightDoubled is a height-doubled video
|
// BinkVideoModeHeightDoubled is a height-doubled video
|
||||||
BinkVideoModeHeightDoubled BinkVideoMode = 1
|
BinkVideoModeHeightDoubled
|
||||||
|
|
||||||
// BinkVideoModeHeightInterlaced is a height-interlaced video
|
// BinkVideoModeHeightInterlaced is a height-interlaced video
|
||||||
BinkVideoModeHeightInterlaced BinkVideoMode = 2
|
BinkVideoModeHeightInterlaced
|
||||||
|
|
||||||
// BinkVideoModeWidthDoubled is a width-doubled video
|
// BinkVideoModeWidthDoubled is a width-doubled video
|
||||||
BinkVideoModeWidthDoubled BinkVideoMode = 3
|
BinkVideoModeWidthDoubled
|
||||||
|
|
||||||
// BinkVideoModeWidthAndHeightDoubled is a width and height-doubled video
|
// BinkVideoModeWidthAndHeightDoubled is a width and height-doubled video
|
||||||
BinkVideoModeWidthAndHeightDoubled BinkVideoMode = 4
|
BinkVideoModeWidthAndHeightDoubled
|
||||||
|
|
||||||
// BinkVideoModeWidthAndHeightInterlaced is a width and height interlaced video
|
// BinkVideoModeWidthAndHeightInterlaced is a width and height interlaced video
|
||||||
BinkVideoModeWidthAndHeightInterlaced BinkVideoMode = 5
|
BinkVideoModeWidthAndHeightInterlaced
|
||||||
)
|
)
|
||||||
|
|
||||||
// BinkAudioAlgorithm represents the type of bink audio algorithm
|
// BinkAudioAlgorithm represents the type of bink audio algorithm
|
||||||
@ -34,10 +34,10 @@ type BinkAudioAlgorithm uint32
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// BinkAudioAlgorithmFFT is the FTT audio algorithm
|
// BinkAudioAlgorithmFFT is the FTT audio algorithm
|
||||||
BinkAudioAlgorithmFFT BinkAudioAlgorithm = 0
|
BinkAudioAlgorithmFFT BinkAudioAlgorithm = iota
|
||||||
|
|
||||||
// BinkAudioAlgorithmDCT is the DCT audio algorithm
|
// BinkAudioAlgorithmDCT is the DCT audio algorithm
|
||||||
BinkAudioAlgorithmDCT BinkAudioAlgorithm = 1
|
BinkAudioAlgorithmDCT
|
||||||
)
|
)
|
||||||
|
|
||||||
// BinkAudioTrack represents an audio track
|
// BinkAudioTrack represents an audio track
|
||||||
@ -84,8 +84,7 @@ func CreateBinkDecoder(source []byte) *BinkDecoder {
|
|||||||
|
|
||||||
// GetNextFrame gets the next frame
|
// GetNextFrame gets the next frame
|
||||||
func (v *BinkDecoder) GetNextFrame() {
|
func (v *BinkDecoder) GetNextFrame() {
|
||||||
//nolint:gocritic // v.streamReader.SetPosition(uint64(v.FrameIndexTable[i] & 0xFFFFFFFE))
|
//nolint:gocritic // v.streamReader.SetPosition(uint64(v.FrameIndexTable[i] & 0xFFFFFFFE))
|
||||||
|
|
||||||
lengthOfAudioPackets := v.streamReader.GetUInt32() - 4 //nolint:gomnd // decode magic
|
lengthOfAudioPackets := v.streamReader.GetUInt32() - 4 //nolint:gomnd // decode magic
|
||||||
samplesInPacket := v.streamReader.GetUInt32()
|
samplesInPacket := v.streamReader.GetUInt32()
|
||||||
|
|
||||||
|
2
d2common/d2data/d2video/doc.go
Normal file
2
d2common/d2data/d2video/doc.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Package d2video provides a bink video decoder
|
||||||
|
package d2video
|
3
d2common/d2data/doc.go
Normal file
3
d2common/d2data/doc.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Package d2data provides file compression utilities, video decoders, and file loaders
|
||||||
|
// for the txt files inside of diablo's mpq files
|
||||||
|
package d2data
|
@ -2,7 +2,6 @@ package d2ds1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data"
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
||||||
@ -13,7 +12,7 @@ const maxActNumber = 5
|
|||||||
// DS1 represents the "stamp" data that is used to build up maps.
|
// DS1 represents the "stamp" data that is used to build up maps.
|
||||||
type DS1 struct {
|
type DS1 struct {
|
||||||
Files []string // FilePtr table of file string pointers
|
Files []string // FilePtr table of file string pointers
|
||||||
Objects []d2data.Object // Objects
|
Objects []Object // Objects
|
||||||
Tiles [][]TileRecord // The tile data for the DS1
|
Tiles [][]TileRecord // The tile data for the DS1
|
||||||
SubstitutionGroups []SubstitutionGroup // Substitution groups for the DS1
|
SubstitutionGroups []SubstitutionGroup // Substitution groups for the DS1
|
||||||
Version int32 // The version of the DS1
|
Version int32 // The version of the DS1
|
||||||
@ -111,10 +110,10 @@ func LoadDS1(fileData []byte) (*DS1, error) {
|
|||||||
func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
||||||
if ds1.Version >= 2 { //nolint:gomnd // Version number
|
if ds1.Version >= 2 { //nolint:gomnd // Version number
|
||||||
numberOfObjects := br.GetInt32()
|
numberOfObjects := br.GetInt32()
|
||||||
ds1.Objects = make([]d2data.Object, numberOfObjects)
|
ds1.Objects = make([]Object, numberOfObjects)
|
||||||
|
|
||||||
for objIdx := 0; objIdx < int(numberOfObjects); objIdx++ {
|
for objIdx := 0; objIdx < int(numberOfObjects); objIdx++ {
|
||||||
newObject := d2data.Object{}
|
newObject := Object{}
|
||||||
newObject.Type = int(br.GetInt32())
|
newObject.Type = int(br.GetInt32())
|
||||||
newObject.ID = int(br.GetInt32())
|
newObject.ID = int(br.GetInt32())
|
||||||
newObject.X = int(br.GetInt32())
|
newObject.X = int(br.GetInt32())
|
||||||
@ -124,7 +123,7 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
|||||||
ds1.Objects[objIdx] = newObject
|
ds1.Objects[objIdx] = newObject
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ds1.Objects = make([]d2data.Object, 0)
|
ds1.Objects = make([]Object, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package d2data
|
package d2ds1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
Loading…
Reference in New Issue
Block a user