|
|
@ -107,9 +107,9 @@ bool Maps::IsValid ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// getter for map size in blocks
|
|
|
|
// 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;
|
|
|
|
x = y = z = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -118,14 +118,38 @@ void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
|
|
|
|
y = world->map.y_count_block;
|
|
|
|
y = world->map.y_count_block;
|
|
|
|
z = world->map.z_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
|
|
|
|
// 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;
|
|
|
|
x *= 16;
|
|
|
|
y *= 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
|
|
|
|
// getter for map position
|
|
|
|
void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z)
|
|
|
|
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;
|
|
|
|
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)
|
|
|
|
if (!block)
|
|
|
|
return false;
|
|
|
|
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)
|
|
|
|
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;
|
|
|
|
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)
|
|
|
|
if (!block)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
int idx = linear_index(block->block_events, which);
|
|
|
|
int idx = linear_index(block->block_events, which);
|
|
|
|
if (idx >= 0)
|
|
|
|
if (idx >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -493,6 +524,14 @@ bool Maps::RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, df::block_square
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
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] = {
|
|
|
|
static df::coord2d biome_offsets[9] = {
|
|
|
|
df::coord2d(-1,-1), df::coord2d(0,-1), df::coord2d(1,-1),
|
|
|
|
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 )
|
|
|
|
if ( x == 0 && y == 0 )
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
df::tiletype_shape shape1 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
df::tiletype_shape shape3 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
if ( shape1 == tiletype_shape::WALL ) {
|
|
|
|
if ( shape3 == tiletype_shape::WALL ) {
|
|
|
|
foundWall = true;
|
|
|
|
foundWall = true;
|
|
|
|
x = 2;
|
|
|
|
x = 2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -695,8 +734,8 @@ bool Maps::canStepBetween(df::coord pos1, df::coord pos2)
|
|
|
|
if ( x == 0 && y == 0 )
|
|
|
|
if ( x == 0 && y == 0 )
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
df::tiletype* type = Maps::getTileType(df::coord(pos1.x+x,pos1.y+y,pos1.z));
|
|
|
|
df::tiletype_shape shape1 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
df::tiletype_shape shape3 = ENUM_ATTR(tiletype,shape,*type);
|
|
|
|
if ( shape1 == tiletype_shape::WALL ) {
|
|
|
|
if ( shape3 == tiletype_shape::WALL ) {
|
|
|
|
foundWall = true;
|
|
|
|
foundWall = true;
|
|
|
|
x = 2;
|
|
|
|
x = 2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|