1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Tool specific pointing and blocking pointable type (#13992)

This commit is contained in:
cx384 2024-01-22 18:27:08 +01:00 committed by GitHub
parent fb461d21a5
commit 5958714309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 676 additions and 67 deletions

View file

@ -122,6 +122,7 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def)
stack_max = def.stack_max;
usable = def.usable;
liquids_pointable = def.liquids_pointable;
pointabilities = def.pointabilities;
if (def.tool_capabilities)
tool_capabilities = new ToolCapabilities(*def.tool_capabilities);
groups = def.groups;
@ -167,6 +168,7 @@ void ItemDefinition::reset()
stack_max = 99;
usable = false;
liquids_pointable = false;
pointabilities = std::nullopt;
delete tool_capabilities;
tool_capabilities = NULL;
groups.clear();
@ -241,6 +243,14 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
writeU8(os, wallmounted_rotate_vertical);
touch_interaction.serialize(os);
std::string pointabilities_s;
if (pointabilities) {
std::ostringstream tmp_os(std::ios::binary);
pointabilities->serialize(tmp_os);
pointabilities_s = tmp_os.str();
}
os << serializeString16(pointabilities_s);
}
void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
@ -316,6 +326,13 @@ void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
wallmounted_rotate_vertical = readU8(is); // 0 if missing
touch_interaction.deSerialize(is);
std::string pointabilities_s = deSerializeString16(is);
if (!pointabilities_s.empty()) {
std::istringstream tmp_is(pointabilities_s, std::ios::binary);
pointabilities = std::make_optional<Pointabilities>();
pointabilities->deSerialize(tmp_is);
}
} catch(SerializationError &e) {};
}