mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 15:43:49 +01:00
Remove 51 panic() calls from handler code and replace with: - Proper error logging using zap - Appropriate client error responses (doAckBufFail, doAckSimpleFail) - Graceful error recovery instead of server crashes Files updated: - handlers_guild_scout.go (9 panics) - handlers_guild_tresure.go (10 panics) - handlers_guild.go (7 panics + dead code removal) - handlers_mail.go (5 panics) - handlers.go (9 panics) - handlers_tower.go (2 panics) - handlers_clients.go (3 panics) - handlers_guild_alliance.go (1 panic) - handlers_quest.go (1 panic) - handlers_rengoku.go (1 panic) - handlers_stage.go (1 panic) - handlers_data.go (1 panic) - handlers_cafe.go (1 panic) - signserver/sign_server.go (1 panic) Remaining panics (3) are in test files and compression library where panicking on programming errors is appropriate.
108 lines
5.3 KiB
Go
108 lines
5.3 KiB
Go
package channelserver
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"erupe-ce/network/mhfpacket"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func handleMsgMhfGetTowerInfo(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfGetTowerInfo)
|
|
var data []byte
|
|
var err error
|
|
/*
|
|
type:
|
|
1 == TOWER_RANK_POINT,
|
|
2 == GET_OWN_TOWER_SKILL
|
|
3 == GET_OWN_TOWER_LEVEL_V3
|
|
4 == TOWER_TOUHA_HISTORY
|
|
5 = ?
|
|
|
|
[] = type
|
|
req
|
|
resp
|
|
|
|
01 1d 01 fc 00 09 [00 00 00 01] 00 00 00 02 00 00 00 00
|
|
00 12 01 fc 00 09 01 00 00 18 0a 21 8e ad 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
|
|
|
|
01 1d 01 fc 00 0a [00 00 00 02] 00 00 00 00 00 00 00 00
|
|
00 12 01 fc 00 0a 01 00 00 94 0a 21 8e ad 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
01 1d 01 ff 00 0f [00 00 00 04] 00 00 00 00 00 00 00 00
|
|
00 12 01 ff 00 0f 01 00 00 24 0a 21 8e ad 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
01 1d 01 fc 00 0b [00 00 00 05] 00 00 00 00 00 00 00 00
|
|
00 12 01 fc 00 0b 01 00 00 10 0a 21 8e ad 00 00 00 00 00 00 00 00 00 00 00 00
|
|
*/
|
|
switch pkt.InfoType {
|
|
case mhfpacket.TowerInfoTypeTowerRankPoint:
|
|
data, err = hex.DecodeString("0A218EAD0000000000000000000000010000000000000000")
|
|
case mhfpacket.TowerInfoTypeGetOwnTowerSkill:
|
|
//data, err = hex.DecodeString("0A218EAD000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
|
data, err = hex.DecodeString("0A218EAD0000000000000000000000010000001C0000000500050000000000020000000000000000000000000000000000030003000000000003000500050000000300030003000300030003000200030001000300020002000300010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
|
case mhfpacket.TowerInfoTypeGetOwnTowerLevelV3:
|
|
// TODO: No known response values for GetOwnTowerLevelV3
|
|
stubGetNoResults(s, pkt.AckHandle)
|
|
return
|
|
case mhfpacket.TowerInfoTypeTowerTouhaHistory:
|
|
data, err = hex.DecodeString("0A218EAD0000000000000000000000010000000000000000000000000000000000000000")
|
|
case mhfpacket.TowerInfoTypeUnk5:
|
|
data, err = hex.DecodeString("0A218EAD000000000000000000000000")
|
|
}
|
|
|
|
if err != nil {
|
|
stubGetNoResults(s, pkt.AckHandle)
|
|
}
|
|
doAckBufSucceed(s, pkt.AckHandle, data)
|
|
}
|
|
|
|
func handleMsgMhfPostTowerInfo(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfPostTowerInfo)
|
|
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
|
}
|
|
|
|
func handleMsgMhfGetTenrouirai(s *Session, p mhfpacket.MHFPacket) {
|
|
// if the game gets bad responses for this it breaks the ability to save
|
|
pkt := p.(*mhfpacket.MsgMhfGetTenrouirai)
|
|
var data []byte
|
|
var err error
|
|
if pkt.Unk0 == 1 {
|
|
data, err = hex.DecodeString("0A218EAD000000000000000000000001010000000000060010")
|
|
} else if pkt.Unk2 == 4 {
|
|
data, err = hex.DecodeString("0A218EAD0000000000000000000000210101005000000202010102020104001000000202010102020106003200000202010002020104000C003202020101020201030032000002020101020202059C4000000202010002020105C35000320202010102020201003C00000202010102020203003200000201010001020203002800320201010101020204000C00000201010101020206002800000201010001020101003C00320201020101020105C35000000301020101020106003200000301020001020104001000320301020101020105C350000003010201010202030028000003010200010201030032003203010201010202059C4000000301020101010206002800000301020001010201003C00320301020101010206003200000301020101010204000C000003010200010101010050003203010201010101059C40000003010201010101030032000003010200010101040010003203010001010101060032000003010001010102030028000003010001010101010050003203010000010102059C4000000301000001010206002800000301000001010010")
|
|
} else {
|
|
data = []byte{0x00, 0x00, 0x00, 0x00}
|
|
s.logger.Info("GET_TENROUIRAI request for unknown type")
|
|
}
|
|
if err != nil {
|
|
s.logger.Error("failed to decode tenrouirai hex data", zap.Error(err))
|
|
doAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
|
return
|
|
}
|
|
doAckBufSucceed(s, pkt.AckHandle, data)
|
|
}
|
|
|
|
func handleMsgMhfPostTenrouirai(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfPostTenrouirai)
|
|
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
|
}
|
|
|
|
func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) {}
|
|
|
|
func handleMsgMhfGetWeeklySeibatuRankingReward(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfGetWeeklySeibatuRankingReward)
|
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
|
}
|
|
|
|
func handleMsgMhfPresentBox(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfPresentBox)
|
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
|
}
|
|
|
|
func handleMsgMhfGetGemInfo(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgMhfGetGemInfo)
|
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
|
}
|
|
|
|
func handleMsgMhfPostGemInfo(s *Session, p mhfpacket.MHFPacket) {}
|