1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-20 00:22:54 +02:00

Rotation rebase2 (#912)

* Instead of [x][y][z] coordinates, map will be stored as [z][x][y].
* Nullkiller AI can get it too.
* Use boost::multi_array instead of nested vectors
* In MapHandler too
* Rotate foreach algorithms, too
* VCAI gets rotated, too
This commit is contained in:
DjWarmonger
2022-09-18 16:39:10 +02:00
committed by GitHub
parent e85f8a56bb
commit 7ba271edf1
44 changed files with 502 additions and 1015 deletions

View File

@@ -502,28 +502,29 @@ const TerrainTile * CGameInfoCallback::getTile( int3 tile, bool verbose) const
}
//TODO: typedef?
std::shared_ptr<boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::getAllVisibleTiles() const
std::shared_ptr<const boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::getAllVisibleTiles() const
{
assert(player.is_initialized());
auto team = getPlayerTeam(player.get());
size_t width = gs->map->width;
size_t height = gs->map->height;
size_t levels = (gs->map->twoLevel ? 2 : 1);
size_t levels = gs->map->levels();
auto ptr = new boost::multi_array<TerrainTile*, 3>(boost::extents[levels][width][height]);
boost::multi_array<TerrainTile*, 3> tileArray(boost::extents[width][height][levels]);
for (size_t x = 0; x < width; x++)
for (size_t y = 0; y < height; y++)
for (size_t z = 0; z < levels; z++)
int3 tile;
for(tile.z = 0; tile.z < levels; tile.z++)
for(tile.x = 0; tile.x < width; tile.x++)
for(tile.y = 0; tile.y < height; tile.y++)
{
if (team->fogOfWarMap[x][y][z])
tileArray[x][y][z] = &gs->map->getTile(int3((si32)x, (si32)y, (si32)z));
if ((*team->fogOfWarMap)[tile.z][tile.x][tile.y])
(*ptr)[tile.z][tile.x][tile.y] = &gs->map->getTile(tile);
else
tileArray[x][y][z] = nullptr;
(*ptr)[tile.z][tile.x][tile.y] = nullptr;
}
return std::make_shared<boost::multi_array<TerrainTile*, 3>>(tileArray);
return std::shared_ptr<const boost::multi_array<TerrainTile*, 3>>(ptr);
}
EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, BuildingID ID )
@@ -694,7 +695,7 @@ CGameInfoCallback::CGameInfoCallback(CGameState *GS, boost::optional<PlayerColor
player = Player;
}
const std::vector< std::vector< std::vector<ui8> > > & CPlayerSpecificInfoCallback::getVisibilityMap() const
std::shared_ptr<const boost::multi_array<ui8, 3>> CPlayerSpecificInfoCallback::getVisibilityMap() const
{
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
return gs->getPlayerTeam(*player)->fogOfWarMap;