From 96254c41f8fc023501014d36295839fcacb4be10 Mon Sep 17 00:00:00 2001
From: mrb0nk500 <b0nk@b0nk.xyz>
Date: Fri, 3 Feb 2023 17:28:10 -0400
Subject: TMainTask: Add `SET_OR_CLEAR_CHILD_FLAGS` macro

---
 include/pso/TMainTask.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'include/pso')

diff --git a/include/pso/TMainTask.h b/include/pso/TMainTask.h
index 8e7243a..34c2d6c 100644
--- a/include/pso/TMainTask.h
+++ b/include/pso/TMainTask.h
@@ -5,6 +5,20 @@
 #include "pso/macros.h"
 #include "pso/TObject.h"
 
+#define SET_OR_CLEAR_CHILD_FLAGS(flags, old_flags, flag_bit)					\
+	if (flags != old_flags) {								\
+		TMainTask *child;								\
+		u32 bit = 1;									\
+		FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down, child, bit <<= 1) {	\
+			if (main_task_flags & bit) {						\
+				child->set_flag_##flag_bit();					\
+			} else {								\
+				child->clear_flag_##flag_bit();					\
+			}									\
+		}										\
+		old_flags = flags;								\
+	}
+
 class TMainTask : public TObject {
 public:
 	u32 task_flags;
-- 
cgit v1.2.3-13-gbd6f