1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +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

@@ -560,6 +560,20 @@ public:
data = boost::optional<T>();
}
}
template <typename T>
void load(boost::multi_array<T, 3> & data)
{
ui32 length = readAndCheckLength();
ui32 x, y, z;
load(x);
load(y);
load(z);
data.resize(boost::extents[x][y][z]);
assert(length == data.num_elements()); //x*y*z should be equal to number of elements
for(ui32 i = 0; i < length; i++)
load(data.data()[i]);
}
};
class DLL_LINKAGE CLoadFile : public IBinaryReader

View File

@@ -350,6 +350,18 @@ public:
save((ui8)0);
}
}
template <typename T>
void save(const boost::multi_array<T, 3> &data)
{
ui32 length = data.num_elements();
*this & length;
auto shape = data.shape();
ui32 x = shape[0], y = shape[1], z = shape[2];
*this & x & y & z;
for(ui32 i = 0; i < length; i++)
save(data.data()[i]);
}
};
class DLL_LINKAGE CSaveFile : public IBinaryWriter