handle house interior updates

This commit is contained in:
wishu
2022-07-08 10:02:02 +10:00
parent 9dafa10ba2
commit b792d7b851
3 changed files with 34 additions and 16 deletions

View File

@@ -10,12 +10,12 @@ import (
// MsgMhfLoadHouse represents the MSG_MHF_LOAD_HOUSE
type MsgMhfLoadHouse struct {
AckHandle uint32
Unk0 uint32
Unk1 uint8
Unk2 uint8
Unk3 uint16 // Hardcoded 0 in binary
DataSize uint8
AckHandle uint32
CharID uint32
Unk1 uint8
Unk2 uint8
Unk3 uint16 // Hardcoded 0 in binary
DataSize uint8
RawDataPayload []byte
}
@@ -27,7 +27,7 @@ func (m *MsgMhfLoadHouse) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfLoadHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.CharID = bf.ReadUint32()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint8()
m.Unk3 = bf.ReadUint16()

View File

@@ -9,7 +9,10 @@ import (
)
// MsgMhfUpdateInterior represents the MSG_MHF_UPDATE_INTERIOR
type MsgMhfUpdateInterior struct{}
type MsgMhfUpdateInterior struct {
AckHandle uint32
InteriorData []byte
}
// Opcode returns the ID associated with this packet type.
func (m *MsgMhfUpdateInterior) Opcode() network.PacketID {
@@ -18,7 +21,9 @@ func (m *MsgMhfUpdateInterior) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfUpdateInterior) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
return errors.New("NOT IMPLEMENTED")
m.AckHandle = bf.ReadUint32()
m.InteriorData = bf.ReadBytes(20)
return nil
}
// Build builds a binary packet from the current data.

View File

@@ -8,7 +8,14 @@ import (
"go.uber.org/zap"
)
func handleMsgMhfUpdateInterior(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgMhfUpdateInterior(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfUpdateInterior)
_, err := s.server.db.Exec("UPDATE characters SET house=$1 WHERE id=$2", pkt.InteriorData, s.charID)
if err != nil {
panic(err)
}
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
}
func handleMsgMhfEnumerateHouse(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateHouse)
@@ -19,8 +26,14 @@ func handleMsgMhfUpdateHouse(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfLoadHouse)
// Seems to generate same response regardless of upgrade tier
data, _ := hex.DecodeString("0000000000000000000000000000000000000000")
var data []byte
err := s.server.db.QueryRow("SELECT house FROM characters WHERE id=$1", s.charID).Scan(&data)
if err != nil {
panic(err)
}
if data == nil {
data, _ = hex.DecodeString("0000000000000000000000000000000000000000")
}
doAckBufSucceed(s, pkt.AckHandle, data)
}