diff --git a/common/stringstack/stringstack.go b/common/stringstack/stringstack.go index 5f936e6a2..2e45fd7d1 100644 --- a/common/stringstack/stringstack.go +++ b/common/stringstack/stringstack.go @@ -6,13 +6,12 @@ import ( // StringStack is a basic LIFO "stack" for storing strings. type StringStack struct { - Locked bool - stack []string + stack []string } // New creates a new instance of StringStack func New() *StringStack { - return &StringStack{Locked: false} + return &StringStack{} } // Set sets up a new StringStack @@ -20,20 +19,6 @@ func (s *StringStack) Set(v string) { s.stack = []string{v} } -// Lock freezes the StringStack -func (s *StringStack) Lock() { - if !s.Locked { - s.Locked = true - } -} - -// Unlock unfreezes the StringStack -func (s *StringStack) Unlock() { - if s.Locked { - s.Locked = false - } -} - // Push pushes a string onto the stack. func (s *StringStack) Push(v string) { s.stack = append(s.stack, v) diff --git a/server/channelserver/handlers_stage.go b/server/channelserver/handlers_stage.go index 7a12d453e..3092db3fd 100644 --- a/server/channelserver/handlers_stage.go +++ b/server/channelserver/handlers_stage.go @@ -152,14 +152,11 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgSysEnterStage) // Push our current stage ID to the movement stack before entering another one. - if s.stage.id == "" { - s.stageMoveStack.Set(pkt.StageID) - } else { + if s.stage != nil { s.stage.Lock() s.stage.reservedClientSlots[s.charID] = false s.stage.Unlock() s.stageMoveStack.Push(s.stage.id) - s.stageMoveStack.Lock() } if s.reservationStage != nil { @@ -173,7 +170,6 @@ func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgSysBackStage) // Transfer back to the saved stage ID before the previous move or enter. - s.stageMoveStack.Unlock() backStage, err := s.stageMoveStack.Pop() if err != nil { panic(err) @@ -193,10 +189,8 @@ func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) { func handleMsgSysMoveStage(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgSysMoveStage) - // Set a new move stack from the given stage ID if unlocked - if !s.stageMoveStack.Locked { - s.stageMoveStack.Set(pkt.StageID) - } + // Set a new move stack from the given stage ID + s.stageMoveStack.Set(pkt.StageID) doStageTransfer(s, pkt.AckHandle, pkt.StageID) }