aboutsummaryrefslogtreecommitdiffstats
path: root/al/eax/fx_slot_index.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-05-16 02:08:18 -0700
committerChris Robinson <[email protected]>2022-05-16 02:08:18 -0700
commit65e4c20c27f2acf853e58fd4c26ebc0e3eb926c6 (patch)
tree4fb9a3bffbda4ab8dc1363caa2426cf8e8bbf30e /al/eax/fx_slot_index.cpp
parent83238973ed08225adf03e76b6933e0c209f93fd9 (diff)
Move EAX files to their own sub-directory
Diffstat (limited to 'al/eax/fx_slot_index.cpp')
-rw-r--r--al/eax/fx_slot_index.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/al/eax/fx_slot_index.cpp b/al/eax/fx_slot_index.cpp
new file mode 100644
index 00000000..28b11882
--- /dev/null
+++ b/al/eax/fx_slot_index.cpp
@@ -0,0 +1,71 @@
+#include "config.h"
+
+#include "fx_slot_index.h"
+
+#include "exception.h"
+
+
+namespace
+{
+
+
+class EaxFxSlotIndexException :
+ public EaxException
+{
+public:
+ explicit EaxFxSlotIndexException(
+ const char* message)
+ :
+ EaxException{"EAX_FX_SLOT_INDEX", message}
+ {
+ }
+}; // EaxFxSlotIndexException
+
+
+} // namespace
+
+
+void EaxFxSlotIndex::set(EaxFxSlotIndexValue index)
+{
+ if(index >= EaxFxSlotIndexValue{EAX_MAX_FXSLOTS})
+ fail("Index out of range.");
+
+ emplace(index);
+}
+
+void EaxFxSlotIndex::set(const GUID &guid)
+{
+ if (false)
+ {
+ }
+ else if (guid == EAX_NULL_GUID)
+ {
+ reset();
+ }
+ else if (guid == EAXPROPERTYID_EAX40_FXSlot0 || guid == EAXPROPERTYID_EAX50_FXSlot0)
+ {
+ emplace(0u);
+ }
+ else if (guid == EAXPROPERTYID_EAX40_FXSlot1 || guid == EAXPROPERTYID_EAX50_FXSlot1)
+ {
+ emplace(1u);
+ }
+ else if (guid == EAXPROPERTYID_EAX40_FXSlot2 || guid == EAXPROPERTYID_EAX50_FXSlot2)
+ {
+ emplace(2u);
+ }
+ else if (guid == EAXPROPERTYID_EAX40_FXSlot3 || guid == EAXPROPERTYID_EAX50_FXSlot3)
+ {
+ emplace(3u);
+ }
+ else
+ {
+ fail("Unsupported GUID.");
+ }
+}
+
+[[noreturn]]
+void EaxFxSlotIndex::fail(const char* message)
+{
+ throw EaxFxSlotIndexException{message};
+}