DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,157 @@
|
||||
package dnfbridge
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"longheng.io/server/internal/modules/dnf/worldmap"
|
||||
)
|
||||
|
||||
func TestBuildCurrentDungeonDeathNotificationBodyMatchesCurrentEXEOp38ZeroDropReader(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
objectKey uint32
|
||||
kind currentDungeonDeathResponseKind
|
||||
want []byte
|
||||
}{
|
||||
{name: "tutorial target 402", objectKey: 402, kind: currentDungeonDeathResponseMonster, want: []byte{0x92, 0x01, 0, 0, 0, 0xff, 0}},
|
||||
{name: "hostile AI character 403", objectKey: 403, kind: currentDungeonDeathResponseAICharacter, want: []byte{0x93, 0x01, 0, 0, 0, 0xff, 0}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
body, err := buildCurrentDungeonDeathNotificationBody(test.objectKey, test.kind)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(body, test.want) {
|
||||
t.Fatalf("body=%x want=%x", body, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
if _, err := buildCurrentDungeonDeathNotificationBody(402, "future"); !errors.Is(err, errDungeonDeathResponseKind) {
|
||||
t.Fatalf("unsupported kind error=%v", err)
|
||||
}
|
||||
for _, objectKey := range []uint32{0, 1 << 16} {
|
||||
if _, err := buildCurrentDungeonDeathNotificationBody(objectKey, currentDungeonDeathResponseMonster); !errors.Is(err, errDungeonDeathResponseKeyRange) {
|
||||
t.Fatalf("object key %d error=%v", objectKey, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildCurrentDungeonDeathNotificationBodyCarriesOptionalStoryRoom(t *testing.T) {
|
||||
body, err := buildCurrentDungeonDeathNotificationBodyWithDrops(
|
||||
402,
|
||||
currentDungeonDeathResponseMonster,
|
||||
nil,
|
||||
worldmap.RoomCoordinate{X: 4, Y: 0},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []byte{0x92, 0x01, 0, 0, 0, 0xff, 1, 4, 0}
|
||||
if !bytes.Equal(body, want) {
|
||||
t.Fatalf("story-room body=%x want=%x", body, want)
|
||||
}
|
||||
if _, err := buildCurrentDungeonDeathNotificationBodyWithDrops(
|
||||
402,
|
||||
currentDungeonDeathResponseMonster,
|
||||
nil,
|
||||
worldmap.RoomCoordinate{X: 256},
|
||||
); !errors.Is(err, errDungeonDeathRoomCoordinateRange) {
|
||||
t.Fatalf("out-of-range story room error=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildCurrentDungeonDeathNotificationBodyWithDropMatchesCurrentEXEOp38Reader(t *testing.T) {
|
||||
definition := dungeonDropItemDefinition{
|
||||
ItemID: 9001,
|
||||
Kind: dungeonDropItemEquipment,
|
||||
PVFPath: "equipment/weapon/test_sword.equ",
|
||||
Durability: 57,
|
||||
}
|
||||
const qualitySeed = uint32(345678901)
|
||||
itemState, err := currentDungeonDeathDropItemState(21, definition, 1, qualitySeed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body, err := buildCurrentDungeonDeathNotificationBodyWithDrops(
|
||||
402,
|
||||
currentDungeonDeathResponseMonster,
|
||||
[]currentDungeonDeathDropWire{{
|
||||
SceneObjectKey: 0x44332211,
|
||||
Item: itemState,
|
||||
UnknownTailSentinel: 0x6655,
|
||||
OwnerActorObjectKey: 401,
|
||||
}},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want := currentDungeonZeroDropDeathBodySize + currentDungeonDeathDropWireSize; len(body) != want {
|
||||
t.Fatalf("body len=%d want=%d", len(body), want)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint16(body[0:2]); got != 402 || body[2] != 1 {
|
||||
t.Fatalf("header target=%d count=%d", got, body[2])
|
||||
}
|
||||
if got := binary.LittleEndian.Uint32(body[3:7]); got != 0x44332211 {
|
||||
t.Fatalf("prefix=%#x", got)
|
||||
}
|
||||
itemOffset := 7
|
||||
if got := binary.LittleEndian.Uint16(body[itemOffset : itemOffset+2]); got != 21 {
|
||||
t.Fatalf("scene slot=%d", got)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint32(body[itemOffset+2 : itemOffset+6]); got != 9001 {
|
||||
t.Fatalf("item id=%d", got)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint32(body[itemOffset+6 : itemOffset+10]); got != qualitySeed {
|
||||
t.Fatalf("quality seed=%d want=%d", got, qualitySeed)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint16(body[itemOffset+0x0B : itemOffset+0x0D]); got != 57 {
|
||||
t.Fatalf("durability=%d", got)
|
||||
}
|
||||
tailOffset := itemOffset + currentItemListEntryWireSize
|
||||
if got := binary.LittleEndian.Uint16(body[tailOffset : tailOffset+2]); got != 0x6655 {
|
||||
t.Fatalf("tail value=%#x", got)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint16(body[tailOffset+2 : tailOffset+4]); got != 401 {
|
||||
t.Fatalf("owner actor object key=%d", got)
|
||||
}
|
||||
if got, want := body[len(body)-4:], []byte{0, 0, 0xff, 0}; !bytes.Equal(got, want) {
|
||||
t.Fatalf("tail=%x want=%x", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCurrentDungeonDeathDropBuilderRejectsInvalidRowsAndCount(t *testing.T) {
|
||||
if _, err := currentDungeonDeathDropItemState(0, dungeonDropItemDefinition{ItemID: 100, Kind: dungeonDropItemStackable}, 1); !errors.Is(err, errDungeonDeathDropItemInvalid) {
|
||||
t.Fatalf("zero scene slot error=%v", err)
|
||||
}
|
||||
goldState, err := currentDungeonDeathDropItemState(1, dungeonDropItemDefinition{Kind: dungeonDropItemStackable}, 7)
|
||||
if err != nil {
|
||||
t.Fatalf("gold item row rejected: %v", err)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint32(goldState.data[0x02:0x06]); got != 0 {
|
||||
t.Fatalf("gold item id=%d want 0", got)
|
||||
}
|
||||
if got := binary.LittleEndian.Uint32(goldState.data[0x06:0x0A]); got != 7 {
|
||||
t.Fatalf("gold amount=%d want 7", got)
|
||||
}
|
||||
if _, err := currentDungeonDeathDropItemState(1, dungeonDropItemDefinition{ItemID: 100, Kind: dungeonDropItemStackable}, 0); !errors.Is(err, errDungeonDeathDropItemInvalid) {
|
||||
t.Fatalf("zero amount error=%v", err)
|
||||
}
|
||||
if _, err := buildCurrentDungeonDeathNotificationBodyWithDrops(
|
||||
402,
|
||||
currentDungeonDeathResponseMonster,
|
||||
make([]currentDungeonDeathDropWire, 256),
|
||||
); !errors.Is(err, errDungeonDeathDropCountRange) {
|
||||
t.Fatalf("drop count error=%v", err)
|
||||
}
|
||||
if _, err := buildCurrentDungeonDeathNotificationBodyWithDrops(
|
||||
402,
|
||||
currentDungeonDeathResponseMonster,
|
||||
[]currentDungeonDeathDropWire{{}},
|
||||
); !errors.Is(err, errDungeonDeathDropItemInvalid) {
|
||||
t.Fatalf("empty item row error=%v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user