1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-03 15:17:04 -05:00

d2common: fix fieldalignment lints

This commit is contained in:
gucio321 2021-06-13 16:04:38 +02:00
parent c1d048a616
commit dfc575ce75
29 changed files with 242 additions and 247 deletions

View File

@ -11,10 +11,10 @@ import (
var _ d2interface.Cache = &Cache{} // Static check to confirm struct conforms to interface var _ d2interface.Cache = &Cache{} // Static check to confirm struct conforms to interface
type cacheNode struct { type cacheNode struct {
value interface{}
next *cacheNode next *cacheNode
prev *cacheNode prev *cacheNode
key string key string
value interface{}
weight int weight int
} }

View File

@ -39,8 +39,8 @@ func (t tokenType) String() string {
// Token is a lexical token of a calculation string. // Token is a lexical token of a calculation string.
type Token struct { type Token struct {
Type tokenType
Value string Value string
Type tokenType
} }
func (t *Token) String() string { func (t *Token) String() string {
@ -49,11 +49,11 @@ func (t *Token) String() string {
// Lexer is the tokenizer for calculation strings. // Lexer is the tokenizer for calculation strings.
type Lexer struct { type Lexer struct {
data []byte
CurrentToken Token CurrentToken Token
nextToken Token
data []byte
index int index int
peeked bool peeked bool
nextToken Token
} }
// New creates a new Lexer for tokenizing the given data. // New creates a new Lexer for tokenizing the given data.
@ -79,7 +79,7 @@ func (l *Lexer) extractOpToken() Token {
panic("Invalid operator at index!" + strconv.Itoa(l.index)) panic("Invalid operator at index!" + strconv.Itoa(l.index))
} else { } else {
l.index += 2 l.index += 2
return Token{Symbol, string(c) + "="} return Token{Type: Symbol, Value: string(c) + "="}
} }
} }
@ -87,15 +87,15 @@ func (l *Lexer) extractOpToken() Token {
next, ok := l.peekNext() next, ok := l.peekNext()
if ok == nil && next == '=' { if ok == nil && next == '=' {
l.index += 2 l.index += 2
return Token{Symbol, string(c) + "="} return Token{Type: Symbol, Value: string(c) + "="}
} }
l.index++ l.index++
return Token{Symbol, string(c)} return Token{Type: Symbol, Value: string(c)}
} }
l.index++ l.index++
return Token{Symbol, string(c)} return Token{Type: Symbol, Value: string(c)}
} }
func (l *Lexer) extractNumber() Token { func (l *Lexer) extractNumber() Token {
@ -106,7 +106,7 @@ func (l *Lexer) extractNumber() Token {
l.index++ l.index++
} }
return Token{Number, sb.String()} return Token{Type: Number, Value: sb.String()}
} }
func (l *Lexer) extractString() Token { func (l *Lexer) extractString() Token {
@ -119,7 +119,7 @@ func (l *Lexer) extractString() Token {
} }
l.index++ l.index++
return Token{String, sb.String()} return Token{Type: String, Value: sb.String()}
} }
func (l *Lexer) extractName() Token { func (l *Lexer) extractName() Token {
@ -132,7 +132,7 @@ func (l *Lexer) extractName() Token {
l.index++ l.index++
} }
return Token{Name, sb.String()} return Token{Type: Name, Value: sb.String()}
} }
// Peek returns the next token, but does not advance the tokenizer. // Peek returns the next token, but does not advance the tokenizer.
@ -143,7 +143,7 @@ func (l *Lexer) Peek() Token {
} }
if l.index == len(l.data) { if l.index == len(l.data) {
l.nextToken = Token{EOF, ""} l.nextToken = Token{Type: EOF, Value: ""}
return l.nextToken return l.nextToken
} }
@ -152,7 +152,7 @@ func (l *Lexer) Peek() Token {
} }
if l.index == len(l.data) { if l.index == len(l.data) {
l.nextToken = Token{EOF, ""} l.nextToken = Token{Type: EOF, Value: ""}
return l.nextToken return l.nextToken
} }

View File

@ -8,12 +8,12 @@ func TestName(t *testing.T) {
lexer := New([]byte("correct horse battery staple andromeda13142 n1n2n4")) lexer := New([]byte("correct horse battery staple andromeda13142 n1n2n4"))
expected := []Token{ expected := []Token{
{Name, "correct"}, {"correct", Name},
{Name, "horse"}, {"horse", Name},
{Name, "battery"}, {"battery", Name},
{Name, "staple"}, {"staple", Name},
{Name, "andromeda13142"}, {"andromeda13142", Name},
{Name, "n1n2n4"}, {"n1n2n4", Name},
} }
for _, want := range expected { for _, want := range expected {
@ -33,11 +33,11 @@ func TestNumber(t *testing.T) {
lexer := New([]byte("12 2325 53252 312 3411")) lexer := New([]byte("12 2325 53252 312 3411"))
expected := []Token{ expected := []Token{
{Number, "12"}, {"12", Number},
{Number, "2325"}, {"2325", Number},
{Number, "53252"}, {"53252", Number},
{Number, "312"}, {"312", Number},
{Number, "3411"}, {"3411", Number},
} }
for _, want := range expected { for _, want := range expected {
@ -57,32 +57,32 @@ func TestSymbol(t *testing.T) {
lexer := New([]byte("((+-==>>>=!=<=<=<*//*)?(::.,.:?")) lexer := New([]byte("((+-==>>>=!=<=<=<*//*)?(::.,.:?"))
expected := []Token{ expected := []Token{
{Symbol, "("}, {"(", Symbol},
{Symbol, "("}, {"(", Symbol},
{Symbol, "+"}, {"+", Symbol},
{Symbol, "-"}, {"-", Symbol},
{Symbol, "=="}, {"==", Symbol},
{Symbol, ">"}, {">", Symbol},
{Symbol, ">"}, {">", Symbol},
{Symbol, ">="}, {">=", Symbol},
{Symbol, "!="}, {"!=", Symbol},
{Symbol, "<="}, {"<=", Symbol},
{Symbol, "<="}, {"<=", Symbol},
{Symbol, "<"}, {"<", Symbol},
{Symbol, "*"}, {"*", Symbol},
{Symbol, "/"}, {"/", Symbol},
{Symbol, "/"}, {"/", Symbol},
{Symbol, "*"}, {"*", Symbol},
{Symbol, ")"}, {")", Symbol},
{Symbol, "?"}, {"?", Symbol},
{Symbol, "("}, {"(", Symbol},
{Symbol, ":"}, {":", Symbol},
{Symbol, ":"}, {":", Symbol},
{Symbol, "."}, {".", Symbol},
{Symbol, ","}, {",", Symbol},
{Symbol, "."}, {".", Symbol},
{Symbol, ":"}, {":", Symbol},
{Symbol, "?"}, {"?", Symbol},
} }
for _, want := range expected { for _, want := range expected {
@ -102,11 +102,11 @@ func TestString(t *testing.T) {
lexer := New([]byte(`correct 'horse' 'battery staple' 'andromeda13142 ' n1n2n4`)) lexer := New([]byte(`correct 'horse' 'battery staple' 'andromeda13142 ' n1n2n4`))
expected := []Token{ expected := []Token{
{Name, "correct"}, {"correct", Name},
{String, "horse"}, {"horse", String},
{String, "battery staple"}, {"battery staple", String},
{String, "andromeda13142 "}, {"andromeda13142 ", String},
{Name, "n1n2n4"}, {"n1n2n4", Name},
} }
for _, want := range expected { for _, want := range expected {
@ -126,30 +126,30 @@ func TestActualConstructions(t *testing.T) {
lexer := New([]byte("skill('Sacrifice'.blvl) > 3 ? min(50, lvl) : skill('Sacrifice'.lvl) * ln12")) lexer := New([]byte("skill('Sacrifice'.blvl) > 3 ? min(50, lvl) : skill('Sacrifice'.lvl) * ln12"))
expected := []Token{ expected := []Token{
{Name, "skill"}, {"skill", Name},
{Symbol, "("}, {"(", Symbol},
{String, "Sacrifice"}, {"Sacrifice", String},
{Symbol, "."}, {".", Symbol},
{Name, "blvl"}, {"blvl", Name},
{Symbol, ")"}, {")", Symbol},
{Symbol, ">"}, {">", Symbol},
{Number, "3"}, {"3", Number},
{Symbol, "?"}, {"?", Symbol},
{Name, "min"}, {"min", Name},
{Symbol, "("}, {"(", Symbol},
{Number, "50"}, {"50", Number},
{Symbol, ","}, {",", Symbol},
{Name, "lvl"}, {"lvl", Name},
{Symbol, ")"}, {")", Symbol},
{Symbol, ":"}, {":", Symbol},
{Name, "skill"}, {"skill", Name},
{Symbol, "("}, {"(", Symbol},
{String, "Sacrifice"}, {"Sacrifice", String},
{Symbol, "."}, {".", Symbol},
{Name, "lvl"}, {"lvl", Name},
{Symbol, ")"}, {")", Symbol},
{Symbol, "*"}, {"*", Symbol},
{Name, "ln12"}, {"ln12", Name},
} }
for _, want := range expected { for _, want := range expected {

View File

@ -6,41 +6,41 @@ import (
) )
type binaryOperation struct { type binaryOperation struct {
Function func(v1, v2 int) int
Operator string Operator string
Precedence int Precedence int
IsRightAssociated bool IsRightAssociated bool
Function func(v1, v2 int) int
} }
type unaryOperation struct { type unaryOperation struct {
Function func(v int) int
Operator string Operator string
Precedence int Precedence int
Function func(v int) int
} }
type ternaryOperation struct { type ternaryOperation struct {
Function func(v1, v2, v3 int) int
Operator string Operator string
Marker string Marker string
Precedence int Precedence int
IsRightAssociated bool IsRightAssociated bool
Function func(v1, v2, v3 int) int
} }
func getUnaryOperations() map[string]unaryOperation { func getUnaryOperations() map[string]unaryOperation {
return map[string]unaryOperation{ return map[string]unaryOperation{
"+": { "+": {
"+",
4,
func(v int) int { func(v int) int {
return v return v
}, },
"+",
4,
}, },
"-": { "-": {
"-",
4,
func(v int) int { func(v int) int {
return -v return -v
}, },
"-",
4,
}, },
} }
} }
@ -48,16 +48,16 @@ func getUnaryOperations() map[string]unaryOperation {
func getTernaryOperations() map[string]ternaryOperation { func getTernaryOperations() map[string]ternaryOperation {
return map[string]ternaryOperation{ return map[string]ternaryOperation{
"?": { "?": {
"?",
":",
0,
true,
func(v1, v2, v3 int) int { func(v1, v2, v3 int) int {
if v1 != 0 { if v1 != 0 {
return v2 return v2
} }
return v3 return v3
}, },
"?",
":",
0,
true,
}, },
} }
} }
@ -65,110 +65,110 @@ func getTernaryOperations() map[string]ternaryOperation {
func getBinaryOperations() map[string]binaryOperation { //nolint:funlen // No reason to split function, just creates the operations. func getBinaryOperations() map[string]binaryOperation { //nolint:funlen // No reason to split function, just creates the operations.
return map[string]binaryOperation{ return map[string]binaryOperation{
"==": { "==": {
"==",
1,
false,
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 == v2 { if v1 == v2 {
return 1 return 1
} }
return 0 return 0
}, },
}, "==",
"!=": {
"!=",
1, 1,
false, false,
},
"!=": {
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 != v2 { if v1 != v2 {
return 1 return 1
} }
return 0 return 0
}, },
"!=",
1,
false,
}, },
"<": { "<": {
"<",
2,
false,
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 < v2 { if v1 < v2 {
return 1 return 1
} }
return 0 return 0
}, },
}, "<",
">": {
">",
2, 2,
false, false,
},
">": {
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 > v2 { if v1 > v2 {
return 1 return 1
} }
return 0 return 0
}, },
}, ">",
"<=": {
"<=",
2, 2,
false, false,
},
"<=": {
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 <= v2 { if v1 <= v2 {
return 1 return 1
} }
return 0 return 0
}, },
}, "<=",
">=": {
">=",
2, 2,
false, false,
},
">=": {
func(v1, v2 int) int { func(v1, v2 int) int {
if v1 >= v2 { if v1 >= v2 {
return 1 return 1
} }
return 0 return 0
}, },
">=",
2,
false,
}, },
"+": { "+": {
"+",
3,
false,
func(v1, v2 int) int { func(v1, v2 int) int {
return v1 + v2 return v1 + v2
}, },
}, "+",
"-": {
"-",
3, 3,
false, false,
},
"-": {
func(v1, v2 int) int { func(v1, v2 int) int {
return v1 - v2 return v1 - v2
}, },
"-",
3,
false,
}, },
"*": { "*": {
"*",
5,
false,
func(v1, v2 int) int { func(v1, v2 int) int {
return v1 * v2 return v1 * v2
}, },
}, "*",
"/": {
"/",
5, 5,
false, false,
},
"/": {
func(v1, v2 int) int { func(v1, v2 int) int {
return v1 / v2 return v1 / v2
}, },
"/",
5,
false,
}, },
"^": { "^": {
"^",
6,
true,
func(v1, v2 int) int { func(v1, v2 int) int {
return int(math.Pow(float64(v1), float64(v2))) return int(math.Pow(float64(v1), float64(v2)))
}, },
"^",
6,
true,
}, },
} }
} }

View File

@ -38,12 +38,12 @@ import (
// linkedNode is a node which is both hierachcical (parent/child) and doubly linked (next/prev) // linkedNode is a node which is both hierachcical (parent/child) and doubly linked (next/prev)
type linkedNode struct { type linkedNode struct {
decompressedValue int
weight int
parent *linkedNode parent *linkedNode
child0 *linkedNode child0 *linkedNode
prev *linkedNode prev *linkedNode
next *linkedNode next *linkedNode
decompressedValue int
weight int
} }
// createLinkedNode creates a linked node // createLinkedNode creates a linked node

View File

@ -58,14 +58,14 @@ type BinkAudioTrack struct {
// BinkDecoder represents the bink decoder // BinkDecoder represents the bink decoder
type BinkDecoder struct { type BinkDecoder struct {
streamReader *d2datautils.StreamReader
AudioTracks []BinkAudioTrack AudioTracks []BinkAudioTrack
FrameIndexTable []uint32 FrameIndexTable []uint32
streamReader *d2datautils.StreamReader VideoHeight uint32
fileSize uint32
numberOfFrames uint32 numberOfFrames uint32
largestFrameSizeBytes uint32 largestFrameSizeBytes uint32
VideoWidth uint32 VideoWidth uint32
VideoHeight uint32 fileSize uint32
FPS uint32 FPS uint32
FrameTimeMS uint32 FrameTimeMS uint32
VideoMode BinkVideoMode VideoMode BinkVideoMode
@ -73,9 +73,6 @@ type BinkDecoder struct {
videoCodecRevision byte videoCodecRevision byte
HasAlphaPlane bool HasAlphaPlane bool
Grayscale bool Grayscale bool
// Mask bit 0, as this is defined as a keyframe
} }
// CreateBinkDecoder returns a new instance of the bink decoder // CreateBinkDecoder returns a new instance of the bink decoder

View File

@ -21,9 +21,9 @@ const (
// AnimationData is a representation of the binary data from `data/global/AnimData.d2` // AnimationData is a representation of the binary data from `data/global/AnimData.d2`
type AnimationData struct { type AnimationData struct {
hashTable
blocks [numBlocks]*block blocks [numBlocks]*block
entries map[string][]*AnimationDataRecord entries map[string][]*AnimationDataRecord
hashTable
} }
// GetRecordNames returns a slice of all record name strings // GetRecordNames returns a slice of all record name strings
@ -179,10 +179,10 @@ func Load(data []byte) (*AnimationData, error) {
} }
r := &AnimationDataRecord{ r := &AnimationDataRecord{
name, name: name,
frames, framesPerDirection: frames,
speed, speed: speed,
events, events: events,
} }
records[recordIdx] = r records[recordIdx] = r
@ -195,8 +195,8 @@ func Load(data []byte) (*AnimationData, error) {
} }
b := &block{ b := &block{
recordCount, recordCount: recordCount,
records, records: records,
} }
animdata.blocks[blockIdx] = b animdata.blocks[blockIdx] = b
@ -232,7 +232,7 @@ func (ad *AnimationData) Marshal() []byte {
recordIdx := 0 recordIdx := 0
// numberOfEntries is a number of entries in all map indexes // numberOfEntries is a number of entries in all map indexes
var numberOfEntries = 0 numberOfEntries := 0
for i := 0; i < len(keys); i++ { for i := 0; i < len(keys); i++ {
numberOfEntries += len(ad.entries[keys[i]]) numberOfEntries += len(ad.entries[keys[i]])

View File

@ -1,6 +1,6 @@
package d2animdata package d2animdata
type block struct { type block struct {
recordCount uint32
records []*AnimationDataRecord records []*AnimationDataRecord
recordCount uint32
} }

View File

@ -2,10 +2,10 @@ package d2animdata
// AnimationDataRecord represents a single record from the AnimData.d2 file // AnimationDataRecord represents a single record from the AnimData.d2 file
type AnimationDataRecord struct { type AnimationDataRecord struct {
events map[int]AnimationEvent
name string name string
framesPerDirection uint32 framesPerDirection uint32
speed uint16 speed uint16
events map[int]AnimationEvent
} }
// FramesPerDirection returns frames per direction value // FramesPerDirection returns frames per direction value

View File

@ -65,18 +65,16 @@ func Unmarshal(data []byte) (*COF, error) {
// COF is a structure that represents a COF file. // COF is a structure that represents a COF file.
type COF struct { type COF struct {
// unknown bytes for header
unknownHeaderBytes []byte
// unknown bytes (first "body's" bytes)
unknownBodyBytes []byte
NumberOfDirections int
FramesPerDirection int
NumberOfLayers int
Speed int
CofLayers []CofLayer
CompositeLayers map[d2enum.CompositeType]int CompositeLayers map[d2enum.CompositeType]int
unknownHeaderBytes []byte
AnimationFrames []d2enum.AnimationFrame AnimationFrames []d2enum.AnimationFrame
Priority [][][]d2enum.CompositeType Priority [][][]d2enum.CompositeType
CofLayers []CofLayer
unknownBodyBytes []byte
NumberOfLayers int
Speed int
NumberOfDirections int
FramesPerDirection int
} }
// Unmarshal a byte slice to this COF // Unmarshal a byte slice to this COF

View File

@ -22,14 +22,14 @@ const (
// DC6 represents a DC6 file. // DC6 represents a DC6 file.
type DC6 struct { type DC6 struct {
Version int32 FramePointers []uint32
Flags uint32 Frames []*DC6Frame
Termination []byte
Encoding uint32 Encoding uint32
Termination []byte // 4 bytes
Directions uint32 Directions uint32
FramesPerDirection uint32 FramesPerDirection uint32
FramePointers []uint32 // size is Directions*FramesPerDirection Version int32
Frames []*DC6Frame // size is Directions*FramesPerDirection Flags uint32
} }
// New creates a new, empty DC6 // New creates a new, empty DC6

View File

@ -2,14 +2,14 @@ package d2dc6
// DC6Frame represents a single frame in a DC6. // DC6Frame represents a single frame in a DC6.
type DC6Frame struct { type DC6Frame struct {
FrameData []byte
Terminator []byte
Flipped uint32 Flipped uint32
Width uint32 Width uint32
Height uint32
OffsetX int32
OffsetY int32 OffsetY int32
Unknown uint32 Unknown uint32
NextBlock uint32 NextBlock uint32
Length uint32 Length uint32
FrameData []byte // size is the value of Length Height uint32
Terminator []byte // 3 bytes OffsetX int32
} }

View File

@ -2,10 +2,10 @@ package d2dc6
// DC6Header represents the file header of a DC6 file. // DC6Header represents the file header of a DC6 file.
type DC6Header struct { type DC6Header struct {
Termination []byte `struct:"[4]byte"`
Version int32 `struct:"int32"` Version int32 `struct:"int32"`
Flags uint32 `struct:"uint32"` Flags uint32 `struct:"uint32"`
Encoding uint32 `struct:"uint32"` Encoding uint32 `struct:"uint32"`
Termination []byte `struct:"[4]byte"`
Directions int32 `struct:"int32"` Directions int32 `struct:"int32"`
FramesPerDirection int32 `struct:"int32"` FramesPerDirection int32 `struct:"int32"`
} }

View File

@ -11,13 +11,13 @@ const directionOffsetMultiplier = 8
// DCC represents a DCC file. // DCC represents a DCC file.
type DCC struct { type DCC struct {
Signature int fileData []byte
Directions []*DCCDirection
directionOffsets []int
Version int Version int
NumberOfDirections int NumberOfDirections int
FramesPerDirection int FramesPerDirection int
Directions []*DCCDirection Signature int
directionOffsets []int
fileData []byte
} }
// Load loads a DCC file. // Load loads a DCC file.

View File

@ -20,27 +20,27 @@ const cellsPerRow = 4
// DCCDirection represents a DCCDirection file. // DCCDirection represents a DCCDirection file.
type DCCDirection struct { type DCCDirection struct {
OutSizeCoded int PixelBuffer []DCCPixelBufferEntry
CompressionFlags int PixelData []byte
Variable0Bits int Cells []*DCCCell
WidthBits int Frames []*DCCDirectionFrame
HeightBits int Box d2geom.Rectangle
XOffsetBits int PixelMaskBitstreamSize int
YOffsetBits int YOffsetBits int
OptionalDataBits int OptionalDataBits int
CodedBytesBits int CodedBytesBits int
EqualCellsBitstreamSize int EqualCellsBitstreamSize int
PixelMaskBitstreamSize int XOffsetBits int
EncodingTypeBitsreamSize int EncodingTypeBitsreamSize int
RawPixelCodesBitstreamSize int RawPixelCodesBitstreamSize int
Frames []*DCCDirectionFrame HeightBits int
PaletteEntries [256]byte
Box d2geom.Rectangle
Cells []*DCCCell
PixelData []byte
HorizontalCellCount int
VerticalCellCount int VerticalCellCount int
PixelBuffer []DCCPixelBufferEntry WidthBits int
Variable0Bits int
CompressionFlags int
HorizontalCellCount int
OutSizeCoded int
PaletteEntries [256]byte
} }
// CreateDCCDirection creates an instance of a DCCDirection. // CreateDCCDirection creates an instance of a DCCDirection.

View File

@ -9,13 +9,13 @@ import (
// DCCDirectionFrame represents a direction frame for a DCC. // DCCDirectionFrame represents a direction frame for a DCC.
type DCCDirectionFrame struct { type DCCDirectionFrame struct {
Box d2geom.Rectangle
Cells []DCCCell Cells []DCCCell
PixelData []byte PixelData []byte
Width int Box d2geom.Rectangle
YOffset int
Height int Height int
XOffset int XOffset int
YOffset int Width int
NumberOfOptionalBytes int NumberOfOptionalBytes int
NumberOfCodedBytes int NumberOfCodedBytes int
HorizontalCellCount int HorizontalCellCount int

View File

@ -37,11 +37,12 @@ func (l LayerGroupType) String() string {
type layerGroup []*Layer type layerGroup []*Layer
type ds1Layers struct { type ds1Layers struct {
width, height int
Floors layerGroup Floors layerGroup
Walls layerGroup Walls layerGroup
Shadows layerGroup Shadows layerGroup
Substitutions layerGroup Substitutions layerGroup
width int
height int
} }
func (l *ds1Layers) ensureInit() { func (l *ds1Layers) ensureInit() {

View File

@ -169,10 +169,10 @@ func exampleData() *DS1 { //nolint:funlen // not a big deal if this is long func
}, },
Files: []string{"a.dt1", "bfile.dt1"}, Files: []string{"a.dt1", "bfile.dt1"},
Objects: []Object{ Objects: []Object{
{0, 0, 0, 0, 0, nil}, {nil, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, []d2path.Path{{}}}, {[]d2path.Path{{}}, 0, 1, 0, 0, 0},
{0, 2, 0, 0, 0, nil}, {nil, 0, 2, 0, 0, 0},
{0, 3, 0, 0, 0, nil}, {nil, 0, 3, 0, 0, 0},
}, },
SubstitutionGroups: nil, SubstitutionGroups: nil,
version: 17, version: 17,

View File

@ -6,12 +6,12 @@ import (
// Object is a game world object // Object is a game world object
type Object struct { type Object struct {
Paths []d2path.Path
Type int Type int
ID int ID int
X int X int
Y int Y int
Flags int Flags int
Paths []d2path.Path
} }
// Equals checks if this Object is equivalent to the given Object // Equals checks if this Object is equivalent to the given Object

View File

@ -2,14 +2,14 @@ package d2dt1
// Block represents a DT1 block // Block represents a DT1 block
type Block struct { type Block struct {
EncodedData []byte
Length int32
FileOffset int32
format int16
X int16 X int16
Y int16 Y int16
GridX byte GridX byte
GridY byte GridY byte
format int16
EncodedData []byte
Length int32
FileOffset int32
} }
// Format returns block format // Format returns block format

View File

@ -31,11 +31,11 @@ const (
// DT1 represents a DT1 file. // DT1 represents a DT1 file.
type DT1 struct { type DT1 struct {
Tiles []Tile
majorVersion int32 majorVersion int32
minorVersion int32 minorVersion int32
numberOfTiles int32 numberOfTiles int32
bodyPosition int32 bodyPosition int32
Tiles []Tile
} }
// New creates a new DT1 // New creates a new DT1

View File

@ -3,19 +3,19 @@ package d2dt1
// Tile is a representation of a map tile // Tile is a representation of a map tile
type Tile struct { type Tile struct {
unknown2 []byte unknown2 []byte
Direction int32 Blocks []Block
RoofHeight int16 Sequence int32
MaterialFlags MaterialFlags RarityFrameIndex int32
Height int32 Height int32
Width int32 Width int32
Type int32 Type int32
Style int32 Direction int32
Sequence int32
RarityFrameIndex int32
SubTileFlags [25]SubTileFlags
blockHeaderPointer int32 blockHeaderPointer int32
blockHeaderSize int32 blockHeaderSize int32
Blocks []Block Style int32
RoofHeight int16
SubTileFlags [25]SubTileFlags
MaterialFlags MaterialFlags
} }
func (t *Tile) unknown1() []byte { func (t *Tile) unknown1() []byte {

View File

@ -28,9 +28,9 @@ const (
// Font represents a displayable font // Font represents a displayable font
type Font struct { type Font struct {
sheet d2interface.Animation sheet d2interface.Animation
table []byte
Glyphs map[rune]*d2fontglyph.FontGlyph
color color.Color color color.Color
Glyphs map[rune]*d2fontglyph.FontGlyph
table []byte
} }
// Load loads a new font from byte slice // Load loads a new font from byte slice

View File

@ -32,13 +32,12 @@ const (
) )
// Block represents an entry in the block table // Block represents an entry in the block table
type Block struct { // 16 bytes type Block struct {
FileName string
FilePosition uint32 FilePosition uint32
CompressedFileSize uint32 CompressedFileSize uint32
UncompressedFileSize uint32 UncompressedFileSize uint32
Flags FileFlag Flags FileFlag
// Local Stuff...
FileName string
EncryptionSeed uint32 EncryptionSeed uint32
} }

View File

@ -3,6 +3,6 @@ package d2mpq
// MpqFileRecord represents a file record in an MPQ // MpqFileRecord represents a file record in an MPQ
type MpqFileRecord struct { type MpqFileRecord struct {
MpqFile string MpqFile string
IsPatch bool
UnpatchedMpqFile string UnpatchedMpqFile string
IsPatch bool
} }

View File

@ -16,10 +16,10 @@ import (
// Stream represents a stream of data in an MPQ archive // Stream represents a stream of data in an MPQ archive
type Stream struct { type Stream struct {
Data []byte
Positions []uint32
MPQ *MPQ MPQ *MPQ
Block *Block Block *Block
Data []byte
Positions []uint32
Index uint32 Index uint32
Size uint32 Size uint32
Position uint32 Position uint32

View File

@ -11,10 +11,10 @@ import (
// DataDictionary represents a data file (Excel) // DataDictionary represents a data file (Excel)
type DataDictionary struct { type DataDictionary struct {
Err error
lookup map[string]int lookup map[string]int
r *csv.Reader r *csv.Reader
record []string record []string
Err error
} }
// LoadDataDictionary loads the contents of a spreadsheet style txt file // LoadDataDictionary loads the contents of a spreadsheet style txt file

View File

@ -6,48 +6,48 @@ import (
// MusicDef stores the music definitions of a region // MusicDef stores the music definitions of a region
type MusicDef struct { type MusicDef struct {
MusicFile string
Region d2enum.RegionIdType Region d2enum.RegionIdType
InTown bool InTown bool
MusicFile string
} }
func getMusicDefs() []MusicDef { func getMusicDefs() []MusicDef {
return []MusicDef{ return []MusicDef{
{d2enum.RegionAct1Town, false, BGMAct1Town1}, {BGMAct1Town1, d2enum.RegionAct1Town, false},
{d2enum.RegionAct1Wilderness, false, BGMAct1Wild}, {BGMAct1Wild, d2enum.RegionAct1Wilderness, false},
{d2enum.RegionAct1Cave, false, BGMAct1Caves}, {BGMAct1Caves, d2enum.RegionAct1Cave, false},
{d2enum.RegionAct1Crypt, false, BGMAct1Crypt}, {BGMAct1Crypt, d2enum.RegionAct1Crypt, false},
{d2enum.RegionAct1Monestary, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Monestary, false},
{d2enum.RegionAct1Courtyard, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Courtyard, false},
{d2enum.RegionAct1Barracks, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Barracks, false},
{d2enum.RegionAct1Jail, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Jail, false},
{d2enum.RegionAct1Cathedral, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Cathedral, false},
{d2enum.RegionAct1Catacombs, false, BGMAct1Monastery}, {BGMAct1Monastery, d2enum.RegionAct1Catacombs, false},
{d2enum.RegionAct1Tristram, false, BGMAct1Tristram}, {BGMAct1Tristram, d2enum.RegionAct1Tristram, false},
{d2enum.RegionAct2Town, false, BGMAct2Town2}, {BGMAct2Town2, d2enum.RegionAct2Town, false},
{d2enum.RegionAct2Sewer, false, BGMAct2Sewer}, {BGMAct2Sewer, d2enum.RegionAct2Sewer, false},
{d2enum.RegionAct2Harem, false, BGMAct2Harem}, {BGMAct2Harem, d2enum.RegionAct2Harem, false},
{d2enum.RegionAct2Basement, false, BGMAct2Harem}, {BGMAct2Harem, d2enum.RegionAct2Basement, false},
{d2enum.RegionAct2Desert, false, BGMAct2Desert}, {BGMAct2Desert, d2enum.RegionAct2Desert, false},
{d2enum.RegionAct2Tomb, false, BGMAct2Tombs}, {BGMAct2Tombs, d2enum.RegionAct2Tomb, false},
{d2enum.RegionAct2Lair, false, BGMAct2Lair}, {BGMAct2Lair, d2enum.RegionAct2Lair, false},
{d2enum.RegionAct2Arcane, false, BGMAct2Sanctuary}, {BGMAct2Sanctuary, d2enum.RegionAct2Arcane, false},
{d2enum.RegionAct3Town, false, BGMAct3Town3}, {BGMAct3Town3, d2enum.RegionAct3Town, false},
{d2enum.RegionAct3Jungle, false, BGMAct3Jungle}, {BGMAct3Jungle, d2enum.RegionAct3Jungle, false},
{d2enum.RegionAct3Kurast, false, BGMAct3Kurast}, {BGMAct3Kurast, d2enum.RegionAct3Kurast, false},
{d2enum.RegionAct3Spider, false, BGMAct3Spider}, {BGMAct3Spider, d2enum.RegionAct3Spider, false},
{d2enum.RegionAct3Dungeon, false, BGMAct3KurastSewer}, {BGMAct3KurastSewer, d2enum.RegionAct3Dungeon, false},
{d2enum.RegionAct3Sewer, false, BGMAct3KurastSewer}, {BGMAct3KurastSewer, d2enum.RegionAct3Sewer, false},
{d2enum.RegionAct4Town, false, BGMAct4Town4}, {BGMAct4Town4, d2enum.RegionAct4Town, false},
{d2enum.RegionAct4Mesa, false, BGMAct4Mesa}, {BGMAct4Mesa, d2enum.RegionAct4Mesa, false},
{d2enum.RegionAct4Lava, false, BGMAct4Mesa}, {BGMAct4Mesa, d2enum.RegionAct4Lava, false},
{d2enum.RegonAct5Town, false, BGMAct5XTown}, {BGMAct5XTown, d2enum.RegonAct5Town, false},
{d2enum.RegionAct5Siege, false, BGMAct5Siege}, {BGMAct5Siege, d2enum.RegionAct5Siege, false},
{d2enum.RegionAct5Barricade, false, BGMAct5Siege}, // ? {BGMAct5Siege, d2enum.RegionAct5Barricade, false}, // ?
{d2enum.RegionAct5Temple, false, BGMAct5XTemple}, {BGMAct5XTemple, d2enum.RegionAct5Temple, false},
{d2enum.RegionAct5IceCaves, false, BGMAct5IceCaves}, {BGMAct5IceCaves, d2enum.RegionAct5IceCaves, false},
{d2enum.RegionAct5Baal, false, BGMAct5Baal}, {BGMAct5Baal, d2enum.RegionAct5Baal, false},
{d2enum.RegionAct5Lava, false, BGMAct5Nihlathak}, // ? {BGMAct5Nihlathak, d2enum.RegionAct5Lava, false}, // ?
} }
} }

View File

@ -60,8 +60,8 @@ func NewLogger() *Logger {
// Logger is used to write log messages, and can have a log level to determine verbosity // Logger is used to write log messages, and can have a log level to determine verbosity
type Logger struct { type Logger struct {
prefix string
io.Writer io.Writer
prefix string
level LogLevel level LogLevel
colorEnabled bool colorEnabled bool
} }