added copy constructor and assignment operator for Land record struct

sceneinput
Marc Zinnschlag 9 years ago
parent 890bbb6b11
commit b0641934d4

@ -1,5 +1,7 @@
#include "loadland.hpp"
#include <utility>
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
@ -215,4 +217,29 @@ bool Land::isDataLoaded(int flags) const
return (mDataLoaded & flags) == (flags & mDataTypes);
}
Land::Land (const Land& land)
: mFlags (land.mFlags), mX (land.mX), mY (land.mY), mPlugin (land.mPlugin),
mEsm (land.mEsm), mContext (land.mContext), mDataTypes (land.mDataTypes),
mDataLoaded (land.mDataLoaded),
mLandData (land.mLandData ? new LandData (*land.mLandData) : 0)
{}
Land& Land::operator= (Land land)
{
swap (land);
return *this;
}
void Land::swap (Land& land)
{
std::swap (mFlags, land.mFlags);
std::swap (mX, land.mX);
std::swap (mY, land.mY);
std::swap (mPlugin, land.mPlugin);
std::swap (mEsm, land.mEsm);
std::swap (mContext, land.mContext);
std::swap (mDataTypes, land.mDataTypes);
std::swap (mDataLoaded, land.mDataLoaded);
std::swap (mLandData, land.mLandData);
}
}

@ -116,9 +116,13 @@ struct Land
/// @note We only check data types that *can* be loaded (present in mDataTypes)
bool isDataLoaded(int flags) const;
Land (const Land& land);
Land& operator= (Land land);
void swap (Land& land);
private:
Land(const Land& land);
Land& operator=(const Land& land);
/// Loads data and marks it as loaded
/// \return true if data is actually loaded from file, false otherwise

Loading…
Cancel
Save