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

@@ -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))
}