summaryrefslogtreecommitdiffstats
path: root/tools/debug_pools.patch
blob: fffb0fc8403a3a80089478aef938f8d5c8fbe9ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
diff --git a/core/src/ch/asynk/tankontank/engine/Move.java b/core/src/ch/asynk/tankontank/engine/Move.java
index 06035c3..1bb55b1 100644
--- a/core/src/ch/asynk/tankontank/engine/Move.java
+++ b/core/src/ch/asynk/tankontank/engine/Move.java
@@ -15,12 +15,30 @@ public class Move extends Path implements Iterable<Vector3>
         EXIT;
     }
 
+    static int count = 0;
+
     private static final Pool<Move> movePool = new Pool<Move>()
     {
         @Override
         protected Move newObject() {
             return new Move();
         }
+
+        @Override
+        public Move obtain()
+        {
+            count += 1;
+            System.err.println("   MovePool " + count + "/" + getFree());
+            return super.obtain();
+        }
+
+        @Override
+        public void free(Move cmd)
+        {
+            count -= 1;
+            super.free(cmd);
+            System.err.println("   MovePool " + count + "/" + getFree());
+        }
     };
 
     public static Move get(Pawn pawn, Tile from, Tile to, Orientation orientation, Path path)
diff --git a/core/src/ch/asynk/tankontank/game/Command.java b/core/src/ch/asynk/tankontank/game/Command.java
index 0d39e6c..db3c910 100644
--- a/core/src/ch/asynk/tankontank/game/Command.java
+++ b/core/src/ch/asynk/tankontank/game/Command.java
@@ -19,12 +19,30 @@ public  class Command extends Order
         END_OF_TURN;
     }
 
+    static int count = 0;
+
     private static final Pool<Command> commandPool = new Pool<Command>()
     {
         @Override
         protected Command newObject() {
             return new Command();
         }
+
+        @Override
+        public Command obtain()
+        {
+            count += 1;
+            System.err.println("   CommandPool " + count + "/" + getFree());
+            return super.obtain();
+        }
+
+        @Override
+        public void free(Command cmd)
+        {
+            count -= 1;
+            super.free(cmd);
+            System.err.println("   CommandPool " + count + "/" + getFree());
+        }
     };
 
     public static void clearPool()
diff --git a/core/src/ch/asynk/tankontank/game/Engagement.java b/core/src/ch/asynk/tankontank/game/Engagement.java
index 8f01008..d06ac6d 100644
--- a/core/src/ch/asynk/tankontank/game/Engagement.java
+++ b/core/src/ch/asynk/tankontank/game/Engagement.java
@@ -8,11 +8,29 @@ import com.badlogic.gdx.utils.Disposable;
 
 public class Engagement implements Disposable, Pool.Poolable
 {
+    static int count = 0;
+
     private static final Pool<Engagement> engagementPool = new Pool<Engagement>() {
         @Override
         protected Engagement newObject() {
             return new Engagement();
         }
+
+        @Override
+        public Engagement obtain()
+        {
+            count += 1;
+            System.err.println("   EngagementPool " + count + "/" + getFree());
+            return super.obtain();
+        }
+
+        @Override
+        public void free(Engagement cmd)
+        {
+            count -= 1;
+            super.free(cmd);
+            System.err.println("   EngagementPool " + count + "/" + getFree());
+        }
     };
 
     public static Engagement get(Unit attacker, Unit defender)