X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fobject_properties.cpp;h=e4c6569465a1bc0c0e2a180b642e85c01c87c077;hb=5c248c2d7de3db54e85f7c388743a2eb8e36fee4;hp=c2debf328296eabbc34b2a18bfd4346101f65c4b;hpb=8cae65978611476d0da215acf61819a905c68267;p=minetest.git diff --git a/src/object_properties.cpp b/src/object_properties.cpp index c2debf328..e4c656946 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -19,87 +19,158 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "object_properties.h" #include "irrlichttypes_bloated.h" +#include "exceptions.h" #include "util/serialize.h" +#include "util/basic_macros.h" #include -#include - -#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" -#define PP2(x) "("<<(x).X<<","<<(x).Y<<")" - -ObjectProperties::ObjectProperties(): - hp_max(1), - physical(false), - collideWithObjects(true), - weight(5), - collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5), - visual("sprite"), - mesh(""), - visual_size(1,1), - spritediv(1,1), - initial_sprite_basepos(0,0), - is_visible(true), - makes_footstep_sound(false), - automatic_rotate(0) + +static const video::SColor NULL_BGCOLOR{0, 1, 1, 1}; + +ObjectProperties::ObjectProperties() { - textures.push_back("unknown_object.png"); - colors.push_back(video::SColor(255,255,255,255)); + textures.emplace_back("no_texture.png"); + colors.emplace_back(255,255,255,255); } std::string ObjectProperties::dump() { std::ostringstream os(std::ios::binary); - os<<"hp_max="< 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, 1); // version - writeS16(os, hp_max); + writeU8(os, 4); // PROTOCOL_VERSION >= 37 + writeU16(os, hp_max); writeU8(os, physical); - writeF1000(os, weight); - writeV3F1000(os, collisionbox.MinEdge); - writeV3F1000(os, collisionbox.MaxEdge); - os<