Skip to content

Commit

Permalink
Merge pull request wowsims#3779 from wowsims/update_go_1_21
Browse files Browse the repository at this point in the history
updated to use go 1.21
  • Loading branch information
lologarithm authored Oct 2, 2023
2 parents a515700 + 07e7131 commit f25a2fa
Show file tree
Hide file tree
Showing 91 changed files with 219 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.21.x

- name: Install Protoc
uses: arduino/setup-protoc@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.21.x

- name: Install Protoc
uses: arduino/setup-protoc@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.21.x

- name: Install Protoc
uses: arduino/setup-protoc@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.21.x

- name: Install Protoc
uses: arduino/setup-protoc@v1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM golang:1.18
FROM golang:1.21

WORKDIR /wotlk
COPY . .
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ Then unzip the downloaded file, then open the unzipped file to open the sim in y
Alternatively, you can choose from a specific relase on the [Releases](https://github.com/wowsims/wotlk/releases) page and click the suitable link under "Assets"
# Local Dev Installation

This project has dependencies on Go >=1.18, protobuf-compiler and the corresponding Go plugins, and node >= 14.0.
This project has dependencies on Go >=1.21, protobuf-compiler and the corresponding Go plugins, and node >= 14.0.

## Ubuntu
Do not use apt to install any dependencies, the versions they install are all too old.
Script below will curl latest versions and install them.
```sh
# Standard Go installation script
curl -O https://dl.google.com/go/go1.18.3.linux-amd64.tar.gz
curl -O https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.bashrc
echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> $HOME/.bashrc
Expand Down
4 changes: 2 additions & 2 deletions cmd/wowsimcli/cmd/decode_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"fmt"
"strings"

goproto "github.com/golang/protobuf/proto"
"github.com/spf13/cobra"
"github.com/wowsims/wotlk/sim/core/proto"
"google.golang.org/protobuf/encoding/protojson"
goproto "google.golang.org/protobuf/proto"
)

var decodeLinkCmd = &cobra.Command{
Expand Down Expand Up @@ -62,6 +62,6 @@ func decodeLink(link string) error {
return fmt.Errorf("cannot unmarshal raw proto: %w", err)
}

fmt.Println(protojson.Format(goproto.MessageV2(settings)))
fmt.Println(protojson.Format(goproto.Message(settings)))
return nil
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
module github.com/wowsims/wotlk

go 1.18
go 1.21

require (
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.1
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/satori/go.uuid v1.2.0
github.com/spf13/cobra v1.7.0
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f
google.golang.org/protobuf v1.30.0
google.golang.org/protobuf v1.31.0
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.1.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
18 changes: 4 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand All @@ -30,10 +23,7 @@ golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion sim/common/tbc/melee_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
})
}

numHits := core.MinInt32(5, character.Env.GetNumTargets())
numHits := min(5, character.Env.GetNumTargets())
debuffAuras := make([]*core.Aura, len(character.Env.Encounter.TargetUnits))
for i, target := range character.Env.Encounter.TargetUnits {
debuffAuras[i] = makeDebuffAura(target)
Expand Down
4 changes: 2 additions & 2 deletions sim/common/wotlk/other_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func init() {

character.AddDynamicDamageTakenModifier(func(sim *core.Simulation, spell *core.Spell, result *core.SpellResult) {
if procAura.IsActive() {
result.Damage = core.MaxFloat(0, result.Damage-140)
result.Damage = max(0, result.Damage-140)
}
})

Expand Down Expand Up @@ -52,7 +52,7 @@ func init() {

character.AddDynamicDamageTakenModifier(func(sim *core.Simulation, spell *core.Spell, result *core.SpellResult) {
if procAura.IsActive() {
result.Damage = core.MaxFloat(0, result.Damage-205)
result.Damage = max(0, result.Damage-205)
}
})

Expand Down
8 changes: 4 additions & 4 deletions sim/core/apl_values_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ func (value *APLValueMax) Type() proto.APLValueType {
func (value *APLValueMax) GetInt(sim *Simulation) int32 {
result := value.vals[0].GetInt(sim)
for i := 1; i < len(value.vals); i++ {
result = MaxInt32(result, value.vals[i].GetInt(sim))
result = max(result, value.vals[i].GetInt(sim))
}
return result
}
func (value *APLValueMax) GetFloat(sim *Simulation) float64 {
result := value.vals[0].GetFloat(sim)
for i := 1; i < len(value.vals); i++ {
result = MaxFloat(result, value.vals[i].GetFloat(sim))
result = max(result, value.vals[i].GetFloat(sim))
}
return result
}
Expand Down Expand Up @@ -537,14 +537,14 @@ func (value *APLValueMin) Type() proto.APLValueType {
func (value *APLValueMin) GetInt(sim *Simulation) int32 {
result := value.vals[0].GetInt(sim)
for i := 1; i < len(value.vals); i++ {
result = MinInt32(result, value.vals[i].GetInt(sim))
result = min(result, value.vals[i].GetInt(sim))
}
return result
}
func (value *APLValueMin) GetFloat(sim *Simulation) float64 {
result := value.vals[0].GetFloat(sim)
for i := 1; i < len(value.vals); i++ {
result = MinFloat(result, value.vals[i].GetFloat(sim))
result = min(result, value.vals[i].GetFloat(sim))
}
return result
}
Expand Down
6 changes: 3 additions & 3 deletions sim/core/attack.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package core

import (
"golang.org/x/exp/slices"
"slices"
"time"

"github.com/wowsims/wotlk/sim/core/proto"
Expand Down Expand Up @@ -294,13 +294,13 @@ func (unit *Unit) EnableAutoAttacks(agent Agent, options AutoAttackOptions) {

if unit.Type == EnemyUnit {
unit.AutoAttacks.MHConfig.ApplyEffects = func(sim *Simulation, target *Unit, spell *Spell) {
ap := MaxFloat(0, spell.Unit.stats[stats.AttackPower])
ap := max(0, spell.Unit.stats[stats.AttackPower])
baseDamage := spell.Unit.AutoAttacks.MH.EnemyWeaponDamage(sim, ap, spell.Unit.PseudoStats.DamageSpread)

spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeEnemyMeleeWhite)
}
unit.AutoAttacks.OHConfig.ApplyEffects = func(sim *Simulation, target *Unit, spell *Spell) {
ap := MaxFloat(0, spell.Unit.stats[stats.AttackPower])
ap := max(0, spell.Unit.stats[stats.AttackPower])
baseDamage := spell.Unit.AutoAttacks.MH.EnemyWeaponDamage(sim, ap, spell.Unit.PseudoStats.DamageSpread) * 0.5

spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeEnemyMeleeWhite)
Expand Down
5 changes: 3 additions & 2 deletions sim/core/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package core

import (
"fmt"
"golang.org/x/exp/constraints"
"math"
"strconv"
"time"

"golang.org/x/exp/constraints"

"github.com/wowsims/wotlk/sim/core/proto"
"github.com/wowsims/wotlk/sim/core/stats"
)
Expand Down Expand Up @@ -183,7 +184,7 @@ func (aura *Aura) SetStacks(sim *Simulation, newStacks int32) {
panic("MaxStacks required to set Aura stacks: " + aura.Label)
}
oldStacks := aura.stacks
newStacks = MinInt32(newStacks, aura.MaxStacks)
newStacks = min(newStacks, aura.MaxStacks)

if oldStacks == newStacks {
return
Expand Down
17 changes: 12 additions & 5 deletions sim/core/buffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package core

import (
"math"
"slices"
"strconv"
"time"

"golang.org/x/exp/slices"
googleProto "google.golang.org/protobuf/proto"

"github.com/wowsims/wotlk/sim/core/proto"
Expand Down Expand Up @@ -162,7 +162,7 @@ func applyBuffEffects(agent Agent, raidBuffs *proto.RaidBuffs, partyBuffs *proto
kingsStrStamAmount = 1.1
} else if raidBuffs.DrumsOfForgottenKings {
kingsAgiIntSpiAmount = 1.08
kingsStrStamAmount = MaxFloat(kingsStrStamAmount, 1.08)
kingsStrStamAmount = max(kingsStrStamAmount, 1.08)
}
if kingsStrStamAmount > 0 {
character.MultiplyStat(stats.Strength, kingsStrStamAmount)
Expand Down Expand Up @@ -379,7 +379,7 @@ func ApplyInspiration(character *Character, uptime float64) {
if uptime <= 0 {
return
}
uptime = MinFloat(1, uptime)
uptime = min(1, uptime)

inspirationAura := InspirationAura(&character.Unit, 3)

Expand Down Expand Up @@ -1307,8 +1307,15 @@ func (raid *Raid) ProcReplenishment(sim *Simulation, src ReplenishmentSource) {
}

eligible := append(raid.curReplenishmentUnits[src], raid.leftoverReplenishmentUnits...)
slices.SortFunc(eligible, func(v1, v2 *Unit) bool {
return v1.CurrentManaPercent() < v2.CurrentManaPercent()
slices.SortFunc(eligible, func(v1, v2 *Unit) int {
v1Mana := v1.CurrentManaPercent()
v2Mana := v2.CurrentManaPercent()
if v1Mana > v2Mana {
return 1
} else if v2Mana > v1Mana {
return -1
}
return 0
})
raid.curReplenishmentUnits[src] = eligible[:10]
raid.leftoverReplenishmentUnits = eligible[10:]
Expand Down
2 changes: 1 addition & 1 deletion sim/core/bulksim.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync/atomic"
"time"

goproto "github.com/golang/protobuf/proto"
goproto "google.golang.org/protobuf/proto"

"github.com/wowsims/wotlk/sim/core/proto"
)
Expand Down
4 changes: 2 additions & 2 deletions sim/core/bulksim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

goproto "github.com/golang/protobuf/proto"
"github.com/google/go-cmp/cmp"
"github.com/wowsims/wotlk/sim/core/proto"
"google.golang.org/protobuf/encoding/protojson"
)

const (
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestBulkSim(t *testing.T) {

want := &proto.BulkSimResult{}
if diff := cmp.Diff(want, got, cmp.Comparer(func(a, b *proto.BulkSimResult) bool {
return goproto.MarshalTextString(a) == goproto.MarshalTextString(b)
return protojson.Format(a) == protojson.Format(b)
})); diff != "" {
t.Fatalf("BulkSim() returned diff (-want +got):\n%s", diff)
}
Expand Down
8 changes: 4 additions & 4 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
if spell.CurCast.CastTime > 0 {
if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) {
spell.Unit.Log(sim, "Casting %s (Cost = %0.03f, Cast Time = %s, Effective Time = %s)",
spell.ActionID, MaxFloat(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime())
spell.ActionID, max(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime())
}

spell.Unit.Hardcast = Hardcast{
Expand Down Expand Up @@ -177,7 +177,7 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {

if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) {
spell.Unit.Log(sim, "Casting %s (Cost = %0.03f, Cast Time = %s, Effective Time = %s)",
spell.ActionID, MaxFloat(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime())
spell.ActionID, max(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime())
spell.Unit.Log(sim, "Completed cast %s", spell.ActionID)
}

Expand Down Expand Up @@ -260,6 +260,6 @@ func (spell *Spell) makeCastFuncAutosOrProcs() CastSuccessFunc {

func (spell *Spell) ApplyCostModifiers(cost float64) float64 {
cost -= spell.Unit.PseudoStats.CostReduction
cost = MaxFloat(0, cost*spell.Unit.PseudoStats.CostMultiplier)
return MaxFloat(0, cost*spell.CostMultiplier)
cost = max(0, cost*spell.Unit.PseudoStats.CostMultiplier)
return max(0, cost*spell.CostMultiplier)
}
3 changes: 1 addition & 2 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package core

import (
"fmt"
"slices"
"strconv"
"strings"
"time"

"golang.org/x/exp/slices"

"github.com/wowsims/wotlk/sim/core/proto"
"github.com/wowsims/wotlk/sim/core/stats"
"google.golang.org/protobuf/encoding/protowire"
Expand Down
2 changes: 1 addition & 1 deletion sim/core/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (dot *Dot) MaxTicksRemaining() int32 {
func (dot *Dot) NumTicksRemaining(sim *Simulation) int {
maxTicksRemaining := dot.MaxTicksRemaining()
finalTickAt := dot.lastTickTime + dot.tickPeriod*time.Duration(maxTicksRemaining)
return MaxInt(0, int((finalTickAt-sim.CurrentTime)/dot.tickPeriod)+1)
return max(0, int((finalTickAt-sim.CurrentTime)/dot.tickPeriod)+1)
}

// Roll over = gets carried over with everlasting refresh and doesn't get applied if triggered when the spell is already up.
Expand Down
Loading

0 comments on commit f25a2fa

Please sign in to comment.