Implement MsgSysCreateStage

This commit is contained in:
Andrew Gutekanst
2020-01-22 18:17:23 -05:00
parent 5a67d689e0
commit cf3cafa929
2 changed files with 24 additions and 4 deletions

View File

@@ -6,7 +6,13 @@ import (
)
// MsgSysCreateStage represents the MSG_SYS_CREATE_STAGE
type MsgSysCreateStage struct{}
type MsgSysCreateStage struct {
AckHandle uint32
Unk0 uint8
Unk1 uint8
StageIDLength uint8
StageID string // NULL terminated string.
}
// Opcode returns the ID associated with this packet type.
func (m *MsgSysCreateStage) Opcode() network.PacketID {
@@ -15,7 +21,12 @@ func (m *MsgSysCreateStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysCreateStage) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented")
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = 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.

View File

@@ -252,7 +252,16 @@ func handleMsgSysRecordLog(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysEcho(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgSysCreateStage)
s.server.stagesLock.Lock()
s.server.stages[stripNullTerminator(s.stageID)] = &Stage{}
s.server.stagesLock.Lock()
resp := make([]byte, 8) // Unk resp.
s.QueueAck(pkt.AckHandle, resp)
}
func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {}