change user insertion method

This commit is contained in:
wish
2022-07-22 14:34:44 +10:00
parent 628975db68
commit 1db9080202
3 changed files with 20 additions and 8 deletions

View File

@@ -150,15 +150,11 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
} }
if pkt.StageID == "sl1Ns200p0a0u0" { // First entry if pkt.StageID == "sl1Ns200p0a0u0" { // First entry
s.server.BroadcastMHF(&mhfpacket.MsgSysInsertUser{
CharID: s.charID,
}, s)
var temp mhfpacket.MHFPacket var temp mhfpacket.MHFPacket
loginNotif := byteframe.NewByteFrame() loginNotif := byteframe.NewByteFrame()
s.server.Lock() s.server.Lock()
for _, session := range s.server.sessions { for _, session := range s.server.sessions {
if s == session { if s == session || !session.binariesDone {
continue continue
} }
temp = &mhfpacket.MsgSysInsertUser{ temp = &mhfpacket.MsgSysInsertUser{
@@ -181,7 +177,6 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.QueueSend(loginNotif.Data()) s.QueueSend(loginNotif.Data())
} }
} }
doStageTransfer(s, pkt.AckHandle, pkt.StageID) doStageTransfer(s, pkt.AckHandle, pkt.StageID)
} }

View File

@@ -4,8 +4,8 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"erupe-ce/network/mhfpacket"
"erupe-ce/common/byteframe" "erupe-ce/common/byteframe"
"erupe-ce/network/mhfpacket"
) )
func handleMsgSysInsertUser(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysInsertUser(s *Session, p mhfpacket.MHFPacket) {}
@@ -18,6 +18,21 @@ func handleMsgSysSetUserBinary(s *Session, p mhfpacket.MHFPacket) {
s.server.userBinaryParts[userBinaryPartID{charID: s.charID, index: pkt.BinaryType}] = pkt.RawDataPayload s.server.userBinaryParts[userBinaryPartID{charID: s.charID, index: pkt.BinaryType}] = pkt.RawDataPayload
s.server.userBinaryPartsLock.Unlock() s.server.userBinaryPartsLock.Unlock()
// Insert user once all binary parts exist
if !s.binariesDone {
for i := 0; i < 3; i++ {
_, exists := s.server.userBinaryParts[userBinaryPartID{charID: s.charID, index: uint8(i + 1)}]
if !exists {
return
}
}
s.binariesDone = true
s.server.BroadcastMHF(&mhfpacket.MsgSysInsertUser{
CharID: s.charID,
}, s)
return
}
msg := &mhfpacket.MsgSysNotifyUserBinary{ msg := &mhfpacket.MsgSysNotifyUserBinary{
CharID: s.charID, CharID: s.charID,
BinaryType: pkt.BinaryType, BinaryType: pkt.BinaryType,

View File

@@ -31,6 +31,7 @@ type Session struct {
stage *Stage stage *Stage
reservationStage *Stage // Required for the stateful MsgSysUnreserveStage packet. reservationStage *Stage // Required for the stateful MsgSysUnreserveStage packet.
stagePass string // Temporary storage stagePass string // Temporary storage
binariesDone bool
charID uint32 charID uint32
logKey []byte logKey []byte
sessionStart int64 sessionStart int64
@@ -66,6 +67,7 @@ func NewSession(server *Server, conn net.Conn) *Session {
Encoding: japanese.ShiftJIS, Encoding: japanese.ShiftJIS,
}, },
}, },
binariesDone: false,
sessionStart: Time_Current_Adjusted().Unix(), sessionStart: Time_Current_Adjusted().Unix(),
stageMoveStack: stringstack.New(), stageMoveStack: stringstack.New(),
} }