diff --git a/d2common/d2data/d2compression/wav.go b/d2common/d2data/d2compression/wav.go index 32b8706d..85818289 100644 --- a/d2common/d2data/d2compression/wav.go +++ b/d2common/d2data/d2compression/wav.go @@ -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) diff --git a/d2common/d2enum/skill_class.go b/d2common/d2enum/skill_class.go index 76dd7f32..5aa456aa 100644 --- a/d2common/d2enum/skill_class.go +++ b/d2common/d2enum/skill_class.go @@ -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) diff --git a/d2common/d2fileformats/d2dcc/dcc_direction.go b/d2common/d2fileformats/d2dcc/dcc_direction.go index eca7c700..22b6900f 100644 --- a/d2common/d2fileformats/d2dcc/dcc_direction.go +++ b/d2common/d2fileformats/d2dcc/dcc_direction.go @@ -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} diff --git a/d2common/d2fileformats/d2dcc/dcc_direction_frame.go b/d2common/d2fileformats/d2dcc/dcc_direction_frame.go index e3cfcf45..65b5f654 100644 --- a/d2common/d2fileformats/d2dcc/dcc_direction_frame.go +++ b/d2common/d2fileformats/d2dcc/dcc_direction_frame.go @@ -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-- } diff --git a/d2common/d2fileformats/d2dt1/dt1.go b/d2common/d2fileformats/d2dt1/dt1.go index 84ebb58d..ed0257b0 100644 --- a/d2common/d2fileformats/d2dt1/dt1.go +++ b/d2common/d2fileformats/d2dt1/dt1.go @@ -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) diff --git a/d2common/d2fileformats/d2dt1/material.go b/d2common/d2fileformats/d2dt1/material.go index d5708b28..27da3394 100644 --- a/d2common/d2fileformats/d2dt1/material.go +++ b/d2common/d2fileformats/d2dt1/material.go @@ -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, diff --git a/d2common/d2fileformats/d2dt1/subtile.go b/d2common/d2fileformats/d2dt1/subtile.go index 1e048837..981ee681 100644 --- a/d2common/d2fileformats/d2dt1/subtile.go +++ b/d2common/d2fileformats/d2dt1/subtile.go @@ -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, diff --git a/d2common/d2fileformats/d2mpq/crypto_buff.go b/d2common/d2fileformats/d2mpq/crypto_buff.go index 2c000bf2..7618743b 100644 --- a/d2common/d2fileformats/d2mpq/crypto_buff.go +++ b/d2common/d2fileformats/d2mpq/crypto_buff.go @@ -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) diff --git a/d2common/d2fileformats/d2mpq/mpq.go b/d2common/d2fileformats/d2mpq/mpq.go index 07a6e631..23deed54 100644 --- a/d2common/d2fileformats/d2mpq/mpq.go +++ b/d2common/d2fileformats/d2mpq/mpq.go @@ -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 diff --git a/d2common/d2fileformats/d2mpq/mpq_stream.go b/d2common/d2fileformats/d2mpq/mpq_stream.go index 816b92ee..b6156322 100644 --- a/d2common/d2fileformats/d2mpq/mpq_stream.go +++ b/d2common/d2fileformats/d2mpq/mpq_stream.go @@ -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)) diff --git a/d2core/d2asset/animation.go b/d2core/d2asset/animation.go index 275ff356..2efc92c7 100644 --- a/d2core/d2asset/animation.go +++ b/d2core/d2asset/animation.go @@ -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() diff --git a/d2core/d2asset/composite.go b/d2core/d2asset/composite.go index ce2b7b45..d81a139e 100644 --- a/d2core/d2asset/composite.go +++ b/d2core/d2asset/composite.go @@ -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 { diff --git a/d2core/d2asset/dc6_animation.go b/d2core/d2asset/dc6_animation.go index 0d507224..bd793172 100644 --- a/d2core/d2asset/dc6_animation.go +++ b/d2core/d2asset/dc6_animation.go @@ -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 } diff --git a/d2core/d2asset/dcc_animation.go b/d2core/d2asset/dcc_animation.go index 41e0f314..0b91943b 100644 --- a/d2core/d2asset/dcc_animation.go +++ b/d2core/d2asset/dcc_animation.go @@ -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 } diff --git a/d2core/d2hero/hero_skill.go b/d2core/d2hero/hero_skill.go index fd54655c..61e44bf3 100644 --- a/d2core/d2hero/hero_skill.go +++ b/d2core/d2hero/hero_skill.go @@ -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"` diff --git a/d2core/d2hero/hero_state_factory.go b/d2core/d2hero/hero_state_factory.go index c565c12d..72be28ac 100644 --- a/d2core/d2hero/hero_state_factory.go +++ b/d2core/d2hero/hero_state_factory.go @@ -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 } diff --git a/d2core/d2input/ebiten/ebiten_input.go b/d2core/d2input/ebiten/ebiten_input.go index 1d1e0516..cb7a91d2 100644 --- a/d2core/d2input/ebiten/ebiten_input.go +++ b/d2core/d2input/ebiten/ebiten_input.go @@ -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, diff --git a/d2core/d2item/diablo2item/item_property_test.go b/d2core/d2item/diablo2item/item_property_test.go index ca07f17b..5736382f 100644 --- a/d2core/d2item/diablo2item/item_property_test.go +++ b/d2core/d2item/diablo2item/item_property_test.go @@ -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 { diff --git a/d2core/d2map/d2mapentity/object.go b/d2core/d2map/d2mapentity/object.go index 389fc832..71dbaf1e 100644 --- a/d2core/d2map/d2mapentity/object.go +++ b/d2core/d2map/d2mapentity/object.go @@ -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 { diff --git a/d2core/d2map/d2mapgen/act1_overworld.go b/d2core/d2map/d2mapgen/act1_overworld.go index ebb29f1e..90f40956 100644 --- a/d2core/d2map/d2mapgen/act1_overworld.go +++ b/d2core/d2map/d2mapgen/act1_overworld.go @@ -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) diff --git a/d2core/d2stats/diablo2stats/stat.go b/d2core/d2stats/diablo2stats/stat.go index 53ce0691..5e3753c5 100644 --- a/d2core/d2stats/diablo2stats/stat.go +++ b/d2core/d2stats/diablo2stats/stat.go @@ -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() diff --git a/d2game/d2player/skill_select_menu.go b/d2game/d2player/skill_select_menu.go index ba15eacf..2c70c9bb 100644 --- a/d2game/d2player/skill_select_menu.go +++ b/d2game/d2player/skill_select_menu.go @@ -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 diff --git a/main.go b/main.go index 1c1f998d..e66f056a 100644 --- a/main.go +++ b/main.go @@ -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() {