summaryrefslogtreecommitdiff
path: root/WorldSegment.h
diff options
context:
space:
mode:
authorJapa2010-04-09 14:24:27 +0000
committerJapa2010-04-09 14:24:27 +0000
commit114df922d3073bd296b38cf522997f520fb17850 (patch)
treec4cf372825118c3663cd77e18c69a6c3b59d070f /WorldSegment.h
parent81aefc8e03ff3f647494012e18bcdc8f33f4de42 (diff)
downloadstonesense-114df922d3073bd296b38cf522997f520fb17850.tar.gz
stonesense-114df922d3073bd296b38cf522997f520fb17850.tar.bz2
stonesense-114df922d3073bd296b38cf522997f520fb17850.tar.xz
updated trunk to the new graphics engine, and the latest DFhack
Diffstat (limited to 'WorldSegment.h')
-rw-r--r--WorldSegment.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/WorldSegment.h b/WorldSegment.h
new file mode 100644
index 0000000..62ba7c6
--- /dev/null
+++ b/WorldSegment.h
@@ -0,0 +1,52 @@
+#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(){
+ uint32_t num = (uint32_t)blocks.size();
+ for(uint32_t i = 0; i < num; i++){
+ delete(blocks[i]);
+ }
+ blocks.clear();
+ }
+
+ void Dispose(void){
+ free(blocksAsPointerVolume);
+ }
+
+ uint32_t getNumBlocks(){
+ return (uint32_t)blocks.size();
+ }
+
+ Block* getBlock(int32_t x, int32_t y, int32_t z);
+ Block* getBlockLocal(uint32_t x, uint32_t y, uint32_t z);
+ Block* getBlockRelativeTo(uint32_t x, uint32_t y, uint32_t z, dirRelative direction);
+ Block* getBlock(uint32_t index);
+ void addBlock(Block* b);
+ void drawAllBlocks();
+ bool CoordinateInsideSegment(uint32_t x, uint32_t y, uint32_t z);
+}; \ No newline at end of file