Various lint error fixes and suppressions (#846)

* suppressing the magic number lint errors in mapgen, it will get a heavy refactor soon, hopefully...

* adding string token constants for SkillClass

* adding panic on error to left/right skill select render

* fixed cuddle lint error

* fixed unnecessary conversion, unused func param lint errors in dcc_animation.go

* adding comment for skill class tokens

* fixed typo in comment

* removed unused parameter in dcc/dc6 animations

* supress warning about Object.setMode always being passed direction value of 0

* fixed all invalid golint directives

* fixed a couple gocritic lint errors
This commit is contained in:
gravestench 2020-10-26 09:04:50 +00:00 committed by GitHub
parent 622186e350
commit 6f8b43f8d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 103 additions and 95 deletions

View File

@ -6,7 +6,7 @@ import (
// WavDecompress decompresses wav files
//nolint:gomnd // binary decode magic
func WavDecompress(data []byte, channelCount int) []byte { //nolint:funlen doesn't make sense to split
func WavDecompress(data []byte, channelCount int) []byte { //nolint:funlen // can't reduce
Array1 := []int{0x2c, 0x2c}
Array2 := make([]int, channelCount)

View File

@ -17,26 +17,38 @@ const (
SkillClassDruid
)
// Skill class tokens
const (
SkillClassTokenGeneric = ""
SkillClassTokenBarbarian = "bar"
SkillClassTokenNecromancer = "nec"
SkillClassTokenPaladin = "pal"
SkillClassTokenAssassin = "ass"
SkillClassTokenSorceress = "sor"
SkillClassTokenAmazon = "ama"
SkillClassTokenDruid = "dru"
)
// FromToken returns the enum which corresponds to the given class token
func (sc *SkillClass) FromToken(classToken string) SkillClass {
resource := SkillClassGeneric
switch classToken {
case "":
case SkillClassTokenGeneric:
return SkillClassGeneric
case "bar":
case SkillClassTokenBarbarian:
return SkillClassBarbarian
case "nec":
case SkillClassTokenNecromancer:
return SkillClassNecromancer
case "pal":
case SkillClassTokenPaladin:
return SkillClassPaladin
case "ass":
case SkillClassTokenAssassin:
return SkillClassAssassin
case "sor":
case SkillClassTokenSorceress:
return SkillClassSorceress
case "ama":
case SkillClassTokenAmazon:
return SkillClassAmazon
case "dru":
case SkillClassTokenDruid:
return SkillClassDruid
default:
log.Fatalf("Unknown skill class token: '%s'", classToken)

View File

@ -162,7 +162,7 @@ func (v *DCCDirection) verify(
}
}
//nolint:gocognit nolint:gocyclo // Can't reduce
// nolint:gocognit,gocyclo // Can't reduce
func (v *DCCDirection) generateFrames(pcd *d2datautils.BitMuncher) {
pbIdx := 0
@ -265,7 +265,7 @@ func (v *DCCDirection) generateFrames(pcd *d2datautils.BitMuncher) {
v.PixelBuffer = nil
}
//nolint:funlen nolint:gocognit // can't reduce
//nolint:funlen,gocognit // can't reduce
func (v *DCCDirection) fillPixelBuffer(pcd, ec, pm, et, rp *d2datautils.BitMuncher) {
var pixelMaskLookup = []int{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}

View File

@ -61,20 +61,20 @@ func (v *DCCDirectionFrame) recalculateCells(direction *DCCDirection) {
v.HorizontalCellCount = 1
} else {
tmp := v.Width - w - 1
v.HorizontalCellCount = 2 + (tmp / 4) //nolint:gomnd magic math
v.HorizontalCellCount = 2 + (tmp / 4) //nolint:gomnd // magic math
if (tmp % 4) == 0 {
v.HorizontalCellCount--
}
}
// Height of the first column (in pixels)
h := 4 - ((v.Box.Top - direction.Box.Top) % 4) //nolint:gomnd data decode
h := 4 - ((v.Box.Top - direction.Box.Top) % 4) //nolint:gomnd // data decode
if (v.Height - h) <= 1 {
v.VerticalCellCount = 1
} else {
tmp := v.Height - h - 1
v.VerticalCellCount = 2 + (tmp / 4) //nolint:gomnd data decode
v.VerticalCellCount = 2 + (tmp / 4) //nolint:gomnd // data decode
if (tmp % 4) == 0 {
v.VerticalCellCount--
}

View File

@ -23,7 +23,7 @@ const (
)
// LoadDT1 loads a DT1 record
//nolint:funlen Can't reduce
//nolint:funlen // Can't reduce
func LoadDT1(fileData []byte) (*DT1, error) {
result := &DT1{}
br := d2datautils.CreateStreamReader(fileData)

View File

@ -15,7 +15,7 @@ type MaterialFlags struct {
}
// NewMaterialFlags represents the material flags
// nolint:gomnd Binary values
// nolint:gomnd // Binary values
func NewMaterialFlags(data uint16) MaterialFlags {
return MaterialFlags{
Other: data&0x0001 == 0x0001,

View File

@ -64,7 +64,7 @@ func (s *SubTileFlags) DebugString() string {
}
// NewSubTileFlags returns a list of new subtile flags
//nolint:gomnd binary flags
//nolint:gomnd // binary flags
func NewSubTileFlags(data byte) SubTileFlags {
return SubTileFlags{
BlockWalk: data&1 == 1,

View File

@ -1,7 +1,7 @@
package d2mpq
var cryptoBuffer [0x500]uint32 //nolint:gochecknoglobals will fix later..
var cryptoBufferReady bool //nolint:gochecknoglobals will fix later..
var cryptoBuffer [0x500]uint32 //nolint:gochecknoglobals // will fix later..
var cryptoBufferReady bool //nolint:gochecknoglobals // will fix later..
func cryptoLookup(index uint32) uint32 {
if !cryptoBufferReady {
@ -13,7 +13,7 @@ func cryptoLookup(index uint32) uint32 {
return cryptoBuffer[index]
}
//nolint:gomnd magic cryptographic stuff here...
//nolint:gomnd // magic cryptographic stuff here...
func cryptoInitialize() {
seed := uint32(0x00100001)

View File

@ -106,7 +106,7 @@ func Load(fileName string) (d2interface.Archive, error) {
if runtime.GOOS == "linux" {
result.file, err = openIgnoreCase(fileName)
} else {
result.file, err = os.Open(fileName) //nolint:gosec Will fix later
result.file, err = os.Open(fileName) //nolint:gosec // Will fix later
}
if err != nil {
@ -122,7 +122,7 @@ func Load(fileName string) (d2interface.Archive, error) {
func openIgnoreCase(mpqPath string) (*os.File, error) {
// First see if file exists with specified case
mpqFile, err := os.Open(mpqPath) //nolint:gosec Will fix later
mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later
if err == nil {
return mpqFile, err
}
@ -142,7 +142,7 @@ func openIgnoreCase(mpqPath string) (*os.File, error) {
}
}
file, err := os.Open(path.Join(mpqDir, mpqName)) //nolint:gosec Will fix later
file, err := os.Open(path.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later
return file, err
}
@ -174,7 +174,7 @@ func (v *MPQ) loadHashTable() error {
log.Panic(err)
}
hashData := make([]uint32, v.data.HashTableEntries*4) //nolint:gomnd Decryption magic
hashData := make([]uint32, v.data.HashTableEntries*4) //nolint:gomnd // // Decryption magic
hash := make([]byte, 4)
for i := range hashData {
@ -193,8 +193,8 @@ func (v *MPQ) loadHashTable() error {
NamePartA: hashData[i*4],
NamePartB: hashData[(i*4)+1],
// https://github.com/OpenDiablo2/OpenDiablo2/issues/812
Locale: uint16(hashData[(i*4)+2] >> 16), //nolint:gomnd binary data
Platform: uint16(hashData[(i*4)+2] & 0xFFFF), //nolint:gomnd binary data
Locale: uint16(hashData[(i*4)+2] >> 16), //nolint:gomnd // // binary data
Platform: uint16(hashData[(i*4)+2] & 0xFFFF), //nolint:gomnd // // binary data
BlockIndex: hashData[(i*4)+3],
})
}
@ -208,11 +208,11 @@ func (v *MPQ) loadBlockTable() {
log.Panic(err)
}
blockData := make([]uint32, v.data.BlockTableEntries*4) //nolint:gomnd binary data
blockData := make([]uint32, v.data.BlockTableEntries*4) //nolint:gomnd // // binary data
hash := make([]byte, 4)
for i := range blockData {
_, err = v.file.Read(hash[:]) //nolint:errcheck Will fix later
_, err = v.file.Read(hash) //nolint:errcheck // Will fix later
if err != nil {
log.Print(err)
}
@ -233,43 +233,43 @@ func (v *MPQ) loadBlockTable() {
}
func decrypt(data []uint32, seed uint32) {
seed2 := uint32(0xeeeeeeee) //nolint:gomnd Decryption magic
seed2 := uint32(0xeeeeeeee) //nolint:gomnd // Decryption magic
for i := 0; i < len(data); i++ {
seed2 += cryptoLookup(0x400 + (seed & 0xff)) //nolint:gomnd Decryption magic
seed2 += cryptoLookup(0x400 + (seed & 0xff)) //nolint:gomnd // Decryption magic
result := data[i]
result ^= seed + seed2
seed = ((^seed << 21) + 0x11111111) | (seed >> 11)
seed2 = result + seed2 + (seed2 << 5) + 3 //nolint:gomnd Decryption magic
seed2 = result + seed2 + (seed2 << 5) + 3 //nolint:gomnd // Decryption magic
data[i] = result
}
}
func decryptBytes(data []byte, seed uint32) {
seed2 := uint32(0xEEEEEEEE) //nolint:gomnd Decryption magic
seed2 := uint32(0xEEEEEEEE) //nolint:gomnd // Decryption magic
for i := 0; i < len(data)-3; i += 4 {
seed2 += cryptoLookup(0x400 + (seed & 0xFF)) //nolint:gomnd Decryption magic
seed2 += cryptoLookup(0x400 + (seed & 0xFF)) //nolint:gomnd // Decryption magic
result := binary.LittleEndian.Uint32(data[i : i+4])
result ^= seed + seed2
seed = ((^seed << 21) + 0x11111111) | (seed >> 11)
seed2 = result + seed2 + (seed2 << 5) + 3 //nolint:gomnd Decryption magic
seed2 = result + seed2 + (seed2 << 5) + 3 //nolint:gomnd // Decryption magic
data[i+0] = uint8(result & 0xff) //nolint:gomnd Decryption magic
data[i+1] = uint8((result >> 8) & 0xff) //nolint:gomnd Decryption magic
data[i+2] = uint8((result >> 16) & 0xff) //nolint:gomnd Decryption magic
data[i+3] = uint8((result >> 24) & 0xff) //nolint:gomnd Decryption magic
data[i+0] = uint8(result & 0xff) //nolint:gomnd // Decryption magic
data[i+1] = uint8((result >> 8) & 0xff) //nolint:gomnd // Decryption magic
data[i+2] = uint8((result >> 16) & 0xff) //nolint:gomnd // Decryption magic
data[i+3] = uint8((result >> 24) & 0xff) //nolint:gomnd // Decryption magic
}
}
func hashString(key string, hashType uint32) uint32 {
seed1 := uint32(0x7FED7FED) //nolint:gomnd Decryption magic
seed2 := uint32(0xEEEEEEEE) //nolint:gomnd Decryption magic
seed1 := uint32(0x7FED7FED) //nolint:gomnd // Decryption magic
seed2 := uint32(0xEEEEEEEE) //nolint:gomnd // Decryption magic
/* prepare seeds. */
for _, char := range strings.ToUpper(key) {
seed1 = cryptoLookup((hashType*0x100)+uint32(char)) ^ (seed1 + seed2)
seed2 = uint32(char) + seed1 + seed2 + (seed2 << 5) + 3 //nolint:gomnd Decryption magic
seed2 = uint32(char) + seed1 + seed2 + (seed2 << 5) + 3 //nolint:gomnd // Decryption magic
}
return seed1

View File

@ -33,7 +33,7 @@ func CreateStream(mpq *MPQ, blockTableEntry BlockTableEntry, fileName string) (*
result := &Stream{
MPQData: mpq,
BlockTableEntry: blockTableEntry,
CurrentBlockIndex: 0xFFFFFFFF, //nolint:gomnd MPQ magic
CurrentBlockIndex: 0xFFFFFFFF, //nolint:gomnd // MPQ magic
}
fileSegs := strings.Split(fileName, `\`)
result.EncryptionSeed = hashString(fileSegs[len(fileSegs)-1], 3)
@ -42,7 +42,7 @@ func CreateStream(mpq *MPQ, blockTableEntry BlockTableEntry, fileName string) (*
result.EncryptionSeed = (result.EncryptionSeed + result.BlockTableEntry.FilePosition) ^ result.BlockTableEntry.UncompressedFileSize
}
result.BlockSize = 0x200 << result.MPQData.data.BlockSize //nolint:gomnd MPQ magic
result.BlockSize = 0x200 << result.MPQData.data.BlockSize //nolint:gomnd // MPQ magic
if result.BlockTableEntry.HasFlag(FilePatchFile) {
log.Fatal("Patching is not supported")
@ -67,7 +67,7 @@ func (v *Stream) loadBlockOffsets() error {
return err
}
mpqBytes := make([]byte, blockPositionCount*4) //nolint:gomnd MPQ magic
mpqBytes := make([]byte, blockPositionCount*4) //nolint:gomnd // MPQ magic
_, err = v.MPQData.file.Read(mpqBytes)
if err != nil {
@ -75,11 +75,11 @@ func (v *Stream) loadBlockOffsets() error {
}
for i := range v.BlockPositions {
idx := i * 4 //nolint:gomnd MPQ magic
idx := i * 4 //nolint:gomnd // MPQ magic
v.BlockPositions[i] = binary.LittleEndian.Uint32(mpqBytes[idx : idx+4])
}
blockPosSize := blockPositionCount << 2 //nolint:gomnd MPQ magic
blockPosSize := blockPositionCount << 2 //nolint:gomnd // MPQ magic
if v.BlockTableEntry.HasFlag(FileEncrypted) {
decrypt(v.BlockPositions, v.EncryptionSeed-1)
@ -235,7 +235,7 @@ func (v *Stream) loadBlock(blockIndex, expectedLength uint32) []byte {
return data
}
//nolint:gomnd Will fix enum values later
//nolint:gomnd // Will fix enum values later
func decompressMulti(data []byte /*expectedLength*/, _ uint32) []byte {
compressionType := data[0]
@ -270,18 +270,19 @@ func decompressMulti(data []byte /*expectedLength*/, _ uint32) []byte {
return tmp
case 0x48:
//byte[] result = PKDecompress(sinput, outputLength);
//return MpqWavCompression.Decompress(new MemoryStream(result), 1);
// byte[] result = PKDecompress(sinput, outputLength);
// return MpqWavCompression.Decompress(new MemoryStream(result), 1);
panic("pk + mpqwav decompression not supported")
case 0x81:
sinput := d2compression.HuffmanDecompress(data[1:])
sinput = d2compression.WavDecompress(sinput, 2)
tmp := make([]byte, len(sinput))
copy(tmp, sinput)
return tmp
case 0x88:
//byte[] result = PKDecompress(sinput, outputLength);
//return MpqWavCompression.Decompress(new MemoryStream(result), 2);
// byte[] result = PKDecompress(sinput, outputLength);
// return MpqWavCompression.Decompress(new MemoryStream(result), 2);
panic("pk + wav decompression not supported")
default:
panic(fmt.Sprintf("decompression not supported for unknown compression type %X", compressionType))

View File

@ -202,7 +202,7 @@ func (a *Animation) RenderFromOrigin(target d2interface.Surface, shadow bool) er
if shadow && !a.effect.Transparent() && a.hasShadow {
_, height := a.GetFrameBounds()
height = int(math.Abs(float64(height)))
halfHeight := height / 2 //nolint:mnd // this ain't rocket surgery...
halfHeight := height / 2 //nolint:gomnd // this ain't rocket surgery...
target.PushTranslation(-halfHeight, 0)
defer target.Pop()

View File

@ -150,7 +150,7 @@ func (c *Composite) Equip(equipment *[d2enum.CompositeTypeMax]string) error {
// SetAnimSpeed sets the speed at which the Composite's animation should advance through its frames
func (c *Composite) SetAnimSpeed(speed int) {
c.mode.animationSpeed = 1.0 / (float64(speed) * speedUnit) // nolint:mnd inverse of freq is time
c.mode.animationSpeed = 1.0 / (float64(speed) * speedUnit) //nolint:gomnd // taking inverse
for layerIdx := range c.mode.layers {
layer := c.mode.layers[layerIdx]
if layer != nil {
@ -270,7 +270,7 @@ func (c *Composite) createMode(animationMode animationMode, weaponClass string)
weaponClass: weaponClass,
layers: make([]d2interface.Animation, d2enum.CompositeTypeMax),
frameCount: animationData[0].FramesPerDirection,
animationSpeed: 1.0 / (float64(animationData[0].AnimationSpeed) * speedUnit), // nolint:mnd inverse of freq is time
animationSpeed: 1.0 / (float64(animationData[0].AnimationSpeed) * speedUnit), //nolint:gomnd // taking inverse
}
for _, cofLayer := range cof.CofLayers {

View File

@ -102,11 +102,7 @@ func (a *DC6Animation) decode() error {
func (a *DC6Animation) decodeDirection(directionIndex int) error {
for frameIndex := 0; frameIndex < int(a.dc6.FramesPerDirection); frameIndex++ {
frame, err := a.decodeFrame(directionIndex, frameIndex)
if err != nil {
return err
}
frame := a.decodeFrame(directionIndex, frameIndex)
a.directions[directionIndex].frames[frameIndex] = frame
}
@ -115,7 +111,7 @@ func (a *DC6Animation) decodeDirection(directionIndex int) error {
return nil
}
func (a *DC6Animation) decodeFrame(directionIndex, frameIndex int) (animationFrame, error) {
func (a *DC6Animation) decodeFrame(directionIndex, frameIndex int) animationFrame {
startFrame := directionIndex * int(a.dc6.FramesPerDirection)
dc6Frame := a.dc6.Frames[startFrame+frameIndex]
@ -129,7 +125,7 @@ func (a *DC6Animation) decodeFrame(directionIndex, frameIndex int) (animationFra
a.directions[directionIndex].frames[frameIndex].decoded = true
return frame, nil
return frame
}
func (a *DC6Animation) createSurfaces() error {
@ -165,11 +161,7 @@ func (a *DC6Animation) createDirectionSurfaces(directionIndex int) error {
func (a *DC6Animation) createFrameSurface(directionIndex, frameIndex int) (d2interface.Surface, error) {
if !a.directions[directionIndex].frames[frameIndex].decoded {
frame, err := a.decodeFrame(directionIndex, frameIndex)
if err != nil {
return nil, err
}
frame := a.decodeFrame(directionIndex, frameIndex)
a.directions[directionIndex].frames[frameIndex] = frame
}

View File

@ -118,18 +118,14 @@ func (a *DCCAnimation) decodeDirection(directionIndex int) error {
a.directions[directionIndex].decoded = true
frame, err := a.decodeFrame(directionIndex, frameIndex)
if err != nil {
return err
}
frame := a.decodeFrame(directionIndex)
a.directions[directionIndex].frames[frameIndex] = frame
}
return nil
}
func (a *DCCAnimation) decodeFrame(directionIndex, frameIndex int) (animationFrame, error) {
func (a *DCCAnimation) decodeFrame(directionIndex int) animationFrame {
dccDirection := a.dcc.Directions[directionIndex]
minX, minY := math.MaxInt32, math.MaxInt32
@ -153,7 +149,7 @@ func (a *DCCAnimation) decodeFrame(directionIndex, frameIndex int) (animationFra
decoded: true,
}
return frame, nil
return frame
}
func (a *DCCAnimation) createSurfaces() error {
@ -168,7 +164,7 @@ func (a *DCCAnimation) createSurfaces() error {
}
func (a *DCCAnimation) createDirectionSurfaces(directionIndex int) error {
for frameIndex := 0; frameIndex < int(a.dcc.FramesPerDirection); frameIndex++ {
for frameIndex := 0; frameIndex < a.dcc.FramesPerDirection; frameIndex++ {
if !a.directions[directionIndex].decoded {
err := a.decodeDirection(directionIndex)
if err != nil {
@ -189,11 +185,7 @@ func (a *DCCAnimation) createDirectionSurfaces(directionIndex int) error {
func (a *DCCAnimation) createFrameSurface(directionIndex, frameIndex int) (d2interface.Surface, error) {
if !a.directions[directionIndex].frames[frameIndex].decoded {
frame, err := a.decodeFrame(directionIndex, frameIndex)
if err != nil {
return nil, err
}
frame := a.decodeFrame(directionIndex)
a.directions[directionIndex].frames[frameIndex] = frame
}

View File

@ -15,7 +15,8 @@ type HeroSkill struct {
shallow *shallowHeroSkill
}
// An auxilary struct which only stores the ID of the SkillRecord, instead of the whole SkillRecord and SkillDescrptionRecord.
// An auxiliary struct which only stores the ID of the SkillRecord, instead of the whole SkillRecord
// and SkillDescrptionRecord.
type shallowHeroSkill struct {
SkillID int `json:"skillId"`
SkillPoints int `json:"skillPoints"`

View File

@ -245,6 +245,7 @@ func (f *HeroStateFactory) Save(state *HeroState) error {
if state.FilePath == "" {
state.FilePath = f.getFirstFreeFileName()
}
if err := os.MkdirAll(path.Dir(state.FilePath), mkdirPermission); err != nil {
return err
}

View File

@ -9,7 +9,7 @@ import (
)
var (
//nolint:gochecknoglobals This is a constant in all but by name, no constant map in go
//nolint:gochecknoglobals // This is a constant in all but by name, no constant map in go
keyToEbiten = map[d2enum.Key]ebiten.Key{
d2enum.Key0: ebiten.Key0,
d2enum.Key1: ebiten.Key1,
@ -112,7 +112,7 @@ var (
d2enum.KeyControl: ebiten.KeyControl,
d2enum.KeyShift: ebiten.KeyShift,
}
//nolint:gochecknoglobals This is a constant in all but by name, no constant map in go
//nolint:gochecknoglobals // This is a constant in all but by name, no constant map in go
mouseButtonToEbiten = map[d2enum.MouseButton]ebiten.MouseButton{
d2enum.MouseButtonLeft: ebiten.MouseButtonLeft,
d2enum.MouseButtonMiddle: ebiten.MouseButtonMiddle,

View File

@ -429,7 +429,7 @@ func TestSetup(t *testing.T) {
testAssetManager.Records.Properties = properties
}
func TestNewProperty(t *testing.T) { //nolint:funlen it's mostly test-case definitions
func TestNewProperty(t *testing.T) { //nolint:funlen // it's mostly test-case definitions
rand.Seed(time.Now().UTC().UnixNano())
tests := []struct {

View File

@ -26,6 +26,7 @@ type Object struct {
}
// setMode changes the graphical mode of this animated entity
// nolint:unparam // direction may not always be passed 0 in the future
func (ob *Object) setMode(animationMode d2enum.ObjectAnimationMode, direction int, randomFrame bool) error {
err := ob.composite.SetMode(animationMode, "HTH")
if err != nil {

View File

@ -1,5 +1,8 @@
package d2mapgen
// magic number suppression has been added because most of the work done here
// is experiemental, and mapgen will likely change dramatically in the future.
import (
"log"
"math/rand"
@ -80,7 +83,7 @@ func (g *MapGenerator) GenerateAct1Overworld() {
}
}
// nolint:gosec // we're not concerned with crypto-strong randomness
// nolint:gosec,gomnd // we dont need crypto-strong randomness, mapgen will get a refactor soon
func (g *MapGenerator) generateWilderness1TownEast(startX, startY int) {
levelDetails := g.asset.Records.GetLevelDetails(wildernessDetailsRecordID)
@ -146,7 +149,7 @@ func (g *MapGenerator) generateWilderness1TownEast(startX, startY int) {
g.engine.PlaceStamp(fenceSouthEastStamp, startX+levelDetails.SizeXNormal, startY+levelDetails.SizeYNormal+6)
}
// nolint:gosec // we're not concerned with crypto-strong randomness
// nolint:gosec,gomnd // we dont need crypto-strong randomness, mapgen will get a refactor soon
func (g *MapGenerator) generateWilderness1TownSouth(startX, startY int) {
levelDetails := g.asset.Records.GetLevelDetails(wildernessDetailsRecordID)
@ -200,7 +203,7 @@ func (g *MapGenerator) generateWilderness1TownSouth(startX, startY int) {
g.engine.PlaceStamp(fenceWaterBorderSouthEast, startX+(9*9)-4, startY+(8*9)+1)
}
// nolint:gosec // we're not concerned with crypto-strong randomness
// nolint:gosec,gomnd // we dont need crypto-strong randomness, mapgen will get a refactor soon
func (g *MapGenerator) generateWilderness1TownWest(startX, startY int) {
levelDetails := g.asset.Records.GetLevelDetails(wildernessDetailsRecordID)
@ -267,7 +270,7 @@ func (g *MapGenerator) generateWilderness1TownWest(startX, startY int) {
g.generateWilderness1Contents(areaRect)
}
// nolint:gosec // we're not concerned with crypto-strong randomness
// nolint:gosec,gomnd // we dont need crypto-strong randomness, mapgen will get a refactor soon
func (g *MapGenerator) generateWilderness1Contents(rect d2geom.Rectangle) {
levelDetails := g.asset.Records.GetLevelDetails(wildernessDetailsRecordID)

View File

@ -52,12 +52,12 @@ type diablo2Stat struct {
// depending on the stat record, sets up the proper number of values,
// as well as set up the stat value number types, value combination types, and
// the value stringer functions used
func (s *diablo2Stat) init(numbers ...float64) { //nolint:funlen doesn't make sense to split
func (s *diablo2Stat) init(numbers ...float64) { //nolint:funlen,gocyclo // can't reduce
if s.record == nil {
return
}
//nolint:gomdn introducing a const for these would be worse
//nolint:gomnd // introducing a const for these would be worse
switch s.record.DescFnID {
case 0:
// special case for poisonlength, or other stats, which have a
@ -345,7 +345,7 @@ func (s *diablo2Stat) canBeCombinedWith(other d2stats.Stat) bool {
}
// String returns the formatted description string
func (s *diablo2Stat) String() string { //nolint:gocyclo switch statement is not so bad
func (s *diablo2Stat) String() string { //nolint:gocyclo // switch statement is not so bad
var result string
for idx := range s.values {
@ -354,7 +354,7 @@ func (s *diablo2Stat) String() string { //nolint:gocyclo switch statement is not
}
}
//nolint:gomdn introducing a const for these would be worse
//nolint:gomnd // introducing a const for these would be worse
switch s.record.DescFnID {
case 1, 2, 3, 4, 5, 12, 20:
result = s.descFn1()

View File

@ -54,8 +54,13 @@ func (sm *SkillSelectMenu) RegenerateImageCache() {
// Render gets called on every frame
func (sm *SkillSelectMenu) Render(target d2interface.Surface) {
sm.LeftPanel.Render(target)
sm.RightPanel.Render(target)
if err := sm.LeftPanel.Render(target); err != nil {
panic(err)
}
if err := sm.RightPanel.Render(target); err != nil {
panic(err)
}
}
// IsOpen returns whether one of the panels(left or right) is open

View File

@ -14,11 +14,11 @@ import (
)
// GitBranch is set by the CI build process to the name of the branch
//nolint:gochecknoglobals This is filled in by the build system
//nolint:gochecknoglobals // This is filled in by the build system
var GitBranch string
// GitCommit is set by the CI build process to the commit hash
//nolint:gochecknoglobals This is filled in by the build system
//nolint:gochecknoglobals // This is filled in by the build system
var GitCommit string
func main() {