mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
fix invalid semaphore id for raviente support
This commit is contained in:
@@ -11,7 +11,7 @@ func handleMsgSysOperateRegister(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf := byteframe.NewByteFrameFromBytes(pkt.RawDataPayload)
|
bf := byteframe.NewByteFrameFromBytes(pkt.RawDataPayload)
|
||||||
s.server.raviente.Lock()
|
s.server.raviente.Lock()
|
||||||
switch pkt.SemaphoreID {
|
switch pkt.SemaphoreID {
|
||||||
case 3:
|
case 4:
|
||||||
resp := byteframe.NewByteFrame()
|
resp := byteframe.NewByteFrame()
|
||||||
size := 6
|
size := 6
|
||||||
for i := 0; i < len(bf.Data())-1; i += size {
|
for i := 0; i < len(bf.Data())-1; i += size {
|
||||||
@@ -49,7 +49,7 @@ func handleMsgSysOperateRegister(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
resp.WriteUint8(0)
|
resp.WriteUint8(0)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
case 4:
|
case 5:
|
||||||
resp := byteframe.NewByteFrame()
|
resp := byteframe.NewByteFrame()
|
||||||
size := 6
|
size := 6
|
||||||
for i := 0; i < len(bf.Data())-1; i += size {
|
for i := 0; i < len(bf.Data())-1; i += size {
|
||||||
@@ -74,7 +74,7 @@ func handleMsgSysOperateRegister(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
resp.WriteUint8(0)
|
resp.WriteUint8(0)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
case 5:
|
case 6:
|
||||||
resp := byteframe.NewByteFrame()
|
resp := byteframe.NewByteFrame()
|
||||||
size := 6
|
size := 6
|
||||||
for i := 0; i < len(bf.Data())-1; i += size {
|
for i := 0; i < len(bf.Data())-1; i += size {
|
||||||
@@ -242,15 +242,15 @@ func handleMsgSysLoadRegister(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
func (s *Session) notifyRavi() {
|
func (s *Session) notifyRavi() {
|
||||||
var temp mhfpacket.MHFPacket
|
var temp mhfpacket.MHFPacket
|
||||||
raviNotif := byteframe.NewByteFrame()
|
raviNotif := byteframe.NewByteFrame()
|
||||||
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 3}
|
|
||||||
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
|
||||||
temp.Build(raviNotif, s.clientContext)
|
|
||||||
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 4}
|
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 4}
|
||||||
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
||||||
temp.Build(raviNotif, s.clientContext)
|
temp.Build(raviNotif, s.clientContext)
|
||||||
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 5}
|
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 5}
|
||||||
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
||||||
temp.Build(raviNotif, s.clientContext)
|
temp.Build(raviNotif, s.clientContext)
|
||||||
|
temp = &mhfpacket.MsgSysNotifyRegister{RegisterID: 6}
|
||||||
|
raviNotif.WriteUint16(uint16(temp.Opcode()))
|
||||||
|
temp.Build(raviNotif, s.clientContext)
|
||||||
raviNotif.WriteUint16(0x0010) // End it.
|
raviNotif.WriteUint16(0x0010) // End it.
|
||||||
sema := getRaviSemaphore(s)
|
sema := getRaviSemaphore(s)
|
||||||
if sema != "" {
|
if sema != "" {
|
||||||
@@ -262,7 +262,7 @@ func (s *Session) notifyRavi() {
|
|||||||
|
|
||||||
func getRaviSemaphore(s *Session) string {
|
func getRaviSemaphore(s *Session) string {
|
||||||
for _, semaphore := range s.server.semaphore {
|
for _, semaphore := range s.server.semaphore {
|
||||||
if strings.HasPrefix(semaphore.id_semaphore, "hs_l0u3B5") && strings.HasSuffix(semaphore.id_semaphore, "3") {
|
if strings.HasPrefix(semaphore.id_semaphore, "hs_l0u3B5") && strings.HasSuffix(semaphore.id_semaphore, "4") {
|
||||||
return semaphore.id_semaphore
|
return semaphore.id_semaphore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,10 @@ func destructEmptySemaphores(s *Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func releaseRaviSemaphore(s *Session, sema *Semaphore) {
|
func releaseRaviSemaphore(s *Session, sema *Semaphore) {
|
||||||
if !strings.HasSuffix(sema.id_semaphore, "5") {
|
delete(sema.reservedClientSlots, s.charID)
|
||||||
delete(sema.reservedClientSlots, s.charID)
|
delete(sema.clients, s)
|
||||||
delete(sema.clients, s)
|
if strings.HasSuffix(sema.id_semaphore, "2") && len(sema.clients) == 0 {
|
||||||
}
|
s.logger.Debug("Main raviente semaphore is empty, resetting")
|
||||||
if len(sema.reservedClientSlots) == 0 && len(sema.clients) == 0 {
|
|
||||||
s.logger.Debug("Raviente semaphore is empty, resetting")
|
|
||||||
resetRavi(s)
|
resetRavi(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +89,7 @@ func handleMsgSysCreateAcquireSemaphore(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
suffix, _ := strconv.ParseUint(pkt.SemaphoreID[len(pkt.SemaphoreID)-1:], 10, 32)
|
suffix, _ := strconv.ParseUint(pkt.SemaphoreID[len(pkt.SemaphoreID)-1:], 10, 32)
|
||||||
s.server.semaphore[SemaphoreID] = &Semaphore{
|
s.server.semaphore[SemaphoreID] = &Semaphore{
|
||||||
id_semaphore: pkt.SemaphoreID,
|
id_semaphore: pkt.SemaphoreID,
|
||||||
id: uint32(suffix),
|
id: uint32(suffix + 1),
|
||||||
clients: make(map[*Session]uint32),
|
clients: make(map[*Session]uint32),
|
||||||
reservedClientSlots: make(map[uint32]interface{}),
|
reservedClientSlots: make(map[uint32]interface{}),
|
||||||
maxPlayers: 32,
|
maxPlayers: 32,
|
||||||
|
|||||||
Reference in New Issue
Block a user