mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 10:32:55 +01:00
feat(protbot): add headless MHF protocol bot as cmd/protbot
Copy MHBridge into the Erupe module as cmd/protbot/ so it can be built, tested, and maintained alongside the server. The bot implements the full sign → entrance → channel login flow and supports lobby entry, chat, session setup, and quest enumeration. The conn/ package keeps its own Blowfish crypto primitives to avoid importing erupe-ce/config (which requires a config file at init).
This commit is contained in:
31
cmd/protbot/scenario/quest.go
Normal file
31
cmd/protbot/scenario/quest.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package scenario
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"erupe-ce/cmd/protbot/protocol"
|
||||
)
|
||||
|
||||
// EnumerateQuests sends MSG_MHF_ENUMERATE_QUEST and returns the raw quest list data.
|
||||
func EnumerateQuests(ch *protocol.ChannelConn, world uint8, counter uint16) ([]byte, error) {
|
||||
ack := ch.NextAckHandle()
|
||||
pkt := protocol.BuildEnumerateQuestPacket(ack, world, counter, 0)
|
||||
fmt.Printf("[quest] Sending MSG_MHF_ENUMERATE_QUEST (world=%d, counter=%d, ackHandle=%d)...\n",
|
||||
world, counter, ack)
|
||||
if err := ch.SendPacket(pkt); err != nil {
|
||||
return nil, fmt.Errorf("enumerate quest send: %w", err)
|
||||
}
|
||||
|
||||
resp, err := ch.WaitForAck(ack, 15*time.Second)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("enumerate quest ack: %w", err)
|
||||
}
|
||||
if resp.ErrorCode != 0 {
|
||||
return nil, fmt.Errorf("enumerate quest failed: error code %d", resp.ErrorCode)
|
||||
}
|
||||
fmt.Printf("[quest] ENUMERATE_QUEST ACK (error=%d, %d bytes data)\n",
|
||||
resp.ErrorCode, len(resp.Data))
|
||||
|
||||
return resp.Data, nil
|
||||
}
|
||||
Reference in New Issue
Block a user