mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
interception map generator & file refactor
This commit is contained in:
@@ -1492,167 +1492,6 @@ func handleMsgMhfGetGuildManageRight(s *Session, p mhfpacket.MHFPacket) {
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
func handleMsgMhfGetUdGuildMapInfo(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetUdGuildMapInfo)
|
||||
|
||||
type Tile struct {
|
||||
ID uint16
|
||||
NextID uint16
|
||||
BranchID uint16
|
||||
QuestFile uint16
|
||||
Unk0 uint32
|
||||
BranchIndex uint8
|
||||
Type uint8
|
||||
PointsReq int32
|
||||
Claimed bool
|
||||
Unk1 uint8
|
||||
Unk2 uint32
|
||||
}
|
||||
type mapProg struct {
|
||||
ID uint32
|
||||
Unk uint16
|
||||
Tiles []Tile
|
||||
Active bool
|
||||
Bytes *byteframe.ByteFrame
|
||||
}
|
||||
|
||||
// rudimentary example
|
||||
interceptionPoints := map[uint16]int32{0: 2000, 58079: 50}
|
||||
var guildProg []mapProg
|
||||
mapData := []struct {
|
||||
ID uint32
|
||||
NextID uint32
|
||||
Tiles []Tile
|
||||
}{
|
||||
{ID: 1, NextID: 1, Tiles: []Tile{
|
||||
{ID: 101, NextID: 102, BranchIndex: 1, Type: 1},
|
||||
{ID: 102, NextID: 103, BranchID: 202, BranchIndex: 2, Type: 3, PointsReq: 500},
|
||||
{ID: 103, BranchIndex: 3, Type: 2, PointsReq: 500},
|
||||
{ID: 202, QuestFile: 58079, BranchIndex: 1, Type: 4, PointsReq: 100, Unk1: 1, Unk2: 1},
|
||||
}}, {ID: 2, NextID: 3, Tiles: []Tile{
|
||||
{ID: 105, NextID: 205, BranchIndex: 1, Type: 1},
|
||||
{ID: 205, NextID: 305, BranchIndex: 2, Type: 0, PointsReq: 500},
|
||||
{ID: 305, NextID: 405, BranchIndex: 3, Type: 0, PointsReq: 500},
|
||||
{ID: 405, NextID: 505, BranchIndex: 4, Type: 0, PointsReq: 500},
|
||||
{ID: 505, BranchIndex: 5, Type: 2, PointsReq: 5000},
|
||||
}}, {ID: 3, NextID: 1, Tiles: []Tile{
|
||||
{ID: 512, NextID: 412, BranchIndex: 1, Type: 1},
|
||||
{ID: 412, BranchIndex: 2, Type: 2, PointsReq: 500},
|
||||
}},
|
||||
}
|
||||
|
||||
unkData := []struct {
|
||||
Unk0 uint32
|
||||
Unk1 uint8
|
||||
Unk2 uint8
|
||||
Unk3 uint8
|
||||
Unk4 uint16
|
||||
Unk5 uint16
|
||||
Unk6 uint16
|
||||
Unk7 uint8
|
||||
}{}
|
||||
|
||||
bf := byteframe.NewByteFrame()
|
||||
|
||||
bf.WriteUint16(uint16(len(mapData)))
|
||||
for _, _map := range mapData {
|
||||
guildProg = append(guildProg, mapProg{ID: _map.ID, Unk: 1, Tiles: _map.Tiles})
|
||||
bf.WriteUint32(_map.ID)
|
||||
bf.WriteUint32(_map.NextID)
|
||||
for _, tile := range _map.Tiles {
|
||||
bf.WriteUint16(tile.ID)
|
||||
bf.WriteUint16(tile.NextID)
|
||||
bf.WriteUint16(tile.BranchID)
|
||||
bf.WriteUint16(tile.QuestFile)
|
||||
bf.WriteUint32(tile.Unk0)
|
||||
bf.WriteUint8(tile.BranchIndex)
|
||||
bf.WriteUint8(tile.Type)
|
||||
bf.WriteInt32(tile.PointsReq)
|
||||
|
||||
bf.WriteUint8(tile.Unk1)
|
||||
bf.WriteUint32(tile.Unk2)
|
||||
}
|
||||
bf.WriteBytes(make([]byte, 23*(64-len(_map.Tiles)))) // Fill out 64 tiles
|
||||
}
|
||||
|
||||
bf.WriteUint16(uint16(len(unkData)))
|
||||
for _, unk := range unkData {
|
||||
bf.WriteUint32(unk.Unk0)
|
||||
bf.WriteUint8(unk.Unk1)
|
||||
bf.WriteUint8(unk.Unk2)
|
||||
bf.WriteUint8(unk.Unk3)
|
||||
bf.WriteUint16(unk.Unk4)
|
||||
bf.WriteUint16(unk.Unk5)
|
||||
bf.WriteUint16(unk.Unk6)
|
||||
bf.WriteUint8(unk.Unk7)
|
||||
}
|
||||
|
||||
var tilesClaimed uint32
|
||||
var currentMapID uint32
|
||||
var prevMapID uint32
|
||||
|
||||
for i, prog := range guildProg {
|
||||
guildProg[i].Bytes = byteframe.NewByteFrame()
|
||||
guildProg[i].Bytes.WriteUint32(prog.ID)
|
||||
guildProg[i].Bytes.WriteUint16(prog.Unk)
|
||||
guildProg[i].Bytes.WriteUint8(uint8(len(prog.Tiles)))
|
||||
for _, tile := range prog.Tiles {
|
||||
if tile.Type != 1 && interceptionPoints[tile.QuestFile] > 0 {
|
||||
if tile.PointsReq-interceptionPoints[tile.QuestFile] < 0 {
|
||||
interceptionPoints[tile.QuestFile] -= tile.PointsReq
|
||||
guildProg[i].Bytes.WriteInt32(tile.PointsReq)
|
||||
tilesClaimed++
|
||||
tile.Claimed = true
|
||||
} else {
|
||||
if tile.QuestFile == 0 {
|
||||
currentMapID = prog.ID
|
||||
if i > 0 {
|
||||
prevMapID = guildProg[i-1].ID
|
||||
}
|
||||
}
|
||||
guildProg[i].Bytes.WriteInt32(interceptionPoints[tile.QuestFile])
|
||||
interceptionPoints[tile.QuestFile] = 0
|
||||
}
|
||||
} else {
|
||||
guildProg[i].Bytes.WriteUint32(0)
|
||||
}
|
||||
guildProg[i].Bytes.WriteInt32(tile.PointsReq)
|
||||
guildProg[i].Bytes.WriteUint16(tile.ID)
|
||||
guildProg[i].Bytes.WriteUint16(tile.NextID)
|
||||
guildProg[i].Bytes.WriteUint16(tile.BranchID)
|
||||
guildProg[i].Bytes.WriteUint16(tile.QuestFile)
|
||||
guildProg[i].Bytes.WriteUint32(tile.Unk0)
|
||||
guildProg[i].Bytes.WriteUint8(tile.BranchIndex)
|
||||
guildProg[i].Bytes.WriteUint8(tile.Type)
|
||||
guildProg[i].Bytes.WriteBool(tile.Claimed)
|
||||
}
|
||||
}
|
||||
|
||||
if prevMapID != 0 {
|
||||
bf.WriteUint8(2)
|
||||
for _, prog := range guildProg {
|
||||
if prog.ID == currentMapID {
|
||||
bf.WriteBytes(prog.Bytes.Data())
|
||||
}
|
||||
}
|
||||
for _, prog := range guildProg {
|
||||
if prog.ID == prevMapID {
|
||||
bf.WriteBytes(prog.Bytes.Data())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bf.WriteUint8(1)
|
||||
for _, prog := range guildProg {
|
||||
if prog.ID == currentMapID {
|
||||
bf.WriteBytes(prog.Bytes.Data())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bf.WriteUint32(tilesClaimed)
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
func handleMsgMhfGetGuildTargetMemberNum(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetGuildTargetMemberNum)
|
||||
|
||||
@@ -2141,11 +1980,6 @@ func handleMsgMhfAddGuildWeeklyBonusExceptionalUser(s *Session, p mhfpacket.MHFP
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
||||
}
|
||||
|
||||
func handleMsgMhfGenerateUdGuildMap(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGenerateUdGuildMap)
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
|
||||
func handleMsgMhfUpdateGuild(s *Session, p mhfpacket.MHFPacket) {}
|
||||
|
||||
func handleMsgMhfSetGuildManageRight(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
Reference in New Issue
Block a user