(no commit message)
[atyndall/cits2231.git] / scene.c
diff --git a/scene.c b/scene.c
index e6dee1f..c7d5318 100644 (file)
--- a/scene.c
+++ b/scene.c
@@ -276,17 +276,21 @@ void makeMenu() {
     addObjectSubmenu[i] = glutCreateMenu(processObjectEvents);\r
     int startNum = i*11 - (i-1);\r
     for ( int j = startNum - 1; j < (startNum+9); j++ ) {\r
-      if ( j + 1 == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array\r
+      if ( j == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array\r
       glutAddMenuEntry( objectMenuEntries[j], j );\r
     }\r
   }\r
 \r
   // Construct add object menu\r
   int addObjectMenu = glutCreateMenu(processObjectEvents);\r
-  for ( int i = 0; addObjectSubmenu[i]; i++ ) {\r
+  for ( int i = 0; i < menuNumber; i++ ) {\r
     char name[10]; // buffer to hold name\r
     int startNum = i*11 - (i-1);\r
-    sprintf(name, "%d-%d", startNum, startNum + 9);\r
+    int endNum = startNum + 9;\r
+    if ( i == menuNumber - 1 ) { // We're on the last one\r
+      endNum = startNum + 4;\r
+    }\r
+    sprintf(name, "%d-%d", startNum, endNum);\r
     glutAddSubMenu( name, addObjectSubmenu[i] );\r
   }\r
 \r

UCC git Repository :: git.ucc.asn.au