mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 02:23:37 +01:00
fix(channelserver): mitigate house theme corruption on save (#92)
The game client sometimes writes -1 (0xFF bytes) into the house_tier field during save, which causes the house theme to vanish on next login. Snapshot the house tier before applying the save delta and restore it if the incoming value is corrupted.
This commit is contained in:
@@ -25,6 +25,11 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
// Snapshot current house tier before applying the update so we can
|
||||
// restore it if the incoming data is corrupted (issue #92).
|
||||
prevHouseTier := make([]byte, len(characterSaveData.HouseTier))
|
||||
copy(prevHouseTier, characterSaveData.HouseTier)
|
||||
|
||||
// Var to hold the decompressed savedata for updating the launcher response fields.
|
||||
if pkt.SaveType == 1 {
|
||||
// Diff-based update.
|
||||
@@ -55,6 +60,20 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
characterSaveData.updateStructWithSaveData()
|
||||
|
||||
// Mitigate house theme corruption (issue #92): the game client
|
||||
// sometimes sends house_tier as -1 (all 0xFF bytes), which causes
|
||||
// the house theme to vanish on next login. If the new value looks
|
||||
// corrupted, restore the previous value in both the struct and the
|
||||
// decompressed blob so Save() persists consistent data.
|
||||
if len(prevHouseTier) > 0 && characterSaveData.isHouseTierCorrupted() {
|
||||
s.logger.Warn("Detected corrupted house_tier in save data, restoring previous value",
|
||||
zap.Binary("corrupted", characterSaveData.HouseTier),
|
||||
zap.Binary("restored", prevHouseTier),
|
||||
zap.Uint32("charID", s.charID),
|
||||
)
|
||||
characterSaveData.restoreHouseTier(prevHouseTier)
|
||||
}
|
||||
|
||||
s.playtime = characterSaveData.Playtime
|
||||
s.playtimeTime = time.Now()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user