mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-04 17:27:16 -05:00
removed all 'gocritic' lint errors (#835)
This commit is contained in:
parent
6b5c2a1fc5
commit
1ce2af19bf
@ -92,7 +92,7 @@ const (
|
||||
|
||||
// --- Help Overlay ---
|
||||
|
||||
//HelpBorder = "/data/global/ui/MENU/helpborder.DC6"
|
||||
// HelpBorder = "/data/global/ui/MENU/helpborder.DC6"
|
||||
HelpBorder = "/data/global/ui/MENU/800helpborder.DC6"
|
||||
HelpYellowBullet = "/data/global/ui/MENU/helpyellowbullet.DC6"
|
||||
HelpWhiteBullet = "/data/global/ui/MENU/helpwhitebullet.DC6"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Package d2wilderness provides an enumeration of wilderness types
|
||||
package d2wilderness
|
||||
|
||||
// nolint: golint // these probably don't require individual explanations.
|
||||
// nolint:golint // these don't require individual explanations.
|
||||
const (
|
||||
TreeBorderSouth int = iota + 4
|
||||
TreeBorderWest
|
||||
|
@ -526,7 +526,6 @@ type callout struct {
|
||||
func (h *Overlay) createBullet(c callout) {
|
||||
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
||||
newLabel.SetText(c.LabelText)
|
||||
//ww, hh = newLabel.GetSize()
|
||||
newLabel.SetPosition(c.LabelX, c.LabelY)
|
||||
h.text = append(h.text, newLabel)
|
||||
|
||||
@ -547,7 +546,6 @@ func (h *Overlay) createBullet(c callout) {
|
||||
func (h *Overlay) createLabel(c callout) {
|
||||
newLabel := h.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteSky)
|
||||
newLabel.SetText(c.LabelText)
|
||||
//ww, hh = newLabel.GetSize()
|
||||
newLabel.SetPosition(c.LabelX, c.LabelY)
|
||||
h.text = append(h.text, newLabel)
|
||||
newLabel.Alignment = d2gui.HorizontalAlignCenter
|
||||
|
@ -29,7 +29,7 @@ func (s *SkillListRow) GetRectangle() d2geom.Rectangle {
|
||||
}
|
||||
|
||||
// IsInRect returns true when the list has any skills and coordinates are in the rectangle of the list.
|
||||
func (s *SkillListRow) IsInRect(X int, Y int) bool {
|
||||
func (s *SkillListRow) IsInRect(x, y int) bool {
|
||||
// if there are no skills, row won't be rendered and it shouldn't be considered visible
|
||||
return len(s.Skills) > 0 && s.Rectangle.IsInRect(X, Y)
|
||||
return len(s.Skills) > 0 && s.Rectangle.IsInRect(x, y)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type SkillSelectMenu struct {
|
||||
// NewSkillSelectMenu creates a skill select menu.
|
||||
func NewSkillSelectMenu(asset *d2asset.AssetManager, ui *d2ui.UIManager, hero *d2mapentity.Player) *SkillSelectMenu {
|
||||
skillSelectMenu := &SkillSelectMenu{
|
||||
LeftPanel: NewHeroSkillsPanel(asset, ui, hero, true),
|
||||
LeftPanel: NewHeroSkillsPanel(asset, ui, hero, true),
|
||||
RightPanel: NewHeroSkillsPanel(asset, ui, hero, false),
|
||||
}
|
||||
|
||||
@ -24,12 +24,12 @@ func NewSkillSelectMenu(asset *d2asset.AssetManager, ui *d2ui.UIManager, hero *d
|
||||
}
|
||||
|
||||
// HandleClick will propagate the click to the panels.
|
||||
func (sm *SkillSelectMenu) HandleClick(X int, Y int) bool {
|
||||
if sm.LeftPanel.HandleClick(X, Y) {
|
||||
func (sm *SkillSelectMenu) HandleClick(x, y int) bool {
|
||||
if sm.LeftPanel.HandleClick(x, y) {
|
||||
return true
|
||||
}
|
||||
|
||||
if sm.RightPanel.HandleClick(X, Y) {
|
||||
if sm.RightPanel.HandleClick(x, y) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -37,12 +37,11 @@ func (sm *SkillSelectMenu) HandleClick(X int, Y int) bool {
|
||||
}
|
||||
|
||||
// HandleMouseMove will propagate the mouse move event to the panels.
|
||||
func (sm *SkillSelectMenu) HandleMouseMove(X int, Y int) {
|
||||
func (sm *SkillSelectMenu) HandleMouseMove(x, y int) {
|
||||
if sm.LeftPanel.IsOpen() {
|
||||
sm.LeftPanel.HandleMouseMove(X, Y)
|
||||
|
||||
sm.LeftPanel.HandleMouseMove(x, y)
|
||||
} else if sm.RightPanel.IsOpen() {
|
||||
sm.RightPanel.HandleMouseMove(X, Y)
|
||||
sm.RightPanel.HandleMouseMove(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +64,8 @@ func (sm *SkillSelectMenu) IsOpen() bool {
|
||||
}
|
||||
|
||||
// IsInRect returns whether the coordinates are in one of the panels(left or right)
|
||||
func (sm *SkillSelectMenu) IsInRect(X int, Y int) bool {
|
||||
return sm.LeftPanel.IsInRect(X, Y) || sm.RightPanel.IsInRect(X, Y)
|
||||
func (sm *SkillSelectMenu) IsInRect(x, y int) bool {
|
||||
return sm.LeftPanel.IsInRect(x, y) || sm.RightPanel.IsInRect(x, y)
|
||||
}
|
||||
|
||||
// ClosePanels will close both panels
|
||||
|
@ -196,8 +196,8 @@ func makeTabString(keys ...interface{}) string {
|
||||
return fmt.Sprintf(format, translations...)
|
||||
}
|
||||
|
||||
func makeCloseButtonPos(close1 int , close2 int, close3 int) [3]int {
|
||||
return [3]int{ close1, close2, close3 }
|
||||
func makeCloseButtonPos(close1, close2, close3 int) [3]int {
|
||||
return [3]int{close1, close2, close3}
|
||||
}
|
||||
|
||||
func (s *skillTree) getTab(class d2enum.Hero) (heroTabData, bool) {
|
||||
@ -315,7 +315,7 @@ func (s *skillTree) setHeroTypeResourcePath() {
|
||||
s.tab[secondTab].buttonText = entry.str2
|
||||
s.tab[thirdTab].buttonText = entry.str3
|
||||
|
||||
for i:= 0; i < 3; i++ {
|
||||
for i := 0; i < 3; i++ {
|
||||
s.tab[i].closeButtonPosX = entry.closeButtonPos[i]
|
||||
}
|
||||
}
|
||||
@ -363,10 +363,9 @@ func (s *skillTree) IsOpen() bool {
|
||||
|
||||
// Set the callback run on closing the skilltree
|
||||
func (s *skillTree) SetOnCloseCb(cb func()) {
|
||||
s.onCloseCb = cb
|
||||
s.onCloseCb = cb
|
||||
}
|
||||
|
||||
|
||||
func (s *skillTree) setTab(tab int) {
|
||||
s.selectedTab = tab
|
||||
s.closeButton.SetPosition(s.tab[tab].closeButtonPosX, skillCloseButtonY)
|
||||
|
@ -314,7 +314,7 @@ func (g *GameClient) handleCastSkillPacket(packet d2netpacket.NetPacket) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GameClient) createSummonedNpcEntity(skillRecord *d2records.SkillRecord, X, Y int) (*d2mapentity.NPC, error) {
|
||||
func (g *GameClient) createSummonedNpcEntity(skillRecord *d2records.SkillRecord, x, y int) (*d2mapentity.NPC, error) {
|
||||
monsterStatsRecord := g.asset.Records.Monster.Stats[skillRecord.Summon]
|
||||
|
||||
if monsterStatsRecord == nil {
|
||||
@ -322,7 +322,7 @@ func (g *GameClient) createSummonedNpcEntity(skillRecord *d2records.SkillRecord,
|
||||
}
|
||||
|
||||
// https://github.com/OpenDiablo2/OpenDiablo2/issues/803
|
||||
summonedNpcEntity, err := g.MapEngine.NewNPC(X, Y, monsterStatsRecord, 0)
|
||||
summonedNpcEntity, err := g.MapEngine.NewNPC(x, y, monsterStatsRecord, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -330,7 +330,7 @@ func (g *GameClient) createSummonedNpcEntity(skillRecord *d2records.SkillRecord,
|
||||
return summonedNpcEntity, nil
|
||||
}
|
||||
|
||||
func (g *GameClient) createMissileEntities(skillRecord *d2records.SkillRecord, player *d2mapentity.Player, castX float64, castY float64) ([]*d2mapentity.Missile, error) {
|
||||
func (g *GameClient) createMissileEntities(skillRecord *d2records.SkillRecord, player *d2mapentity.Player, castX, castY float64) ([]*d2mapentity.Missile, error) {
|
||||
missileRecords := []*d2records.MissileRecord{
|
||||
g.asset.Records.GetMissileByName(skillRecord.Cltmissile),
|
||||
g.asset.Records.GetMissileByName(skillRecord.Cltmissilea),
|
||||
@ -385,7 +385,7 @@ func (g *GameClient) createMissileEntity(missileRecord *d2records.MissileRecord,
|
||||
return missileEntity, nil
|
||||
}
|
||||
|
||||
func (g *GameClient) playCastOverlay(overlayRecord *d2records.OverlayRecord, x int, y int) error {
|
||||
func (g *GameClient) playCastOverlay(overlayRecord *d2records.OverlayRecord, x, y int) error {
|
||||
if overlayRecord == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import (
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2mpq"
|
||||
)
|
||||
|
||||
const (
|
||||
directoryPermissions = 0750
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
outPath string
|
||||
@ -40,7 +44,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, mpqFile := filepath.Split(strings.Replace(filename, "\\", "/", -1))
|
||||
_, mpqFile := filepath.Split(strings.ReplaceAll(filename, "\\", "/"))
|
||||
|
||||
for _, filename := range list {
|
||||
extractFile(mpq, mpqFile, filename, outPath)
|
||||
@ -51,16 +55,17 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func extractFile(mpq d2interface.Archive, mpqFile string, filename string, outPath string) {
|
||||
func extractFile(mpq d2interface.Archive, mpqFile, filename, outPath string) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("recovered from panic in file: %s, %v", filename, r)
|
||||
}
|
||||
}()
|
||||
dir, file := filepath.Split(strings.Replace(filename, "\\", "/", -1))
|
||||
|
||||
dir, file := filepath.Split(strings.ReplaceAll(filename, "\\", "/"))
|
||||
dir = mpqFile + "/" + dir
|
||||
|
||||
err := os.MkdirAll(outPath+dir, 0755)
|
||||
err := os.MkdirAll(outPath+dir, directoryPermissions)
|
||||
if err != nil {
|
||||
log.Printf("failed to create directory: %s, %v", outPath+dir, err)
|
||||
return
|
||||
@ -72,7 +77,9 @@ func extractFile(mpq d2interface.Archive, mpqFile string, filename string, outPa
|
||||
return
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
_ = f.Close()
|
||||
}()
|
||||
|
||||
buf, err := mpq.ReadFile(filename)
|
||||
if err != nil {
|
||||
@ -80,5 +87,5 @@ func extractFile(mpq d2interface.Archive, mpqFile string, filename string, outPa
|
||||
return
|
||||
}
|
||||
|
||||
f.Write(buf)
|
||||
_, _ = f.Write(buf)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user