Added changes for Z1 Tower with CapLink

Added TinyBin Item code and some notes, Added CapLink API
This commit is contained in:
stratic-dev
2024-04-01 22:08:58 +01:00
parent b8be6e7aa8
commit dc59755384
7 changed files with 99 additions and 31 deletions

View File

@@ -1,18 +1,18 @@
package mhfpacket
import (
"errors"
import (
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfGetPaperData represents the MSG_MHF_GET_PAPER_DATA
type MsgMhfGetPaperData struct {
// Communicator type, multi-format. This might be valid for only one type.
AckHandle uint32
Unk0 uint32
Type uint32
Unk1 uint32
Unk2 uint32
}
@@ -25,7 +25,7 @@ func (m *MsgMhfGetPaperData) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfGetPaperData) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.Type = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
m.Unk2 = bf.ReadUint32()
return nil

View File

@@ -41,6 +41,12 @@ func NewAPIServer(config *Config) *APIServer {
}
return s
}
func (s *APIServer) loggingMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s.logger.Info("Received " + r.Method + " request from " + r.RemoteAddr + "path" + r.RequestURI + "\n")
next.ServeHTTP(w, r)
})
}
// Start starts the server in a new goroutine.
func (s *APIServer) Start() error {
@@ -54,6 +60,9 @@ func (s *APIServer) Start() error {
r.HandleFunc("/character/export", s.ExportSave)
r.HandleFunc("/api/ss/bbs/upload.php", s.ScreenShot)
r.HandleFunc("/api/ss/bbs/{id}", s.ScreenShotGet)
r.HandleFunc("/v1/crypt/commonkey/rsa", s.CapLinkCrypt)
r.Use(s.loggingMiddleware)
handler := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}))(r)
s.httpServer.Handler = handlers.LoggingHandler(os.Stdout, handler)
s.httpServer.Addr = fmt.Sprintf(":%d", s.erupeConfig.API.Port)

View File

@@ -410,3 +410,23 @@ func (s *APIServer) ScreenShot(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write(xmlData)
}
func (s *APIServer) CapLinkCrypt(w http.ResponseWriter, r *http.Request) {
// Extract query parameters
queryParams := r.URL.Query()
// Extracting specific query parameters
clientPubKey := queryParams.Get("client_pub_key")
deviceID := queryParams.Get("device_id")
platformID := queryParams.Get("platform_id")
contentID := queryParams.Get("content_id")
serverVersion := queryParams.Get("server_version")
clientVersion := queryParams.Get("client_version")
// Your business logic to generate response based on query parameters
response := fmt.Sprintf("Received request with client_pub_key: %s, device_id: %s, platform_id: %s, content_id: %s, server_version: %s, client_version: %s", clientPubKey, deviceID, platformID, contentID, serverVersion, clientVersion)
// Write response headers
w.WriteHeader(http.StatusOK)
// Write response body
w.Write([]byte(response))
}

View File

@@ -1122,6 +1122,7 @@ func handleMsgMhfGetEarthValue(s *Session, p mhfpacket.MHFPacket) {
switch pkt.ReqType {
case 1:
earthValues = []EarthValues{
//TowerBlock,AmountOfFloorsClimbed,Unk,Unk,Unk,Unk
{[]uint32{1, 312, 0, 0, 0, 0}},
{[]uint32{2, 99, 0, 0, 0, 0}},
}

View File

@@ -73,9 +73,25 @@ func handleMsgMhfGetRyoudama(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfPostRyoudama(s *Session, p mhfpacket.MHFPacket) {}
func handleMsgMhfGetTinyBin(s *Session, p mhfpacket.MHFPacket) {
type TinyBinItem struct {
ItemId uint16
Amount uint8
Unk2 uint8 //if 4 the Red message "There are some items and points that cannot be recieved." Shows
}
tinyBinItems := []TinyBinItem{{7, 2, 4}, {8, 1, 0}, {9, 1, 0}, {300, 4, 0}, {10, 1, 0}}
pkt := p.(*mhfpacket.MsgMhfGetTinyBin)
// requested after conquest quests
doAckBufSucceed(s, pkt.AckHandle, []byte{})
bf := byteframe.NewByteFrame()
bf.SetLE()
for _, items := range tinyBinItems {
bf.WriteUint16(items.ItemId)
bf.WriteUint8(items.Amount)
bf.WriteUint8(items.Unk2)
}
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
}
func handleMsgMhfPostTinyBin(s *Session, p mhfpacket.MHFPacket) {

View File

@@ -14,6 +14,7 @@ import (
"erupe-ce/network/mhfpacket"
"erupe-ce/server/channelserver/compression/deltacomp"
"erupe-ce/server/channelserver/compression/nullcomp"
"go.uber.org/zap"
)
@@ -1001,16 +1002,26 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
var paperMissions PaperMission
var paperGift []PaperGift
// pkt.Type
// if pkt.Type 3 then Unk2==0 PaperMissionData
// if pkt.Type 0 then unk2 4, 5 or 6 PaperData
// if pkt.Type 2 then unk2 6001 6011 PaperGiftData
// is pkt.Unk2 a index?
paperMissions = PaperMission{
[]PaperMissionTimetable{{TimeMidnight(), TimeMidnight().Add(24 * time.Hour)}},
[]PaperMissionData{{1, 1, 50, 7, 10, 8, 11},
{1, 2, 100, 7, 12, 8, 13},
{1, 3, 150, 7, 14, 8, 15},
{1, 4, 200, 7, 16, 8, 17},
{1, 5, 250, 7, 18, 8, 19},
{1, 6, 300, 7, 21, 8, 21}},
}
switch pkt.Unk2 {
case 0:
paperMissions = PaperMission{
[]PaperMissionTimetable{{TimeMidnight(), TimeMidnight().Add(24 * time.Hour)}},
[]PaperMissionData{},
}
case 5:
paperData = []PaperData{
// getTowerQuestTowerLevel
{1001, 1, 0, 0, 0, 0, 0},
{1001, 1, 1, 0, 0, 0, 0},
{1001, 2, 0, 0, 0, 0, 0},
// iniTQT
{1003, 1, 100, 100, 200, 100, 0},
@@ -1029,8 +1040,8 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
{1012, 1, 8000, 17500, 22500, 27500, 31000},
{1012, 2, 8000, 17500, 22500, 27500, 31000},
// setServerZako
{1015, 1, 16, 16, 16, 0, 0},
{1015, 2, 16, 16, 16, 0, 0},
{1015, 1, mhfmon.Velociprey, mhfmon.Velociprey, mhfmon.Velociprey, 0, 0},
{1015, 2, mhfmon.Velociprey, mhfmon.Velociprey, mhfmon.Velociprey, 0, 0},
// createTowerFloorRandomNumberArray
{1101, 1, 2016, 500, 0, 0, 0},
{1101, 2, 2016, 500, 0, 0, 0},
@@ -1509,9 +1520,25 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
if pkt.Unk2 < 1000 {
s.logger.Info("PaperData request for unknown type", zap.Uint32("Unk2", pkt.Unk2))
}
}
if pkt.Unk2 > 1000 {
switch pkt.Type {
case 0:
for _, pdata := range paperData {
bf := byteframe.NewByteFrame()
bf.WriteUint16(pdata.Unk0)
bf.WriteInt16(pdata.Unk1)
bf.WriteInt16(pdata.Unk2)
bf.WriteInt16(pdata.Unk3)
bf.WriteInt16(pdata.Unk4)
bf.WriteInt16(pdata.Unk5)
bf.WriteInt16(pdata.Unk6)
data = append(data, bf)
}
doAckEarthSucceed(s, pkt.AckHandle, data)
case 2:
_, ok := paperGiftData[pkt.Unk2]
if ok {
paperGift = paperGiftData[pkt.Unk2]
@@ -1527,7 +1554,8 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
data = append(data, bf)
}
doAckEarthSucceed(s, pkt.AckHandle, data)
} else if pkt.Unk2 == 0 {
case 3:
bf := byteframe.NewByteFrame()
bf.WriteUint16(uint16(len(paperMissions.Timetables)))
bf.WriteUint16(uint16(len(paperMissions.Data)))
@@ -1545,19 +1573,9 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint8(mdata.Reward2Quantity)
}
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} else {
for _, pdata := range paperData {
bf := byteframe.NewByteFrame()
bf.WriteUint16(pdata.Unk0)
bf.WriteInt16(pdata.Unk1)
bf.WriteInt16(pdata.Unk2)
bf.WriteInt16(pdata.Unk3)
bf.WriteInt16(pdata.Unk4)
bf.WriteInt16(pdata.Unk5)
bf.WriteInt16(pdata.Unk6)
data = append(data, bf)
}
doAckEarthSucceed(s, pkt.AckHandle, data)
default:
s.logger.Info("PaperData request for unknown type", zap.Uint32("Type", pkt.Type))
}
}

View File

@@ -3,10 +3,11 @@ package channelserver
import (
_config "erupe-ce/config"
"fmt"
"go.uber.org/zap"
"strings"
"time"
"go.uber.org/zap"
"erupe-ce/common/byteframe"
"erupe-ce/common/stringsupport"
"erupe-ce/network/mhfpacket"
@@ -392,6 +393,8 @@ func handleMsgMhfPresentBox(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPresentBox)
var data []*byteframe.ByteFrame
/*
bf := byteframe.NewByteFrame()
bf.WriteUint32(0)
bf.WriteInt32(0)
bf.WriteInt32(0)
@@ -403,6 +406,7 @@ func handleMsgMhfPresentBox(s *Session, p mhfpacket.MHFPacket) {
bf.WriteInt32(0)
bf.WriteInt32(0)
bf.WriteInt32(0)
data = append(data, bf)
*/
doAckEarthSucceed(s, pkt.AckHandle, data)
}