Files
hanfuit 645b64fe21 DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go):
- GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面
- GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新
- 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新)
- 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍
- 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0)
- 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算

启动器(Python/JS):
- 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭
- GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐)
- 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
2026-11-04 14:31:55 +08:00

69 lines
2.3 KiB
Go

package protocol
import (
"encoding/binary"
"errors"
)
const (
DprotoServerControlOpcode = uint16(1466)
DprotoServerEnvelopeOpcode = uint16(1467)
DprotoClientEnvelopeOpcode = uint16(1517)
DprotoCallbackOpcode = uint16(1518)
)
var (
ErrDprotoEnvelopeOpcode = errors.New("dnf dproto envelope opcode is invalid")
ErrDprotoEnvelopeBody = errors.New("dnf dproto envelope body is invalid")
ErrDprotoProtectedSize = errors.New("dnf dproto protected payload length is invalid")
)
// DprotoClientEnvelope is the verified C2S class1/op1517 outer packet. The
// protected bytes remain opaque until a real server-role provider consumes
// the complete Raw packet and its per-connection session state.
type DprotoClientEnvelope struct {
Header ChannelHeader
Protected []byte
Raw []byte
}
// ParseDprotoClientEnvelope verifies the ordinary outer upper checksum and
// the u32 protected-length field observed at body offset zero.
func ParseDprotoClientEnvelope(raw []byte, maxProtectedBytes int) (DprotoClientEnvelope, error) {
packet, err := ParseChannelPacket(raw)
if err != nil {
return DprotoClientEnvelope{}, err
}
if packet.Header.Classification != DefaultChannelClassification ||
packet.Header.MsgID != DprotoClientEnvelopeOpcode {
return DprotoClientEnvelope{}, ErrDprotoEnvelopeOpcode
}
if len(packet.Body) < 4 {
return DprotoClientEnvelope{}, ErrDprotoEnvelopeBody
}
protectedLength := int(binary.LittleEndian.Uint32(packet.Body[:4]))
if protectedLength <= 0 || protectedLength != len(packet.Body)-4 {
return DprotoClientEnvelope{}, ErrDprotoProtectedSize
}
if maxProtectedBytes > 0 && protectedLength > maxProtectedBytes {
return DprotoClientEnvelope{}, ErrPacketTooLarge
}
return DprotoClientEnvelope{
Header: packet.Header,
Protected: cloneBytes(packet.Body[4:]),
Raw: cloneBytes(raw),
}, nil
}
// BuildDprotoClientEnvelope exists for provider integration tests and native
// transport fixtures. Production C2S envelopes are built by the client.
func BuildDprotoClientEnvelope(protected []byte, seq uint16) ([]byte, error) {
if len(protected) == 0 {
return nil, ErrDprotoProtectedSize
}
body := make([]byte, 4+len(protected))
binary.LittleEndian.PutUint32(body[:4], uint32(len(protected)))
copy(body[4:], protected)
return BuildChannelPacket(DprotoClientEnvelopeOpcode, body, seq, DefaultChannelClassification)
}