Files

92 lines
3.2 KiB
Go

package gameserver
import (
"fmt"
"gac-hkrpg-go/internal/common"
goproto "gac-hkrpg-go/protocol/proto"
)
// UI requests bound to the command names in the loaded protocol.
func init() {
// client pauses itself when opening menus/map — must be acked
handle("SetClientPaused", func(s *Session, req *goproto.SetClientPausedCsReq, rsp *goproto.SetClientPausedScRsp) error {
rsp.Retcode = 0
rsp.Paused = req.Paused
return nil
})
// The Endgame entrance waits for this response before opening its UI.
handle("GetUnreleasedBlockInfo", func(s *Session, req *goproto.GetUnreleasedBlockInfoCsReq, rsp *goproto.GetUnreleasedBlockInfoScRsp) error {
rsp.Retcode = 0
return nil
})
handle("TakeQuestReward", func(s *Session, req *goproto.TakeQuestRewardCsReq, rsp *goproto.TakeQuestRewardScRsp) error {
rsp.Retcode = 0
rsp.SuccQuestIdList = req.SuccQuestIdList
return nil
})
handle("GetFirstTalkNpc", func(s *Session, req *goproto.GetFirstTalkNpcCsReq, rsp *goproto.GetFirstTalkNpcScRsp) error {
rsp.Retcode = 0
return nil
})
handle("QuitBattle", func(s *Session, req *goproto.QuitBattleCsReq, rsp *goproto.QuitBattleScRsp) error {
rsp.Retcode = 0
if req.Stt != nil {
report := common.BattleReportFromStatistics(req.Stt, 0, 0, "QUIT")
if err := common.SaveBattleReport(report); err != nil {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Failed to save quit battle report: %v", err))
} else {
Log(fmt.Sprintf("[DAMAGE_ANALYST] Quit battle report captured: Dmg=%.1f Cycles=%d Turns=%d",
report.TeamTotalDamage, report.RoundCnt, report.TotalBattleTurns))
}
}
return nil
})
// NOTE: GetMapRotationData (6827) must NOT be answered with an empty
// ScRsp - the client enters map-rotation mode with a null state and NREs
// in AdventurePhase._EnterStep1_InitializeMapInfo (no scene load).
// Implement real RotaterData before answering this one.
handle("GetPamSkinData", func(s *Session, req *goproto.GetPamSkinDataCsReq, rsp *goproto.GetPamSkinDataScRsp) error {
profile, err := loadProfileResources()
if err != nil {
return err
}
rsp.CurSkin = profile.CurrentPamSkin
rsp.UnlockSkinList = append([]uint32(nil), profile.PamSkins...)
SceneDebugLog("GET_PAM_SKIN current=%d owned=%v", rsp.CurSkin, rsp.UnlockSkinList)
return nil
})
handle("GetAllServerPrefsData", func(s *Session, req *goproto.GetAllServerPrefsDataCsReq, rsp *goproto.GetAllServerPrefsDataScRsp) error {
rsp.Retcode = 0
return nil
})
handle("UpdateServerPrefsData", func(s *Session, req *goproto.UpdateServerPrefsDataCsReq, rsp *goproto.UpdateServerPrefsDataScRsp) error {
rsp.Retcode = 0
return nil
})
// simple empty-but-valid data replies (auto-empty also covers these, but
// keeping them explicit documents that they are safe to answer)
handle("GetHeartDialInfo", func(s *Session, req *goproto.GetHeartDialInfoCsReq, rsp *goproto.GetHeartDialInfoScRsp) error {
rsp.Retcode = 0
return nil
})
handle("GetPetData", func(s *Session, req *goproto.GetPetDataCsReq, rsp *goproto.GetPetDataScRsp) error {
rsp.Retcode = 0
return nil
})
handle("GetShopList", func(s *Session, req *goproto.GetShopListCsReq, rsp *goproto.GetShopListScRsp) error {
rsp.Retcode = 0
return nil
})
}