From d6be4c8303f215467c5d036d8308a1aa5613fc44 Mon Sep 17 00:00:00 2001
From: mfranz <mfranz>
Date: Mon, 19 Nov 2007 14:22:55 +0000
Subject: [PATCH] make sure aircraft don't use reserved view indices (0..99) I
 tried it the nice way, but it didn't work. Why is it important to reserve
 indices for fgfs? Because someone has otherwise to go through all aircraft in
 CVS and move aircraft specific views out of the way, every time a system view
 gets added. Been there, done that.

---
 Nasal/view.nas | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Nasal/view.nas b/Nasal/view.nas
index 135fb46c2..a612de557 100644
--- a/Nasal/view.nas
+++ b/Nasal/view.nas
@@ -448,6 +448,16 @@ var fovProp = nil;
 
 _setlistener("/sim/signals/nasal-dir-initialized", func {
 	views = props.globals.getNode("/sim").getChildren("view");
+	# make sure aircraft don't use reserved view indices (0..99)
+	foreach (var v; views) {
+		var index = v.getIndex();
+		if (index > 6 and index < 100) {
+			globals["view"] = nil;
+			die("\n***\n*\n*  Illegal use of reserved view index "
+					~ index ~ ". Use indices >= 100!\n*\n***");
+		}
+	}
+
 	fovProp = props.globals.getNode("/sim/current-view/field-of-view");
 	point.init();
 });