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
s.server.BroadcastMHF(&mhfpacket.MsgSysInsertUser{
CharID: s.charID,
}, s)
var temp mhfpacket.MHFPacket
loginNotif := byteframe.NewByteFrame()
s.server.Lock()
for _, session := range s.server.sessions {
if s == session {
if s == session || !session.binariesDone {
continue
}
temp = &mhfpacket.MsgSysInsertUser{
@@ -181,7 +177,6 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.QueueSend(loginNotif.Data())
}
}
doStageTransfer(s, pkt.AckHandle, pkt.StageID)
}

View File

@@ -4,8 +4,8 @@ import (
"encoding/base64"
"fmt"
"erupe-ce/network/mhfpacket"
"erupe-ce/common/byteframe"
"erupe-ce/network/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.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{
CharID: s.charID,
BinaryType: pkt.BinaryType,

View File

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