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

134 lines
4.6 KiB
Go

package dnfbridge
import (
"errors"
"fmt"
"longheng.io/server/internal/modules/dnf/worldmap"
)
var errTournamentObjectKeyRange = errors.New("dnf tournament actor object key exceeds current EXE range")
func (s *Service) prepareCurrentTournamentRuntime(
table *worldmap.Table,
dungeon worldmap.Dungeon,
scene worldmap.DungeonRoomScene,
nextObjectKey uint32,
) (*worldmap.TournamentRuntime, uint32, error) {
if dungeon.Metadata.Flags == nil || !dungeon.Metadata.Flags["tournament dungeon"] {
return nil, nextObjectKey, nil
}
if table == nil || scene.Map.Map.ID <= 0 {
return nil, nextObjectKey, errTournamentProtocolRuntime
}
definition, err := table.TournamentDefinition(dungeon.ID, scene.Map.Map.ID, 1, nil)
if err != nil {
return nil, nextObjectKey, err
}
tournament, err := worldmap.NewTournamentRuntime(definition, s.chooseDungeonIndex)
if err != nil {
return nil, nextObjectKey, err
}
if nextObjectKey == 0 || nextObjectKey > uint32(^uint16(0)) ||
len(tournament.PathActors) == 0 ||
nextObjectKey+uint32(len(tournament.PathActors))-1 > uint32(^uint16(0)) {
return nil, nextObjectKey, fmt.Errorf("%w: first=%d count=%d", errTournamentObjectKeyRange, nextObjectKey, len(tournament.PathActors))
}
if !tournament.BindFirstActorSequence(uint16(nextObjectKey)) {
return nil, nextObjectKey, fmt.Errorf("%w: first=%d", errTournamentObjectKeyRange, nextObjectKey)
}
return tournament, nextObjectKey + uint32(len(tournament.PathActors)), nil
}
// appendCurrentTournamentActors materializes the four PVF-selected path
// opponents in the ordinary op29 actor table. They are deliberately extended
// actors without a HostileReference: tournament progress is owned by
// TournamentRuntime, not by ordinary room-clear accounting.
func appendCurrentTournamentActors(
plan *runtimeDungeonExtendedActorPlan,
runtime *worldmap.TournamentRuntime,
) error {
if plan == nil || runtime == nil {
return nil
}
first := runtime.FirstActorSequence()
if first == 0 || len(runtime.PathActors) == 0 {
return worldmap.ErrTournamentSequenceUnbound
}
if plan.NextObjectKey != uint32(first) {
return fmt.Errorf("tournament actor sequence does not match extended plan: first=%d next=%d", first, plan.NextObjectKey)
}
for index, actor := range runtime.PathActors {
objectKey := uint32(first) + uint32(index)
packet := currentDungeonStartMapActor{
PacketIndex: uint32(index),
ObjectKey: uint16(objectKey),
Code: actor.Code,
Level: actor.Level,
Type: actor.Type,
}
if objectKey == 0 || objectKey > uint32(^uint16(0)) {
return fmt.Errorf("%w: object_key=%d", errTournamentObjectKeyRange, objectKey)
}
plan.Actors = append(plan.Actors, runtimeDungeonExtendedActor{
Kind: runtimeDungeonActorTournament,
ObjectKey: objectKey,
Packet: packet,
State: runtimeDungeonMonsterPlanned,
})
}
plan.NextObjectKey += uint32(len(runtime.PathActors))
return nil
}
func (s *Service) sendCurrentTournamentEntryProjection(
session *gameSession,
runtime *runtimeDungeonState,
scene worldmap.DungeonRoomScene,
) error {
if runtime == nil || runtime.tournament == nil {
return nil
}
infoBody, err := buildCurrentTournamentInfoBody(runtime.tournament, runtime.Request.Difficulty)
if err != nil {
return err
}
if scene.Coordinate.X < 0 || scene.Coordinate.X > 0xff || scene.Coordinate.Y < 0 || scene.Coordinate.Y > 0xff {
return fmt.Errorf("%w: room=%s", errDungeonStartMapCoordinateRange, scene.Coordinate)
}
mapBody, err := (currentTournamentMapInfo{
RoomX: byte(scene.Coordinate.X),
RoomY: byte(scene.Coordinate.Y),
Seed: runtime.Seed,
RoomState: 0,
Operation: 1,
MapID: runtime.tournament.Definition.MapID,
}).Build()
if err != nil {
return err
}
if err := s.sendGameUpperRawClass(session, currentTournamentInfoNotification, infoBody, 0); err != nil {
return err
}
if err := s.sendGameUpperRawClass(session, currentTournamentMapInfoNotification, mapBody, 0); err != nil {
return err
}
s.logGameEvent(session, "game-tournament-entry-projection-sent",
"dungeon_id", runtime.Dungeon.ID,
"map_id", scene.Map.Map.ID,
"room", scene.Coordinate.String(),
"first_actor_sequence", runtime.tournament.FirstActorSequence(),
"path_actor_count", len(runtime.tournament.PathActors),
"op386_body_len", len(infoBody),
"op387_body_len", len(mapBody),
"sequence", "current_exe_op28_op29_then_op386_op387")
return nil
}
func currentTournamentDeathResponseKind(actor worldmap.TournamentActor) currentDungeonDeathResponseKind {
if actor.Kind == worldmap.TournamentActorAICharacter {
return currentDungeonDeathResponseAICharacter
}
return currentDungeonDeathResponseMonster
}