diff --git a/d2app/app.go b/d2app/app.go index b5f243a4..1b43054b 100644 --- a/d2app/app.go +++ b/d2app/app.go @@ -260,8 +260,6 @@ func (a *App) LoadConfig() (*d2config.Configuration, error) { return nil, err } - //config.SetPath(filepath.Join(configAsset.Source().Path(), configAsset.Path())) - a.Infof("loaded configuration file from %s", config.Path()) return config, nil @@ -625,6 +623,11 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie a.Error(err.Error()) } + if gameClient == nil { + a.Error("could not create client") + return + } + if err = gameClient.Open(host, filePath); err != nil { errorMessage := fmt.Sprintf("can not connect to the host: %s", host) a.Error(errorMessage) diff --git a/d2common/d2loader/loader.go b/d2common/d2loader/loader.go index 64c6bd1b..1c478fd6 100644 --- a/d2common/d2loader/loader.go +++ b/d2common/d2loader/loader.go @@ -127,6 +127,7 @@ func (l *Loader) AddSource(path string, sourceType types.SourceType) error { return nil } +// Exists checks if the given path exists in at least one source func (l *Loader) Exists(subPath string) bool { subPath = filepath.Clean(subPath) diff --git a/d2common/d2loader/loader_test.go b/d2common/d2loader/loader_test.go index f04c3ec4..942c1511 100644 --- a/d2common/d2loader/loader_test.go +++ b/d2common/d2loader/loader_test.go @@ -62,7 +62,6 @@ func TestLoader_AddSource(t *testing.T) { if errE == nil { t.Error("expecting error on bad file path") } - } // nolint:gocyclo // this is just a test, not a big deal if we ignore linter here diff --git a/d2core/d2asset/asset_manager.go b/d2core/d2asset/asset_manager.go index 4fe91e16..d6f0b3dd 100644 --- a/d2core/d2asset/asset_manager.go +++ b/d2core/d2asset/asset_manager.go @@ -485,6 +485,7 @@ func (am *AssetManager) commandAssetClear([]string) error { return nil } +// LoadDT1 loads and returns the given path as a DT1 func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) { if dt1Value, found := am.dt1s.Retrieve(dt1Path); found { return dt1Value.(*d2dt1.DT1), nil @@ -492,7 +493,7 @@ func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) { fileData, err := am.LoadFile("/data/global/tiles/" + dt1Path) if err != nil { - return nil, fmt.Errorf("Could not load /data/global/tiles/%s", dt1Path) + return nil, fmt.Errorf("could not load /data/global/tiles/%s", dt1Path) } dt1, err := d2dt1.LoadDT1(fileData) @@ -507,6 +508,7 @@ func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) { return dt1, nil } +// LoadDS1 loads and returns the given path as a DS1 func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error) { if ds1Value, found := am.dt1s.Retrieve(ds1Path); found { return ds1Value.(*d2ds1.DS1), nil @@ -527,9 +529,9 @@ func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error) { } return ds1, nil - } +// LoadCOF loads and returns the given path as a COF func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error) { if cofValue, found := am.cofs.Retrieve(cofPath); found { return cofValue.(*d2cof.COF), nil @@ -552,6 +554,7 @@ func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error) { return cof, nil } +// LoadDCC loads and returns the given path as a DCC func (am *AssetManager) LoadDCC(dccPath string) (*d2dcc.DCC, error) { if dccValue, found := am.dccs.Retrieve(dccPath); found { return dccValue.(*d2dcc.DCC), nil diff --git a/d2core/d2map/d2maprenderer/renderer.go b/d2core/d2map/d2maprenderer/renderer.go index d693e578..0691d582 100644 --- a/d2core/d2map/d2maprenderer/renderer.go +++ b/d2core/d2map/d2maprenderer/renderer.go @@ -88,11 +88,18 @@ func CreateMapRenderer(asset *d2asset.AssetManager, renderer d2interface.Rendere result.Camera.position = &startPosition result.viewport.SetCamera(&result.Camera) - if err := term.Bind("mapdebugvis", "set map debug visualization level", []string{"level"}, result.commandMapDebugVis); err != nil { + var name, desc, level string + + name, desc = "mapdebugvis", "set map debug visualization level" + level = "level" + + if err := term.Bind(name, desc, []string{level}, result.commandMapDebugVis); err != nil { result.Errorf("could not bind the mapdebugvis action, err: %v", err) } - if err := term.Bind("entitydebugvis", "set entity debug visualization level", []string{"level"}, result.commandEntityDebugVis); err != nil { + name, desc = "entitydebugvis", "set entity debug visualization level" + + if err := term.Bind(name, desc, []string{level}, result.commandEntityDebugVis); err != nil { result.Errorf("could not bind the entitydebugvis action, err: %v", err) } diff --git a/d2core/d2ui/button.go b/d2core/d2ui/button.go index 71b0cefd..0ce1fd03 100644 --- a/d2core/d2ui/button.go +++ b/d2core/d2ui/button.go @@ -863,6 +863,7 @@ type buttonStateDescriptor struct { func (v *Button) createTooltip() { var t *Tooltip + switch v.buttonLayout.Tooltip { case buttonTooltipNone: return diff --git a/d2thread/mainthread.go b/d2thread/mainthread.go index 9d9e479b..0d7ab9f1 100644 --- a/d2thread/mainthread.go +++ b/d2thread/mainthread.go @@ -10,7 +10,7 @@ import ( // // The default value is 16 and should be good for 99% usecases. var ( - callQueue chan func() //nolint:gochecknoglobals + callQueue chan func() //nolint:gochecknoglobals // necessary evil for now ) func checkRun() {