mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 10:03:06 +01:00
refactor(channelserver): split handlers.go into goocoo, scenario, and misc files
Replace the grab-bag handlers.go with thematically organized files: - handlers_goocoo.go: Goocoo/Guacot pet handlers - handlers_scenario.go: Scenario counter struct and handler - handlers_misc.go: remaining unrelated handlers (etc points, earth, equip skin history, trend weapons, minidata, lobby crowd, etc.)
This commit is contained in:
58
server/channelserver/handlers_scenario.go
Normal file
58
server/channelserver/handlers_scenario.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package channelserver
|
||||
|
||||
import (
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network/mhfpacket"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Scenario struct {
|
||||
MainID uint32
|
||||
// 0 = Basic
|
||||
// 1 = Veteran
|
||||
// 3 = Other
|
||||
// 6 = Pallone
|
||||
// 7 = Diva
|
||||
CategoryID uint8
|
||||
}
|
||||
|
||||
func handleMsgMhfInfoScenarioCounter(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfInfoScenarioCounter)
|
||||
var scenarios []Scenario
|
||||
var scenario Scenario
|
||||
scenarioData, err := s.server.db.Queryx("SELECT scenario_id, category_id FROM scenario_counter")
|
||||
if err != nil {
|
||||
_ = scenarioData.Close()
|
||||
s.logger.Error("Failed to get scenario counter info from db", zap.Error(err))
|
||||
doAckBufSucceed(s, pkt.AckHandle, make([]byte, 1))
|
||||
return
|
||||
}
|
||||
for scenarioData.Next() {
|
||||
err = scenarioData.Scan(&scenario.MainID, &scenario.CategoryID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
scenarios = append(scenarios, scenario)
|
||||
}
|
||||
|
||||
// Trim excess scenarios
|
||||
if len(scenarios) > 128 {
|
||||
scenarios = scenarios[:128]
|
||||
}
|
||||
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint8(uint8(len(scenarios)))
|
||||
for _, scenario := range scenarios {
|
||||
bf.WriteUint32(scenario.MainID)
|
||||
// If item exchange
|
||||
switch scenario.CategoryID {
|
||||
case 3, 6, 7:
|
||||
bf.WriteBool(true)
|
||||
default:
|
||||
bf.WriteBool(false)
|
||||
}
|
||||
bf.WriteUint8(scenario.CategoryID)
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
Reference in New Issue
Block a user