mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
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).
32 lines
947 B
Go
32 lines
947 B
Go
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
|
|
}
|