mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 09:33:02 +01:00
feat(diva): implement Diva Defense point accumulation (#168)
RE'd putAdd_ud_point (FUN_114fd490) and putAdd_ud_tactics_point (FUN_114fe9c0) from the ZZ client DLL via Ghidra decompilation. MsgMhfAddUdPoint fields: QuestPoints (sum of 11 category accumulators earned per quest) and BonusPoints (kiju prayer song multiplier extra). MsgMhfAddUdTacticsPoint fields: QuestID and TacticsPoints. Adds diva_points table (migration 0009) for per-character per-event point tracking, with UPSERT-based atomic accumulation in the handler.
This commit is contained in:
@@ -151,6 +151,26 @@ func handleMsgMhfSetKiju(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfAddUdPoint(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfAddUdPoint)
|
||||
|
||||
// Find the current diva event to associate points with.
|
||||
eventID := uint32(0)
|
||||
if s.server.divaRepo != nil {
|
||||
events, err := s.server.divaRepo.GetEvents()
|
||||
if err == nil && len(events) > 0 {
|
||||
eventID = events[len(events)-1].ID
|
||||
}
|
||||
}
|
||||
|
||||
if eventID != 0 && s.charID != 0 && (pkt.QuestPoints > 0 || pkt.BonusPoints > 0) {
|
||||
if err := s.server.divaRepo.AddPoints(s.charID, eventID, pkt.QuestPoints, pkt.BonusPoints); err != nil {
|
||||
s.logger.Warn("Failed to add diva points",
|
||||
zap.Uint32("charID", s.charID),
|
||||
zap.Uint32("questPoints", pkt.QuestPoints),
|
||||
zap.Uint32("bonusPoints", pkt.BonusPoints),
|
||||
zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user