diff options
| author | Jonas Ask | 2009-10-22 12:54:20 +0000 |
|---|---|---|
| committer | Jonas Ask | 2009-10-22 12:54:20 +0000 |
| commit | fb452ce9594ea297aea586512ee66d47f232add5 (patch) | |
| tree | aa60bdc48c6ce33dfcb169d2013de5175f019e77 /WorldSegment.h | |
| parent | 4bcc80edf1d438ce6718df4d580b2579ba22afa2 (diff) | |
| download | stonesense-fb452ce9594ea297aea586512ee66d47f232add5.tar.gz stonesense-fb452ce9594ea297aea586512ee66d47f232add5.tar.bz2 stonesense-fb452ce9594ea297aea586512ee66d47f232add5.tar.xz | |
Cleaning up and some heavy refactoring.
Added a safety so users can't scroll to negative z-levels
Diffstat (limited to 'WorldSegment.h')
| -rw-r--r-- | WorldSegment.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/WorldSegment.h b/WorldSegment.h new file mode 100644 index 0000000..844dc6d --- /dev/null +++ b/WorldSegment.h @@ -0,0 +1,47 @@ +#pragma once
+
+#include "Block.h"
+
+class WorldSegment{
+private:
+ vector<Block*> blocks;
+public:
+ int x, y, z;
+ int sizex, sizey, sizez;
+ Crd3D regionSize;
+ Block** blocksAsPointerVolume;
+
+
+ WorldSegment(int x, int y, int z, int sizex, int sizey, int sizez){
+ this->x = x;
+ this->y = y;
+ this->z = z - sizez + 1;
+ this->sizex = sizex; this->sizey = sizey; this->sizez = sizez;
+
+ regionSize.x = regionSize.y = regionSize.z = 0;
+
+ uint32_t memoryNeeded = sizex * sizey * sizez * sizeof(Block*);
+ blocksAsPointerVolume = (Block**) malloc( memoryNeeded );
+ memset(blocksAsPointerVolume, 0, memoryNeeded);
+ }
+
+ ~WorldSegment(){
+ for(uint32_t i = 0; i < blocks.size(); i++){
+ free(blocks[i]);
+ }
+ }
+
+ void Dispose(void){
+ free(blocksAsPointerVolume);
+ }
+
+ uint32_t getNumBlocks(){
+ return (uint32_t)blocks.size();
+ }
+
+ Block* getBlock(uint32_t x, uint32_t y, uint32_t z);
+ Block* getBlock(uint32_t index);
+ void addBlock(Block* b);
+ void drawAllBlocks(BITMAP* target);
+ bool CoordinateInsideRegion(uint32_t x, uint32_t y, uint32_t z);
+};
\ No newline at end of file |
