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:
lord 2020-08-06 13:45:38 -07:00 committed by GitHub
parent 33f66badfc
commit 16b8a6467f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 21 deletions

View File

@ -7,6 +7,11 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
)
const (
numCofNameBytes = 8
numFlagBytes = 144
)
// AnimationDataRecord represents a single entry in the animation data dictionary file
type AnimationDataRecord struct {
// COFName is the name of the COF file used for this animation
@ -30,13 +35,13 @@ func LoadAnimationData(rawData []byte) {
for !streamReader.EOF() {
dataCount := int(streamReader.GetInt32())
for i := 0; i < dataCount; i++ {
cofNameBytes := streamReader.ReadBytes(8)
cofNameBytes := streamReader.ReadBytes(numCofNameBytes)
data := &AnimationDataRecord{
COFName: strings.ReplaceAll(string(cofNameBytes), string(0), ""),
FramesPerDirection: int(streamReader.GetInt32()),
AnimationSpeed: int(streamReader.GetInt32()),
}
data.Flags = streamReader.ReadBytes(144)
data.Flags = streamReader.ReadBytes(numFlagBytes)
cofIndex := strings.ToLower(data.COFName)
if _, found := AnimationData[cofIndex]; !found {

View File

@ -256,7 +256,8 @@ func insertNode(tail *linkedNode, decomp int) *linkedNode {
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)
return result

View File

@ -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
// these show up in a lot of txt files where blizzard added LoD expansion stuff
const (
expansion = "Expansion"
expansionCode = 100

View 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

View File

@ -11,22 +11,22 @@ type BinkVideoMode uint32
const (
// BinkVideoModeNormal is a normal video
BinkVideoModeNormal BinkVideoMode = 0
BinkVideoModeNormal BinkVideoMode = iota
// BinkVideoModeHeightDoubled is a height-doubled video
BinkVideoModeHeightDoubled BinkVideoMode = 1
BinkVideoModeHeightDoubled
// BinkVideoModeHeightInterlaced is a height-interlaced video
BinkVideoModeHeightInterlaced BinkVideoMode = 2
BinkVideoModeHeightInterlaced
// BinkVideoModeWidthDoubled is a width-doubled video
BinkVideoModeWidthDoubled BinkVideoMode = 3
BinkVideoModeWidthDoubled
// BinkVideoModeWidthAndHeightDoubled is a width and height-doubled video
BinkVideoModeWidthAndHeightDoubled BinkVideoMode = 4
BinkVideoModeWidthAndHeightDoubled
// BinkVideoModeWidthAndHeightInterlaced is a width and height interlaced video
BinkVideoModeWidthAndHeightInterlaced BinkVideoMode = 5
BinkVideoModeWidthAndHeightInterlaced
)
// BinkAudioAlgorithm represents the type of bink audio algorithm
@ -34,10 +34,10 @@ type BinkAudioAlgorithm uint32
const (
// BinkAudioAlgorithmFFT is the FTT audio algorithm
BinkAudioAlgorithmFFT BinkAudioAlgorithm = 0
BinkAudioAlgorithmFFT BinkAudioAlgorithm = iota
// BinkAudioAlgorithmDCT is the DCT audio algorithm
BinkAudioAlgorithmDCT BinkAudioAlgorithm = 1
BinkAudioAlgorithmDCT
)
// BinkAudioTrack represents an audio track
@ -84,8 +84,7 @@ func CreateBinkDecoder(source []byte) *BinkDecoder {
// GetNextFrame gets the next frame
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
samplesInPacket := v.streamReader.GetUInt32()

View File

@ -0,0 +1,2 @@
// Package d2video provides a bink video decoder
package d2video

3
d2common/d2data/doc.go Normal file
View 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

View File

@ -2,7 +2,6 @@ package d2ds1
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math"
"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.
type DS1 struct {
Files []string // FilePtr table of file string pointers
Objects []d2data.Object // Objects
Objects []Object // Objects
Tiles [][]TileRecord // The tile data for the DS1
SubstitutionGroups []SubstitutionGroup // Substitution groups for 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) {
if ds1.Version >= 2 { //nolint:gomnd // Version number
numberOfObjects := br.GetInt32()
ds1.Objects = make([]d2data.Object, numberOfObjects)
ds1.Objects = make([]Object, numberOfObjects)
for objIdx := 0; objIdx < int(numberOfObjects); objIdx++ {
newObject := d2data.Object{}
newObject := Object{}
newObject.Type = int(br.GetInt32())
newObject.ID = int(br.GetInt32())
newObject.X = int(br.GetInt32())
@ -124,7 +123,7 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
ds1.Objects[objIdx] = newObject
}
} else {
ds1.Objects = make([]d2data.Object, 0)
ds1.Objects = make([]Object, 0)
}
}

View File

@ -1,4 +1,4 @@
package d2data
package d2ds1
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"