2011-06-16 15:53:39 -06:00
|
|
|
/*
|
|
|
|
https://github.com/peterix/dfhack
|
|
|
|
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
|
2011-04-10 05:12:28 -06:00
|
|
|
#pragma once
|
2011-03-10 19:09:45 -07:00
|
|
|
#ifndef MAPEXTRAS_H
|
|
|
|
#define MAPEXTRAS_H
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "TileTypes.h"
|
2011-06-15 09:35:47 -06:00
|
|
|
#include <stdint.h>
|
2011-03-10 19:09:45 -07:00
|
|
|
#include <cstring>
|
2012-01-19 13:11:52 -07:00
|
|
|
#include "df/map_block.h"
|
|
|
|
#include "df/block_square_event_mineralst.h"
|
2012-01-19 20:44:17 -07:00
|
|
|
using namespace DFHack;
|
2011-03-10 19:09:45 -07:00
|
|
|
namespace MapExtras
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
void SquashVeins (DFCoord bcoord, mapblock40d & mb, t_blockmaterials & materials)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
memset(materials,-1,sizeof(materials));
|
2012-01-19 13:11:52 -07:00
|
|
|
std::vector <df::block_square_event_mineralst *> veins;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::SortBlockEvents(bcoord.x,bcoord.y,bcoord.z,&veins);
|
2011-03-10 19:09:45 -07:00
|
|
|
//iterate through block rows
|
|
|
|
for(uint32_t j = 0;j<16;j++)
|
|
|
|
{
|
|
|
|
//iterate through columns
|
|
|
|
for (uint32_t k = 0; k< 16;k++)
|
|
|
|
{
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = mb.tiletypes[k][j];
|
|
|
|
if(DFHack::tileMaterial(tt) == tiletype_material::MINERAL)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
for(int i = (int) veins.size() - 1; i >= 0;i--)
|
|
|
|
{
|
2012-01-19 13:11:52 -07:00
|
|
|
if(!!(((1 << k) & veins[i]->tile_bitmask[j]) >> k))
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
2012-01-19 13:11:52 -07:00
|
|
|
materials[k][j] = veins[i]->inorganic_mat;
|
2011-03-10 19:09:45 -07:00
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-06 04:26:18 -06:00
|
|
|
void SquashRocks ( std::vector< std::vector <uint16_t> > * layerassign, DFHack::mapblock40d & mb, DFHack::t_blockmaterials & materials)
|
2011-04-10 09:01:58 -06:00
|
|
|
{
|
|
|
|
// get the layer materials
|
|
|
|
for(uint32_t xx = 0;xx<16;xx++)
|
|
|
|
{
|
|
|
|
for (uint32_t yy = 0; yy< 16;yy++)
|
|
|
|
{
|
|
|
|
uint8_t test = mb.designation[xx][yy].bits.biome;
|
|
|
|
if( test >= sizeof(mb.biome_indices))
|
|
|
|
{
|
|
|
|
materials[xx][yy] = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2012-02-13 08:56:35 -07:00
|
|
|
if (mb.biome_indices[test] >= layerassign->size())
|
|
|
|
{
|
|
|
|
materials[xx][yy] = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-10 09:01:58 -06:00
|
|
|
materials[xx][yy] =
|
|
|
|
layerassign->at(mb.biome_indices[test])[mb.designation[xx][yy].bits.geolayer_index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-10 19:09:45 -07:00
|
|
|
class Block
|
|
|
|
{
|
|
|
|
public:
|
2012-01-19 20:44:17 -07:00
|
|
|
Block(DFHack::DFCoord _bcoord, std::vector< std::vector <uint16_t> > * layerassign = 0)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
dirty_designations = false;
|
|
|
|
dirty_tiletypes = false;
|
|
|
|
dirty_temperatures = false;
|
|
|
|
dirty_blockflags = false;
|
2011-04-27 17:36:31 -06:00
|
|
|
dirty_occupancies = false;
|
2011-03-10 19:09:45 -07:00
|
|
|
valid = false;
|
|
|
|
bcoord = _bcoord;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(Maps::ReadBlock40d(bcoord.x,bcoord.y,bcoord.z,&raw))
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::ReadTemperatures(bcoord.x,bcoord.y, bcoord.z,&temp1,&temp2);
|
|
|
|
SquashVeins(bcoord,raw,veinmats);
|
2011-04-10 09:01:58 -06:00
|
|
|
if(layerassign)
|
|
|
|
SquashRocks(layerassign,raw,basemats);
|
|
|
|
else
|
|
|
|
memset(basemats,-1,sizeof(basemats));
|
2011-03-10 19:09:45 -07:00
|
|
|
valid = true;
|
|
|
|
}
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
int16_t veinMaterialAt(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
2011-04-09 22:17:11 -06:00
|
|
|
return veinmats[p.x][p.y];
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
int16_t baseMaterialAt(df::coord2d p)
|
2011-04-10 09:01:58 -06:00
|
|
|
{
|
|
|
|
return basemats[p.x][p.y];
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
void ClearMaterialAt(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
2011-04-09 22:17:11 -06:00
|
|
|
veinmats[p.x][p.y] = -1;
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
|
|
|
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype TileTypeAt(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
return raw.tiletypes[p.x][p.y];
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
bool setTiletypeAt(df::coord2d p, df::tiletype tiletype)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_tiletypes = true;
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
raw.tiletypes[p.x][p.y] = tiletype;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:28:00 -07:00
|
|
|
uint16_t temperature1At(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
return temp1[p.x][p.y];
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setTemp1At(df::coord2d p, uint16_t temp)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
temp1[p.x][p.y] = temp;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:28:00 -07:00
|
|
|
uint16_t temperature2At(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
return temp2[p.x][p.y];
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setTemp2At(df::coord2d p, uint16_t temp)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
temp2[p.x][p.y] = temp;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:28:00 -07:00
|
|
|
df::tile_designation DesignationAt(df::coord2d p)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
return raw.designation[p.x][p.y];
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setDesignationAt(df::coord2d p, df::tile_designation des)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_designations = true;
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
raw.designation[p.x][p.y] = des;
|
2011-08-22 07:18:35 -06:00
|
|
|
if(des.bits.dig)
|
|
|
|
{
|
|
|
|
dirty_blockflags = true;
|
|
|
|
raw.blockflags.bits.designated = true;
|
|
|
|
}
|
2011-03-10 19:09:45 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-20 03:28:00 -07:00
|
|
|
df::tile_occupancy OccupancyAt(df::coord2d p)
|
2011-04-27 17:36:31 -06:00
|
|
|
{
|
|
|
|
return raw.occupancy[p.x][p.y];
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setOccupancyAt(df::coord2d p, df::tile_occupancy des)
|
2011-04-27 17:36:31 -06:00
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_occupancies = true;
|
|
|
|
raw.occupancy[p.x][p.y] = des;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-10 19:09:45 -07:00
|
|
|
DFHack::t_blockflags BlockFlags()
|
|
|
|
{
|
|
|
|
return raw.blockflags;
|
|
|
|
}
|
|
|
|
bool setBlockFlags(DFHack::t_blockflags des)
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_blockflags = true;
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
raw.blockflags = des;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Write ()
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
if(dirty_designations)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::WriteDesignations(bcoord.x,bcoord.y,bcoord.z, &raw.designation);
|
|
|
|
Maps::WriteDirtyBit(bcoord.x,bcoord.y,bcoord.z,true);
|
2011-03-10 19:09:45 -07:00
|
|
|
dirty_designations = false;
|
|
|
|
}
|
|
|
|
if(dirty_tiletypes)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::WriteTileTypes(bcoord.x,bcoord.y,bcoord.z, &raw.tiletypes);
|
2011-03-10 19:09:45 -07:00
|
|
|
dirty_tiletypes = false;
|
|
|
|
}
|
|
|
|
if(dirty_temperatures)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::WriteTemperatures(bcoord.x,bcoord.y,bcoord.z, &temp1, &temp2);
|
2011-03-10 19:09:45 -07:00
|
|
|
dirty_temperatures = false;
|
|
|
|
}
|
|
|
|
if(dirty_blockflags)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::WriteBlockFlags(bcoord.x,bcoord.y,bcoord.z,raw.blockflags);
|
2011-03-10 19:09:45 -07:00
|
|
|
dirty_blockflags = false;
|
|
|
|
}
|
2011-04-27 17:36:31 -06:00
|
|
|
if(dirty_occupancies)
|
|
|
|
{
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::WriteOccupancy(bcoord.x,bcoord.y,bcoord.z,&raw.occupancy);
|
2011-04-27 17:36:31 -06:00
|
|
|
dirty_occupancies = false;
|
|
|
|
}
|
2011-03-10 19:09:45 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool valid:1;
|
|
|
|
bool dirty_designations:1;
|
|
|
|
bool dirty_tiletypes:1;
|
|
|
|
bool dirty_temperatures:1;
|
|
|
|
bool dirty_blockflags:1;
|
2011-04-27 17:36:31 -06:00
|
|
|
bool dirty_occupancies:1;
|
2011-03-10 19:09:45 -07:00
|
|
|
DFHack::mapblock40d raw;
|
|
|
|
DFHack::DFCoord bcoord;
|
2011-04-09 22:17:11 -06:00
|
|
|
DFHack::t_blockmaterials veinmats;
|
2011-04-10 09:01:58 -06:00
|
|
|
DFHack::t_blockmaterials basemats;
|
2011-03-10 19:09:45 -07:00
|
|
|
DFHack::t_temperatures temp1;
|
|
|
|
DFHack::t_temperatures temp2;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MapCache
|
|
|
|
{
|
|
|
|
public:
|
2012-01-19 20:44:17 -07:00
|
|
|
MapCache()
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
valid = 0;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_bmax, y_bmax, z_max);
|
|
|
|
validgeo = Maps::ReadGeology( layerassign );
|
2011-03-10 19:09:45 -07:00
|
|
|
valid = true;
|
|
|
|
};
|
|
|
|
~MapCache()
|
|
|
|
{
|
2011-04-10 10:41:49 -06:00
|
|
|
trash();
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
|
|
|
bool isValid ()
|
|
|
|
{
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
/// get the map block at a *block* coord. Block coord = tile coord / 16
|
|
|
|
Block * BlockAt (DFHack::DFCoord blockcoord)
|
|
|
|
{
|
|
|
|
if(!valid)
|
|
|
|
return 0;
|
2011-07-06 04:26:18 -06:00
|
|
|
std::map <DFHack::DFCoord, Block*>::iterator iter = blocks.find(blockcoord);
|
2011-03-10 19:09:45 -07:00
|
|
|
if(iter != blocks.end())
|
|
|
|
{
|
|
|
|
return (*iter).second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(blockcoord.x < x_bmax && blockcoord.y < y_bmax && blockcoord.z < z_max)
|
|
|
|
{
|
2011-04-10 09:01:58 -06:00
|
|
|
Block * nblo;
|
|
|
|
if(validgeo)
|
2012-01-19 20:44:17 -07:00
|
|
|
nblo = new Block(blockcoord, &layerassign);
|
2011-04-10 09:01:58 -06:00
|
|
|
else
|
2012-01-19 20:44:17 -07:00
|
|
|
nblo = new Block(blockcoord);
|
2011-03-10 19:09:45 -07:00
|
|
|
blocks[blockcoord] = nblo;
|
|
|
|
return nblo;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tiletypeAt (DFHack::DFCoord tilecoord)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->TileTypeAt(tilecoord % 16);
|
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
return tiletype::Void;
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
2012-02-13 15:56:33 -07:00
|
|
|
bool setTiletypeAt(DFHack::DFCoord tilecoord, df::tiletype tiletype)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setTiletypeAt(tilecoord % 16, tiletype);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t temperature1At (DFHack::DFCoord tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->temperature1At(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setTemp1At(DFHack::DFCoord tilecoord, uint16_t temperature)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setTemp1At(tilecoord % 16, temperature);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t temperature2At (DFHack::DFCoord tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->temperature2At(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-01-20 03:28:00 -07:00
|
|
|
bool setTemp2At(DFHack::DFCoord tilecoord, uint16_t temperature)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setTemp2At(tilecoord % 16, temperature);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-09 22:17:11 -06:00
|
|
|
int16_t veinMaterialAt (DFHack::DFCoord tilecoord)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
2011-04-09 22:17:11 -06:00
|
|
|
return b->veinMaterialAt(tilecoord % 16);
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-04-10 09:01:58 -06:00
|
|
|
int16_t baseMaterialAt (DFHack::DFCoord tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->baseMaterialAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-10 19:09:45 -07:00
|
|
|
bool clearMaterialAt (DFHack::DFCoord tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->ClearMaterialAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation designationAt (DFHack::DFCoord tilecoord)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->DesignationAt(tilecoord % 16);
|
|
|
|
}
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_designation temp;
|
2011-03-10 19:09:45 -07:00
|
|
|
temp.whole = 0;
|
|
|
|
return temp;
|
|
|
|
}
|
2012-01-19 13:11:52 -07:00
|
|
|
bool setDesignationAt (DFHack::DFCoord tilecoord, df::tile_designation des)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setDesignationAt(tilecoord % 16, des);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_occupancy occupancyAt (DFHack::DFCoord tilecoord)
|
2011-04-27 17:36:31 -06:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->OccupancyAt(tilecoord % 16);
|
|
|
|
}
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_occupancy temp;
|
2011-04-27 17:36:31 -06:00
|
|
|
temp.whole = 0;
|
|
|
|
return temp;
|
|
|
|
}
|
2012-01-19 13:11:52 -07:00
|
|
|
bool setOccupancyAt (DFHack::DFCoord tilecoord, df::tile_occupancy occ)
|
2011-04-27 17:36:31 -06:00
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setOccupancyAt(tilecoord % 16, occ);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-10 19:09:45 -07:00
|
|
|
bool testCoord (DFHack::DFCoord tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool WriteAll()
|
|
|
|
{
|
2011-07-06 04:26:18 -06:00
|
|
|
std::map<DFHack::DFCoord, Block *>::iterator p;
|
2011-03-10 19:09:45 -07:00
|
|
|
for(p = blocks.begin(); p != blocks.end(); p++)
|
|
|
|
{
|
|
|
|
p->second->Write();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-04-10 10:41:49 -06:00
|
|
|
void trash()
|
|
|
|
{
|
2011-07-06 04:26:18 -06:00
|
|
|
std::map<DFHack::DFCoord, Block *>::iterator p;
|
2011-04-10 10:41:49 -06:00
|
|
|
for(p = blocks.begin(); p != blocks.end(); p++)
|
|
|
|
{
|
|
|
|
delete p->second;
|
|
|
|
}
|
|
|
|
blocks.clear();
|
|
|
|
}
|
2011-03-10 19:09:45 -07:00
|
|
|
private:
|
|
|
|
volatile bool valid;
|
2011-04-10 09:01:58 -06:00
|
|
|
volatile bool validgeo;
|
2011-03-10 19:09:45 -07:00
|
|
|
uint32_t x_bmax;
|
|
|
|
uint32_t y_bmax;
|
|
|
|
uint32_t x_tmax;
|
|
|
|
uint32_t y_tmax;
|
|
|
|
uint32_t z_max;
|
2011-07-06 04:26:18 -06:00
|
|
|
std::vector< std::vector <uint16_t> > layerassign;
|
|
|
|
std::map<DFHack::DFCoord, Block *> blocks;
|
2011-03-10 19:09:45 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|