mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-03 07:07:25 -05:00
d2common: fix fieldalignment lints
This commit is contained in:
parent
c1d048a616
commit
dfc575ce75
@ -11,10 +11,10 @@ import (
|
||||
var _ d2interface.Cache = &Cache{} // Static check to confirm struct conforms to interface
|
||||
|
||||
type cacheNode struct {
|
||||
value interface{}
|
||||
next *cacheNode
|
||||
prev *cacheNode
|
||||
key string
|
||||
value interface{}
|
||||
weight int
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ func (t tokenType) String() string {
|
||||
|
||||
// Token is a lexical token of a calculation string.
|
||||
type Token struct {
|
||||
Type tokenType
|
||||
Value string
|
||||
Type tokenType
|
||||
}
|
||||
|
||||
func (t *Token) String() string {
|
||||
@ -49,11 +49,11 @@ func (t *Token) String() string {
|
||||
|
||||
// Lexer is the tokenizer for calculation strings.
|
||||
type Lexer struct {
|
||||
data []byte
|
||||
CurrentToken Token
|
||||
nextToken Token
|
||||
data []byte
|
||||
index int
|
||||
peeked bool
|
||||
nextToken Token
|
||||
}
|
||||
|
||||
// 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))
|
||||
} else {
|
||||
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()
|
||||
if ok == nil && next == '=' {
|
||||
l.index += 2
|
||||
return Token{Symbol, string(c) + "="}
|
||||
return Token{Type: Symbol, Value: string(c) + "="}
|
||||
}
|
||||
l.index++
|
||||
|
||||
return Token{Symbol, string(c)}
|
||||
return Token{Type: Symbol, Value: string(c)}
|
||||
}
|
||||
l.index++
|
||||
|
||||
return Token{Symbol, string(c)}
|
||||
return Token{Type: Symbol, Value: string(c)}
|
||||
}
|
||||
|
||||
func (l *Lexer) extractNumber() Token {
|
||||
@ -106,7 +106,7 @@ func (l *Lexer) extractNumber() Token {
|
||||
l.index++
|
||||
}
|
||||
|
||||
return Token{Number, sb.String()}
|
||||
return Token{Type: Number, Value: sb.String()}
|
||||
}
|
||||
|
||||
func (l *Lexer) extractString() Token {
|
||||
@ -119,7 +119,7 @@ func (l *Lexer) extractString() Token {
|
||||
}
|
||||
l.index++
|
||||
|
||||
return Token{String, sb.String()}
|
||||
return Token{Type: String, Value: sb.String()}
|
||||
}
|
||||
|
||||
func (l *Lexer) extractName() Token {
|
||||
@ -132,7 +132,7 @@ func (l *Lexer) extractName() Token {
|
||||
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.
|
||||
@ -143,7 +143,7 @@ func (l *Lexer) Peek() Token {
|
||||
}
|
||||
|
||||
if l.index == len(l.data) {
|
||||
l.nextToken = Token{EOF, ""}
|
||||
l.nextToken = Token{Type: EOF, Value: ""}
|
||||
return l.nextToken
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ func (l *Lexer) Peek() Token {
|
||||
}
|
||||
|
||||
if l.index == len(l.data) {
|
||||
l.nextToken = Token{EOF, ""}
|
||||
l.nextToken = Token{Type: EOF, Value: ""}
|
||||
return l.nextToken
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,12 @@ func TestName(t *testing.T) {
|
||||
lexer := New([]byte("correct horse battery staple andromeda13142 n1n2n4"))
|
||||
|
||||
expected := []Token{
|
||||
{Name, "correct"},
|
||||
{Name, "horse"},
|
||||
{Name, "battery"},
|
||||
{Name, "staple"},
|
||||
{Name, "andromeda13142"},
|
||||
{Name, "n1n2n4"},
|
||||
{"correct", Name},
|
||||
{"horse", Name},
|
||||
{"battery", Name},
|
||||
{"staple", Name},
|
||||
{"andromeda13142", Name},
|
||||
{"n1n2n4", Name},
|
||||
}
|
||||
|
||||
for _, want := range expected {
|
||||
@ -33,11 +33,11 @@ func TestNumber(t *testing.T) {
|
||||
lexer := New([]byte("12 2325 53252 312 3411"))
|
||||
|
||||
expected := []Token{
|
||||
{Number, "12"},
|
||||
{Number, "2325"},
|
||||
{Number, "53252"},
|
||||
{Number, "312"},
|
||||
{Number, "3411"},
|
||||
{"12", Number},
|
||||
{"2325", Number},
|
||||
{"53252", Number},
|
||||
{"312", Number},
|
||||
{"3411", Number},
|
||||
}
|
||||
|
||||
for _, want := range expected {
|
||||
@ -57,32 +57,32 @@ func TestSymbol(t *testing.T) {
|
||||
lexer := New([]byte("((+-==>>>=!=<=<=<*//*)?(::.,.:?"))
|
||||
|
||||
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 {
|
||||
@ -102,11 +102,11 @@ func TestString(t *testing.T) {
|
||||
lexer := New([]byte(`correct 'horse' 'battery staple' 'andromeda13142 ' n1n2n4`))
|
||||
|
||||
expected := []Token{
|
||||
{Name, "correct"},
|
||||
{String, "horse"},
|
||||
{String, "battery staple"},
|
||||
{String, "andromeda13142 "},
|
||||
{Name, "n1n2n4"},
|
||||
{"correct", Name},
|
||||
{"horse", String},
|
||||
{"battery staple", String},
|
||||
{"andromeda13142 ", String},
|
||||
{"n1n2n4", Name},
|
||||
}
|
||||
|
||||
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"))
|
||||
|
||||
expected := []Token{
|
||||
{Name, "skill"},
|
||||
{Symbol, "("},
|
||||
{String, "Sacrifice"},
|
||||
{Symbol, "."},
|
||||
{Name, "blvl"},
|
||||
{Symbol, ")"},
|
||||
{Symbol, ">"},
|
||||
{Number, "3"},
|
||||
{Symbol, "?"},
|
||||
{Name, "min"},
|
||||
{Symbol, "("},
|
||||
{Number, "50"},
|
||||
{Symbol, ","},
|
||||
{Name, "lvl"},
|
||||
{Symbol, ")"},
|
||||
{Symbol, ":"},
|
||||
{Name, "skill"},
|
||||
{Symbol, "("},
|
||||
{String, "Sacrifice"},
|
||||
{Symbol, "."},
|
||||
{Name, "lvl"},
|
||||
{Symbol, ")"},
|
||||
{Symbol, "*"},
|
||||
{Name, "ln12"},
|
||||
{"skill", Name},
|
||||
{"(", Symbol},
|
||||
{"Sacrifice", String},
|
||||
{".", Symbol},
|
||||
{"blvl", Name},
|
||||
{")", Symbol},
|
||||
{">", Symbol},
|
||||
{"3", Number},
|
||||
{"?", Symbol},
|
||||
{"min", Name},
|
||||
{"(", Symbol},
|
||||
{"50", Number},
|
||||
{",", Symbol},
|
||||
{"lvl", Name},
|
||||
{")", Symbol},
|
||||
{":", Symbol},
|
||||
{"skill", Name},
|
||||
{"(", Symbol},
|
||||
{"Sacrifice", String},
|
||||
{".", Symbol},
|
||||
{"lvl", Name},
|
||||
{")", Symbol},
|
||||
{"*", Symbol},
|
||||
{"ln12", Name},
|
||||
}
|
||||
|
||||
for _, want := range expected {
|
||||
|
@ -6,41 +6,41 @@ import (
|
||||
)
|
||||
|
||||
type binaryOperation struct {
|
||||
Function func(v1, v2 int) int
|
||||
Operator string
|
||||
Precedence int
|
||||
IsRightAssociated bool
|
||||
Function func(v1, v2 int) int
|
||||
}
|
||||
|
||||
type unaryOperation struct {
|
||||
Function func(v int) int
|
||||
Operator string
|
||||
Precedence int
|
||||
Function func(v int) int
|
||||
}
|
||||
|
||||
type ternaryOperation struct {
|
||||
Function func(v1, v2, v3 int) int
|
||||
Operator string
|
||||
Marker string
|
||||
Precedence int
|
||||
IsRightAssociated bool
|
||||
Function func(v1, v2, v3 int) int
|
||||
}
|
||||
|
||||
func getUnaryOperations() map[string]unaryOperation {
|
||||
return map[string]unaryOperation{
|
||||
"+": {
|
||||
"+",
|
||||
4,
|
||||
func(v int) int {
|
||||
return v
|
||||
},
|
||||
"+",
|
||||
4,
|
||||
},
|
||||
"-": {
|
||||
"-",
|
||||
4,
|
||||
func(v int) int {
|
||||
return -v
|
||||
},
|
||||
"-",
|
||||
4,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -48,16 +48,16 @@ func getUnaryOperations() map[string]unaryOperation {
|
||||
func getTernaryOperations() map[string]ternaryOperation {
|
||||
return map[string]ternaryOperation{
|
||||
"?": {
|
||||
"?",
|
||||
":",
|
||||
0,
|
||||
true,
|
||||
func(v1, v2, v3 int) int {
|
||||
if v1 != 0 {
|
||||
return v2
|
||||
}
|
||||
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.
|
||||
return map[string]binaryOperation{
|
||||
"==": {
|
||||
"==",
|
||||
1,
|
||||
false,
|
||||
func(v1, v2 int) int {
|
||||
if v1 == v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
},
|
||||
"!=": {
|
||||
"!=",
|
||||
"==",
|
||||
1,
|
||||
false,
|
||||
},
|
||||
"!=": {
|
||||
func(v1, v2 int) int {
|
||||
if v1 != v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
"!=",
|
||||
1,
|
||||
false,
|
||||
},
|
||||
"<": {
|
||||
"<",
|
||||
2,
|
||||
false,
|
||||
func(v1, v2 int) int {
|
||||
if v1 < v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
},
|
||||
">": {
|
||||
">",
|
||||
"<",
|
||||
2,
|
||||
false,
|
||||
},
|
||||
">": {
|
||||
func(v1, v2 int) int {
|
||||
if v1 > v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
},
|
||||
"<=": {
|
||||
"<=",
|
||||
">",
|
||||
2,
|
||||
false,
|
||||
},
|
||||
"<=": {
|
||||
func(v1, v2 int) int {
|
||||
if v1 <= v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
},
|
||||
">=": {
|
||||
">=",
|
||||
"<=",
|
||||
2,
|
||||
false,
|
||||
},
|
||||
">=": {
|
||||
func(v1, v2 int) int {
|
||||
if v1 >= v2 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
},
|
||||
">=",
|
||||
2,
|
||||
false,
|
||||
},
|
||||
"+": {
|
||||
"+",
|
||||
3,
|
||||
false,
|
||||
func(v1, v2 int) int {
|
||||
return v1 + v2
|
||||
},
|
||||
},
|
||||
"-": {
|
||||
"-",
|
||||
"+",
|
||||
3,
|
||||
false,
|
||||
},
|
||||
"-": {
|
||||
func(v1, v2 int) int {
|
||||
return v1 - v2
|
||||
},
|
||||
"-",
|
||||
3,
|
||||
false,
|
||||
},
|
||||
"*": {
|
||||
"*",
|
||||
5,
|
||||
false,
|
||||
func(v1, v2 int) int {
|
||||
return v1 * v2
|
||||
},
|
||||
},
|
||||
"/": {
|
||||
"/",
|
||||
"*",
|
||||
5,
|
||||
false,
|
||||
},
|
||||
"/": {
|
||||
func(v1, v2 int) int {
|
||||
return v1 / v2
|
||||
},
|
||||
"/",
|
||||
5,
|
||||
false,
|
||||
},
|
||||
"^": {
|
||||
"^",
|
||||
6,
|
||||
true,
|
||||
func(v1, v2 int) int {
|
||||
return int(math.Pow(float64(v1), float64(v2)))
|
||||
},
|
||||
"^",
|
||||
6,
|
||||
true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ import (
|
||||
|
||||
// linkedNode is a node which is both hierachcical (parent/child) and doubly linked (next/prev)
|
||||
type linkedNode struct {
|
||||
decompressedValue int
|
||||
weight int
|
||||
parent *linkedNode
|
||||
child0 *linkedNode
|
||||
prev *linkedNode
|
||||
next *linkedNode
|
||||
decompressedValue int
|
||||
weight int
|
||||
}
|
||||
|
||||
// createLinkedNode creates a linked node
|
||||
|
@ -58,14 +58,14 @@ type BinkAudioTrack struct {
|
||||
|
||||
// BinkDecoder represents the bink decoder
|
||||
type BinkDecoder struct {
|
||||
streamReader *d2datautils.StreamReader
|
||||
AudioTracks []BinkAudioTrack
|
||||
FrameIndexTable []uint32
|
||||
streamReader *d2datautils.StreamReader
|
||||
fileSize uint32
|
||||
VideoHeight uint32
|
||||
numberOfFrames uint32
|
||||
largestFrameSizeBytes uint32
|
||||
VideoWidth uint32
|
||||
VideoHeight uint32
|
||||
fileSize uint32
|
||||
FPS uint32
|
||||
FrameTimeMS uint32
|
||||
VideoMode BinkVideoMode
|
||||
@ -73,9 +73,6 @@ type BinkDecoder struct {
|
||||
videoCodecRevision byte
|
||||
HasAlphaPlane bool
|
||||
Grayscale bool
|
||||
|
||||
// Mask bit 0, as this is defined as a keyframe
|
||||
|
||||
}
|
||||
|
||||
// CreateBinkDecoder returns a new instance of the bink decoder
|
||||
|
@ -21,9 +21,9 @@ const (
|
||||
|
||||
// AnimationData is a representation of the binary data from `data/global/AnimData.d2`
|
||||
type AnimationData struct {
|
||||
hashTable
|
||||
blocks [numBlocks]*block
|
||||
entries map[string][]*AnimationDataRecord
|
||||
hashTable
|
||||
}
|
||||
|
||||
// GetRecordNames returns a slice of all record name strings
|
||||
@ -179,10 +179,10 @@ func Load(data []byte) (*AnimationData, error) {
|
||||
}
|
||||
|
||||
r := &AnimationDataRecord{
|
||||
name,
|
||||
frames,
|
||||
speed,
|
||||
events,
|
||||
name: name,
|
||||
framesPerDirection: frames,
|
||||
speed: speed,
|
||||
events: events,
|
||||
}
|
||||
|
||||
records[recordIdx] = r
|
||||
@ -195,8 +195,8 @@ func Load(data []byte) (*AnimationData, error) {
|
||||
}
|
||||
|
||||
b := &block{
|
||||
recordCount,
|
||||
records,
|
||||
recordCount: recordCount,
|
||||
records: records,
|
||||
}
|
||||
|
||||
animdata.blocks[blockIdx] = b
|
||||
@ -232,7 +232,7 @@ func (ad *AnimationData) Marshal() []byte {
|
||||
recordIdx := 0
|
||||
|
||||
// numberOfEntries is a number of entries in all map indexes
|
||||
var numberOfEntries = 0
|
||||
numberOfEntries := 0
|
||||
|
||||
for i := 0; i < len(keys); i++ {
|
||||
numberOfEntries += len(ad.entries[keys[i]])
|
||||
|
@ -1,6 +1,6 @@
|
||||
package d2animdata
|
||||
|
||||
type block struct {
|
||||
recordCount uint32
|
||||
records []*AnimationDataRecord
|
||||
recordCount uint32
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package d2animdata
|
||||
|
||||
// AnimationDataRecord represents a single record from the AnimData.d2 file
|
||||
type AnimationDataRecord struct {
|
||||
events map[int]AnimationEvent
|
||||
name string
|
||||
framesPerDirection uint32
|
||||
speed uint16
|
||||
events map[int]AnimationEvent
|
||||
}
|
||||
|
||||
// FramesPerDirection returns frames per direction value
|
||||
|
@ -65,18 +65,16 @@ func Unmarshal(data []byte) (*COF, error) {
|
||||
|
||||
// COF is a structure that represents a COF file.
|
||||
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
|
||||
unknownHeaderBytes []byte
|
||||
AnimationFrames []d2enum.AnimationFrame
|
||||
Priority [][][]d2enum.CompositeType
|
||||
CofLayers []CofLayer
|
||||
unknownBodyBytes []byte
|
||||
NumberOfLayers int
|
||||
Speed int
|
||||
NumberOfDirections int
|
||||
FramesPerDirection int
|
||||
}
|
||||
|
||||
// Unmarshal a byte slice to this COF
|
||||
|
@ -22,14 +22,14 @@ const (
|
||||
|
||||
// DC6 represents a DC6 file.
|
||||
type DC6 struct {
|
||||
Version int32
|
||||
Flags uint32
|
||||
FramePointers []uint32
|
||||
Frames []*DC6Frame
|
||||
Termination []byte
|
||||
Encoding uint32
|
||||
Termination []byte // 4 bytes
|
||||
Directions uint32
|
||||
FramesPerDirection uint32
|
||||
FramePointers []uint32 // size is Directions*FramesPerDirection
|
||||
Frames []*DC6Frame // size is Directions*FramesPerDirection
|
||||
Version int32
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
// New creates a new, empty DC6
|
||||
|
@ -2,14 +2,14 @@ package d2dc6
|
||||
|
||||
// DC6Frame represents a single frame in a DC6.
|
||||
type DC6Frame struct {
|
||||
FrameData []byte
|
||||
Terminator []byte
|
||||
Flipped uint32
|
||||
Width uint32
|
||||
Height uint32
|
||||
OffsetX int32
|
||||
OffsetY int32
|
||||
Unknown uint32
|
||||
NextBlock uint32
|
||||
Length uint32
|
||||
FrameData []byte // size is the value of Length
|
||||
Terminator []byte // 3 bytes
|
||||
Height uint32
|
||||
OffsetX int32
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package d2dc6
|
||||
|
||||
// DC6Header represents the file header of a DC6 file.
|
||||
type DC6Header struct {
|
||||
Termination []byte `struct:"[4]byte"`
|
||||
Version int32 `struct:"int32"`
|
||||
Flags uint32 `struct:"uint32"`
|
||||
Encoding uint32 `struct:"uint32"`
|
||||
Termination []byte `struct:"[4]byte"`
|
||||
Directions int32 `struct:"int32"`
|
||||
FramesPerDirection int32 `struct:"int32"`
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ const directionOffsetMultiplier = 8
|
||||
|
||||
// DCC represents a DCC file.
|
||||
type DCC struct {
|
||||
Signature int
|
||||
fileData []byte
|
||||
Directions []*DCCDirection
|
||||
directionOffsets []int
|
||||
Version int
|
||||
NumberOfDirections int
|
||||
FramesPerDirection int
|
||||
Directions []*DCCDirection
|
||||
directionOffsets []int
|
||||
fileData []byte
|
||||
Signature int
|
||||
}
|
||||
|
||||
// Load loads a DCC file.
|
||||
|
@ -20,27 +20,27 @@ const cellsPerRow = 4
|
||||
|
||||
// DCCDirection represents a DCCDirection file.
|
||||
type DCCDirection struct {
|
||||
OutSizeCoded int
|
||||
CompressionFlags int
|
||||
Variable0Bits int
|
||||
WidthBits int
|
||||
HeightBits int
|
||||
XOffsetBits int
|
||||
PixelBuffer []DCCPixelBufferEntry
|
||||
PixelData []byte
|
||||
Cells []*DCCCell
|
||||
Frames []*DCCDirectionFrame
|
||||
Box d2geom.Rectangle
|
||||
PixelMaskBitstreamSize int
|
||||
YOffsetBits int
|
||||
OptionalDataBits int
|
||||
CodedBytesBits int
|
||||
EqualCellsBitstreamSize int
|
||||
PixelMaskBitstreamSize int
|
||||
XOffsetBits int
|
||||
EncodingTypeBitsreamSize int
|
||||
RawPixelCodesBitstreamSize int
|
||||
Frames []*DCCDirectionFrame
|
||||
PaletteEntries [256]byte
|
||||
Box d2geom.Rectangle
|
||||
Cells []*DCCCell
|
||||
PixelData []byte
|
||||
HorizontalCellCount int
|
||||
HeightBits 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.
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
|
||||
// DCCDirectionFrame represents a direction frame for a DCC.
|
||||
type DCCDirectionFrame struct {
|
||||
Box d2geom.Rectangle
|
||||
Cells []DCCCell
|
||||
PixelData []byte
|
||||
Width int
|
||||
Box d2geom.Rectangle
|
||||
YOffset int
|
||||
Height int
|
||||
XOffset int
|
||||
YOffset int
|
||||
Width int
|
||||
NumberOfOptionalBytes int
|
||||
NumberOfCodedBytes int
|
||||
HorizontalCellCount int
|
||||
|
@ -37,11 +37,12 @@ func (l LayerGroupType) String() string {
|
||||
type layerGroup []*Layer
|
||||
|
||||
type ds1Layers struct {
|
||||
width, height int
|
||||
Floors layerGroup
|
||||
Walls layerGroup
|
||||
Shadows layerGroup
|
||||
Substitutions layerGroup
|
||||
width int
|
||||
height int
|
||||
}
|
||||
|
||||
func (l *ds1Layers) ensureInit() {
|
||||
|
@ -169,10 +169,10 @@ func exampleData() *DS1 { //nolint:funlen // not a big deal if this is long func
|
||||
},
|
||||
Files: []string{"a.dt1", "bfile.dt1"},
|
||||
Objects: []Object{
|
||||
{0, 0, 0, 0, 0, nil},
|
||||
{0, 1, 0, 0, 0, []d2path.Path{{}}},
|
||||
{0, 2, 0, 0, 0, nil},
|
||||
{0, 3, 0, 0, 0, nil},
|
||||
{nil, 0, 0, 0, 0, 0},
|
||||
{[]d2path.Path{{}}, 0, 1, 0, 0, 0},
|
||||
{nil, 0, 2, 0, 0, 0},
|
||||
{nil, 0, 3, 0, 0, 0},
|
||||
},
|
||||
SubstitutionGroups: nil,
|
||||
version: 17,
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
|
||||
// Object is a game world object
|
||||
type Object struct {
|
||||
Paths []d2path.Path
|
||||
Type int
|
||||
ID int
|
||||
X int
|
||||
Y int
|
||||
Flags int
|
||||
Paths []d2path.Path
|
||||
}
|
||||
|
||||
// Equals checks if this Object is equivalent to the given Object
|
||||
|
@ -2,14 +2,14 @@ package d2dt1
|
||||
|
||||
// Block represents a DT1 block
|
||||
type Block struct {
|
||||
EncodedData []byte
|
||||
Length int32
|
||||
FileOffset int32
|
||||
format int16
|
||||
X int16
|
||||
Y int16
|
||||
GridX byte
|
||||
GridY byte
|
||||
format int16
|
||||
EncodedData []byte
|
||||
Length int32
|
||||
FileOffset int32
|
||||
}
|
||||
|
||||
// Format returns block format
|
||||
|
@ -31,11 +31,11 @@ const (
|
||||
|
||||
// DT1 represents a DT1 file.
|
||||
type DT1 struct {
|
||||
Tiles []Tile
|
||||
majorVersion int32
|
||||
minorVersion int32
|
||||
numberOfTiles int32
|
||||
bodyPosition int32
|
||||
Tiles []Tile
|
||||
}
|
||||
|
||||
// New creates a new DT1
|
||||
|
@ -3,19 +3,19 @@ package d2dt1
|
||||
// Tile is a representation of a map tile
|
||||
type Tile struct {
|
||||
unknown2 []byte
|
||||
Direction int32
|
||||
RoofHeight int16
|
||||
MaterialFlags MaterialFlags
|
||||
Blocks []Block
|
||||
Sequence int32
|
||||
RarityFrameIndex int32
|
||||
Height int32
|
||||
Width int32
|
||||
Type int32
|
||||
Style int32
|
||||
Sequence int32
|
||||
RarityFrameIndex int32
|
||||
SubTileFlags [25]SubTileFlags
|
||||
Direction int32
|
||||
blockHeaderPointer int32
|
||||
blockHeaderSize int32
|
||||
Blocks []Block
|
||||
Style int32
|
||||
RoofHeight int16
|
||||
SubTileFlags [25]SubTileFlags
|
||||
MaterialFlags MaterialFlags
|
||||
}
|
||||
|
||||
func (t *Tile) unknown1() []byte {
|
||||
|
@ -28,9 +28,9 @@ const (
|
||||
// Font represents a displayable font
|
||||
type Font struct {
|
||||
sheet d2interface.Animation
|
||||
table []byte
|
||||
Glyphs map[rune]*d2fontglyph.FontGlyph
|
||||
color color.Color
|
||||
Glyphs map[rune]*d2fontglyph.FontGlyph
|
||||
table []byte
|
||||
}
|
||||
|
||||
// Load loads a new font from byte slice
|
||||
|
@ -32,14 +32,13 @@ const (
|
||||
)
|
||||
|
||||
// Block represents an entry in the block table
|
||||
type Block struct { // 16 bytes
|
||||
type Block struct {
|
||||
FileName string
|
||||
FilePosition uint32
|
||||
CompressedFileSize uint32
|
||||
UncompressedFileSize uint32
|
||||
Flags FileFlag
|
||||
// Local Stuff...
|
||||
FileName string
|
||||
EncryptionSeed uint32
|
||||
EncryptionSeed uint32
|
||||
}
|
||||
|
||||
// HasFlag returns true if the specified flag is present
|
||||
|
@ -3,6 +3,6 @@ package d2mpq
|
||||
// MpqFileRecord represents a file record in an MPQ
|
||||
type MpqFileRecord struct {
|
||||
MpqFile string
|
||||
IsPatch bool
|
||||
UnpatchedMpqFile string
|
||||
IsPatch bool
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ import (
|
||||
|
||||
// Stream represents a stream of data in an MPQ archive
|
||||
type Stream struct {
|
||||
Data []byte
|
||||
Positions []uint32
|
||||
MPQ *MPQ
|
||||
Block *Block
|
||||
Data []byte
|
||||
Positions []uint32
|
||||
Index uint32
|
||||
Size uint32
|
||||
Position uint32
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
|
||||
// DataDictionary represents a data file (Excel)
|
||||
type DataDictionary struct {
|
||||
Err error
|
||||
lookup map[string]int
|
||||
r *csv.Reader
|
||||
record []string
|
||||
Err error
|
||||
}
|
||||
|
||||
// LoadDataDictionary loads the contents of a spreadsheet style txt file
|
||||
|
@ -6,48 +6,48 @@ import (
|
||||
|
||||
// MusicDef stores the music definitions of a region
|
||||
type MusicDef struct {
|
||||
MusicFile string
|
||||
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}, // ?
|
||||
{BGMAct1Town1, d2enum.RegionAct1Town, false},
|
||||
{BGMAct1Wild, d2enum.RegionAct1Wilderness, false},
|
||||
{BGMAct1Caves, d2enum.RegionAct1Cave, false},
|
||||
{BGMAct1Crypt, d2enum.RegionAct1Crypt, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Monestary, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Courtyard, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Barracks, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Jail, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Cathedral, false},
|
||||
{BGMAct1Monastery, d2enum.RegionAct1Catacombs, false},
|
||||
{BGMAct1Tristram, d2enum.RegionAct1Tristram, false},
|
||||
{BGMAct2Town2, d2enum.RegionAct2Town, false},
|
||||
{BGMAct2Sewer, d2enum.RegionAct2Sewer, false},
|
||||
{BGMAct2Harem, d2enum.RegionAct2Harem, false},
|
||||
{BGMAct2Harem, d2enum.RegionAct2Basement, false},
|
||||
{BGMAct2Desert, d2enum.RegionAct2Desert, false},
|
||||
{BGMAct2Tombs, d2enum.RegionAct2Tomb, false},
|
||||
{BGMAct2Lair, d2enum.RegionAct2Lair, false},
|
||||
{BGMAct2Sanctuary, d2enum.RegionAct2Arcane, false},
|
||||
{BGMAct3Town3, d2enum.RegionAct3Town, false},
|
||||
{BGMAct3Jungle, d2enum.RegionAct3Jungle, false},
|
||||
{BGMAct3Kurast, d2enum.RegionAct3Kurast, false},
|
||||
{BGMAct3Spider, d2enum.RegionAct3Spider, false},
|
||||
{BGMAct3KurastSewer, d2enum.RegionAct3Dungeon, false},
|
||||
{BGMAct3KurastSewer, d2enum.RegionAct3Sewer, false},
|
||||
{BGMAct4Town4, d2enum.RegionAct4Town, false},
|
||||
{BGMAct4Mesa, d2enum.RegionAct4Mesa, false},
|
||||
{BGMAct4Mesa, d2enum.RegionAct4Lava, false},
|
||||
{BGMAct5XTown, d2enum.RegonAct5Town, false},
|
||||
{BGMAct5Siege, d2enum.RegionAct5Siege, false},
|
||||
{BGMAct5Siege, d2enum.RegionAct5Barricade, false}, // ?
|
||||
{BGMAct5XTemple, d2enum.RegionAct5Temple, false},
|
||||
{BGMAct5IceCaves, d2enum.RegionAct5IceCaves, false},
|
||||
{BGMAct5Baal, d2enum.RegionAct5Baal, false},
|
||||
{BGMAct5Nihlathak, d2enum.RegionAct5Lava, false}, // ?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ func NewLogger() *Logger {
|
||||
|
||||
// Logger is used to write log messages, and can have a log level to determine verbosity
|
||||
type Logger struct {
|
||||
prefix string
|
||||
io.Writer
|
||||
prefix string
|
||||
level LogLevel
|
||||
colorEnabled bool
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user