mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-06 03:24:15 -04:00
fix lint errors for dc6 package (#681)
This commit is contained in:
parent
120afe51a1
commit
c3326a30f1
@ -9,6 +9,14 @@ const (
|
|||||||
maxRunLength = 0x7f
|
maxRunLength = 0x7f
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type scanlineState int
|
||||||
|
|
||||||
|
const (
|
||||||
|
endOfLine scanlineState = iota
|
||||||
|
runOfTransparentPixels
|
||||||
|
runOfOpaquePixels
|
||||||
|
)
|
||||||
|
|
||||||
// DC6 represents a DC6 file.
|
// DC6 represents a DC6 file.
|
||||||
type DC6 struct {
|
type DC6 struct {
|
||||||
Version int32
|
Version int32
|
||||||
@ -75,22 +83,24 @@ func (d *DC6) DecodeFrame(frameIndex int) []byte {
|
|||||||
y := int(frame.Height) - 1
|
y := int(frame.Height) - 1
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
|
loop: // this is a label for the loop, so the switch can break the loop (and not the switch)
|
||||||
for {
|
for {
|
||||||
b := int(frame.FrameData[offset])
|
b := int(frame.FrameData[offset])
|
||||||
offset++
|
offset++
|
||||||
|
|
||||||
if b == endOfScanLine {
|
switch scanlineType(b) {
|
||||||
|
case endOfLine:
|
||||||
if y == 0 {
|
if y == 0 {
|
||||||
break
|
break loop
|
||||||
}
|
}
|
||||||
|
|
||||||
y--
|
y--
|
||||||
|
|
||||||
x = 0
|
x = 0
|
||||||
} else if b&endOfScanLine > 0 {
|
case runOfTransparentPixels:
|
||||||
transparentPixels := b & maxRunLength
|
transparentPixels := b & maxRunLength
|
||||||
x += transparentPixels
|
x += transparentPixels
|
||||||
} else {
|
case runOfOpaquePixels:
|
||||||
for i := 0; i < b; i++ {
|
for i := 0; i < b; i++ {
|
||||||
indexData[x+y*int(frame.Width)+i] = frame.FrameData[offset]
|
indexData[x+y*int(frame.Width)+i] = frame.FrameData[offset]
|
||||||
offset++
|
offset++
|
||||||
@ -102,3 +112,15 @@ func (d *DC6) DecodeFrame(frameIndex int) []byte {
|
|||||||
|
|
||||||
return indexData
|
return indexData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func scanlineType(b int) scanlineState {
|
||||||
|
if b == endOfScanLine {
|
||||||
|
return endOfLine
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b & endOfScanLine) > 0 {
|
||||||
|
return runOfTransparentPixels
|
||||||
|
}
|
||||||
|
|
||||||
|
return runOfOpaquePixels
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user