mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 11:04:44 +00:00
TSAGE: Fixed problem with saving double values
This commit is contained in:
parent
ab7fdccc3b
commit
160a8d96d9
@ -3105,10 +3105,10 @@ void Scene6100::Object::synchronize(Serializer &s) {
|
||||
SceneObject::synchronize(s);
|
||||
|
||||
// Save the double fields of the FloatSet
|
||||
s.syncBytes((byte *)&_floats._float1, sizeof(double));
|
||||
s.syncBytes((byte *)&_floats._float2, sizeof(double));
|
||||
s.syncBytes((byte *)&_floats._float3, sizeof(double));
|
||||
s.syncBytes((byte *)&_floats._float4, sizeof(double));
|
||||
s.syncAsDouble(_floats._float1);
|
||||
s.syncAsDouble(_floats._float2);
|
||||
s.syncAsDouble(_floats._float3);
|
||||
s.syncAsDouble(_floats._float4);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
@ -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) {
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
Common::Serializer::Version maxVersion = kLastVersion);
|
||||
void validate(int v, Common::Serializer::Version minVersion = 0,
|
||||
Common::Serializer::Version maxVersion = kLastVersion);
|
||||
void syncAsDouble(double &v);
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user