mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 10:03:06 +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:
@@ -202,3 +202,27 @@ func (save *CharacterSaveData) updateStructWithSaveData() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// isHouseTierCorrupted checks whether the house tier field contains 0xFF
|
||||
// bytes, which indicates an uninitialized or -1 value from the game client.
|
||||
// The game uses small positive integers for theme IDs; 0xFF is never valid.
|
||||
func (save *CharacterSaveData) isHouseTierCorrupted() bool {
|
||||
for _, b := range save.HouseTier {
|
||||
if b == 0xFF {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// restoreHouseTier replaces the current house tier with the given value in
|
||||
// both the struct field and the underlying decompressed save blob, keeping
|
||||
// them consistent for Save().
|
||||
func (save *CharacterSaveData) restoreHouseTier(valid []byte) {
|
||||
save.HouseTier = make([]byte, len(valid))
|
||||
copy(save.HouseTier, valid)
|
||||
offset, ok := save.Pointers[pHouseTier]
|
||||
if ok && offset+len(valid) <= len(save.decompSave) {
|
||||
copy(save.decompSave[offset:offset+len(valid)], valid)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user