1
0

Split cCoord template into one and two data types

This commit is contained in:
Tiger Wang 2014-02-01 21:40:02 +00:00
parent 6f660b379e
commit b0784d1931
2 changed files with 34 additions and 12 deletions

View File

@ -498,15 +498,14 @@ public:
/// Generic template that can store any kind of data together with a triplet of 3 coords: /** Generic template that can store any kind of data together with a triplet of 3 coords*/
template <typename X, typename Y> class cCoordWithData template <typename X> class cCoordWithData
{ {
public: public:
int x; int x;
int y; int y;
int z; int z;
X Data; X Data;
Y SecondData;
cCoordWithData(int a_X, int a_Y, int a_Z) : cCoordWithData(int a_X, int a_Y, int a_Z) :
x(a_X), y(a_Y), z(a_Z) x(a_X), y(a_Y), z(a_Z)
@ -517,18 +516,41 @@ public:
x(a_X), y(a_Y), z(a_Z), Data(a_Data) x(a_X), y(a_Y), z(a_Z), Data(a_Data)
{ {
} }
cCoordWithData(int a_X, int a_Y, int a_Z, const X & a_Data, const Y & a_SecondData) :
x(a_X), y(a_Y), z(a_Z), Data(a_Data), SecondData(a_SecondData)
{
}
} ; } ;
typedef cCoordWithData<int, void *> cCoordWithInt; typedef cCoordWithData<int> cCoordWithInt;
typedef cCoordWithData<BLOCKTYPE, bool> cCoordWithBlockAndBool; typedef cCoordWithData<BLOCKTYPE> cCoordWithBlock;
typedef std::list<cCoordWithInt> cCoordWithIntList; typedef std::list<cCoordWithInt> cCoordWithIntList;
typedef std::vector<cCoordWithInt> cCoordWithIntVector; typedef std::vector<cCoordWithInt> cCoordWithIntVector;
/** Generic template that can store two types of any kind of data together with a triplet of 3 coords */
template <typename X, typename Z> class cCoordWithDoubleData
{
public:
int x;
int y;
int z;
X Data;
Z DataTwo;
cCoordWithDoubleData(int a_X, int a_Y, int a_Z) :
x(a_X), y(a_Y), z(a_Z)
{
}
cCoordWithDoubleData(int a_X, int a_Y, int a_Z, const X & a_Data, const Z & a_DataTwo) :
x(a_X), y(a_Y), z(a_Z), Data(a_Data), DataTwo(a_DataTwo)
{
}
};
typedef cCoordWithDoubleData <BLOCKTYPE, bool> cCoordWithBlockAndBool;
typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector; typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector;

View File

@ -169,7 +169,7 @@ void cRedstoneSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChu
{ {
if (!IsAllowedBlock(Block)) if (!IsAllowedBlock(Block))
{ {
itr->SecondData = true; // The new blocktype is not redstone; it must be queued to be removed from this list itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list
} }
else else
{ {
@ -209,7 +209,7 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c
for (cRedstoneSimulatorChunkData::iterator dataitr = ChunkData.begin(); dataitr != ChunkData.end();) for (cRedstoneSimulatorChunkData::iterator dataitr = ChunkData.begin(); dataitr != ChunkData.end();)
{ {
if (dataitr->SecondData) if (dataitr->DataTwo)
{ {
dataitr = ChunkData.erase(dataitr); dataitr = ChunkData.erase(dataitr);
continue; continue;