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,86 @@
|
||||
package inventory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
||||
)
|
||||
|
||||
// ReservedMainSlotRelocation records a one-time repair of an ordinary item
|
||||
// that was imported into a main-list slot owned by a client wallet.
|
||||
//
|
||||
// The caller supplies the item's runtime-PVF page bounds. Inventory owns the
|
||||
// atomic mutation, while the bridge remains responsible for resolving those
|
||||
// bounds from the active PVF rather than guessing a destination page.
|
||||
type ReservedMainSlotRelocation struct {
|
||||
Changed bool
|
||||
ItemID int64
|
||||
FromSlot int16
|
||||
ToSlot int16
|
||||
}
|
||||
|
||||
// RelocateReservedMainSlot moves a non-wallet main-list item out of one fixed
|
||||
// client-reserved slot into the first empty slot in its proven PVF page. It
|
||||
// preserves the entire durable stack (raw row, bind, expiration, and extras)
|
||||
// and never overwrites an occupied destination.
|
||||
func (o *Owner) RelocateReservedMainSlot(
|
||||
ctx context.Context,
|
||||
characterID string,
|
||||
reservedSlot int16,
|
||||
pageStart int16,
|
||||
pageEnd int16,
|
||||
) (ReservedMainSlotRelocation, error) {
|
||||
if o == nil || o.repo == nil {
|
||||
return ReservedMainSlotRelocation{}, ErrOwnerUnavailable
|
||||
}
|
||||
characterID = strings.TrimSpace(characterID)
|
||||
if characterID == "" {
|
||||
return ReservedMainSlotRelocation{}, ErrCharacterRequired
|
||||
}
|
||||
if reservedSlot < 0 || pageStart < 0 || pageEnd < pageStart || (reservedSlot >= pageStart && reservedSlot <= pageEnd) {
|
||||
return ReservedMainSlotRelocation{}, fmt.Errorf("%w: reserved=%d page=%d..%d", ErrReservedSlotRelocationFull, reservedSlot, pageStart, pageEnd)
|
||||
}
|
||||
if !o.inItemTransaction {
|
||||
var result ReservedMainSlotRelocation
|
||||
err := o.withinInventoryTransaction(ctx, characterID, func(txOwner *Owner) error {
|
||||
var err error
|
||||
result, err = txOwner.RelocateReservedMainSlot(ctx, characterID, reservedSlot, pageStart, pageEnd)
|
||||
return err
|
||||
})
|
||||
return result, err
|
||||
}
|
||||
|
||||
record, found, err := o.repo.Load(ctx, characterID)
|
||||
if err != nil {
|
||||
return ReservedMainSlotRelocation{}, err
|
||||
}
|
||||
if !found {
|
||||
return ReservedMainSlotRelocation{}, ErrInventoryNotFound
|
||||
}
|
||||
record = dnfrepo.CloneInventory(record)
|
||||
if record.Slots == nil {
|
||||
return ReservedMainSlotRelocation{}, nil
|
||||
}
|
||||
sourceKey := slotKey(listTypeMain, reservedSlot)
|
||||
stack, found := record.Slots[sourceKey]
|
||||
if !found || stack.ItemID == 0 {
|
||||
return ReservedMainSlotRelocation{}, nil
|
||||
}
|
||||
for slot := pageStart; slot <= pageEnd; slot++ {
|
||||
destinationKey := slotKey(listTypeMain, slot)
|
||||
if _, occupied := record.Slots[destinationKey]; occupied {
|
||||
continue
|
||||
}
|
||||
delete(record.Slots, sourceKey)
|
||||
record.Slots[destinationKey] = stack
|
||||
record.UpdatedAt = time.Now().UTC()
|
||||
if err := dnfrepo.SaveInventoryFields(ctx, o.repo, record, dnfrepo.InventoryFieldSlots); err != nil {
|
||||
return ReservedMainSlotRelocation{}, err
|
||||
}
|
||||
return ReservedMainSlotRelocation{Changed: true, ItemID: stack.ItemID, FromSlot: reservedSlot, ToSlot: slot}, nil
|
||||
}
|
||||
return ReservedMainSlotRelocation{ItemID: stack.ItemID, FromSlot: reservedSlot}, fmt.Errorf("%w: item=%d reserved=%d page=%d..%d", ErrReservedSlotRelocationFull, stack.ItemID, reservedSlot, pageStart, pageEnd)
|
||||
}
|
||||
Reference in new issue
Block a user