TSAGE: Fixed problem with saving double values

This commit is contained in:
Paul Gilbert 2011-07-02 13:49:27 +10:00
parent ab7fdccc3b
commit 160a8d96d9
3 changed files with 18 additions and 4 deletions

View file

@ -103,6 +103,19 @@ void Serializer::validate(int v, Common::Serializer::Version minVersion,
error("Savegame is corrupt");
}
#define DOUBLE_PRECISION 1000000000
void Serializer::syncAsDouble(double &v) {
int32 num = (int32)(v);
uint32 fraction = (uint32)((v - (int32)v) * DOUBLE_PRECISION);
syncAsSint32LE(num);
syncAsUint32LE(fraction);
if (isLoading())
v = num + (double)fraction / DOUBLE_PRECISION;
}
/*--------------------------------------------------------------------------*/
Common::Error Saver::save(int slot, const Common::String &saveName) {