diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-19 11:30:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-19 11:30:46 +0200 |
commit | 1992db1395d9c068327a7c08bac7a24ef7112274 (patch) | |
tree | 3fb4982e4662a9519e08b57cab228c6b26d4a57f /src/object_properties.cpp | |
parent | 4a1265ceb5919c53efaa8c50bbb0fe7955aa47aa (diff) | |
download | minetest-1992db1395d9c068327a7c08bac7a24ef7112274.tar.gz minetest-1992db1395d9c068327a7c08bac7a24ef7112274.tar.bz2 minetest-1992db1395d9c068327a7c08bac7a24ef7112274.zip |
Code modernization: src/n*, src/o* (#6280)
* Code modernization: src/n*, src/o*
* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* remove unused IWritableNodeDefManager::clone()
* C++ STL header style
* Pointer constness in some functions
Diffstat (limited to 'src/object_properties.cpp')
-rw-r--r-- | src/object_properties.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/object_properties.cpp b/src/object_properties.cpp index af442806b..5534db283 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -26,8 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc., ObjectProperties::ObjectProperties() { - textures.push_back("unknown_object.png"); - colors.push_back(video::SColor(255,255,255,255)); + textures.emplace_back("unknown_object.png"); + colors.emplace_back(255,255,255,255); } std::string ObjectProperties::dump() @@ -42,13 +42,14 @@ std::string ObjectProperties::dump() os<<", mesh="<<mesh; os<<", visual_size="<<PP2(visual_size); os<<", textures=["; - for(u32 i=0; i<textures.size(); i++){ - os<<"\""<<textures[i]<<"\" "; + for (const std::string &texture : textures) { + os<<"\""<< texture <<"\" "; } os<<"]"; os<<", colors=["; - for(u32 i=0; i<colors.size(); i++){ - os<<"\""<<colors[i].getAlpha()<<","<<colors[i].getRed()<<","<<colors[i].getGreen()<<","<<colors[i].getBlue()<<"\" "; + for (const video::SColor &color : colors) { + os << "\"" << color.getAlpha() << "," << color.getRed() << "," + << color.getGreen() << "," << color.getBlue() << "\" "; } os<<"]"; os<<", spritediv="<<PP2(spritediv); @@ -74,8 +75,8 @@ void ObjectProperties::serialize(std::ostream &os) const os<<serializeString(visual); writeV2F1000(os, visual_size); writeU16(os, textures.size()); - for(u32 i=0; i<textures.size(); i++){ - os<<serializeString(textures[i]); + for (const std::string &texture : textures) { + os << serializeString(texture); } writeV2S16(os, spritediv); writeV2S16(os, initial_sprite_basepos); @@ -85,8 +86,8 @@ void ObjectProperties::serialize(std::ostream &os) const // Added in protocol version 14 os<<serializeString(mesh); writeU16(os, colors.size()); - for(u32 i=0; i<colors.size(); i++){ - writeARGB8(os, colors[i]); + for (video::SColor color : colors) { + writeARGB8(os, color); } writeU8(os, collideWithObjects); writeF1000(os,stepheight); |