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
|
si := 0
|
||||||
ci := 0
|
ci := 0
|
||||||
count := 1
|
count := 1
|
||||||
for _, ee := range config.ErupeConfig.Entrance.Entries {
|
for j, ee := range config.ErupeConfig.Entrance.Entries {
|
||||||
for i, ce := range ee.Channels {
|
for i, ce := range ee.Channels {
|
||||||
sid := (4096 + si*256) + (16 + ci)
|
sid := (4096 + si*256) + (16 + ci)
|
||||||
c := *channelserver.NewServer(&channelserver.Config{
|
c := *channelserver.NewServer(&channelserver.Config{
|
||||||
@@ -202,6 +202,7 @@ func main() {
|
|||||||
c.IP = ee.IP
|
c.IP = ee.IP
|
||||||
}
|
}
|
||||||
c.Port = ce.Port
|
c.Port = ce.Port
|
||||||
|
c.GlobalID = fmt.Sprintf("%02d%02d", j+1, i+1)
|
||||||
err = c.Start()
|
err = c.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
preventClose(fmt.Sprintf("Failed to start channel server: %s", err.Error()))
|
preventClose(fmt.Sprintf("Failed to start channel server: %s", err.Error()))
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package mhfpacket
|
package mhfpacket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
|
||||||
"erupe-ce/network"
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
"erupe-ce/network"
|
||||||
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgSysLockGlobalSema represents the MSG_SYS_LOCK_GLOBAL_SEMA
|
// MsgSysLockGlobalSema represents the MSG_SYS_LOCK_GLOBAL_SEMA
|
||||||
type MsgSysLockGlobalSema struct {
|
type MsgSysLockGlobalSema struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
UserIDLength uint16
|
UserIDLength uint16
|
||||||
ServerChannelIDLength uint16
|
ServerChannelIDLength uint16
|
||||||
UserIDString string
|
UserIDString string
|
||||||
ServerChannelIDString string
|
ServerChannelIDString string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package channelserver
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
ps "erupe-ce/common/pascalstring"
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -314,25 +315,30 @@ func handleMsgSysEcho(s *Session, p mhfpacket.MHFPacket) {}
|
|||||||
|
|
||||||
func handleMsgSysLockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgSysLockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgSysLockGlobalSema)
|
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()
|
bf := byteframe.NewByteFrame()
|
||||||
// Unk
|
if len(sgid) > 0 && sgid != s.server.GlobalID {
|
||||||
// 0x00 when no ID sent
|
bf.WriteUint8(0)
|
||||||
// 0x02 when ID sent
|
bf.WriteUint8(0)
|
||||||
if pkt.ServerChannelIDLength == 1 {
|
ps.Uint16(bf, sgid, false)
|
||||||
bf.WriteBytes([]byte{0x00, 0x00, 0x00, 0x01, 0x00})
|
|
||||||
} else {
|
} else {
|
||||||
bf.WriteUint8(0x02)
|
bf.WriteUint8(2)
|
||||||
bf.WriteUint8(0x00) // Unk
|
bf.WriteUint8(0)
|
||||||
bf.WriteUint16(uint16(pkt.ServerChannelIDLength))
|
ps.Uint16(bf, pkt.ServerChannelIDString, false)
|
||||||
bf.WriteBytes([]byte(pkt.ServerChannelIDString))
|
|
||||||
}
|
}
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgSysUnlockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgSysUnlockGlobalSema(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgSysUnlockGlobalSema)
|
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) {}
|
func handleMsgSysUpdateRight(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type Server struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
Channels []*Server
|
Channels []*Server
|
||||||
ID uint16
|
ID uint16
|
||||||
|
GlobalID string
|
||||||
IP string
|
IP string
|
||||||
Port uint16
|
Port uint16
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
|
|||||||
Reference in New Issue
Block a user