Combine MsgSysEnterStage with MsgSysMoveStage

This commit is contained in:
Andrew Gutekanst
2020-02-07 18:16:33 -05:00
parent 315449aa33
commit 99c965e3b6
3 changed files with 31 additions and 11 deletions

View File

@@ -6,7 +6,12 @@ import (
) )
// MsgSysMoveStage represents the MSG_SYS_MOVE_STAGE // MsgSysMoveStage represents the MSG_SYS_MOVE_STAGE
type MsgSysMoveStage struct{} type MsgSysMoveStage struct {
AckHandle uint32
UnkBool uint8
StageIDLength uint8
StageID string
}
// Opcode returns the ID associated with this packet type. // Opcode returns the ID associated with this packet type.
func (m *MsgSysMoveStage) Opcode() network.PacketID { func (m *MsgSysMoveStage) Opcode() network.PacketID {
@@ -15,10 +20,14 @@ func (m *MsgSysMoveStage) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysMoveStage) Parse(bf *byteframe.ByteFrame) error { func (m *MsgSysMoveStage) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented") m.AckHandle = bf.ReadUint32()
m.UnkBool = bf.ReadUint8()
m.StageIDLength = bf.ReadUint8()
m.StageID = string(bf.ReadBytes(uint(m.StageIDLength)))
return nil
} }
// Build builds a binary packet from the current data. // Build builds a binary packet from the current data.
func (m *MsgSysMoveStage) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysMoveStage) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -62,6 +62,10 @@ func NewServer(config *Config) *Server {
stage := NewStage("sl1Ns200p0a0u0") stage := NewStage("sl1Ns200p0a0u0")
s.stages[stage.id] = stage s.stages[stage.id] = stage
// Town underground left area -- rasta bar stage (Maybe private bar ID as well?)
stage2 := NewStage("sl1Ns211p0a0u0")
s.stages[stage2.id] = stage2
return s return s
} }

View File

@@ -303,12 +303,11 @@ func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) {
func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) { func doStageTransfer(s *Session, ackHandle uint32, stageID string) {
pkt := p.(*mhfpacket.MsgSysEnterStage)
// Remove this session from old stage clients list and put myself in the new one. // Remove this session from old stage clients list and put myself in the new one.
s.server.stagesLock.Lock() s.server.stagesLock.Lock()
newStage, gotNewStage := s.server.stages[stripNullTerminator(pkt.StageID)] newStage, gotNewStage := s.server.stages[stripNullTerminator(stageID)]
s.server.stagesLock.Unlock() s.server.stagesLock.Unlock()
// Remove from old stage. // Remove from old stage.
@@ -327,7 +326,7 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
// Save our new stage ID and pointer to the new stage itself. // Save our new stage ID and pointer to the new stage itself.
s.Lock() s.Lock()
s.stageID = string(stripNullTerminator(pkt.StageID)) s.stageID = string(stripNullTerminator(stageID))
s.stage = newStage s.stage = newStage
s.Unlock() s.Unlock()
@@ -335,7 +334,7 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.QueueSendMHF(&mhfpacket.MsgSysCleanupObject{}) s.QueueSendMHF(&mhfpacket.MsgSysCleanupObject{})
// Confirm the stage entry. // Confirm the stage entry.
s.QueueAck(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) s.QueueAck(ackHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
// Notify existing stage clients that this new client has entered. // Notify existing stage clients that this new client has entered.
s.logger.Info("Sending MsgSysInsertUser & MsgSysNotifyUserBinary") s.logger.Info("Sending MsgSysInsertUser & MsgSysNotifyUserBinary")
@@ -414,9 +413,17 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
s.QueueSend(clientDupObjNotif.Data()) s.QueueSend(clientDupObjNotif.Data())
} }
func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgSysEnterStage)
doStageTransfer(s, pkt.AckHandle, pkt.StageID)
}
func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysMoveStage(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysMoveStage(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgSysMoveStage)
doStageTransfer(s, pkt.AckHandle, pkt.StageID)
}
func handleMsgSysLeaveStage(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysLeaveStage(s *Session, p mhfpacket.MHFPacket) {}
@@ -587,9 +594,9 @@ func handleMsgSysEnumerateStage(s *Session, p mhfpacket.MHFPacket) {
//resp.WriteBytes([]byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00}) //resp.WriteBytes([]byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00})
resp.WriteUint16(5) // Current players. resp.WriteUint16(5) // Current players.
resp.WriteUint16(7) // Unknown value resp.WriteUint16(7) // Unknown value
resp.WriteUint16(0) // HasDeparted or IsLocked. resp.WriteUint16(0) // HasDeparted.
resp.WriteUint16(20) // Max players. resp.WriteUint16(20) // Max players.
resp.WriteUint8(2) // Password protected. resp.WriteUint8(2) // Password protected.
resp.WriteUint8(uint8(len(sid))) resp.WriteUint8(uint8(len(sid)))
resp.WriteBytes([]byte(sid)) resp.WriteBytes([]byte(sid))
} }