Add method for writing block/map feature indexes

develop
Petr Mrázek 2011-05-13 05:00:29 +02:00
parent 4631ec2e0d
commit 7dbb41cc66
2 changed files with 18 additions and 0 deletions

@ -551,6 +551,10 @@ namespace DFHack
* Get the feature indexes of a block
*/
bool ReadFeatures(uint32_t x, uint32_t y, uint32_t z, int16_t & local, int16_t & global);
/**
* Set the feature indexes of a block
*/
bool WriteFeatures(uint32_t x, uint32_t y, uint32_t z, const int16_t & local, const int16_t & global);
/**
* Get pointers to features of a block
*/

@ -833,6 +833,20 @@ bool Maps::ReadFeatures(uint32_t x, uint32_t y, uint32_t z, int16_t & local, int
return false;
}
bool Maps::WriteFeatures(uint32_t x, uint32_t y, uint32_t z, const int16_t & local, const int16_t & global)
{
MAPS_GUARD
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
Process * p = d->owner;
p->writeWord(addr + d->offsets.global_feature_offset, (const uint16_t&) global);
p->writeWord(addr + d->offsets.local_feature_offset, (const uint16_t&) local);
return true;
}
return false;
}
bool Maps::ReadFeatures(uint32_t x, uint32_t y, uint32_t z, t_feature ** local, t_feature ** global)
{
if(!d->FeaturesStarted) return false;