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,142 @@
|
||||
package dnfbridge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
)
|
||||
|
||||
func initialEquipmentRosterSummary(entries []initialEquipmentEntry) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if len(entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]dnfrepo.CharacterRosterEquipSummary, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
if entry.Slot <= 0 || entry.ItemID <= 0 {
|
||||
continue
|
||||
}
|
||||
out = append(out, dnfrepo.CharacterRosterEquipSummary{
|
||||
Slot: int64(entry.Slot),
|
||||
ItemIDOrIcon: entry.ItemID,
|
||||
RawEntry: append([]byte(nil), entry.RawEntry...),
|
||||
})
|
||||
}
|
||||
sortRosterEquipSummary(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func equipmentRosterSummary(record dnfrepo.EquipmentRecord) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if len(record.Entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]dnfrepo.CharacterRosterEquipSummary, 0, len(record.Entries))
|
||||
for _, entry := range record.Entries {
|
||||
if entry.SlotIndex < 0 || entry.ItemID <= 0 {
|
||||
continue
|
||||
}
|
||||
// The roster actor uses the same current appearance-slot table as mode0.
|
||||
// In particular, PVF starter equipment stores the old worn weapon slot 11,
|
||||
// while the current client renders a real weapon from appearance slot 12.
|
||||
// Sending the old value makes the client keep its job-default weapon layer
|
||||
// and add the equipped model as a second layer.
|
||||
appearanceSlot, ok := currentActorMode0AppearanceSlot(entry)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
row := dnfrepo.CharacterRosterEquipSummary{
|
||||
Slot: int64(appearanceSlot),
|
||||
ItemIDOrIcon: int64(currentActorAppearanceItemID(entry)),
|
||||
RawEntry: append([]byte(nil), entry.RawEntry...),
|
||||
}
|
||||
// The selection screen reads the weapon row from this summary, not from
|
||||
// the mode0 snapshot the in-town scene uses. Carry the same reinforcement
|
||||
// packed-flags (one byte per row, sub_20026C0 packed_byte>>1) so a +15
|
||||
// real weapon keeps its golden glow on the character-select card; the
|
||||
// client reads PackedFlags only when ItemIDOrIcon names that weapon.
|
||||
if appearanceSlot == currentActorMode0WeaponSlot {
|
||||
row.PackedFlags = int64(currentActorMode0WeaponPackedFlags(entry))
|
||||
}
|
||||
out = append(out, row)
|
||||
}
|
||||
sortRosterEquipSummary(out)
|
||||
return filterRosterWeaponAppearance(out)
|
||||
}
|
||||
|
||||
// filterRosterWeaponAppearance sends both the real weapon (slot 12) and a
|
||||
// weapon avatar (slot 10) on the selection card. The client picks the avatar
|
||||
// as the visible model but still reads the slot-12 row's PackedFlags to render
|
||||
// the reinforcement glow (the same byte the mode0 snapshot carries for the
|
||||
// in-town scene), so dropping either row would make a +15 weapon lose its
|
||||
// gold aura on the character-select card.
|
||||
func filterRosterWeaponAppearance(rows []dnfrepo.CharacterRosterEquipSummary) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if len(rows) == 0 {
|
||||
return nil
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func sortRosterEquipSummary(rows []dnfrepo.CharacterRosterEquipSummary) {
|
||||
sort.SliceStable(rows, func(i, j int) bool {
|
||||
if rows[i].Slot == rows[j].Slot {
|
||||
return rows[i].ItemIDOrIcon < rows[j].ItemIDOrIcon
|
||||
}
|
||||
return rows[i].Slot < rows[j].Slot
|
||||
})
|
||||
}
|
||||
|
||||
func characterEquipSummary(character dnfrepo.CharacterRecord) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if len(character.Roster.Entry.EquipSummary) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := cloneRosterEquipSummary(character.Roster.Entry.EquipSummary)
|
||||
sortRosterEquipSummary(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func currentSceneObjectEquipSummary(character dnfrepo.CharacterRecord, hasCharacter bool) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if !hasCharacter {
|
||||
return nil
|
||||
}
|
||||
out := cloneRosterEquipSummary(character.Roster.Entry.EquipSummary)
|
||||
sortRosterEquipSummary(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func cloneRosterEquipSummary(rows []dnfrepo.CharacterRosterEquipSummary) []dnfrepo.CharacterRosterEquipSummary {
|
||||
if len(rows) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]dnfrepo.CharacterRosterEquipSummary, len(rows))
|
||||
for idx, row := range rows {
|
||||
row.RawEntry = append([]byte(nil), row.RawEntry...)
|
||||
out[idx] = row
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *Service) attachEquipmentSummary(ctx context.Context, repos dnfrepo.Group, record *dnfrepo.CharacterRecord) {
|
||||
if s == nil || record == nil || strings.TrimSpace(record.CharacterID) == "" {
|
||||
return
|
||||
}
|
||||
if _, err := s.ensureCharacterInitializationSnapshot(ctx, repos, *record); err != nil {
|
||||
s.logPacketEvent("dnf-character-initialization-backfill-failed",
|
||||
"character_id", record.CharacterID,
|
||||
"job", record.Job,
|
||||
"error", err)
|
||||
}
|
||||
if repos.Equipment != nil {
|
||||
equipment, found, err := repos.Equipment.Load(ctx, record.CharacterID)
|
||||
if err != nil {
|
||||
s.logPacketEvent("dnf-character-equipment-load-failed", "character_id", record.CharacterID, "error", err)
|
||||
} else if found {
|
||||
// The equipment repository is the durable authority after character
|
||||
// creation. Replace any cached roster summary even when the current
|
||||
// equipped set is empty, so unequip-all clears the selector appearance
|
||||
// and cannot accidentally trigger starter-equipment backfill.
|
||||
record.Roster.Entry.EquipSummary = equipmentRosterSummary(equipment)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user