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,97 @@
|
||||
package pvf
|
||||
|
||||
import "fmt"
|
||||
|
||||
func (a *Archive) readTextIndex(idx int) (string, error) {
|
||||
if cached, ok := a.texts.get(idx); ok {
|
||||
return cached.(string), nil
|
||||
}
|
||||
value, err := a.textFlights.do(idx, func() (any, error) {
|
||||
if cached, ok := a.texts.get(idx); ok {
|
||||
return cached.(string), nil
|
||||
}
|
||||
raw, err := a.readRawIndex(idx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var text string
|
||||
switch a.items[idx].dataType {
|
||||
case 1:
|
||||
text = a.decodeScript(raw)
|
||||
case 3:
|
||||
text = decodeUTF16LE(raw)
|
||||
default:
|
||||
text = ""
|
||||
}
|
||||
a.texts.add(idx, text, int64(len(text)))
|
||||
return text, nil
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return value.(string), nil
|
||||
}
|
||||
|
||||
func (a *Archive) readRawIndex(idx int) ([]byte, error) {
|
||||
if idx < 0 || idx >= len(a.items) {
|
||||
return nil, fmt.Errorf("%w: file index %d", ErrFileNotFound, idx)
|
||||
}
|
||||
item := a.items[idx]
|
||||
chunk, err := a.chunk(item.chunkIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if item.dataOffset < 0 || item.dataSize < 0 || item.dataOffset+item.dataSize > len(chunk) {
|
||||
return nil, fmt.Errorf("%w: file %d data range is invalid", ErrInvalidArchive, idx)
|
||||
}
|
||||
out := make([]byte, item.dataSize)
|
||||
copy(out, chunk[item.dataOffset:item.dataOffset+item.dataSize])
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *Archive) chunk(idx int) ([]byte, error) {
|
||||
if idx < 0 || idx >= len(a.groups) {
|
||||
return nil, fmt.Errorf("%w: chunk %d is out of range", ErrInvalidArchive, idx)
|
||||
}
|
||||
if cached, ok := a.chunks.get(idx); ok {
|
||||
return cached.([]byte), nil
|
||||
}
|
||||
value, err := a.chunkFlights.do(idx, func() (any, error) {
|
||||
if cached, ok := a.chunks.get(idx); ok {
|
||||
return cached.([]byte), nil
|
||||
}
|
||||
prev := 0
|
||||
if idx > 0 {
|
||||
prev = a.groups[idx-1].compressedSize
|
||||
}
|
||||
curr := a.groups[idx].compressedSize
|
||||
if curr <= prev {
|
||||
return nil, fmt.Errorf("%w: chunk %d compressed range is invalid", ErrInvalidArchive, idx)
|
||||
}
|
||||
start := a.bodyOff + prev
|
||||
size := curr - prev
|
||||
if start < 0 || size <= 0 || start+size > len(a.data) {
|
||||
return nil, fmt.Errorf("%w: chunk %d exceeds archive", ErrInvalidArchive, idx)
|
||||
}
|
||||
encrypted := append([]byte(nil), a.data[start:start+size]...)
|
||||
switch a.format {
|
||||
case FormatProtectedNKPI:
|
||||
decryptProtected("bODy", encrypted)
|
||||
default:
|
||||
decrypt("BodY", encrypted)
|
||||
}
|
||||
chunk, err := zlibBytes(encrypted)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: chunk %d decompress: %w", ErrInvalidArchive, idx, err)
|
||||
}
|
||||
if want := a.groups[idx].originalSize; want >= 0 && want != len(chunk) {
|
||||
return nil, fmt.Errorf("%w: chunk %d original size mismatch: want %d got %d", ErrInvalidArchive, idx, want, len(chunk))
|
||||
}
|
||||
a.chunks.add(idx, chunk, int64(len(chunk)))
|
||||
return chunk, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return value.([]byte), nil
|
||||
}
|
||||
Reference in new issue
Block a user