commit 48c8189c441eaf55adc091b9bdceb07e6877ee20
Author: LeszekKoltunski <leszek@koltunski.pl>
Date:   Wed Apr 23 10:53:29 2025 +0200

    compiles and works now

diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueue.kt b/src/main/java/org/distorted/library/effectqueue/EffectQueue.kt
index 80ac635..35cfa79 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueue.kt
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueue.kt
@@ -42,19 +42,14 @@ abstract class EffectQueue : Slave
     var numEffects: Int = 0     // 'ToBe' will be more than mNumEffects if doWork() hasn't
     var numEffectsToBe: Int = 0 // added them yet (or less if it hasn't removed some yet)
         private set
-    var mEffects: Array<Effect?>
+    lateinit var mEffects: Array<Effect?>
     var mUBF: UniformBlockFloatUniforms? = null
     var mUBI: UniformBlockIntUniforms? = null
     var iD: Long = 0
         private set
     private val mIndex: Int
     private var mCreated = false
-
-    private class Job(var type: Int, var num1: Int, var num2: Int, var bool: Boolean, e: Effect?)
-    {
-        var effect: Effect = e!!
-    }
-
+    private class Job(var type: Int, var num1: Int, var num2: Int, var bool: Boolean, var effect: Effect?)
     private val mJobs: ArrayList<Job>
 
     companion object
@@ -69,15 +64,35 @@ abstract class EffectQueue : Slave
         private const val DETALL = 3
 
         ///////////////////////////////////////////////////////////////////////////////////////////
-        fun allocateQueues(queues: Array<EffectQueue?>, from: Array<EffectQueue?>, flags: Int)
+        @JvmStatic
+        fun createQueues() : Array<EffectQueue?>
+        {
+            val queues: Array<EffectQueue?> = arrayOfNulls(EffectType.LENGTH)
+
+            queues[0] = EffectQueueMatrix()
+            queues[1] = EffectQueueVertex()
+            queues[2] = EffectQueueFragment()
+            queues[3] = EffectQueuePostprocess()
+
+            return queues
+        }
+
+        ///////////////////////////////////////////////////////////////////////////////////////////
+        @JvmStatic
+        fun createQueues(from: Array<EffectQueue?>, flags: Int) : Array<EffectQueue?>
         {
+            val queues: Array<EffectQueue?> = arrayOfNulls(EffectType.LENGTH)
+
             queues[0] = if ((flags and DistortedLibrary.CLONE_MATRIX     ) != 0) from[0] else EffectQueueMatrix()
             queues[1] = if ((flags and DistortedLibrary.CLONE_VERTEX     ) != 0) from[1] else EffectQueueVertex()
             queues[2] = if ((flags and DistortedLibrary.CLONE_FRAGMENT   ) != 0) from[2] else EffectQueueFragment()
             queues[3] = if ((flags and DistortedLibrary.CLONE_POSTPROCESS) != 0) from[3] else EffectQueuePostprocess()
+
+            return queues
         }
 
         ///////////////////////////////////////////////////////////////////////////////////////////
+        @JvmStatic
         fun compute(queues: Array<EffectQueue>, currTime: Long, step: Long)
         {
             (queues[0] as EffectQueueMatrix     ).compute(currTime, step)
@@ -87,6 +102,7 @@ abstract class EffectQueue : Slave
         }
 
         ///////////////////////////////////////////////////////////////////////////////////////////
+        @JvmStatic
         fun send(queues: Array<EffectQueue>, programH: Int, distance: Float, mipmap: Float,
                  projection: FloatArray, inflate: Float, variant: Int)
         {
@@ -114,10 +130,7 @@ abstract class EffectQueue : Slave
 
         ///////////////////////////////////////////////////////////////////////////////////////////
         @JvmStatic
-        fun getMax(index: Int): Int
-        {
-            return InternalStackFrameList.getMax(index)
-        }
+        fun getMax(index: Int): Int = InternalStackFrameList.getMax(index)
     }
 
     ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -239,13 +252,11 @@ abstract class EffectQueue : Slave
         var ret = 0
 
         for (i in 0..<numEffects)
-        {
             if (mEffects[i]!!.name == name)
             {
                 mJobs.add( Job(DETACH,0,0,true,mEffects[i]) )
                 ret++
             }
-        }
 
         if (ret > 0)
         {
@@ -362,9 +373,9 @@ abstract class EffectQueue : Slave
     ///////////////////////////////////////////////////////////////////////////////////////////////
     fun setAssociation(effectID: Long)
     {
-        for (j in 0..<numEffects)
-            if (mEffects[j]!!.id == effectID)
-                mUBI!!.addAssociations(j, mEffects[j]!!)
+        for (i in 0..<numEffects)
+            if (mEffects[i]!!.id == effectID)
+                mUBI!!.addAssociations(i, mEffects[i]!!)
     }
 
     ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -410,13 +421,13 @@ abstract class EffectQueue : Slave
                             mCreated = true
                         }
                 ATTACH ->
-                        if (InternalStackFrameList.getMax(mIndex)>numEffects)  // it is possible that we have first
+                        if (InternalStackFrameList.getMax(mIndex)>numEffects )  // it is possible that we have first
                         {                                                      // added effects and then lowered mMax
                             val position = job.num1
 
                             if (position < 0)
                             {
-                                addNow(numEffects, job.effect)
+                                addNow(numEffects, job.effect!!)
                                 numEffects++
                                 changed = true
                             }
@@ -424,48 +435,34 @@ abstract class EffectQueue : Slave
                             {
                                 System.arraycopy(mEffects, position, mEffects, position+1, numEffects - position)
                                 mUBI!!.makeHole(position, numEffects)
-                                addNow(position, job.effect)
+                                addNow(position, job.effect!!)
                                 numEffects++
                                 changed = true
                             }
                         }
-                        else
-                        {
-                            DistortedLibrary.logMessage("EffectQueue: failed to add effect " + job.effect.name)
-                        }
+                        else DistortedLibrary.logMessage("EffectQueue: failed to add effect " + job.effect!!.name)
 
                 DETACH ->
                         {
-                            var j = 0
-
-                            while (j < numEffects)
-                            {
+                            for (j in 0..<numEffects)
                                 if (mEffects[j] === job.effect)
                                 {
                                     removeNow(j)
                                     changed = true
                                     break
                                 }
-                                j++
-                            }
                         }
 
                 DETALL ->
                         {
-                            var j = 0
-                            while (j < numEffects)
+                            for (j in 0..<numEffects)
                             {
                                 changed = true
                                 mEffects[j] = null
-                                j++
                             }
 
                             // TODO: notify listeners?
-                            /* if( job.bool )
-                                {
-                                // ...
-                                }
-                            */
+                            //  if( job.bool ) { ... }
                             numEffects = 0
                         }
             }
diff --git a/src/main/java/org/distorted/library/main/DistortedEffects.java b/src/main/java/org/distorted/library/main/DistortedEffects.java
index d075fd9..e30ae49 100644
--- a/src/main/java/org/distorted/library/main/DistortedEffects.java
+++ b/src/main/java/org/distorted/library/main/DistortedEffects.java
@@ -54,8 +54,7 @@ public class DistortedEffects
  public DistortedEffects()
     {
     mID = InternalStackFrameList.getNextEffectsID();
-    mQueues = new EffectQueue[EffectType.LENGTH];
-    EffectQueue.allocateQueues(mQueues,null,0);
+    mQueues = EffectQueue.createQueues();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -71,8 +70,7 @@ public class DistortedEffects
   public DistortedEffects(DistortedEffects dc, int flags)
     {
     mID = InternalStackFrameList.getNextEffectsID();
-    mQueues = new EffectQueue[EffectType.LENGTH];
-    EffectQueue.allocateQueues(mQueues,dc.getQueues(),flags);
+    mQueues = EffectQueue.createQueues(dc.getQueues(),flags);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
