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,162 @@
|
||||
package dnfbridge
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"math"
|
||||
|
||||
dnfguild "longheng.io/server/internal/modules/dnf/guild"
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
)
|
||||
|
||||
// F97B52..F97B87 copies three u32 fields into a 25-byte native structure.
|
||||
// The first 13 bytes are uninitialized client-local wrapper data, not IDs.
|
||||
func parseCurrentGuildWarShopUpgrade(body []byte) (npc uint32, before, after uint16, ok bool) {
|
||||
if len(body) != 25 {
|
||||
return
|
||||
}
|
||||
npc = binary.LittleEndian.Uint32(body[13:])
|
||||
from, to := binary.LittleEndian.Uint32(body[17:]), binary.LittleEndian.Uint32(body[21:])
|
||||
if from == 0 || from > math.MaxUint16 || to > math.MaxUint16 || to != from+1 {
|
||||
return
|
||||
}
|
||||
return npc, uint16(from), uint16(to), true
|
||||
}
|
||||
|
||||
func currentGuildWarShopError(err error) byte {
|
||||
switch {
|
||||
case errors.Is(err, dnfguild.ErrPermissionDenied):
|
||||
return 36
|
||||
case errors.Is(err, errDungeonPickupInventoryFull):
|
||||
return 136
|
||||
default:
|
||||
return currentGuildGuardianError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) handleCurrentGuildWarShopUpgrade(session *gameSession, body []byte) error {
|
||||
const opcode = uint16(840)
|
||||
npc, before, after, ok := parseCurrentGuildWarShopUpgrade(body)
|
||||
ready, _ := s.currentSceneTransitionReadyForState(session)
|
||||
if !ok || !ready {
|
||||
return s.sendGameUpperFailure(session, opcode, 3)
|
||||
}
|
||||
items, err := s.currentPVFItemCatalog()
|
||||
if err != nil {
|
||||
return s.sendGameUpperFailure(session, opcode, 1)
|
||||
}
|
||||
catalog, err := dnfguild.LoadWarShops(items.source)
|
||||
if err != nil {
|
||||
s.logGameEvent(session, "game-guild-war-shop-catalog-failed", "error", err)
|
||||
return s.sendGameUpperFailure(session, opcode, 1)
|
||||
}
|
||||
ctx, cancel := s.currentGuildContext()
|
||||
defer cancel()
|
||||
var guild *dnfguild.Guild
|
||||
var kind byte
|
||||
err = s.transactCurrentGuildAssets(ctx, session, func(_ dnfrepo.Group, r *dnfguild.Registry, c *dnfrepo.CharacterRecord) error {
|
||||
var e error
|
||||
kind, e = r.UpgradeWarShop(c.CharacterID, npc, before, after, catalog, s.gameplayNow())
|
||||
if e == nil {
|
||||
guild, _, _ = r.GuildForCharacter(c.CharacterID)
|
||||
}
|
||||
return e
|
||||
})
|
||||
if err != nil {
|
||||
s.logGameEvent(session, "game-guild-war-shop-upgrade-rejected", "npc", npc, "before", before, "after", after, "error", err)
|
||||
return s.sendGameUpperFailure(session, opcode, currentGuildWarShopError(err))
|
||||
}
|
||||
if err = s.sendGameUpperSuccess(session, opcode, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = s.publishCurrentGuildGuardianState(session, guild); err != nil {
|
||||
return err
|
||||
}
|
||||
// E84240 (class0/778) consumes u8 shop kind + u32 level, closes the
|
||||
// upgrade dialog and updates the two native u16 merchant-level fields.
|
||||
var notice packetWriter
|
||||
notice.writeByte(kind)
|
||||
notice.writeUint32(uint32(after))
|
||||
s.logGameEvent(session, "game-guild-war-shop-upgraded", "npc", npc, "kind", kind, "level", after, "ap", guild.GuardianAP, "gp", guild.GuardianGP)
|
||||
return s.sendGameUpperRawClass(session, 778, notice.bytes(), 0)
|
||||
}
|
||||
|
||||
func (s *Service) handleCurrentGuildWarShopBuy(session *gameSession, body []byte) error {
|
||||
const opcode = uint16(1354)
|
||||
request, err := parseCurrentNPCShopBuyRequest(body)
|
||||
ready, _ := s.currentSceneTransitionReadyForState(session)
|
||||
if err != nil || !ready || request.Count == 0 {
|
||||
return s.sendGameUpperFailure(session, opcode, 3)
|
||||
}
|
||||
items, err := s.currentPVFItemCatalog()
|
||||
if err != nil {
|
||||
return s.sendGameUpperFailure(session, opcode, 1)
|
||||
}
|
||||
catalog, err := dnfguild.LoadWarShops(items.source)
|
||||
if err != nil {
|
||||
s.logGameEvent(session, "game-guild-war-shop-catalog-failed", "error", err)
|
||||
return s.sendGameUpperFailure(session, opcode, 1)
|
||||
}
|
||||
definition, err := items.ResolveItem(request.ItemID)
|
||||
if err != nil || definition.Kind != dungeonDropItemStackable || definition.InventoryListType != dnfrepo.MainInventoryListType {
|
||||
return s.sendGameUpperFailure(session, opcode, 3)
|
||||
}
|
||||
cost, err := dnfguild.LoadWarProductCost(items.source, definition.PVFPath)
|
||||
if err != nil {
|
||||
return s.sendGameUpperFailure(session, opcode, 3)
|
||||
}
|
||||
ctx, cancel := s.currentGuildContext()
|
||||
defer cancel()
|
||||
var guild *dnfguild.Guild
|
||||
var updates []currentItemListEntry
|
||||
err = s.transactCurrentGuildAssets(ctx, session, func(tx dnfrepo.Group, r *dnfguild.Registry, c *dnfrepo.CharacterRecord) error {
|
||||
if int64(c.Level) < definition.MinimumLevel {
|
||||
return dnfguild.ErrInvalidContent
|
||||
}
|
||||
if e := r.BuyWarProduct(c.CharacterID, request.ShopContext, request.ActorContext, request.ItemID, request.Count, catalog, cost, s.gameplayNow()); e != nil {
|
||||
return e
|
||||
}
|
||||
if tx.Inventory == nil {
|
||||
return dnfguild.ErrRepositoryUnavailable
|
||||
}
|
||||
inventory, found, e := tx.Inventory.Load(ctx, c.CharacterID)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
if !found {
|
||||
return dnfguild.ErrRepositoryUnavailable
|
||||
}
|
||||
slots, e := grantCurrentCeraShopProduct(&inventory, definition, request.Count, s.currentInventoryPlacementMainSlotCount(ctx, &inventory, c.CharacterID))
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
for _, slot := range slots {
|
||||
key := currentCeraShopInventorySlotKey(definition.InventoryListType, int16(slot))
|
||||
stack := inventory.Slots[key]
|
||||
if stack.Extra == nil {
|
||||
stack.Extra = make(map[string]string)
|
||||
}
|
||||
stack.Extra["last_grant_source"] = "guild_war_shop"
|
||||
entry := currentItemListEntryFromStack(definition.InventoryListType, int16(slot), stack)
|
||||
stack.RawEntry = append([]byte(nil), entry.data[:]...)
|
||||
inventory.Slots[key] = stack
|
||||
updates = append(updates, entry)
|
||||
}
|
||||
guild, _, _ = r.GuildForCharacter(c.CharacterID)
|
||||
return tx.Inventory.Save(ctx, inventory)
|
||||
})
|
||||
if err != nil {
|
||||
s.logGameEvent(session, "game-guild-war-shop-buy-rejected", "item", request.ItemID, "count", request.Count, "shop", request.ShopContext, "npc", request.ActorContext, "error", err)
|
||||
return s.sendGameUpperFailure(session, opcode, currentGuildWarShopError(err))
|
||||
}
|
||||
// E8F730 clears the native purchase-busy flag on both success and failure.
|
||||
if err = s.sendGameUpperSuccess(session, opcode, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
sortCurrentItemListEntries(updates)
|
||||
if err = s.sendGameUpperRawClass(session, 14, buildCurrentItemUpdateBody(definition.InventoryListType, updates), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
s.logGameEvent(session, "game-guild-war-shop-bought", "item", request.ItemID, "count", request.Count, "shop", request.ShopContext, "ap", guild.GuardianAP, "gp", guild.GuardianGP)
|
||||
return s.publishCurrentGuildGuardianState(session, guild)
|
||||
}
|
||||
Reference in new issue
Block a user