summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2MatterArray.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
commit37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch)
treeeaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/T2MatterArray.cpp
downloadt2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz
t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip
initial commit
Diffstat (limited to 'src/T2DLL/T2MatterArray.cpp')
-rw-r--r--src/T2DLL/T2MatterArray.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/T2DLL/T2MatterArray.cpp b/src/T2DLL/T2MatterArray.cpp
new file mode 100644
index 0000000..2dee1cc
--- /dev/null
+++ b/src/T2DLL/T2MatterArray.cpp
@@ -0,0 +1,38 @@
+#include "T2MatterArray.h"
+
+T2MatterArray::T2MatterArray(unsigned int jobType, unsigned int validRange, unsigned int startID)
+ : T2ObjectArray(startID)
+{
+ mJobType = jobType;
+ mValidRange = validRange;
+
+ for (unsigned int i = 0; i < 448; i++)
+ mMatter[i].mMatterID = mStartID + i;
+}
+
+void T2MatterArray::SetValidRange(unsigned int validRange) {
+ if (validRange <= 448)
+ mValidRange = validRange;
+}
+
+T2Matter* T2MatterArray::FindUnusedMatter(unsigned int arg) {
+ for (unsigned int i = 0; i < mValidRange; i++) {
+ if (!mMatter[i].IsUsed())
+ return &mMatter[i];
+ }
+
+ if (arg > 0) {
+ unsigned int start = mValidRange;
+ unsigned int end = mValidRange + arg;
+ if (end > 448)
+ end = 448;
+ mValidRange = end;
+
+ for (unsigned int i = start; i < mValidRange; i++) {
+ if (!mMatter[i].IsUsed())
+ return &mMatter[i];
+ }
+ }
+
+ return NULL;
+}