From 1d4ef4383aef63029d77c7906b968ed1834e33e0 Mon Sep 17 00:00:00 2001
From: JoePfeiffer <joseph@pfeifferfamily.net>
Date: Thu, 22 Aug 2024 16:50:43 -0600
Subject: [PATCH] SIM_WARN events take a null source. The Warning being passed
 in includes a set of sources; in case of a SIM_WARN event we'll look the
 source up there

---
 .../info/openrocket/core/simulation/FlightEvent.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/info/openrocket/core/simulation/FlightEvent.java b/core/src/main/java/info/openrocket/core/simulation/FlightEvent.java
index 5802738b3..921dfdf05 100644
--- a/core/src/main/java/info/openrocket/core/simulation/FlightEvent.java
+++ b/core/src/main/java/info/openrocket/core/simulation/FlightEvent.java
@@ -124,8 +124,8 @@ public class FlightEvent implements Comparable<FlightEvent> {
 		this(type, time, source, null);
 	}
 	
-	public FlightEvent(final FlightEvent _sourceEvent, final RocketComponent _comp, final Object _data) {
-		this(_sourceEvent.type, _sourceEvent.time, _comp, _data);
+	public FlightEvent( final FlightEvent sourceEvent, final RocketComponent source, final Object data) {
+		this(sourceEvent.type, sourceEvent.time, source, data);
 	}
 	
 	public FlightEvent( final Type type, final double time, final RocketComponent source, final Object data) {
@@ -248,6 +248,12 @@ public class FlightEvent implements Comparable<FlightEvent> {
 			}
 			break;
 		case SIM_WARN:
+			if (null != this.source) {
+				// rather than making event sources take sets of components, or trying to keep them
+				// in sync with the sources of Warnings, we'll require the event source to be null
+				// and pull the actual sources from the Warning
+				throw new IllegalStateException(type.name()+" event requires null source component; was " + this.source);
+			}	
 			if (( null == this.data ) || ( ! ( this.data instanceof Warning ))) {
 				throw new IllegalStateException(type.name()+" events require Warning objects");
 			}