服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
93 lines
2.0 KiB
Go
93 lines
2.0 KiB
Go
package services
|
|
|
|
import "sync"
|
|
|
|
// archiveTaskGate tracks work that may retain a *pvf.Archive after it has
|
|
// released core.mu. Closing the archive blocks new tasks, cancels the active
|
|
// ones, and waits for their references to disappear before releasing memory.
|
|
type archiveTaskGate struct {
|
|
mu sync.Mutex
|
|
cond *sync.Cond
|
|
closing bool
|
|
nextID uint64
|
|
tasks map[uint64]chan struct{}
|
|
}
|
|
|
|
func newArchiveTaskGate() archiveTaskGate {
|
|
// Initialize the condition lazily, after the gate has reached its final
|
|
// address. Returning a cond bound to a local mutex copies the wrong lock.
|
|
return archiveTaskGate{tasks: make(map[uint64]chan struct{})}
|
|
}
|
|
|
|
func (g *archiveTaskGate) ensureLocked() {
|
|
if g.cond != nil {
|
|
return
|
|
}
|
|
g.tasks = make(map[uint64]chan struct{})
|
|
g.cond = sync.NewCond(&g.mu)
|
|
}
|
|
|
|
func (g *archiveTaskGate) begin() func() {
|
|
g.mu.Lock()
|
|
g.ensureLocked()
|
|
for g.closing {
|
|
g.cond.Wait()
|
|
}
|
|
return g.beginLocked()
|
|
}
|
|
|
|
// tryBegin lets an existing task register follow-up work without waiting for
|
|
// closeArchive, which may itself be waiting for that task to finish.
|
|
func (g *archiveTaskGate) tryBegin() (func(), bool) {
|
|
g.mu.Lock()
|
|
g.ensureLocked()
|
|
if g.closing {
|
|
g.mu.Unlock()
|
|
return nil, false
|
|
}
|
|
return g.beginLocked(), true
|
|
}
|
|
|
|
func (g *archiveTaskGate) beginLocked() func() {
|
|
g.nextID++
|
|
id := g.nextID
|
|
done := make(chan struct{})
|
|
g.tasks[id] = done
|
|
g.mu.Unlock()
|
|
|
|
var once sync.Once
|
|
return func() {
|
|
once.Do(func() {
|
|
g.mu.Lock()
|
|
if current, ok := g.tasks[id]; ok {
|
|
delete(g.tasks, id)
|
|
close(current)
|
|
}
|
|
g.mu.Unlock()
|
|
})
|
|
}
|
|
}
|
|
|
|
func (g *archiveTaskGate) beginClose() []<-chan struct{} {
|
|
g.mu.Lock()
|
|
g.ensureLocked()
|
|
for g.closing {
|
|
g.cond.Wait()
|
|
}
|
|
g.closing = true
|
|
waitFor := make([]<-chan struct{}, 0, len(g.tasks))
|
|
for _, done := range g.tasks {
|
|
waitFor = append(waitFor, done)
|
|
}
|
|
g.mu.Unlock()
|
|
return waitFor
|
|
}
|
|
|
|
func (g *archiveTaskGate) endClose() {
|
|
g.mu.Lock()
|
|
g.ensureLocked()
|
|
g.closing = false
|
|
g.cond.Broadcast()
|
|
g.mu.Unlock()
|
|
}
|