diff --git a/network/mhfpacket/msg_mhf_add_ud_tactics_point.go b/network/mhfpacket/msg_mhf_add_ud_tactics_point.go index 5e1f4261a..ff5d8d337 100644 --- a/network/mhfpacket/msg_mhf_add_ud_tactics_point.go +++ b/network/mhfpacket/msg_mhf_add_ud_tactics_point.go @@ -11,7 +11,7 @@ import ( type MsgMhfAddUdTacticsPoint struct { AckHandle uint32 QuestFileID uint16 - Points uint32 + Points int32 } // Opcode returns the ID associated with this packet type. @@ -23,7 +23,7 @@ func (m *MsgMhfAddUdTacticsPoint) Opcode() network.PacketID { func (m *MsgMhfAddUdTacticsPoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() m.QuestFileID = bf.ReadUint16() - m.Points = bf.ReadUint32() + m.Points = bf.ReadInt32() return nil } diff --git a/patch-schema/diva.sql b/patch-schema/diva.sql index 70bebde70..d5fe1a077 100644 --- a/patch-schema/diva.sql +++ b/patch-schema/diva.sql @@ -3,4 +3,7 @@ BEGIN; ALTER TABLE IF EXISTS public.guilds ADD COLUMN IF NOT EXISTS interception_maps bytea; +ALTER TABLE IF EXISTS public.guild_characters + ADD COLUMN IF NOT EXISTS interception_points bytea; + END; \ No newline at end of file diff --git a/server/channelserver/handlers_diva.go b/server/channelserver/handlers_diva.go index eeed4f9f9..c411034db 100644 --- a/server/channelserver/handlers_diva.go +++ b/server/channelserver/handlers_diva.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "encoding/json" "erupe-ce/common/stringsupport" + "github.com/lib/pq" "go.uber.org/zap" "golang.org/x/exp/slices" "math/rand" @@ -450,15 +451,27 @@ func handleMsgMhfGetUdGuildMapInfo(s *Session, p mhfpacket.MHFPacket) { } var interceptionMaps InterceptionMaps - err = s.server.db.QueryRow(`SELECT interception_maps FROM public.guilds WHERE guilds.id=$1`, guild.ID).Scan(&interceptionMaps) + var personalPoints map[uint16]int32 + + interceptionPoints := make(map[uint16]int32) + var _interceptionPoints pq.ByteaArray + err = s.server.db.QueryRow(`SELECT interception_maps, (SELECT ARRAY(SELECT interception_points FROM guild_characters gc WHERE gc.guild_id = g.id)) AS interception_points FROM public.guilds g WHERE g.id=$1`, guild.ID).Scan(&interceptionMaps, &_interceptionPoints) if err != nil { s.server.logger.Debug("err", zap.Error(err)) doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4)) return } + for _, playerPoints := range _interceptionPoints { + json.Unmarshal(playerPoints, &personalPoints) + for u, i := range personalPoints { + if u < 58079 || u > 58083 { + interceptionPoints[0] += i + } else { + interceptionPoints[u] += i + } + } + } - // rudimentary example - interceptionPoints := map[uint16]int32{0: 200000, 58079: 50} var guildProg []MapProg unkData := []struct { diff --git a/server/channelserver/handlers_tactics.go b/server/channelserver/handlers_tactics.go index 179a73eb7..d95d72ff2 100644 --- a/server/channelserver/handlers_tactics.go +++ b/server/channelserver/handlers_tactics.go @@ -2,6 +2,7 @@ package channelserver import ( "encoding/hex" + "encoding/json" "erupe-ce/common/byteframe" "erupe-ce/common/stringsupport" "erupe-ce/network/mhfpacket" @@ -18,6 +19,18 @@ func handleMsgMhfGetUdTacticsPoint(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfAddUdTacticsPoint(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfAddUdTacticsPoint) + var personalPoints map[uint16]int32 + var temp []byte + s.server.db.QueryRow(`SELECT interception_points FROM guild_characters WHERE id=$1`, s.charID).Scan(&temp) + json.Unmarshal(temp, &personalPoints) + if personalPoints == nil { + personalPoints = make(map[uint16]int32) + personalPoints[pkt.QuestFileID] = pkt.Points + } else { + personalPoints[pkt.QuestFileID] += pkt.Points + } + val, _ := json.Marshal(personalPoints) + s.server.db.Exec(`UPDATE guild_characters SET interception_points=$1 WHERE id=$2`, val, s.charID) doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) }