Skip to content

Commit

Permalink
Fix serialization for new larger coordinates
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 25, 2021
1 parent 34cb977 commit 9fc3685
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/ccstruct/points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9fc3685

Please sign in to comment.