From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/T2MatterArray.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/T2DLL/T2MatterArray.cpp (limited to 'src/T2DLL/T2MatterArray.cpp') 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; +} -- cgit v1.2.3