Files
questshock/modding/hacked/ss1/content/archive/IsSavegame.go
T

29 lines
567 B
Go

package archive
import (
"io/ioutil"
"github.com/inkyblackness/hacked/ss1/resource"
)
// IsSavegame returns true for resources that most likely identify a savegame.
// This function must be called with a resource from ID 0x0FA1.
func IsSavegame(res resource.BlockProvider) bool {
if res == nil {
return false
}
if res.BlockCount() < 1 {
return false
}
dataReader, err := res.Block(0)
if err != nil {
return false
}
data, err := ioutil.ReadAll(dataReader)
if err != nil {
return false
}
state := NewGameState(data)
return state.IsSavegame()
}