diff --git a/include/llmr/style/sprite.hpp b/include/llmr/style/sprite.hpp index 6dd4828e3..a4752f9eb 100644 --- a/include/llmr/style/sprite.hpp +++ b/include/llmr/style/sprite.hpp @@ -16,7 +16,7 @@ class Map; class SpritePosition { public: - SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t pixelRatio = 1); + explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t pixelRatio = 1); uint16_t x = 0, y = 0; uint16_t width = 0, height = 0; @@ -25,8 +25,8 @@ public: class ImagePosition { public: - ImagePosition() {} - ImagePosition(const vec2& size, vec2 tl, vec2 br); + explicit ImagePosition() {} + explicit ImagePosition(const vec2& size, vec2 tl, vec2 br); vec2 size = { 0, 0 }; vec2 tl = { 0, 0 }; diff --git a/src/style/sprite.cpp b/src/style/sprite.cpp index e91a24c49..016149385 100644 --- a/src/style/sprite.cpp +++ b/src/style/sprite.cpp @@ -101,15 +101,14 @@ void Sprite::parseJSON(std::shared_ptr &sprite) { if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); - - sprite->pos.insert({ name, { x, y, width, height, pixelRatio } }); + sprite->pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio }); } } } } ImagePosition Sprite::getPosition(const std::string& name, bool repeating) { - if (!isLoaded()) return {}; + if (!isLoaded()) return ImagePosition {}; // `repeating` indicates that the image will be used in a repeating pattern // repeating pattern images are assumed to have a 1px padding that mirrors the opposite edge @@ -117,10 +116,10 @@ ImagePosition Sprite::getPosition(const std::string& name, bool repeating) { int8_t offset = repeating ? 1 : 0; auto it = pos.find(name); - if (it == pos.end()) return {}; + if (it == pos.end()) return ImagePosition {}; SpritePosition& pos = it->second; - return { + return ImagePosition { { pos.width, pos.height