|
|
@ -38,6 +38,8 @@ distribution.
|
|
|
|
#include "df/item.h"
|
|
|
|
#include "df/item.h"
|
|
|
|
#include "df/inclusion_type.h"
|
|
|
|
#include "df/inclusion_type.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
|
|
|
|
namespace df {
|
|
|
|
namespace df {
|
|
|
|
struct world_region_details;
|
|
|
|
struct world_region_details;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,22 +129,22 @@ public:
|
|
|
|
/// Arbitrary tag field for flood fills etc.
|
|
|
|
/// Arbitrary tag field for flood fills etc.
|
|
|
|
int16_t &tag(df::coord2d p) {
|
|
|
|
int16_t &tag(df::coord2d p) {
|
|
|
|
if (!tags) init_tags();
|
|
|
|
if (!tags) init_tags();
|
|
|
|
return index_tile<int16_t&>(tags, p);
|
|
|
|
return index_tile(tags, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Base layer tile type (i.e. layer stone, veins, feature stone)
|
|
|
|
/// Base layer tile type (i.e. layer stone, veins, feature stone)
|
|
|
|
df::tiletype baseTiletypeAt(df::coord2d p)
|
|
|
|
df::tiletype baseTiletypeAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!tiles) init_tiles();
|
|
|
|
if (!tiles) init_tiles();
|
|
|
|
return index_tile<df::tiletype>(tiles->base_tiles,p);
|
|
|
|
return index_tile(tiles->base_tiles,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Base layer material (i.e. layer stone, veins, feature stone)
|
|
|
|
/// Base layer material (i.e. layer stone, veins, feature stone)
|
|
|
|
t_matpair baseMaterialAt(df::coord2d p)
|
|
|
|
t_matpair baseMaterialAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
return t_matpair(
|
|
|
|
return t_matpair(
|
|
|
|
index_tile<int16_t>(basemats->mat_type,p),
|
|
|
|
index_tile(basemats->mat_type,p),
|
|
|
|
index_tile<int16_t>(basemats->mat_index,p)
|
|
|
|
index_tile(basemats->mat_index,p)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Check if the base layer tile is a vein
|
|
|
|
/// Check if the base layer tile is a vein
|
|
|
@ -164,13 +166,13 @@ public:
|
|
|
|
int16_t veinMaterialAt(df::coord2d p)
|
|
|
|
int16_t veinMaterialAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
return index_tile<int16_t>(basemats->veinmat,p);
|
|
|
|
return index_tile(basemats->veinmat,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Vein type at pos (even if there is no vein tile)
|
|
|
|
/// Vein type at pos (even if there is no vein tile)
|
|
|
|
df::inclusion_type veinTypeAt(df::coord2d p)
|
|
|
|
df::inclusion_type veinTypeAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
return (df::inclusion_type)index_tile<uint8_t>(basemats->veintype,p);
|
|
|
|
return (df::inclusion_type)index_tile(basemats->veintype,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Sets the vein material at the specified tile position.
|
|
|
|
/** Sets the vein material at the specified tile position.
|
|
|
@ -207,7 +209,7 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!tiles) init_tiles();
|
|
|
|
if (!tiles) init_tiles();
|
|
|
|
if (tiles->con_info)
|
|
|
|
if (tiles->con_info)
|
|
|
|
return index_tile<df::tiletype>(tiles->con_info->tiles,p);
|
|
|
|
return index_tile(tiles->con_info->tiles,p);
|
|
|
|
return baseTiletypeAt(p);
|
|
|
|
return baseTiletypeAt(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Static layer material (i.e. base + constructions)
|
|
|
|
/// Static layer material (i.e. base + constructions)
|
|
|
@ -216,8 +218,8 @@ public:
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
if (!basemats) init_tiles(true);
|
|
|
|
if (tiles->con_info)
|
|
|
|
if (tiles->con_info)
|
|
|
|
return t_matpair(
|
|
|
|
return t_matpair(
|
|
|
|
index_tile<int16_t>(tiles->con_info->mat_type,p),
|
|
|
|
index_tile(tiles->con_info->mat_type,p),
|
|
|
|
index_tile<int16_t>(tiles->con_info->mat_index,p)
|
|
|
|
index_tile(tiles->con_info->mat_index,p)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return baseMaterialAt(p);
|
|
|
|
return baseMaterialAt(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -232,47 +234,50 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!block) return tiletype::Void;
|
|
|
|
if (!block) return tiletype::Void;
|
|
|
|
if (tiles)
|
|
|
|
if (tiles)
|
|
|
|
return index_tile<df::tiletype>(tiles->raw_tiles,p);
|
|
|
|
return index_tile(tiles->raw_tiles,p);
|
|
|
|
return index_tile<df::tiletype>(block->tiletype,p);
|
|
|
|
return index_tile(block->tiletype,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setTiletypeAt(df::coord2d, df::tiletype tt, bool force = false);
|
|
|
|
bool setTiletypeAt(df::coord2d, df::tiletype tt, bool force = false);
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t temperature1At(df::coord2d p)
|
|
|
|
uint16_t temperature1At(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return index_tile<uint16_t>(temp1,p);
|
|
|
|
return index_tile(temp1,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setTemp1At(df::coord2d p, uint16_t temp)
|
|
|
|
bool setTemp1At(df::coord2d p, uint16_t temp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
index_tile<uint16_t&>(temp1,p) = temp;
|
|
|
|
index_tile(temp1,p) = temp;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t temperature2At(df::coord2d p)
|
|
|
|
uint16_t temperature2At(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return index_tile<uint16_t>(temp2,p);
|
|
|
|
return index_tile(temp2,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setTemp2At(df::coord2d p, uint16_t temp)
|
|
|
|
bool setTemp2At(df::coord2d p, uint16_t temp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
dirty_temperatures = true;
|
|
|
|
index_tile<uint16_t&>(temp2,p) = temp;
|
|
|
|
index_tile(temp2,p) = temp;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
df::tile_designation DesignationAt(df::coord2d p)
|
|
|
|
df::tile_designation DesignationAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return index_tile<df::tile_designation>(designation,p);
|
|
|
|
return index_tile(designation,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setDesignationAt(df::coord2d p, df::tile_designation des)
|
|
|
|
bool setDesignationAt(df::coord2d p, df::tile_designation des, int32_t priority = 4000)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_designations = true;
|
|
|
|
dirty_designations = true;
|
|
|
|
|
|
|
|
designated_tiles[(p.x&15) + (p.y&15)*16] = true;
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
index_tile<df::tile_designation&>(designation,p) = des;
|
|
|
|
index_tile(designation,p) = des;
|
|
|
|
if(des.bits.dig && block)
|
|
|
|
if((des.bits.dig || des.bits.smooth) && block) {
|
|
|
|
block->flags.bits.designated = true;
|
|
|
|
block->flags.bits.designated = true;
|
|
|
|
|
|
|
|
setPriorityAt(p, priority);
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -281,21 +286,21 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
df::tile_occupancy OccupancyAt(df::coord2d p)
|
|
|
|
df::tile_occupancy OccupancyAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return index_tile<df::tile_occupancy>(occupancy,p);
|
|
|
|
return index_tile(occupancy,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setOccupancyAt(df::coord2d p, df::tile_occupancy des)
|
|
|
|
bool setOccupancyAt(df::coord2d p, df::tile_occupancy des)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!valid) return false;
|
|
|
|
if(!valid) return false;
|
|
|
|
dirty_occupancies = true;
|
|
|
|
dirty_occupancies = true;
|
|
|
|
index_tile<df::tile_occupancy&>(occupancy,p) = des;
|
|
|
|
index_tile(occupancy,p) = des;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool getFlagAt(df::coord2d p, df::tile_designation::Mask mask) {
|
|
|
|
bool getFlagAt(df::coord2d p, df::tile_designation::Mask mask) {
|
|
|
|
return (index_tile<df::tile_designation&>(designation,p).whole & mask) != 0;
|
|
|
|
return (index_tile(designation,p).whole & mask) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool getFlagAt(df::coord2d p, df::tile_occupancy::Mask mask) {
|
|
|
|
bool getFlagAt(df::coord2d p, df::tile_occupancy::Mask mask) {
|
|
|
|
return (index_tile<df::tile_occupancy&>(occupancy,p).whole & mask) != 0;
|
|
|
|
return (index_tile(occupancy,p).whole & mask) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool setFlagAt(df::coord2d p, df::tile_designation::Mask mask, bool set);
|
|
|
|
bool setFlagAt(df::coord2d p, df::tile_designation::Mask mask, bool set);
|
|
|
|
bool setFlagAt(df::coord2d p, df::tile_occupancy::Mask mask, bool set);
|
|
|
|
bool setFlagAt(df::coord2d p, df::tile_occupancy::Mask mask, bool set);
|
|
|
@ -303,7 +308,7 @@ public:
|
|
|
|
int itemCountAt(df::coord2d p)
|
|
|
|
int itemCountAt(df::coord2d p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!item_counts) init_item_counts();
|
|
|
|
if (!item_counts) init_item_counts();
|
|
|
|
return index_tile<int>(item_counts,p);
|
|
|
|
return index_tile(item_counts,p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
t_blockflags BlockFlags()
|
|
|
|
t_blockflags BlockFlags()
|
|
|
@ -316,7 +321,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
int biomeIndexAt(df::coord2d p);
|
|
|
|
int biomeIndexAt(df::coord2d p);
|
|
|
|
int layerIndexAt(df::coord2d p) {
|
|
|
|
int layerIndexAt(df::coord2d p) {
|
|
|
|
return index_tile<df::tile_designation&>(designation,p).bits.geolayer_index;
|
|
|
|
return index_tile(designation,p).bits.geolayer_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
df::coord2d biomeRegionAt(df::coord2d p);
|
|
|
|
df::coord2d biomeRegionAt(df::coord2d p);
|
|
|
@ -342,13 +347,15 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
|
|
bool valid;
|
|
|
|
bool valid:1;
|
|
|
|
bool dirty_designations:1;
|
|
|
|
bool dirty_designations:1;
|
|
|
|
bool dirty_tiles:1;
|
|
|
|
bool dirty_tiles:1;
|
|
|
|
bool dirty_veins:1;
|
|
|
|
bool dirty_veins:1;
|
|
|
|
bool dirty_temperatures:1;
|
|
|
|
bool dirty_temperatures:1;
|
|
|
|
bool dirty_occupancies:1;
|
|
|
|
bool dirty_occupancies:1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::bitset<16*16> designated_tiles;
|
|
|
|
|
|
|
|
|
|
|
|
DFCoord bcoord;
|
|
|
|
DFCoord bcoord;
|
|
|
|
|
|
|
|
|
|
|
|
// Custom tags for floodfill
|
|
|
|
// Custom tags for floodfill
|
|
|
@ -548,13 +555,11 @@ class DFHACK_EXPORT MapCache
|
|
|
|
return b ? b->DesignationAt(tilecoord) : df::tile_designation();
|
|
|
|
return b ? b->DesignationAt(tilecoord) : df::tile_designation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// priority is optional, only set if >= 0
|
|
|
|
// priority is optional, only set if >= 0
|
|
|
|
bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = -1)
|
|
|
|
bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = 4000)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Block *b = BlockAtTile(tilecoord))
|
|
|
|
if (Block *b = BlockAtTile(tilecoord))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!b->setDesignationAt(tilecoord, des))
|
|
|
|
if (!b->setDesignationAt(tilecoord, des, priority))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (priority >= 0 && b->setPriorityAt(tilecoord, priority))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -599,15 +604,8 @@ class DFHACK_EXPORT MapCache
|
|
|
|
return b ? b->removeItemOnGround(item) : false;
|
|
|
|
return b ? b->removeItemOnGround(item) : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WriteAll()
|
|
|
|
bool WriteAll();
|
|
|
|
{
|
|
|
|
|
|
|
|
std::map<DFCoord, Block *>::iterator p;
|
|
|
|
|
|
|
|
for(p = blocks.begin(); p != blocks.end(); p++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
p->second->Write();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void trash()
|
|
|
|
void trash()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::map<DFCoord, Block *>::iterator p;
|
|
|
|
std::map<DFCoord, Block *>::iterator p;
|
|
|
|