1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-18 02:16:23 -05:00

Code Cleanup for #790 (#870)

* Return errors for #790

* Fixing lint issues

* Returning nil instead of empty struct pointer
This commit is contained in:
Stephen Horan 2020-10-30 20:19:06 -04:00 committed by GitHub
parent 4506380dbb
commit fb8e25ebdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -612,9 +612,11 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie
// ToCharacterSelect forces the game to transition to the Character Select (load character) screen // ToCharacterSelect forces the game to transition to the Character Select (load character) screen
func (a *App) ToCharacterSelect(connType d2clientconnectiontype.ClientConnectionType, connHost string) { func (a *App) ToCharacterSelect(connType d2clientconnectiontype.ClientConnectionType, connHost string) {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/790 characterSelect, err := d2gamescreen.CreateCharacterSelect(a, a.asset, a.renderer, a.inputManager,
characterSelect := d2gamescreen.CreateCharacterSelect(a, a.asset, a.renderer, a.inputManager,
a.audio, a.ui, connType, connHost) a.audio, a.ui, connType, connHost)
if err != nil {
fmt.Printf("unable to create character select screen: %s", err)
}
a.screen.SetNextScreen(characterSelect) a.screen.SetNextScreen(characterSelect)
} }

View File

@ -67,10 +67,16 @@ func CreateCharacterSelect(
ui *d2ui.UIManager, ui *d2ui.UIManager,
connectionType d2clientconnectiontype.ClientConnectionType, connectionType d2clientconnectiontype.ClientConnectionType,
connectionHost string, connectionHost string,
) *CharacterSelect { ) (*CharacterSelect, error) {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/790 playerStateFactory, err := d2hero.NewHeroStateFactory(asset)
playerStateFactory, _ := d2hero.NewHeroStateFactory(asset) if err != nil {
entityFactory, _ := d2mapentity.NewMapEntityFactory(asset) return nil, err
}
entityFactory, err := d2mapentity.NewMapEntityFactory(asset)
if err != nil {
return nil, err
}
return &CharacterSelect{ return &CharacterSelect{
selectedCharacter: -1, selectedCharacter: -1,
@ -84,7 +90,7 @@ func CreateCharacterSelect(
navigator: navigator, navigator: navigator,
uiManager: ui, uiManager: ui,
HeroStateFactory: playerStateFactory, HeroStateFactory: playerStateFactory,
} }, nil
} }
const ( const (