mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-06-22 23:25:23 +00:00
fixing most of the remaining lint errors in d2fileformats (#600)
This commit is contained in:
parent
fc31594277
commit
093ea3682e
|
@ -1,5 +1,15 @@
|
|||
package d2cof
|
||||
|
||||
type directionCount int
|
||||
|
||||
const (
|
||||
four directionCount = 4 << iota
|
||||
eight
|
||||
sixteen
|
||||
thirtyTwo
|
||||
sixtyFour
|
||||
)
|
||||
|
||||
// Dir64ToCof returns the cof direction based on the actual direction
|
||||
func Dir64ToCof(direction, numDirections int) int {
|
||||
var dir4 = [64]int{
|
||||
|
@ -32,16 +42,16 @@ func Dir64ToCof(direction, numDirections int) int {
|
|||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}
|
||||
|
||||
switch numDirections {
|
||||
case 4:
|
||||
switch directionCount(numDirections) {
|
||||
case four:
|
||||
return dir4[direction]
|
||||
case 8:
|
||||
case eight:
|
||||
return dir8[direction]
|
||||
case 16:
|
||||
case sixteen:
|
||||
return dir16[direction]
|
||||
case 32:
|
||||
case thirtyTwo:
|
||||
return dir32[direction]
|
||||
case 64:
|
||||
case sixtyFour:
|
||||
return dir64[direction]
|
||||
default:
|
||||
return 0
|
||||
|
|
|
@ -50,10 +50,12 @@ func (c *DATColor) SetRGBA(rgba uint32) {
|
|||
c.r, c.g, c.b, c.a = toComponent(rgba)
|
||||
}
|
||||
|
||||
// BGRA gets the combination of the color components (0xBBGGRRAA)
|
||||
func (c *DATColor) BGRA() uint32 {
|
||||
return toComposite(c.b, c.g, c.r, c.a)
|
||||
}
|
||||
|
||||
// SetBGRA sets the color components using the given BGRA form
|
||||
func (c *DATColor) SetBGRA(bgra uint32) {
|
||||
c.b, c.g, c.r, c.a = toComponent(bgra)
|
||||
}
|
||||
|
@ -72,6 +74,6 @@ func toComponent (wxyz uint32) (w,x,y,z uint8){
|
|||
x = uint8(wxyz >> bitShift16 & mask)
|
||||
y = uint8(wxyz >> bitShift8 & mask)
|
||||
z = uint8(wxyz >> bitShift0 & mask)
|
||||
|
||||
return w, x, y, z
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package d2dat
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ import (
|
|||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
const (
|
||||
endOfScanLine = 0x80
|
||||
maxRunLength = 0x7f
|
||||
)
|
||||
|
||||
// DC6 represents a DC6 file.
|
||||
type DC6 struct {
|
||||
Version int32
|
||||
|
@ -41,6 +46,7 @@ func Load(data []byte) (*DC6, error) {
|
|||
}
|
||||
|
||||
dc.Frames = make([]*DC6Frame, frameCount)
|
||||
|
||||
for i := 0; i < frameCount; i++ {
|
||||
frame := &DC6Frame{
|
||||
Flipped: r.GetUInt32(),
|
||||
|
@ -73,7 +79,7 @@ func (d *DC6) DecodeFrame(frameIndex int) []byte {
|
|||
b := int(frame.FrameData[offset])
|
||||
offset++
|
||||
|
||||
if b == 0x80 {
|
||||
if b == endOfScanLine {
|
||||
if y == 0 {
|
||||
break
|
||||
}
|
||||
|
@ -81,8 +87,8 @@ func (d *DC6) DecodeFrame(frameIndex int) []byte {
|
|||
y--
|
||||
|
||||
x = 0
|
||||
} else if b&0x80 > 0 {
|
||||
transparentPixels := b & 0x7f
|
||||
} else if b&endOfScanLine > 0 {
|
||||
transparentPixels := b & maxRunLength
|
||||
x += transparentPixels
|
||||
} else {
|
||||
for i := 0; i < b; i++ {
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
package d2dcc
|
||||
|
||||
type directionCount int
|
||||
|
||||
const (
|
||||
four directionCount = 4 << iota
|
||||
eight
|
||||
sixteen
|
||||
thirtyTwo
|
||||
sixtyFour
|
||||
)
|
||||
|
||||
// Dir64ToDcc returns the DCC direction based on the actual direction.
|
||||
// Special thanks for Necrolis for these tables!
|
||||
func Dir64ToDcc(direction, numDirections int) int {
|
||||
|
@ -33,16 +43,16 @@ func Dir64ToDcc(direction, numDirections int) int {
|
|||
6, 48, 24, 49, 12, 50, 25, 51, 2, 52, 26, 53, 13, 54, 27, 55,
|
||||
7, 56, 28, 57, 14, 58, 29, 59, 3, 60, 30, 61, 15, 62, 31, 63}
|
||||
|
||||
switch numDirections {
|
||||
case 4:
|
||||
switch directionCount(numDirections) {
|
||||
case four:
|
||||
return dir4[direction]
|
||||
case 8:
|
||||
case eight:
|
||||
return dir8[direction]
|
||||
case 16:
|
||||
case sixteen:
|
||||
return dir16[direction]
|
||||
case 32:
|
||||
case thirtyTwo:
|
||||
return dir32[direction]
|
||||
case 64:
|
||||
case sixtyFour:
|
||||
return dir64[direction]
|
||||
default:
|
||||
return 0
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package d2dt1
|
||||
|
||||
// Tile is a representation of a map tile
|
||||
type Tile struct {
|
||||
Direction int32
|
||||
RoofHeight int16
|
||||
|
@ -16,6 +17,8 @@ type Tile struct {
|
|||
Blocks []Block
|
||||
}
|
||||
|
||||
// GetSubTileFlags returns the tile flags for the given subtile
|
||||
func (t *Tile) GetSubTileFlags(x, y int) *SubTileFlags {
|
||||
var subtileLookup = [5][5]int{
|
||||
{20, 21, 22, 23, 24},
|
||||
{15, 16, 17, 18, 19},
|
||||
|
@ -24,7 +27,5 @@ var subtileLookup = [5][5]int{
|
|||
{0, 1, 2, 3, 4},
|
||||
}
|
||||
|
||||
func (t *Tile) GetSubTileFlags(x, y int) *SubTileFlags {
|
||||
|
||||
return &t.SubTileFlags[subtileLookup[y][x]]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package d2mpq
|
||||
|
||||
// hashEntryMap represents a hash entry map
|
||||
// HashEntryMap represents a hash entry map
|
||||
type HashEntryMap struct {
|
||||
entries map[uint64]HashTableEntry
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user