aboutsummaryrefslogtreecommitdiff
path: root/src/object_properties.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-09-19 20:56:13 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-09-19 20:56:13 +0200
commitc8900e169a1ddceec07a449f1ae7c4322ff02036 (patch)
tree5156605fb473d25786426eb6876ba2e7d3b7507b /src/object_properties.cpp
parent950d2c9b3e10cbace9236e820c8119d1abb9e01f (diff)
parente0529da5c84f224c380e6d5e063392cb01f85683 (diff)
downloaddragonfireclient-c8900e169a1ddceec07a449f1ae7c4322ff02036.tar.xz
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/object_properties.cpp')
-rw-r--r--src/object_properties.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index 2eebc27d6..db06f8930 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -83,6 +83,39 @@ std::string ObjectProperties::dump()
return os.str();
}
+bool ObjectProperties::validate()
+{
+ const char *func = "ObjectProperties::validate(): ";
+ bool ret = true;
+
+ // cf. where serializeString16 is used below
+ for (u32 i = 0; i < textures.size(); i++) {
+ if (textures[i].size() > U16_MAX) {
+ warningstream << func << "texture " << (i+1) << " has excessive length, "
+ "clearing it." << std::endl;
+ textures[i].clear();
+ ret = false;
+ }
+ }
+ if (nametag.length() > U16_MAX) {
+ warningstream << func << "nametag has excessive length, clearing it." << std::endl;
+ nametag.clear();
+ ret = false;
+ }
+ if (infotext.length() > U16_MAX) {
+ warningstream << func << "infotext has excessive length, clearing it." << std::endl;
+ infotext.clear();
+ ret = false;
+ }
+ if (wield_item.length() > U16_MAX) {
+ warningstream << func << "wield_item has excessive length, clearing it." << std::endl;
+ wield_item.clear();
+ ret = false;
+ }
+
+ return ret;
+}
+
void ObjectProperties::serialize(std::ostream &os) const
{
writeU8(os, 4); // PROTOCOL_VERSION >= 37
@@ -105,7 +138,6 @@ void ObjectProperties::serialize(std::ostream &os) const
writeU8(os, is_visible);
writeU8(os, makes_footstep_sound);
writeF32(os, automatic_rotate);
- // Added in protocol version 14
os << serializeString16(mesh);
writeU16(os, colors.size());
for (video::SColor color : colors) {