diff --git a/include/core/block.h b/include/core/block.h index 6a787265..0f30c4da 100644 --- a/include/core/block.h +++ b/include/core/block.h @@ -10,7 +10,8 @@ public: Block(); Block(uint16_t); Block(uint16_t tile, uint16_t collision, uint16_t elevation); - Block(const Block&); + Block(const Block &); + Block &operator=(const Block &); bool operator ==(Block); bool operator !=(Block); uint16_t tile:10; diff --git a/src/core/block.cpp b/src/core/block.cpp index 2a6b057d..1479ed10 100644 --- a/src/core/block.cpp +++ b/src/core/block.cpp @@ -1,25 +1,30 @@ #include "block.h" -Block::Block() : tile(0), collision(0), elevation(0) { -} +Block::Block() : tile(0), collision(0), elevation(0) { } -Block::Block(uint16_t tile, uint16_t collision, uint16_t elevation) { - this->tile = tile; - this->collision = collision; - this->elevation = elevation; -} +Block::Block(uint16_t tile, uint16_t collision, uint16_t elevation) : + tile(tile), + collision(collision), + elevation(elevation) +{ } -Block::Block(uint16_t word) -{ - tile = word & 0x3ff; - collision = (word >> 10) & 0x3; - elevation = (word >> 12) & 0xf; -} +Block::Block(uint16_t word) : + tile(word & 0x3ff), + collision((word >> 10) & 0x3), + elevation((word >> 12) & 0xf) +{ } -Block::Block(const Block &block) { - tile = block.tile; - collision = block.collision; - elevation = block.elevation; +Block::Block(const Block &other) : + tile(other.tile), + collision(other.collision), + elevation(other.elevation) +{ } + +Block &Block::operator=(const Block &other) { + tile = other.tile; + collision = other.collision; + elevation = other.elevation; + return *this; } uint16_t Block::rawValue() {