1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-12 18:50:42 +00:00

all: use goimports to format code and fix two minor typos in comments (#326)

Typos located using misspell: https://github.com/client9/misspell

Formatting done using goimports: https://godoc.org/golang.org/x/tools/cmd/goimports
This commit is contained in:
Robin Eklind 2020-04-11 20:56:47 +02:00 committed by GitHub
parent 019bb920c9
commit ff4f0b0bfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 83 additions and 76 deletions

View File

@ -1,9 +1,9 @@
package d2common package d2common
// a calcstring is a type of string often used in datafiles to specify // a calcstring is a type of string often used in datafiles to specify
// a value that is calculated dynamically based on the stats of the relevant // a value that is calculated dynamically based on the stats of the relevant
// source, for instance a missile might have a movement speed of lvl*2 // source, for instance a missile might have a movement speed of lvl*2
type CalcString string type CalcString string
// todo: the logic for parsing these should exist here // todo: the logic for parsing these should exist here

View File

@ -263,7 +263,7 @@ func adjustTree(newNode *linkedNode) {
continue continue
} }
// The following code basicly swaps insertpoint with current // The following code basically swaps insertpoint with current
// remove insert point // remove insert point
if insertpoint.Prev != nil { if insertpoint.Prev != nil {

View File

@ -1,6 +1,5 @@
package d2datadict package d2datadict
var objectLookups = []ObjectLookupRecord{ var objectLookups = []ObjectLookupRecord{
{Act: 1, Type: ObjectTypeCharacter, Id: 0, Description: "gheed-ACT 1 TABLE", ObjectsTxtId: -1, MonstatsTxtId: -1, Direction: -1, Base: "/Data/Global/Monsters", Token: "GH", Mode: "NU", Class: "HTH", TR: "LIT", Index: -1}, {Act: 1, Type: ObjectTypeCharacter, Id: 0, Description: "gheed-ACT 1 TABLE", ObjectsTxtId: -1, MonstatsTxtId: -1, Direction: -1, Base: "/Data/Global/Monsters", Token: "GH", Mode: "NU", Class: "HTH", TR: "LIT", Index: -1},
{Act: 1, Type: ObjectTypeCharacter, Id: 1, Description: "cain1-ACT 1 TABLE", ObjectsTxtId: -1, MonstatsTxtId: -1, Direction: -1, Base: "/Data/Global/Monsters", Token: "DC", Mode: "NU", Class: "HTH", TR: "LIT", Index: -1}, {Act: 1, Type: ObjectTypeCharacter, Id: 1, Description: "cain1-ACT 1 TABLE", ObjectsTxtId: -1, MonstatsTxtId: -1, Direction: -1, Base: "/Data/Global/Monsters", Token: "DC", Mode: "NU", Class: "HTH", TR: "LIT", Index: -1},

View File

@ -1,8 +1,9 @@
package d2datadict package d2datadict
import ( import (
testify "github.com/stretchr/testify/assert"
"testing" "testing"
testify "github.com/stretchr/testify/assert"
) )
// Verify the lookup returns the right object after indexing. // Verify the lookup returns the right object after indexing.

View File

@ -1,17 +1,17 @@
package d2dt1 package d2dt1
type SubTileFlags struct { type SubTileFlags struct {
BlockWalk bool BlockWalk bool
BlockLOS bool BlockLOS bool
BlockJump bool BlockJump bool
BlockPlayerWalk bool BlockPlayerWalk bool
Unknown1 bool Unknown1 bool
BlockLight bool BlockLight bool
Unknown2 bool Unknown2 bool
Unknown3 bool Unknown3 bool
} }
func (s* SubTileFlags) DebugString() string { func (s *SubTileFlags) DebugString() string {
result := "" result := ""
if s.BlockWalk { if s.BlockWalk {
result += "BlockWalk " result += "BlockWalk "
@ -42,13 +42,13 @@ func (s* SubTileFlags) DebugString() string {
func NewSubTileFlags(data byte) SubTileFlags { func NewSubTileFlags(data byte) SubTileFlags {
return SubTileFlags{ return SubTileFlags{
BlockWalk: data & 1 == 1, BlockWalk: data&1 == 1,
BlockLOS: data & 2 == 2, BlockLOS: data&2 == 2,
BlockJump: data & 4 == 4, BlockJump: data&4 == 4,
BlockPlayerWalk: data & 8 == 8, BlockPlayerWalk: data&8 == 8,
Unknown1: data & 16 == 16, Unknown1: data&16 == 16,
BlockLight: data & 32 == 32, BlockLight: data&32 == 32,
Unknown2: data & 64 == 64, Unknown2: data&64 == 64,
Unknown3: data & 128 == 128, Unknown3: data&128 == 128,
} }
} }

View File

@ -1,8 +1,9 @@
package d2dt1 package d2dt1
import ( import (
testify "github.com/stretchr/testify/assert"
"testing" "testing"
testify "github.com/stretchr/testify/assert"
) )
func TestNewSubTile(t *testing.T) { func TestNewSubTile(t *testing.T) {

View File

@ -7,45 +7,45 @@ import (
) )
type PL2File struct { type PL2File struct {
BasePalette PL2Palette BasePalette PL2Palette
LightLevelVariations [32]PL2PaletteTransform LightLevelVariations [32]PL2PaletteTransform
InvColorVariations [16]PL2PaletteTransform InvColorVariations [16]PL2PaletteTransform
SelectedUintShift PL2PaletteTransform SelectedUintShift PL2PaletteTransform
AlphaBlend [3][256]PL2PaletteTransform AlphaBlend [3][256]PL2PaletteTransform
AdditiveBlend [256]PL2PaletteTransform AdditiveBlend [256]PL2PaletteTransform
MultiplicativeBlend [256]PL2PaletteTransform MultiplicativeBlend [256]PL2PaletteTransform
HueVariations [111]PL2PaletteTransform HueVariations [111]PL2PaletteTransform
RedTones PL2PaletteTransform RedTones PL2PaletteTransform
GreenTones PL2PaletteTransform GreenTones PL2PaletteTransform
BlueTones PL2PaletteTransform BlueTones PL2PaletteTransform
UnknownVariations [14]PL2PaletteTransform UnknownVariations [14]PL2PaletteTransform
MaxComponentBlend [256]PL2PaletteTransform MaxComponentBlend [256]PL2PaletteTransform
DarkendColorShift PL2PaletteTransform DarkendColorShift PL2PaletteTransform
TextColors [13]PL2Color24Bits TextColors [13]PL2Color24Bits
TextColorShifts [13]PL2PaletteTransform TextColorShifts [13]PL2PaletteTransform
} }
type PL2Color struct { type PL2Color struct {
R uint8 R uint8
G uint8 G uint8
B uint8 B uint8
_ uint8 _ uint8
} }
type PL2Color24Bits struct { type PL2Color24Bits struct {
R uint8 R uint8
G uint8 G uint8
B uint8 B uint8
} }
type PL2Palette struct { type PL2Palette struct {
Colors [256]PL2Color Colors [256]PL2Color
} }
type PL2PaletteTransform struct { type PL2PaletteTransform struct {
Indices [256]uint8 Indices [256]uint8
} }
// uses restruct to read the binary dc6 data into structs // uses restruct to read the binary dc6 data into structs
@ -56,7 +56,7 @@ func LoadPL2(data []byte) (*PL2File, error) {
err := restruct.Unpack(data, binary.LittleEndian, &result) err := restruct.Unpack(data, binary.LittleEndian, &result)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result, nil return result, nil

View File

@ -105,7 +105,7 @@ func SplitIntoLinesWithMaxWidth(fullSentence string, maxChars int) []string {
totalLength := 0 totalLength := 0
words := strings.Split(fullSentence, " ") words := strings.Split(fullSentence, " ")
if len(words[0]) > maxChars { if len(words[0]) > maxChars {
// mostly happend within CJK characters (no whitespace) // mostly happened within CJK characters (no whitespace)
return splitCjkIntoChunks(fullSentence, maxChars) return splitCjkIntoChunks(fullSentence, maxChars)
} }
for _, word := range words { for _, word := range words {

View File

@ -14,12 +14,12 @@ var (
) )
type assetManager struct { type assetManager struct {
archiveManager *archiveManager archiveManager *archiveManager
fileManager *fileManager fileManager *fileManager
paletteManager *paletteManager paletteManager *paletteManager
paletteTransformManager *paletteTransformManager paletteTransformManager *paletteTransformManager
animationManager *animationManager animationManager *animationManager
fontManager *fontManager fontManager *fontManager
} }
func loadDC6(dc6Path string) (*d2dc6.DC6File, error) { func loadDC6(dc6Path string) (*d2dc6.DC6File, error) {

View File

@ -7,9 +7,9 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dat" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dat"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2mpq" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2mpq"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2pl2"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2config" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2config"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2term" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2term"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2pl2"
) )
var singleton *assetManager var singleton *assetManager
@ -18,13 +18,13 @@ func Initialize() error {
verifyNotInit() verifyNotInit()
var ( var (
config = d2config.Get() config = d2config.Get()
archiveManager = createArchiveManager(config) archiveManager = createArchiveManager(config)
fileManager = createFileManager(config, archiveManager) fileManager = createFileManager(config, archiveManager)
paletteManager = createPaletteManager() paletteManager = createPaletteManager()
paletteTransformManager = createPaletteTransformManager() paletteTransformManager = createPaletteTransformManager()
animationManager = createAnimationManager() animationManager = createAnimationManager()
fontManager = createFontManager() fontManager = createFontManager()
) )
singleton = &assetManager{ singleton = &assetManager{

View File

@ -22,7 +22,7 @@ func (pm *paletteTransformManager) loadPaletteTransform(path string) (*d2pl2.PL2
return pl2.(*d2pl2.PL2File), nil return pl2.(*d2pl2.PL2File), nil
} }
data, err := LoadFile(path); data, err := LoadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,10 +1,11 @@
package d2map package d2map
import ( import (
"github.com/beefsack/go-astar"
"math" "math"
"strings" "strings"
"github.com/beefsack/go-astar"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2audio"

View File

@ -10,9 +10,9 @@ import (
type Hero struct { type Hero struct {
*AnimatedComposite *AnimatedComposite
Equipment d2inventory.CharacterEquipment Equipment d2inventory.CharacterEquipment
mode d2enum.AnimationMode mode d2enum.AnimationMode
direction int direction int
} }
func CreateHero(x, y int, direction int, heroType d2enum.Hero, equipment d2inventory.CharacterEquipment) *Hero { func CreateHero(x, y int, direction int, heroType d2enum.Hero, equipment d2inventory.CharacterEquipment) *Hero {

View File

@ -2,10 +2,11 @@ package d2map
import ( import (
"fmt" "fmt"
"math"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
"math"
) )
type Missile struct { type Missile struct {

View File

@ -1,11 +1,12 @@
package d2map package d2map
import ( import (
"math/rand"
"github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"math/rand"
) )
type NPC struct { type NPC struct {

View File

@ -1,9 +1,10 @@
package d2map package d2map
import ( import (
"github.com/OpenDiablo2/OpenDiablo2/d2common"
"math" "math"
"sort" "sort"
"github.com/OpenDiablo2/OpenDiablo2/d2common"
) )
type MapEntitiesSearcher interface { type MapEntitiesSearcher interface {

View File

@ -1,10 +1,11 @@
package d2map package d2map
import ( import (
"testing"
"github.com/OpenDiablo2/OpenDiablo2/d2common" "github.com/OpenDiablo2/OpenDiablo2/d2common"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2render" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2render"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing"
) )
type mockEntity struct { type mockEntity struct {

View File

@ -1,6 +1,6 @@
package d2render package d2render
// Filter represents the type of texture filter to be used when an image is maginified or minified. // Filter represents the type of texture filter to be used when an image is magnified or minified.
type Filter int type Filter int
const ( const (

View File

@ -42,7 +42,7 @@ const (
// ButtonLayout defines the type of buttons // ButtonLayout defines the type of buttons
type ButtonLayout struct { type ButtonLayout struct {
XSegments int //1 XSegments int // 1
YSegments int // 1 YSegments int // 1
ResourceName string // Font Name ResourceName string // Font Name
PaletteName string // PaletteType PaletteName string // PaletteType

View File

@ -1,8 +1,9 @@
package d2player package d2player
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
type TestItem struct { type TestItem struct {