commit ad9f5cae43dbc6dbae6c3ede703c2fa5154cc428
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Oct 1 22:01:27 2021 +0200

    Correct a recently introduced bug with restoring records.
    Slightely simplify ObjectType.

diff --git a/src/main/java/org/distorted/objectlib/main/ObjectType.java b/src/main/java/org/distorted/objectlib/main/ObjectType.java
index 0d29dd6e..966426cc 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectType.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectType.java
@@ -25,28 +25,9 @@ import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshSquare;
 import org.distorted.library.type.Static4D;
+
 import org.distorted.objectlib.R;
-import org.distorted.objectlib.objects.TwistyBandaged2Bar;
-import org.distorted.objectlib.objects.TwistyBandaged3Plate;
-import org.distorted.objectlib.objects.TwistyBandagedEvil;
-import org.distorted.objectlib.objects.TwistyBandagedFused;
-import org.distorted.objectlib.objects.TwistyCube;
-import org.distorted.objectlib.objects.TwistyDiamond;
-import org.distorted.objectlib.objects.TwistyDino4;
-import org.distorted.objectlib.objects.TwistyDino6;
-import org.distorted.objectlib.objects.TwistyHelicopter;
-import org.distorted.objectlib.objects.TwistyIvy;
-import org.distorted.objectlib.objects.TwistyJing;
-import org.distorted.objectlib.objects.TwistyKilominx;
-import org.distorted.objectlib.objects.TwistyMegaminx;
-import org.distorted.objectlib.objects.TwistyMirror;
-import org.distorted.objectlib.objects.TwistyPyraminx;
-import org.distorted.objectlib.objects.TwistyRedi;
-import org.distorted.objectlib.objects.TwistyRex;
-import org.distorted.objectlib.objects.TwistySkewb;
-import org.distorted.objectlib.objects.TwistySquare1;
-import org.distorted.objectlib.objects.TwistySquare2;
-import org.distorted.objectlib.objects.TwistyUltimate;
+import org.distorted.objectlib.objects.*;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -87,12 +68,10 @@ public enum ObjectType
   ;
 
   public static final int NUM_OBJECTS = values().length;
-  public static final int MAX_LEVEL;
-  public static final int MAX_SCRAMBLE;
-  public static final int MAX_OBJECT_SIZE;
+  public static final int MAX_LEVEL,MAX_SCRAMBLE,MAX_OBJECT_SIZE;
 
   private final int mRow, mSize, mDBLevels, mNumScrambles;
-  private final int mSmallIconID, mMediumIconID, mBigIconID, mHugeIconID;
+  private final int mSmallIcon, mMediumIcon, mBigIcon, mHugeIcon;
 
   private static final ObjectType[] objects;
   private static int[] mIndices;
@@ -161,7 +140,6 @@ public enum ObjectType
   public static int getColumnCount()
     {
     if( mIndices==null ) setUpColAndRow();
-
     return mColCount;
     }
 
@@ -170,7 +148,6 @@ public enum ObjectType
   public static int getRowCount()
     {
     if( mIndices==null ) setUpColAndRow();
-
     return mRowCount;
     }
 
@@ -179,7 +156,6 @@ public enum ObjectType
   public static int[] getIndices()
     {
     if( mIndices==null ) setUpColAndRow();
-
     return mIndices;
     }
 
@@ -233,16 +209,16 @@ public enum ObjectType
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  ObjectType(int row, int size, int db, int scrambles, int smallIcon, int mediumIcon, int bigIcon, int hugeIcon)
+  ObjectType(int row, int size, int db, int scrambles, int sIcon, int mIcon, int bIcon, int hIcon)
     {
     mRow         = row;
     mSize        = size;
     mDBLevels    = db;
     mNumScrambles= scrambles;
-    mSmallIconID = smallIcon;
-    mMediumIconID= mediumIcon;
-    mBigIconID   = bigIcon;
-    mHugeIconID  = hugeIcon;
+    mSmallIcon   = sIcon;
+    mMediumIcon  = mIcon;
+    mBigIcon     = bIcon;
+    mHugeIcon    = hIcon;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -251,13 +227,13 @@ public enum ObjectType
     {
     switch(size)
       {
-      case 0: return mSmallIconID;
-      case 1: return mMediumIconID;
-      case 2: return mBigIconID;
-      case 3: return mHugeIconID;
+      case 0: return mSmallIcon;
+      case 1: return mMediumIcon;
+      case 2: return mBigIcon;
+      case 3: return mHugeIcon;
       }
 
-    return mSmallIconID;
+    return mSmallIcon;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -268,40 +244,43 @@ public enum ObjectType
     DistortedEffects effects = new DistortedEffects();
     MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
 
-    switch(ordinal())
+    int ord = ordinal();
+    int size= objects[ord].mSize;
+
+    switch(ord)
       {
-      case  0: return new TwistyCube          (objects[ 0].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  1: return new TwistyCube          (objects[ 1].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  2: return new TwistyCube          (objects[ 2].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  3: return new TwistyCube          (objects[ 3].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  4: return new TwistyJing          (objects[ 4].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  5: return new TwistyPyraminx      (objects[ 5].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  6: return new TwistyPyraminx      (objects[ 6].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  7: return new TwistyPyraminx      (objects[ 7].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  8: return new TwistyKilominx      (objects[ 8].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case  9: return new TwistyKilominx      (objects[ 9].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 10: return new TwistyMegaminx      (objects[10].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 11: return new TwistyMegaminx      (objects[11].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 12: return new TwistyUltimate      (objects[12].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 13: return new TwistyDiamond       (objects[13].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 14: return new TwistyDiamond       (objects[14].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 15: return new TwistyDiamond       (objects[15].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 16: return new TwistyDino6         (objects[16].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 17: return new TwistyDino4         (objects[17].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 18: return new TwistyRedi          (objects[18].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 19: return new TwistyHelicopter    (objects[19].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 20: return new TwistySkewb         (objects[20].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 21: return new TwistySkewb         (objects[21].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 22: return new TwistyIvy           (objects[22].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 23: return new TwistyRex           (objects[23].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 24: return new TwistyBandagedFused (objects[24].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 25: return new TwistyBandaged2Bar  (objects[25].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 26: return new TwistyBandaged3Plate(objects[26].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 27: return new TwistyBandagedEvil  (objects[27].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 28: return new TwistySquare1       (objects[28].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 29: return new TwistySquare2       (objects[29].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 30: return new TwistyMirror        (objects[30].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
-      case 31: return new TwistyMirror        (objects[31].mSize, quat, texture, mesh, effects, moves, res, scrWidth);
+      case  0:
+      case  1:
+      case  2:
+      case  3: return new TwistyCube          (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case  4: return new TwistyJing          (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case  5:
+      case  6:
+      case  7: return new TwistyPyraminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case  8:
+      case  9: return new TwistyKilominx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 10:
+      case 11: return new TwistyMegaminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 12: return new TwistyUltimate      (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 13:
+      case 14:
+      case 15: return new TwistyDiamond       (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 16: return new TwistyDino6         (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 17: return new TwistyDino4         (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 18: return new TwistyRedi          (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 19: return new TwistyHelicopter    (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 20:
+      case 21: return new TwistySkewb         (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 22: return new TwistyIvy           (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 23: return new TwistyRex           (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 24: return new TwistyBandagedFused (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 25: return new TwistyBandaged2Bar  (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 26: return new TwistyBandaged3Plate(size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 27: return new TwistyBandagedEvil  (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 28: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 29: return new TwistySquare2       (size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 30:
+      case 31: return new TwistyMirror        (size, quat, texture, mesh, effects, moves, res, scrWidth);
       }
 
     return null;
diff --git a/src/main/java/org/distorted/objectlib/main/TwistyObject.java b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
index b8b08f04..10a9724c 100644
--- a/src/main/java/org/distorted/objectlib/main/TwistyObject.java
+++ b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
@@ -1111,7 +1111,7 @@ public abstract class TwistyObject extends DistortedNode
     mRotationAngleStatic.set0(0.0f);
     mRotationAxis.set( mAxis[axis] );
     mRotationAngle.add(mRotationAngleStatic);
-    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis* ObjectType.MAX_OBJECT_SIZE) , -1);
+    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*ObjectType.MAX_OBJECT_SIZE) , -1);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1129,7 +1129,7 @@ public abstract class TwistyObject extends DistortedNode
       mRotationAngle.resetToBeginning();
       mRotationAngle.add(new Static1D(0));
       mRotationAngle.add(new Static1D(angle));
-      mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis* ObjectType.MAX_OBJECT_SIZE) , -1);
+      mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*ObjectType.MAX_OBJECT_SIZE) , -1);
       mRotateEffect.notifyWhenFinished(listener);
 
       return mRotateEffect.getID();
