Fix off-by one error in decoder and make padding deterministic.

This commit is contained in:
Patrick Niklaus 2015-09-14 23:01:38 +02:00
parent fe0fe1873a
commit 8e02263084
2 changed files with 7 additions and 3 deletions

View File

@ -79,7 +79,7 @@ struct ObjectEncoder
replaceAll(encoded, "-", "+");
replaceAll(encoded, "_", "/");
std::copy(binary_t(encoded.begin()), binary_t(encoded.begin() + encoded.length() - 1),
std::copy(binary_t(encoded.begin()), binary_t(encoded.begin() + encoded.length()),
reinterpret_cast<char *>(&object));
}
catch (...)

View File

@ -88,8 +88,10 @@ struct PhantomNode
unsigned component_id;
FixedPointCoordinate location;
unsigned short fwd_segment_position;
TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;
// note 4 bits would suffice for each,
// but the saved byte would be padding anyway
TravelMode forward_travel_mode;
TravelMode backward_travel_mode;
int GetForwardWeightPlusOffset() const;
@ -108,6 +110,8 @@ struct PhantomNode
bool operator==(const PhantomNode &other) const;
};
static_assert(sizeof(PhantomNode) == 48, "PhantomNode has more padding then expected");
using PhantomNodeArray = std::vector<std::vector<PhantomNode>>;
class phantom_node_pair : public std::pair<PhantomNode, PhantomNode>