Skip to content

Commit

Permalink
clang_7 is unhappy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jan 17, 2025
1 parent 8d33167 commit b6eb3d0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/object_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ void ObjectProperties::serialize(std::ostream &os) const
}

namespace {
// Type-safe wrapper for bools as u8
inline bool readBool(std::istream &is)
{
return readU8(is) != 0;
}

// Wrapper for primitive reading functions that don't throw (awful)
template <typename T, auto (reader)(std::istream& is)>
template <typename T, T (reader)(std::istream& is)>
bool tryRead(T& val, std::istream& is)
{
T tmp = reader(is);
Expand Down Expand Up @@ -257,10 +263,10 @@ void ObjectProperties::deSerialize(std::istream &is)
return;
}

if (!tryRead<bool, readU8>(shaded, is))
if (!tryRead<bool, readBool>(shaded, is))
return;

if (!tryRead<bool, readU8>(show_on_minimap, is))
if (!tryRead<bool, readBool>(show_on_minimap, is))
return;

auto bgcolor = readARGB8(is);
Expand All @@ -269,7 +275,7 @@ void ObjectProperties::deSerialize(std::istream &is)
else
nametag_bgcolor = std::nullopt;

if (!tryRead<bool, readU8>(rotate_selectionbox, is))
if (!tryRead<bool, readBool>(rotate_selectionbox, is))
return;

if (!tryRead<content_t, readU16>(node.param0, is))
Expand Down

0 comments on commit b6eb3d0

Please sign in to comment.