mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
implement interception point collation & progression
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user