summaryrefslogtreecommitdiff
path: root/src/lockedarray.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-22 19:45:03 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-22 19:45:56 +0100
commit0c43d04b438d41c277ae80402d4b4888db1a0b64 (patch)
tree3aaeb75ecd1bcbe85decedab5f1fa426fe0411e3 /src/lockedarray.h
parenta7f5eaeb7f643658d356533a608f0f18d85b6d32 (diff)
parent401802c1d7a1b3d659bdc53a45d9a6292fc1121e (diff)
downloadmana-client-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.gz
mana-client-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.bz2
mana-client-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.xz
mana-client-0c43d04b438d41c277ae80402d4b4888db1a0b64.zip
Merged the tmwserv client with the eAthena client
This merge involved major changes on both sides, and as such took several weeks. Lots of things are expected to be broken now, however, we now have a single code base to improve and extend, which can be compiled to support either eAthena or tmwserv. In the coming months, the plan is to work towards a client that supports both eAthena and tmwserv, without needing to be recompiled. Conflicts: Everywhere!
Diffstat (limited to 'src/lockedarray.h')
-rw-r--r--src/lockedarray.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/lockedarray.h b/src/lockedarray.h
index 2b4b099d..c4c83ea9 100644
--- a/src/lockedarray.h
+++ b/src/lockedarray.h
@@ -44,7 +44,7 @@ class LockedArray
bool isLocked() const { return mLocked; };
T getEntry() const { return mData[mCurEntry]; };
- void setEntry(T entry) { mData[mCurEntry] = entry; };
+ void setEntry(T entry) { mData[mCurEntry] = entry; mFilled = true; };
void next();
void prev();
@@ -53,6 +53,11 @@ class LockedArray
unsigned int getSize() const { return mSize; };
+ /**
+ * Clears the array without changing size or data type
+ */
+ void clear();
+
protected:
unsigned int mSize;
@@ -60,11 +65,14 @@ class LockedArray
unsigned int mCurEntry;
bool mLocked;
+
+ bool mFilled;
};
template<class T>
LockedArray<T>::LockedArray(unsigned int size):
- mSize(size), mData(new T[size]), mCurEntry(0), mLocked(false)
+ mSize(size), mData(new T[size]), mCurEntry(0), mLocked(false),
+ mFilled(false)
{
std::fill_n(mData, mSize, (T)0);
}
@@ -105,4 +113,19 @@ void LockedArray<T>::select(unsigned int pos)
mCurEntry = 0;
}
+template<class T>
+void LockedArray<T>::clear()
+{
+ if (!mFilled) return;
+
+ delete [] mData;
+
+ mData = new T[mSize];
+
+ std::fill_n(mData, mSize, (T)0);
+
+ mCurEntry = 0;
+
+ mLocked = false;
+}
#endif