Files
Erupe/server/channelserver/handlers_scenario.go
Houmgaor 9e8dc034be 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.)
2026-02-18 19:42:59 +01:00

59 lines
1.3 KiB
Go

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())
}