Skip to content

Commit

Permalink
dragonfly/server: Fix newly introduced nil pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Sep 1, 2024
1 parent 900b9f4 commit 23a9096
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ func New(name string, skin skin.Skin, pos mgl64.Vec3) *Player {
cooldowns: make(map[string]time.Time),
mc: &entity.MovementComputer{Gravity: 0.08, Drag: 0.02, DragBeforeGravity: true},
}
var scoreTag string
var gm world.GameMode = world.GameModeSurvival
p.gameMode.Store(&gm)
p.Handle(nil)
p.skin.Store(&skin)
p.speed.Store(math.Float64bits(0.1))
p.nameTag.Store(&name)
p.scoreTag.Store(&scoreTag)
p.airSupplyTicks.Store(300)
p.maxAirSupplyTicks.Store(300)
p.enchantSeed.Store(rand.Int63())
Expand Down Expand Up @@ -2144,7 +2146,8 @@ func (p *Player) CollectExperience(value int) bool {
if p.Dead() || !p.GameMode().AllowsInteraction() {
return false
}
if time.Since(*p.lastXPPickup.Load()) < time.Millisecond*100 {
last := p.lastXPPickup.Load()
if last == nil || time.Since(*last) < time.Millisecond*100 {
return false
}
value = p.mendItems(value)
Expand Down
5 changes: 5 additions & 0 deletions server/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ func New(conn Conn, maxChunkRadius int, log Logger, joinMessage, quitMessage str
inv := inventory.New(1, nil)
s.openedWindow.Store(&inv)

var scoreboardName string
var scoreboardLines []string
s.currentScoreboard.Store(&scoreboardName)
s.currentLines.Store(&scoreboardLines)

s.registerHandlers()
return s
}
Expand Down

0 comments on commit 23a9096

Please sign in to comment.