Skip to content

Commit

Permalink
fix stringstack & MoveStage error
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Jan 10, 2024
1 parent c8e2138 commit ba7321b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
17 changes: 1 addition & 16 deletions common/stringstack/stringstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ 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
Expand All @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions server/channelserver/handlers_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.stage.reservedClientSlots[s.charID] = false
s.stage.Unlock()
s.stageMoveStack.Push(s.stage.id)
s.stageMoveStack.Lock()
}

if s.reservationStage != nil {
Expand All @@ -171,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 backStage == "" || err != nil {
backStage = "sl1Ns200p0a0u0"
Expand All @@ -190,12 +188,6 @@ 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 !s.stageMoveStack.Locked {
s.stageMoveStack.Set(pkt.StageID)
}

doStageTransfer(s, pkt.AckHandle, pkt.StageID)
}

Expand Down

0 comments on commit ba7321b

Please sign in to comment.