diff --git a/network/mhfpacket/msg_sys_move_stage.go b/network/mhfpacket/msg_sys_move_stage.go index 57bfdb942..c8ae87dd7 100644 --- a/network/mhfpacket/msg_sys_move_stage.go +++ b/network/mhfpacket/msg_sys_move_stage.go @@ -6,7 +6,12 @@ import ( ) // 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. func (m *MsgSysMoveStage) Opcode() network.PacketID { @@ -15,10 +20,14 @@ func (m *MsgSysMoveStage) Opcode() network.PacketID { // Parse parses the packet from binary 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. func (m *MsgSysMoveStage) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/server/channelserver/channel_server.go b/server/channelserver/channel_server.go index ed2db6d6a..ca9452170 100644 --- a/server/channelserver/channel_server.go +++ b/server/channelserver/channel_server.go @@ -62,6 +62,10 @@ func NewServer(config *Config) *Server { stage := NewStage("sl1Ns200p0a0u0") 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 } diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index bc6c51679..5bfd965ca 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -303,12 +303,11 @@ func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) { func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {} -func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) { - pkt := p.(*mhfpacket.MsgSysEnterStage) +func doStageTransfer(s *Session, ackHandle uint32, stageID string) { // Remove this session from old stage clients list and put myself in the new one. s.server.stagesLock.Lock() - newStage, gotNewStage := s.server.stages[stripNullTerminator(pkt.StageID)] + newStage, gotNewStage := s.server.stages[stripNullTerminator(stageID)] s.server.stagesLock.Unlock() // 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. s.Lock() - s.stageID = string(stripNullTerminator(pkt.StageID)) + s.stageID = string(stripNullTerminator(stageID)) s.stage = newStage s.Unlock() @@ -335,7 +334,7 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) { s.QueueSendMHF(&mhfpacket.MsgSysCleanupObject{}) // 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. s.logger.Info("Sending MsgSysInsertUser & MsgSysNotifyUserBinary") @@ -414,9 +413,17 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) { 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 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) {} @@ -587,9 +594,9 @@ func handleMsgSysEnumerateStage(s *Session, p mhfpacket.MHFPacket) { //resp.WriteBytes([]byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00}) resp.WriteUint16(5) // Current players. resp.WriteUint16(7) // Unknown value - resp.WriteUint16(0) // HasDeparted or IsLocked. + resp.WriteUint16(0) // HasDeparted. resp.WriteUint16(20) // Max players. - resp.WriteUint8(2) // Password protected. + resp.WriteUint8(2) // Password protected. resp.WriteUint8(uint8(len(sid))) resp.WriteBytes([]byte(sid)) }