Solid data is moving from the server to the client, read more

The APIs have access to the solid data, and I fixed a bug: Basically, the
template parameter for std::bitset  expects an integer representing the
number of bits to hold, but I initially misread it as the number of bytes.
This has been corrected.

I've also added a sandy beach to the generated island. I'm tempted to
start working on some simple generators soon.
This commit is contained in:
Kayne Ruse
2014-07-02 00:47:37 +10:00
parent 8ed308e89a
commit 93480be685
7 changed files with 53 additions and 13 deletions
+7 -5
View File
@@ -26,12 +26,12 @@
#include <cmath>
//the region's storage format
constexpr int REGION_WIDTH = 21;
constexpr int REGION_HEIGHT = 21;
constexpr int REGION_WIDTH = 20;
constexpr int REGION_HEIGHT = 20;
constexpr int REGION_DEPTH = 3;
//the size of the solid map
constexpr int REGION_SOLID = ceil(REGION_WIDTH * REGION_HEIGHT / 8.0);
constexpr int REGION_SOLID_FOOTPRINT = ceil(REGION_WIDTH * REGION_HEIGHT / 8.0);
class Region {
public:
@@ -51,15 +51,17 @@ public:
//accessors
int GetX() const { return x; }
int GetY() const { return y; }
std::bitset<REGION_WIDTH*REGION_HEIGHT>* GetSolidBitset() { return &solid; }
private:
const int x;
const int y;
type_t tiles[REGION_WIDTH][REGION_HEIGHT][REGION_DEPTH];
std::bitset<REGION_SOLID> solid;
std::bitset<REGION_WIDTH*REGION_HEIGHT> solid;
};
//the memory footprint of the tile and solid data; not including any metadata
constexpr int REGION_FOOTPRINT = REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + REGION_SOLID;
constexpr int REGION_FOOTPRINT = REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + REGION_SOLID_FOOTPRINT;
#endif