mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
various changes
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
type MsgMhfReadMercenaryM struct {
|
type MsgMhfReadMercenaryM struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
CharID uint32
|
CharID uint32
|
||||||
Unk0 uint32
|
MercID uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
@@ -24,7 +24,7 @@ func (m *MsgMhfReadMercenaryM) Opcode() network.PacketID {
|
|||||||
func (m *MsgMhfReadMercenaryM) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfReadMercenaryM) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.CharID = bf.ReadUint32()
|
m.CharID = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint32()
|
m.MercID = bf.ReadUint32()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
// MsgMhfReadMercenaryW represents the MSG_MHF_READ_MERCENARY_W
|
// MsgMhfReadMercenaryW represents the MSG_MHF_READ_MERCENARY_W
|
||||||
type MsgMhfReadMercenaryW struct {
|
type MsgMhfReadMercenaryW struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk0 bool
|
GetPact bool
|
||||||
Unk1 uint8
|
Unk1 uint8
|
||||||
Unk2 uint16 // Hardcoded 0 in the binary
|
Unk2 uint16 // Hardcoded 0 in the binary
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID {
|
|||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfReadMercenaryW) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfReadMercenaryW) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadBool()
|
m.GetPact = bf.ReadBool()
|
||||||
m.Unk1 = bf.ReadUint8()
|
m.Unk1 = bf.ReadUint8()
|
||||||
m.Unk2 = bf.ReadUint16()
|
m.Unk2 = bf.ReadUint16()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ import (
|
|||||||
type MsgMhfSaveMercenary struct {
|
type MsgMhfSaveMercenary struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
GCP uint32
|
GCP uint32
|
||||||
Unk0 uint32
|
PactMercID uint32
|
||||||
MercData []byte
|
MercData []byte
|
||||||
Unk1 uint32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
@@ -27,9 +26,10 @@ func (m *MsgMhfSaveMercenary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clie
|
|||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
bf.ReadUint32() // lenData
|
bf.ReadUint32() // lenData
|
||||||
m.GCP = bf.ReadUint32()
|
m.GCP = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint32()
|
m.PactMercID = bf.ReadUint32()
|
||||||
m.MercData = bf.ReadBytes(uint(bf.ReadUint32()))
|
dataSize := bf.ReadUint32()
|
||||||
m.Unk1 = bf.ReadUint32()
|
_ = bf.ReadUint32() // Merc index?
|
||||||
|
m.MercData = bf.ReadBytes(uint(dataSize))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
patch-schema/rasta-id.sql
Normal file
9
patch-schema/rasta-id.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
UPDATE characters SET savemercenary = NULL;
|
||||||
|
|
||||||
|
ALTER TABLE characters ADD rasta_id INT;
|
||||||
|
|
||||||
|
ALTER TABLE characters ADD pact_id INT;
|
||||||
|
|
||||||
|
END;
|
||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// THERE ARE [PARTENER] [MERCENARY] [OTOMO AIRU]
|
// THERE ARE [PARTENER] [MERCENARY] [OTOMO AIRU]
|
||||||
@@ -114,12 +115,6 @@ func handleMsgMhfSaveHunterNavi(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////
|
|
||||||
/// MERCENARY //
|
|
||||||
///////////////////////////////////////////
|
|
||||||
|
|
||||||
func handleMsgMhfMercenaryHuntdata(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfMercenaryHuntdata(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfMercenaryHuntdata)
|
pkt := p.(*mhfpacket.MsgMhfMercenaryHuntdata)
|
||||||
if pkt.Unk0 == 1 {
|
if pkt.Unk0 == 1 {
|
||||||
@@ -149,15 +144,11 @@ func handleMsgMhfEnumerateMercenaryLog(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func handleMsgMhfCreateMercenary(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfCreateMercenary(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfCreateMercenary)
|
pkt := p.(*mhfpacket.MsgMhfCreateMercenary)
|
||||||
|
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
|
|
||||||
var nextID uint32
|
var nextID uint32
|
||||||
s.server.db.QueryRow("SELECT nextval('rasta_id_seq')").Scan(&nextID)
|
_ = s.server.db.QueryRow("SELECT nextval('rasta_id_seq')").Scan(&nextID)
|
||||||
|
s.server.db.Exec("UPDATE characters SET rasta_id=$1 WHERE id=$2", nextID, s.charID)
|
||||||
bf.WriteUint32(nextID) // New MercID
|
bf.WriteUint32(nextID)
|
||||||
bf.WriteUint32(0xDEADBEEF) // Unk
|
|
||||||
|
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, bf.Data())
|
doAckSimpleSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,16 +156,34 @@ func handleMsgMhfSaveMercenary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
pkt := p.(*mhfpacket.MsgMhfSaveMercenary)
|
pkt := p.(*mhfpacket.MsgMhfSaveMercenary)
|
||||||
dumpSaveData(s, pkt.MercData, "mercenary")
|
dumpSaveData(s, pkt.MercData, "mercenary")
|
||||||
if len(pkt.MercData) > 0 {
|
if len(pkt.MercData) > 0 {
|
||||||
s.server.db.Exec("UPDATE characters SET savemercenary=$1 WHERE id=$2", pkt.MercData, s.charID)
|
temp := byteframe.NewByteFrameFromBytes(pkt.MercData)
|
||||||
|
s.server.db.Exec("UPDATE characters SET savemercenary=$1, rasta_id=$2 WHERE id=$3", pkt.MercData, temp.ReadUint32(), s.charID)
|
||||||
}
|
}
|
||||||
s.server.db.Exec("UPDATE characters SET gcp=$1 WHERE id=$2", pkt.GCP, s.charID)
|
s.server.db.Exec("UPDATE characters SET gcp=$1, pact_id=$2 WHERE id=$3", pkt.GCP, pkt.PactMercID, s.charID)
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfReadMercenaryW(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfReadMercenaryW(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfReadMercenaryW)
|
pkt := p.(*mhfpacket.MsgMhfReadMercenaryW)
|
||||||
if pkt.Unk0 {
|
if pkt.GetPact {
|
||||||
|
var pactID uint32
|
||||||
|
s.server.db.QueryRow("SELECT pact_id FROM characters WHERE id=$1", s.charID).Scan(&pactID)
|
||||||
|
if pactID > 0 {
|
||||||
|
var name string
|
||||||
|
var cid uint32
|
||||||
|
s.server.db.QueryRow("SELECT name, id FROM characters WHERE rasta_id = $1", pactID).Scan(&name, &cid)
|
||||||
|
bf := byteframe.NewByteFrame()
|
||||||
|
bf.WriteBool(true)
|
||||||
|
bf.WriteUint32(pactID)
|
||||||
|
bf.WriteUint32(cid)
|
||||||
|
bf.WriteBool(true)
|
||||||
|
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix()))
|
||||||
|
bf.WriteUint32(uint32(Time_Current_Adjusted().Add(time.Hour * 24 * 7).Unix()))
|
||||||
|
bf.WriteBytes(stringsupport.PaddedString(name, 18, true))
|
||||||
|
bf.WriteBool(false)
|
||||||
|
} else {
|
||||||
doAckBufSucceed(s, pkt.AckHandle, make([]byte, 2))
|
doAckBufSucceed(s, pkt.AckHandle, make([]byte, 2))
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var data []byte
|
var data []byte
|
||||||
@@ -183,11 +192,12 @@ func handleMsgMhfReadMercenaryW(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.server.db.QueryRow("SELECT COALESCE(gcp, 0) FROM characters WHERE id=$1", s.charID).Scan(&gcp)
|
s.server.db.QueryRow("SELECT COALESCE(gcp, 0) FROM characters WHERE id=$1", s.charID).Scan(&gcp)
|
||||||
|
|
||||||
resp := byteframe.NewByteFrame()
|
resp := byteframe.NewByteFrame()
|
||||||
|
resp.WriteUint16(0)
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
resp.WriteBytes(make([]byte, 3))
|
resp.WriteBool(false)
|
||||||
} else {
|
} else {
|
||||||
resp.WriteBytes(data[1:])
|
resp.WriteBool(true)
|
||||||
resp.WriteUint32(0) // Unk
|
resp.WriteBytes(data)
|
||||||
}
|
}
|
||||||
resp.WriteUint32(gcp)
|
resp.WriteUint32(gcp)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
@@ -201,7 +211,7 @@ func handleMsgMhfReadMercenaryM(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
resp.WriteBool(false)
|
resp.WriteBool(false)
|
||||||
} else {
|
} else {
|
||||||
resp.WriteBytes(data[4:])
|
resp.WriteBytes(data)
|
||||||
}
|
}
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user