|
|
|
@ -107,9 +107,9 @@ bool Maps::IsValid ()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getter for map size in blocks
|
|
|
|
|
void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
|
|
|
|
|
inline void getSizeInline (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
|
{
|
|
|
|
|
if (!IsValid())
|
|
|
|
|
if (!Maps::IsValid())
|
|
|
|
|
{
|
|
|
|
|
x = y = z = 0;
|
|
|
|
|
return;
|
|
|
|
@ -118,14 +118,38 @@ void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
|
|
|
|
|
y = world->map.y_count_block;
|
|
|
|
|
z = world->map.z_count_block;
|
|
|
|
|
}
|
|
|
|
|
void Maps::getSize (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
|
{
|
|
|
|
|
getSizeInline(x, y, z);
|
|
|
|
|
}
|
|
|
|
|
void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z) //todo: deprecate me
|
|
|
|
|
{
|
|
|
|
|
int32_t sx, sy, sz;
|
|
|
|
|
getSizeInline(sx, sy, sz);
|
|
|
|
|
x = uint32_t(sx);
|
|
|
|
|
y = uint32_t(sy);
|
|
|
|
|
z = uint32_t(sz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getter for map size in tiles
|
|
|
|
|
void Maps::getTileSize (uint32_t& x, uint32_t& y, uint32_t& z)
|
|
|
|
|
inline void getTileSizeInline (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
|
{
|
|
|
|
|
getSize(x, y, z);
|
|
|
|
|
getSizeInline(x, y, z);
|
|
|
|
|
x *= 16;
|
|
|
|
|
y *= 16;
|
|
|
|
|
}
|
|
|
|
|
void Maps::getTileSize (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
|
{
|
|
|
|
|
getTileSizeInline(x, y, z);
|
|
|
|
|
}
|
|
|
|
|
void Maps::getTileSize (uint32_t& x, uint32_t& y, uint32_t& z) //todo: deprecate me
|
|
|
|
|
{
|
|
|
|
|
int32_t sx, sy, sz;
|
|
|
|
|
getTileSizeInline(sx, sy, sz);
|
|
|
|
|
x = uint32_t(sx);
|
|
|
|
|
y = uint32_t(sy);
|
|
|
|
|
z = uint32_t(sz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getter for map position
|
|
|
|
|
void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
@ -375,12 +399,20 @@ bool GetLocalFeature(t_feature &feature, df::coord2d rgn_pos, int32_t index)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Maps::ReadFeatures(uint32_t x, uint32_t y, uint32_t z, t_feature *local, t_feature *global)
|
|
|
|
|
inline bool ReadFeaturesInline(int32_t x, int32_t y, int32_t z, t_feature *local, t_feature *global)
|
|
|
|
|
{
|
|
|
|
|
df::map_block *block = getBlock(x,y,z);
|
|
|
|
|
df::map_block* block = Maps::getBlock(x, y, z);
|
|
|
|
|
if (!block)
|
|
|
|
|
return false;
|
|
|
|
|
return ReadFeatures(block, local, global);
|
|
|
|
|
return Maps::ReadFeatures(block, local, global);
|
|
|
|
|
}
|
|
|
|
|
bool Maps::ReadFeatures(int32_t x, int32_t y, int32_t z, t_feature *local, t_feature *global)
|
|
|
|
|
{
|
|
|
|
|
return ReadFeaturesInline(x, y, z, local, global);
|
|
|
|
|
}
|
|
|
|
|
bool Maps::ReadFeatures(uint32_t x, uint32_t y, uint32_t z, t_feature *local, t_feature *global) //todo: deprecate me
|
|
|
|
|
{
|
|
|
|
|
return ReadFeaturesInline(int32_t(x), int32_t(y), int32_t(z), local, global);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Maps::ReadFeatures(df::map_block * block, t_feature * local, t_feature * global)
|
|
|
|
@ -477,12 +509,11 @@ bool Maps::SortBlockEvents(df::map_block *block,
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Maps::RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, df::block_square_event * which)
|
|
|
|
|
inline bool RemoveBlockEventInline(int32_t x, int32_t y, int32_t z, df::block_square_event * which)
|
|
|
|
|
{
|
|
|
|
|
df::map_block * block = getBlock(x,y,z);
|
|
|
|
|
df::map_block* block = Maps::getBlock(x, y, z);
|
|
|
|
|
if (!block)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
int idx = linear_index(block->block_events, which);
|
|
|
|
|
if (idx >= 0)
|
|
|
|
|
{
|
|
|
|
@ -493,6 +524,14 @@ bool Maps::RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, df::block_square
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
inline bool Maps::RemoveBlockEvent(int32_t x, int32_t y, int32_t z, df::block_square_event * which)
|
|
|
|
|
{
|
|
|
|
|
return RemoveBlockEventInline(x, y, z, which);
|
|
|
|
|
}
|
|
|
|
|
bool Maps::RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, df::block_square_event * which) //todo: deprecate me
|
|
|
|
|
{
|
|
|
|
|
return RemoveBlockEventInline(int32_t(x), int32_t(y), int32_t(z), which);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static df::coord2d biome_offsets[9] = {
|
|
|
|
|
df::coord2d(-1,-1), df::coord2d(0,-1), df::coord2d(1,-1),
|
|
|
|
@ -658,8 +697,8 @@ bool Maps::canStepBetween(df::coord pos1, df::coord pos2)
|
|
|
|
|
if ( x == 0 && y == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
|
df::tiletype_shape shape1 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
|
if ( shape1 == tiletype_shape::WALL ) {
|
|
|
|
|
df::tiletype_shape shape3 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
|
if ( shape3 == tiletype_shape::WALL ) {
|
|
|
|
|
foundWall = true;
|
|
|
|
|
x = 2;
|
|
|
|
|
break;
|
|
|
|
@ -695,8 +734,8 @@ bool Maps::canStepBetween(df::coord pos1, df::coord pos2)
|
|
|
|
|
if ( x == 0 && y == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
|
df::tiletype_shape shape1 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
|
if ( shape1 == tiletype_shape::WALL ) {
|
|
|
|
|
df::tiletype_shape shape3 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
|
if ( shape3 == tiletype_shape::WALL ) {
|
|
|
|
|
foundWall = true;
|
|
|
|
|
x = 2;
|
|
|
|
|
break;
|
|
|
|
|