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,191 @@
|
||||
package worldmap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
dnfpvf "longheng.io/server/internal/modules/dnf/pvf"
|
||||
)
|
||||
|
||||
var ErrSourceRequired = errors.New("dnf worldmap source is required")
|
||||
|
||||
func LoadSource(ctx context.Context, source dnfpvf.Source, options Options) (*Table, error) {
|
||||
if source == nil {
|
||||
return nil, ErrSourceRequired
|
||||
}
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
table := &Table{
|
||||
mapByID: make(map[int64]int), mapByPath: make(map[string]int),
|
||||
areaByID: make(map[int64]int), areaByPath: make(map[string]int), areaByDungeon: make(map[int64]int),
|
||||
dungeonByID: make(map[int64]int), dungeonByPath: make(map[string]int),
|
||||
}
|
||||
if !options.SkipMaps {
|
||||
listPath := options.MapListPath
|
||||
if listPath == "" {
|
||||
listPath = DefaultMapList
|
||||
}
|
||||
entries, err := sourceList(source, listPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
docPath, doc, err := sourceDocument(source, listPath, entry.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parsed, err := parseMapWithImports(entry.ID, docPath, doc, func(candidate string) (string, *dnfpvf.Document, error) {
|
||||
text, err := source.ReadText(candidate)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
importDoc, err := ParseDocument(candidate, text)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return candidate, importDoc, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("load dnf worldmap map %q: %w", docPath, err)
|
||||
}
|
||||
if options.CompactRuntime {
|
||||
compactMapForRuntime(&parsed)
|
||||
}
|
||||
addMapToTable(table, parsed)
|
||||
}
|
||||
}
|
||||
if !options.SkipDungeons {
|
||||
listPath := options.DungeonListPath
|
||||
if listPath == "" {
|
||||
listPath = DefaultDungeonList
|
||||
}
|
||||
entries, err := sourceList(source, listPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
docPath, doc, err := sourceDocument(source, listPath, entry.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parsed := ParseDungeon(entry.ID, docPath, doc)
|
||||
if options.CompactRuntime {
|
||||
compactDungeonForRuntime(&parsed)
|
||||
}
|
||||
addDungeonToTable(table, parsed)
|
||||
}
|
||||
}
|
||||
if !options.SkipAreas {
|
||||
listPath := options.WorldMapListPath
|
||||
if listPath == "" {
|
||||
listPath = DefaultWorldMapList
|
||||
}
|
||||
entries, err := sourceList(source, listPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
docPath, doc, err := sourceDocument(source, listPath, entry.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parsed := ParseArea(entry.ID, docPath, doc)
|
||||
if options.CompactRuntime {
|
||||
compactAreaForRuntime(&parsed)
|
||||
}
|
||||
addAreaToTable(table, parsed)
|
||||
}
|
||||
}
|
||||
return table, nil
|
||||
}
|
||||
|
||||
func sourceList(source dnfpvf.Source, listPath string) ([]dnfpvf.ListEntry, error) {
|
||||
text, err := source.ReadText(listPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read dnf worldmap list %q: %w", listPath, err)
|
||||
}
|
||||
doc, err := ParseDocument(listPath, text)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entries := dnfpvf.ParseList(doc)
|
||||
if len(entries) == 0 {
|
||||
return nil, fmt.Errorf("%w: %s", ErrListEmpty, listPath)
|
||||
}
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func sourceDocument(source dnfpvf.Source, listPath, reference string) (string, *dnfpvf.Document, error) {
|
||||
docPath := resolveSourceReference(listPath, reference)
|
||||
text, err := source.ReadText(docPath)
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("read dnf worldmap document %q: %w", docPath, err)
|
||||
}
|
||||
doc, err := ParseDocument(docPath, text)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return docPath, doc, nil
|
||||
}
|
||||
|
||||
func resolveSourceReference(listPath, reference string) string {
|
||||
reference = strings.TrimSpace(strings.ReplaceAll(reference, "\\", "/"))
|
||||
reference = strings.TrimPrefix(reference, "./")
|
||||
reference = strings.TrimPrefix(reference, "/")
|
||||
listDirectory := strings.TrimSuffix(path.Dir(strings.ReplaceAll(listPath, "\\", "/")), "/")
|
||||
if listDirectory == "." || listDirectory == "" {
|
||||
return reference
|
||||
}
|
||||
if pathKey(reference) == pathKey(listDirectory) || strings.HasPrefix(pathKey(reference), pathKey(listDirectory)+"/") {
|
||||
return reference
|
||||
}
|
||||
return path.Join(listDirectory, reference)
|
||||
}
|
||||
|
||||
func addMapToTable(table *Table, parsed Map) {
|
||||
pos := len(table.maps)
|
||||
table.maps = append(table.maps, parsed)
|
||||
if _, exists := table.mapByID[parsed.ID]; !exists {
|
||||
table.mapByID[parsed.ID] = pos
|
||||
}
|
||||
table.mapByPath[pathKey(parsed.Path)] = pos
|
||||
}
|
||||
|
||||
func addDungeonToTable(table *Table, parsed Dungeon) {
|
||||
pos := len(table.dungeons)
|
||||
table.dungeons = append(table.dungeons, parsed)
|
||||
if _, exists := table.dungeonByID[parsed.ID]; !exists {
|
||||
table.dungeonByID[parsed.ID] = pos
|
||||
}
|
||||
table.dungeonByPath[pathKey(parsed.Path)] = pos
|
||||
}
|
||||
|
||||
func addAreaToTable(table *Table, parsed Area) {
|
||||
pos := len(table.areas)
|
||||
table.areas = append(table.areas, parsed)
|
||||
if _, exists := table.areaByID[parsed.ID]; !exists {
|
||||
table.areaByID[parsed.ID] = pos
|
||||
}
|
||||
table.areaByPath[pathKey(parsed.Path)] = pos
|
||||
for _, dungeon := range parsed.Dungeons {
|
||||
if dungeon.DungeonID <= 0 {
|
||||
continue
|
||||
}
|
||||
if _, exists := table.areaByDungeon[dungeon.DungeonID]; !exists {
|
||||
table.areaByDungeon[dungeon.DungeonID] = pos
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user