mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
improve house entry handling
This commit is contained in:
@@ -14,9 +14,10 @@ type MsgMhfLoadHouse struct {
|
||||
AckHandle uint32
|
||||
CharID uint32
|
||||
Destination uint8
|
||||
InMezeporta bool
|
||||
Unk3 uint16 // Hardcoded 0 in binary
|
||||
Password string
|
||||
// False if already in hosts My Series, in case host updates PW
|
||||
CheckPass bool
|
||||
Unk3 uint16 // Hardcoded 0 in binary
|
||||
Password string
|
||||
}
|
||||
|
||||
// Opcode returns the ID associated with this packet type.
|
||||
@@ -29,7 +30,7 @@ func (m *MsgMhfLoadHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCo
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.CharID = bf.ReadUint32()
|
||||
m.Destination = bf.ReadUint8()
|
||||
m.InMezeporta = bf.ReadBool()
|
||||
m.CheckPass = bf.ReadBool()
|
||||
_ = bf.ReadUint16()
|
||||
_ = bf.ReadUint8() // Password length
|
||||
m.Password = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
|
||||
|
||||
@@ -123,35 +123,54 @@ func handleMsgMhfUpdateHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfLoadHouse)
|
||||
bf := byteframe.NewByteFrame()
|
||||
var data []byte
|
||||
err := s.server.db.QueryRow("SELECT house FROM characters WHERE id=$1", pkt.CharID).Scan(&data)
|
||||
if pkt.Destination != 9 && len(pkt.Password) > 0 && pkt.CheckPass {
|
||||
for _, session := range s.server.sessions {
|
||||
if session.charID == pkt.CharID && pkt.Password != session.house.password {
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var furniture []byte
|
||||
err := s.server.db.QueryRow("SELECT house FROM characters WHERE id=$1", pkt.CharID).Scan(&furniture)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if data == nil {
|
||||
data = make([]byte, 20)
|
||||
if furniture == nil {
|
||||
furniture = make([]byte, 20)
|
||||
}
|
||||
|
||||
// TODO: Find where the missing data comes from, savefile offset?
|
||||
switch pkt.Destination {
|
||||
case 3: // Others house
|
||||
houseTier := uint8(2) // Fallback if can't find
|
||||
for _, session := range s.server.sessions {
|
||||
if session.charID == pkt.CharID {
|
||||
if pkt.Password != session.house.password {
|
||||
// Not the correct error code but works
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
houseTier = session.house.tier
|
||||
}
|
||||
}
|
||||
bf.WriteBytes(make([]byte, 4))
|
||||
bf.WriteUint8(houseTier) // House tier 0x1FB70
|
||||
// Item box style
|
||||
bf.WriteBytes(make([]byte, 80))
|
||||
// Item box style bitfield
|
||||
// tier 1 = 0x09FE
|
||||
// tier 2 = 0x69FF
|
||||
// tier 3 = 0xE9FF
|
||||
// unused = 0x0001
|
||||
// unused = 0x6000
|
||||
switch houseTier {
|
||||
case 0:
|
||||
bf.WriteUint16(0x0000)
|
||||
case 1:
|
||||
bf.WriteUint16(0x69FF)
|
||||
case 2:
|
||||
bf.WriteUint16(0xE9FF)
|
||||
}
|
||||
// Rastae
|
||||
// Partner
|
||||
bf.WriteBytes(make([]byte, 214))
|
||||
bf.WriteBytes(data)
|
||||
bf.WriteBytes(make([]byte, 132))
|
||||
bf.WriteBytes(furniture)
|
||||
case 4: // Bookshelf
|
||||
// Hunting log
|
||||
bf.WriteBytes(make([]byte, 5576))
|
||||
@@ -164,7 +183,7 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
// Pugis
|
||||
bf.WriteBytes(make([]byte, 240))
|
||||
case 9: // Own house
|
||||
bf.WriteBytes(data)
|
||||
bf.WriteBytes(furniture)
|
||||
case 10: // Garden
|
||||
// Gardening upgrades
|
||||
// Gooks
|
||||
|
||||
Reference in New Issue
Block a user