Skip to content

Commit d78b443

Browse files
committed
Fix serialization for new larger coordinates
Signed-off-by: Stefan Weil <[email protected]>
1 parent c380b75 commit d78b443

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: src/ccstruct/points.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,32 @@ bool FCOORD::normalise() { // Convert to unit vec
4040
return true;
4141
}
4242

43+
// Deserialize an ICOORD.
44+
// For compatibility reasons it uses unsigned 16 bit coordinates
45+
// instead of 32 bit coordinates.
4346
bool ICOORD::DeSerialize(TFile *f) {
44-
return f->DeSerialize(&xcoord) && f->DeSerialize(&ycoord);
47+
bool success = false;
48+
uint16_t coord;
49+
if (f->DeSerialize(&coord)) {
50+
xcoord = coord;
51+
if (f->DeSerialize(&coord)) {
52+
ycoord = coord;
53+
success = true;
54+
}
55+
}
56+
return success;
4557
}
4658

59+
// Serialize an ICOORD.
60+
// For compatibility reasons it uses unsigned 16 bit coordinates
61+
// instead of 32 bit coordinates.
4762
bool ICOORD::Serialize(TFile *f) const {
48-
return f->Serialize(&xcoord) && f->Serialize(&ycoord);
63+
uint16_t coord;
64+
coord = xcoord;
65+
auto success = f->Serialize(&coord);
66+
coord = ycoord;
67+
success = success && f->Serialize(&coord);
68+
return success;
4969
}
5070

5171
// Set from the given x,y, shrinking the vector to fit if needed.

0 commit comments

Comments
 (0)