服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
119 lines
4.6 KiB
Go
119 lines
4.6 KiB
Go
package dnfbridge
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"longheng.io/server/internal/modules/dnf/mail"
|
|
)
|
|
|
|
// sendMailboxAlarmForSession projects a mailbox's durable unread state onto
|
|
// one already-active game session. It is used for both a live recipient and
|
|
// the first selected-town scene, which must explicitly clear a prior actor's
|
|
// indicator by sending a zero count as well.
|
|
func (s *Service) sendMailboxAlarmForSession(session *gameSession, characterID uint16, source string) error {
|
|
if session == nil || characterID == 0 {
|
|
return nil
|
|
}
|
|
repos, available := s.repositoryGroup()
|
|
if !available {
|
|
return fmt.Errorf("mailbox alarm repository is unavailable")
|
|
}
|
|
ctx, cancel := context.WithTimeout(context.Background(), createWriteTimeout)
|
|
defer cancel()
|
|
result, err := mail.NewOwner(repos).Open(ctx, strconv.FormatUint(uint64(characterID), 10))
|
|
if err != nil {
|
|
return fmt.Errorf("load mailbox alarm state: %w", err)
|
|
}
|
|
if err := s.sendGameUpperRawClass(
|
|
session,
|
|
mail.MailboxAlarmNotificationMessageID,
|
|
mail.BuildAlarmNotification(result.Unread),
|
|
0,
|
|
); err != nil {
|
|
return err
|
|
}
|
|
s.logGameEvent(session, "game-mailbox-alarm-sent",
|
|
"source", source,
|
|
"char_id", characterID,
|
|
"unread", result.Unread)
|
|
return nil
|
|
}
|
|
|
|
// sendMailboxAlarmToOnlineRecipient is deliberately a bridge-owned delivery
|
|
// projection: mailbox ownership has already committed in the mail module, and
|
|
// an offline recipient receives the same class0/op63 snapshot during the
|
|
// selected-town bootstrap. The game-session index and its wire mutex make the
|
|
// optional live notice safe without giving the domain module transport
|
|
// ownership.
|
|
func (s *Service) sendMailboxAlarmToOnlineRecipient(characterID uint16) error {
|
|
session, online := s.onlineGameSession(characterID)
|
|
if !online {
|
|
return nil
|
|
}
|
|
return s.sendMailboxAlarmForSession(session, characterID, "online_recipient_mail_delivery")
|
|
}
|
|
|
|
// sendMailboxListRefreshToOnlineRecipient pushes the complete class0/op0x61
|
|
// mailbox page (the same body the client's own op96 gets) to an online
|
|
// character.
|
|
//
|
|
// WHY the alarm alone is not enough - read off NoPack.exe:
|
|
//
|
|
// class0/0x63 -> FUN_01d7ff70 (registered by FUN_02262980(0x63, 0x1d7ff70, 0)
|
|
// in the class-0 table FUN_01d927e0). It reads exactly one u16 and does
|
|
// exactly two things:
|
|
// 01d7ff7f CALL FUN_034e39e0 ; count u16
|
|
// 01d7ff8c JLE 0x01d80008 ; count <= 0 -> no banner
|
|
// 01d7ffcd GetString(0x811) ; 2065 = 收到新邮件, drawn as a
|
|
// ; floating notice at 0xff4e78ff
|
|
// 01d8000d CALL FUN_0270be70 ; the lazily built singleton
|
|
// 01d80014 CALL FUN_0270b330 ; **(this+4) = count; *(this+4)[1] = 0
|
|
// Nothing in that path reloads or repaints the mailbox list, so a letter that
|
|
// arrives while the mailbox is open stays invisible until the player closes and
|
|
// reopens it. The list is only ever rebuilt by the class0/0x61 reader
|
|
// FUN_01d913c0, whose tail calls the singleton and then FUN_0270bc30 ->
|
|
// FUN_0270b7f0 to rebuild the list from its container.
|
|
//
|
|
// That pair is not an invention: the GM mailbox-clear refresh in gm_admin.go
|
|
// already publishes alarm-then-page for exactly this reason, and op96 answers
|
|
// with this very snapshot. FUN_0270b7f0 only sorts and refills the mail
|
|
// container, so pushing it without an open mailbox cannot pop a window open.
|
|
//
|
|
// Deliberately NOT wired into the item auction's delivery path: that path must
|
|
// stay byte-identical, so this is only called by the 金币寄售 letter sender.
|
|
func (s *Service) sendMailboxListRefreshToOnlineRecipient(characterID uint16) error {
|
|
if s == nil || characterID == 0 {
|
|
return nil
|
|
}
|
|
session, online := s.onlineGameSession(characterID)
|
|
if !online {
|
|
return nil
|
|
}
|
|
repos, available := s.repositoryGroup()
|
|
if !available {
|
|
return fmt.Errorf("mailbox list refresh repository is unavailable")
|
|
}
|
|
ctx, cancel := context.WithTimeout(context.Background(), createWriteTimeout)
|
|
defer cancel()
|
|
opened, err := mail.NewOwner(repos).Open(ctx, strconv.FormatUint(uint64(characterID), 10))
|
|
if err != nil {
|
|
return fmt.Errorf("load mailbox list refresh state: %w", err)
|
|
}
|
|
snapshot, err := mail.BuildListNotification(opened)
|
|
if err != nil {
|
|
return fmt.Errorf("build mailbox list refresh page: %w", err)
|
|
}
|
|
if err := s.sendGameUpperRawClass(session, mail.MailboxListNotificationMessageID, snapshot, 0); err != nil {
|
|
return err
|
|
}
|
|
s.logGameEvent(session, "game-mailbox-list-refreshed",
|
|
"source", "online_recipient_mail_delivery",
|
|
"char_id", characterID,
|
|
"mails", len(opened.Mails),
|
|
"unread", opened.Unread,
|
|
"page_len", len(snapshot))
|
|
return nil
|
|
}
|