From 8e41133f39cace1e4baa5338b89b11a70543e87f Mon Sep 17 00:00:00 2001 From: lord Date: Tue, 4 Aug 2020 21:03:33 -0700 Subject: [PATCH] lint and minor refactor of d2common (#690) - moved contents of `d2common/math.go` into `d2math/math.go` - removed lint errors from files in d2common --- d2app/app.go | 3 +- d2common/calcstring.go | 3 +- d2common/d2fileformats/d2dcc/dcc_direction.go | 9 +- d2common/d2fileformats/d2ds1/ds1.go | 3 +- d2common/d2fileformats/d2mpq/mpq_stream.go | 8 +- d2common/d2math/math.go | 79 +++++++++++++++++ d2common/math.go | 87 ------------------- d2common/text_dictionary.go | 2 +- d2core/d2asset/animation.go | 6 +- d2core/d2asset/dcc_animation.go | 10 +-- d2core/d2asset/font.go | 10 +-- d2core/d2gui/common.go | 4 +- d2core/d2gui/layout.go | 15 ++-- d2core/d2map/d2maprenderer/tile_cache.go | 18 ++-- d2core/d2term/terminal.go | 10 +-- d2core/d2ui/sprite.go | 5 +- d2networking/d2client/game_client.go | 4 +- 17 files changed, 136 insertions(+), 140 deletions(-) delete mode 100644 d2common/math.go diff --git a/d2app/app.go b/d2app/app.go index def95dd3..e6f1e5b6 100644 --- a/d2app/app.go +++ b/d2app/app.go @@ -6,6 +6,7 @@ import ( "container/ring" "errors" "fmt" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image" "image/gif" "image/png" @@ -547,7 +548,7 @@ func (a *App) convertFramesToGif() error { framesPal[j] = framePal.(*image.Paletted) frameDelays[j] = 5 } - }(i, d2common.MinInt(i+framesPerCPU, framesTotal)) + }(i, d2math.MinInt(i+framesPerCPU, framesTotal)) } waitGroup.Wait() diff --git a/d2common/calcstring.go b/d2common/calcstring.go index 4539fc14..fa7e7a35 100644 --- a/d2common/calcstring.go +++ b/d2common/calcstring.go @@ -5,4 +5,5 @@ package d2common // source, for instance a missile might have a movement speed of lvl*2 type CalcString string -// todo: the logic for parsing these should exist here +// Issue #689 +// info about calcstrings can be found here: https://d2mods.info/forum/kb/viewarticle?a=371 diff --git a/d2common/d2fileformats/d2dcc/dcc_direction.go b/d2common/d2fileformats/d2dcc/dcc_direction.go index 3f250e2a..292dadb8 100644 --- a/d2common/d2fileformats/d2dcc/dcc_direction.go +++ b/d2common/d2fileformats/d2dcc/dcc_direction.go @@ -1,6 +1,7 @@ package d2dcc import ( + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "log" "github.com/OpenDiablo2/OpenDiablo2/d2common" @@ -57,10 +58,10 @@ func CreateDCCDirection(bm *d2common.BitMuncher, // Load the frame headers for frameIdx := 0; frameIdx < file.FramesPerDirection; frameIdx++ { result.Frames[frameIdx] = CreateDCCDirectionFrame(bm, result) - minx = int(d2common.MinInt32(int32(result.Frames[frameIdx].Box.Left), int32(minx))) - miny = int(d2common.MinInt32(int32(result.Frames[frameIdx].Box.Top), int32(miny))) - maxx = int(d2common.MaxInt32(int32(result.Frames[frameIdx].Box.Right()), int32(maxx))) - maxy = int(d2common.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy))) + minx = int(d2math.MinInt32(int32(result.Frames[frameIdx].Box.Left), int32(minx))) + miny = int(d2math.MinInt32(int32(result.Frames[frameIdx].Box.Top), int32(miny))) + maxx = int(d2math.MaxInt32(int32(result.Frames[frameIdx].Box.Right()), int32(maxx))) + maxy = int(d2math.MaxInt32(int32(result.Frames[frameIdx].Box.Bottom()), int32(maxy))) } result.Box = d2common.Rectangle{Left: minx, Top: miny, Width: maxx - minx, Height: maxy - miny} diff --git a/d2common/d2fileformats/d2ds1/ds1.go b/d2common/d2fileformats/d2ds1/ds1.go index f81003aa..4c686e14 100644 --- a/d2common/d2fileformats/d2ds1/ds1.go +++ b/d2common/d2fileformats/d2ds1/ds1.go @@ -4,6 +4,7 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector" ) @@ -42,7 +43,7 @@ func LoadDS1(fileData []byte) (*DS1, error) { ds1.Height = br.GetInt32() + 1 if ds1.Version >= 8 { //nolint:gomnd // Version number - ds1.Act = d2common.MinInt32(maxActNumber, br.GetInt32()+1) + ds1.Act = d2math.MinInt32(maxActNumber, br.GetInt32()+1) } if ds1.Version >= 10 { //nolint:gomnd // Version number diff --git a/d2common/d2fileformats/d2mpq/mpq_stream.go b/d2common/d2fileformats/d2mpq/mpq_stream.go index c1639d96..ae8f1bce 100644 --- a/d2common/d2fileformats/d2mpq/mpq_stream.go +++ b/d2common/d2fileformats/d2mpq/mpq_stream.go @@ -6,12 +6,12 @@ import ( "encoding/binary" "errors" "fmt" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "log" "strings" "github.com/JoshVarga/blast" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2compression" ) @@ -120,7 +120,7 @@ func (v *Stream) readInternalSingleUnit(buffer []byte, offset, count uint32) uin v.loadSingleUnit() } - bytesToCopy := d2common.Min(uint32(len(v.CurrentData))-v.CurrentPosition, count) + bytesToCopy := d2math.Min(uint32(len(v.CurrentData))-v.CurrentPosition, count) copy(buffer[offset:offset+bytesToCopy], v.CurrentData[v.CurrentPosition:v.CurrentPosition+bytesToCopy]) @@ -133,7 +133,7 @@ func (v *Stream) readInternal(buffer []byte, offset, count uint32) uint32 { v.bufferData() localPosition := v.CurrentPosition % v.BlockSize - bytesToCopy := d2common.MinInt32(int32(len(v.CurrentData))-int32(localPosition), int32(count)) + bytesToCopy := d2math.MinInt32(int32(len(v.CurrentData))-int32(localPosition), int32(count)) if bytesToCopy <= 0 { return 0 @@ -153,7 +153,7 @@ func (v *Stream) bufferData() { return } - expectedLength := d2common.Min(v.BlockTableEntry.UncompressedFileSize-(requiredBlock*v.BlockSize), v.BlockSize) + expectedLength := d2math.Min(v.BlockTableEntry.UncompressedFileSize-(requiredBlock*v.BlockSize), v.BlockSize) v.CurrentData = v.loadBlock(requiredBlock, expectedLength) v.CurrentBlockIndex = requiredBlock } diff --git a/d2common/d2math/math.go b/d2common/d2math/math.go index 1082445e..650ef850 100644 --- a/d2common/d2math/math.go +++ b/d2common/d2math/math.go @@ -1,5 +1,7 @@ package d2math +import "math" + const ( // Epsilon is used as the threshold for 'almost equal' operations. Epsilon float64 = 0.0001 @@ -88,3 +90,80 @@ func WrapInt(x, max int) int { return wrapped } + +// MinInt returns the minimum of the given values +func MinInt(a, b int) int { + if a < b { + return a + } + + return b +} + +// MaxInt returns the maximum of the given values +func MaxInt(a, b int) int { + if a > b { + return a + } + + return b +} + +// Min returns the lower of two values +func Min(a, b uint32) uint32 { + if a < b { + return a + } + + return b +} + +// Max returns the higher of two values +func Max(a, b uint32) uint32 { + if a > b { + return a + } + + return b +} + +// MaxInt32 returns the higher of two values +func MaxInt32(a, b int32) int32 { + if a > b { + return a + } + + return b +} + +// AbsInt32 returns the absolute of the given int32 +func AbsInt32(a int32) int32 { + if a < 0 { + return -a + } + + return a +} + +// MinInt32 returns the higher of two values +func MinInt32(a, b int32) int32 { + if a < b { + return a + } + + return b +} + +// BytesToInt32 converts 4 bytes to int32 + +// IsoToScreen converts isometric coordinates to screenspace coordinates + +// ScreenToIso converts screenspace coordinates to isometric coordinates + +// GetRadiansBetween returns the radians between two points. 0rad is facing to the right. +func GetRadiansBetween(p1X, p1Y, p2X, p2Y float64) float64 { + deltaY := p2Y - p1Y + deltaX := p2X - p1X + + return math.Atan2(deltaY, deltaX) +} diff --git a/d2common/math.go b/d2common/math.go deleted file mode 100644 index 6d0e2f9f..00000000 --- a/d2common/math.go +++ /dev/null @@ -1,87 +0,0 @@ -package d2common - -import ( - "math" -) - -// MinInt returns the minimum of the given values -func MinInt(a, b int) int { - if a < b { - return a - } - - return b -} - -// MaxInt returns the maximum of the given values -func MaxInt(a, b int) int { - if a > b { - return a - } - - return b -} - -// Min returns the lower of two values -func Min(a, b uint32) uint32 { - if a < b { - return a - } - - return b -} - -// Max returns the higher of two values -func Max(a, b uint32) uint32 { - if a > b { - return a - } - - return b -} - -// MaxInt32 returns the higher of two values -func MaxInt32(a, b int32) int32 { - if a > b { - return a - } - - return b -} - -// AbsInt32 returns the absolute of the given int32 -func AbsInt32(a int32) int32 { - if a < 0 { - return -a - } - - return a -} - -// MinInt32 returns the higher of two values -func MinInt32(a, b int32) int32 { - if a < b { - return a - } - - return b -} - -// BytesToInt32 converts 4 bytes to int32 - -// IsoToScreen converts isometric coordinates to screenspace coordinates - -// ScreenToIso converts screenspace coordinates to isometric coordinates - -// GetRadiansBetween returns the radians between two points. 0rad is facing to the right. -func GetRadiansBetween(p1X, p1Y, p2X, p2Y float64) float64 { - deltaY := p2Y - p1Y - deltaX := p2X - p1X - - return math.Atan2(deltaY, deltaX) -} - -// AlmostEqual returns true if two values are within threshold from each other -func AlmostEqual(a, b, threshold float64) bool { - return math.Abs(a-b) <= threshold -} diff --git a/d2common/text_dictionary.go b/d2common/text_dictionary.go index 9a8fb8fb..072b172c 100644 --- a/d2common/text_dictionary.go +++ b/d2common/text_dictionary.go @@ -14,7 +14,7 @@ type textDictionaryHashEntry struct { NameLength uint16 } -var lookupTable map[string]string +var lookupTable map[string]string //nolint:gochecknoglobals // currently global by design const ( crcByteCount = 2 diff --git a/d2core/d2asset/animation.go b/d2core/d2asset/animation.go index c3359d9f..60f67932 100644 --- a/d2core/d2asset/animation.go +++ b/d2core/d2asset/animation.go @@ -2,6 +2,7 @@ package d2asset import ( "errors" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image" "image/color" "math" @@ -10,7 +11,6 @@ import ( d2iface "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dcc" ) @@ -207,8 +207,8 @@ func (a *animation) GetFrameBounds() (maxWidth, maxHeight int) { direction := a.directions[a.directionIndex] for _, frame := range direction.frames { - maxWidth = d2common.MaxInt(maxWidth, frame.width) - maxHeight = d2common.MaxInt(maxHeight, frame.height) + maxWidth = d2math.MaxInt(maxWidth, frame.width) + maxHeight = d2math.MaxInt(maxHeight, frame.height) } return maxWidth, maxHeight diff --git a/d2core/d2asset/dcc_animation.go b/d2core/d2asset/dcc_animation.go index e59498bb..7e36ab26 100644 --- a/d2core/d2asset/dcc_animation.go +++ b/d2core/d2asset/dcc_animation.go @@ -2,11 +2,11 @@ package d2asset import ( "errors" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "math" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dcc" d2iface "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" ) @@ -90,10 +90,10 @@ func (a *DCCAnimation) decodeDirection(directionIndex int) error { maxX, maxY := math.MinInt32, math.MinInt32 for _, dccFrame := range direction.Frames { - minX = d2common.MinInt(minX, dccFrame.Box.Left) - minY = d2common.MinInt(minY, dccFrame.Box.Top) - maxX = d2common.MaxInt(maxX, dccFrame.Box.Right()) - maxY = d2common.MaxInt(maxY, dccFrame.Box.Bottom()) + minX = d2math.MinInt(minX, dccFrame.Box.Left) + minY = d2math.MinInt(minY, dccFrame.Box.Top) + maxX = d2math.MaxInt(maxX, dccFrame.Box.Right()) + maxY = d2math.MaxInt(maxY, dccFrame.Box.Bottom()) } frameWidth := maxX - minX diff --git a/d2core/d2asset/font.go b/d2core/d2asset/font.go index 734b8670..2b5f1b7d 100644 --- a/d2core/d2asset/font.go +++ b/d2core/d2asset/font.go @@ -3,10 +3,10 @@ package d2asset import ( "encoding/binary" "errors" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image/color" "strings" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" ) @@ -80,17 +80,17 @@ func (f *Font) GetTextMetrics(text string) (width, height int) { for _, c := range text { if c == '\n' { - totalWidth = d2common.MaxInt(totalWidth, lineWidth) + totalWidth = d2math.MaxInt(totalWidth, lineWidth) totalHeight += lineHeight lineWidth = 0 lineHeight = 0 } else if glyph, ok := f.glyphs[c]; ok { lineWidth += glyph.width - lineHeight = d2common.MaxInt(lineHeight, glyph.height) + lineHeight = d2math.MaxInt(lineHeight, glyph.height) } } - totalWidth = d2common.MaxInt(totalWidth, lineWidth) + totalWidth = d2math.MaxInt(totalWidth, lineWidth) totalHeight += lineHeight return totalWidth, totalHeight @@ -122,7 +122,7 @@ func (f *Font) RenderText(text string, target d2interface.Surface) error { return err } - lineHeight = d2common.MaxInt(lineHeight, glyph.height) + lineHeight = d2math.MaxInt(lineHeight, glyph.height) lineLength++ target.PushTranslation(glyph.width, 0) diff --git a/d2core/d2gui/common.go b/d2core/d2gui/common.go index 2ce71171..23865550 100644 --- a/d2core/d2gui/common.go +++ b/d2core/d2gui/common.go @@ -2,11 +2,11 @@ package d2gui import ( "errors" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image/color" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" ) @@ -40,7 +40,7 @@ func renderSegmented(animation d2interface.Animation, segmentsX, segmentsY, fram } width, height := animation.GetCurrentFrameSize() - maxHeight = d2common.MaxInt(maxHeight, height) + maxHeight = d2math.MaxInt(maxHeight, height) currentX += width } diff --git a/d2core/d2gui/layout.go b/d2core/d2gui/layout.go index e2cb2ec4..b743a590 100644 --- a/d2core/d2gui/layout.go +++ b/d2core/d2gui/layout.go @@ -3,6 +3,7 @@ package d2gui import ( "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" ) type layoutEntry struct { @@ -258,14 +259,14 @@ func (l *Layout) getContentSize() (width, height int) { switch l.positionType { case PositionTypeVertical: - width = d2common.MaxInt(width, w) + width = d2math.MaxInt(width, w) height += h case PositionTypeHorizontal: width += w - height = d2common.MaxInt(height, h) + height = d2math.MaxInt(height, h) case PositionTypeAbsolute: - width = d2common.MaxInt(width, x+w) - height = d2common.MaxInt(height, y+h) + width = d2math.MaxInt(width, x+w) + height = d2math.MaxInt(height, y+h) } } @@ -274,7 +275,7 @@ func (l *Layout) getContentSize() (width, height int) { func (l *Layout) getSize() (width, height int) { width, height = l.getContentSize() - return d2common.MaxInt(width, l.width), d2common.MaxInt(height, l.height) + return d2math.MaxInt(width, l.width), d2math.MaxInt(height, l.height) } func (l *Layout) onMouseButtonDown(event d2interface.MouseEvent) bool { @@ -348,8 +349,8 @@ func (l *Layout) AdjustEntryPlacement() { expanderWidth = (width - contentWidth) / expanderCount } - expanderWidth = d2common.MaxInt(0, expanderWidth) - expanderHeight = d2common.MaxInt(0, expanderHeight) + expanderWidth = d2math.MaxInt(0, expanderWidth) + expanderHeight = d2math.MaxInt(0, expanderHeight) } var offsetX, offsetY int diff --git a/d2core/d2map/d2maprenderer/tile_cache.go b/d2core/d2map/d2maprenderer/tile_cache.go index 6c65a8b1..a62bb21a 100644 --- a/d2core/d2map/d2maprenderer/tile_cache.go +++ b/d2core/d2map/d2maprenderer/tile_cache.go @@ -1,9 +1,9 @@ package d2maprenderer import ( + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "log" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2ds1" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dt1" @@ -77,11 +77,11 @@ func (mr *MapRenderer) generateFloorCache(tile *d2ds1.FloorShadowRecord) { tileYMinimum := int32(0) for _, block := range tileData[i].Blocks { - tileYMinimum = d2common.MinInt32(tileYMinimum, int32(block.Y)) + tileYMinimum = d2math.MinInt32(tileYMinimum, int32(block.Y)) } - tileYOffset := d2common.AbsInt32(tileYMinimum) - tileHeight := d2common.AbsInt32(tileData[i].Height) + tileYOffset := d2math.AbsInt32(tileYMinimum) + tileHeight := d2math.AbsInt32(tileData[i].Height) image, _ := mr.renderer.NewSurface(int(tileData[i].Width), int(tileHeight), d2enum.FilterNearest) indexData := make([]byte, tileData[i].Width*tileHeight) d2dt1.DecodeTileGfxData(tileData[i].Blocks, &indexData, tileYOffset, tileData[i].Width) @@ -111,8 +111,8 @@ func (mr *MapRenderer) generateShadowCache(tile *d2ds1.FloorShadowRecord) { tileMaxY := int32(0) for _, block := range tileData.Blocks { - tileMinY = d2common.MinInt32(tileMinY, int32(block.Y)) - tileMaxY = d2common.MaxInt32(tileMaxY, int32(block.Y+32)) + tileMinY = d2math.MinInt32(tileMinY, int32(block.Y)) + tileMaxY = d2math.MaxInt32(tileMaxY, int32(block.Y+32)) } tileYOffset := -tileMinY @@ -160,11 +160,11 @@ func (mr *MapRenderer) generateWallCache(tile *d2ds1.WallRecord) { } for _, block := range target.Blocks { - tileMinY = d2common.MinInt32(tileMinY, int32(block.Y)) - tileMaxY = d2common.MaxInt32(tileMaxY, int32(block.Y+32)) + tileMinY = d2math.MinInt32(tileMinY, int32(block.Y)) + tileMaxY = d2math.MaxInt32(tileMaxY, int32(block.Y+32)) } - realHeight := d2common.MaxInt32(d2common.AbsInt32(tileData.Height), tileMaxY-tileMinY) + realHeight := d2math.MaxInt32(d2math.AbsInt32(tileData.Height), tileMaxY-tileMinY) tileYOffset := -tileMinY if tile.Type == 15 { diff --git a/d2core/d2term/terminal.go b/d2core/d2term/terminal.go index 96a81c1a..0446cd3c 100644 --- a/d2core/d2term/terminal.go +++ b/d2core/d2term/terminal.go @@ -3,6 +3,7 @@ package d2term import ( "errors" "fmt" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image/color" "log" "math" @@ -11,7 +12,6 @@ import ( "strconv" "strings" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" ) @@ -114,9 +114,9 @@ func (t *terminal) OnKeyDown(event d2interface.KeyEvent) bool { case d2enum.KeyEnd: t.outputIndex = 0 case d2enum.KeyHome: - t.outputIndex = d2common.MaxInt(0, len(t.outputHistory)-t.lineCount) + t.outputIndex = d2math.MaxInt(0, len(t.outputHistory)-t.lineCount) case d2enum.KeyPageUp: - maxOutputIndex := d2common.MaxInt(0, len(t.outputHistory)-t.lineCount) + maxOutputIndex := d2math.MaxInt(0, len(t.outputHistory)-t.lineCount) if t.outputIndex += t.lineCount; t.outputIndex >= maxOutputIndex { t.outputIndex = maxOutputIndex } @@ -168,7 +168,7 @@ func (t *terminal) handleControlKey(eventKey d2enum.Key, keyMod d2enum.KeyMod) { switch eventKey { case d2enum.KeyUp: if keyMod == d2enum.KeyModControl { - t.lineCount = d2common.MaxInt(0, t.lineCount-1) + t.lineCount = d2math.MaxInt(0, t.lineCount-1) } else if len(t.commandHistory) > 0 { t.command = t.commandHistory[t.commandIndex] if t.commandIndex == 0 { @@ -179,7 +179,7 @@ func (t *terminal) handleControlKey(eventKey d2enum.Key, keyMod d2enum.KeyMod) { } case d2enum.KeyDown: if keyMod == d2enum.KeyModControl { - t.lineCount = d2common.MinInt(t.lineCount+1, termRowCountMax) + t.lineCount = d2math.MinInt(t.lineCount+1, termRowCountMax) } } } diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index 2fad38f5..4a597558 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -2,13 +2,12 @@ package d2ui import ( "errors" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "image" "image/color" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" - - "github.com/OpenDiablo2/OpenDiablo2/d2common" ) // Sprite is a positioned visual object. @@ -67,7 +66,7 @@ func (s *Sprite) RenderSegmented(target d2interface.Surface, segmentsX, segments } frameWidth, frameHeight := s.GetCurrentFrameSize() - maxFrameHeight = d2common.MaxInt(maxFrameHeight, frameHeight) + maxFrameHeight = d2math.MaxInt(maxFrameHeight, frameHeight) currentX += frameWidth } diff --git a/d2networking/d2client/game_client.go b/d2networking/d2client/game_client.go index 2ad53a39..d7c3652d 100644 --- a/d2networking/d2client/game_client.go +++ b/d2networking/d2client/game_client.go @@ -2,10 +2,10 @@ package d2client import ( "fmt" + "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math" "log" "os" - "github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector" @@ -240,7 +240,7 @@ func (g *GameClient) handleCastSkillPacket(packet d2netpacket.NetPacket) error { return err } - rads := d2common.GetRadiansBetween( + rads := d2math.GetRadiansBetween( player.Position.X(), player.Position.Y(), playerCast.TargetX*numSubtilesPerTile,