mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
change getRaviSemaphore scope & handle RegisterEvent
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
// MsgMhfReleaseEvent represents the MSG_MHF_RELEASE_EVENT
|
// MsgMhfReleaseEvent represents the MSG_MHF_RELEASE_EVENT
|
||||||
type MsgMhfReleaseEvent struct {
|
type MsgMhfReleaseEvent struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk0 uint32
|
RaviID uint32
|
||||||
Unk1 uint32
|
Unk1 uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ func (m *MsgMhfReleaseEvent) Opcode() network.PacketID {
|
|||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfReleaseEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfReleaseEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint32()
|
m.RaviID = bf.ReadUint32()
|
||||||
m.Unk1 = bf.ReadUint32()
|
m.Unk1 = bf.ReadUint32()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ func parseChatCommand(s *Session, command string) {
|
|||||||
case commands["Raviente"].Prefix:
|
case commands["Raviente"].Prefix:
|
||||||
if commands["Raviente"].Enabled {
|
if commands["Raviente"].Enabled {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
if getRaviSemaphore(s.server) != nil {
|
if s.server.getRaviSemaphore() != nil {
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "start":
|
case "start":
|
||||||
if s.server.raviente.register[1] == 0 {
|
if s.server.raviente.register[1] == 0 {
|
||||||
@@ -420,7 +420,7 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
case BroadcastTypeServer:
|
case BroadcastTypeServer:
|
||||||
if pkt.MessageType == 1 {
|
if pkt.MessageType == 1 {
|
||||||
if getRaviSemaphore(s.server) != nil {
|
if s.server.getRaviSemaphore() != nil {
|
||||||
s.server.BroadcastMHF(resp, s)
|
s.server.BroadcastMHF(resp, s)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import (
|
|||||||
func handleMsgMhfRegisterEvent(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfRegisterEvent(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfRegisterEvent)
|
pkt := p.(*mhfpacket.MsgMhfRegisterEvent)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
if pkt.Unk3 > 0 {
|
// Some kind of check if there's already a session
|
||||||
|
if pkt.Unk3 > 0 && s.server.getRaviSemaphore() == nil {
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -110,7 +111,7 @@ func handleMsgSysLoadRegister(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) notifyRavi() {
|
func (s *Session) notifyRavi() {
|
||||||
sema := getRaviSemaphore(s.server)
|
sema := s.server.getRaviSemaphore()
|
||||||
if sema == nil {
|
if sema == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -139,7 +140,7 @@ func (s *Session) notifyRavi() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRaviSemaphore(s *Server) *Semaphore {
|
func (s *Server) getRaviSemaphore() *Semaphore {
|
||||||
for _, semaphore := range s.semaphore {
|
for _, semaphore := range s.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, "3") {
|
||||||
return semaphore
|
return semaphore
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ func NewRaviente() *Raviente {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetRaviMultiplier() float64 {
|
func (s *Server) GetRaviMultiplier() float64 {
|
||||||
raviSema := getRaviSemaphore(s)
|
raviSema := s.getRaviSemaphore()
|
||||||
if raviSema != nil {
|
if raviSema != nil {
|
||||||
var minPlayers int
|
var minPlayers int
|
||||||
if s.raviente.register[9] > 8 {
|
if s.raviente.register[9] > 8 {
|
||||||
|
|||||||
Reference in New Issue
Block a user