mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
implement guild semaphore locking
This commit is contained in:
3
main.go
3
main.go
@@ -186,7 +186,7 @@ func main() {
|
||||
si := 0
|
||||
ci := 0
|
||||
count := 1
|
||||
for _, ee := range config.ErupeConfig.Entrance.Entries {
|
||||
for j, ee := range config.ErupeConfig.Entrance.Entries {
|
||||
for i, ce := range ee.Channels {
|
||||
sid := (4096 + si*256) + (16 + ci)
|
||||
c := *channelserver.NewServer(&channelserver.Config{
|
||||
@@ -202,6 +202,7 @@ func main() {
|
||||
c.IP = ee.IP
|
||||
}
|
||||
c.Port = ce.Port
|
||||
c.GlobalID = fmt.Sprintf("%02d%02d", j+1, i+1)
|
||||
err = c.Start()
|
||||
if err != nil {
|
||||
preventClose(fmt.Sprintf("Failed to start channel server: %s", err.Error()))
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"errors"
|
||||
|
||||
"erupe-ce/network/clientctx"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
)
|
||||
|
||||
// MsgSysLockGlobalSema represents the MSG_SYS_LOCK_GLOBAL_SEMA
|
||||
type MsgSysLockGlobalSema struct {
|
||||
AckHandle uint32
|
||||
UserIDLength uint16
|
||||
ServerChannelIDLength uint16
|
||||
UserIDLength uint16
|
||||
ServerChannelIDLength uint16
|
||||
UserIDString string
|
||||
ServerChannelIDString string
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package channelserver
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
ps "erupe-ce/common/pascalstring"
|
||||
"erupe-ce/common/stringsupport"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -314,25 +315,30 @@ func handleMsgSysEcho(s *Session, p mhfpacket.MHFPacket) {}
|
||||
|
||||
func handleMsgSysLockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgSysLockGlobalSema)
|
||||
|
||||
var sgid string
|
||||
for _, channel := range s.server.Channels {
|
||||
for id := range channel.stages {
|
||||
if strings.HasSuffix(id, pkt.UserIDString) {
|
||||
sgid = channel.GlobalID
|
||||
}
|
||||
}
|
||||
}
|
||||
bf := byteframe.NewByteFrame()
|
||||
// Unk
|
||||
// 0x00 when no ID sent
|
||||
// 0x02 when ID sent
|
||||
if pkt.ServerChannelIDLength == 1 {
|
||||
bf.WriteBytes([]byte{0x00, 0x00, 0x00, 0x01, 0x00})
|
||||
if len(sgid) > 0 && sgid != s.server.GlobalID {
|
||||
bf.WriteUint8(0)
|
||||
bf.WriteUint8(0)
|
||||
ps.Uint16(bf, sgid, false)
|
||||
} else {
|
||||
bf.WriteUint8(0x02)
|
||||
bf.WriteUint8(0x00) // Unk
|
||||
bf.WriteUint16(uint16(pkt.ServerChannelIDLength))
|
||||
bf.WriteBytes([]byte(pkt.ServerChannelIDString))
|
||||
bf.WriteUint8(2)
|
||||
bf.WriteUint8(0)
|
||||
ps.Uint16(bf, pkt.ServerChannelIDString, false)
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
func handleMsgSysUnlockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgSysUnlockGlobalSema)
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 8))
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
|
||||
func handleMsgSysUpdateRight(s *Session, p mhfpacket.MHFPacket) {}
|
||||
|
||||
@@ -38,6 +38,7 @@ type Server struct {
|
||||
sync.Mutex
|
||||
Channels []*Server
|
||||
ID uint16
|
||||
GlobalID string
|
||||
IP string
|
||||
Port uint16
|
||||
logger *zap.Logger
|
||||
|
||||
Reference in New Issue
Block a user