1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +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

@ -286,6 +286,8 @@ public:
CMapHeader();
virtual ~CMapHeader();
ui8 levels() const;
EMapFormat::EMapFormat version; /// The default value is EMapFormat::SOD.
si32 height; /// The default value is 72.
si32 width; /// The default value is 72.
@ -432,18 +434,18 @@ public:
h & questIdentifierToId;
//TODO: viccondetails
int level = twoLevel ? 2 : 1;
const int level = levels();
if(h.saving)
{
// Save terrain
for(int i = 0; i < width ; ++i)
for(int z = 0; z < level; ++z)
{
for(int j = 0; j < height ; ++j)
for(int x = 0; x < width; ++x)
{
for(int k = 0; k < level; ++k)
for(int y = 0; y < height; ++y)
{
h & terrain[i][j][k];
h & guardingCreaturePositions[i][j][k];
h & terrain[z][x][y];
h & guardingCreaturePositions[z][x][y];
}
}
}
@ -451,26 +453,27 @@ public:
else
{
// Load terrain
terrain = new TerrainTile**[width];
guardingCreaturePositions = new int3**[width];
for(int i = 0; i < width; ++i)
terrain = new TerrainTile**[level];
guardingCreaturePositions = new int3**[level];
for(int z = 0; z < level; ++z)
{
terrain[i] = new TerrainTile*[height];
guardingCreaturePositions[i] = new int3*[height];
for(int j = 0; j < height; ++j)
terrain[z] = new TerrainTile*[width];
guardingCreaturePositions[z] = new int3*[width];
for(int x = 0; x < width; ++x)
{
terrain[i][j] = new TerrainTile[level];
guardingCreaturePositions[i][j] = new int3[level];
terrain[z][x] = new TerrainTile[height];
guardingCreaturePositions[z][x] = new int3[height];
}
}
for(int i = 0; i < width ; ++i)
for(int z = 0; z < level; ++z)
{
for(int j = 0; j < height ; ++j)
for(int x = 0; x < width; ++x)
{
for(int k = 0; k < level; ++k)
for(int y = 0; y < height; ++y)
{
h & terrain[i][j][k];
h & guardingCreaturePositions[i][j][k];
h & terrain[z][x][y];
h & guardingCreaturePositions[z][x][y];
}
}
}