diff --git a/network/mhfpacket/msg_sys_enumerate_stage.go b/network/mhfpacket/msg_sys_enumerate_stage.go index 0c3362562..79aff6016 100644 --- a/network/mhfpacket/msg_sys_enumerate_stage.go +++ b/network/mhfpacket/msg_sys_enumerate_stage.go @@ -10,7 +10,7 @@ type MsgSysEnumerateStage struct { AckHandle uint32 Unk0 uint8 // Hardcoded 1 in the binary StageIDLength uint8 - StageID string + StageID string // NULL terminated string. } // Opcode returns the ID associated with this packet type. diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 21708db64..21b4bd916 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "log" + "strings" "time" "github.com/Andoryuuta/Erupe/network/mhfpacket" @@ -89,6 +90,11 @@ func fixedSizeShiftJIS(text string, size int) []byte { return out } +// TODO(Andoryuuta): Fix/move/remove me! +func stripNullTerminator(x string) string { + return strings.SplitN(x, "\x00", 2)[0] +} + func handleMsgHead(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysReserve01(s *Session, p mhfpacket.MHFPacket) {} @@ -344,7 +350,7 @@ func handleMsgSysCreateObject(s *Session, p mhfpacket.MHFPacket) { // Get the current stage. s.server.stagesLock.RLock() defer s.server.stagesLock.RUnlock() - stage, ok := s.server.stages[s.stageID] + stage, ok := s.server.stages[stripNullTerminator(s.stageID)] if !ok { s.logger.Fatal("StageID not in the stages map!", zap.String("stageID", s.stageID)) }