Files
90CNServer/server/internal/services/dnfbridge/dungeon_runtime_memory_test.go
T
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

67 lines
2.8 KiB
Go

package dnfbridge
import (
"testing"
"longheng.io/server/internal/modules/dnf/worldmap"
)
func TestDungeonRuntimeMemorySnapshotDeduplicatesPartyRuntime(t *testing.T) {
runtime := &runtimeDungeonState{
Dungeon: worldmap.Dungeon{ID: 1234},
Rooms: map[runtimeDungeonRoomKey]*runtimeDungeonRoomVisit{
{X: 1}: {},
},
LayerChains: make(map[worldmap.RoomCoordinate]*runtimeDungeonLayerChain),
}
first := &gameSession{selectedCharacterID: 19}
second := &gameSession{selectedCharacterID: 20}
first.dungeon.runtime = runtime
second.dungeon.runtime = runtime
service := &Service{gameSessions: map[uint16]*gameSession{19: first, 20: second}}
snapshot := service.dungeonRuntimeMemorySnapshot()
if snapshot.OnlineSessions != 2 || snapshot.ActiveRuntimes != 1 ||
snapshot.TotalRooms != 1 || snapshot.TotalLayerChains != 0 ||
snapshot.PayloadRuntimes != 1 {
t.Fatalf("unexpected runtime snapshot: %+v", snapshot)
}
}
func TestReleaseDungeonRuntimePayloadDropsLargeRunState(t *testing.T) {
beforeReleases := dungeonRuntimePayloadReleaseCount.Load()
runtime := &runtimeDungeonState{
Rooms: make(map[runtimeDungeonRoomKey]*runtimeDungeonRoomVisit),
Room: &runtimeDungeonRoom{},
LayerChains: make(map[worldmap.RoomCoordinate]*runtimeDungeonLayerChain),
StoryStages: []worldmap.DungeonStoryStage{{}},
DropOwner: &runtimeDungeonDropOwner{},
HellParty: &currentDungeonHellPartyOwner{},
partyDungeonOwner: &runtimePartyDungeonOwner{},
settlementPlayResultBody: []byte{1},
settlementStatisticBody: []byte{2},
partyCardSelectionPending: [][]byte{{3}},
settlementMonsterExperienceByObjectKey: map[uint32]uint32{4: 5},
clearMapCompletionQuestIDs: []int64{6},
}
session := &worldmap.DungeonSession{}
runtime.Session = session
releaseDungeonRuntimePayload(runtime)
if runtime.Rooms != nil || runtime.Room != nil || runtime.LayerChains != nil || runtime.StoryStages != nil ||
runtime.DropOwner != nil || runtime.HellParty != nil || runtime.partyDungeonOwner != nil ||
runtime.settlementPlayResultBody != nil || runtime.settlementStatisticBody != nil ||
runtime.partyCardSelectionPending != nil || runtime.settlementMonsterExperienceByObjectKey != nil ||
runtime.clearMapCompletionQuestIDs != nil {
t.Fatalf("large runtime payload retained: %+v", runtime)
}
if runtime.Session != session {
t.Fatal("post-detach session pointer was cleared")
}
releaseDungeonRuntimePayload(runtime)
if got := dungeonRuntimePayloadReleaseCount.Load(); got != beforeReleases+1 {
t.Fatalf("release was not counted exactly once: before=%d after=%d", beforeReleases, got)
}
}