Fix MsgSysCreateObject stage lookup

This commit is contained in:
Andrew Gutekanst
2020-01-22 18:03:02 -05:00
parent fa245e53fb
commit 5a67d689e0
2 changed files with 8 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ type MsgSysEnumerateStage struct {
AckHandle uint32 AckHandle uint32
Unk0 uint8 // Hardcoded 1 in the binary Unk0 uint8 // Hardcoded 1 in the binary
StageIDLength uint8 StageIDLength uint8
StageID string StageID string // NULL terminated string.
} }
// Opcode returns the ID associated with this packet type. // Opcode returns the ID associated with this packet type.

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"strings"
"time" "time"
"github.com/Andoryuuta/Erupe/network/mhfpacket" "github.com/Andoryuuta/Erupe/network/mhfpacket"
@@ -89,6 +90,11 @@ func fixedSizeShiftJIS(text string, size int) []byte {
return out 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 handleMsgHead(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgSysReserve01(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. // Get the current stage.
s.server.stagesLock.RLock() s.server.stagesLock.RLock()
defer s.server.stagesLock.RUnlock() defer s.server.stagesLock.RUnlock()
stage, ok := s.server.stages[s.stageID] stage, ok := s.server.stages[stripNullTerminator(s.stageID)]
if !ok { if !ok {
s.logger.Fatal("StageID not in the stages map!", zap.String("stageID", s.stageID)) s.logger.Fatal("StageID not in the stages map!", zap.String("stageID", s.stageID))
} }