BIG REFACTOR
This commit is contained in:
@@ -12,23 +12,30 @@
|
||||
|
||||
namespace td {
|
||||
namespace game {
|
||||
typedef std::pair<std::int16_t, std::int16_t> ChunkCoord;
|
||||
|
||||
struct ChunkCoord {
|
||||
std::int16_t x, y;
|
||||
|
||||
friend bool operator==(const td::game::ChunkCoord& first, const td::game::ChunkCoord& other) {
|
||||
return first.x == other.x && first.y == other.y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<td::game::ChunkCoord> {
|
||||
std::size_t operator()(const td::game::ChunkCoord& key) const {
|
||||
// Compute individual hash values for first,
|
||||
// second and third and combine them using XOR
|
||||
// and bit shifting:
|
||||
return ((std::hash<std::int16_t>()(key.first) ^ (std::hash<std::int16_t>()(key.second) << 1)) >> 1);
|
||||
return std::hash<std::int16_t>()(key.x) ^ std::hash<std::int16_t>()(key.y);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace td {
|
||||
|
||||
namespace protocol {
|
||||
|
||||
class WorldBeginDataPacket;
|
||||
@@ -91,12 +98,13 @@ typedef std::vector<std::uint16_t> ChunkPalette;
|
||||
|
||||
typedef std::shared_ptr<WalkableTile> WalkableTilePtr;
|
||||
|
||||
typedef std::array<std::uint16_t, 32 * 32> ChunkData;
|
||||
typedef std::uint32_t TileIndex;
|
||||
|
||||
//32 x 32 area
|
||||
struct Chunk {
|
||||
enum { ChunkWidth = 32, ChunkHeight = 32, ChunkSize = ChunkWidth * ChunkHeight };
|
||||
typedef std::array<std::uint16_t, ChunkSize> ChunkData;
|
||||
|
||||
// stores index of tile palette
|
||||
ChunkData tiles{ 0 };
|
||||
ChunkPalette palette;
|
||||
|
||||
Reference in New Issue
Block a user