mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 15:04:38 +01:00
fix stringstack & MoveStage error
This commit is contained in:
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
// StringStack is a basic LIFO "stack" for storing strings.
|
// StringStack is a basic LIFO "stack" for storing strings.
|
||||||
type StringStack struct {
|
type StringStack struct {
|
||||||
Locked bool
|
stack []string
|
||||||
stack []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new instance of StringStack
|
// New creates a new instance of StringStack
|
||||||
@@ -20,20 +19,6 @@ func (s *StringStack) Set(v string) {
|
|||||||
s.stack = []string{v}
|
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.
|
// Push pushes a string onto the stack.
|
||||||
func (s *StringStack) Push(v string) {
|
func (s *StringStack) Push(v string) {
|
||||||
s.stack = append(s.stack, v)
|
s.stack = append(s.stack, v)
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.stage.reservedClientSlots[s.charID] = false
|
s.stage.reservedClientSlots[s.charID] = false
|
||||||
s.stage.Unlock()
|
s.stage.Unlock()
|
||||||
s.stageMoveStack.Push(s.stage.id)
|
s.stageMoveStack.Push(s.stage.id)
|
||||||
s.stageMoveStack.Lock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.reservationStage != nil {
|
if s.reservationStage != nil {
|
||||||
@@ -171,7 +170,6 @@ func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
pkt := p.(*mhfpacket.MsgSysBackStage)
|
pkt := p.(*mhfpacket.MsgSysBackStage)
|
||||||
|
|
||||||
// Transfer back to the saved stage ID before the previous move or enter.
|
// Transfer back to the saved stage ID before the previous move or enter.
|
||||||
s.stageMoveStack.Unlock()
|
|
||||||
backStage, err := s.stageMoveStack.Pop()
|
backStage, err := s.stageMoveStack.Pop()
|
||||||
if backStage == "" || err != nil {
|
if backStage == "" || err != nil {
|
||||||
backStage = "sl1Ns200p0a0u0"
|
backStage = "sl1Ns200p0a0u0"
|
||||||
@@ -190,12 +188,6 @@ func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func handleMsgSysMoveStage(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgSysMoveStage(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgSysMoveStage)
|
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)
|
doStageTransfer(s, pkt.AckHandle, pkt.StageID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user