mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
emulate retail semaphore logic
This commit is contained in:
@@ -48,7 +48,9 @@ type Session struct {
|
||||
kqf []byte
|
||||
kqfOverride bool
|
||||
|
||||
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
||||
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
||||
semaphoreMode bool
|
||||
semaphoreID []uint16
|
||||
|
||||
// A stack containing the stage movement history (push on enter/move, pop on back)
|
||||
stageMoveStack *stringstack.StringStack
|
||||
@@ -79,6 +81,7 @@ func NewSession(server *Server, conn net.Conn) *Session {
|
||||
sessionStart: TimeAdjusted().Unix(),
|
||||
stageMoveStack: stringstack.New(),
|
||||
ackStart: make(map[uint32]time.Time),
|
||||
semaphoreID: make([]uint16, 2),
|
||||
}
|
||||
s.SetObjectID()
|
||||
return s
|
||||
@@ -310,6 +313,14 @@ func (s *Session) NextObjectID() uint32 {
|
||||
return bf.ReadUint32()
|
||||
}
|
||||
|
||||
func (s *Session) GetSemaphoreID() uint32 {
|
||||
if s.semaphoreMode {
|
||||
return 0x000E0000 + uint32(s.semaphoreID[1])
|
||||
} else {
|
||||
return 0x000F0000 + uint32(s.semaphoreID[0])
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) isOp() bool {
|
||||
var op bool
|
||||
err := s.server.db.QueryRow(`SELECT op FROM users u WHERE u.id=(SELECT c.user_id FROM characters c WHERE c.id=$1)`, s.charID).Scan(&op)
|
||||
|
||||
Reference in New Issue
Block a user