From 9fc3685f1254828b30b19dacfe2429376d1c7d18 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 28 May 2021 14:56:31 +0200 Subject: [PATCH] Fix serialization for new larger coordinates Signed-off-by: Stefan Weil --- src/ccstruct/points.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ccstruct/points.cpp b/src/ccstruct/points.cpp index 1e0375e740..d001953b33 100644 --- a/src/ccstruct/points.cpp +++ b/src/ccstruct/points.cpp @@ -40,12 +40,32 @@ bool FCOORD::normalise() { // Convert to unit vec return true; } +// Deserialize an ICOORD. +// For compatibility reasons it uses unsigned 16 bit coordinates +// instead of 32 bit coordinates. bool ICOORD::DeSerialize(TFile *f) { - return f->DeSerialize(&xcoord) && f->DeSerialize(&ycoord); + bool success = false; + uint16_t coord; + if (f->DeSerialize(&coord)) { + xcoord = coord; + if (f->DeSerialize(&coord)) { + ycoord = coord; + success = true; + } + } + return success; } +// Serialize an ICOORD. +// For compatibility reasons it uses unsigned 16 bit coordinates +// instead of 32 bit coordinates. bool ICOORD::Serialize(TFile *f) const { - return f->Serialize(&xcoord) && f->Serialize(&ycoord); + uint16_t coord; + coord = xcoord; + auto success = f->Serialize(&coord); + coord = ycoord; + success = success && f->Serialize(&coord); + return success; } // Set from the given x,y, shrinking the vector to fit if needed.